-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Added navigation features to the sagittal and centerline GUI #1545
Conversation
The user can now nagivate using the arrow keys. Also, update the canvas dragging the mouse along the canvas. Implements #1501
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.
So in other words: Navigating the sagittal plane: up/down traverses the axial plane and the left/right traverses the corrinal plane. And navigating the axial plane: up/down traverses the corrinal plane and left/right traverses the sagittal plane. Is that correct? |
i would sum up points as follows:
|
@jcohenadad @peristeri I agree for PropSeg. No need for keys control. |
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.
Nice ! I added some comments. I just missed function and classes docstrings documentation.
spinalcordtoolbox/gui/base.py
Outdated
self.setWindowTitle(self.params.dialog_title) | ||
|
||
def increment_vertical_nav(self): | ||
pass |
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 think it is better to raise a NotImplementedError
here and on the other abstract methods.
spinalcordtoolbox/gui/base.py
Outdated
pass | ||
|
||
def decrement_vertical_nav(self): | ||
pass |
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.
Same here.
spinalcordtoolbox/gui/base.py
Outdated
pass | ||
|
||
def increment_horizontal_nav(self): | ||
pass |
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.
Same here.
spinalcordtoolbox/gui/base.py
Outdated
pass | ||
|
||
def decrement_horizontal_nav(self): | ||
pass |
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.
Same here.
spinalcordtoolbox/gui/base.py
Outdated
@@ -114,8 +114,26 @@ def _init_ui(self): | |||
QtGui.QShortcut(QtGui.QKeySequence.Save, self, self.on_save_quit) | |||
QtGui.QShortcut(QtGui.QKeySequence.Quit, self, self.close) | |||
|
|||
QtGui.QShortcut(QtGui.QKeySequence.MoveToNextChar, self, self.increment_vertical_nav) |
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.
There are a lot of shortcuts being added here, maybe it's worth creating mapping list like (keysequence, func) and then iterating over it on a loop to add the shortcuts.
spinalcordtoolbox/gui/base.py
Outdated
self.setWindowTitle(self.params.dialog_title) | ||
|
||
def increment_vertical_nav(self): |
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.
Functions without documentation.
spinalcordtoolbox/gui/centerline.py
Outdated
@@ -138,15 +151,15 @@ def _init_controls(self, parent): | |||
custom_mode.setToolTip('Manually select the axis slice on sagittal plane') | |||
custom_mode.toggled.connect(self.on_toggle_mode) | |||
custom_mode.mode = 'CUSTOM' | |||
custom_mode.sagittal_title = 'Select an axial slice' | |||
custom_mode.sagittal_title = 'Select an axial slice.\n%s' % self.params.subtitle |
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.
Consider using the new style string formatting, like the one below where you use the .format()
.
expected = [(15, 45, 33, 1), (30, 51, 35, 1), (60, 71, 31, 1)] | ||
points = [(x + controller.INTERVAL, y, z) for x, y, z, _ in expected] | ||
controller = self._init_auto() | ||
expected = [(0, 45, 33, 1), (160, 51, 35, 1), (319, 71, 31, 1)] |
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.
Another reason to have namedtuple
or something similar here, what is the fourth element on each of these tuples ?
spinalcordtoolbox/gui/widgets.py
Outdated
for i in self.annotations: | ||
i.remove() | ||
self.annotations = [] | ||
if hasattr(self, 'annotations'): |
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 think it would be better to always have this attribute here. And then you keep it as an empty list when there are no annotations. Then you can do something like:
for i in self.annotations:
i.remove()
self.annotations.clear()
without having to do the check using hasattr()
.
if self._plot_points: | ||
controller = self._parent._controller | ||
logger.debug('Plotting points {}'.format(controller.points)) | ||
points = [x for x in controller.points if x[0] == controller.position[0]] |
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 think it's better to add some comments on what is happening here, why the except ValueError
below is required, etc.
…eg because it was previously too large for mode init-mask
…s wrongly calling nz param, which is orientation dependent)
The user can now navigate using the arrow keys. Also, update the canvas dragging
the mouse along the canvas.
Implements #1501