From b09a72c046c2eecd3de73724b7bd1a80d19296fa Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 15 Jun 2005 18:01:48 +0000 Subject: [PATCH] Unify some code for the drawing of crystal structures, plus using a brighter color for the "own" crysal structure. svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=425840 --- kalzium/src/element.cpp | 92 ++++++++++++----------------------------- kalzium/src/element.h | 12 +++--- 2 files changed, 31 insertions(+), 73 deletions(-) diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index 53534b4..36747bc 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -263,70 +263,6 @@ const QString Element::adjustUnits( const int type ) return v; } -void Element::drawCrystalstructure( QPainter* p ) -{ - //the height of a "line" inside an element - int h_small = 15; //the size for the small units like elementnumber - - //The X-coordiante - int X = xPos(); - - //The Y-coordinate - int Y = yPos(); - - QColor color; - QString name; - QString structure = crystalstructure(); - /** - * hcp: hexagonal close packed - * fcc: face centered cubic - * krz/bbc cubic body centered // kubisch raumzentriert - * kdp: kubisch dicht gepackt - * hdp: hexagonal dicht gepackt - * ccp: cubic close packed // kubisch dichteste Kugelpackung - */ - if ( structure == "own"){ - color = Qt::blue; - name = i18n( "this means, the element has its 'own' structur", "own" ); - }else if ( structure == "bbc" ){ - color = Qt::red; - name = i18n( "Crystalsystem body centered cubic", "bbc" ); - }else if ( structure == "hdp" ){ - color = Qt::yellow; - name = i18n( "Crystalsystem hexagonal dense packed", "hdp" ); - }else if ( structure == "ccp" ){ - color = Qt::green; - name = i18n( "Crystalsystem cubic close packed", "ccp" ); - } - else{ - color = Qt::white; - name = QString::null; - } - setElementColor( color ); - - p->setPen( color ); - p->fillRect( X, Y,ELEMENTSIZE,ELEMENTSIZE, color ); - p->drawRect( X, Y,ELEMENTSIZE,ELEMENTSIZE ); - - QFont symbol_font = p->font(); - symbol_font.setPointSize( 18 ); - QFont f = p->font(); - f.setPointSize( 9 ); - - p->setFont( f ); - - //top left - p->setPen( Qt::black ); - p->drawText( X,Y ,ELEMENTSIZE,h_small,Qt::AlignCenter, name ); - - p->setFont( symbol_font ); - p->drawText( X,Y, ELEMENTSIZE,ELEMENTSIZE,Qt::AlignCenter, symbol() ); - - //border - p->setPen( Qt::black ); - p->drawRect( X, Y,ELEMENTSIZE+1,ELEMENTSIZE+1); -} - void Element::drawStateOfMatter( QPainter* p, double temp ) { //the height of a "line" inside an element @@ -436,7 +372,7 @@ void Element::drawGradient( QPainter* p, const QString& value, const QColor& c) p->drawRect( X, Y,ELEMENTSIZE+1,ELEMENTSIZE+1); } -void Element::drawSelf( QPainter* p, bool simple ) +void Element::drawSelf( QPainter* p, bool simple, bool isCrystal ) { //the height of a "line" inside an element int h_small = 15; //the size for the small units like elementnumber @@ -461,7 +397,31 @@ void Element::drawSelf( QPainter* p, bool simple ) if ( !simple ) {//the user only want a simply pse, no weight the cell - text = QString::number( strippedValue( mass( ) ) ); + QString text; + if ( isCrystal ) + { + QString structure = crystalstructure(); + /** + * hcp: hexagonal close packed + * fcc: face centered cubic + * krz/bbc cubic body centered // kubisch raumzentriert + * kdp: kubisch dicht gepackt + * hdp: hexagonal dicht gepackt + * ccp: cubic close packed // kubisch dichteste Kugelpackung + */ + if ( structure == "own") + text = i18n( "this means, the element has its 'own' structur", "own" ); + else if ( structure == "bbc" ) + text = i18n( "Crystalsystem body centered cubic", "bbc" ); + else if ( structure == "hdp" ) + text = i18n( "Crystalsystem hexagonal dense packed", "hdp" ); + else if ( structure == "ccp" ) + text = i18n( "Crystalsystem cubic close packed", "ccp" ); +// else +// text = QString::null; + } + else + text = QString::number( strippedValue( mass( ) ) ); p->drawText( X,Y ,ELEMENTSIZE,h_small,Qt::AlignCenter, text ); } diff --git a/kalzium/src/element.h b/kalzium/src/element.h index a599353..e39cbc6 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -497,16 +497,14 @@ class Element{ doubleList m_ionenergies; public: - /** - * draw the recatangle with the information - * @param showFullInformation if True more information will be shown - */ virtual void drawGradient( QPainter* p, const QString& value, const QColor& ); - virtual void drawSelf( QPainter* p, bool simple = false ); + /** + * draw the rectangle with the information + * @param simple if True more information will be shown + */ + virtual void drawSelf( QPainter* p, bool simple = false, bool isCrystal = false ); - virtual void drawCrystalstructure( QPainter* p ); - virtual void drawStateOfMatter( QPainter* p, double temperature ); }; -- 2.47.3