From 9243ad2c9300b7e40369620b7dc9faf79d501424 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Thu, 26 May 2005 18:06:01 +0000 Subject: [PATCH] * adding the rest of the data * adding the drawing stuff needed for the crystal mode svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=418482 --- kalzium/src/element.cpp | 55 +++++++++++++++++++++++++---------------- kalzium/src/element.h | 7 ++++++ 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index a2563b5..f5f5d2c 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -238,19 +238,38 @@ 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 = ( x-1 )*ELEMENTSIZE; - - //The Y-coordinate - int Y = ( y-1 )*ELEMENTSIZE; + int X = xPos(); - QColor color = Qt::blue; + //The Y-coordinate + int Y = yPos(); + QColor color; + QString name; + QString structure = crystalstructure(); + if ( structure == "own"){ + color = Qt::blue; + name = i18n( "own" ); + }else if ( structure == "bbc" ){ + color = Qt::red; + name = i18n( "bbc" ); + }else if ( structure == "hdp" ){ + color = Qt::yellow; + name = i18n( "hdp" ); + }else if ( structure == "ccp" ){ + color = Qt::green; + name = i18n( "ccp" ); + } + else{ + color = Qt::white; + name = QString::null; + } + p->setPen( color ); p->fillRect( X+3, Y+3,ELEMENTSIZE-6,ELEMENTSIZE-6, color ); p->drawRoundRect( X+2, Y+2,ELEMENTSIZE-4,ELEMENTSIZE-4 ); - QString text; QFont symbol_font = p->font(); symbol_font.setPointSize( 18 ); QFont f = p->font(); @@ -260,8 +279,7 @@ void Element::drawCrystalstructure( QPainter* p ) //top left p->setPen( Qt::black ); - text = crystalstructure(); - p->drawText( X+5,Y+2 ,ELEMENTSIZE-2,h_small,Qt::AlignLeft, text ); + p->drawText( X+5,Y+2 ,ELEMENTSIZE-2,h_small,Qt::AlignLeft, name ); p->setFont( symbol_font ); p->drawText( X+5,Y+2, ELEMENTSIZE,ELEMENTSIZE,Qt::AlignCenter, symbol() ); @@ -269,7 +287,6 @@ void Element::drawCrystalstructure( QPainter* p ) //border p->setPen( Qt::black ); p->drawRoundRect( X+1, Y+1,ELEMENTSIZE-2,ELEMENTSIZE-2); - } void Element::drawStateOfMatter( QPainter* p, double temp ) @@ -278,10 +295,10 @@ void Element::drawStateOfMatter( QPainter* p, double temp ) int h_small = 15; //the size for the small units like elementnumber //The X-coordiante - int X = ( x-1 )*ELEMENTSIZE; - + int X = xPos(); + //The Y-coordinate - int Y = ( y-1 )*ELEMENTSIZE; + int Y = yPos(); QColor color = currentColor( temp ); @@ -379,13 +396,10 @@ void Element::drawGradient( QPainter* p, const QString& value, const QColor& c) int h_small = 15; //the size for the small units like elementnumber //The X-coordiante - int X = 0; + int X = xPos(); - X = ( x-1 )*ELEMENTSIZE; - //The Y-coordinate - int Y = ( y-1 )*ELEMENTSIZE; - Y += ELEMENTSIZE; + int Y = yPos(); p->setPen( c ); p->fillRect( X+3, Y+3,ELEMENTSIZE-6,ELEMENTSIZE-6, c ); @@ -415,11 +429,10 @@ void Element::drawSelf( QPainter* p ) int h_small = 15; //the size for the small units like elementnumber //The X-coordiante - int X = ( x-1 )*ELEMENTSIZE; - + int X = xPos(); + //The Y-coordinate - int Y = ( y-1 )*ELEMENTSIZE; - Y += ELEMENTSIZE; + int Y = yPos(); p->setPen( elementColor() ); p->fillRect( X+3, Y+3,ELEMENTSIZE-6,ELEMENTSIZE-6, elementColor() ); diff --git a/kalzium/src/element.h b/kalzium/src/element.h index 02dce64..c7f4214 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -328,6 +328,13 @@ class Element{ QColor m_Color; + inline int xPos() const{ + return ( x-1 )*ELEMENTSIZE; + } + inline int yPos() const{ + return ( y-1 )*ELEMENTSIZE + ELEMENTSIZE; + } + double m_weight, m_MP, m_BP, -- 2.47.3