The graphical representation of the MarXbot traction sensor. More...

Inheritance diagram for TractionSensorGraphic:

Public Member Functions

 TractionSensorGraphic (WObject *object, const wVector &offset, real radius, real scale=1.0, real maxLength=1.0, real minLength=0.0, QString name="unamed")
 Constructor.
 ~TractionSensorGraphic ()
 Destructor.
void setVector (const wVector vector)
 Sets the vector to draw. The vector must be in the object frame of reference.
- Public Member Functions inherited from GraphicalWObject
 GraphicalWObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity())
WObjectattachedObject () const
void attachToObject (WObject *object, bool makeOwner=false, const wMatrix &displacement=wMatrix::identity())
QColor color () const
void drawLocalAxes (bool d)
const wMatrixgetDisplacement () const
bool isInvisible () const
const QString & label () const
const QColor & labelColor () const
const wVector & labelPosition () const
bool labelShown () const
bool localAxesDrawn () const
const wMatrixmatrix () const
QString name () const
 Ownable ()
const QList< Owned > & owned () const
Ownableowner () const
virtual void postUpdate ()
virtual void preUpdate ()
void setAlpha (int alpha)
void setColor (QColor c)
void setDisplacement (const wMatrix &displacement)
void setInvisible (bool b)
void setLabel (QString label)
void setLabel (QString label, wVector pos)
void setLabel (QString label, wVector pos, QColor color)
void setLabelColor (const QColor &color)
void setLabelPosition (const wVector &pos)
void setMatrix (const wMatrix &newm)
void setOwner (Ownable *owner, bool destroy=true)
void setPosition (const wVector &newpos)
void setPosition (real x, real y, real z)
void setTexture (QString textureName)
void setUseColorTextureOfOwner (bool b)
void showLabel (bool show)
QString texture () const
void updateAndCalculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm)
void updateAndCalculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint)
void updateAndRender (RenderWObject *renderer, QGLContext *gw)
void updateAndRenderAABB (RenderWObject *renderer, RenderWorld *gw)
bool useColorTextureOfOwner () const
 WObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity(), bool addToWorld=true)
Worldworld ()
const Worldworld () const

Protected Member Functions

void drawArrow (wVector vector, real radius, real maxTipLength, QColor col, RenderWObject *renderer, QGLContext *gw)
 Draws an arrow.
real limitComponent (real v, bool &limited)
 Limits the component to be between m_minLength and m_maxLength.
virtual void render (RenderWObject *renderer, QGLContext *gw)
 Performs the actual drawing.
- Protected Member Functions inherited from GraphicalWObject
virtual void calculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm)
virtual void calculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint)
virtual void changedMatrix ()
virtual void renderAABB (RenderWObject *renderer, RenderWorld *gw)
void updateMatrixFromAttachedObject ()

Protected Attributes

const real m_maxLength
 The maximum length of the vector.
const real m_maxTipLength
 The maximum length of the tip of the vector.
const real m_minLength
 The minimum length of the vector.
WObject *const m_object
 The object to which this representation is attached.
const real m_radius
 The radius of the arrow. The length depends on the vector intensity.
const real m_scale
 The scaling factor for the vector length.
wVector m_vector
 The vector to represent.
QMutex m_vectorMutex
 The mutex protecting the m_vector vector.
- Protected Attributes inherited from GraphicalWObject
QColor colorv
bool invisible
QColor labelcol
bool labeldrawn
wVector labelpos
QString labelv
bool localFrameOfReferenceDrawn
QString namev
QString texturev
wMatrix tm
bool usecolortextureofowner
Worldworldv
- Protected Attributes inherited from WObject
QColor colorv
bool invisible
QColor labelcol
bool labeldrawn
wVector labelpos
QString labelv
bool localFrameOfReferenceDrawn
QString namev
QString texturev
wMatrix tm
bool usecolortextureofowner
Worldworldv

Additional Inherited Members

- Public Types inherited from GraphicalWObject
typedef QList< OwnedOwnedList

Detailed Description

The graphical representation of the MarXbot traction sensor.

The arrow is drawn as a cylinder with a cone on top

Definition at line 703 of file marxbotsensors.cpp.

Constructor & Destructor Documentation

TractionSensorGraphic ( WObject object,
const wVector &  offset,
real  radius,
real  scale = 1.0,
real  maxLength = 1.0,
real  minLength = 0.0,
QString  name = "unamed" 
)
inline

Constructor.

This also sets a default color for the piece and sets handPiece to be our owner. This draws an arrow representing a vector

Parameters
objectthe object to which this representation is attached. This must not be NULL
offsetthe offset relative to object. The arrow starts from the offset in the frame of reference of the object
radiusthe radius of the arrow. The length depends on the vector intensity
scalethe scaling factor for the vector length
maxLengththe maximum length of the vector in each axis. If the vector is longer than this on, the arrow is drawn this length with a different color. This is the length BEFORE scaling
minLengththe minimum length of the vector in each axis. If the vector is shorter than this, the arrow is not drawn. This is the length BEFORE scaling
namethe name of this object

Definition at line 730 of file marxbotsensors.cpp.

References GraphicalWObject::attachToObject(), wMatrix::identity(), TractionSensorGraphic::m_object, GraphicalWObject::setTexture(), GraphicalWObject::setUseColorTextureOfOwner(), and wMatrix::w_pos.

~TractionSensorGraphic ( )
inline

Destructor.

Definition at line 754 of file marxbotsensors.cpp.

Member Function Documentation

void drawArrow ( wVector  vector,
real  radius,
real  maxTipLength,
QColor  col,
RenderWObject renderer,
QGLContext *  gw 
)
inlineprotected

Draws an arrow.

This function can only be called by render(). This uses the current frame of reference

Parameters
vectorthe vector to draw
radiusthe radius of the arrow to draw
maxTipLengththe maximum length of the tip of the arrow
colthe color of the arrow
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe OpenGL context

Definition at line 823 of file marxbotsensors.cpp.

References GraphicalWObject::color(), RenderWObject::container(), RenderWObjectContainer::drawCylinder(), wMatrix::grammSchmidt(), GraphicalWObject::matrix(), farsa::min(), GraphicalWObject::setColor(), RenderWObjectContainer::setupColorTexture(), and wMatrix::w_pos.

Referenced by TractionSensorGraphic::render().

real limitComponent ( real  v,
bool &  limited 
)
inlineprotected

Limits the component to be between m_minLength and m_maxLength.

This takes the sign of the component into account

Parameters
vthe value of the component to limit
limitedset to true if the value has been limited
Returns
the limited component

Definition at line 876 of file marxbotsensors.cpp.

References TractionSensorGraphic::m_maxLength, and TractionSensorGraphic::m_minLength.

Referenced by TractionSensorGraphic::render().

virtual void render ( RenderWObject renderer,
QGLContext *  gw 
)
inlineprotectedvirtual

Performs the actual drawing.

Draws the vector

Parameters
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe OpenGL context

Implements GraphicalWObject.

Definition at line 782 of file marxbotsensors.cpp.

References TractionSensorGraphic::drawArrow(), TractionSensorGraphic::limitComponent(), TractionSensorGraphic::m_maxTipLength, TractionSensorGraphic::m_radius, TractionSensorGraphic::m_scale, TractionSensorGraphic::m_vector, TractionSensorGraphic::m_vectorMutex, and GraphicalWObject::tm.

void setVector ( const wVector  vector)
inline

Sets the vector to draw. The vector must be in the object frame of reference.

This function is thread-safe

Parameters
vectorthe vector to draw. The vector must be in the object frame of reference

Definition at line 766 of file marxbotsensors.cpp.

References TractionSensorGraphic::m_vector, and TractionSensorGraphic::m_vectorMutex.

Referenced by MarXbotTractionSensor::update().

Member Data Documentation

const real m_maxLength
protected

The maximum length of the vector.

If the vector is longer than this, the arrow is drawn this length with a different color. This is the length BEFORE scaling

Definition at line 913 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::limitComponent().

const real m_maxTipLength
protected

The maximum length of the tip of the vector.

This is computed in the constructor

Definition at line 928 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::render().

const real m_minLength
protected

The minimum length of the vector.

If the vector is shorter than this, the arrow is not drawn. This is the length BEFORE scaling

Definition at line 921 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::limitComponent().

WObject* const m_object
protected

The object to which this representation is attached.

Definition at line 893 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::TractionSensorGraphic().

const real m_radius
protected

The radius of the arrow. The length depends on the vector intensity.

Definition at line 899 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::render().

const real m_scale
protected

The scaling factor for the vector length.

Definition at line 904 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::render().

wVector m_vector
protected

The vector to represent.

The vector is in the object frame of reference

Definition at line 935 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::render(), and TractionSensorGraphic::setVector().

QMutex m_vectorMutex
protected

The mutex protecting the m_vector vector.

The vector could be accessed by multiple threads concurrently, so we protect it with a mutex

Definition at line 943 of file marxbotsensors.cpp.

Referenced by TractionSensorGraphic::render(), and TractionSensorGraphic::setVector().


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