]> Git trees. - libqmvoc.git/commitdiff
New periodic table of elements for kalzium.
authorEtienne Rebetez <etienne.rebetez@oberwallis.ch>
Mon, 16 Aug 2010 18:05:25 +0000 (18:05 +0000)
committerEtienne Rebetez <etienne.rebetez@oberwallis.ch>
Mon, 16 Aug 2010 18:05:25 +0000 (18:05 +0000)
Adding universal gradient slider.

BUG: 191836
BUG: 162798
FEATURE: 126717
GUI

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=1164426

libscience/psetables.cpp
libscience/psetables.h

index c3c3a96842ebcbd8a59f6f01260c0686fabe0569..b9d1d3d5b969400329231bb1c94541934d55b309 100644 (file)
@@ -36,6 +36,9 @@ pseTables::pseTables()
 
 pseTables::~pseTables()
 {
+//     foreach(psTable *i, m_tables) {
+//         delete i;
+//     }
 }
 
 pseTables *pseTables::instance()
@@ -73,8 +76,6 @@ pseTable* pseTables::getTabletype(const QString tableName)
     return 0;
 }
 
-
-
 pseTable::pseTable()
 {
 }
@@ -139,7 +140,7 @@ QPoint pseTable::coordsMax() const
 {
     int x = 0, y = 0, i;
 
-    for(i = 0; i < m_posX.count(); i++) {
+    for (i = 0; i < m_posX.count(); i++) {
         if (m_posX.at(i) > x) {
             x = m_posX.at(i) ;
         }
@@ -150,6 +151,14 @@ QPoint pseTable::coordsMax() const
     return QPoint(x, y);
 }
 
+int pseTable::numeration( int xPos ) const
+{
+  if ( xPos >= 0 && xPos < m_xCoordsNumeration.count() ) {
+     return m_xCoordsNumeration.at( xPos );
+  }
+  return -1;
+}
+
 /// Regular Table Data
 pseRegularTable::pseRegularTable()
         : pseTable()
@@ -158,6 +167,9 @@ pseRegularTable::pseRegularTable()
 
     m_description = i18n( "Classic Periodic Table" );
 
+    m_xCoordsNumeration <<
+    1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18;
+
     m_posX <<
     1 <<                                                                                         18 <<
     1 << 2 <<                                                      13 << 14 << 15 << 16 << 17 << 18 <<
@@ -204,6 +216,9 @@ pseLongTable::pseLongTable()
 
     m_description = i18n( "Long Periodic Table" );
 
+    m_xCoordsNumeration <<
+    1 << 2 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 <<-1 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18;
+
     m_posX <<
     1 <<                                                                                                                                                      32 <<
     1 << 2 <<                                                                                                                        27 <<28 <<29 <<30 <<31 <<32 <<
@@ -246,6 +261,9 @@ pseShortTable::pseShortTable()
 
     m_description = i18n( "Short Periodic Table" );
 
+    m_xCoordsNumeration <<
+    1 << 2 <<13 <<14 <<15 <<16 <<17 <<18;
+
     m_posX <<
     1 <<                               8 <<//He
     1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Ne
@@ -291,6 +309,9 @@ pseDTable::pseDTable()
 
     m_description = i18n( "Transition Elements" );
 
+    m_xCoordsNumeration <<
+    3<< 4<< 5<< 6<< 7<< 8<< 9<<10<<11<< 12;
+
     m_posX <<
     1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10<<
     1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10<<
@@ -328,12 +349,15 @@ pseDZTable::pseDZTable()
 
     m_description = i18n( "DZ Periodic Table" );
 
+    m_xCoordsNumeration <<
+    1 << 2 <<13 <<14 <<15 <<16 <<17 <<18 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12;
+
     m_posX <<
     1<< 2<<
     2<< 2<<
-         3<< 4<< 5<< 6<< 7<< 8<<
+    3<< 4<< 5<< 6<< 7<< 8<<
     1<< 2<<
-         3<< 4<< 5<< 6<< 7<< 8<<
+    3<< 4<< 5<< 6<< 7<< 8<<
     1<< 2<<
                            9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
          3<< 4<< 5<< 6<< 7<< 8<<
@@ -347,29 +371,30 @@ pseDZTable::pseDZTable()
     1<< 2<<
                                                               19<<20<<21<<22<<23<<24<<25<<26<<27<<28<<29<<30<<31<<32<<
                            9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
-         3 <<4 <<5 <<6
+         3 <<4 <<5 <<6 <<7 <<8
     ;
 
     m_posY <<
     1<< 1<<
     2<< 2<<
-         3<< 3<< 3<< 3<< 3<< 3<<
+    3<< 3<< 3<< 3<< 3<< 3<<
     4<< 4<<
-         5<< 5<< 5<< 5<< 5<< 5<<
+    5<< 5<< 5<< 5<< 5<< 5<<
     6<< 6<<
                           7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<<
          8<< 8<< 8<< 8<< 8<< 8<<
     9<< 9<<
-                          10<<10<<10<<10<<10<<10<<10<<10<<10<<10<<
-         11<<11<<11<<11<<11<<11<<
+    10<<10<<10<<10<<10<<10<<10<<10<<10<<10<<
+    11<<11<<11<<11<<11<<11<<
     12<<12<<
+
                                                               13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<
                           14<<14<<14<<14<<14<<14<<14<<14<<14<<14<<
          15<<15<<15<<15<<15<<15<<
     16<<16<<
                                                               17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<
                           18<<18<<18<<18<<18<<18<<18<<18<<18<<18<<
-         19<<19<<19<<19
+         19<<19<<19<<19<<19<<19
     ;
 
     // The DZ PS has all Elements
@@ -385,4 +410,4 @@ pseDZTable *pseDZTable::init()
 {
     static pseDZTable thisTable;
     return &thisTable;
-}
\ No newline at end of file
+}
index fdd2148794ce3cb984272372bb6ee6f8baa6604a..79180575870804de756273064663655c5d826048 100644 (file)
@@ -1,13 +1,13 @@
 /*********************************************************************************
- *   Copyright (C) 2005, 2006   by Pino Toscano, toscano.pino@tiscali.it         *
- *   Copyright (C) 2007         by Carste Niehaus, cniehaus@kde.org              *
- *   copyright (C) 2010         by Etienne Rebetez, etienne.rebetez@oberwallis.ch*
+ *   Copyright (C) 2005, 2006  by Pino Toscano, toscano.pino@tiscali.it          *
+ *   Copyright (C) 2007        by Carste Niehaus, cniehaus@kde.org               *
+ *   copyright (C) 2010        by Etienne Rebetez, etienne.rebetez@oberwallis.ch *
  *                                                                               *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify       *
+ *   it under the terms of the GNU General Public License as published by      *
+ *   the Free Software Foundation; either version 2 of the License, or        *
+ *   (at your option) any later version.                                     *
+ *                                                                          *
  *   This program is distributed in the hope that it will be useful,       *
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 #include <QList>
 #include <QStringList>
 
+/**
+ * @class pseTables
+ * Provides functions to easyli create pse tables with q*GridLayouts or qGraphicsView.
+ *
+ * creating a table for the gridlayout
+@code
+  foreach (intElement, pseTables::instance()->getTabletype( m_psTableType )->elements()) {
+       group = pseTables::instance()->getTabletype( m_psTableType )->elementCoords( intElement ).x();
+       period = pseTables::instance()->getTabletype( m_psTableType )->elementCoords( intElement ).y();
+
+       ElementLabel *element = new ElementLabel( intElement );
+
+       gridLayoutOfPeriodSystem->addItem (element, period, group );
+  }
+
+@endcode
+
+ * position elements in a qGraphicsScene
+@code
+
+
+@endcode
+
+ * getting the position of the Numerations for the pse (j)
+ @code
+    for (int i = 0; i < pseTables::instance()->getTabletype( j )->coordsMax().x() || i < numerationItems.count(); i++) {
+       int itemAtPos = pseTables::instance()->getTabletype( j )->numeration( i );
+    }
+ @endcode
+ * @short Provides shape and elements of diferent peridic tables of elements
+ * @author Etienne Rebetez
+ */
 class pseTable;
 
 /**
@@ -69,7 +101,8 @@ private:
  * defines a Periodic Table.
  * Holds the position (x,y) and all the displaed elements
  */
-class SCIENCE_EXPORT pseTable
+class pseTable
+
 {
 public:
     static pseTable *init();
@@ -93,13 +126,19 @@ public:
     virtual QPoint elementCoords(int element);
 
     /**
+     * Returns a list with all elements in the actual periodic table
+     */
+    virtual QList<int> elements() const;
+
+    /**
+
      * Returns the element that comes right before the specified @p element.
      * -1 means that @p element is the first in this table type.
      *
      * The default implementation returns <tt>element - 1</tt> if @p element
      * is not 1, else -1.
      */
-    int previousOf ( int element ) const;
+    virtual int previousOf ( int element ) const;
 
     /**
      * Returns the element that comes right after the specified @p element.
@@ -108,28 +147,28 @@ public:
      * The default implementation returns <tt>element + 1</tt> if @p element
      * is not the latest element, else -1.
      */
-    int nextOf ( int element ) const;
+    virtual int nextOf ( int element ) const;
 
     /**
      * Returns the first element of the table.
      */
-    int firstElement() const;
+    virtual int firstElement() const;
 
     /**
      * Returns the last element of the table.
      */
-    int lastElement() const;
-
-    /**
-     * Returns a list with all elements in the actual periodic table
-     */
-    virtual QList<int> elements() const;
+    virtual int lastElement() const;
 
     /**
      * Returns the maximal Coordinates of the periodic table.
      */
     virtual QPoint coordsMax() const;
 
+     /**
+     * Returns the Numeration for the current Table according to the position in the Table. IUPAC Style eq. numbers
+     */
+     virtual int numeration( int xPos ) const;
+
 protected:
     pseTable();
 
@@ -138,6 +177,7 @@ protected:
 
     QList<int> m_posX;
     QList<int> m_posY;
+    QList<int> m_xCoordsNumeration;
     QList<int> m_elementList;
 };