]> Git trees. - libqmvoc.git/commitdiff
* Make it possible to select more than 1 atoms. 1 selected atom is now
authorCarsten Niehaus <cniehaus@gmx.de>
Wed, 28 Jun 2006 11:32:28 +0000 (11:32 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Wed, 28 Jun 2006 11:32:28 +0000 (11:32 +0000)
  just a special case of many atoms (QList<Atom*> with just one member
* Currently the selection is hardcoded to atom 2 and 6, I am now
  coding the QTreeWidget-code
* Benoit: The sphere is not drawn, only the bond it seems... No clue why
  I don't know the structure of the GL-code :)

CCMAIL:jacob@math.jussieu.fr

svn path=/trunk/KDE/kdeedu/kalzium/src/kalziumglwidget.h; revision=555706

kalzium/kalziumglwidget.cpp
kalzium/kalziumglwidget.h

index c856c6ec6debe6831abaf19cdb96659b837ce4bb..e48baea1ebc83318531094319343d528c3184fbc 100644 (file)
@@ -38,7 +38,6 @@ KalziumGLWidget::KalziumGLWidget( QWidget * parent )
        m_molecule = 0;
        m_detail = 0;
        m_useFog = false;
-       m_selectedAtom = 0;
 
        ChooseStylePreset( PRESET_SPHERES_AND_BICOLOR_BONDS );
        
@@ -225,30 +224,32 @@ void KalziumGLWidget::paintGL()
                }
        }
 
-       // now, paint a semitransparent sphere around the selected atom
-
-       if( m_selectedAtom )
+       // now, paint a semitransparent sphere around the selected atoms
+       if( m_selectedAtoms.count() > 0 )//there are items selected
        {
-               GLFLOAT x = (GLFLOAT) m_selectedAtom->GetX();
-               GLFLOAT y = (GLFLOAT) m_selectedAtom->GetY();
-               GLFLOAT z = (GLFLOAT) m_selectedAtom->GetZ();
-
                Color c( 0.4, 0.4, 1.0, 0.7 );
 
                GLFLOAT radius = m_molMinBondLength * 0.35;
-               GLFLOAT min_radius = (GLFLOAT) atomRadius () * 1.25;
+               const GLFLOAT min_radius = (GLFLOAT) atomRadius () * 1.25;
                if( radius < min_radius ) radius = min_radius;
 
-               glEnable( GL_BLEND );
+               foreach(OpenBabel::OBAtom* atom, m_selectedAtoms)
+               {//iterate through all OBAtoms and highlight one after eachother
+                       GLFLOAT x = (GLFLOAT) atom->GetX();
+                       GLFLOAT y = (GLFLOAT) atom->GetY();
+                       GLFLOAT z = (GLFLOAT) atom->GetZ();
 
-               glEnable( GL_LIGHTING );
+                       glEnable( GL_BLEND );
 
-               drawSphere(
-                       x, y, z,
-                       radius,
-                       c);
+                       glEnable( GL_LIGHTING );
+
+                       drawSphere(
+                                       x, y, z,
+                                       radius,
+                                       c);
 
-               glDisable( GL_BLEND );
+                       glDisable( GL_BLEND );
+               }
        }
 #ifdef USE_FPS_COUNTER
        QTime t;
@@ -425,7 +426,6 @@ void KalziumGLWidget::slotSetMolecule( OpenBabel::OBMol* molecule )
 {
        if ( !molecule ) return;
        m_molecule = molecule;
-       m_selectedAtom = 0;
        prepareMoleculeData();
        setupObjects();
        updateGL();
@@ -569,13 +569,8 @@ Color& KalziumGLWidget::getAtomColor( OpenBabel::OBAtom* atom )
 
 void KalziumGLWidget::slotAtomsSelected( QList<OpenBabel::OBAtom*> atoms )
 {
-
-}
-
-void KalziumGLWidget::slotAtomSelected( OpenBabel::OBAtom* atom )
-{
-       if ( !atom ) return;
-       m_selectedAtom = atom;
+       kDebug() << "KalziumGLWidget::slotAtomsSelected() with " << atoms.count() << " atoms" << endl;
+       m_selectedAtoms = atoms;
        updateGL();
 }
 
index 97dd670838cf343270a5801cf6866646ebe6205a..5b60ec42dd9cafadab50a1bc28458d681930838c 100644 (file)
@@ -102,9 +102,9 @@ class KalziumGLWidget : public QGLWidget
                bool m_useFog;
 
                /**
-                * The selected atom
+                * The selected atoms
                 */
-               OpenBabel::OBAtom* m_selectedAtom;
+               QList<OpenBabel::OBAtom*> m_selectedAtoms;
 
                /**
                 * The style in which the atoms are rendered.
@@ -168,10 +168,6 @@ class KalziumGLWidget : public QGLWidget
                 */
                void slotSetDetail( int detail );
 
-               /**
-                * Chooses the style of rendering among some presets
-                * @param stylePreset the wanted style preset
-                */
                /**
                 * Chooses the style of rendering among some presets
                 * @param stylePreset the wanted style preset
@@ -181,10 +177,8 @@ class KalziumGLWidget : public QGLWidget
                }
 
                /**
-                * The atom @p atom was selected by the user
+                * The atoms @p atoms was selected by the user
                 */
-               void slotAtomSelected( OpenBabel::OBAtom* atom );
-               
                void slotAtomsSelected( QList<OpenBabel::OBAtom*> atoms );
 
        protected: