Computer Assited Medical Intervention Tool Kit  version 4.1
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-2018 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 class QToolBar;
42 
43 //-- vtk stuff
44 #include <vtkType.h>
45 #include <vtkSmartPointer.h>
46 
47 //-- vtk stuff classes
48 class vtkActor;
49 class vtkPicker;
50 class vtkProp;
51 class vtkObject;
52 class vtkCamera;
53 class vtkEventQtSlotConnect;
54 
55 namespace camitk {
56 // -- Core stuff classes
57 class SliderSpinBoxWidget;
58 class GeometricObject;
59 class InterfaceGeometry;
60 class InterfaceBitMap;
61 class InteractiveViewer;
62 class MeshDataFilterModel;
63 class PropertyObject;
64 class Property;
65 
66 using vtkSmartPointerCamera = vtkSmartPointer<vtkCamera>;
67 
69 class InteractiveViewerFrame : public QFrame {
70 public:
72  InteractiveViewerFrame(QWidget* parent, InteractiveViewer* s3D) : QFrame(parent), myInteractiveViewer(s3D) {}
73 
75  void keyPressEvent(QKeyEvent*) override;
76 
77 protected:
79 };
80 
141  Q_OBJECT
142  Q_ENUMS(HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation) // so that it can be used in property editor
143 
144 public:
146  enum ViewerType {
147  SLICE_VIEWER,
148  GEOMETRY_VIEWER
149  };
150 
153  enum PickingMode {
159  NO_PICKING
160  };
161 
167  OFF,
169  SELECTION_ONLY
170  };
171 
175 
181  static InteractiveViewer* getNewViewer(QString, ViewerType type);
182 
184  static InteractiveViewer* getViewer(QString);
185 
187  static InteractiveViewer* get3DViewer();
188 
190  static InteractiveViewer* getAxialViewer();
191 
193  static InteractiveViewer* getCoronalViewer();
194 
196  static InteractiveViewer* getSagittalViewer();
197 
199  static InteractiveViewer* getArbitraryViewer();
200 
202  ~InteractiveViewer() override;
203 
205  QString getName() const;
207 
210  unsigned int numberOfViewedComponent() override;
213 
215  void refresh(Viewer* whoIsAsking = nullptr) override;
216 
218  QWidget* getWidget(QWidget* parent) override;
219 
221  QObject* getPropertyObject() override;
222 
224  QMenu* getMenu() override;
225 
227  QToolBar* getToolBar() override;
229 
232 
235  void refreshRenderer();
236 
238  void resetCamera();
239 
241  void setActiveCamera(QString cameraName);
242 
246  vtkSmartPointer<vtkCamera> getCamera(QString cameraName = "default");
247 
249  void screenshot(QString);
250 
251 public slots:
253  void screenshot();
255 
256 public:
258  virtual void setGradientBackground(bool);
259 
261  virtual void setBackgroundColor(QColor);
262 
265 public slots:
268  void setBackfaceCulling(bool);
269 
271  void setScreenshotAction(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  virtual void setHighlightMode(InteractiveViewer::HighlightMode);
293 
296  return rendererWidget;
297  }
298 
299 
301 
304  void setColorScale(bool);
307 
309  bool getColorScale() const;
310 
316  void setColorScaleMinMax(double m, double M);
317 
321  void setColorScaleTitle(QString t);
322 
324  void initPicking(PickingMode);
325 
327  void getBoundsOfSelected(double* bound);
328 
330  void getBounds(double* bound);
331 
333  void setSideFrameVisible(bool);
335 
336 public slots:
337 
340  void sliderChanged(int);
341 
343  void xAngleChanged(double angle);
344 
346  void yAngleChanged(double angle);
347 
349  void zAngleChanged(double angle);
350 
352  void toggleCopyright(bool);
353 
354 protected:
357 
362  InteractiveViewer(QString& name, ViewerType type);
363 
365  static QMap<QString, InteractiveViewer*> viewers;
366 
368  static QString defaultNames[5];
369 
371 
372 
383 
386  void initSettings();
387 
389  ViewerType myType;
390 
392  void toggleInterpolation();
393 
395  void updateSelectionDisplay(Component*);
396 
398  QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
399 
401  void addActor(Component*, vtkSmartPointer<vtkProp>);
402 
404  void removeAllActors(Component*);
405 
408 
410  QMap<QString, vtkSmartPointerCamera> cameraMap;
412 
415  RendererWidget* rendererWidget;
418 
422 
425 
427  QFrame* sideFrame;
428 
431 
433  friend void InteractiveViewerFrame::keyPressEvent(QKeyEvent* e);
434 
436  QMenu* viewerMenu;
437 
439  QToolBar* viewerToolBar;
440 
442  QComboBox* scalarDataComboBox;
443 
445 
447  void initActions();
448 
450  void updateActions();
451 
454 
457  QAction* surfaceAction;
458  QAction* wireframeAction;
459  QAction* pointsAction;
460  QAction* colorAction;
461  QAction* glyphAction;
462  QWidgetAction* scalarDataColorAction;
463 
468 
472 
477 
480 
483 
486 
489 
492 
495 
498 
501 
503  QAction* pickPointAction;
504  QAction* pickCellAction;
507 
509 
512 
517  std::vector <Component*> pickedComponent;
518 
521 
523  bool isPicking;
524 
527 
530 
533 
534  vtkSmartPointer<vtkEventQtSlotConnect> connector;
535 
537 
540  QString whatsThis;
543 
546 
548  void initWhatsThis();
549 
551  void startWhatsThisSection(const QString& title = "");
552 
554  void endWhatsThisSection();
555 
557  void addWhatsThisItem(const QString& key, const QString& description);
559 
563 
568 
573 
578 
583 
588 
593 
598 
603 
607  void createProperties();
608 
615  bool eventFilter(QObject* object, QEvent* event) override;
616 
618 
619 protected slots:
623  void renderingActorsChanged();
625 
626  void highlightModeChanged(QAction* selectedAction);
627 
628  void cameraOrientationChanged(QAction* selectedAction);
629 
630  void viewControlModeChanged(QAction*);
631 
632  void backgroundColor();
633 
634  void toggleAxes(bool);
635 
636  void toggleOrientationDecorations(bool);
637 
638  void pickingModeChanged(QAction*);
639 
641  void picked();
642 
643  void rightClick();
644 
646  void setLabel(bool);
647 
648  void setGlyph(bool);
649 
651 
652 
653 
654 };
655 
656 }
657 
659 
660 #endif
661 
662 //**************************************************************************
InteractiveViewer * myInteractiveViewer
Definition: InteractiveViewer.h:78
A utility class to have QSpinBox and QSlider synchronized.
Definition: SliderSpinBoxWidget.h:42
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition: InteractiveViewer.h:410
Property * screenshotActionProperty
Property that tells whether the screenshot action is visible or not.
Definition: InteractiveViewer.h:597
InteractiveViewerFrame * frame
the InteractiveViewer frame
Definition: InteractiveViewer.h:424
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition: InteractiveViewer.h:436
QFrame * sideFrame
the right side frame (this is where the slider and screenshot buttons are shown)
Definition: InteractiveViewer.h:427
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition: InteractiveViewer.h:421
CamiTK intern class to help automatically sort or show specific data.
Definition: MeshDataModel.h:108
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:567
QAction * cameraOrientationRightDownAction
to change the axes view mode
Definition: InteractiveViewer.h:474
const char * description
Definition: applications/cepgenerator/main.cpp:37
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition: InteractiveViewer.h:534
pick a pixel on a Slice
Definition: InteractiveViewer.h:154
QToolBar * viewerToolBar
the QToolBar for the InteractiveViewer
Definition: InteractiveViewer.h:439
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:140
QAction * toggleOrientationDecorationsAction
button allows one to display orientation decoration in SLICE_VIEWER mode
Definition: InteractiveViewer.h:485
QAction * controlModeTrackballAction
to change the camera control mode
Definition: InteractiveViewer.h:470
Viewer is an abstract viewer.
Definition: Viewer.h:55
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition: InteractiveViewer.h:295
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ... ...
Definition: InteractiveViewer.h:153
QAction * pickCellAction
Definition: InteractiveViewer.h:504
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:126
QAction * highlightOffAction
Definition: InteractiveViewer.h:467
QAction * toggleAxesAction
button allows one to display the Axes in the InteractiveViewer
Definition: InteractiveViewer.h:482
Definition: Action.cpp:36
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:532
QComboBox * scalarDataComboBox
the ComboBox for mesh scalar data
Definition: InteractiveViewer.h:442
bool oddWhatsThis
are we currently in a odd table line
Definition: InteractiveViewer.h:545
static QMap< QString, InteractiveViewer * > viewers
the map containing all the InteractiveViewer instances
Definition: InteractiveViewer.h:365
bool isPicking
Indicates that this viewer is picking.
Definition: InteractiveViewer.h:523
pick cells that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:157
QAction * screenshotAction
Screenshot.
Definition: InteractiveViewer.h:453
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition: InteractiveViewer.h:389
QAction * cameraOrientationRightUpAction
Definition: InteractiveViewer.h:476
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition: InteractiveViewer.h:66
QMenu * renderingMenu
Rendering.
Definition: InteractiveViewer.h:456
Property * backgroundGradientColorProperty
Property that tells whether the viewer use a gradient background color or not.
Definition: InteractiveViewer.h:582
QAction * controlModeJoystickAction
Definition: InteractiveViewer.h:471
bool isChangingSlice
Indicates that this viewer is changing the slice by the slice slider.
Definition: InteractiveViewer.h:526
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:298
pick a cell in the VTK representation of an Geometry
Definition: InteractiveViewer.h:156
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes a property object.
Definition: PropertyObject.h:71
QAction * cameraOrientationLeftUpAction
Definition: InteractiveViewer.h:475
QAction * toggleBackfaceCullingAction
back face culling
Definition: InteractiveViewer.h:497
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:517
Property * backgroundColorProperty
The property that stands for the background color of the viewer.
Definition: InteractiveViewer.h:577
QAction * toggleCopyrightAction
button to remove the copyright
Definition: InteractiveViewer.h:488
pick a point in the VTK representation of an Geometry
Definition: InteractiveViewer.h:155
QAction * wireframeAction
Definition: InteractiveViewer.h:458
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition: InteractiveViewer.h:407
void keyPressEvent(QKeyEvent *) override
Handle keyboard events in the scene frame, just send everything to InteractiveViewer! ...
Definition: InteractiveViewer.cpp:2382
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition: InteractiveViewer.h:398
QAction * highlightSelectionAction
display mode
Definition: InteractiveViewer.h:465
QAction * toggleLabelAction
button allows one to display the labels of the object3D
Definition: InteractiveViewer.h:491
QAction * surfaceAction
Definition: InteractiveViewer.h:457
Property * linesAsTubesProperty
Property that tells whether the viewer uses lines as tubes or not.
Definition: InteractiveViewer.h:587
QAction * highlightSelectionOnlyAction
Definition: InteractiveViewer.h:466
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition: InteractiveViewer.h:529
Property * backfaceCullingProperty
Property that tells whether the viewer uses the backface culling option or not.
Definition: InteractiveViewer.h:592
QToolBar * screenshotActionMenu
the screenshot action is inside this menu (in the slice viewer side bar)
Definition: InteractiveViewer.h:430
QAction * pointsAction
Definition: InteractiveViewer.h:459
QAction * pickPointAction
action of the picking menu
Definition: InteractiveViewer.h:503
QAction * colorAction
Definition: InteractiveViewer.h:460
PickingMode pickingMode
Current picking mode, NO_PICKING be default.
Definition: InteractiveViewer.h:520
QAction * backgroundColorAction
background color
Definition: InteractiveViewer.h:479
QWidgetAction * scalarDataColorAction
Definition: InteractiveViewer.h:462
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:602
the selected Components are in default mode, the non-selected Components are shaded ...
Definition: InteractiveViewer.h:168
pick points that are inside a rectangular area in the VTK representation of an Geometry ...
Definition: InteractiveViewer.h:158
both selected and non-selected Components are in default mode
Definition: InteractiveViewer.h:167
QAction * toggleScreenshotAction
visibility of the screenshot action in the side toolbar of slice viewer
Definition: InteractiveViewer.h:500
HighlightMode
describes the current mode of display.
Definition: InteractiveViewer.h:166
QAction * pickPointRegionAction
Definition: InteractiveViewer.h:506
QAction * toggleLinesAsTubesAction
button allows one to display the lines as tubes (the lines are to be in vtkPolyData) ...
Definition: InteractiveViewer.h:494
QAction * glyphAction
Definition: InteractiveViewer.h:461
InteractiveViewerFrame(QWidget *parent, InteractiveViewer *s3D)
default constructor
Definition: InteractiveViewer.h:72
InteractiveViewerFrame is just a QFrame that delegates all key events to its InteractiveViewer.
Definition: InteractiveViewer.h:69
Property * highlightModeProperty
The property that stands for the type of highlight mode of the 3D viewer.
Definition: InteractiveViewer.h:572
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:291
QAction * pickCellRegionAction
Definition: InteractiveViewer.h:505
MeshDataFilterModel * scalarDataModel
Definition: InteractiveViewer.h:444