Improve code simplicity/readability
This commit is contained in:
committed by
WandererFan
parent
bcfcd0a337
commit
4f9e5cd464
@@ -508,7 +508,7 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//removes all DPGI - used when deleting DPG
|
||||
int DrawProjGroup::purgeProjections()
|
||||
@@ -1231,73 +1231,32 @@ void DrawProjGroup::updateSecondaryDirs()
|
||||
recomputeChildren();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateRight()
|
||||
{
|
||||
//Front -> Right -> Rear -> Left -> Front
|
||||
void DrawProjGroup::rotate(const std::string &rotationdirection) {
|
||||
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
|
||||
newDirs = getDirsFromFront("Left");
|
||||
if(rotationdirection == "Right") newDirs = getDirsFromFront("Left"); // Front -> Right -> Rear -> Left -> Front
|
||||
else if(rotationdirection == "Left") newDirs = getDirsFromFront("Right"); // Front -> Left -> Rear -> Right -> Front
|
||||
else if(rotationdirection == "Up") newDirs = getDirsFromFront("Bottom"); // Front -> Top -> Rear -> Bottom -> Front
|
||||
else if(rotationdirection == "Down") newDirs = getDirsFromFront("Top"); // Front -> Bottom -> Rear -> Top -> Front
|
||||
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
anchor->Direction.setValue(newDirs.first);
|
||||
anchor->XDirection.setValue(newDirs.second);
|
||||
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateLeft()
|
||||
void DrawProjGroup::spin(const std::string &spindirection)
|
||||
{
|
||||
//Front -> Left -> Rear -> Right -> Front
|
||||
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
|
||||
newDirs = getDirsFromFront("Right");
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
anchor->Direction.setValue(newDirs.first);
|
||||
anchor->XDirection.setValue(newDirs.second);
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
double angle;
|
||||
if(spindirection == "CW") angle = M_PI / 2.0; // Top -> Right -> Bottom -> Left -> Top
|
||||
if(spindirection == "CCW") angle = - M_PI / 2.0; // Top -> Left -> Bottom -> Right -> Top
|
||||
|
||||
void DrawProjGroup::rotateUp()
|
||||
{
|
||||
//Front -> Top -> Rear -> Bottom -> Front
|
||||
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
|
||||
newDirs = getDirsFromFront("Bottom");
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
anchor->Direction.setValue(newDirs.first);
|
||||
anchor->XDirection.setValue(newDirs.second);
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateDown()
|
||||
{
|
||||
//Front -> Bottom -> Rear -> Top -> Front
|
||||
std::pair<Base::Vector3d,Base::Vector3d> newDirs;
|
||||
newDirs = getDirsFromFront("Top");
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
anchor->Direction.setValue(newDirs.first);
|
||||
anchor->XDirection.setValue(newDirs.second);
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::spinCW()
|
||||
{
|
||||
//Top -> Right -> Bottom -> Left -> Top
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
double angle = M_PI / 2.0;
|
||||
Base::Vector3d org(0.0,0.0,0.0);
|
||||
Base::Vector3d curRot = anchor->getXDirection();
|
||||
Base::Vector3d curDir = anchor->Direction.getValue();
|
||||
Base::Vector3d newRot = DrawUtil::vecRotate(curRot,angle,curDir,org);
|
||||
anchor->XDirection.setValue(newRot);
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::spinCCW()
|
||||
{
|
||||
//Top -> Left -> Bottom -> Right -> Top
|
||||
DrawProjGroupItem* anchor = getAnchor();
|
||||
double angle = M_PI / 2.0;
|
||||
Base::Vector3d org(0.0,0.0,0.0);
|
||||
Base::Vector3d curRot = anchor->getXDirection();
|
||||
Base::Vector3d curDir = anchor->Direction.getValue();
|
||||
Base::Vector3d newRot = DrawUtil::vecRotate(curRot,-angle,curDir,org);
|
||||
anchor->XDirection.setValue(newRot);
|
||||
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
@@ -124,12 +124,8 @@ public:
|
||||
|
||||
void updateSecondaryDirs();
|
||||
|
||||
void rotateRight(void);
|
||||
void rotateLeft(void);
|
||||
void rotateUp(void);
|
||||
void rotateDown(void);
|
||||
void spinCW(void);
|
||||
void spinCCW(void);
|
||||
void rotate(const std::string &rotationdirection);
|
||||
void spin(const std::string &spindirection);
|
||||
|
||||
void dumpISO(const char * title);
|
||||
std::vector<DrawProjGroupItem*> getViewsAsDPGI();
|
||||
|
||||
@@ -214,20 +214,14 @@ void TaskProjGroup::rotateButtonClicked(void)
|
||||
if ( multiView && ui ) {
|
||||
const QObject *clicked = sender();
|
||||
|
||||
//change Front View Dir by 90
|
||||
if ( clicked == ui->butTopRotate ) multiView->rotate("Up");
|
||||
else if (clicked == ui->butDownRotate) multiView->rotate("Down");
|
||||
else if (clicked == ui->butRightRotate) multiView->rotate("Right");
|
||||
else if (clicked == ui->butLeftRotate) multiView->rotate("Left");
|
||||
else if (clicked == ui->butCWRotate ) multiView->spin("CW");
|
||||
else if (clicked == ui->butCCWRotate) multiView->spin("CCW");
|
||||
|
||||
if ( clicked == ui->butTopRotate ) { //change Front View Dir by 90
|
||||
multiView->rotateUp();
|
||||
} else if ( clicked == ui->butDownRotate) {
|
||||
multiView->rotateDown();
|
||||
} else if ( clicked == ui->butRightRotate) {
|
||||
multiView->rotateRight();
|
||||
} else if ( clicked == ui->butLeftRotate) {
|
||||
multiView->rotateLeft();
|
||||
} else if ( clicked == ui->butCWRotate ) {
|
||||
multiView->spinCW();
|
||||
} else if ( clicked == ui->butCCWRotate) {
|
||||
multiView->spinCCW();
|
||||
}
|
||||
setUiPrimary();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user