Computer Assited Medical Intervention Tool Kit  version 3.3
 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 
39 //-- vtk stuff
40 #include <vtkType.h>
41 #include <vtkSmartPointer.h>
42 
43 //-- vtk stuff classes
44 class vtkActor;
45 class vtkPicker;
46 class vtkProp;
47 class vtkObject;
48 class vtkCamera;
49 
50 namespace camitk {
51 // -- Core stuff classes
52 class RendererWidget;
53 class SliderSpinBoxWidget;
54 class GeometricObject;
55 class InterfaceGeometry;
56 class InterfaceBitMap;
58 
59 typedef vtkSmartPointer<vtkCamera> vtkSmartPointerCamera;
60 
62 class InteractiveViewerFrame : public QFrame {
63 public:
65  InteractiveViewerFrame ( QWidget* parent, InteractiveViewer* s3D ) : QFrame ( parent ), myInteractiveViewer ( s3D ) {};
66 
68  void keyPressEvent ( QKeyEvent* );
69 
70 protected:
72 };
73 
135  Q_OBJECT
136  Q_ENUMS ( HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation ) // so that it can be used in property editor
137  Q_PROPERTY ( HighlightMode highlightMode READ getHighlightMode WRITE setHighlightMode )
138  Q_PROPERTY ( QColor backgroundColor READ getBackgroundColor WRITE setBackgroundColor )
139  Q_PROPERTY ( bool gradientBackground READ getGradientBackground WRITE setGradientBackground )
140  Q_PROPERTY ( bool linesAsTubes READ getLinesAsTubes WRITE setLinesAsTubes )
141  Q_PROPERTY ( bool backfaceCulling READ getBackfaceCulling WRITE setBackfaceCulling )
142  Q_PROPERTY ( double pointSize READ getPointSize WRITE setPointSize )
143 
144 public:
146  enum ViewerType {
147  SLICE_VIEWER,
148  GEOMETRY_VIEWER
149  };
150 
153  enum PickingMode {
157  NO_PICKING
158  };
159 
165  OFF,
167  SELECTION_ONLY
168  };
169 
173 
179  static InteractiveViewer * getNewViewer ( QString , ViewerType type );
180 
182  static InteractiveViewer *getViewer ( QString );
183 
185  static InteractiveViewer * get3DViewer();
186 
188  static InteractiveViewer * getAxialViewer();
189 
191  static InteractiveViewer * getCoronalViewer();
192 
194  static InteractiveViewer * getSagittalViewer();
195 
197  static InteractiveViewer * getArbitraryViewer();
198 
200  virtual ~InteractiveViewer();
201 
203  QString getName() const;
205 
208  virtual unsigned int numberOfViewedComponent();
211 
213  virtual void refresh ( Viewer *whoIsAsking = NULL );
214 
216  virtual QWidget * getWidget ( QWidget * parent );
217 
219  virtual QObject * getPropertyObject();
220 
222  virtual QMenu * getMenu();
223 
225  virtual QToolBar * getToolBar();
227 
230 
233  void refreshRenderer();
234 
236  void resetCamera();
237 
239  void setActiveCamera ( QString cameraName );
240 
244  vtkSmartPointer<vtkCamera> getCamera ( QString cameraName = "default" );
245 
247  void screenshot ( QString );
248 
249 public slots:
251  void screenshot();
253 
256 
258 public:
260  virtual void setGradientBackground ( bool );
261 
263  bool getGradientBackground() const;
264 
266  virtual void setBackgroundColor ( QColor );
267 
269  QColor getBackgroundColor() const;
270 
271 public slots:
273  void setBackfaceCulling ( bool );
274 
275 public:
277  bool getBackfaceCulling() const;
278 
279 public slots:
287  void setLinesAsTubes ( bool tubes );
288 
289 public:
291  void keyPressEvent ( QKeyEvent* e );
292 
294  bool getLinesAsTubes() const;
295 
303  void setPointSize ( double size );
304 
306  double getPointSize() const;
307 
309  virtual void setHighlightMode ( InteractiveViewer::HighlightMode );
310 
312  InteractiveViewer::HighlightMode getHighlightMode() const;
313 
316  return rendererWidget;
317  }
318 
319 
321 
324  void setColorScale ( bool );
327 
329  bool getColorScale() const;
330 
336  void setColorScaleMinMax ( double m, double M );
337 
341  void setColorScaleTitle ( QString t );
342 
344  void initPicking ( PickingMode );
345 
347  void getBoundsOfSelected ( double *bound );
348 
350  void getBounds ( double *bound );
351 
353  void setSideFrameVisible(bool);
355 
356 public slots:
357 
362  void actorPicked ( vtkSmartPointer<vtkPicker> );
363 
366  void sliderChanged ( int );
367 
369  void xAngleChanged ( double angle );
370 
372  void yAngleChanged ( double angle );
373 
375  void zAngleChanged ( double angle );
376 
378  void toggleCopyright ( bool );
379 
380 protected:
383 
388  InteractiveViewer ( QString & name, ViewerType type );
389 
391  static QMap<QString, InteractiveViewer*> viewers;
392 
394  static QString defaultNames[5];
395 
397 
398 
409 
412  void initSettings();
413 
415  ViewerType myType;
416 
419 
421  void toggleInterpolation();
422 
425 
427  void updateSelectionDisplay ( Component * );
428 
430  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
431 
433  void addActor ( Component *, vtkSmartPointer<vtkProp> );
434 
436  void removeAllActors ( Component * );
437 
440 
442  QMap<QString, vtkSmartPointerCamera> cameraMap;
444 
447  RendererWidget * rendererWidget;
450 
454 
457 
459  QFrame *sideFrame;
460 
462  friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
463 
465  QMenu* viewerMenu;
466 
468  QToolBar *viewerToolBar;
469 
471  void initActions();
472 
474  void updateActions();
475 
478 
481  QAction *surfaceAction;
482  QAction *wireframeAction;
483  QAction *pointsAction;
484  QAction *colorAction;
485  QAction *glyphAction;
486 
491 
495 
500 
503 
506 
509 
512 
515 
518 
520  QAction *pickPointAction;
521  QAction *pickCellAction;
522  //TODO QAction *pickRegionAction; /// to pick a region by selecting top left / bottom right corners
523 
525 
528 
533  std::vector <Component *> pickedComponent;
534 
537 
540 
544 
545 
548  QString whatsThis;
551 
554 
556  void initWhatsThis();
557 
559  void startWhatsThisSection ( const QString & title = "" );
560 
562  void endWhatsThisSection();
563 
565  void addWhatsThisItem ( const QString & key, const QString & description );
567 
568 protected slots:
571  void renderingActorsChanged();
573 
574  void highlightModeChanged ( QAction *selectedAction );
575 
576  void cameraOrientationChanged ( QAction *selectedAction );
577 
578  void viewControlModeChanged ( QAction* );
579 
580  void backgroundColor();
581 
582  void toggleAxes ( bool );
583 
584  void pickingModeChanged ( QAction* );
585 
586  void rightClick();
587 
589  void setLabel (bool);
590 
591  void setGlyph(bool);
592 
594 };
595 
596 }
597 
598 
599 #endif
600 
601 //**************************************************************************
InteractiveViewer * myInteractiveViewer
Definition: InteractiveViewer.h:71
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:43
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:442
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:456
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:465
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:459
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:453
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:497
ControlMode
list of possible user interaction control mode
Definition: RendererWidget.h:100
QToolBar * viewerToolBar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:468
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:134
CameraOrientation
describes the initial position and orientation of the default camera.
Definition: RendererWidget.h:93
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:493
Viewer is an abstract viewer.
Definition: Viewer.h:55
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:315
QAction * pickCellAction
Definition: InteractiveViewer.h:521
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:75
QAction * highlightOffAction
Definition: InteractiveViewer.h:490
QAction * toggleAxesAction
button allows to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:505
the selected Components are in default mode, the non-selected Components are shaded ...
Definition: InteractiveViewer.h:166
Definition: Action.h: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:542
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:155
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:57
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:553
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:165
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:477
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:415
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:499
pick a pixel on a Slice
Definition: InteractiveViewer.h:154
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:480
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:533
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:494
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:292
#define CAMITK_API
Definition: CamiTKAPI.h:49
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:498
static QMap< QString, InteractiveViewer * > viewers
the map containing all the InteractiveViewer instances
Definition: InteractiveViewer.h:391
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ... ...
Definition: InteractiveViewer.h:153
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:517
QAction * toggleCopyrightAction
button to remove the copyright
Definition: InteractiveViewer.h:508
QAction * wireframeAction
Definition: InteractiveViewer.h:482
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:439
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:430
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:488
QAction * toggleLabelAction
button allows to display the labels of the object3D
Definition: InteractiveViewer.h:511
QAction * surfaceAction
Definition: InteractiveViewer.h:481
void keyPressEvent(QKeyEvent *)
Handle keyboard events in the scene frame, just send everything to InteractiveViewer! ...
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:489
bool linesAsTubes
Are lines currently displayed as tubes (the actors have to add a vtkTubeFilter between the source and...
Definition: InteractiveViewer.h:418
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:539
HighlightMode highlightMode
keep the value of the hightlight mode
Definition: InteractiveViewer.h:424
QAction * pointsAction
Definition: InteractiveViewer.h:483
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:520
QAction * colorAction
Definition: InteractiveViewer.h:484
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:536
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:502
QAction * toggleLinesAsTubesAction
button allows to display the lines as tubes (the lines are to be in vtkPolyData)
Definition: InteractiveViewer.h:514
QAction * glyphAction
Definition: InteractiveViewer.h:485
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:164
InteractiveViewerFrame(QWidget *parent, InteractiveViewer *s3D)
default constructor
Definition: InteractiveViewer.h:65
InteractiveViewerFrame is just a QFrame that delegates all key events to its InteractiveViewer.
Definition: InteractiveViewer.h:62
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:156