enh(ui): contextual mode and menu for landmarks and distances
Description
Over the past few weeks, we have iterated over landmarks and distances management. However, we think we can improve even more and harmonize them.
Proposal
We introduce a landmark edition mode, and a distance edition mode. This replaces the add/remove buttons in SightViewer. In the following, we call fiducials either landmarks or distances.
- When clicked, the mouse pointer switches to a cross and allows to add points/distances just by clicking/touching.
- When mouse hover a fiducial, it highlights and/or scales in size to get a feedback. The mouse pointer should also change to another icon. If we click/touch, a contextual speed dial menu pop-ups with:
- a pen button to rename the fiducial
- a cross button to remove the fiducial
- a size slider to scale the fiducial (ideally an icon button and when pressing, it pop-ups the slider which disappears when releasing)
- a color picker
- a group picker for the landmarks
Functional specifications
After discussing, we decided that in the end most of these buttons actually won't be necessary. Only one button will appear when clicking on a fiducial in edit mode, the remove button (which should be a bin icon, not a cross icon, so that the user understands correctly that it is a delete button, not a "close this popup" button). This button should be placed upward the landmark to make it easier to use in touchscreen context. The fiducial can be renamed by clicking on the label. This behavior can be disabled in the configuration of the adaptor.
Technical specifications
With this feature, the SLandmarks and SImageMultiDistances adaptor will have to create buttons and line edits among other things. It means that they must use in one way or another Qt. SLandmarks and SImageMultiDistances are currently in module::scene3d, which can't depend on Qt. This means that we must either create an abstract layer to avoid SLandmarks and SImageMultiDistances to directly depends on Qt, or we move SLandmarks and SImageMultiDistances to module::scene3dQt, which depends on Qt. Out of simplicity, we decided the latter.
Since the "context menu" is only one icon and it is shown upward the fiducial, we can't use a traditional context menu (the one that appears one bottom right of your cursor when you right-click). Instead, we'll use plain QPushButtons.
Right now, the fiducial name labels are QLabels. They can't be modified in any way by the user. We should use QLineEdit for that. So we must either stop using QLabels for fiducial name labels and directly use QLineEdits so they can be modified by the user (and QLineEdits can be marked read-only if necessary) or keep QLabels but "transform" them (make them hidden and place QLineEdits at the same place) when switching to edit mode. If we can easily make QLineEdit background transparent and change the font color, we could stick to the former, else we may have to do the latter. Finally, the labels tend to get on top of the fiducials, which not only makes them harder to reader, but will also make harder to select the fiducial if the label is on top. The label position algorithm should be tweaked so that the label is always placed next to the fiducial and not on top of it.
Moving SLandmarks to scene3dQt is more complicated than anticipated, since it depends on scene3d::adaptor::SMaterial, and scene3dQt::SLandmarks can't depend directly on another module. To workaround this, a new interface, IMaterialAdaptor, is created, whose scene3d::adaptor::SMaterial inherits from, and SLandmarks reference it instead of SMaterial.
Test plan
GUI tests.