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

kalzium

Avogadro::Engine

Avogadro::Engine Class Reference

#include <avogadro/engine.h>

Inheritance diagram for Avogadro::Engine:

Inheritance graph
[legend]

List of all members.


Detailed Description

Engine plugin interface.

Author:
Donald Ephraim Curtis

Marcus D. Hanwell

This class provides an interface for our engines. Subclasses of this class are loaded by the GLWidget and used to render different parts of our project (Molecule, Atom, Bond, Residue) depending on what style of engine we are implementing.
See also:
GLWidget::render()

Definition at line 66 of file src/engine.h.


Public Types

enum  EngineFlag {
  NoFlags = 0x00, Transparent = 0x01, Overlay = 0x02, Bonds = 0x04,
  Atoms = 0x08, Molecules = 0x10
}

Public Slots

virtual void addPrimitive (Primitive *primitive)
virtual Color * colorMap ()
virtual void removePrimitive (Primitive *primitive)
virtual void setColorMap (Color *map)
virtual void updatePrimitive (Primitive *primitive)

Signals

void changed ()

Public Member Functions

virtual void clearPrimitives ()
virtual Engine * clone () const =0
QString description () const
 Engine (QObject *parent=0)
virtual EngineFlags flags () const
bool isEnabled () const
QString name () const
PrimitiveList primitives () const
virtual double radius (const PainterDevice *pd, const Primitive *primitive=0) const
virtual void readSettings (QSettings &settings)
virtual bool renderOpaque (PainterDevice *pd)=0
virtual bool renderQuick (PainterDevice *pd)
virtual bool renderTransparent (PainterDevice *)
void setDescription (const QString &description)
void setEnabled (bool enabled)
void setName (const QString &name)
virtual void setPrimitives (const PrimitiveList &primitives)
virtual QWidget * settingsWidget ()
virtual double transparencyDepth () const
virtual QString type () const =0
virtual void writeSettings (QSettings &settings) const
virtual ~Engine ()

Member Enumeration Documentation

enum Avogadro::Engine::EngineFlag

Different properties an engine can set which affect the rendering order.

Enumerator:
NoFlags 
Transparent  no flags
Overlay  renders transparency
Bonds  renders overlay
Atoms  renders bonds
Molecules  renders atoms

Definition at line 75 of file src/engine.h.


Constructor & Destructor Documentation

Avogadro::Engine::Engine ( QObject *  parent = 0  ) 

Constructor.

Definition at line 42 of file engine.cpp.

Avogadro::Engine::~Engine (  )  [virtual]

Destructor.

Definition at line 46 of file engine.cpp.


Member Function Documentation

void Avogadro::Engine::addPrimitive ( Primitive *  primitive  )  [virtual, slot]

Add the primitive to the engines PrimitiveList.

Parameters:
primitive to be added to the PrimitiveList.

Reimplemented in Avogadro::OrbitalEngine, Avogadro::RibbonEngine, and Avogadro::SurfaceEngine.

Definition at line 83 of file engine.cpp.

void Avogadro::Engine::changed (  )  [signal]

Signals that something has been changed and the engine needs to render after these changes were made.

void Avogadro::Engine::clearPrimitives (  )  [virtual]

Clear the primitives of the engine instance.

Definition at line 67 of file engine.cpp.

virtual Engine* Avogadro::Engine::clone (  )  const [pure virtual]

Returns:
a pointer to an identical engine or 0 if this fails

Color * Avogadro::Engine::colorMap (  )  [virtual, slot]

Returns:
the current color map used by this engine

Definition at line 110 of file engine.cpp.

QString Avogadro::Engine::description (  )  const

Returns:
engine description.

Definition at line 131 of file engine.cpp.

Engine::EngineFlags Avogadro::Engine::flags (  )  const [virtual]

Returns:
the flags for this engine.

Definition at line 136 of file engine.cpp.

bool Avogadro::Engine::isEnabled (  )  const

Returns:
true if the engine is enabled or false if it is not.

Definition at line 72 of file engine.cpp.

QString Avogadro::Engine::name (  )  const

Returns:
the name of the engine.

Definition at line 120 of file engine.cpp.

PrimitiveList Avogadro::Engine::primitives (  )  const

Returns:
the engine's PrimitiveList containing all primitives the engine can render.

Definition at line 51 of file engine.cpp.

double Avogadro::Engine::radius ( const PainterDevice *  pd,
const Primitive *  primitive = 0 
) const [virtual]

Get the radius of the primitive referred to.

Parameters:
primitive is the Primitive to get the radius of.
Returns:
the radius of the Primitive.

Definition at line 62 of file engine.cpp.

void Avogadro::Engine::readSettings ( QSettings &  settings  )  [virtual]

Read in the settings that have been saved for the engine instance.

Definition at line 153 of file engine.cpp.

void Avogadro::Engine::removePrimitive ( Primitive *  primitive  )  [virtual, slot]

Remove the primitive to from the engines PrimitiveList.

Parameters:
primitive to be removed from the PrimitiveList.

Reimplemented in Avogadro::OrbitalEngine, Avogadro::RibbonEngine, and Avogadro::SurfaceEngine.

Definition at line 94 of file engine.cpp.

virtual bool Avogadro::Engine::renderOpaque ( PainterDevice *  pd  )  [pure virtual]

Render opaque elements.

This function is allowed to render whatever opaque primitives it wishes. There is no requirement that it render every primitive.

During generation of the GL view engines will have their render functions called at most once. It is the responsibility of the engine to render all of the objects in it's queue if it can.

Returns:
true if the rendering was completed successfully, false otherwise
Example
 Color *map = colorMap(); // possible custom color map
 if (!map) map = pd->colorMap(); // fall back to global color map

 // Get a list of bonds and render them
 QList<Primitive *> list;
 list = primitives().subList(Primitive::BondType);

 foreach(Primitive *p, list)
   render(static_cast<const Bond *>(p))

 return true;

Note:
To allow picking to happen you need to push the object type and name. If objects cannot be picked this may be omitted.
For more information on the various primitive lists available see PrimitiveList.

virtual bool Avogadro::Engine::renderQuick ( PainterDevice *  pd  )  [inline, virtual]

Render all elements the engine is responsible for quickly with an emphasis on maintaining interactivity even with very large molecules.

By default this function calls renderOpaque but in most cases should be implemented and tuned using large molecule test cases. The GLWidget ensures dynamic scaling of geometric primitives is off before calling this rendering function.

Definition at line 213 of file src/engine.h.

virtual bool Avogadro::Engine::renderTransparent ( PainterDevice *   )  [inline, virtual]

Render transparent elements.

This function is allowed to render whatever transparent primitives it wishes. There is no requirement that it render every primitive.

During generation of the GL view engines will have their render functions called at most once. It is the responsibility of the engine to render all of the objects in it's queue if it can.

Returns:
true if the rendering was completed successfully, false otherwise
Example
 Color *map = colorMap(); // possible custom color map
 if (!map) map = pd->colorMap(); // fall back to global color map

 // Get a list of atoms and render the selected ones as transparent spheres
 QList<Primitive *> list;
 list = primitives().subList(Primitive::AtomType);

 foreach(Primitive *p, list) {
   const Atom *a = static_cast<const Atom *>(p);

   // Render the selection highlight
   if (pd->isSelected(a)) {
     map->set(0.3, 0.6, 1.0, 0.7);
     glEnable(GL_BLEND);
     pd->painter()->setColor(map);
     pd->painter()->setName(a);
     pd->painter()->drawSphere(a->pos(), 0.1 + radius( a ));
     glDisable(GL_BLEND);
   }
 }

Note:
To allow picking to happen you need to push the object type and name. If objects cannot be picked this may be omitted.
For more information on the various primitive lists available see PrimitiveList.

Definition at line 203 of file src/engine.h.

void Avogadro::Engine::setColorMap ( Color *  map  )  [virtual, slot]

Set the color map to be used for this engine.

The default is to color each atom by element.

Parameters:
map is the new colors to be used

Definition at line 100 of file engine.cpp.

void Avogadro::Engine::setDescription ( const QString &  description  ) 

Parameters:
description the new description of this engine.

Definition at line 126 of file engine.cpp.

void Avogadro::Engine::setEnabled ( bool  enabled  ) 

Setter to enable or disable the engine instance.

Parameters:
enabled true to enable the egine, false to disable the engine.

Definition at line 77 of file engine.cpp.

void Avogadro::Engine::setName ( const QString &  name  ) 

Parameters:
name the new name for the engine instance.

Definition at line 115 of file engine.cpp.

void Avogadro::Engine::setPrimitives ( const PrimitiveList &  primitives  )  [virtual]

Set the primitives that the engine instance can render.

Parameters:
primitives the PrimitiveList the engine can render from.

Definition at line 56 of file engine.cpp.

QWidget * Avogadro::Engine::settingsWidget (  )  [virtual]

Returns:
a QWidget containing the engine settings or 0 if no settings widget is available.

Definition at line 105 of file engine.cpp.

double Avogadro::Engine::transparencyDepth (  )  const [virtual]

Returns:
transparency level, rendered low to high.

Definition at line 141 of file engine.cpp.

virtual QString Avogadro::Engine::type (  )  const [pure virtual]

Returns:
a string with the type of the engine.

void Avogadro::Engine::updatePrimitive ( Primitive *  primitive  )  [virtual, slot]

Update the primitive in the engines PrimitiveList.

Parameters:
primitive to be updated in the PrimitiveList.

Reimplemented in Avogadro::OrbitalEngine, Avogadro::RibbonEngine, and Avogadro::SurfaceEngine.

Definition at line 89 of file engine.cpp.

void Avogadro::Engine::writeSettings ( QSettings &  settings  )  const [virtual]

Write the engine settings so that they can be saved between sessions.

Definition at line 146 of file engine.cpp.


The documentation for this class was generated from the following files:
  • src/engine.h
  • engine.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