From: BenoƮt Jacob Date: Fri, 21 Jul 2006 08:22:42 +0000 (+0000) Subject: don't render multiple bonds when in sticks-mode X-Git-Tag: v3.80.3~103^2~25 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=b25ccfaa9683363bf730f01fe26687ba3eea00c2;p=libqmvoc.git don't render multiple bonds when in sticks-mode 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 --- diff --git a/kalzium/kalziumglhelperclasses.cpp b/kalzium/kalziumglhelperclasses.cpp index 6607182..aabf99e 100644 --- a/kalzium/kalziumglhelperclasses.cpp +++ b/kalzium/kalziumglhelperclasses.cpp @@ -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 = diff --git a/kalzium/kalziumglhelperclasses.h b/kalzium/kalziumglhelperclasses.h index 4e6bb10..0b0b821 100644 --- a/kalzium/kalziumglhelperclasses.h +++ b/kalzium/kalziumglhelperclasses.h @@ -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 ); diff --git a/kalzium/kalziumglwidget.cpp b/kalzium/kalziumglwidget.cpp index 9432336..078f72f 100644 --- a/kalzium/kalziumglwidget.cpp +++ b/kalzium/kalziumglwidget.cpp @@ -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;