Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Protected Member Functions | Private Types | Private Member Functions | List of all members
camitk::RendererWidget Class Reference

RendererWidget implements all support methods to use camiTK with Qt interface. More...

#include <RendererWidget.h>

Classes

class  ScreenshotFormatInfo
 sub-class containing all information concerning exporting images (screenshot) More...

Protected Member Functions

virtual void mouseMoveEvent (QMouseEvent *event)
 overloaded mouse move handler because a potentialbug in vtk 5.2.1
virtual void mouseReleaseEvent (QMouseEvent *event)
 overloaded mouse release handler because a potentialbug in vtk 5.2.1

Static Protected Member Functions

screenshot management

build the map

static void buildScreenshotMap ()
static const ScreenshotFormatInfogetScreenshotFormatInfo (QString)
 get the information from the extension (QString)

Protected Attributes

extra actors managements

is the gradient background displayed

bool displayGradient
bool displayCopyright
 is the copyright text displayed
vtkSmartPointer< vtkActor2D > copyrightTextActor
 copyright text vtk actor
bool displayColorScale
 is the color scale currently displayed
vtkSmartPointer
< vtkScalarBarActor > 
colorScale
 the color scale displaying the lookup table + values
vtkSmartPointer
< vtkScalarBarWidget > 
colorBarWidget
 the scalar bar widget
vtkSmartPointer< vtkAxesActor > axes
 axes actor
vtkSmartPointer
< vtkAnnotatedCubeActor > 
annotatedCube
 annotated cube actor

Private Types

enum  ControlMode { JOYSTICK, TRACKBALL, TRACKBALL_2D, NONE }
 list of possible user interaction control mode More...
enum  MouseButtonState { NO_BUTTON, LEFT_BUTTON, MIDDLE_BUTTON, RIGHT_BUTTON }
 state of the pressed button (for 3 buttons mouse) More...
enum  ScreenshotFormat {
  PNG = 0, JPG, BMP, PS,
  EPS, PDF, TEX, SVG,
  OBJ, RIB, VRML, NOT_SUPPORTED
}
 list of supported screenshot export formats More...

Private Member Functions

 RendererWidget (QWidget *parent=0, ControlMode mode=RendererWidget::TRACKBALL)
 constructors.
 ~RendererWidget ()
 destructor
add/manipulate actors
void addProp (vtkSmartPointer< vtkProp > p, bool refresh=false)
 add a vtkActor or vtkActor2D, updating the cull face depending on the current state.
bool containsProp (vtkSmartPointer< vtkProp >)
 is the given vtkProp (e.g. vtkActor or vtkActor2D) in this renderer
void removeProp (vtkSmartPointer< vtkProp > p, bool refresh=false)
 remove the given vtkProp (e.g.
void actorTransform (vtkSmartPointer< vtkActor >, double *, int, double **, double *, double *)
 perform the transformation of the actor

picking and interaction

to manage interactions

vtkSmartPointer< QVTKInteractor > interactor
vtkSmartPointer
< vtkInteractorStyle > 
interactorStyle
 for the interaction with the scene
ControlMode controlMode
 current control mode
ControlMode getControlMode () const
void setControlMode (ControlMode mode)
 Set the interaction like trackball or joystick style.
void setPicker (vtkSmartPointer< vtkPicker > woodyWood)
 set the picker to handle the action
void pick ()
 Perform picking using the current mouse position.
void pickActor (int x, int y)
 Perform picking from screen coordinates.
void keyPressEvent (QKeyEvent *e)
 key events (do nothing but pass on e to the parent widget), please do not add any shortcut management here (see note in implementation)!
void screenshot (QString filename)
 save the screenshot in a file
void refresh ()
 refresh the display
static const ScreenshotFormatInfogetScreenshotFormatInfo (unsigned int)
 return the information concerning the supporting format using an index corresponding to the enum (check index validity)
static const ScreenshotFormatInfogetScreenshotFormatInfo (ScreenshotFormat)
 retun the information concerning the supporting format using an index corresponding to the enum (check index validity)
void leftClick ()
void rightClick ()
 manage right mouse click interactions, can emit rightButtonPressed() signal
void actorPicked (vtkSmartPointer< vtkPicker >)
void rightButtonPressed ()
 send when the mouse right button is clicked

view/camera settings

Reset camera settings (position, what is looked at and how)

vtkSmartPointer< vtkRenderer > renderer
 The current renderer.
bool backfaceCulling
 Is back face culling on?
CameraOrientation cameraOrientation
 state of the initial camera orientation
bool lightFollowCamera
 Is the light following the camera.
double pointSize
 default point size
bool rendering3DRedBlue
 is rendering in 3D stereo red/blue
void setBackfaceCulling (bool)
bool getBackfaceCulling () const
 Get the current state of backface culling.
void setCameraOrientation (RendererWidget::CameraOrientation)
 Set the current axes mode.
RendererWidget::CameraOrientation getCameraOrientation () const
 Return the current axes mode.
void setLightFollowCamera (bool)
 Set/unset the light to follow the camera.
bool getLightFollowCamera () const
 Get the current state of the property.
void setPointSize (double size)
 set the default point size
double getPointSize () const
 get the current value of point size
void rotateCamera (double angle, int axe)
 Rotate the camera around param "axe" of "angle" degrees.
void resetCamera ()
 reset the camera to the default position, default FOV.
void resetCamera (double bounds[6])
 reset the camera to the default position, default FOV and use the given bounds to focus on
void getCameraSettings (double position[3], double focalPoint[3], double viewUp[3])
 get camera settings information (position, what is looked at and how) in world coordinates
void setActiveCamera (vtkCamera *cam)
 set active camera
vtkCamera * getActiveCamera ()
 get the active camera
void getMouse3DCoordinates (double &x, double &y, double &z)
 get the mouse coordinates in 3D
void setBackgroundColor (double, double, double)
 set the background color (rgb)
void getBackgroundColor (double &, double &, double &)
 get the background color (rgb)
bool getGradientBackground ()
 get the current state of the gradient background
void setGradientBackground (bool)
 set the gradient background
void toogle3DRedBlue ()
 toggle stereo 3D red/blue rendering (you will need red/blue glasses)
void toggleCopyright (bool)
 toggle copyright text
void toggleAxes (bool)
 display the axes
void updateAxes ()
 update the axes sizes
void setColorScale (bool)
 display the color scale in the viewport, use setColorScaleMinMax to change the displayed values
bool getColorScale () const
 get the color display state
void setColorScaleMinMax (double m, double M)
 set the min and max values.
void setColorScaleTitle (QString t)
 set the color scale title.
void computeVisiblePropBounds (double bounds[6])
 get the bounding box of all visible actors [xmin,xmax, ymin,ymax, zmin,zmax]
void resetCameraSettings ()

callback and interaction

manage connections between vtk objets events and qt slots

vtkSmartPointer
< vtkEventQtSlotConnect > 
connector
vtkSmartPointer
< vtkCallbackCommand > 
pickingButtonDiverter
 the callback to remove left button interaction while in picking mode
bool pickingDiverter
 is the picking diverter used
static void divertionCallback (vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
 a diverter observer callback (to be used to divert undesired events)

Detailed Description

RendererWidget implements all support methods to use camiTK with Qt interface.

This class wraps the necessary VTK method for rendering, interactions, and signal/slot connections. This class should be usable completely independantly of Core.

The Core companion class is InteractiveViewer (which delegates all vtk stuff to RendererWidget.

It is directly based on QVTKWidget, the GUI support class available in Vtk version >= 5.0 This is a pure Qt/vtk wrapper class (no Core stuff).

For developers: please check the coding policy in InteractiveViewer API documentation first.

Member Enumeration Documentation

list of possible user interaction control mode

Enumerator:
JOYSTICK 

the mouse is used a joystick

TRACKBALL 

the mouse is used as a trackball (default)

TRACKBALL_2D 

same as TRACKBALL but does not allow rotation using left button (but zoom and displacement parallel to slice is allowed)

NONE 

state of the pressed button (for 3 buttons mouse)

Enumerator:
NO_BUTTON 
LEFT_BUTTON 
MIDDLE_BUTTON 
RIGHT_BUTTON 

list of supported screenshot export formats

Enumerator:
PNG 

Portable Network Graphics.

JPG 

JPEG.

BMP 

Bitmap.

PS 

PostScript.

EPS 

Encapsulated PostScript.

PDF 

Portable Document Format.

TEX 

LaTeX (only the text is exported)

SVG 

Scalable Vector Graphics.

OBJ 

Alias Wavefront .OBJ.

RIB 

RenderMan/BMRT .RIB.

VRML 

VRML 2.0.

NOT_SUPPORTED 

Constructor & Destructor Documentation

camitk::RendererWidget::RendererWidget ( QWidget *  parent = 0,
ControlMode  mode = RendererWidget::TRACKBALL 
)
private

constructors.

By default:

  • the backface culling is off,
  • the interaction mode is controlling the camera
  • the light follow the camera
  • the copyright is shown
  • the gradient background is not shown
Parameters
parentthe parent widget
modethe mouse interaction control mode (default is TRACKBALL)

References addProp(), annotatedCube, axes, backfaceCulling, buildScreenshotMap(), cameraOrientation, colorBarWidget, connector, controlMode, copyrightTextActor, displayColorScale, displayCopyright, displayGradient, divertionCallback(), interactor, interactorStyle, leftClick(), NONE, pickingButtonDiverter, pickingDiverter, pointSize, renderer, rendering3DRedBlue, rightClick(), setBackgroundColor(), setCameraOrientation(), and setControlMode().

camitk::RendererWidget::~RendererWidget ( )
private

destructor

Member Function Documentation

void camitk::RendererWidget::actorPicked ( vtkSmartPointer< vtkPicker >  )
signal

Referenced by mouseReleaseEvent(), and pickActor().

void camitk::RendererWidget::actorTransform ( vtkSmartPointer< vtkActor >  actor,
double *  boxCenter,
int  numRotation,
double **  rotate,
double *  translate,
double *  scale 
)
private

perform the transformation of the actor

void camitk::RendererWidget::addProp ( vtkSmartPointer< vtkProp >  p,
bool  refresh = false 
)
private

add a vtkActor or vtkActor2D, updating the cull face depending on the current state.

The method checks it is not already there first. This method is "clever": it does different things (that should be documented bellow), depending on the type of the vtkProp

Action performed depending on the vtkProp (true) type:

  • vtkActor: apply the current backface culling and point size property to the actor.
    Parameters
    pthe vtkProp to add to the scene
    refreshif true the axes are refreshed (default false)

References backfaceCulling, containsProp(), pointSize, renderer, and updateAxes().

Referenced by camitk::InteractiveViewer::addActor(), RendererWidget(), setGradientBackground(), and toggleCopyright().

void camitk::RendererWidget::buildScreenshotMap ( )
staticprotected

References BMP, EPS, JPG, NOT_SUPPORTED, OBJ, PDF, PNG, PS, RIB, camitk::screenshotMap, SVG, TEX, and VRML.

Referenced by RendererWidget().

void camitk::RendererWidget::computeVisiblePropBounds ( double  bounds[6])
private

get the bounding box of all visible actors [xmin,xmax, ymin,ymax, zmin,zmax]

References renderer.

Referenced by camitk::InteractiveViewer::getBounds(), camitk::InteractiveViewer::keyPressEvent(), and updateAxes().

bool camitk::RendererWidget::containsProp ( vtkSmartPointer< vtkProp >  prop)
private

is the given vtkProp (e.g. vtkActor or vtkActor2D) in this renderer

References renderer.

Referenced by addProp(), and removeProp().

static void camitk::RendererWidget::divertionCallback ( vtkObject *  caller,
unsigned long  eid,
void *  clientdata,
void *  calldata 
)
inlinestaticprotected

a diverter observer callback (to be used to divert undesired events)

Referenced by RendererWidget().

vtkCamera * camitk::RendererWidget::getActiveCamera ( )
private

get the active camera

References renderer.

Referenced by camitk::InteractiveViewer::InteractiveViewer().

bool camitk::RendererWidget::getBackfaceCulling ( ) const
private

Get the current state of backface culling.

References backfaceCulling.

Referenced by camitk::InteractiveViewer::getBackfaceCulling(), and camitk::InteractiveViewer::keyPressEvent().

void camitk::RendererWidget::getBackgroundColor ( double &  r,
double &  g,
double &  b 
)
private

get the background color (rgb)

References renderer.

Referenced by camitk::InteractiveViewer::getBackgroundColor().

RendererWidget::CameraOrientation camitk::RendererWidget::getCameraOrientation ( ) const
private
void camitk::RendererWidget::getCameraSettings ( double  position[3],
double  focalPoint[3],
double  viewUp[3] 
)
private

get camera settings information (position, what is looked at and how) in world coordinates

References renderer.

Referenced by camitk::InteractiveViewer::keyPressEvent().

bool camitk::RendererWidget::getColorScale ( ) const
private
RendererWidget::ControlMode camitk::RendererWidget::getControlMode ( ) const
private

References controlMode.

bool camitk::RendererWidget::getGradientBackground ( )
private

get the current state of the gradient background

References displayGradient.

Referenced by camitk::InteractiveViewer::getGradientBackground().

bool camitk::RendererWidget::getLightFollowCamera ( ) const
private

Get the current state of the property.

References lightFollowCamera.

Referenced by camitk::InteractiveViewer::keyPressEvent().

void camitk::RendererWidget::getMouse3DCoordinates ( double &  x,
double &  y,
double &  z 
)
private

get the mouse coordinates in 3D

References renderer.

double camitk::RendererWidget::getPointSize ( ) const
private

get the current value of point size

References pointSize.

Referenced by camitk::InteractiveViewer::getPointSize().

const RendererWidget::ScreenshotFormatInfo * camitk::RendererWidget::getScreenshotFormatInfo ( unsigned int  id)
staticprivate

return the information concerning the supporting format using an index corresponding to the enum (check index validity)

References NOT_SUPPORTED.

Referenced by getScreenshotFormatInfo(), screenshot(), and camitk::InteractiveViewer::screenshot().

const RendererWidget::ScreenshotFormatInfo * camitk::RendererWidget::getScreenshotFormatInfo ( ScreenshotFormat  f)
staticprivate

retun the information concerning the supporting format using an index corresponding to the enum (check index validity)

References camitk::screenshotMap.

const RendererWidget::ScreenshotFormatInfo * camitk::RendererWidget::getScreenshotFormatInfo ( QString  ext)
staticprotected

get the information from the extension (QString)

References camitk::RendererWidget::ScreenshotFormatInfo::extension, getScreenshotFormatInfo(), and NOT_SUPPORTED.

void camitk::RendererWidget::keyPressEvent ( QKeyEvent *  e)
private

key events (do nothing but pass on e to the parent widget), please do not add any shortcut management here (see note in implementation)!

void camitk::RendererWidget::leftClick ( )
protectedslot
void camitk::RendererWidget::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

overloaded mouse move handler because a potentialbug in vtk 5.2.1

References pick().

void camitk::RendererWidget::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

overloaded mouse release handler because a potentialbug in vtk 5.2.1

References actorPicked(), interactorStyle, pickingButtonDiverter, and pickingDiverter.

void camitk::RendererWidget::pick ( )
private

Perform picking using the current mouse position.

References pickActor().

Referenced by camitk::InteractiveViewer::keyPressEvent(), leftClick(), and mouseMoveEvent().

void camitk::RendererWidget::pickActor ( int  x,
int  y 
)
private

Perform picking from screen coordinates.

References actorPicked(), and renderer.

Referenced by pick().

void camitk::RendererWidget::refresh ( )
private
void camitk::RendererWidget::removeProp ( vtkSmartPointer< vtkProp >  p,
bool  refresh = false 
)
private

remove the given vtkProp (e.g.

vtkActor or vtkActor2D, such as color scale)

Parameters
pthe vtkProp to add to the scene
refreshif true the axes are refreshed (default false)

References containsProp(), renderer, and updateAxes().

Referenced by camitk::InteractiveViewer::removeAllActors(), setGradientBackground(), and toggleCopyright().

void camitk::RendererWidget::resetCamera ( )
private

reset the camera to the default position, default FOV.

The camera focal is set so that all the things in the scenes are visible (i.e. reset the camera clipping range based on the bounds of the visible actors. This ensures that no props are cut off)

References renderer, and resetCameraSettings().

Referenced by camitk::InteractiveViewer::resetCamera().

void camitk::RendererWidget::resetCamera ( double  bounds[6])
private

reset the camera to the default position, default FOV and use the given bounds to focus on

References renderer, and resetCameraSettings().

void camitk::RendererWidget::resetCameraSettings ( )
protected

References cameraOrientation, and renderer.

Referenced by resetCamera().

void camitk::RendererWidget::rightButtonPressed ( )
signal

send when the mouse right button is clicked

Referenced by rightClick().

void camitk::RendererWidget::rightClick ( )
protectedslot

manage right mouse click interactions, can emit rightButtonPressed() signal

References rightButtonPressed().

Referenced by RendererWidget().

void camitk::RendererWidget::rotateCamera ( double  angle,
int  axe 
)
private

Rotate the camera around param "axe" of "angle" degrees.

References renderer.

Referenced by camitk::InteractiveViewer::keyPressEvent().

void camitk::RendererWidget::screenshot ( QString  filename)
private

save the screenshot in a file

Parameters
filenamethe filename extension (suffix) must be supported (use getScreenshotFormatInfo to get the correct extension)

References BMP, EPS, getScreenshotFormatInfo(), JPG, NOT_SUPPORTED, OBJ, PDF, PNG, PS, RIB, camitk::screenshotMap, SVG, TEX, and VRML.

Referenced by camitk::InteractiveViewer::screenshot().

void camitk::RendererWidget::setActiveCamera ( vtkCamera *  cam)
private

set active camera

References renderer.

Referenced by camitk::InteractiveViewer::setActiveCamera().

void camitk::RendererWidget::setBackfaceCulling ( bool  culling)
private
void camitk::RendererWidget::setBackgroundColor ( double  r,
double  g,
double  b 
)
private
void camitk::RendererWidget::setCameraOrientation ( RendererWidget::CameraOrientation  a)
private
void camitk::RendererWidget::setColorScale ( bool  state)
private

display the color scale in the viewport, use setColorScaleMinMax to change the displayed values

References colorBarWidget, and displayColorScale.

Referenced by camitk::InteractiveViewer::setColorScale(), setColorScaleMinMax(), and setColorScaleTitle().

void camitk::RendererWidget::setColorScaleMinMax ( double  m,
double  M 
)
private

set the min and max values.

Parameters
mminimum value (blue)
Mmaximum value (red)

References colorBarWidget, displayColorScale, and setColorScale().

Referenced by camitk::InteractiveViewer::setColorScaleMinMax().

void camitk::RendererWidget::setColorScaleTitle ( QString  t)
private

set the color scale title.

Parameters
ttitle of the color scale

References colorBarWidget, displayColorScale, and setColorScale().

Referenced by camitk::InteractiveViewer::setColorScaleTitle().

void camitk::RendererWidget::setControlMode ( ControlMode  mode)
private
void camitk::RendererWidget::setGradientBackground ( bool  gb)
private
void camitk::RendererWidget::setLightFollowCamera ( bool  lightFollow)
private

Set/unset the light to follow the camera.

References interactor, lightFollowCamera, and renderer.

Referenced by camitk::InteractiveViewer::keyPressEvent().

void camitk::RendererWidget::setPicker ( vtkSmartPointer< vtkPicker >  woodyWood)
private

set the picker to handle the action

Parameters
woodyWoodthe picker (sorry, I could not resist this one!)

Referenced by camitk::InteractiveViewer::initPicking().

void camitk::RendererWidget::setPointSize ( double  size)
private

set the default point size

References pointSize, and renderer.

Referenced by camitk::InteractiveViewer::initSettings(), and camitk::InteractiveViewer::setPointSize().

void camitk::RendererWidget::toggleAxes ( bool  f)
private

display the axes

References annotatedCube, axes, and updateAxes().

Referenced by camitk::InteractiveViewer::toggleAxes().

void camitk::RendererWidget::toggleCopyright ( bool  c)
private
void camitk::RendererWidget::toogle3DRedBlue ( )
private

toggle stereo 3D red/blue rendering (you will need red/blue glasses)

References rendering3DRedBlue.

Referenced by camitk::InteractiveViewer::keyPressEvent().

void camitk::RendererWidget::updateAxes ( )
private

Member Data Documentation

vtkSmartPointer<vtkAnnotatedCubeActor> camitk::RendererWidget::annotatedCube
protected

annotated cube actor

Referenced by RendererWidget(), toggleAxes(), and updateAxes().

vtkSmartPointer<vtkAxesActor> camitk::RendererWidget::axes
protected

axes actor

Referenced by RendererWidget(), toggleAxes(), and updateAxes().

bool camitk::RendererWidget::backfaceCulling
protected

Is back face culling on?

Referenced by addProp(), getBackfaceCulling(), RendererWidget(), and setBackfaceCulling().

CameraOrientation camitk::RendererWidget::cameraOrientation
protected

state of the initial camera orientation

Referenced by getCameraOrientation(), RendererWidget(), resetCameraSettings(), and setCameraOrientation().

vtkSmartPointer<vtkScalarBarWidget> camitk::RendererWidget::colorBarWidget
protected

the scalar bar widget

Referenced by RendererWidget(), setColorScale(), setColorScaleMinMax(), and setColorScaleTitle().

vtkSmartPointer<vtkScalarBarActor> camitk::RendererWidget::colorScale
protected

the color scale displaying the lookup table + values

vtkSmartPointer<vtkEventQtSlotConnect> camitk::RendererWidget::connector
protected

Referenced by RendererWidget().

ControlMode camitk::RendererWidget::controlMode
protected

current control mode

Referenced by getControlMode(), RendererWidget(), and setControlMode().

vtkSmartPointer<vtkActor2D> camitk::RendererWidget::copyrightTextActor
protected

copyright text vtk actor

Referenced by RendererWidget(), setBackgroundColor(), setGradientBackground(), and toggleCopyright().

bool camitk::RendererWidget::displayColorScale
protected

is the color scale currently displayed

Referenced by getColorScale(), RendererWidget(), setColorScale(), setColorScaleMinMax(), and setColorScaleTitle().

bool camitk::RendererWidget::displayCopyright
protected

is the copyright text displayed

Referenced by RendererWidget(), setGradientBackground(), and toggleCopyright().

bool camitk::RendererWidget::displayGradient
protected
vtkSmartPointer<QVTKInteractor> camitk::RendererWidget::interactor
protected
vtkSmartPointer<vtkInteractorStyle> camitk::RendererWidget::interactorStyle
protected

for the interaction with the scene

Referenced by leftClick(), mouseReleaseEvent(), RendererWidget(), and setControlMode().

bool camitk::RendererWidget::lightFollowCamera
protected

Is the light following the camera.

Referenced by getLightFollowCamera(), and setLightFollowCamera().

vtkSmartPointer<vtkCallbackCommand> camitk::RendererWidget::pickingButtonDiverter
protected

the callback to remove left button interaction while in picking mode

Referenced by leftClick(), mouseReleaseEvent(), and RendererWidget().

bool camitk::RendererWidget::pickingDiverter
protected

is the picking diverter used

Referenced by leftClick(), mouseReleaseEvent(), and RendererWidget().

double camitk::RendererWidget::pointSize
protected

default point size

Referenced by addProp(), getPointSize(), RendererWidget(), and setPointSize().

vtkSmartPointer<vtkRenderer> camitk::RendererWidget::renderer
protected
bool camitk::RendererWidget::rendering3DRedBlue
protected

is rendering in 3D stereo red/blue

Referenced by RendererWidget(), and toogle3DRedBlue().


The documentation for this class was generated from the following files: