Avogadro  1.1.0
Public Member Functions
Avogadro::Painter Class Reference

Pure virtual Painter base class to be implemented by painters. More...

#include <avogadro/painter.h>

Inheritance diagram for Avogadro::Painter:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Painter ()
virtual ~Painter ()
virtual bool initialize ()
virtual bool finalize ()
virtual int quality () const =0
virtual void setName (const Primitive *primitive)=0
virtual void setName (Primitive::Type type, int id)=0
virtual void setColor (const Color *color)=0
virtual void setColor (const QColor *color)=0
virtual void setColor (float red, float green, float blue, float alpha=1.0)=0
virtual void setColor (QString name)=0
virtual void drawSphere (const Eigen::Vector3d &center, double radius)=0
virtual void drawSphere (const Eigen::Vector3d *center, double radius)
virtual void drawCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius)=0
virtual void drawMultiCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius, int order, double shift)=0
virtual void drawCone (const Eigen::Vector3d &base, const Eigen::Vector3d &cap, double baseRadius, double capRadius=0.0)=0
virtual void drawLine (const Eigen::Vector3d &start, const Eigen::Vector3d &end, double lineWidth)=0
virtual void drawMultiLine (const Eigen::Vector3d &start, const Eigen::Vector3d &end, double lineWidth, int order, short stipple)=0
virtual void drawTriangle (const Eigen::Vector3d &p1, const Eigen::Vector3d &p2, const Eigen::Vector3d &p3)=0
virtual void drawTriangle (const Eigen::Vector3d &p1, const Eigen::Vector3d &p2, const Eigen::Vector3d &p3, const Eigen::Vector3d &n)=0
virtual void drawSpline (const QVector< Eigen::Vector3d > &pts, double radius)=0
virtual void drawShadedSector (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction1, const Eigen::Vector3d &direction2, double radius, bool alternateAngle=false)=0
virtual void drawArc (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction1, const Eigen::Vector3d &direction2, double radius, double lineWidth, bool alternateAngle=false)=0
virtual void drawShadedQuadrilateral (const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const Eigen::Vector3d &point3, const Eigen::Vector3d &point4)=0
virtual void drawQuadrilateral (const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const Eigen::Vector3d &point3, const Eigen::Vector3d &point4, double lineWidth)
virtual void drawLineLoop (const QList< Eigen::Vector3d > &points, const double lineWidth)
virtual void drawMesh (const Mesh &mesh, int mode=0)=0
virtual void drawColorMesh (const Mesh &mesh, int mode=0)=0
virtual int drawText (int x, int y, const QString &string)=0
virtual int drawText (const QPoint &pos, const QString &string)=0
virtual int drawText (const Eigen::Vector3d &pos, const QString &string)=0
virtual int drawText (const Eigen::Vector3d &, const QString &, const QFont &)
virtual void drawBox (const Eigen::Vector3d &corner1, const Eigen::Vector3d &corner2)=0
virtual void drawBoxEdges (const Eigen::Vector3d &offset, const Eigen::Vector3d &v1, const Eigen::Vector3d &v2, const Eigen::Vector3d &v3, const double linewidth)
virtual void drawBoxEdges (const Eigen::Vector3d &c1, const Eigen::Vector3d &c2, const Eigen::Vector3d &c3, const Eigen::Vector3d &c4, const Eigen::Vector3d &c5, const Eigen::Vector3d &c6, const Eigen::Vector3d &c7, const Eigen::Vector3d &c8, const double linewidth)
virtual void drawTorus (const Eigen::Vector3d &pos, double majorRadius, double minorRadius)=0
virtual void drawEllipsoid (const Eigen::Vector3d &position, const Eigen::Matrix3d &matrix)=0

Detailed Description

Pure virtual Painter base class to be implemented by painters.

Author:
Marcus D. Hanwell

This class is a pure virtual base class of the Painter. It should be implemented by painters in order to satisfy all primitives objects to be drawn by the engines.

See also:
GLPainter, POVPainter

Constructor & Destructor Documentation

Constructor.

Destructor.


Member Function Documentation

virtual void Avogadro::Painter::drawArc ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  direction1,
const Eigen::Vector3d &  direction2,
double  radius,
double  lineWidth,
bool  alternateAngle = false 
) [pure virtual]

Draws an arc. The arc is defined by three vectors, the center of the circle, and two vectors that define the lines going out from the center of the circle to the circumference of the circle. The actual points on the circumference are found using these two vectors and the radius of the circle.

Parameters:
originthe center of the circle whose circumference this arc is a portion of.
direction1a vector defining the line the start of the arc will lie on.
direction2a vector defining the line the end of the arc will lie on.
radiusthe radius of the circle whose circumference this arc is a portion of.
lineWidththe thickness of the line the arc will be drawn with.
alternateAnglewhether to draw the obtuse angle made by the two vectors instead of the acute angle between them.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawBox ( const Eigen::Vector3d &  corner1,
const Eigen::Vector3d &  corner2 
) [pure virtual]

Placeholder to draw a cube.

Parameters:
corner1First corner of the cube.
corner2Second corner of the cube.
Todo:
Implement this primitive.

Implemented in Avogadro::GLPainter.

void Avogadro::Painter::drawBoxEdges ( const Eigen::Vector3d &  offset,
const Eigen::Vector3d &  v1,
const Eigen::Vector3d &  v2,
const Eigen::Vector3d &  v3,
const double  linewidth 
) [virtual]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Draws the outline of a parallelpiped at offset with three vectors v1, v2, and v3 defining the edges.

       6------8  c1 = origin
      /:     /|  c2 = origin + v1
     / :    / |  c3 = origin + v2
    /  4---/--7  c4 = origin + v3
   /  /   /  /   c5 = origin + v1 + v2
  3------5  /    c6 = origin + v2 + v3
  | /    | /     c7 = origin + v1 + v3
  |/     |/      c8 = origin + v1 + v2 + v3
  1------2
Parameters:
offsetCorner of the box.
v1Edge of box, pointing relative to offset.
v2Edge of box, pointing relative to offset.
v3Edge of box, pointing relative to offset.
linewidthThe width of the line.

Reimplemented in Avogadro::GLPainter.

void Avogadro::Painter::drawBoxEdges ( const Eigen::Vector3d &  c1,
const Eigen::Vector3d &  c2,
const Eigen::Vector3d &  c3,
const Eigen::Vector3d &  c4,
const Eigen::Vector3d &  c5,
const Eigen::Vector3d &  c6,
const Eigen::Vector3d &  c7,
const Eigen::Vector3d &  c8,
const double  linewidth 
) [virtual]

Draws the outline of a box with the given corners.

       6------8
      /:     /|
     / :    / |
    /  4---/--7
   /  /   /  /
  3------5  /
  | /    | /
  |/     |/
  1------2
Warning:
The default implementaion of this function simply calls drawLine repeatedly to draw the specified shape. This may be very inefficent on certain paint devices and should be reimplemented in such cases.
Parameters:
c1Corner
c2Corner
c3Corner
c4Corner
c5Corner
c6Corner
c7Corner
c8Corner
linewidthThe width of the line.

Reimplemented in Avogadro::GLPainter.

References drawLine().

virtual void Avogadro::Painter::drawColorMesh ( const Mesh mesh,
int  mode = 0 
) [pure virtual]

Draws a continuous mesh of triangles and respects the colors stored.

Parameters:
meshthe mesh to be drawn.
modethe mode to use. 0 = filled, 1 = lines and 2 = points.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawCone ( const Eigen::Vector3d &  base,
const Eigen::Vector3d &  cap,
double  baseRadius,
double  capRadius = 0.0 
) [pure virtual]

Draws a cone between the tip and the base with the base radius given.

Parameters:
basethe position of the base of the cone.
capthe position of the tip of the cone.
baseRadiusthe radius of the base of the cone.
capRadiusthe radius of the base of the cone.

Implemented in Avogadro::GLPainter.

Referenced by Avogadro::GLWidget::renderAxesOverlay().

virtual void Avogadro::Painter::drawCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius 
) [pure virtual]

Draws a cylinder, leaving the Painter choose the appropriate detail level based on the apparent radius (ratio of radius over distance) and the global quality setting.

Parameters:
end1the position of the first end of the cylinder.
end2the position of the second end of the cylinder.
radiusthe radius of the cylinder.

Implemented in Avogadro::GLPainter.

Referenced by Avogadro::GLWidget::renderAxesOverlay().

virtual void Avogadro::Painter::drawEllipsoid ( const Eigen::Vector3d &  position,
const Eigen::Matrix3d &  matrix 
) [pure virtual]

Placeholder to draw an ellipsoid.

Parameters:
posPosition of the center of the ellipsoid.
matrixLinear transformation matrix for scaling and rotation.
Todo:
Implement this primitive.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawLine ( const Eigen::Vector3d &  start,
const Eigen::Vector3d &  end,
double  lineWidth 
) [pure virtual]

Draws a line between the given points of the given width.

Parameters:
startthe position of the start of the line.
endthe position of the end of the line.
lineWidththe width of the line.

Implemented in Avogadro::GLPainter.

Referenced by drawBoxEdges(), drawLineLoop(), and drawQuadrilateral().

void Avogadro::Painter::drawLineLoop ( const QList< Eigen::Vector3d > &  points,
const double  lineWidth 
) [virtual]

Draws a closed line loop connecting each of the points in points,

Warning:
The default implementaion of this function simply calls drawLine repeatedly to draw the specified shape. This may be very inefficent on certain paint devices and should be reimplemented in such cases.
Parameters:
pointsA list of consecutive points defining the line loop
lineWidththe thickness of the line the pentagon will be drawn with.

Reimplemented in Avogadro::GLPainter.

References QList::constBegin(), QList::constEnd(), drawLine(), QList::first(), QList::last(), and QList::size().

virtual void Avogadro::Painter::drawMesh ( const Mesh mesh,
int  mode = 0 
) [pure virtual]

Draws a continuous mesh of triangles.

Parameters:
meshthe mesh to be drawn.
modethe mode to use. 0 = filled, 1 = lines and 2 = points.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawMultiCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius,
int  order,
double  shift 
) [pure virtual]

Draws a multiple cylinder (see below), leaving the Painter choose the appropriate detail level based on the apparent radius (ratio of radius over distance) and the global quality setting.

What is a "multiple cylinder"? Think bond of order two or more between two atoms. This function is here to allow drawing multiple bonds in a single call.

This function takes care of rendering multiple bonds in such a way that the individual bonds avoid hiding each other, at least in the defaut viewpoint of a molecule. To achieves that, it asks the GLWidget for the the normal vector of the molecule's best-fitting plane.

Parameters:
end1the position of the first end of the bond.
end2the position of the second end of the bond.
radiusthe radius, i.e. half-width of each cylinder.
orderthe multiplicity order of the bond, e.g. 2 for a double bond. When this parameter equals 1, this function is equivalent to drawCylinder().
shifthow far away from the central axis the cylinders are shifted. In other words this influences the total width of multiple bonds.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawMultiLine ( const Eigen::Vector3d &  start,
const Eigen::Vector3d &  end,
double  lineWidth,
int  order,
short  stipple 
) [pure virtual]

Draws a multiple line between the given points. This function is the line equivalent to the drawMultiCylinder function and performs the same basic operations using simpler and quicker lines.

Parameters:
startthe position of the start of the line.
endthe position of the end of the line.
lineWidththe width of the line.
orderthe order of the bond, e.g. 2 for a double bond.
stippleThe stipple parameter for the bond, can be used to draw aromatic bonds etc. sa drawMultiCylinder

Implemented in Avogadro::GLPainter.

void Avogadro::Painter::drawQuadrilateral ( const Eigen::Vector3d &  point1,
const Eigen::Vector3d &  point2,
const Eigen::Vector3d &  point3,
const Eigen::Vector3d &  point4,
double  lineWidth 
) [virtual]

Draws the outline of a two dimensional quadrilateral in three dimensional space.

Warning:
The default implementaion of this function simply calls drawLine repeatedly to draw the specified shape. This may be very inefficent on certain paint devices and should be reimplemented in such cases.
Parameters:
point1the first of the four corners of the quadrilateral.
point2the second of the four corners of the quadrilateral.
point3the third of the four corners of the quadrilateral.
point4the last of the four corners of the quadrilateral.
lineWidththe thickness of the line the quadrilateral will be drawn with.

Reimplemented in Avogadro::GLPainter.

References drawLine().

virtual void Avogadro::Painter::drawShadedQuadrilateral ( const Eigen::Vector3d &  point1,
const Eigen::Vector3d &  point2,
const Eigen::Vector3d &  point3,
const Eigen::Vector3d &  point4 
) [pure virtual]

Draws a solid two dimensional quadrilateral in three dimensional space.

Parameters:
point1the first of the four corners of the quadrilateral.
point2the second of the four corners of the quadrilateral.
point3the third of the four corners of the quadrilateral.
point4the last of the four corners of the quadrilateral.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawShadedSector ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  direction1,
const Eigen::Vector3d &  direction2,
double  radius,
bool  alternateAngle = false 
) [pure virtual]

Draws a shaded sector of a circle. The sector is defined by three vectors, the center of the circle, and two vectors that define the lines going out from the centre of the circle to the circumference of the circle. The actual points on the circumference are found using these two vectors and the radius of the circle.

Parameters:
originthe center of the circle this sector is a portion of.
direction1a vector defining the line the first point will lie on.
direction2a vector defining the line the second point will lie on.
radiusthe radius of the circle this sector is a portion of.
alternateAnglewhether to draw the obtuse angle made by the two vectors instead of the acute angle between them.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawSphere ( const Eigen::Vector3d &  center,
double  radius 
) [pure virtual]

Draws a sphere, leaving the Painter choose the appropriate detail level based on the apparent radius (ratio of radius over distance) and the global quality setting.

Parameters:
centerthe position of the center of the sphere.
radiusthe radius of the sphere.

Implemented in Avogadro::GLPainter.

Referenced by drawSphere(), and Avogadro::GLWidget::renderAxesOverlay().

void Avogadro::Painter::drawSphere ( const Eigen::Vector3d *  center,
double  radius 
) [virtual]

Draws a sphere, leaving the Painter choose the appropriate detail level based on the apparent radius (ratio of radius over distance) and the global quality setting.

Parameters:
centerthe position of the center of the sphere.
radiusthe radius of the sphere.
Note:
Convenience function - might be removed.

References drawSphere().

virtual void Avogadro::Painter::drawSpline ( const QVector< Eigen::Vector3d > &  pts,
double  radius 
) [pure virtual]

Draw a cubic B-spline between the given points.

Parameters:
ptsQVector containing the points to draw the cubic B-spline along.
radiusthe radius of the cubic B-spline.

Implemented in Avogadro::GLPainter.

virtual int Avogadro::Painter::drawText ( int  x,
int  y,
const QString string 
) [pure virtual]

Draws text at a given window position, on top of the scene.

Note:
Calls to drawText methods must be enclosed between begin() and end().
Text is rendered as a transparent object, and should therefore be rendered after the opaque objects.
Parameters:
x,ythe window coordinates of the top-left corner of the text to render, (0, 0) is the top-left corner of the window.
stringthe string to render. All character encodings are allowed but superposed characters are not supported yet. For accented letters, use a character giving the whole accented letter, not a separate character for the accent.
See also:
begin(), drawText(const Eigen::Vector3d &, const QString &) const, drawText(const QPoint &, const QString &) const

Implemented in Avogadro::GLPainter.

virtual int Avogadro::Painter::drawText ( const QPoint pos,
const QString string 
) [pure virtual]

Draws text at a given window position, on top of the scene.

Note:
Calls to drawText methods must be enclosed between begin() and endText().
Text is rendered as a transparent object, and should therefore be rendered after the opaque objects.
Parameters:
posthe window coordinates of the top-left corner of the text to render, (0, 0) is the top-left corner of the window.
stringthe string to render. All character encodings are allowed but superposed characters are not supported yet. For accented letters, use a character giving the whole accented letter, not a separate character for the accent.
See also:
begin(), drawText(const Eigen::Vector3d &, const QString &) const, drawText(int, int, const QString &) const

Implemented in Avogadro::GLPainter.

virtual int Avogadro::Painter::drawText ( const Eigen::Vector3d &  pos,
const QString string 
) [pure virtual]

Draws text at a given scene position, inside the scene.

Note:
Calls to drawText methods must be enclosed between begin() and endText().
Text is rendered as a transparent object, and should therefore be rendered after the opaque objects.
Parameters:
posthe scene coordinates of the top-left corner of the text to render.
stringThe string to render. All character encodings are allowed but superposed characters are not supported yet. For accented letters, use a character giving the whole accented letter, not a separate character for the accent.
See also:
begin(), drawText(const QPoint&, const QString &) const, drawText(int, int, const QString &) const

Implemented in Avogadro::GLPainter.

virtual int Avogadro::Painter::drawText ( const Eigen::Vector3d &  ,
const QString ,
const QFont  
) [inline, virtual]

Draws text at a given scene position, inside the scene, using given font

Parameters:
posthe scene coordinates of the top-left corner of the text to render.
stringThe string to render. All character encodings are allowed but superposed characters are not supported yet. For accented letters, use a character giving the whole accented letter, not a separate character for the accent.
fontThe font to use for rendering
Todo:
make it pure virtual in 2.0
See also:
begin(), drawText(const QPoint&, const QString &) const, drawText(int, int, const QString &) const

Reimplemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawTorus ( const Eigen::Vector3d &  pos,
double  majorRadius,
double  minorRadius 
) [pure virtual]

Placeholder to draw a torus.

Parameters:
posPosition of the center of the torus.
majorRadiusMajor radius of the torus.
minorRadiusMinor radius of the torus.
Todo:
Implement this primitive.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawTriangle ( const Eigen::Vector3d &  p1,
const Eigen::Vector3d &  p2,
const Eigen::Vector3d &  p3 
) [pure virtual]

Draws a triangle with vertives on the three given points. This function calculates the normal of the triangle and corrects the winding order to ensure the front face is facing the camera.

Parameters:
p1first triangle vertex.
p2second triangle vertex.
p3third triangle vertex.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::drawTriangle ( const Eigen::Vector3d &  p1,
const Eigen::Vector3d &  p2,
const Eigen::Vector3d &  p3,
const Eigen::Vector3d &  n 
) [pure virtual]

Draws a triangle with vertives on the three given points using the given normal. This function corrects the triangle's winding order.

Parameters:
p1first triangle vertex.
p2second triangle vertex.
p3third triangle vertex.
nthe normal of the triangle.

Implemented in Avogadro::GLPainter.

bool Avogadro::Painter::finalize ( ) [virtual]

Function to clean up before the drawing context is destroyed.

Returns:
True on success, false on failure to finalize.
bool Avogadro::Painter::initialize ( ) [virtual]

Function that may be used to initialize the drawing context when the painter is first used.

Returns:
True on success, false on failure to initialize.
virtual int Avogadro::Painter::quality ( ) const [pure virtual]
Returns:
The current global quality setting.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::setColor ( const Color color) [pure virtual]

Set the color to paint the primitive elements with.

Parameters:
colorthe color to be used for painting.

Implemented in Avogadro::GLPainter.

Referenced by Avogadro::GLWidget::renderAxesOverlay().

virtual void Avogadro::Painter::setColor ( const QColor color) [pure virtual]

Set the color to paint the primitive elements with.

Parameters:
colorthe color to be used for painting.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::setColor ( float  red,
float  green,
float  blue,
float  alpha = 1.0 
) [pure virtual]

Set the color to paint elements with where 0.0 is the minimum and 1.0 is the maximum.

Parameters:
redcomponent of the color.
greencomponent of the color.
bluecomponent of the color.
alphacomponent of the color.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::setColor ( QString  name) [pure virtual]

Set the color to paint elements by its name

Parameters:
namename of the color to be used

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::setName ( const Primitive primitive) [pure virtual]

Uses the primitive to set the type and name if the Paint Device supports it.

Parameters:
primitivethe primitive about to be drawn.

Implemented in Avogadro::GLPainter.

virtual void Avogadro::Painter::setName ( Primitive::Type  type,
int  id 
) [pure virtual]

Sets the primitive type and id.

Parameters:
typethe primitive type about to be drawn.
idthe primitive id.

Implemented in Avogadro::GLPainter.


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