1
/*********************************************************************************
2
* Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it *
3
* Copyright (C) 2007 by Carste Niehaus, cniehaus@kde.org *
4
* copyright (C) 2010 by Etienne Rebetez, etienne.rebetez@oberwallis.ch *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20
***************************************************************************/
25
#include "libkdeedu_science_export.h"
29
#include <QStringList>
33
* Provides functions to easyli create pse tables with qGridLayouts or qGraphicsView.
35
* creating a table for the gridlayout
37
foreach (int elementIndex, pseTables::instance()->getTabletype( m_psTableType )->elements()) {
38
int group = pseTables::instance()->getTabletype( m_psTableType )->elementCoords( elementIndex ).x();
39
int period = pseTables::instance()->getTabletype( m_psTableType )->elementCoords( elementIndex ).y();
41
ElementLabel *element = new ElementLabel( elementIndex );
43
gridLayoutOfPeriodSystem->addItem (element, period, group );
48
* position elements in a qGraphicsScene
54
* getting the position of the Numerations for the periodic system of elements (j)
56
for (int i = 0; i < pseTables::instance()->getTabletype( j )->tableSize().x() || i < numerationItems.count(); i++) {
57
int itemAtPos = pseTables::instance()->getTabletype( j )->numerationAtPos( i );
60
* @short Provides shape and elements of diferent peridic tables of elements
61
* @author Etienne Rebetez
66
* Holds all periodic system tables and make them accesible.
68
class SCIENCE_EXPORT pseTables
71
static pseTables *instance();
76
* Returns the KalziumTableType with the @p id specified.
77
* It will gives 0 if none found.
79
pseTable* getTabletype(const int tableType);
82
* Returns the KalziumTableType whose name is the @p id
84
* It will gives 0 if none found.
86
pseTable* getTabletype(const QString tableType);
89
* Returns a list with the names of the table types we support.
91
QStringList tables() const;
95
QList<pseTable*> m_tables;
101
* defines a Periodic Table.
102
* Holds the position (x,y) and all the displaed elements
108
static pseTable *init();
113
* Returns the ID of this table type.
115
virtual QString name() const;
118
* Returns a short description of the periodic table in use
120
virtual QString description() const;
123
* Returns the coordinates of an element @p element in
124
* the periodic system.
125
* If the element is not in the periodic system QPoint(-1,-1) is returned.
127
virtual QPoint elementCoords(int element) const;
130
* Returns a list with all elements in the actual periodic table
132
virtual QList<int> elements() const;
136
* Returns the element that comes right before the specified @p element.
137
* -1 means that @p element is the first in this table type.
139
* The default implementation returns <tt>element - 1</tt> if @p element
142
virtual int previousOf ( int element ) const;
145
* Returns the element that comes right after the specified @p element.
146
* -1 means that @p element is the last in this table type.
148
* The default implementation returns <tt>element + 1</tt> if @p element
149
* is not the latest element, else -1.
151
virtual int nextOf ( int element ) const;
154
* Returns the first element of the table.
156
virtual int firstElement() const;
159
* Returns the last element of the table.
161
virtual int lastElement() const;
164
* Returns the maximal size of the periodic table.
166
virtual QPoint tableSize() const;
169
* Returns the Numeration for the current Table according to the position in the Table.
170
* Coordinatates beginning wiht 0. Returns -1 if none is found.
172
virtual int numerationAtPos( int xPos ) const;
178
QString m_description;
182
QList<int> m_xCoordsNumeration;
183
QList<int> m_elementList;
188
class pseRegularTable : public pseTable
191
static pseRegularTable *init();
197
class pseLongTable : public pseTable
200
static pseLongTable *init();
206
class pseShortTable : public pseTable
209
static pseShortTable *init();
215
class pseDTable : public pseTable
218
static pseDTable *init();
224
class pseDZTable : public pseTable
227
static pseDZTable *init();