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

kalzium

Avogadro::Painter

Avogadro::Painter Class Reference

#include <painter.h>

List of all members.


Detailed Description

A simple Painter class for Avogadro.

Currently it can draw spheres, cylinders, multiple cylinders (as in multiple bonds) and text.

Each GLWidget has a Painter which you can get by calling GLWidget::painter().

The motivation for having a centralized Painter class is that it allows for global quality control. Just call setGlobalQualitySetting() to adjust the quality setting.

Another nice thing is that it handles level-of-detail computation, so that you can just call drawSphere(center,radius) and the Painter automatically determines the correct detail level based on the radius of the sphere, on the distance to the camera, and on the global quality setting.

The multiple cylinders are drawn in such a way that the individual cylinders avoid hiding each other, at least in the default viewpoint.

The text is drawn with a black outlining so that it remains readable regardless of the background color.

Definition at line 60 of file src/painter.h.


Public Member Functions

 Painter ()
 ~Painter ()
void setGLWidget (GLWidget *widget)
void setGlobalQualitySetting (int globalQualitySetting)
int globalQualitySetting () const
void initialize (GLWidget *widget, int globalQualitySetting)
void drawSphere (const Eigen::Vector3d &center, double radius, int detailLevel) const
void drawSphere (const Eigen::Vector3d &center, double radius) const
void drawCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius, int detailLevel) const
void drawCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius) const
void drawMultiCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius, int order, double shift, int detailLevel) const
void drawMultiCylinder (const Eigen::Vector3d &end1, const Eigen::Vector3d &end2, double radius, int order, double shift) const
int drawText (int x, int y, const QString &string) const
int drawText (const QPoint &pos, const QString &string) const
int drawText (const Eigen::Vector3d &pos, const QString &string) const
void beginText () const
void endText () const

Constructor & Destructor Documentation

Avogadro::Painter::Painter (  ) 

Definition at line 184 of file painter.cpp.

Avogadro::Painter::~Painter (  ) 

Definition at line 188 of file painter.cpp.


Member Function Documentation

void Avogadro::Painter::setGLWidget ( GLWidget *  widget  ) 

sets the GLWidget in which we are painting.

Please note that in the current implementation, we are expecting that the font() of the GLWidgets are always the same one (typically, the default font set by the user's desktop environment). Multiple-font text rendering is currently unsupported.

Definition at line 193 of file painter.cpp.

void Avogadro::Painter::setGlobalQualitySetting ( int  globalQualitySetting  ) 

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 199 of file painter.cpp.

int Avogadro::Painter::globalQualitySetting (  )  const

Returns:
the current global quality setting.

Definition at line 208 of file painter.cpp.

void Avogadro::Painter::initialize ( GLWidget *  widget,
int  globalQualitySetting 
)

You have to call this once, typically in the GLWidget::initializeGL() function.

It calls setGLWidget() and setGlobalQualitySetting(), and marks this Painter as initialized and ready for painting.

Definition at line 213 of file painter.cpp.

void Avogadro::Painter::drawSphere ( const Eigen::Vector3d &  center,
double  radius,
int  detailLevel 
) const

Draws a sphere with prescribed detail level.

The effective detail level is still influenced by the global quality setting. The detailLevel argument only makes the detail level independent of the apparent radius of the sphere.

Parameters:
center The position of the center of the sphere
radius The radius of the sphere
detailLevel The detail level, ranging between 0 and PAINTER_DETAIL_LEVELS-1.

Definition at line 221 of file painter.cpp.

void Avogadro::Painter::drawSphere ( const Eigen::Vector3d &  center,
double  radius 
) const

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

Definition at line 228 of file painter.cpp.

void Avogadro::Painter::drawCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius,
int  detailLevel 
) const

Draws a cylinder with prescribed detail level.

The effective detail level is still influenced by the global quality setting. The detailLevel argument only makes the detail level independent of the apparent radius of the cylinder.

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
detailLevel The detail level, ranging between 0 and PAINTER_DETAIL_LEVELS-1.

Definition at line 251 of file painter.cpp.

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

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

Definition at line 259 of file painter.cpp.

void Avogadro::Painter::drawMultiCylinder ( const Eigen::Vector3d &  end1,
const Eigen::Vector3d &  end2,
double  radius,
int  order,
double  shift,
int  detailLevel 
) const

Draws a multiple cylinder (see below) with prescribed detail level.

The effective detail level is still influenced by the global quality setting. The detailLevel argument only makes the detail level independent of the apparent radius of the cylinders.

What is a "multiple cylinder" ? Think multiple bond between two atoms. This function is there 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 on a molecule. To achieves that, it asks the GLWidget for the 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.
detailLevel The detail level, ranging between 0 and PAINTER_DETAIL_LEVELS-1.

Definition at line 285 of file painter.cpp.

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

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 multiple bond between two atoms. This function is there 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 on a molecule. To achieves that, it asks the GLWidget for the 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.

Definition at line 294 of file painter.cpp.

int Avogadro::Painter::drawText ( int  x,
int  y,
const QString &  string 
) const

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

Note:
Calls to drawText methods must be enclosed between beginText() and endText().

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:
beginText(), drawText( const Eigen::Vector3d &, const QString &) const, drawText( const QPoint &, const QString & ) const

Definition at line 320 of file painter.cpp.

int Avogadro::Painter::drawText ( const QPoint &  pos,
const QString &  string 
) const

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

Note:
Calls to drawText methods must be enclosed between beginText() 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:
beginText(), drawText( const Eigen::Vector3d &, const QString &) const, drawText( int, int, const QString & ) const

Definition at line 325 of file painter.cpp.

int Avogadro::Painter::drawText ( const Eigen::Vector3d &  pos,
const QString &  string 
) const

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

Note:
Calls to drawText methods must be enclosed between beginText() 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:
beginText(), drawText( const QPoint&, const QString &) const, drawText( int, int, const QString & ) const

Definition at line 330 of file painter.cpp.

void Avogadro::Painter::beginText (  )  const

Enter text-drawing mode.

You must call this before calling any of the drawText functions. You must then call endText() to leave text-drawing mode. Be careful when doing OpenGL state changes while in text drawing mode. Of course, changing the drawing color is safe, as well as modifying the modelview matrix.

See also:
endText()

Definition at line 341 of file painter.cpp.

void Avogadro::Painter::endText (  )  const

Leave text-drawing mode.

See also:
beginText()

Definition at line 346 of file painter.cpp.


The documentation for this class was generated from the following files:
  • src/painter.h
  • painter.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
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
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