Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix ProjectionGroup Directions
  • Loading branch information
WandererFan authored and yorikvanhavre committed Oct 31, 2016
1 parent a51b3f7 commit a82a50a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
49 changes: 29 additions & 20 deletions src/Mod/TechDraw/App/DrawProjGroup.cpp
Expand Up @@ -338,59 +338,68 @@ int DrawProjGroup::purgeProjections()

void DrawProjGroup::setViewOrientation(DrawProjGroupItem *v, const char *projType) const
{
Base::Vector3d dir, xDir;
Base::Vector3d dir;
// Base::Vector3d dir, xDir;

// Traditional orthographic
if(strcmp(projType, "Front") == 0) {
dir.Set(0, 1, 0);
xDir.Set(1, 0, 0);
dir.Set(0, -1, 0);
// xDir.Set(1, 0, 0);

} else if(strcmp(projType, "Rear") == 0) {
dir.Set(0, -1, 0);
xDir.Set(-1, 0, 0);
dir.Set(0, 1, 0);
// xDir.Set(-1, 0, 0);

} else if(strcmp(projType, "Right") == 0) {
dir.Set(1, 0, 0);
xDir.Set(0, -1, 0);
// xDir.Set(0, -1, 0);

} else if(strcmp(projType, "Left") == 0) {
dir.Set(-1, 0, 0);
xDir.Set(0, 1, 0);
// xDir.Set(0, 1, 0);

} else if(strcmp(projType, "Top") == 0) {
dir.Set(0, 0, 1);
xDir.Set(1, 0, 0);
// xDir.Set(1, 0, 0);

} else if(strcmp(projType, "Bottom") == 0) {
dir.Set(0, 0, -1);
xDir.Set(1, 0, 0);
// xDir.Set(1, 0, 0);

// Isometric
} else if(strcmp(projType, "FrontTopLeft") == 0) {
dir.Set(-1/sqrt(3), 1/sqrt(3), 1/sqrt(3));
xDir.Set(sqrt(2)/2.0, sqrt(2.0)/2.0, 0);
dir.Set(-1,-1,1);
dir.Normalize();
// dir.Set(-1/sqrt(3), 1/sqrt(3), 1/sqrt(3));
// xDir.Set(sqrt(2)/2.0, sqrt(2.0)/2.0, 0);

} else if(strcmp(projType, "FrontTopRight") == 0) {
dir.Set(1/sqrt(3), 1/sqrt(3), 1/sqrt(3));
xDir.Set(sqrt(2)/2.0, -sqrt(2.0)/2.0, 0);
dir.Set(1, -1, 1);
dir.Normalize();
// dir.Set(1/sqrt(3), 1/sqrt(3), 1/sqrt(3));
// xDir.Set(sqrt(2)/2.0, -sqrt(2.0)/2.0, 0);

} else if(strcmp(projType, "FrontBottomRight") == 0) {
dir.Set(1/sqrt(3), 1/sqrt(3), -1/sqrt(3));
xDir.Set(sqrt(2)/2.0, -sqrt(2.0)/2.0, 0);
dir.Set(1, -1, -1);
dir.Normalize();
// dir.Set(1/sqrt(3), 1/sqrt(3), -1/sqrt(3));
// xDir.Set(sqrt(2)/2.0, -sqrt(2.0)/2.0, 0);

} else if(strcmp(projType, "FrontBottomLeft") == 0) {
dir.Set(-1/sqrt(3), 1/sqrt(3), -1/sqrt(3));
xDir.Set(sqrt(2)/2.0, sqrt(2.0)/2.0, 0);
dir.Set(-1, -1, -1);
dir.Normalize();
// dir.Set(-1/sqrt(3), 1/sqrt(3), -1/sqrt(3));
// xDir.Set(sqrt(2)/2.0, sqrt(2.0)/2.0, 0);

} else {
throw Base::Exception("Unknown view type in DrawProjGroup::setViewOrientation()");
}

dir = viewOrientationMatrix.getValue() * dir;
xDir = viewOrientationMatrix.getValue() * xDir;
dir = viewOrientationMatrix.getValue() * dir; //multiply std dir by transform matrix
//xDir = viewOrientationMatrix.getValue() * xDir;

v->Direction.setValue(dir);
v->XAxisDirection.setValue(xDir);
//v->XAxisDirection.setValue(xDir);
}

void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const
Expand Down
18 changes: 18 additions & 0 deletions src/Mod/TechDraw/Gui/TaskProjGroup.ui
Expand Up @@ -179,27 +179,39 @@
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="2">
<widget class="QPushButton" name="butCWRotate">
<property name="toolTip">
<string>About 3D Y</string>
</property>
<property name="text">
<string>Spin CW</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="butRightRotate">
<property name="toolTip">
<string>About 3D Z</string>
</property>
<property name="text">
<string>&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="butCCWRotate">
<property name="toolTip">
<string>About 3D Y</string>
</property>
<property name="text">
<string>Spin CCW</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="butTopRotate">
<property name="toolTip">
<string>About 3D X</string>
</property>
<property name="text">
<string>/\</string>
</property>
Expand All @@ -217,13 +229,19 @@
</item>
<item row="3" column="0">
<widget class="QPushButton" name="butLeftRotate">
<property name="toolTip">
<string>About 3D Y</string>
</property>
<property name="text">
<string>&lt;</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="butDownRotate">
<property name="toolTip">
<string>About 3D X</string>
</property>
<property name="text">
<string>\/</string>
</property>
Expand Down

0 comments on commit a82a50a

Please sign in to comment.