Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
RendererWidget.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#ifndef RENDERERWIDGET_H
27#define RENDERERWIDGET_H
28
29#ifdef CAMITK_ERROR
30#error "Header Error: headers reordering required. Please include Log.h after including RendererWidget.h and InteractiveViewer.h or any OpenGL window based class."
31#endif
32
33// -- Core stuff
34#include "CamiTKAPI.h"
35
36// -- VTK stuff
37#include <vtkVersion.h>
38#include <vtkPicker.h> // Needed for smart pointers
39// disable warning generated by clang about the surrounded headers
40#include "CamiTKDisableWarnings"
41#include <QVTKInteractor.h>
42#include "CamiTKReEnableWarnings"
43
44// -- VTK stuff classes
45class vtkInteractorStyle;
46class vtkRenderer;
47class vtkProp;
48class vtkActor;
49class vtkActor2D;
50class vtkScalarBarActor;
51class vtkEventQtSlotConnect;
52class vtkCallbackCommand;
53class vtkCamera;
54class vtkAxesActor;
55class vtkAnnotatedCubeActor;
56class vtkScalarBarWidget;
57class vtkTextMapper;
58class vtkAbstractPropPicker;
59class vtkLogoWidget;
60
61// Define CamiTKQVTKWidget for VTK9
62#include <QVTKOpenGLNativeWidget.h>
63#include <vtkGenericOpenGLRenderWindow.h>
64
65using CamiTKQVTKWidget = QVTKOpenGLNativeWidget;
66
67
68
69namespace camitk {
70
71class vtkInteractorStylePick;
72
92 Q_OBJECT
93
94public :
95
114 Q_ENUM(CameraOrientation) // so that it can be used in property editor
115
116
123 Q_ENUM(ControlMode)
124
125
132
145 RendererWidget(QWidget* parent = nullptr, ControlMode mode = RendererWidget::TRACKBALL);
146
148 ~RendererWidget() override;
149
152
153 void setAreaPicking(bool areaPicking);
154
156 ControlMode getControlMode() const;
157
159 void setControlMode(ControlMode mode);
160
164 void setPicker(vtkSmartPointer<vtkAbstractPropPicker> woodyWood);
165
167 void keyPressEvent(QKeyEvent* e) override;
168
172 void screenshot(QString filename);
173
175 void refresh();
177
181 void setBackfaceCulling(bool);
182
184 bool getBackfaceCulling() const;
185
187 void setFxaaAntialiasing(bool);
188
190 bool getFxaaAntialiasing() const;
191
193 void setCameraOrientation(RendererWidget::CameraOrientation);
194
196 RendererWidget::CameraOrientation getCameraOrientation() const;
197
199 void setLightFollowCamera(bool);
200
202 bool getLightFollowCamera() const;
203
205 void setPointSize(double size);
206
208 double getPointSize() const;
209
211 void rotateCamera(double angle, int axe);
212
217 void resetCamera();
218
220 void resetCamera(double* bounds);
221
223 void getCameraSettings(double* position, double* focalPoint, double* viewUp);
224
226 void setActiveCamera(vtkCamera* cam);
227
229 vtkCamera* getActiveCamera();
230
232 vtkSmartPointer<QVTKInteractor> getInteractor();
233
235 vtkSmartPointer<vtkRenderWindow> getRenderWindow();
236
238 void getMouse3DCoordinates(double& x, double& y, double& z);
239
241 void setBackgroundColor(double, double, double);
242
244 void getBackgroundColor(double&, double&, double&);
245
247 bool getGradientBackground();
248
250 void setGradientBackground(bool);
251
253 void toogle3DRedBlue();
254
256 void toggleLogo(bool);
257
259 void toggleAxes(bool);
260
262 void updateAxes();
263
265 void toggleOrientationDecorations(bool);
266
268 void setOrientationDecorationsLetters(QStringList letters);
269
271 void setColorScale(bool);
272
274 bool getColorScale() const;
275
280 void setColorScaleMinMax(double m, double M);
281
285 void setColorScaleTitle(QString t);
286
288 void computeVisiblePropBounds(double* bounds);
289
293 void resetClippingPlanes(double* bounds = nullptr);
295
298
307 void addProp(vtkSmartPointer<vtkProp> p, bool refresh = false);
308
310 bool containsProp(vtkSmartPointer<vtkProp>);
311
316 void removeProp(vtkSmartPointer<vtkProp> p, bool refresh = false);
317
318protected slots:
322 void startPicking();
323
325 void endPicking();
326
328
329signals :
330
334 void actorPicked(vtkSmartPointer<vtkPicker>);
335
339
340protected:
341
343 void mousePressEvent(QMouseEvent* event) override;
344
346 void mouseReleaseEvent(QMouseEvent* event) override;
347
349 void mouseMoveEvent(QMouseEvent* event) override;
350
351protected :
352
356 vtkSmartPointer<QVTKInteractor> renderWindowInteractor;
357
359 vtkSmartPointer<vtkInteractorStyle> controlInteractorStyle;
360
363
365
369 void resetCameraSettings();
370
372 vtkSmartPointer<vtkRenderer> renderer;
373
376
377 // Is FXAA antialiasing on?
379
382
385
387 double pointSize;
388
392
395
397 vtkSmartPointer<vtkInteractorStylePick> pickInteractorStyle;
398
400
405
408
410 vtkSmartPointer<vtkLogoWidget> logoWidget;
411
414
416 vtkSmartPointer<vtkScalarBarActor> colorScale;
417
419 vtkSmartPointer<vtkScalarBarWidget> colorBarWidget;
420
422 vtkSmartPointer<vtkAxesActor> axes;
423
425 vtkSmartPointer<vtkAnnotatedCubeActor> annotatedCube;
426
428 vtkSmartPointer<vtkActor2D> orientationDecorationActors[4];
429
431 vtkSmartPointer<vtkTextMapper> orientationDecorationsTextMapper[4];
432
434
435};
436
437}
438
439#endif //RENDERERWIDGET_H
440
#define CAMITK_API
Definition CamiTKAPI.h:66
QVTKOpenGLNativeWidget CamiTKQVTKWidget
Definition RendererWidget.h:65
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition RendererWidget.h:91
bool displayColorScale
is the color scale currently displayed
Definition RendererWidget.h:413
CameraOrientation
describes the initial position and orientation of the default camera.
Definition RendererWidget.h:107
@ RIGHT_DOWN
World axes are seen so that x points to the right, y points downward.
Definition RendererWidget.h:108
@ LEFT_BACK
Definition RendererWidget.h:111
@ BACK_DOWN
< World axes are seen so that x points to the left, y points backward. For Medical Images Coronal Vie...
Definition RendererWidget.h:112
@ RIGHT_UP
World axes are seen so that x points to the right, y points upward.
Definition RendererWidget.h:110
@ LEFT_UP
World axes are seen so that x points to the left, y points upward.
Definition RendererWidget.h:109
vtkSmartPointer< vtkRenderer > renderer
The current renderer.
Definition RendererWidget.h:372
vtkSmartPointer< vtkAnnotatedCubeActor > annotatedCube
annotated cube actor
Definition RendererWidget.h:425
ControlMode controlMode
current control mode
Definition RendererWidget.h:362
vtkSmartPointer< vtkInteractorStylePick > pickInteractorStyle
picking interactor
Definition RendererWidget.h:397
bool lightFollowCamera
Is the light following the camera.
Definition RendererWidget.h:384
ControlMode
list of possible user interaction control mode
Definition RendererWidget.h:117
@ JOYSTICK
the mouse is used a joystick
Definition RendererWidget.h:118
@ TRACKBALL_2D
same as TRACKBALL but does not allow rotation using left button (but zoom and displacement parallel t...
Definition RendererWidget.h:120
@ TRACKBALL
the mouse is used as a trackball (default)
Definition RendererWidget.h:119
bool fxaaAntialiasing
Definition RendererWidget.h:378
bool displayLogo
is the logo displayed
Definition RendererWidget.h:407
vtkSmartPointer< vtkScalarBarWidget > colorBarWidget
the scalar bar widget
Definition RendererWidget.h:419
vtkSmartPointer< vtkAxesActor > axes
axes actor
Definition RendererWidget.h:422
double pointSize
default point size
Definition RendererWidget.h:387
vtkSmartPointer< QVTKInteractor > renderWindowInteractor
Definition RendererWidget.h:356
void rightButtonPressed()
send when the mouse right button is clicked
vtkSmartPointer< vtkScalarBarActor > colorScale
the color scale displaying the lookup table + values
Definition RendererWidget.h:416
vtkSmartPointer< vtkInteractorStyle > controlInteractorStyle
for the interaction with the scene
Definition RendererWidget.h:359
bool rendering3DRedBlue
is rendering in 3D stereo red/blue
Definition RendererWidget.h:390
void actorPicked(vtkSmartPointer< vtkPicker >)
vtkSmartPointer< vtkLogoWidget > logoWidget
logo widget
Definition RendererWidget.h:410
CameraOrientation cameraOrientation
state of the initial camera orientation
Definition RendererWidget.h:381
bool backfaceCulling
Is back face culling on?
Definition RendererWidget.h:375
MouseButtonState
state of the pressed button (for 3 buttons mouse)
Definition RendererWidget.h:126
@ LEFT_BUTTON
the mouse left button is currently pressed
Definition RendererWidget.h:128
@ NO_BUTTON
no buttons are currently pressed
Definition RendererWidget.h:127
@ MIDDLE_BUTTON
the mouse middle button is currently pressed (or 3rd button emulation)
Definition RendererWidget.h:129
bool displayGradient
Definition RendererWidget.h:404
Definition Action.cpp:40