ExtGLWidget Class Reference

An enhanced QGLWidget. More...

#include <qwt3d_extglwidget.h>

Inheritance diagram for ExtGLWidget:

Plot3D GraphPlot SurfacePlot VolumePlot GridPlot MeshPlot

List of all members.

Classes

struct  Light

Public Slots

void setRotation (double xVal, double yVal, double zVal)
void setShift (double xVal, double yVal, double zVal)
void setViewportShift (double xVal, double yVal)
void setScale (double xVal, double yVal, double zVal)
void setZoom (double)
void setOrtho (bool)
void enableMouse (bool val=true)
void disableMouse (bool val=true)
void enableKeyboard (bool val=true)
void disableKeyboard (bool val=true)
void enableLighting (bool val=true)
void disableLighting (bool val=true)
void setLightRotation (double xVal, double yVal, double zVal, unsigned int idx=0)
void setLightShift (double xVal, double yVal, double zVal, unsigned int idx=0)

Signals

void rotationChanged (double xAngle, double yAngle, double zAngle)
void shiftChanged (double xShift, double yShift, double zShift)
void vieportShiftChanged (double xShift, double yShift)
void scaleChanged (double xScale, double yScale, double zScale)
void zoomChanged (double)
void projectionChanged (bool)

Public Member Functions

 ExtGLWidget (QWidget *parent=0, const QGLWidget *shareWidget=0)
double xRotation () const
double yRotation () const
double zRotation () const
double xShift () const
double yShift () const
double zShift () const
double xViewportShift () const
double yViewportShift () const
double xScale () const
double yScale () const
double zScale () const
double zoom () const
bool ortho () const
void assignMouse (MouseState xrot, MouseState yrot, MouseState zrot, MouseState xscale, MouseState yscale, MouseState zscale, MouseState zoom, MouseState xshift, MouseState yshift)
bool mouseEnabled () const
void assignKeyboard (KeyboardState xrot_n, KeyboardState xrot_p, KeyboardState yrot_n, KeyboardState yrot_p, KeyboardState zrot_n, KeyboardState zrot_p, KeyboardState xscale_n, KeyboardState xscale_p, KeyboardState yscale_n, KeyboardState yscale_p, KeyboardState zscale_n, KeyboardState zscale_p, KeyboardState zoom_n, KeyboardState zoom_p, KeyboardState xshift_n, KeyboardState xshift_p, KeyboardState yshift_n, KeyboardState yshift_p)
bool keyboardEnabled () const
void setKeySpeed (double rot, double scale, double shift)
void keySpeed (double &rot, double &scale, double &shift) const
bool lightingEnabled () const
void illuminate (unsigned light=0)
void blowout (unsigned light=0)
void setMaterialComponent (GLenum property, double r, double g, double b, double a=1.0)
void setMaterialComponent (GLenum property, double intensity)
void setShininess (double exponent)
void setLightComponent (GLenum property, double r, double g, double b, double a=1.0, unsigned light=0)
void setLightComponent (GLenum property, double intensity, unsigned light=0)
double xLightRotation (unsigned idx=0) const
double yLightRotation (unsigned idx=0) const
double zLightRotation (unsigned idx=0) const
double xLightShift (unsigned idx=0) const
double yLightShift (unsigned idx=0) const
double zLightShift (unsigned idx=0) const

Protected Member Functions

void mousePressEvent (QMouseEvent *e)
void mouseReleaseEvent (QMouseEvent *e)
void mouseMoveEvent (QMouseEvent *e)
void wheelEvent (QWheelEvent *e)
void keyPressEvent (QKeyEvent *e)
void initializeGL ()
bool initializedGL () const
void applyLights ()


Detailed Description

The class covers mouse/keyboard handling, lighting and basic transformations, like scaling, shifting and rotating objects.

Constructor & Destructor Documentation

ExtGLWidget ( QWidget *  parent = 0,
const QGLWidget *  shareWidget = 0 
)

This should be the first call in your derived classes constructors.


Member Function Documentation

double xRotation (  )  const [inline]

Returns rotation around X axis [-360..360] (some angles are equivalent).

double yRotation (  )  const [inline]

Returns rotation around Y axis [-360..360] (some angles are equivalent).

double zRotation (  )  const [inline]

Returns rotation around Z axis [-360..360] (some angles are equivalent).

double xShift (  )  const [inline]

Returns shift along X axis (object coordinates).

double yShift (  )  const [inline]

Returns shift along Y axis (object coordinates).

double zShift (  )  const [inline]

Returns shift along Z axis (object coordinates).

double xViewportShift (  )  const [inline]

Returns relative shift [-1..1] along X axis (view coordinates).

double yViewportShift (  )  const [inline]

Returns relative shift [-1..1] along Y axis (view coordinates).

double xScale (  )  const [inline]

Returns scaling for X values [0..inf].

double yScale (  )  const [inline]

Returns scaling for Y values [0..inf].

double zScale (  )  const [inline]

Returns scaling for Z values [0..inf].

double zoom (  )  const [inline]

Returns zoom (0..inf).

bool ortho (  )  const [inline]

Returns orthogonal (true) or perspective (false) projection.

void assignMouse ( MouseState  xrot,
MouseState  yrot,
MouseState  zrot,
MouseState  xscale,
MouseState  yscale,
MouseState  zscale,
MouseState  zoom,
MouseState  xshift,
MouseState  yshift 
)

Sets the key/mousebutton combination for data/coordinatesystem moves inside the widget

default behaviour:

	rotate around x axis: Qt::LeftButton 
	rotate around y axis: Qt::LeftButton | Qt::ShiftButton
	rotate around z axis: Qt::LeftButton 
	scale x:              Qt::LeftButton | Qt::AltButton 
	scale y:              Qt::LeftButton | Qt::AltButton 
	scale z:              Qt::LeftButton | Qt::AltButton | Qt::ShiftButton
	zoom:                 Qt::LeftButton | Qt::AltButton | Qt::ControlButton
	shifting along x:     Qt::LeftButton | Qt::ControlButton 
	shifting along y:     Qt::LeftButton | Qt::ControlButton
	

mouseMoveEvent() evaluates this function - if overridden, their usefulness becomes somehow limited

bool mouseEnabled (  )  const

Returns true, if the widget accept mouse input from the user.

void assignKeyboard ( KeyboardState  xrot_n,
KeyboardState  xrot_p,
KeyboardState  yrot_n,
KeyboardState  yrot_p,
KeyboardState  zrot_n,
KeyboardState  zrot_p,
KeyboardState  xscale_n,
KeyboardState  xscale_p,
KeyboardState  yscale_n,
KeyboardState  yscale_p,
KeyboardState  zscale_n,
KeyboardState  zscale_p,
KeyboardState  zoom_n,
KeyboardState  zoom_p,
KeyboardState  xshift_n,
KeyboardState  xshift_p,
KeyboardState  yshift_n,
KeyboardState  yshift_p 
)

Sets the keybutton combination for data/coordinatesystem moves inside the widget

default behaviour:

	rotate around x axis: [Key_Down, Key_Up] 
	rotate around y axis: SHIFT+[Key_Right, Key_Left]
	rotate around z axis: [Key_Right, Key_Left] 
	scale x:              ALT+[Key_Right, Key_Left] 
	scale y:              ALT+[Key_Up, Key_Down] 
	scale z:              ALT+SHIFT[Key_Down, Key_Up] 
	zoom:                 ALT+CTRL+[Key_Down, Key_Up]
	shifting along x:     CTRL+[Key_Right, Key_Left] 
	shifting along z:     CTRL+[Key_Down, Key_Up]
	

bool keyboardEnabled (  )  const

Returns true, if the widget accept keyboard input from the user

void setKeySpeed ( double  rot,
double  scale,
double  shift 
)

Sets speed for keyboard driven transformations.

Values < 0 are ignored. Default is (3,5,5)

void keySpeed ( double &  rot,
double &  scale,
double &  shift 
) const

Gets speed for keyboard driven transformations.

bool lightingEnabled (  )  const

Returns true, if Lighting is enabled, false else

void illuminate ( unsigned  light = 0  ) 

Turn light on.

Parameters:
light light number [0..7]
See also:
setLight

void blowout ( unsigned  light = 0  ) 

Turn light off.

Parameters:
light light number [0..7]
See also:
setLight

void setMaterialComponent ( GLenum  property,
double  r,
double  g,
double  b,
double  a = 1.0 
)

Sets GL material properties

void setMaterialComponent ( GLenum  property,
double  intensity 
)

This function is for convenience. It sets GL material properties with the equal r,g,b values and a blending alpha with value 1.0

void setShininess ( double  exponent  ) 

Sets GL shininess

void setLightComponent ( GLenum  property,
double  r,
double  g,
double  b,
double  a = 1.0,
unsigned  light = 0 
)

Sets GL light properties for light 'light'

void setLightComponent ( GLenum  property,
double  intensity,
unsigned  light = 0 
)

This function is for convenience. It sets GL light properties with the equal r,g,b values and a blending alpha with value 1.0

double xLightRotation ( unsigned  idx = 0  )  const [inline]

Returns Light 'idx' rotation around X axis [-360..360] (some angles are equivalent).

double yLightRotation ( unsigned  idx = 0  )  const [inline]

Returns Light 'idx' rotation around Y axis [-360..360] (some angles are equivalent).

double zLightRotation ( unsigned  idx = 0  )  const [inline]

Returns Light 'idx' rotation around Z axis [-360..360] (some angles are equivalent).

double xLightShift ( unsigned  idx = 0  )  const [inline]

Returns shift of Light 'idx 'along X axis (object coordinates).

double yLightShift ( unsigned  idx = 0  )  const [inline]

Returns shift of Light 'idx 'along Y axis (object coordinates).

double zLightShift ( unsigned  idx = 0  )  const [inline]

Returns shift of Light 'idx 'along Z axis (object coordinates).

void rotationChanged ( double  xAngle,
double  yAngle,
double  zAngle 
) [signal]

Emitted, if the rotation is changed.

void shiftChanged ( double  xShift,
double  yShift,
double  zShift 
) [signal]

Emitted, if the shift is changed.

void vieportShiftChanged ( double  xShift,
double  yShift 
) [signal]

Emitted, if the viewport shift is changed.

void scaleChanged ( double  xScale,
double  yScale,
double  zScale 
) [signal]

Emitted, if the scaling is changed.

void zoomChanged ( double   )  [signal]

Emitted, if the zoom is changed.

void projectionChanged ( bool   )  [signal]

Emitted, if the projection mode is changed.

void setRotation ( double  xVal,
double  yVal,
double  zVal 
) [slot]

Set the rotation angle of the object. If you look along the respective axis towards ascending values, the rotation is performed in mathematical negative sense

Parameters:
xVal angle in degree to rotate around the X axis
yVal angle in degree to rotate around the Y axis
zVal angle in degree to rotate around the Z axis

void setShift ( double  xVal,
double  yVal,
double  zVal 
) [slot]

Set the shift in object (world) coordinates.

Parameters:
xVal shift along (world) X axis
yVal shift along (world) Y axis
zVal shift along (world) Z axis
See also:
setViewportShift()

void setViewportShift ( double  xVal,
double  yVal 
) [slot]

Performs shifting along screen axes. The shift moves points inside a sphere, which encloses the unscaled and unzoomed data by multiples of the spheres diameter

Parameters:
xVal shift along (view) X axis
yVal shift along (view) Y axis
See also:
setShift()

void setScale ( double  xVal,
double  yVal,
double  zVal 
) [slot]

Set the scale in object (world) coordinates.

Parameters:
xVal scaling for X values
yVal scaling for Y values
zVal scaling for Z values
A respective value of 1 represents no scaling;

void setZoom ( double  val  )  [slot]

Set the (zoom in addition to scale).

Parameters:
val zoom value (value == 1 indicates no zooming)

void setOrtho ( bool  val  )  [slot]

Set up ortogonal or perspective mode and updates widget

void enableMouse ( bool  val = true  )  [slot]

Enable mouse input.

The function has no effect if you derive from ExtGLWidget and overrides the mouse Function too careless. In this case check first against mouseEnabled() in your version of mouseMoveEvent() and wheelEvent(). A more fine grained input control can be achieved by combining assignMouse() with enableMouse().

void disableMouse ( bool  val = true  )  [slot]

Disable mouse input.

See also:
enableMouse()

void enableKeyboard ( bool  val = true  )  [slot]

Enable keyboard input.

The function has no effect if you derive from ExtGLWidget and overrides the keyboard Functions too careless. In this case check first against keyboardEnabled() in your version of keyPressEvent() A more fine grained input control can be achieved by combining assignKeyboard() with enableKeyboard().

void disableKeyboard ( bool  val = true  )  [slot]

Disable keyboard input.

See also:
enableKeyboard()

void enableLighting ( bool  val = true  )  [slot]

Turn Lighting on or off.

void disableLighting ( bool  val = true  )  [slot]

Turn Lighting on or off

void setLightRotation ( double  xVal,
double  yVal,
double  zVal,
unsigned int  idx = 0 
) [slot]

Rotate ligthsource[idx].

void setLightShift ( double  xVal,
double  yVal,
double  zVal,
unsigned int  idx = 0 
) [slot]

Shift ligthsource[idx].

void mousePressEvent ( QMouseEvent *  e  )  [protected]

Standard mouse button Function. Prepares the call to mouseMoveEvent

See also:
mouseMoveEvent()

void mouseReleaseEvent ( QMouseEvent *  e  )  [protected]

Standard mouse button Function. Completes the call to mouseMoveEvent

See also:
mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent *  e  )  [protected]

Standard mouse button Function

See also:
assignMouse()

void wheelEvent ( QWheelEvent *  e  )  [protected]

Standard wheel Function - zoom (wheel only) or z-scale (shift+wheel)

void keyPressEvent ( QKeyEvent *  e  )  [protected]

Standard keyboard handler. Uses the settings from setRotationKeyboard in order to perform rotations, shifts etc.

void initializeGL (  )  [protected]

Set up the OpenGL rendering state


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

Generated on Sun Jun 7 00:16:33 2009 for QwtPlot3D API by  doxygen 1.5.8