]> Git trees. - libqmvoc.git/commitdiff
don't render multiple bonds when in sticks-mode
authorBenoît Jacob <jacob.benoit.1@gmail.com>
Fri, 21 Jul 2006 08:22:42 +0000 (08:22 +0000)
committerBenoît Jacob <jacob.benoit.1@gmail.com>
Fri, 21 Jul 2006 08:22:42 +0000 (08:22 +0000)
small simplification in Sphere::computeVertex() : make use of vector3's
arithmetic operators.

M    src/kalziumglhelperclasses.h
M    src/kalziumglwidget.cpp
M    src/kalziumglhelperclasses.cpp

svn path=/trunk/KDE/kdeedu/kalzium/src/kalziumglhelperclasses.cpp; revision=564761

kalzium/kalziumglhelperclasses.cpp
kalzium/kalziumglhelperclasses.h
kalzium/kalziumglwidget.cpp

index 66071829d5c33290fb8289cb0fa9b427b2ec6963..aabf99eae2ae5bdaed1defdac4edaae29bf82603 100644 (file)
@@ -18,6 +18,7 @@ using namespace OpenBabel;
 
 void MolStyle::setup( BondStyle bondStyle, AtomStyle atomStyle,
        double singleBondRadius,
+       bool renderMultipleBonds,
        double multipleBondRadius,
        double multipleBondShift,
        double atomRadiusFactor )
@@ -25,6 +26,7 @@ void MolStyle::setup( BondStyle bondStyle, AtomStyle atomStyle,
        m_bondStyle = bondStyle;
        m_atomStyle = atomStyle;
        m_singleBondRadius = singleBondRadius;
+       m_renderMultipleBonds = renderMultipleBonds;
        m_multipleBondRadius = multipleBondRadius;
        m_multipleBondShift = multipleBondShift;
        m_atomRadiusFactor = atomRadiusFactor;
@@ -87,10 +89,10 @@ void Color::applyAsMaterials()
                s + t * m_blue,
                m_alpha };
 
-       glMaterialfv(GL_FRONT, GL_AMBIENT, ambientColor);
-       glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor);
-       glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor);
-       glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
+       glMaterialfv( GL_FRONT, GL_AMBIENT, ambientColor );
+       glMaterialfv( GL_FRONT, GL_DIFFUSE, diffuseColor );
+       glMaterialfv( GL_FRONT, GL_SPECULAR, specularColor );
+       glMaterialf( GL_FRONT, GL_SHININESS, 50.0 );
 }
 
 VertexArray::VertexArray( GLenum mode,
@@ -280,10 +282,7 @@ void Sphere::computeVertex( int strip, int column, int row)
        double u1 = double(c1) / m_detail;
        double u2 = double(c2) / m_detail;
 
-       vector3 v;
-       v.SetX( v0->x() + u1 * (v1->x() - v0->x()) + u2 * (v2->x() - v0->x()) );
-       v.SetY( v0->y() + u1 * (v1->y() - v0->y()) + u2 * (v2->y() - v0->y()) );
-       v.SetZ( v0->z() + u1 * (v1->z() - v0->z()) + u2 * (v2->z() - v0->z()) );
+       vector3 v = *v0 + u1 * ( *v1 - *v0 ) + u2 * ( *v2 - *v0 );
        v.normalize();
 
        Vector *vertex =
index 4e6bb10f2e53f1e43337520400e6fa5c843c22fb..0b0b821df8aa26ca87db99dd56773d1bae5e4f34 100644 (file)
@@ -72,6 +72,9 @@ struct MolStyle
 
        /** The radius ( = half-thickness ) of single bonds */
        double m_singleBondRadius;
+       /** If true, multiple bonds will be rendered as such. If false,
+        * they will be rendered as single bonds */
+       double m_renderMultipleBonds;
        /** The radius ( = half-thickness ) of each bond inside a
         * multiple bond */
        double m_multipleBondRadius;
@@ -88,6 +91,7 @@ struct MolStyle
         * the members. */
        void setup( BondStyle bondStyle, AtomStyle atomStyle,
                double singleBondRadius,
+               bool renderMultipleBonds,
                double multipleBondRadius,
                double multipleBondShift,
                double atomRadiusFactor );
index 9432336ec883a7baeb8e72d13e2db395b5fd6c46..078f72fbb95826f11c7fe4be515f152a0ceb9f67 100644 (file)
@@ -360,7 +360,8 @@ void KalziumGLWidget::drawBond( OBBond *bond )
        vector3 v3 = ( v1 + v2 ) / 2;
 
        int order;
-       if( bond->IsSingle() ) order = 1;
+       if( m_molStyle.m_renderMultipleBonds == false
+        || bond->IsSingle() ) order = 1;
        else if( bond->IsDouble() ) order = 2;
        else if( bond->IsTriple() ) order = 3;
        else
@@ -439,22 +440,22 @@ void KalziumGLWidget::slotSetMolStyle( int style )
                case 0: // sticks-style
                        m_molStyle.setup( MolStyle::BONDS_USE_ATOMS_COLORS,
                                MolStyle::ATOMS_USE_FIXED_RADIUS,
-                               0.20, 0.06, 0.14, 0.20 );
+                               0.20, false, 0.06, 0.14, 0.20 );
                        break;
                case 1: // atoms: smaller van der Waals, bonds: gray
                        m_molStyle.setup( MolStyle::BONDS_GRAY,
                                MolStyle::ATOMS_USE_VAN_DER_WAALS_RADIUS,
-                               0.08, 0.08, 0.14, 0.20 );
+                               0.08, true, 0.08, 0.14, 0.20 );
                        break;
                case 2: // atoms: smaller van der Waals, bonds: use atom colors
                        m_molStyle.setup( MolStyle::BONDS_USE_ATOMS_COLORS,
                                MolStyle::ATOMS_USE_VAN_DER_WAALS_RADIUS,
-                               0.08, 0.08, 0.14, 0.20 );
+                               0.08, true, 0.08, 0.14, 0.20 );
                        break;
                case 3: // atoms: real van der Waals, bonds: disabled
                        m_molStyle.setup( MolStyle::BONDS_DISABLED,
                                MolStyle::ATOMS_USE_VAN_DER_WAALS_RADIUS,
-                               0.00, 0.00, 0.00, 1.00 );
+                               0.00, false, 0.00, 0.00, 1.00 );
                        break;
 
                default: break;