Computer Assited Medical Intervention Tool Kit  version 3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2014 UJF-Grenoble 1, 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 
35 //-- QT stuff
36 #include <QFrame>
37 #include <QPushButton>
38 #include <QWidgetAction>
39 #include <QComboBox>
40 
41 //-- vtk stuff
42 #include <vtkType.h>
43 #include <vtkSmartPointer.h>
44 
45 //-- vtk stuff classes
46 class vtkActor;
47 class vtkPicker;
48 class vtkProp;
49 class vtkObject;
50 class vtkCamera;
51 class vtkEventQtSlotConnect;
52 
53 namespace camitk {
54 // -- Core stuff classes
55 class RendererWidget;
56 class SliderSpinBoxWidget;
57 class GeometricObject;
58 class InterfaceGeometry;
59 class InterfaceBitMap;
61 
62 typedef vtkSmartPointer<vtkCamera> vtkSmartPointerCamera;
63 
65 class InteractiveViewerFrame : public QFrame {
66 public:
68  InteractiveViewerFrame ( QWidget* parent, InteractiveViewer* s3D ) : QFrame ( parent ), myInteractiveViewer ( s3D ) {};
69 
71  void keyPressEvent ( QKeyEvent* );
72 
73 protected:
75 };
76 
138  Q_OBJECT
139  Q_ENUMS ( HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation ) // so that it can be used in property editor
140  Q_PROPERTY ( HighlightMode highlightMode READ getHighlightMode WRITE setHighlightMode )
141  Q_PROPERTY ( QColor backgroundColor READ getBackgroundColor WRITE setBackgroundColor )
142  Q_PROPERTY ( bool gradientBackground READ getGradientBackground WRITE setGradientBackground )
143  Q_PROPERTY ( bool linesAsTubes READ getLinesAsTubes WRITE setLinesAsTubes )
144  Q_PROPERTY ( bool backfaceCulling READ getBackfaceCulling WRITE setBackfaceCulling )
145  Q_PROPERTY ( double pointSize READ getPointSize WRITE setPointSize )
146 
147 public:
149  enum ViewerType {
150  SLICE_VIEWER,
151  GEOMETRY_VIEWER
152  };
153 
156  enum PickingMode {
162  NO_PICKING
163  };
164 
170  OFF,
172  SELECTION_ONLY
173  };
174 
178 
184  static InteractiveViewer * getNewViewer ( QString , ViewerType type );
185 
187  static InteractiveViewer *getViewer ( QString );
188 
190  static InteractiveViewer * get3DViewer();
191 
193  static InteractiveViewer * getAxialViewer();
194 
196  static InteractiveViewer * getCoronalViewer();
197 
199  static InteractiveViewer * getSagittalViewer();
200 
202  static InteractiveViewer * getArbitraryViewer();
203 
205  virtual ~InteractiveViewer();
206 
208  QString getName() const;
210 
213  virtual unsigned int numberOfViewedComponent();
216 
218  virtual void refresh ( Viewer *whoIsAsking = NULL );
219 
221  virtual QWidget * getWidget ( QWidget * parent );
222 
224  virtual QObject * getPropertyObject();
225 
227  virtual QMenu * getMenu();
228 
230  virtual QToolBar * getToolBar();
232 
235 
238  void refreshRenderer();
239 
241  void resetCamera();
242 
244  void setActiveCamera ( QString cameraName );
245 
249  vtkSmartPointer<vtkCamera> getCamera ( QString cameraName = "default" );
250 
252  void screenshot ( QString );
253 
254 public slots:
256  void screenshot();
258 
261 
263 public:
265  virtual void setGradientBackground ( bool );
266 
268  bool getGradientBackground() const;
269 
271  virtual void setBackgroundColor ( QColor );
272 
274  QColor getBackgroundColor() const;
275 
276 public slots:
278  void setBackfaceCulling ( bool );
279 
280 public:
282  bool getBackfaceCulling() const;
283 
284 public slots:
292  void setLinesAsTubes ( bool tubes );
293 
294 public:
296  void keyPressEvent ( QKeyEvent* e );
297 
299  bool getLinesAsTubes() const;
300 
308  void setPointSize ( double size );
309 
311  double getPointSize() const;
312 
314  virtual void setHighlightMode ( InteractiveViewer::HighlightMode );
315 
317  InteractiveViewer::HighlightMode getHighlightMode() const;
318 
321  return rendererWidget;
322  }
323 
324 
326 
329  void setColorScale ( bool );
332 
334  bool getColorScale() const;
335 
341  void setColorScaleMinMax ( double m, double M );
342 
346  void setColorScaleTitle ( QString t );
347 
349  void initPicking ( PickingMode );
350 
352  void getBoundsOfSelected ( double *bound );
353 
355  void getBounds ( double *bound );
356 
358  void setSideFrameVisible(bool);
360 
361 public slots:
362 
365  void sliderChanged ( int );
366 
368  void xAngleChanged ( double angle );
369 
371  void yAngleChanged ( double angle );
372 
374  void zAngleChanged ( double angle );
375 
377  void toggleCopyright ( bool );
378 
379 protected:
382 
387  InteractiveViewer ( QString & name, ViewerType type );
388 
390  static QMap<QString, InteractiveViewer*> viewers;
391 
393  static QString defaultNames[5];
394 
396 
397 
408 
411  void initSettings();
412 
414  ViewerType myType;
415 
418 
420  void toggleInterpolation();
421 
424 
426  void updateSelectionDisplay ( Component * );
427 
429  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
430 
432  void addActor ( Component *, vtkSmartPointer<vtkProp> );
433 
435  void removeAllActors ( Component * );
436 
439 
441  QMap<QString, vtkSmartPointerCamera> cameraMap;
443 
446  RendererWidget * rendererWidget;
449 
453 
456 
458  QFrame *sideFrame;
459 
461  friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
462 
464  QMenu* viewerMenu;
465 
467  QToolBar *viewerToolBar;
468 
470  void initActions();
471 
473  void updateActions();
474 
477 
480  QAction *surfaceAction;
481  QAction *wireframeAction;
482  QAction *pointsAction;
483  QAction *colorAction;
484  QAction *glyphAction;
485 
490 
494 
499 
502 
505 
508 
511 
514 
517 
520 
522  QAction *pickPointAction;
523  QAction *pickCellAction;
526  //TODO QAction *pickRegionAction; /// to pick a region by selecting top left / bottom right corners
527 
529 
532 
537  std::vector <Component *> pickedComponent;
538 
541 
544 
547 
548  vtkSmartPointer<vtkEventQtSlotConnect> connector;
549 
551 
552 
555  QString whatsThis;
558 
561 
563  void initWhatsThis();
564 
566  void startWhatsThisSection ( const QString & title = "" );
567 
569  void endWhatsThisSection();
570 
572  void addWhatsThisItem ( const QString & key, const QString & description );
574 
575 protected slots:
578  void renderingActorsChanged();
580 
581  void highlightModeChanged ( QAction *selectedAction );
582 
583  void cameraOrientationChanged ( QAction *selectedAction );
584 
585  void viewControlModeChanged ( QAction* );
586 
587  void backgroundColor();
588 
589  void toggleAxes ( bool );
590 
591  void toggleOrientationDecorations ( bool );
592 
593  void pickingModeChanged ( QAction* );
594 
596  void picked();
597 
598  void rightClick();
599 
601  void setLabel (bool);
602 
603  void setGlyph(bool);
604 
606 };
607 
608 }
609 
610 
611 #endif
612 
613 //**************************************************************************
InteractiveViewer * myInteractiveViewer
Definition: InteractiveViewer.h:74
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:42
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:441
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:455
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:464
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:458
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:452
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:496
const char * description
Definition: applications/cepgenerator/main.cpp:37
ControlMode
list of possible user interaction control mode
Definition: RendererWidget.h:147
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition: InteractiveViewer.h:548
QToolBar * viewerToolBar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:467
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:137
CameraOrientation
describes the initial position and orientation of the default camera.
Definition: RendererWidget.h:137
QAction * toggleOrientationDecorationsAction
button allows one to display orientation decoration in SLICE_VIEWER mode
Definition: InteractiveViewer.h:507
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:492
Viewer is an abstract viewer.
Definition: Viewer.h:55
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:320
QAction * pickCellAction
Definition: InteractiveViewer.h:523
string name
Definition: select.cpp:111
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:120
QAction * highlightOffAction
Definition: InteractiveViewer.h:489
QAction * toggleAxesAction
button allows one to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:504
the selected Components are in default mode, the non-selected Components are shaded ...
Definition: InteractiveViewer.h:171
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:546
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:158
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:60
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:560
static QMap< QString, InteractiveViewer * > viewers
the map containing all the InteractiveViewer instances
Definition: InteractiveViewer.h:390
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:170
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:476
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:414
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:498
pick a pixel on a Slice
Definition: InteractiveViewer.h:157
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:479
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:537
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:493
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
#define CAMITK_API
Definition: CamiTKAPI.h:49
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:497
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ... ...
Definition: InteractiveViewer.h:156
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:519
QAction * toggleCopyrightAction
button to remove the copyright
Definition: InteractiveViewer.h:510
QAction * wireframeAction
Definition: InteractiveViewer.h:481
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:438
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:429
pick cells that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:160
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:487
QAction * toggleLabelAction
button allows one to display the labels of the object3D
Definition: InteractiveViewer.h:513
QAction * surfaceAction
Definition: InteractiveViewer.h:480
void keyPressEvent(QKeyEvent *)
Handle keyboard events in the scene frame, just send everything to InteractiveViewer! ...
Definition: InteractiveViewer.cpp:2142
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:488
bool linesAsTubes
Are lines currently displayed as tubes (the actors have to add a vtkTubeFilter between the source and...
Definition: InteractiveViewer.h:417
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:543
StructureProperties::GeometricType type
Definition: ansys2pml.cpp:40
HighlightMode highlightMode
keep the value of the hightlight mode
Definition: InteractiveViewer.h:423
QAction * pointsAction
Definition: InteractiveViewer.h:482
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:522
QAction * colorAction
Definition: InteractiveViewer.h:483
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:540
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:501
pick points that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:161
QAction * pickPointRegionAction
Definition: InteractiveViewer.h:525
QAction * toggleLinesAsTubesAction
button allows one to display the lines as tubes (the lines are to be in vtkPolyData) ...
Definition: InteractiveViewer.h:516
QAction * glyphAction
Definition: InteractiveViewer.h:484
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:169
InteractiveViewerFrame(QWidget *parent, InteractiveViewer *s3D)
default constructor
Definition: InteractiveViewer.h:68
InteractiveViewerFrame is just a QFrame that delegates all key events to its InteractiveViewer.
Definition: InteractiveViewer.h:65
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:159
QAction * pickCellRegionAction
Definition: InteractiveViewer.h:524