#include <QMouseEvent>
#include <QListWidget>
+#ifdef USE_FPS_COUNTER
+#include <QTime>
+#endif
+
#include <openbabel/mol.h>
#include <openbabel/obiter.h>
KalziumGLWidget::KalziumGLWidget( QWidget * parent )
: QGLWidget( parent )
{
+ m_displayList = 0;
m_isDragging = false;
m_molecule = 0;
m_detail = 0;
{
}
+void KalziumGLWidget::deleteDisplayList()
+{
+#ifdef USE_DISPLAY_LIST
+ if( m_displayList) glDeleteLists( m_displayList, 1 );
+ m_displayList = 0;
+#endif
+}
+
void KalziumGLWidget::initializeGL()
{
glClearColor( 0.0, 0.0, 0.0, 1.0 );
}
else glDisable( GL_FOG );
+#ifdef USE_DISPLAY_LIST
+ if ( ! m_displayList )
+ {
+ m_displayList = glGenLists( 1 );
+ glNewList( m_displayList, GL_COMPILE );
+#endif
+
// render the atoms
if( m_atomStyle == ATOM_SPHERE )
{
}
}
+#ifdef USE_DISPLAY_LIST
+ glEndList();
+ }
+
+ glCallList( m_displayList );
+#endif
+
// now, paint a semitransparent sphere around the selected atom
if( m_selectedAtom )
c);
glDisable( GL_BLEND );
+ }
+#ifdef USE_FPS_COUNTER
+ QTime t;
+
+ static bool firstTime = true;
+ static int old_time, new_time;
+ static int frames;
+ static QString s;
+ if( firstTime )
+ {
+ t.start();
+ firstTime = false;
+ old_time = t.elapsed();
+ frames = 0;
+ }
+
+ new_time = t.elapsed();
+
+ frames++;
+
+ if( new_time - old_time > 200 )
+ {
+ s = QString::number( 1000 * frames /
+ double( new_time - old_time ),
+ 'f', 1 );
+ s += " frames per second";
+ frames = 0;
+ old_time = new_time;
}
+
+ renderText ( 20, 20, s );
+
+ update();
+#endif
}
void KalziumGLWidget::resizeGL( int width, int height )
m_sphere.setup( sphere_detail, atomRadius() );
m_cylinder.setup( cylinder_faces, bondRadius() );
+
+ deleteDisplayList();
}
void KalziumGLWidget::drawSphere( GLdouble x, GLdouble y, GLdouble z,
void KalziumGLWidget::prepareMoleculeData()
{
// translate the molecule so that center has coords 0,0,0
- m_molecule->Center();
+ //m_molecule->Center();
+ std::map<std::string, std::string> m;
+ m["c"] = "c";
+ m_molecule->DoTransformations(&m);
+
// calculate the radius of the molecule
// that is, the maximal distance between an atom of the molecule