Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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:
142 
144  enum ViewerType {
145  SLICE_VIEWER,
146  GEOMETRY_VIEWER
147  };
148 
151  enum PickingMode {
155  NO_PICKING
156  };
157 
163  OFF,
165  SELECTION_ONLY
166  };
167 
171 
172 
177  static InteractiveViewer * getNewViewer ( QString , ViewerType type );
178 
180  static InteractiveViewer *getViewer ( QString );
181 
183  static InteractiveViewer * get3DViewer();
184 
186  static InteractiveViewer * getAxialViewer();
187 
189  static InteractiveViewer * getCoronalViewer();
190 
192  static InteractiveViewer * getSagittalViewer();
193 
195  static InteractiveViewer * getArbitraryViewer();
196 
198  virtual ~InteractiveViewer();
199 
201  QString getName() const;
203 
206 
207 
208  virtual unsigned int numberOfViewedComponent();
209 
211  virtual void refresh ( Viewer *whoIsAsking = NULL );
212 
214  virtual QWidget * getWidget ( QWidget * parent );
215 
217  virtual QObject * getPropertyObject();
218 
220  virtual QMenu * getMenu();
221 
223  virtual QToolBar * getToolBar();
225 
228 
229 
231  void refreshRenderer();
232 
234  void resetCamera();
235 
237  void setActiveCamera ( QString cameraName );
238 
242  vtkSmartPointer<vtkCamera> getCamera ( QString cameraName = "default" );
243 
245  void screenshot ( QString );
246 
247 public slots:
249  void screenshot();
251 
254 
255 
256 public:
258  virtual void setGradientBackground ( bool );
259 
261  bool getGradientBackground() const;
262 
264  virtual void setBackgroundColor ( QColor );
265 
267  QColor getBackgroundColor() const;
268 
269 public slots:
271  void setBackfaceCulling ( bool );
272 
273 public:
275  bool getBackfaceCulling() const;
276 
277 public slots:
285  void setLinesAsTubes ( bool tubes );
286 
287 public:
289  void keyPressEvent ( QKeyEvent* e );
290 
292  bool getLinesAsTubes() const;
293 
301  void setPointSize ( double size );
302 
304  double getPointSize() const;
305 
307  virtual void setHighlightMode ( InteractiveViewer::HighlightMode );
308 
310  InteractiveViewer::HighlightMode getHighlightMode() const;
311 
314  return rendererWidget;
315  }
316 
317 
319 
322 
323 
324  void setColorScale ( bool );
325 
327  bool getColorScale() const;
328 
334  void setColorScaleMinMax ( double m, double M );
335 
339  void setColorScaleTitle ( QString t );
340 
342  void initPicking ( PickingMode );
343 
345  void getBoundsOfSelected ( double bound[6] );
346 
348  void getBounds ( double bound[6] );
349 
351  void setSideFrameVisible(bool);
353 
354 public slots:
355 
360  void actorPicked ( vtkSmartPointer<vtkPicker> );
361 
364  void sliderChanged ( int );
365 
367  void xAngleChanged ( double angle );
368 
370  void yAngleChanged ( double angle );
371 
373  void zAngleChanged ( double angle );
374 
376  void toggleCopyright ( bool );
377 
378 protected:
381 
382 
386  InteractiveViewer ( QString & name, ViewerType type );
387 
389  static QMap<QString, InteractiveViewer*> viewers;
390 
392  static QString defaultNames[5];
393 
395 
396 
407 
408 
410  void initSettings();
411 
413  ViewerType myType;
414 
417 
419  void toggleInterpolation();
420 
423 
425  void updateSelectionDisplay ( Component * );
426 
428  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
429 
431  void addActor ( Component *, vtkSmartPointer<vtkProp> );
432 
434  void removeAllActors ( Component * );
435 
438 
440  QMap<QString, vtkSmartPointerCamera> cameraMap;
442 
445 
446 
448 
452 
455 
457  QFrame *sideFrame;
458 
460  friend void InteractiveViewerFrame::keyPressEvent ( QKeyEvent* e );
461 
463  QMenu* viewerMenu;
464 
466  QToolBar *viewerToolBar;
467 
469  void initActions();
470 
472  void updateActions();
473 
476 
479  QAction *surfaceAction;
480  QAction *wireframeAction;
481  QAction *pointsAction;
482  QAction *colorAction;
483  QAction *glyphAction;
484 
489 
493 
498 
501 
504 
507 
510 
513 
516 
518  QAction *pickPointAction;
519  QAction *pickCellAction;
520  //TODO QAction *pickRegionAction; /// to pick a region by selecting top left / bottom right corners
521 
523 
526 
527 
531  std::vector <Component *> pickedComponent;
532 
535 
538 
542 
543 
546 
547 
548  QString whatsThis;
549 
552 
554  void initWhatsThis();
555 
557  void startWhatsThisSection ( const QString & title = "" );
558 
560  void endWhatsThisSection();
561 
563  void addWhatsThisItem ( const QString & key, const QString & description );
565 
566 protected slots:
569 
570  void renderingActorsChanged();
571 
572  void highlightModeChanged ( QAction *selectedAction );
573 
574  void cameraOrientationChanged ( QAction *selectedAction );
575 
576  void viewControlModeChanged ( QAction* );
577 
578  void backgroundColor();
579 
580  void toggleAxes ( bool );
581 
582  void pickingModeChanged ( QAction* );
583 
584  void rightClick();
585 
587  void setLabel (bool);
588 
589  void setGlyph(bool);
590 
592 };
593 
594 }
595 
596 
597 #endif
598 
599 //**************************************************************************