• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kalzium

Avogadro::GLPainter

Avogadro::GLPainter Class Reference

#include <glpainter.h>

Inheritance diagram for Avogadro::GLPainter:

Inheritance graph
[legend]

List of all members.


Detailed Description

Implementation of the Painter class using OpenGL.

Author:
Marcus D. Hanwell
This class implements the base Painter class using OpenGL. It is intended to be used with the GLWidget to render molecules and other constructs to an OpenGL context.

See also:
Painter

Definition at line 49 of file src/glpainter.h.


Public Member Functions

void begin (GLWidget *widget)
void drawArc (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction1, const Eigen::Vector3d &direction2, double radius, double lineWidth, bool alternateAngle=false)
void drawCone (const Eigen::Vector3d &base, const Eigen::Vector3d &tip, double radius)
void drawCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius)
void drawLine (const Eigen::Vector3d &start, const Eigen::Vector3d &end, double lineWidth)
void drawMultiCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius, int order, double shift)
void drawMultiLine (const Eigen::Vector3d &start, const Eigen::Vector3d &end, double lineWidth, int order, short stipple)
void drawQuadrilateral (const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const Eigen::Vector3d &point3, const Eigen::Vector3d &point4, double lineWidth)
void drawShadedQuadrilateral (const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const Eigen::Vector3d &point3, const Eigen::Vector3d &point4)
void drawShadedSector (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction1, const Eigen::Vector3d &direction2, double radius, bool alternateAngle=false)
void drawSphere (const Eigen::Vector3d &center, double radius)
void drawSpline (const QVector< Eigen::Vector3d > &pts, double radius)
int drawText (const Eigen::Vector3d &pos, const QString &string) const
int drawText (const QPoint &pos, const QString &string) const
int drawText (int x, int y, const QString &string) const
void drawTriangle (const Eigen::Vector3d &p1, const Eigen::Vector3d &p2, const Eigen::Vector3d &p3, const Eigen::Vector3d &n)
void drawTriangle (const Eigen::Vector3d &p1, const Eigen::Vector3d &p2, const Eigen::Vector3d &p3)
void end ()
 GLPainter (int quality=-1)
bool isActive ()
bool isShared ()
int quality () const
void setColor (float red, float green, float blue, float alpha=1.0)
void setColor (const Color *color)
void setDynamicScaling (bool scaling)
void setName (Primitive::Type type, int id)
void setName (const Primitive *primitive)
void setQuality (int quality)
 ~GLPainter ()

Static Public Member Functions

static int defaultQuality ()
static int maxQuality ()

Constructor & Destructor Documentation

Avogadro::GLPainter::GLPainter ( int  quality = -1  ) 

Constructor.

Parameters:
quality defaults to -1, valid range from 0 to 4.

Definition at line 271 of file glpainter.cpp.

Avogadro::GLPainter::~GLPainter (  ) 

Destructor.

Definition at line 280 of file glpainter.cpp.


Member Function Documentation

void Avogadro::GLPainter::begin ( GLWidget *  widget  ) 

Set the Painter up for painting onto a GLWidget, should be called before any painting.

Definition at line 1091 of file glpainter.cpp.

int Avogadro::GLPainter::defaultQuality (  )  [static]

Returns:
the default quality level of the Painter.

Definition at line 1061 of file glpainter.cpp.

void Avogadro::GLPainter::drawArc ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  direction1,
const Eigen::Vector3d &  direction2,
double  radius,
double  lineWidth,
bool  alternateAngle = false 
) [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:
origin the center of the circle whose circumference this arc is a portion of.
direction1 a vector defining the line the start of the arc will lie on.
direction2 a vector defining the line the end of the arc will lie on.
radius the radius of the circle whose circumference this arc is a portion of.
lineWidth the thickness of the line the arc will be drawn with.
alternateAngle whether to draw the obtuse angle made by the two vectors instead of the acute angle between them.

Implements Avogadro::Painter.

Definition at line 878 of file glpainter.cpp.

void Avogadro::GLPainter::drawCone ( const Eigen::Vector3d &  base,
const Eigen::Vector3d &  tip,
double  radius 
) [virtual]

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

Parameters:
base the position of the base of the cone.
tip the position of the tip of the cone.
radius the radius of the base of the cone.

Implements Avogadro::Painter.

Definition at line 402 of file glpainter.cpp.

void Avogadro::GLPainter::drawCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius 
) [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:
end1 the position of the first end of the cylinder.
end2 the position of the second end of the cylinder.
radius the radius, i.e. half-width of the cylinder.

Implements Avogadro::Painter.

Definition at line 349 of file glpainter.cpp.

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

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

Parameters:
start the position of the start of the line.
end the position of the end of the line.
lineWidth the width of the GL line.

Implements Avogadro::Painter.

Definition at line 451 of file glpainter.cpp.

void Avogadro::GLPainter::drawMultiCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius,
int  order,
double  shift 
) [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 normal vector of the molecule's best-fitting plane.

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

Implements Avogadro::Painter.

Definition at line 375 of file glpainter.cpp.

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

Draws a multiple GL line between the given points.

This function is the GL line equivalent to the drawMultiCylinder function and performs the same basic operations using simpler and quicker GL lines.

Parameters:
start the position of the start of the line.
end the position of the end of the line.
lineWidth the width of the GL line.
order the order of the bond, e.g. 2 for a double bond.
stipple The GL stipple parameter for the bond, can be used to draw aromatic bonds etc. sa drawMultiCylinder

Implements Avogadro::Painter.

Definition at line 471 of file glpainter.cpp.

void Avogadro::GLPainter::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.

Parameters:
point1 the first of the four corners of the quadrilateral.
point2 the second of the four corners of the quadrilateral.
point3 the third of the four corners of the quadrilateral.
point4 the last of the four corners of the quadrilateral.
lineWidth the thickness of the line the quadrilateral will be drawn with.

Implements Avogadro::Painter.

Definition at line 1006 of file glpainter.cpp.

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

Draws a solid two dimensional quadrilateral in three dimensional space.

Parameters:
point1 the first of the four corners of the quadrilateral.
point2 the second of the four corners of the quadrilateral.
point3 the third of the four corners of the quadrilateral.
point4 the last of the four corners of the quadrilateral.

Implements Avogadro::Painter.

Definition at line 982 of file glpainter.cpp.

void Avogadro::GLPainter::drawShadedSector ( const Eigen::Vector3d &  origin,
const Eigen::Vector3d &  direction1,
const Eigen::Vector3d &  direction2,
double  radius,
bool  alternateAngle = false 
) [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:
origin the center of the circle this sector is a portion of.
direction1 a vector defining the line the first point will lie on.
direction2 a vector defining the line the second point will lie on.
radius the radius of the circle this sector is a portion of.
alternateAngle whether to draw the obtuse angle made by the two vectors instead of the acute angle between them.

Implements Avogadro::Painter.

Definition at line 775 of file glpainter.cpp.

void Avogadro::GLPainter::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:
center the position of the center of the sphere.
radius the radius of the sphere.

Implements Avogadro::Painter.

Definition at line 325 of file glpainter.cpp.

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

Draw a cubic B-spline between the given points using GL NURBS.

Parameters:
pts QVector containing the points to draw the cubic B-spline along.
radius the radius of the cubic B-spline.

Implements Avogadro::Painter.

Definition at line 651 of file glpainter.cpp.

int Avogadro::GLPainter::drawText ( const Eigen::Vector3d &  pos,
const QString &  string 
) const [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:
pos the scene coordinates of the top-left corner of the text to render.
string The 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

Implements Avogadro::Painter.

Definition at line 1052 of file glpainter.cpp.

int Avogadro::GLPainter::drawText ( const QPoint &  pos,
const QString &  string 
) const [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:
pos the window coordinates of the top-left corner of the text to render, (0, 0) is the top-left corner of the window.
string the 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

Implements Avogadro::Painter.

Definition at line 1042 of file glpainter.cpp.

int Avogadro::GLPainter::drawText ( int  x,
int  y,
const QString &  string 
) const [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,y the window coordinates of the top-left corner of the text to render, (0, 0) is the top-left corner of the window.
string the 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

Implements Avogadro::Painter.

Definition at line 1032 of file glpainter.cpp.

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

Draws a triangle with vertives on the three given points using the given normal.

This function corrects the triangle's winding order.

Parameters:
p1 first triangle vertex.
p2 second triangle vertex.
p3 third triangle vertex.
n the normal of the triangle.

Implements Avogadro::Painter.

Definition at line 612 of file glpainter.cpp.

void Avogadro::GLPainter::drawTriangle ( const Eigen::Vector3d &  p1,
const Eigen::Vector3d &  p2,
const Eigen::Vector3d &  p3 
) [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:
p1 first triangle vertex.
p2 second triangle vertex.
p3 third triangle vertex.

Implements Avogadro::Painter.

Definition at line 572 of file glpainter.cpp.

void Avogadro::GLPainter::end (  ) 

End painting, should be called when all painting is complete.

Definition at line 1099 of file glpainter.cpp.

bool Avogadro::GLPainter::isActive (  ) 

Returns:
true if the Painter is active.

Definition at line 1076 of file glpainter.cpp.

bool Avogadro::GLPainter::isShared (  ) 

Returns:
true if the Painter is being shared between multiple GLWidgets.

Definition at line 1071 of file glpainter.cpp.

int Avogadro::GLPainter::maxQuality (  )  [static]

Returns:
the maximum quality level of the Painter.

Definition at line 1066 of file glpainter.cpp.

int Avogadro::GLPainter::quality (  )  const [virtual]

Returns:
the current global quality setting.

Implements Avogadro::Painter.

Definition at line 291 of file glpainter.cpp.

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

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

Parameters:
red component of the color.
green component of the color.
blue component of the color.
alpha component of the color.

Implements Avogadro::Painter.

Definition at line 320 of file glpainter.cpp.

void Avogadro::GLPainter::setColor ( const Color *  color  )  [virtual]

Set the color to paint the OpenGL primitives with.

Parameters:
color the color to be used for painting.

Implements Avogadro::Painter.

Definition at line 315 of file glpainter.cpp.

void Avogadro::GLPainter::setDynamicScaling ( bool  scaling  ) 

Set to true to turn dynamic object scaling on, false for off.

Definition at line 1135 of file glpainter.cpp.

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

Sets the primitive type and id.

Parameters:
type the primitive type about to be drawn.
id the primitive id.

Implements Avogadro::Painter.

Definition at line 309 of file glpainter.cpp.

void Avogadro::GLPainter::setName ( const Primitive *  primitive  )  [virtual]

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

Parameters:
primitive the primitive about to be drawn.

Implements Avogadro::Painter.

Definition at line 296 of file glpainter.cpp.

void Avogadro::GLPainter::setQuality ( int  quality  ) 

Sets the global quality setting.

This influences the detail level of the geometric objects (spheres and cylinders). Values range from 0 to PAINTER_GLOBAL_QUALITY_SETTINGS-1.

Definition at line 285 of file glpainter.cpp.


The documentation for this class was generated from the following files:
  • src/glpainter.h
  • glpainter.cpp

kalzium

Skip menu "kalzium"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal