Gui: Added FreeTurntable orbit style (#8048)

* Added FreeTurntable orbit style
This commit is contained in:
Nabos
2022-12-20 03:21:46 +01:00
committed by GitHub
parent 6b5e015f94
commit 9cda82cf20
4 changed files with 61 additions and 30 deletions

View File

@@ -279,10 +279,11 @@ Select a set and then press the button to view said configurations.</string>
<property name="toolTip">
<string>Rotation orbit style.
Trackball: moving the mouse horizontally will rotate the part around the y-axis
Turntable: the part will be rotated around the z-axis.</string>
Turntable: the part will be rotated around the z-axis (with constrained axes).
Free Turntable: the part will be rotated around the z-axis.</string>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<item>
<property name="text">
@@ -294,6 +295,11 @@ Turntable: the part will be rotated around the z-axis.</string>
<string>Trackball</string>
</property>
</item>
<item>
<property name="text">
<string>Free Turntable</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">

View File

@@ -85,7 +85,8 @@ class FCSphereSheetProjector : public SbSphereSheetProjector {
public:
enum OrbitStyle {
Turntable,
Trackball
Trackball,
FreeTurntable
};
FCSphereSheetProjector(const SbSphere & sph, const SbBool orienttoeye = true)
@@ -114,33 +115,46 @@ public:
SbRotation rot = inherited::getRotation(point1, point2);
if (orbit == Trackball)
return rot;
// 0000333: Turntable camera rotation
SbVec3f axis;
float angle;
rot.getValue(axis, angle);
SbVec3f dif = point1 - point2;
if (fabs(dif[1]) > fabs(dif[0])) {
SbVec3f xaxis(1,0,0);
if (dif[1] < 0)
angle = -angle;
rot.setValue(xaxis, angle);
}
else {
SbVec3f zaxis(0,0,1);
this->worldToScreen.multDirMatrix(zaxis, zaxis);
if (zaxis[1] < 0) {
if (dif[0] < 0)
else if (orbit == Turntable) {
SbVec3f axis;
float angle;
rot.getValue(axis, angle);
SbVec3f dif = point1 - point2;
if (fabs(dif[1]) > fabs(dif[0])) {
SbVec3f xaxis(1,0,0);
if (dif[1] < 0)
angle = -angle;
rot.setValue(xaxis, angle);
}
else {
if (dif[0] > 0)
angle = -angle;
SbVec3f zaxis(0,0,1);
this->worldToScreen.multDirMatrix(zaxis, zaxis);
if (zaxis[1] < 0) {
if (dif[0] < 0)
angle = -angle;
}
else {
if (dif[0] > 0)
angle = -angle;
}
rot.setValue(zaxis, angle);
}
rot.setValue(zaxis, angle);
}
return rot;
return rot;
} else {
// Turntable without constraints
SbRotation zrot, xrot;
SbVec3f dif = point1 - point2;
SbVec3f zaxis(1,0,0);
zrot.setValue(zaxis, dif[1]);
SbVec3f xaxis(0,0,1);
this->worldToScreen.multDirMatrix(xaxis, xaxis);
xrot.setValue(xaxis, -dif[0]);
return zrot * xrot;
}
}
void setOrbitStyle(OrbitStyle style)

View File

@@ -99,7 +99,8 @@ public:
enum OrbitStyle {
Turntable,
Trackball
Trackball,
FreeTurntable
};
enum class RotationCenterMode {

View File

@@ -333,6 +333,7 @@ def retranslateUi():
aCompact.setText(translate("NavigationIndicator", "Compact"))
aTooltip.setText(translate("NavigationIndicator", "Tooltip"))
aTurntable.setText(translate("NavigationIndicator", "Turntable"))
aFreeTurntable.setText(translate("NavigationIndicator", "FreeTurntable"))
aTrackball.setText(translate("NavigationIndicator", "Trackball"))
a0.setText(translate("NavigationIndicator", "Undefined"))
@@ -358,13 +359,18 @@ gOrbit = QtGui.QActionGroup(menuSettings)
aTurntable = QtGui.QAction(gOrbit)
aTurntable.setObjectName("NavigationIndicator_Turntable")
aTurntable.setCheckable(True)
aFreeTurntable = QtGui.QAction(gOrbit)
aFreeTurntable.setObjectName("NavigationIndicator_FreeTurntable")
aFreeTurntable.setCheckable(True)
aTrackball = QtGui.QAction(gOrbit)
aTrackball.setObjectName("NavigationIndicator_Trackball")
aTrackball.setCheckable(True)
menuOrbit.addAction(aFreeTurntable)
menuOrbit.addAction(aTurntable)
menuOrbit.addAction(aTrackball)
menuSettings.addMenu(menuOrbit)
menuSettings.addSeparator()
menuSettings.addAction(aCompact)
@@ -504,18 +510,22 @@ def onOrbit():
if aTurntable.isChecked():
pView.SetInt("OrbitStyle", 0)
else:
elif aTrackball.isChecked():
pView.SetInt("OrbitStyle", 1)
elif aFreeTurntable.isChecked():
pView.SetInt("OrbitStyle", 2)
def onOrbitShow():
"""Set turntable or trackball orbit style."""
gOrbit.blockSignals(True)
if pView.GetInt("OrbitStyle", 1):
aTrackball.setChecked(True)
else:
if pView.GetInt("OrbitStyle", 0):
aTurntable.setChecked(True)
elif pView.GetInt("OrbitStyle", 1):
aTrackball.setChecked(True)
elif pView.GetInt("OrbitStyle", 2):
aFreeTurntable.setChecked(True)
gOrbit.blockSignals(False)