]> Git trees. - libqmvoc.git/commitdiff
* removing az()
authorCarsten Niehaus <cniehaus@gmx.de>
Thu, 9 Jun 2005 21:32:24 +0000 (21:32 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Thu, 9 Jun 2005 21:32:24 +0000 (21:32 +0000)
* adding the info if an element is artificial
* adding the info if an element is radioactive
* Only show solid/gasoline/liquid in the som
* this and that

svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=423847

kalzium/src/element.cpp
kalzium/src/element.h

index 7ea34a96350d66194e6f1ce9f3114984637197de..f7d6ae80f08dc1f431afea1e00d54278a8e515b9 100644 (file)
@@ -36,6 +36,8 @@
 
 Element::Element()
 {
+       m_radioactive = false;
+       m_artificial = false;
 }
 
 QString Element::parsedOrbits( bool canBeEmpty )
@@ -233,7 +235,7 @@ const QString Element::adjustUnits( const int type )
                                        v = i18n( "%1 kg/m<sup>3</sup>" ).arg( QString::number( val ) );
                                        break;
                                case 1://use more common units
-                                       if ( az() == 2 )//gasoline
+                                       if ( boiling() < 295.0 )//gasoline
                                        {
                                                v = i18n( "%1 g/L" ).arg( QString::number( val ) );
                                        }
@@ -356,27 +358,25 @@ void Element::drawStateOfMatter( QPainter* p, double temp )
        p->drawRect( X, Y,ELEMENTSIZE+1,ELEMENTSIZE+1);
 }
        
-QColor Element::currentColor( double temp )
+QColor Element::currentColor( const double temp )
 {
        QColor color;
+       
        //take the colours for the given temperature
-       const int _az = az();
-       if ( _az == 3 || _az == 4 )
-       { //check if the element is radioactive or artificial
-               if ( _az == 3 ) color=Prefs::color_radioactive();
-               if ( _az == 4 ) color=Prefs::color_artificial();
-               return color;
-       }
-
        const double iButton_melting = melting();
        const double iButton_boiling = boiling();
 
+       //If either the mp or bp is not known return
+       //This is to avoid undefined behaviour
+       if ( iButton_boiling <= 0.0 || iButton_melting <= 0.0 )
+               return Qt::lightGray;
+
        if ( temp < iButton_melting )
        { //the element is solid
                color= Prefs::color_solid();
        }
        else if ( temp > iButton_melting &&
-                       temp < iButton_boiling )
+                       temp < iButton_boiling ) 
        { //the element is liquid
                color= Prefs::color_liquid();
        }
@@ -387,7 +387,6 @@ QColor Element::currentColor( double temp )
        else
                color = Qt::lightGray;
 
-
        return color;
 }
 
@@ -614,7 +613,8 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                QString ionic_charge = domElement.namedItem( "radius" ).namedItem( "ionic" ).toElement().attributeNode( "charge" ).value();
                
                int bio = domElement.namedItem( "biologicalmeaning" ).toElement().text().toInt();
-               int az = domElement.namedItem( "aggregation" ).toElement().text().toInt();
+               int radioactive = domElement.namedItem( "radioactive" ).toElement().text().toInt();
+               int artificial = domElement.namedItem( "artificial" ).toElement().text().toInt();
                int date = domElement.namedItem( "date" ).toElement().text().toInt();
                int number = domElement.namedItem( "number" ).toElement().text().toInt();
                
@@ -644,16 +644,20 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                Element *e = new Element();
                e->setDate(date);
                e->setBiologicalMeaning(bio);
-               e->setAggregation(az);
                e->setNumber( number );
+               e->setName(name);
                e->setRadius( Element::ATOMIC, atomic_radius );
                e->setRadius( Element::IONIC, ionic_radius, ionic_charge );
                e->setRadius( Element::COVALENT, covalent_radius );
                e->setRadius( Element::VDW, vdw_radius );
+
+               if ( artificial == 1 )
+                       e->setArtificial();
+               if ( radioactive == 1 )
+                       e->setRadioactive();
                
                e->setScientist(scientist);
                e->setCrysatalstructure( crystal );
-               e->setName(name);
                e->setOrigin(origin);
                e->setBlock(block);
                e->setGroup(group);
index 646add54c7c2f6bf2ab48ecb2f057af99f18ad64..fb20890bcb462f81b1ffeba2b87cfc3858f5d0db 100644 (file)
@@ -89,7 +89,7 @@ class Element{
                {
                        ATOMIC = 0,
                        IONIC,
-                       VDW, //van der Waals forces
+                       VDW, //van der Waals radius
                        COVALENT
                };
 
@@ -101,6 +101,14 @@ class Element{
                        return m_number;
                }
 
+               bool radioactive() const{
+                       return m_radioactive;
+               }
+               
+               bool artificial() const{
+                       return m_artificial;
+               }
+
                QString nameOrigin() const{
                        return m_origin;
                }
@@ -121,7 +129,6 @@ class Element{
                
                void setDate( int date ) { m_date = date; }
                void setBiologicalMeaning( int value ) { m_biological = value; }
-               void setAggregation( int value ) { m_az = value; }
                void setNumber( int num ){ m_number = num; }
 
                void setScientist( const QString& value ) { m_scientist = value; }
@@ -137,6 +144,9 @@ class Element{
                void setAcidicbehaviour( const QString& value ) { m_acidbeh = value; }
                void setIsotopes( const QString& value ) { m_isotopes = value; }
 
+               void setArtificial(){ m_artificial = true; }
+               void setRadioactive(){ m_radioactive = true; }
+
                void setIonisationList( doubleList l ){
                        m_ionenergies = l;
                }
@@ -153,12 +163,15 @@ class Element{
                        return m_date; 
                }
 
-               ///return the correct color of the element
-               QColor currentColor( double temp );
+               /**
+                * return the correct color of the element at the
+                * temperature @p temp
+                */
+               QColor currentColor( const double temp );
     
-    /**
-     * mutator for the element's color
-     */
+               /**
+                * mutator for the element's color
+                */
                void setElementColor( const QColor &c ) { m_Color = c; }
                
                /**
@@ -176,14 +189,6 @@ class Element{
                        return m_biological;
                }
                
-               /**
-                * @return the condition of aggrgation of the element at 
-                * room temperature. 0 means solid, 1 means liquid, 2 means vapor
-                */
-               int az() const {
-                       return m_az;
-               }
-               
                /**
                 * @return the symbol of the element
                 */
@@ -396,7 +401,6 @@ class Element{
 
                int     m_number, 
                        m_date,
-                       m_az,
                        m_biological;
 
                QString m_symbol,
@@ -413,6 +417,9 @@ class Element{
                        m_crystalstructure,
                        m_ionvalue;
 
+               bool m_artificial,
+                        m_radioactive;
+
                doubleList m_ionenergies;
                
        public: