Computer Assited Medical Intervention Tool Kit  version 4.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-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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 
36 //-- QT stuff
37 #include <QFrame>
38 #include <QPushButton>
39 #include <QWidgetAction>
40 #include <QComboBox>
41 
42 //-- vtk stuff
43 #include <vtkType.h>
44 #include <vtkSmartPointer.h>
45 
46 //-- vtk stuff classes
47 class vtkActor;
48 class vtkPicker;
49 class vtkProp;
50 class vtkObject;
51 class vtkCamera;
52 class vtkEventQtSlotConnect;
53 
54 namespace camitk {
55 // -- Core stuff classes
56 class SliderSpinBoxWidget;
57 class GeometricObject;
58 class InterfaceGeometry;
59 class InterfaceBitMap;
60 class InteractiveViewer;
61 class MeshDataFilterModel;
62 class PropertyObject;
63 class Property;
64 
65 typedef vtkSmartPointer<vtkCamera> vtkSmartPointerCamera;
66 
68 class InteractiveViewerFrame : public QFrame {
69 public:
71  InteractiveViewerFrame ( QWidget* parent, InteractiveViewer* s3D ) : QFrame ( parent ), myInteractiveViewer ( s3D ) {}
72 
74  void keyPressEvent ( QKeyEvent* );
75 
76 protected:
78 };
79 
140  Q_OBJECT
141  Q_ENUMS ( HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation ) // so that it can be used in property editor
142 
143 public:
145  enum ViewerType {
146  SLICE_VIEWER,
147  GEOMETRY_VIEWER
148  };
149 
152  enum PickingMode {
158  NO_PICKING
159  };
160 
166  OFF,
168  SELECTION_ONLY
169  };
170 
174 
180  static InteractiveViewer * getNewViewer ( QString , ViewerType type );
181 
183  static InteractiveViewer * getViewer ( QString );
184 
186  static InteractiveViewer * get3DViewer();
187 
189  static InteractiveViewer * getAxialViewer();
190 
192  static InteractiveViewer * getCoronalViewer();
193 
195  static InteractiveViewer * getSagittalViewer();
196 
198  static InteractiveViewer * getArbitraryViewer();
199 
201  virtual ~InteractiveViewer();
202 
204  QString getName() const;
206 
209  virtual unsigned int numberOfViewedComponent();
212 
214  virtual void refresh ( Viewer *whoIsAsking = NULL );
215 
217  virtual QWidget * getWidget ( QWidget * parent );
218 
220  virtual QObject * getPropertyObject();
221 
223  virtual QMenu * getMenu();
224 
226  virtual QToolBar * getToolBar();
228 
231 
234  void refreshRenderer();
235 
237  void resetCamera();
238 
240  void setActiveCamera ( QString cameraName );
241 
245  vtkSmartPointer<vtkCamera> getCamera ( QString cameraName = "default" );
246 
248  void screenshot ( QString );
249 
250 public slots:
252  void screenshot();
254 
255 public:
257  virtual void setGradientBackground ( bool );
258 
260  virtual void setBackgroundColor ( QColor );
261 
264 public slots:
267  void setBackfaceCulling ( bool );
268 
269 public:
271  // bool getBackfaceCulling() const;
272 
273 public slots:
281  void setLinesAsTubes ( bool tubes );
282 
283 public:
285  void keyPressEvent ( QKeyEvent* e );
286 
288  virtual void setHighlightMode ( InteractiveViewer::HighlightMode );
289 
292  return rendererWidget;
293  }
294 
295 
297 
300  void setColorScale ( bool );
303 
305  bool getColorScale() const;
306 
312  void setColorScaleMinMax ( double m, double M );
313 
317  void setColorScaleTitle ( QString t );
318 
320  void initPicking ( PickingMode );
321 
323  void getBoundsOfSelected ( double *bound );
324 
326  void getBounds ( double *bound );
327 
329  void setSideFrameVisible(bool);
331 
332 public slots:
333 
336  void sliderChanged ( int );
337 
339  void xAngleChanged ( double angle );
340 
342  void yAngleChanged ( double angle );
343 
345  void zAngleChanged ( double angle );
346 
348  void toggleCopyright ( bool );
349 
350 protected:
353 
358  InteractiveViewer ( QString & name, ViewerType type );
359 
361  static QMap<QString, InteractiveViewer*> viewers;
362 
364  static QString defaultNames[5];
365 
367 
368 
379 
382  void initSettings();
383 
385  ViewerType myType;
386 
388  void toggleInterpolation();
389 
391  void updateSelectionDisplay ( Component * );
392 
394  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
395 
397  void addActor ( Component *, vtkSmartPointer<vtkProp> );
398 
400  void removeAllActors ( Component * );
401 
404 
406  QMap<QString, vtkSmartPointerCamera> cameraMap;
408 
411  RendererWidget * rendererWidget;
414 
418 
421 
423  QFrame *sideFrame;
424 
426  friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
427 
429  QMenu* viewerMenu;
430 
432  QToolBar *viewerToolBar;
433 
435  QComboBox* scalarDataComboBox;
436 
438 
440  void initActions();
441 
443  void updateActions();
444 
447 
450  QAction *surfaceAction;
451  QAction *wireframeAction;
452  QAction *pointsAction;
453  QAction *colorAction;
454  QAction *glyphAction;
455  QWidgetAction *scalarDataColorAction;
456 
461 
465 
470 
473 
476 
479 
482 
485 
488 
491 
493  QAction *pickPointAction;
494  QAction *pickCellAction;
497 
499 
502 
507  std::vector <Component *> pickedComponent;
508 
511 
513  bool isPicking;
514 
517 
520 
521  vtkSmartPointer<vtkEventQtSlotConnect> connector;
522 
524 
527  QString whatsThis;
530 
533 
535  void initWhatsThis();
536 
538  void startWhatsThisSection ( const QString & title = "" );
539 
541  void endWhatsThisSection();
542 
544  void addWhatsThisItem ( const QString & key, const QString & description );
546 
550 
555 
560 
565 
570 
575 
580 
585 
589  void createProperties();
590 
597  bool eventFilter(QObject *object, QEvent *event);
598 
600 
601 protected slots:
605  void renderingActorsChanged();
607 
608  void highlightModeChanged ( QAction *selectedAction );
609 
610  void cameraOrientationChanged ( QAction *selectedAction );
611 
612  void viewControlModeChanged ( QAction* );
613 
614  void backgroundColor();
615 
616  void toggleAxes ( bool );
617 
618  void toggleOrientationDecorations ( bool );
619 
620  void pickingModeChanged ( QAction* );
621 
623  void picked();
624 
625  void rightClick();
626 
628  void setLabel (bool);
629 
630  void setGlyph(bool);
631 
633 
634 
635 
636 };
637 
638 }
639 
641 
642 #endif
643 
644 //**************************************************************************
InteractiveViewer * myInteractiveViewer
Definition: InteractiveViewer.h:77
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:42
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:406
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:420
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:429
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:423
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:417
Definition: MeshDataModel.h:122
ControlMode
list of possible user interaction control mode
Definition: RendererWidget.h:153
PropertyObject * propertyObject
The property object that holds the properties of this viewer.
Definition: InteractiveViewer.h:554
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:467
const char * description
Definition: applications/cepgenerator/main.cpp:37
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition: InteractiveViewer.h:521
pick a pixel on a Slice
Definition: InteractiveViewer.h:153
QToolBar * viewerToolBar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:432
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:139
QAction * toggleOrientationDecorationsAction
button allows one to display orientation decoration in SLICE_VIEWER mode
Definition: InteractiveViewer.h:478
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:463
Viewer is an abstract viewer.
Definition: Viewer.h:55
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:291
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ... ...
Definition: InteractiveViewer.h:152
QAction * pickCellAction
Definition: InteractiveViewer.h:494
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:126
QAction * highlightOffAction
Definition: InteractiveViewer.h:460
QAction * toggleAxesAction
button allows one to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:475
Definition: Action.cpp:40
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:519
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:63
QComboBox * scalarDataComboBox
the ComboBox for mesh scalar data
Definition: InteractiveViewer.h:435
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:532
static QMap< QString, InteractiveViewer * > viewers
the map containing all the InteractiveViewer instances
Definition: InteractiveViewer.h:361
bool isPicking
Indicate that this viewer is picking.
Definition: InteractiveViewer.h:513
pick cells that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:156
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:446
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:385
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:469
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:449
std::vector< Component * > pickedComponent
list of Component that are currently picked, correctly displayed in the InteractiveViewer, but for speed optimization that are not yet selected in the explorer.
Definition: InteractiveViewer.h:507
Property * backgroundGradientColorProperty
Property that tells whether the viewer use a gradient background color or not.
Definition: InteractiveViewer.h:569
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:464
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:155
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes a property object.
Definition: PropertyObject.h:50
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:468
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:490
Property * backgroundColorProperty
The property that stands for the background color of the viewer.
Definition: InteractiveViewer.h:564
QAction * toggleCopyrightAction
button to remove the copyright
Definition: InteractiveViewer.h:481
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:154
QAction * wireframeAction
Definition: InteractiveViewer.h:451
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:403
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:394
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:458
QAction * toggleLabelAction
button allows one to display the labels of the object3D
Definition: InteractiveViewer.h:484
QAction * surfaceAction
Definition: InteractiveViewer.h:450
void keyPressEvent(QKeyEvent *)
Handle keyboard events in the scene frame, just send everything to InteractiveViewer! ...
Definition: InteractiveViewer.cpp:2205
Property * linesAsTubesProperty
Property that tells whether the viewer uses lines as tubes or not.
Definition: InteractiveViewer.h:574
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:459
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:516
Property * backfaceCullingProperty
Property that tells whether the viewer uses the backface culling option or not.
Definition: InteractiveViewer.h:579
QAction * pointsAction
Definition: InteractiveViewer.h:452
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:493
QAction * colorAction
Definition: InteractiveViewer.h:453
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:510
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:472
QWidgetAction * scalarDataColorAction
Definition: InteractiveViewer.h:455
CameraOrientation
describes the initial position and orientation of the default camera.
Definition: RendererWidget.h:143
Property * pointSizeProperty
Property which defines the point size of each point in the 3D viewer.
Definition: InteractiveViewer.h:584
the selected Components are in default mode, the non-selected Components are shaded ...
Definition: InteractiveViewer.h:167
pick points that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:157
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:166
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:165
QAction * pickPointRegionAction
Definition: InteractiveViewer.h:496
QAction * toggleLinesAsTubesAction
button allows one to display the lines as tubes (the lines are to be in vtkPolyData) ...
Definition: InteractiveViewer.h:487
QAction * glyphAction
Definition: InteractiveViewer.h:454
InteractiveViewerFrame(QWidget *parent, InteractiveViewer *s3D)
default constructor
Definition: InteractiveViewer.h:71
InteractiveViewerFrame is just a QFrame that delegates all key events to its InteractiveViewer.
Definition: InteractiveViewer.h:68
Property * highlightModeProperty
The property that stands for the type of highlight mode of the 3D viewer.
Definition: InteractiveViewer.h:559
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:260
QAction * pickCellRegionAction
Definition: InteractiveViewer.h:495
MeshDataFilterModel * scalarDataModel
Definition: InteractiveViewer.h:437