Computer Assited Medical Intervention Tool Kit  version 3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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-2013 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 
132  Q_OBJECT
133  Q_ENUMS ( HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation ) // so that it can be used in property editor
134  Q_PROPERTY ( HighlightMode highlightMode READ getHighlightMode WRITE setHighlightMode )
135  Q_PROPERTY ( QColor backgroundColor READ getBackgroundColor WRITE setBackgroundColor )
136  Q_PROPERTY ( bool gradientBackground READ getGradientBackground WRITE setGradientBackground )
137  Q_PROPERTY ( bool linesAsTubes READ getLinesAsTubes WRITE setLinesAsTubes )
138  Q_PROPERTY ( bool backfaceCulling READ getBackfaceCulling WRITE setBackfaceCulling )
139  Q_PROPERTY ( double pointSize READ getPointSize WRITE setPointSize )
140 
141 public:
143  enum ViewerType {
144  SLICE_VIEWER,
145  GEOMETRY_VIEWER
146  };
147 
150  enum PickingMode {
154  NO_PICKING
155  };
156 
162  OFF,
164  SELECTION_ONLY
165  };
166 
170 
176  static InteractiveViewer * getNewViewer ( QString , ViewerType type );
177 
179  static InteractiveViewer *getViewer ( QString );
180 
182  static InteractiveViewer * get3DViewer();
183 
185  static InteractiveViewer * getAxialViewer();
186 
188  static InteractiveViewer * getCoronalViewer();
189 
191  static InteractiveViewer * getSagittalViewer();
192 
194  static InteractiveViewer * getArbitraryViewer();
195 
197  virtual ~InteractiveViewer();
198 
200  QString getName() const;
202 
205  virtual unsigned int numberOfViewedComponent();
208 
210  virtual void refresh ( Viewer *whoIsAsking = NULL );
211 
213  virtual QWidget * getWidget ( QWidget * parent );
214 
216  virtual QObject * getPropertyObject();
217 
219  virtual QMenu * getMenu();
220 
222  virtual QToolBar * getToolBar();
224 
227 
230  void refreshRenderer();
231 
233  void resetCamera();
234 
236  void setActiveCamera ( QString cameraName );
237 
241  vtkSmartPointer<vtkCamera> getCamera ( QString cameraName = "default" );
242 
244  void screenshot ( QString );
245 
246 public slots:
248  void screenshot();
250 
253 
255 public:
257  virtual void setGradientBackground ( bool );
258 
260  bool getGradientBackground() const;
261 
263  virtual void setBackgroundColor ( QColor );
264 
266  QColor getBackgroundColor() const;
267 
268 public slots:
270  void setBackfaceCulling ( bool );
271 
272 public:
274  bool getBackfaceCulling() const;
275 
276 public slots:
284  void setLinesAsTubes ( bool tubes );
285 
286 public:
288  void keyPressEvent ( QKeyEvent* e );
289 
291  bool getLinesAsTubes() const;
292 
300  void setPointSize ( double size );
301 
303  double getPointSize() const;
304 
306  virtual void setHighlightMode ( InteractiveViewer::HighlightMode );
307 
309  InteractiveViewer::HighlightMode getHighlightMode() const;
310 
313  return rendererWidget;
314  }
315 
316 
318 
321  void setColorScale ( bool );
324 
326  bool getColorScale() const;
327 
333  void setColorScaleMinMax ( double m, double M );
334 
338  void setColorScaleTitle ( QString t );
339 
341  void initPicking ( PickingMode );
342 
344  void getBoundsOfSelected ( double bound[6] );
345 
347  void getBounds ( double bound[6] );
348 
350  void setSideFrameVisible(bool);
352 
353 public slots:
354 
359  void actorPicked ( vtkSmartPointer<vtkPicker> );
360 
363  void sliderChanged ( int );
364 
366  void xAngleChanged ( double angle );
367 
369  void yAngleChanged ( double angle );
370 
372  void zAngleChanged ( double angle );
373 
375  void toggleCopyright ( bool );
376 
377 protected:
380 
385  InteractiveViewer ( QString & name, ViewerType type );
386 
388  static QMap<QString, InteractiveViewer*> viewers;
389 
391  static QString defaultNames[5];
392 
394 
395 
406 
409  void initSettings();
410 
412  ViewerType myType;
413 
416 
418  void toggleInterpolation();
419 
422 
424  void updateSelectionDisplay ( Component * );
425 
427  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
428 
430  void addActor ( Component *, vtkSmartPointer<vtkProp> );
431 
433  void removeAllActors ( Component * );
434 
437 
439  QMap<QString, vtkSmartPointerCamera> cameraMap;
441 
444  RendererWidget * rendererWidget;
447 
451 
454 
456  QFrame *sideFrame;
457 
459  friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
460 
462  QMenu* viewerMenu;
463 
465  QToolBar *viewerToolBar;
466 
468  void initActions();
469 
471  void updateActions();
472 
475 
478  QAction *surfaceAction;
479  QAction *wireframeAction;
480  QAction *pointsAction;
481  QAction *colorAction;
482  QAction *glyphAction;
483 
488 
492 
497 
500 
503 
506 
509 
512 
515 
517  QAction *pickPointAction;
518  QAction *pickCellAction;
519  //TODO QAction *pickRegionAction; /// to pick a region by selecting top left / bottom right corners
520 
522 
525 
530  std::vector <Component *> pickedComponent;
531 
534 
537 
541 
542 
545  QString whatsThis;
548 
551 
553  void initWhatsThis();
554 
556  void startWhatsThisSection ( const QString & title = "" );
557 
559  void endWhatsThisSection();
560 
562  void addWhatsThisItem ( const QString & key, const QString & description );
564 
565 protected slots:
568  void renderingActorsChanged();
570 
571  void highlightModeChanged ( QAction *selectedAction );
572 
573  void cameraOrientationChanged ( QAction *selectedAction );
574 
575  void viewControlModeChanged ( QAction* );
576 
577  void backgroundColor();
578 
579  void toggleAxes ( bool );
580 
581  void pickingModeChanged ( QAction* );
582 
583  void rightClick();
584 
586  void setLabel (bool);
587 
588  void setGlyph(bool);
589 
591 };
592 
593 }
594 
595 
596 #endif
597 
598 //**************************************************************************
InteractiveViewer * myInteractiveViewer
Definition: InteractiveViewer.h:71
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:39
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:439
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:453
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:462
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:456
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:450
ControlMode
list of possible user interaction control mode
Definition: RendererWidget.h:97
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:494
pick a pixel on a Slice
Definition: InteractiveViewer.h:151
QToolBar * viewerToolBar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:465
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:131
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:490
Viewer is an abstract viewer.
Definition: Viewer.h:50
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:312
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ... ...
Definition: InteractiveViewer.h:150
QAction * pickCellAction
Definition: InteractiveViewer.h:518
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:72
QAction * highlightOffAction
Definition: InteractiveViewer.h:487
QAction * toggleAxesAction
button allows to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:502
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:539
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:57
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:550
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:474
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:412
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:496
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:477
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:530
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:491
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: Component.h:287
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:153
#define CAMITK_API
Definition: CamiTKAPI.h:49
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:495
static QMap< QString, InteractiveViewer * > viewers
the map containing all the InteractiveViewer instances
Definition: InteractiveViewer.h:388
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:514
QAction * toggleCopyrightAction
button to remove the copyright
Definition: InteractiveViewer.h:505
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:152
QAction * wireframeAction
Definition: InteractiveViewer.h:479
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:436
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:427
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:485
QAction * toggleLabelAction
button allows to display the labels of the object3D
Definition: InteractiveViewer.h:508
QAction * surfaceAction
Definition: InteractiveViewer.h:478
void keyPressEvent(QKeyEvent *)
Handle keyboard events in the scene frame, just send everything to InteractiveViewer! ...
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:486
bool linesAsTubes
Are lines currently displayed as tubes (the actors have to add a vtkTubeFilter between the source and...
Definition: InteractiveViewer.h:415
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:536
HighlightMode highlightMode
keep the value of the hightlight mode
Definition: InteractiveViewer.h:421
QAction * pointsAction
Definition: InteractiveViewer.h:480
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:517
QAction * colorAction
Definition: InteractiveViewer.h:481
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:533
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:499
CameraOrientation
describes the initial position and orientation of the default camera.
Definition: RendererWidget.h:90
the selected Components are in default mode, the non-selected Components are shaded ...
Definition: InteractiveViewer.h:163
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:162
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:161
QAction * toggleLinesAsTubesAction
button allows to display the lines as tubes (the lines are to be in vtkPolyData)
Definition: InteractiveViewer.h:511
QAction * glyphAction
Definition: InteractiveViewer.h:482
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