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. More...
 
 ~TractionSensorGraphic ()
 Destructor. More...
 
void setVector (const wVector vector)
 Sets the vector to draw. The vector must be in the object frame of reference. More...
 
- 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())
 
const wMatrixgetDisplacement () const
 
void setDisplacement (const wMatrix &displacement)
 
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)
 
- Public Member Functions inherited from WObject
 WObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity(), bool addToWorld=true)
 
QColor color () const
 
void drawLocalAxes (bool d)
 
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
 
virtual void postUpdate ()
 
virtual void preUpdate ()
 
void setAlpha (int alpha)
 
void setColor (QColor c)
 
void setInvisible (bool b)
 
void setLabel (QString label)
 
void setLabel (QString label, wVector pos, QColor color)
 
void setLabel (QString label, wVector pos)
 
void setLabelColor (const QColor &color)
 
void setLabelPosition (const wVector &pos)
 
void setMatrix (const wMatrix &newm)
 
void setPosition (real x, real y, real z)
 
void setPosition (const wVector &newpos)
 
void setTexture (QString textureName)
 
void setUseColorTextureOfOwner (bool b)
 
void showLabel (bool show)
 
QString texture () const
 
bool useColorTextureOfOwner () const
 
const Worldworld () const
 
Worldworld ()
 
- Public Member Functions inherited from Ownable
const QList< Owned > & owned () const
 
Ownableowner () const
 
void setOwner (Ownable *owner, bool destroy=true)
 

Protected Member Functions

void drawArrow (wVector vector, real radius, real maxTipLength, QColor col, RenderWObject *renderer, QGLContext *gw)
 Draws an arrow. More...
 
real limitComponent (real v, bool &limited)
 Limits the component to be between m_minLength and m_maxLength. More...
 
virtual void render (RenderWObject *renderer, QGLContext *gw)
 Performs the actual drawing. More...
 
- 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 renderAABB (RenderWObject *renderer, RenderWorld *gw)
 
void updateMatrixFromAttachedObject ()
 
- Protected Member Functions inherited from WObject
virtual void changedMatrix ()
 

Protected Attributes

const real m_maxLength
 The maximum length of the vector. More...
 
const real m_maxTipLength
 The maximum length of the tip of the vector. More...
 
const real m_minLength
 The minimum length of the vector. More...
 
WObject *const m_object
 The object to which this representation is attached. More...
 
const real m_radius
 The radius of the arrow. The length depends on the vector intensity. More...
 
const real m_scale
 The scaling factor for the vector length. More...
 
wVector m_vector
 The vector to represent. More...
 
QMutex m_vectorMutex
 The mutex protecting the m_vector vector. More...
 
- 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 Ownable
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, WObject::setTexture(), and WObject::setUseColorTextureOfOwner().

~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 WObject::color(), RenderWObject::container(), RenderWObjectContainer::drawCylinder(), wMatrix::grammSchmidt(), WObject::matrix(), farsa::min(), WObject::setColor(), and RenderWObjectContainer::setupColorTexture().

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 WObject::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: