From 05a6528d608ae6f3015864f71971dcc0f3e6805a Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Wed, 28 Jun 2006 11:32:28 +0000 Subject: [PATCH] * Make it possible to select more than 1 atoms. 1 selected atom is now just a special case of many atoms (QList 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 | 43 ++++++++++++++++--------------------- kalzium/kalziumglwidget.h | 12 +++-------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/kalzium/kalziumglwidget.cpp b/kalzium/kalziumglwidget.cpp index c856c6e..e48baea 100644 --- a/kalzium/kalziumglwidget.cpp +++ b/kalzium/kalziumglwidget.cpp @@ -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 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(); } diff --git a/kalzium/kalziumglwidget.h b/kalzium/kalziumglwidget.h index 97dd670..5b60ec4 100644 --- a/kalzium/kalziumglwidget.h +++ b/kalzium/kalziumglwidget.h @@ -102,9 +102,9 @@ class KalziumGLWidget : public QGLWidget bool m_useFog; /** - * The selected atom + * The selected atoms */ - OpenBabel::OBAtom* m_selectedAtom; + QList 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 atoms ); protected: -- 2.47.3