Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
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-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
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"
36
37//-- QT stuff
38#include <QPushButton>
39#include <QWidgetAction>
40#include <QComboBox>
41class QToolBar;
42class QFrame;
43
44//-- vtk stuff
45#include <vtkType.h>
46#include <vtkSmartPointer.h>
47
48//-- vtk stuff classes
49class vtkActor;
50class vtkPicker;
51class vtkProp;
52class vtkObject;
53class vtkCamera;
54class vtkEventQtSlotConnect;
55
56namespace camitk {
57// -- Core stuff classes
58class SliderSpinBoxWidget;
59class GeometricObject;
60class InterfaceGeometry;
61class InterfaceBitMap;
62class InteractiveViewer;
63class PropertyObject;
64class Property;
65class FrameOfReference;
66
67using vtkSmartPointerCamera = vtkSmartPointer<vtkCamera>;
68
113 Q_OBJECT
114 Q_ENUMS(HighlightMode RendererWidget::ControlMode RendererWidget::CameraOrientation); // so that it can be used in property editor
115
116public:
120 GEOMETRY_VIEWER
121 };
122
127 LOCATION_PICKING = 0,
128 POINT_PICKING = 1,
129 CELL_PICKING = 2,
130 AREA_POINT_PICKING = 3,
131 AREA_CELL_PICKING = 4,
132 PIXEL_PICKING = 5,
133 NO_PICKING
134 };
135
143 SELECTION_ONLY
144 };
145
150 enum class CameraOrientation {
151 XY, // Show the XY plane (camera perpendicular to Z axis)
152 XZ, // Show the XZ plane (camera perpendicular to Y axis)
153 YZ, // Show the YZ plane (camera perpendicular to X axis)
154 AXIAL, // Shows the Axial plane if the current FrameOfReference has anatomicalOrientation information
155 CORONAL, // Shows the Coronal plane if the current FrameOfReference has anatomicalOrientation information
156 SAGITTAL, // Shows the Sagittal plane if the current FrameOfReference has anatomicalOrientation information
157 CUSTOM // Any other orientation (e.g. freely moving camera in the 3D viewer)
158 };
159
161
165 Q_INVOKABLE InteractiveViewer(QString& name, camitk::InteractiveViewer::ViewerType type);
166
168 virtual ~InteractiveViewer() override;
169
171 QString getName() const;
173
178 void refresh(Viewer* whoIsAsking = nullptr) override;
179
181 QWidget* getWidget() override;
182
184 PropertyObject* getPropertyObject() override;
185
187 QMenu* getMenu() override;
188
190 QToolBar* getToolBar() override;
191
193
194
199 virtual void setFrame(const std::shared_ptr<FrameOfReference>& frame);
200
202 virtual const FrameOfReference* getFrame() const;
204
205
209
211 void resetCamera();
212
214 void setActiveCamera(QString cameraName);
215
218 void setCameraOrientation(InteractiveViewer::CameraOrientation orientation);
221 InteractiveViewer::CameraOrientation getCameraOrientation();
222
223
227 vtkSmartPointer<vtkCamera> getCamera(QString cameraName = "default");
228
230 void screenshot(QString);
231
232public slots:
234 void screenshot();
236
237public:
239 virtual void setGradientBackground(bool);
240
242 virtual void setBackgroundColor(QColor);
243
244public slots:
249 void setBackfaceCulling(bool);
250
255 void setFxaaAntialiasing(bool);
256
258 void setScreenshotAction(bool);
259
267 void setLinesAsTubes(bool tubes);
268
269public:
271 void keyPressEvent(QKeyEvent* e);
272
274 virtual void setHighlightMode();
275
278 return rendererWidget;
279 }
280
282
286 void setColorScale(bool);
287
289 bool getColorScale() const;
290
296 void setColorScaleMinMax(double m, double M);
297
301 void setColorScaleTitle(QString t);
302
304 void initPicking(PickingMode);
305
307 void getBoundsOfSelected(double* bound);
308
310 void getBounds(double* bound);
311
313 void setSideFrameVisible(bool);
315
316public slots:
317
320
322 void sliderChanged(int);
323
325 void toggleLogo(bool);
326
328
329protected:
330
332 void init();
333
345
347 void initSettings();
348
351
353 void toggleInterpolation();
354
356 void resetLUT();
357
359 void updateSelectionDisplay(Component*);
360
362 QMultiMap<Component*, vtkSmartPointer<vtkProp> > actorMap;
363
368 QMap<vtkSmartPointer<vtkActor2D>, QVector3D> transformed2DActors;
369
371 std::shared_ptr<FrameOfReference> frameOfReference;
372
374 void addActor(Component*, vtkSmartPointer<vtkProp>, const FrameOfReference* sourceFrame = nullptr);
375
377 void removeAllActors(Component*);
378
380 void updateCurrentFrameOfReferenceColorIndicator();
381
384
386 QMap<QString, vtkSmartPointerCamera> cameraMap;
388
393
397
400
402 QFrame* sideFrame;
403
406
408 friend void InteractiveViewerFrame::keyPressEvent(QKeyEvent* e);
409
412
414 QToolBar* viewerToolbar;
415
417 void initActions();
418
420 void updateActions();
421
422 // Combobox in the toolbar to choose the orientation
424
425 // Combobox in the toolbar to choose the picking mode
426 QComboBox* pickingCombo;
427
430
435 QAction* pointsAction;
436 QAction* colorAction;
437 QAction* glyphAction;
438
443
447
450
453
456
459
462
465
468
471
474
481
483
487
491 std::vector <Component*> pickedComponent;
492
495
498
501
504
507
508 vtkSmartPointer<vtkEventQtSlotConnect> connector;
509
511
516 QString whatsThis;
517
520
522 void initWhatsThis();
523
525 void startWhatsThisSection(const QString& title = "");
526
528 void endWhatsThisSection();
529
531 void addWhatsThisItem(const QString& key, const QString& description);
533
538
542
547
552
553
558
563
568
573
578
583
588
592 void createProperties();
593
600 bool eventFilter(QObject* object, QEvent* event) override;
601
603
604protected slots:
609 void renderingActorsChanged();
610
611 void highlightModeChanged(QAction* selectedAction);
612
613 //void cameraOrientationChanged(QAction* selectedAction);
614
615 void viewControlModeChanged(QAction*);
616
617 void backgroundColor();
618
619 void toggleAxes(bool);
620
621 void toggleOrientationDecorations(bool);
622
623 void pickingModeChanged(QAction*);
624
626 void picked();
627
628 void rightClick();
629
631 void setLabel(bool);
632
633 void setGlyph(bool);
634
636};
637
638} // namespace camitk
639
641
642#endif
643
644//**************************************************************************
#define CAMITK_API
Definition CamiTKAPI.h:66
const char * description
Definition applications/cepgenerator/main.cpp:38
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
FrameOfReference is only a label for an abstract coordinate system.
Definition FrameOfReference.h:71
InteractiveViewerFrame is the basic container for the InteractiveViewer widget.
Definition InteractiveViewerFrame.h:50
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition InteractiveViewer.h:112
QToolBar * viewerToolbar
the QToolBar for the InteractiveViewer
Definition InteractiveViewer.h:414
QAction * toggleAxesAction
button allows one to display the Axes in the InteractiveViewer
Definition InteractiveViewer.h:452
Property * screenshotActionProperty
Property that tells whether the screenshot action is visible or not.
Definition InteractiveViewer.h:582
QAction * glyphAction
Definition InteractiveViewer.h:437
QToolBar * screenshotActionMenu
the screenshot action is inside this menu (in the slice viewer side bar)
Definition InteractiveViewer.h:405
QAction * highlightSelectionAction
display mode
Definition InteractiveViewer.h:440
Property * backfaceCullingProperty
Property that tells whether the viewer uses the backface culling option or not.
Definition InteractiveViewer.h:572
bool isPicking
Indicates that this viewer is picking.
Definition InteractiveViewer.h:497
PickingMode
Different kind of picking must be available: pixel in slice, a point, a cell, ...
Definition InteractiveViewer.h:126
QString whatsThis
Definition InteractiveViewer.h:516
bool oddWhatsThis
are we currently in a odd table line
Definition InteractiveViewer.h:519
RendererWidget * rendererWidget
Definition InteractiveViewer.h:392
QAction * toggleLabelAction
button allows one to display the labels of the object3D
Definition InteractiveViewer.h:461
Property * cameraOrientationProperty
The property that stands for the current orientation of the viewer.
Definition InteractiveViewer.h:551
QAction * backgroundColorAction
background color
Definition InteractiveViewer.h:449
bool isChangingSlice
Indicates that this viewer is changing the slice by the slice slider.
Definition InteractiveViewer.h:500
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition InteractiveViewer.h:508
ViewerType myType
type of InteractiveViewer (display slice or geometry)
Definition InteractiveViewer.h:350
QAction * wireframeAction
Definition InteractiveViewer.h:434
QAction * highlightOffAction
Definition InteractiveViewer.h:442
Property * highlightModeProperty
The property that stands for the type of highlight mode of the 3D viewer.
Definition InteractiveViewer.h:546
Property * linesAsTubesProperty
Property that tells whether the viewer uses lines as tubes or not.
Definition InteractiveViewer.h:567
Property * backgroundColorProperty
The property that stands for the background color of the viewer.
Definition InteractiveViewer.h:557
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:506
SliderSpinBoxWidget * sliceSlider
Slider used to control the slice index in a InteractiveViewer.
Definition InteractiveViewer.h:396
CameraOrientation
describes the current position of the camera.
Definition InteractiveViewer.h:150
QAction * toggleFxaaAntialiasingAction
FXAA antialiasing.
Definition InteractiveViewer.h:470
QAction * colorAction
Definition InteractiveViewer.h:436
QAction * screenshotAction
Screenshot.
Definition InteractiveViewer.h:429
std::shared_ptr< FrameOfReference > frameOfReference
The FrameOfReference in which this component's data is represented in (used to properly position the ...
Definition InteractiveViewer.h:371
Property * fxaaAntialiasingProperty
Property that tells whether the viewer uses the backface culling option or not.
Definition InteractiveViewer.h:577
PropertyObject * propertyObject
The property object that holds the properties of this viewer.
Definition InteractiveViewer.h:541
QAction * surfaceAction
Definition InteractiveViewer.h:433
QMenu * renderingMenu
Rendering.
Definition InteractiveViewer.h:432
QAction * pointsAction
Definition InteractiveViewer.h:435
QAction * pickPointRegionAction
Definition InteractiveViewer.h:479
QAction * pickCellAction
Definition InteractiveViewer.h:477
QAction * controlModeJoystickAction
Definition InteractiveViewer.h:446
bool pickingEffectIsSelecting
picking effect while mouse button is kept pressed is selecting (depends on the selection state of the...
Definition InteractiveViewer.h:503
Property * backgroundGradientColorProperty
Property that tells whether the viewer use a gradient background color or not.
Definition InteractiveViewer.h:562
QAction * toggleLogoAction
button to remove the copyright
Definition InteractiveViewer.h:458
QAction * toggleBackfaceCullingAction
back face culling
Definition InteractiveViewer.h:467
QComboBox * pickingCombo
Definition InteractiveViewer.h:426
QAction * toggleOrientationDecorationsAction
button allows one to display orientation decoration in SLICE_VIEWER mode
Definition InteractiveViewer.h:455
QAction * toggleLinesAsTubesAction
button allows one to display the lines as tubes (the lines are to be in vtkPolyData)
Definition InteractiveViewer.h:464
PickingMode pickingMode
Current picking mode, POINT_PICKING be default.
Definition InteractiveViewer.h:494
unsigned int displayedTopLevelComponents
number of top-level component that are currently displayed
Definition InteractiveViewer.h:383
InteractiveViewerFrame * myWidget
the InteractiveViewer myWidget
Definition InteractiveViewer.h:399
QAction * pickCellRegionAction
Definition InteractiveViewer.h:478
RendererWidget * getRendererWidget()
return interactiveViewer RendererWidget
Definition InteractiveViewer.h:277
HighlightMode
describes the current mode of display.
Definition InteractiveViewer.h:140
@ SELECTION
the selected Components are in default mode, the non-selected Components are shaded
Definition InteractiveViewer.h:142
@ OFF
both selected and non-selected Components are in default mode
Definition InteractiveViewer.h:141
QAction * controlModeTrackballAction
to change the camera control mode
Definition InteractiveViewer.h:445
QAction * pickPointAction
action of the picking menu
Definition InteractiveViewer.h:476
QAction * pickLocationAction
Definition InteractiveViewer.h:480
QAction * highlightSelectionOnlyAction
Definition InteractiveViewer.h:441
QMap< QString, vtkSmartPointerCamera > cameraMap
all the available camera
Definition InteractiveViewer.h:386
Property * pointSizeProperty
Property which defines the point size of each point in the 3D viewer.
Definition InteractiveViewer.h:587
QFrame * sideFrame
the right side myWidget (this is where the slider and screenshot buttons are shown)
Definition InteractiveViewer.h:402
QMenu * viewerMenu
the QMenu for the InteractiveViewer
Definition InteractiveViewer.h:411
QMultiMap< Component *, vtkSmartPointer< vtkProp > > actorMap
the map containing all the actors in the InteractiveViewer
Definition InteractiveViewer.h:362
std::vector< Component * > pickedComponent
list of Component that are currently picked, correctly displayed in the InteractiveViewer,...
Definition InteractiveViewer.h:491
ViewerType
there is two possibilities: this InteractiveViewer is used to display slices or geometry
Definition InteractiveViewer.h:118
@ SLICE_VIEWER
display slices (the view is blocked in 2D and the slider is available)
Definition InteractiveViewer.h:119
QComboBox * orientationCombo
Definition InteractiveViewer.h:423
QAction * toggleScreenshotAction
visibility of the screenshot action in the side toolbar of slice viewer
Definition InteractiveViewer.h:473
QMap< vtkSmartPointer< vtkActor2D >, QVector3D > transformed2DActors
the map containing the initial position of the vtkActor2D They have to be transformed from the creati...
Definition InteractiveViewer.h:368
This class describes a property object.
Definition PropertyObject.h:72
This class describes a property that can be used in components and actions or any class that needs to...
Definition Property.h:306
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition RendererWidget.h:91
CameraOrientation
describes the initial position and orientation of the default camera.
Definition RendererWidget.h:107
ControlMode
list of possible user interaction control mode
Definition RendererWidget.h:117
A utility class to have QSpinBox and QSlider synchronized.
Definition SliderSpinBoxWidget.h:45
Viewer is an abstract class that is the base class for all viewers.
Definition Viewer.h:182
Definition Action.cpp:40
vtkSmartPointer< vtkCamera > vtkSmartPointerCamera
Definition InteractiveViewer.h:67