SOFA API  6a688117
Open source framework for multi-physics simuation
sofa::core::visual::DrawTool Class Referenceabstract

#include <DrawTool.h>

Utility class to perform debug drawing. More...

Inheritance diagram for sofa::core::visual::DrawTool:

Detailed Description

Utility class to perform debug drawing.

Class which contains a set of methods to perform minimal debug drawing regardless of the graphics API used. Components receive a pointer to the DrawTool through the VisualParams parameter of their draw method. Sofa provides a default concrete implementation of this class for the OpenGL API with the DrawToolGL class.

Public Member Functions

 DrawTool ()
 
virtual ~DrawTool ()
 
virtual void init ()=0
 
virtual void enableBlending ()=0
 
virtual void disableBlending ()=0
 
virtual void enableLighting ()=0
 
virtual void disableLighting ()=0
 
virtual void enableDepthTest ()=0
 
virtual void disableDepthTest ()=0
 
virtual void clear ()
 
Primitive rendering methods
virtual void drawPoints (const std::vector< Vector3 > &points, float size, const Vec4f &colour)=0
 
virtual void drawPoints (const std::vector< Vector3 > &points, float size, const std::vector< Vec4f > &colour)=0
 
virtual void drawLine (const Vector3 &p1, const Vector3 &p2, const Vec4f &colour)=0
 
virtual void drawInfiniteLine (const Vector3 &point, const Vector3 &direction, const Vec4f &color)=0
 
virtual void drawLines (const std::vector< Vector3 > &points, float size, const Vec4f &colour)=0
 
virtual void drawLines (const std::vector< Vector3 > &points, float size, const std::vector< Vec4f > &colours)=0
 
virtual void drawLines (const std::vector< Vector3 > &points, const std::vector< Vec2i > &index, float size, const Vec4f &colour)=0
 
virtual void drawLineStrip (const std::vector< Vector3 > &points, float size, const Vec4f &colour)=0
 
virtual void drawLineLoop (const std::vector< Vector3 > &points, float size, const Vec4f &colour)=0
 
virtual void drawDisk (float radius, double from, double to, int resolution, const Vec4f &color)=0
 
virtual void drawCircle (float radius, float lineThickness, int resolution, const Vec4f &color)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const Vec4f &colour)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const Vector3 &normal, const Vec4f &colour)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const std::vector< Vec3i > &index, const std::vector< Vector3 > &normal, const Vec4f &colour)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const std::vector< Vec3i > &index, const std::vector< Vector3 > &normal, const std::vector< Vec4f > &colour)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const std::vector< Vec4f > &colour)=0
 
virtual void drawTriangles (const std::vector< Vector3 > &points, const std::vector< Vector3 > &normal, const std::vector< Vec4f > &colour)=0
 
virtual void drawTriangleStrip (const std::vector< Vector3 > &points, const std::vector< Vector3 > &normal, const Vec4f &colour)=0
 
virtual void drawTriangleFan (const std::vector< Vector3 > &points, const std::vector< Vector3 > &normal, const Vec4f &colour)=0
 
virtual void drawFrame (const Vector3 &position, const Quaternion &orientation, const Vec3f &size)=0
 
virtual void drawFrame (const Vector3 &position, const Quaternion &orientation, const Vec3f &size, const Vec4f &colour)=0
 
virtual void drawSpheres (const std::vector< Vector3 > &points, const std::vector< float > &radius, const Vec4f &colour)=0
 
virtual void drawSpheres (const std::vector< Vector3 > &points, float radius, const Vec4f &colour)=0
 
virtual void drawFakeSpheres (const std::vector< Vector3 > &points, const std::vector< float > &radius, const Vec4f &colour)=0
 
virtual void drawFakeSpheres (const std::vector< Vector3 > &points, float radius, const Vec4f &colour)=0
 
virtual void drawCone (const Vector3 &p1, const Vector3 &p2, float radius1, float radius2, const Vec4f &colour, int subd=16)=0
 
virtual void drawCube (const float &radius, const Vec4f &colour, const int &subd=16)=0
 Draw a cube of size one centered on the current point. More...
 
virtual void drawCylinder (const Vector3 &p1, const Vector3 &p2, float radius, const Vec4f &colour, int subd=16)=0
 
virtual void drawCapsule (const Vector3 &p1, const Vector3 &p2, float radius, const Vec4f &colour, int subd=16)=0
 
virtual void drawArrow (const Vector3 &p1, const Vector3 &p2, float radius, const Vec4f &colour, int subd=16)=0
 
virtual void drawArrow (const Vector3 &p1, const Vector3 &p2, float radius, float coneLength, const Vec4f &colour, int subd=16)=0
 
virtual void drawArrow (const Vector3 &p1, const Vector3 &p2, float radius, float coneLength, float coneRadius, const Vec4f &color, int subd=16)=0
 
virtual void drawCross (const Vector3 &p, float length, const Vec4f &colour)=0
 Draw a cross (3 lines) centered on p. More...
 
virtual void drawPlus (const float &radius, const Vec4f &colour, const int &subd=16)=0
 Draw a plus sign of size one centered on the current point. More...
 
virtual void drawPoint (const Vector3 &p, const Vec4f &c)=0
 
virtual void drawPoint (const Vector3 &p, const Vector3 &n, const Vec4f &c)=0
 
virtual void drawTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &normal)=0
 
virtual void drawTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &normal, const Vec4f &c)=0
 
virtual void drawTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &normal, const Vec4f &c1, const Vec4f &c2, const Vec4f &c3)=0
 
virtual void drawTriangle (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &normal1, const Vector3 &normal2, const Vector3 &normal3, const Vec4f &c1, const Vec4f &c2, const Vec4f &c3)=0
 
virtual void drawQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4, const Vector3 &normal)=0
 
virtual void drawQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4, const Vector3 &normal, const Vec4f &c)=0
 
virtual void drawQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4, const Vector3 &normal, const Vec4f &c1, const Vec4f &c2, const Vec4f &c3, const Vec4f &c4)=0
 
virtual void drawQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4, const Vector3 &normal1, const Vector3 &normal2, const Vector3 &normal3, const Vector3 &normal4, const Vec4f &c1, const Vec4f &c2, const Vec4f &c3, const Vec4f &c4)=0
 
virtual void drawQuads (const std::vector< Vector3 > &points, const Vec4f &colour)=0
 
virtual void drawQuads (const std::vector< Vector3 > &points, const std::vector< Vec4f > &colours)=0
 
virtual void drawTetrahedron (const Vector3 &p0, const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vec4f &colour)=0
 
virtual void drawTetrahedra (const std::vector< Vector3 > &points, const Vec4f &colour)=0
 
virtual void drawScaledTetrahedra (const std::vector< Vector3 > &points, const Vec4f &colour, const float scale)=0
 
virtual void drawHexahedron (const Vector3 &p0, const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4, const Vector3 &p5, const Vector3 &p6, const Vector3 &p7, const Vec4f &colour)=0
 
virtual void drawHexahedra (const std::vector< Vector3 > &points, const Vec4f &colour)=0
 
virtual void drawScaledHexahedra (const std::vector< Vector3 > &points, const Vec4f &colour, const float scale)=0
 
virtual void drawSphere (const Vector3 &p, float radius)=0
 
virtual void drawSphere (const Vector3 &p, float radius, const Vec4f &colour)=0
 
virtual void drawEllipsoid (const Vector3 &p, const Vector3 &radii)=0
 
virtual void drawBoundingBox (const Vector3 &min, const Vector3 &max, float size=1.0)=0
 
virtual void draw3DText (const Vector3 &p, float scale, const Vec4f &color, const char *text)=0
 
virtual void draw3DText_Indices (const std::vector< Vector3 > &positions, float scale, const Vec4f &color)=0
 
Transformation methods.
virtual void pushMatrix ()=0
 
virtual void popMatrix ()=0
 
virtual void multMatrix (float *)=0
 
virtual void scale (float)=0
 
virtual void translate (float x, float y, float z)=0
 
Drawing style methods.
virtual void setMaterial (const Vec4f &colour)=0
 
virtual void resetMaterial (const Vec4f &colour)=0
 
virtual void resetMaterial ()=0
 
virtual void setPolygonMode (int _mode, bool _wireframe)=0
 
virtual void setLightingEnabled (bool _isAnabled)=0
 
States (save/restore)
virtual void saveLastState ()=0
 
virtual void restoreLastState ()=0
 
Overlay methods
virtual void writeOverlayText (int x, int y, unsigned fontSize, const Vec4f &color, const char *text)=0
 draw 2D text at position (x,y) from top-left corner More...
 
virtual void enablePolygonOffset (float factor, float units)=0
 Allow a variable depth offset for polygon drawing. More...
 
virtual void disablePolygonOffset ()=0
 Remove variable depth offset for polygon drawing. More...
 
virtual void readPixels (int x, int y, int w, int h, float *rgb, float *z=nullptr)=0
 

Constructor details

sofa::core::visual::DrawTool::DrawTool ( )
inline
virtual sofa::core::visual::DrawTool::~DrawTool ( )
inlinevirtual

Function details

virtual void sofa::core::visual::DrawTool::clear ( )
inlinevirtual

Reimplemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::disableBlending ( )
pure virtual
virtual void sofa::core::visual::DrawTool::disableDepthTest ( )
pure virtual
virtual void sofa::core::visual::DrawTool::disableLighting ( )
pure virtual
virtual void sofa::core::visual::DrawTool::disablePolygonOffset ( )
pure virtual

Remove variable depth offset for polygon drawing.

Implemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::draw3DText ( const Vector3 p,
float  scale,
const Vec4f color,
const char *  text 
)
pure virtual
virtual void sofa::core::visual::DrawTool::draw3DText_Indices ( const std::vector< Vector3 > &  positions,
float  scale,
const Vec4f color 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawArrow ( const Vector3 p1,
const Vector3 p2,
float  radius,
const Vec4f colour,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawArrow ( const Vector3 p1,
const Vector3 p2,
float  radius,
float  coneLength,
const Vec4f colour,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawArrow ( const Vector3 p1,
const Vector3 p2,
float  radius,
float  coneLength,
float  coneRadius,
const Vec4f color,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawBoundingBox ( const Vector3 min,
const Vector3 max,
float  size = 1.0 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawCapsule ( const Vector3 p1,
const Vector3 p2,
float  radius,
const Vec4f colour,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawCircle ( float  radius,
float  lineThickness,
int  resolution,
const Vec4f color 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawCone ( const Vector3 p1,
const Vector3 p2,
float  radius1,
float  radius2,
const Vec4f colour,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawCross ( const Vector3 p,
float  length,
const Vec4f colour 
)
pure virtual

Draw a cross (3 lines) centered on p.

Implemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::drawCube ( const float radius,
const Vec4f colour,
const int subd = 16 
)
pure virtual

Draw a cube of size one centered on the current point.

Implemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::drawCylinder ( const Vector3 p1,
const Vector3 p2,
float  radius,
const Vec4f colour,
int  subd = 16 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawDisk ( float  radius,
double  from,
double  to,
int  resolution,
const Vec4f color 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawEllipsoid ( const Vector3 p,
const Vector3 radii 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawFakeSpheres ( const std::vector< Vector3 > &  points,
const std::vector< float > &  radius,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawFakeSpheres ( const std::vector< Vector3 > &  points,
float  radius,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawFrame ( const Vector3 position,
const Quaternion orientation,
const Vec3f size 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawFrame ( const Vector3 position,
const Quaternion orientation,
const Vec3f size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawHexahedra ( const std::vector< Vector3 > &  points,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawHexahedron ( const Vector3 p0,
const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4,
const Vector3 p5,
const Vector3 p6,
const Vector3 p7,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawInfiniteLine ( const Vector3 point,
const Vector3 direction,
const Vec4f color 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLine ( const Vector3 p1,
const Vector3 p2,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLineLoop ( const std::vector< Vector3 > &  points,
float  size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLines ( const std::vector< Vector3 > &  points,
float  size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLines ( const std::vector< Vector3 > &  points,
float  size,
const std::vector< Vec4f > &  colours 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLines ( const std::vector< Vector3 > &  points,
const std::vector< Vec2i > &  index,
float  size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawLineStrip ( const std::vector< Vector3 > &  points,
float  size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawPlus ( const float radius,
const Vec4f colour,
const int subd = 16 
)
pure virtual

Draw a plus sign of size one centered on the current point.

Implemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::drawPoint ( const Vector3 p,
const Vec4f c 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawPoint ( const Vector3 p,
const Vector3 n,
const Vec4f c 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawPoints ( const std::vector< Vector3 > &  points,
float  size,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawPoints ( const std::vector< Vector3 > &  points,
float  size,
const std::vector< Vec4f > &  colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuad ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4,
const Vector3 normal 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuad ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4,
const Vector3 normal,
const Vec4f c 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuad ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4,
const Vector3 normal,
const Vec4f c1,
const Vec4f c2,
const Vec4f c3,
const Vec4f c4 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuad ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4,
const Vector3 normal1,
const Vector3 normal2,
const Vector3 normal3,
const Vector3 normal4,
const Vec4f c1,
const Vec4f c2,
const Vec4f c3,
const Vec4f c4 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuads ( const std::vector< Vector3 > &  points,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawQuads ( const std::vector< Vector3 > &  points,
const std::vector< Vec4f > &  colours 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawScaledHexahedra ( const std::vector< Vector3 > &  points,
const Vec4f colour,
const float  scale 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawScaledTetrahedra ( const std::vector< Vector3 > &  points,
const Vec4f colour,
const float  scale 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawSphere ( const Vector3 p,
float  radius 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawSphere ( const Vector3 p,
float  radius,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawSpheres ( const std::vector< Vector3 > &  points,
const std::vector< float > &  radius,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawSpheres ( const std::vector< Vector3 > &  points,
float  radius,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTetrahedra ( const std::vector< Vector3 > &  points,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTetrahedron ( const Vector3 p0,
const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 normal 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 normal,
const Vec4f c 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 normal,
const Vec4f c1,
const Vec4f c2,
const Vec4f c3 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangle ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 normal1,
const Vector3 normal2,
const Vector3 normal3,
const Vec4f c1,
const Vec4f c2,
const Vec4f c3 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangleFan ( const std::vector< Vector3 > &  points,
const std::vector< Vector3 > &  normal,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const Vector3 normal,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const std::vector< Vec3i > &  index,
const std::vector< Vector3 > &  normal,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const std::vector< Vec3i > &  index,
const std::vector< Vector3 > &  normal,
const std::vector< Vec4f > &  colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const std::vector< Vec4f > &  colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangles ( const std::vector< Vector3 > &  points,
const std::vector< Vector3 > &  normal,
const std::vector< Vec4f > &  colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::drawTriangleStrip ( const std::vector< Vector3 > &  points,
const std::vector< Vector3 > &  normal,
const Vec4f colour 
)
pure virtual
virtual void sofa::core::visual::DrawTool::enableBlending ( )
pure virtual
virtual void sofa::core::visual::DrawTool::enableDepthTest ( )
pure virtual
virtual void sofa::core::visual::DrawTool::enableLighting ( )
pure virtual
virtual void sofa::core::visual::DrawTool::enablePolygonOffset ( float  factor,
float  units 
)
pure virtual

Allow a variable depth offset for polygon drawing.

Implemented in sofa::core::visual::DrawToolGL.

virtual void sofa::core::visual::DrawTool::init ( )
pure virtual
virtual void sofa::core::visual::DrawTool::multMatrix ( float )
pure virtual
virtual void sofa::core::visual::DrawTool::popMatrix ( )
pure virtual
virtual void sofa::core::visual::DrawTool::pushMatrix ( )
pure virtual
virtual void sofa::core::visual::DrawTool::readPixels ( int  x,
int  y,
int  w,
int  h,
float rgb,
float z = nullptr 
)
pure virtual
virtual void sofa::core::visual::DrawTool::resetMaterial ( const Vec4f colour)
pure virtual
virtual void sofa::core::visual::DrawTool::resetMaterial ( )
pure virtual
virtual void sofa::core::visual::DrawTool::restoreLastState ( )
pure virtual
virtual void sofa::core::visual::DrawTool::saveLastState ( )
pure virtual
virtual void sofa::core::visual::DrawTool::scale ( float  )
pure virtual
virtual void sofa::core::visual::DrawTool::setLightingEnabled ( bool  _isAnabled)
pure virtual
virtual void sofa::core::visual::DrawTool::setMaterial ( const Vec4f colour)
pure virtual
virtual void sofa::core::visual::DrawTool::setPolygonMode ( int  _mode,
bool  _wireframe 
)
pure virtual
virtual void sofa::core::visual::DrawTool::translate ( float  x,
float  y,
float  z 
)
pure virtual
virtual void sofa::core::visual::DrawTool::writeOverlayText ( int  x,
int  y,
unsigned  fontSize,
const Vec4f color,
const char *  text 
)
pure virtual

draw 2D text at position (x,y) from top-left corner

Implemented in sofa::core::visual::DrawToolGL.