Computer Assited Medical Intervention Tool Kit  version 5.0
InteractiveViewer.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef INTERACTIVE_VIEWER_H
28 #define INTERACTIVE_VIEWER_H
29 
30 // -- Core stuff
31 #include "CamiTKAPI.h"
32 #include "Component.h"
33 #include "Viewer.h"
34 #include "RendererWidget.h"
35 #include "InteractiveViewerFrame.h"
36 
37 //-- QT stuff
38 #include <QPushButton>
39 #include <QWidgetAction>
40 #include <QComboBox>
41 class QToolBar;
42 class QFrame;
43 
44 //-- vtk stuff
45 #include <vtkType.h>
46 #include <vtkSmartPointer.h>
47 
48 //-- vtk stuff classes
49 class vtkActor;
50 class vtkPicker;
51 class vtkProp;
52 class vtkObject;
53 class vtkCamera;
54 class vtkEventQtSlotConnect;
55 
56 namespace camitk {
57 // -- Core stuff classes
58 class SliderSpinBoxWidget;
59 class GeometricObject;
60 class InterfaceGeometry;
61 class InterfaceBitMap;
62 class InteractiveViewer;
63 class MeshDataFilterModel;
64 class PropertyObject;
65 class Property;
66 
67 using vtkSmartPointerCamera = vtkSmartPointer<vtkCamera>;
68 
113  Q_OBJECT
114  Q_ENUMS(HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation); // so that it can be used in property editor
115 
116 public:
118  enum ViewerType {
120  GEOMETRY_VIEWER
121  };
122 
125  enum PickingMode {
131  NO_PICKING
132  };
133 
139  OFF,
141  SELECTION_ONLY
142  };
143 
145 
149  Q_INVOKABLE InteractiveViewer(QString& name, camitk::InteractiveViewer::ViewerType type);
150 
152  virtual ~InteractiveViewer() override;
153 
155  QString getName() const;
157 
162  void refresh(Viewer* whoIsAsking = nullptr) override;
163 
165  QWidget* getWidget() override;
166 
168  QObject* getPropertyObject() override;
169 
171  QMenu* getMenu() override;
172 
174  QToolBar* getToolBar() override;
176 
180 
182  void refreshRenderer();
183 
185  void resetCamera();
186 
188  void setActiveCamera(QString cameraName);
189 
193  vtkSmartPointer<vtkCamera> getCamera(QString cameraName = "default");
194 
196  void screenshot(QString);
197 
198 public slots:
200  void screenshot();
202 
203 public:
205  virtual void setGradientBackground(bool);
206 
208  virtual void setBackgroundColor(QColor);
209 
210 public slots:
215  void setBackfaceCulling(bool);
216 
218  void setScreenshotAction(bool);
219 
227  void setLinesAsTubes(bool tubes);
228 
229 public:
231  void keyPressEvent(QKeyEvent* e);
232 
234  virtual void setHighlightMode();
235 
238  return rendererWidget;
239  }
240 
242 
246  void setColorScale(bool);
247 
249  bool getColorScale() const;
250 
256  void setColorScaleMinMax(double m, double M);
257 
261  void setColorScaleTitle(QString t);
262 
264  void initPicking(PickingMode);
265 
267  void getBoundsOfSelected(double* bound);
268 
270  void getBounds(double* bound);
271 
273  void setSideFrameVisible(bool);
275 
276 public slots:
277 
280 
282  void sliderChanged(int);
283 
285  void xAngleChanged(double angle);
286 
288  void yAngleChanged(double angle);
289 
291  void zAngleChanged(double angle);
292 
294  void toggleLogo(bool);
296 
297 protected:
298 
300  void init();
301 
313 
315  void initSettings();
316 
319 
321  void toggleInterpolation();
322 
324  void resetLUT();
325 
327  void updateSelectionDisplay(Component*);
328 
330  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
331 
333  void addActor(Component*, vtkSmartPointer<vtkProp>);
334 
336  void removeAllActors(Component*);
337 
340 
342  QMap<QString, vtkSmartPointerCamera> cameraMap;
344 
349 
353 
356 
358  QFrame* sideFrame;
359 
362 
364  friend void InteractiveViewerFrame::keyPressEvent(QKeyEvent* e);
365 
367  QMenu* viewerMenu;
368 
370  QToolBar* viewerToolbar;
371 
373  QComboBox* scalarDataComboBox;
374 
376 
378  void initActions();
379 
381  void updateActions();
382 
385 
388  QAction* surfaceAction;
389  QAction* wireframeAction;
390  QAction* pointsAction;
391  QAction* colorAction;
392  QAction* glyphAction;
393  QWidgetAction* scalarDataColorAction;
394 
399 
403 
408 
411 
414 
417 
420 
423 
426 
429 
432 
434  QAction* pickPointAction;
435  QAction* pickCellAction;
438 
440 
444 
448  std::vector <Component*> pickedComponent;
449 
452 
454  bool isPicking;
455 
458 
461 
464 
465  vtkSmartPointer<vtkEventQtSlotConnect> connector;
466 
468 
473  QString whatsThis;
474 
477 
479  void initWhatsThis();
480 
482  void startWhatsThisSection(const QString& title = "");
483 
485  void endWhatsThisSection();
486 
488  void addWhatsThisItem(const QString& key, const QString& description);
490 
495 
499 
504 
509 
514 
519 
524 
529 
534 
538  void createProperties();
539 
546  bool eventFilter(QObject* object, QEvent* event) override;
547 
549 
550 protected slots:
555  void renderingActorsChanged();
556 
557  void highlightModeChanged(QAction* selectedAction);
558 
559  void cameraOrientationChanged(QAction* selectedAction);
560 
561  void viewControlModeChanged(QAction*);
562 
563  void backgroundColor();
564 
565  void toggleAxes(bool);
566 
567  void toggleOrientationDecorations(bool);
568 
569  void pickingModeChanged(QAction*);
570 
572  void picked();
573 
574  void rightClick();
575 
577  void setLabel(bool);
578 
579  void setGlyph(bool);
580 
582 
583 
584 
585 };
586 
587 }
588 
590 
591 #endif
592 
593 //**************************************************************************
#define CAMITK_API
Definition: CamiTKAPI.h:49
const char * description
Definition: applications/cepgenerator/main.cpp:38
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
InteractiveViewerFrame is the basic container for the InteractiveViewer widget.
Definition: InteractiveViewerFrame.h:50
void keyPressEvent(QKeyEvent *) override
Handle keyboard events in the scene frame, just send everything to InteractiveViewer!
Definition: InteractiveViewerFrame.cpp:37
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:112
QToolBar * viewerToolbar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:370
QAction * toggleAxesAction
button allows one to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:413
Property * screenshotActionProperty
Property that tells whether the screenshot action is visible or not.
Definition: InteractiveViewer.h:528
QAction * glyphAction
Definition: InteractiveViewer.h:392
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:406
QToolBar * screenshotActionMenu
the screenshot action is inside this menu (in the slice viewer side bar)
Definition: InteractiveViewer.h:361
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:396
Property * backfaceCullingProperty
Property that tells whether the viewer uses the backface culling option or not.
Definition: InteractiveViewer.h:523
QWidgetAction * scalarDataColorAction
Definition: InteractiveViewer.h:393
bool isPicking
Indicates that this viewer is picking.
Definition: InteractiveViewer.h:454
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:407
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ...
Definition: InteractiveViewer.h:125
@ AREA_CELL_PICKING
pick cells that are inside a rectangular area in the VTK representation of an Geometry
Definition: InteractiveViewer.h:129
@ CELL_PICKING
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:128
@ AREA_POINT_PICKING
pick points that are inside a rectangular area in the VTK representation of an Geometry
Definition: InteractiveViewer.h:130
@ POINT_PICKING
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:127
@ PIXEL_PICKING
pick a pixel on a Slice
Definition: InteractiveViewer.h:126
QString whatsThis
Definition: InteractiveViewer.h:473
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:476
RendererWidget * rendererWidget
Definition: InteractiveViewer.h:348
QAction * toggleLabelAction
button allows one to display the labels of the object3D
Definition: InteractiveViewer.h:422
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:410
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:355
MeshDataFilterModel * scalarDataModel
Definition: InteractiveViewer.h:375
bool isChangingSlice
Indicates that this viewer is changing the slice by the slice slider.
Definition: InteractiveViewer.h:457
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition: InteractiveViewer.h:465
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:318
QAction * wireframeAction
Definition: InteractiveViewer.h:389
QAction * highlightOffAction
Definition: InteractiveViewer.h:398
Property * highlightModeProperty
The property that stands for the type of highlight mode of the 3D viewer.
Definition: InteractiveViewer.h:503
Property * linesAsTubesProperty
Property that tells whether the viewer uses lines as tubes or not.
Definition: InteractiveViewer.h:518
Property * backgroundColorProperty
The property that stands for the background color of the viewer.
Definition: InteractiveViewer.h:508
bool pickingEffectUpdated
was the picking effect updated (it has to be updated with the first picking for a given button down s...
Definition: InteractiveViewer.h:463
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:352
QAction * colorAction
Definition: InteractiveViewer.h:391
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:384
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:237
PropertyObject * propertyObject
The property object that holds the properties of this viewer.
Definition: InteractiveViewer.h:498
QAction * surfaceAction
Definition: InteractiveViewer.h:388
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:387
QAction * pointsAction
Definition: InteractiveViewer.h:390
QAction * pickPointRegionAction
Definition: InteractiveViewer.h:437
QAction * pickCellAction
Definition: InteractiveViewer.h:435
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:405
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:402
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:460
Property * backgroundGradientColorProperty
Property that tells whether the viewer use a gradient background color or not.
Definition: InteractiveViewer.h:513
QAction * toggleLogoAction
button to remove the copyright
Definition: InteractiveViewer.h:419
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:428
QAction * toggleOrientationDecorationsAction
button allows one to display orientation decoration in SLICE_VIEWER mode
Definition: InteractiveViewer.h:416
QAction * toggleLinesAsTubesAction
button allows one to display the lines as tubes (the lines are to be in vtkPolyData)
Definition: InteractiveViewer.h:425
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:451
Q_ENUMS(HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation)
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:339
QAction * pickCellRegionAction
Definition: InteractiveViewer.h:436
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:138
@ SELECTION
the selected Components are in default mode, the non-selected Components are shaded
Definition: InteractiveViewer.h:140
@ OFF
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:139
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:401
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:434
QComboBox * scalarDataComboBox
the ComboBox for mesh scalar data
Definition: InteractiveViewer.h:373
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:397
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:342
Property * pointSizeProperty
Property which defines the point size of each point in the 3D viewer.
Definition: InteractiveViewer.h:533
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:358
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:367
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:330
std::vector< Component * > pickedComponent
list of Component that are currently picked, correctly displayed in the InteractiveViewer,...
Definition: InteractiveViewer.h:448
ViewerType
there is two possibilities: this InteractiveViewer is used to display slices or geometry
Definition: InteractiveViewer.h:118
@ SLICE_VIEWER
display slices (the view is blocked in 2D and the slider is available)
Definition: InteractiveViewer.h:119
QAction * toggleScreenshotAction
visibility of the screenshot action in the side toolbar of slice viewer
Definition: InteractiveViewer.h:431
CamiTK intern class to help automatically sort or show specific data.
Definition: MeshDataModel.h:108
This class describes a property object.
Definition: PropertyObject.h:71
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:280
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:45
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
CameraOrientation
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:130
Definition: Action.cpp:35
void setBackfaceCulling(bool)
void setColorScale(bool)
display the color scale in the viewport, use setColorScaleMinMax to change the displayed values
void setGradientBackground(bool)
set the gradient background
void setColorScaleMinMax(double m, double M)
set the min and max values.
void setColorScaleTitle(QString t)
set the color scale title.
setBackgroundColor(0.0, 0.0, 0.0)
void toggleLogo(bool)
toggle logo
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:67
void toggleOrientationDecorations(bool)
display orientation decorations
void toggleAxes(bool)
display the axes
void keyPressEvent(QKeyEvent *e) override
key events (do nothing but pass on e to the parent widget), please do not add any shortcut management...
RendererWidget(QWidget *parent=nullptr, ControlMode mode=RendererWidget::TRACKBALL)
constructors.
bool getColorScale() const
get the color display state
void refresh()
refresh the display
void resetCamera()
reset the camera to the default position, default FOV.
void screenshot(QString filename)
save the screenshot in a file
void setActiveCamera(vtkCamera *cam)
set active camera