Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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 #ifndef RENDERERWIDGET_H
27 #define RENDERERWIDGET_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 
32 // -- VTK stuff
33 #include <QVTKWidget.h>
34 #include <vtkSmartPointer.h>
35 
36 // -- VTK stuff classes
37 class vtkRenderer;
38 class vtkInteractorStyle;
39 class vtkPicker;
40 class vtkProp;
41 class vtkActor;
42 class vtkActor2D;
43 class vtkScalarBarActor;
44 class vtkEventQtSlotConnect;
45 class vtkCallbackCommand;
46 class vtkCamera;
47 class vtkAxesActor;
48 class vtkAnnotatedCubeActor;
49 class vtkScalarBarWidget;
50 
51 namespace camitk
52 {
53  // -- Core stuff classes
54 class GeometricObject;
55 
75 class CAMITK_API RendererWidget : public QVTKWidget
76 {
77  Q_OBJECT
78  Q_ENUMS(ControlMode CameraOrientation); // so that it can be used in property editor
79 
80 public :
81 
93  enum CameraOrientation {
96  RIGHT_UP
97  };
98 
100  enum ControlMode {
104  NONE
105  };
106 
112  RIGHT_BUTTON
113  };
114 
117  PNG = 0,
118  JPG,
119  BMP,
120  PS,
121  EPS,
122  PDF,
123  TEX,
124  SVG,
125  OBJ,
126  RIB,
128  NOT_SUPPORTED
129  };
130 
133  public:
137  QString extension;
139  QString description;
141  ScreenshotFormatInfo(ScreenshotFormat t, QString e, QString d) : type(t), extension(e), description(d) {}
143  ScreenshotFormatInfo() : type(NOT_SUPPORTED), extension(""), description("Not supported") {}
144  };
145 
158  RendererWidget(QWidget* parent = 0, ControlMode mode = RendererWidget::TRACKBALL);
159 
161  ~RendererWidget();
162 
166  ControlMode getControlMode() const;
167 
169  void setControlMode(ControlMode mode);
170 
174  void setPicker(vtkSmartPointer<vtkPicker> woodyWood);
175 
177  void pick();
178 
180  void pickActor(int x, int y);
181 
183  void keyPressEvent(QKeyEvent* e);
184 
187  static const ScreenshotFormatInfo * getScreenshotFormatInfo(unsigned int);
188 
191  static const ScreenshotFormatInfo * getScreenshotFormatInfo(ScreenshotFormat);
192 
196  void screenshot(QString filename);
197 
199  void refresh();
201 
205  void setBackfaceCulling(bool);
206 
208  bool getBackfaceCulling() const;
209 
211  void setCameraOrientation( RendererWidget::CameraOrientation );
212 
214  RendererWidget::CameraOrientation getCameraOrientation( ) const;
215 
217  void setLightFollowCamera(bool);
218 
220  bool getLightFollowCamera() const;
221 
223  void setPointSize(double size);
224 
226  double getPointSize() const;
227 
229  void rotateCamera(double angle, int axe);
230 
235  void resetCamera();
236 
238  void resetCamera(double *bounds);
239 
241  void getCameraSettings(double *position, double *focalPoint, double *viewUp);
242 
244  void setActiveCamera( vtkCamera * cam );
245 
247  vtkCamera * getActiveCamera();
248 
250  void getMouse3DCoordinates(double & x, double & y, double & z);
251 
253  void setBackgroundColor(double, double, double);
254 
256  void getBackgroundColor(double&, double&, double&);
257 
259  bool getGradientBackground();
260 
262  void setGradientBackground(bool);
263 
265  void toogle3DRedBlue();
266 
268  void toggleCopyright(bool);
269 
271  void toggleAxes(bool);
272 
274  void updateAxes();
275 
277  void setColorScale(bool);
278 
280  bool getColorScale() const;
281 
286  void setColorScaleMinMax(double m, double M);
287 
291  void setColorScaleTitle(QString t);
292 
294  void computeVisiblePropBounds(double *bounds);
296 
297 
300 
309  void addProp(vtkSmartPointer<vtkProp> p, bool refresh=false);
310 
312  bool containsProp(vtkSmartPointer<vtkProp>);
313 
318  void removeProp(vtkSmartPointer<vtkProp> p, bool refresh=false);
319 
321  void actorTransform(vtkSmartPointer<vtkActor>, double *, int , double **, double *, double *);
323 
324 
325 
326 protected slots:
330  void leftClick();
331 
333  void rightClick();
334 
336 
337 signals :
338 
342  void actorPicked(vtkSmartPointer<vtkPicker>);
343 
345  void rightButtonPressed();
347 
348 
349 
350 protected:
352  virtual void mouseReleaseEvent(QMouseEvent* event);
353 
355  virtual void mouseMoveEvent(QMouseEvent* event);
356 
357  protected :
358 
362  vtkSmartPointer<QVTKInteractor> interactor;
363 
365  vtkSmartPointer<vtkInteractorStyle> interactorStyle;
366 
369 
371 
375  void resetCameraSettings();
376 
378  vtkSmartPointer<vtkRenderer> renderer;
379 
382 
384  CameraOrientation cameraOrientation;
385 
388 
390  double pointSize;
391 
395 
399  vtkSmartPointer<vtkEventQtSlotConnect> connector;
400 
402  static void divertionCallback(vtkObject * caller, unsigned long eid, void *clientdata, void *calldata) {};
403 
405  vtkSmartPointer<vtkCallbackCommand> pickingButtonDiverter;
406 
409 
411 
415  static void buildScreenshotMap();
416 
418  static const ScreenshotFormatInfo * getScreenshotFormatInfo(QString);
420 
425 
428 
430  vtkSmartPointer<vtkActor2D> copyrightTextActor;
431 
434 
436  vtkSmartPointer<vtkScalarBarActor> colorScale;
437 
439  vtkSmartPointer<vtkScalarBarWidget> colorBarWidget;
440 
442  vtkSmartPointer<vtkAxesActor> axes;
443 
445  vtkSmartPointer<vtkAnnotatedCubeActor> annotatedCube;
447 
448 };
449 
450 }
451 
452 #endif //RENDERERWIDGET_H
453 
bool pickingDiverter
is the picking diverter used
Definition: RendererWidget.h:408
bool displayGradient
Definition: RendererWidget.h:424
Alias Wavefront .OBJ.
Definition: RendererWidget.h:125
Encapsulated PostScript.
Definition: RendererWidget.h:121
bool backfaceCulling
Is back face culling on?
Definition: RendererWidget.h:381
ControlMode
list of possible user interaction control mode
Definition: RendererWidget.h:100
vtkSmartPointer< QVTKInteractor > interactor
Definition: RendererWidget.h:362
bool displayColorScale
is the color scale currently displayed
Definition: RendererWidget.h:433
ScreenshotFormatInfo(ScreenshotFormat t, QString e, QString d)
Constructor.
Definition: RendererWidget.h:141
LaTeX (only the text is exported)
Definition: RendererWidget.h:123
vtkSmartPointer< vtkScalarBarWidget > colorBarWidget
the scalar bar widget
Definition: RendererWidget.h:439
PostScript.
Definition: RendererWidget.h:120
vtkSmartPointer< vtkScalarBarActor > colorScale
the color scale displaying the lookup table + values
Definition: RendererWidget.h:436
JPEG.
Definition: RendererWidget.h:118
RendererWidget implements all support methods to use camiTK with Qt interface.
Definition: RendererWidget.h:75
vtkSmartPointer< vtkRenderer > renderer
The current renderer.
Definition: RendererWidget.h:378
bool displayCopyright
is the copyright text displayed
Definition: RendererWidget.h:427
ScreenshotFormat type
the corresponding type (key)
Definition: RendererWidget.h:135
double pointSize
default point size
Definition: RendererWidget.h:390
vtkSmartPointer< vtkActor2D > copyrightTextActor
copyright text vtk actor
Definition: RendererWidget.h:430
vtkSmartPointer< vtkEventQtSlotConnect > connector
Definition: RendererWidget.h:399
ScreenshotFormatInfo()
default constructor
Definition: RendererWidget.h:143
VRML 2.0.
Definition: RendererWidget.h:127
same as TRACKBALL but does not allow rotation using left button (but zoom and displacement parallel t...
Definition: RendererWidget.h:103
#define CAMITK_API
Definition: CamiTKAPI.h:49
CameraOrientation cameraOrientation
state of the initial camera orientation
Definition: RendererWidget.h:384
the mouse left button is currently pressed
Definition: RendererWidget.h:110
QString extension
file extension (suffix)
Definition: RendererWidget.h:137
World axes are seen so that x points to the left, y points upward.
Definition: RendererWidget.h:95
the mouse middle button is currently pressed (or 3rd button emulation)
Definition: RendererWidget.h:111
the mouse is used as a trackball (default)
Definition: RendererWidget.h:102
bool lightFollowCamera
Is the light following the camera.
Definition: RendererWidget.h:387
the mouse is used a joystick
Definition: RendererWidget.h:101
Portable Document Format.
Definition: RendererWidget.h:122
vtkSmartPointer< vtkAnnotatedCubeActor > annotatedCube
annotated cube actor
Definition: RendererWidget.h:445
bool rendering3DRedBlue
is rendering in 3D stereo red/blue
Definition: RendererWidget.h:393
World axes are seen so that x points to the right, y points downward.
Definition: RendererWidget.h:94
MouseButtonState
state of the pressed button (for 3 buttons mouse)
Definition: RendererWidget.h:108
ScreenshotFormat
list of supported screenshot export formats
Definition: RendererWidget.h:116
CameraOrientation
describes the initial position and orientation of the default camera.
Definition: RendererWidget.h:93
vtkSmartPointer< vtkInteractorStyle > interactorStyle
for the interaction with the scene
Definition: RendererWidget.h:365
Scalable Vector Graphics.
Definition: RendererWidget.h:124
vtkSmartPointer< vtkAxesActor > axes
axes actor
Definition: RendererWidget.h:442
QString description
file format description
Definition: RendererWidget.h:139
no buttons are currently pressed
Definition: RendererWidget.h:109
sub-class containing all information concerning exporting images (screenshot)
Definition: RendererWidget.h:132
Bitmap.
Definition: RendererWidget.h:119
ControlMode controlMode
current control mode
Definition: RendererWidget.h:368
RenderMan/BMRT .RIB.
Definition: RendererWidget.h:126