-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Expose functions for reproducing 3D view shortcuts #654
Conversation
👍 |
@@ -792,6 +783,56 @@ void vtkThreeDViewInteractorStyle::SetModelDisplayableManager( | |||
} | |||
|
|||
//---------------------------------------------------------------------------- | |||
void vtkThreeDViewInteractorStyle::RotateToPosterior(bool inverse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axis labels have been made configurable. In several places in the code, labels or orientations are still hardcoded, but we should really move away from that.
Therefore, we shouldn't use vtkThreeDViewInteractorStyle::RotateToPosterior(bool inverse), but something like this:
vtkThreeDViewInteractorStyle::RotateToViewAxis(const std::string& axisLabel)
axisLabel is "L", "R", ... is one of the labels in vtkMRMLAbstractViewNode::AxisLabels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll look into that. However, it looks like AxisLabel
can be modified to customize the labels with SetAxisLabel
. Should we pass an integer which defined the index of the axis instead? Or just go through all the values of AxisLabel
and check if it exists, then infer how to rotate based on the axis id?
Also... we would have a RotateToViewAxis(int axis)
in the qMRMLThreeDView, wrapping a RotateToViewAxis(int axis)
in the vtkThreeDViewInteractorStyle, wrapping a RotateTo
in vtkMRMLCameraNode. Do we really need all this? @vovythevov, do you remember why this was implemented in the interactor style as well as the qMRMLThreeDView? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the Nth axis label by calling const char* vtkMRMLAbstractViewNode::GetAxisLabel(int labelIndex). If the view node is not accessible or you would always need to rotate to Nth axis then you can have a method like:
vtkThreeDViewInteractorStyle::RotateToViewAxis(int direction) // direction is in 0..5, same way as in abstract view node axis index (-X, +X, ..., -Z, +Z)
or
vtkThreeDViewInteractorStyle::RotateToViewAxis(int axis, bool positiveDirection) --- where axis is in 0..2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Do we want this in vtkThreeDViewInteractorStyle
as well as qMRMLThreeDView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could be enough to just have it in qMRMLThreeDView.
{ | ||
if (!this->CameraNode) | ||
{ | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log warning instead of just silently fail
5f8c2cc
to
153f8fb
Compare
Changes made. In the future, it could be interesting to consolidate |
vtkThreeDViewInteractorStyle::SafeDownCast(this->interactorStyle()); | ||
if (!style) | ||
{ | ||
QDebug(QtCriticalMsg) << "qMRMLThreeDView::RotateToViewAxis: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use simply qCritical or qWarning?
Q_D(qMRMLThreeDView); | ||
if (!d->MRMLViewNode) | ||
{ | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log warning
return; | ||
} | ||
} | ||
QDebug(QtWarningMsg) << "qMRMLThreeDView::RotateToViewAxis: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qWarning
vtkThreeDViewInteractorStyle::SafeDownCast(this->interactorStyle()); | ||
if (!style) | ||
{ | ||
QDebug(QtCriticalMsg) << "qMRMLThreeDView::RotateToViewAxis: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qWarning
Thank you, it looks good! If you make those few trivial changes then it should be ready to merge. |
Before this, there was no simple way to ask programaticaly for the view to reset the camera like it does when pressing the key pad shortcut keys. Now the user can do this directly from python. This is potentially useful for the scripted modules as well.
153f8fb
to
7d28ea3
Compare
Integrated in r25651 |
Before this, there was no simple way to ask programaticaly for the view
to reset the camera like it does when pressing the key pad shortcut keys.
Now the user can do this directly from python. This is potentially useful
for the scripted modules as well.
by @vovythevov