From 0cb1b485010014e2a9dd6fc71cf24f8fbe394d8d Mon Sep 17 00:00:00 2001 From: Etienne Rebetez Date: Mon, 16 Aug 2010 18:05:25 +0000 Subject: [PATCH] New periodic table of elements for kalzium. Adding universal gradient slider. BUG: 191836 BUG: 162798 FEATURE: 126717 GUI svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=1164426 --- libscience/psetables.cpp | 49 +++++++++++++++++++------- libscience/psetables.h | 76 ++++++++++++++++++++++++++++++---------- 2 files changed, 95 insertions(+), 30 deletions(-) diff --git a/libscience/psetables.cpp b/libscience/psetables.cpp index c3c3a96..b9d1d3d 100644 --- a/libscience/psetables.cpp +++ b/libscience/psetables.cpp @@ -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 < #include +/** + * @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 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 element - 1 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 element + 1 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 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 m_posX; QList m_posY; + QList m_xCoordsNumeration; QList m_elementList; }; -- 2.47.3