• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kalzium/libscience

  • sources
  • kde-4.12
  • kdeedu
  • kalzium
  • libscience
psetables.cpp
Go to the documentation of this file.
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*
5  * *
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. *
10  * *
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. *
15  * *
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  ***************************************************************************/
21 
22 #include "psetables.h"
23 
24 #include <klocale.h>
25 #include <kdebug.h>
26 
27 
28 pseTables::pseTables()
29 {
30  m_tables << pseRegularTable::init();
31  m_tables << pseShortTable::init();
32  m_tables << pseLongTable::init();
33  m_tables << pseDTable::init();
34  m_tables << pseDZTable::init();
35 }
36 
37 pseTables::~pseTables()
38 {
39 }
40 
41 pseTables *pseTables::instance()
42 {
43  static pseTables tables;
44  return &tables;
45 }
46 
47 QStringList pseTables::tables() const
48 {
49  QStringList l;
50  for ( int i = 0; i < m_tables.count(); i++ )
51  {
52  l << m_tables.at( i )->description();
53  }
54  return l;
55 }
56 
57 pseTable* pseTables::getTabletype(const int tableType)
58 {
59  if ( ( tableType < 0 ) || ( tableType >= m_tables.count() ) ) {
60  return 0;
61  }
62 
63  return m_tables.at( tableType );
64 }
65 
66 pseTable* pseTables::getTabletype(const QString tableName)
67 {
68  for ( int i = 0; m_tables.count(); i++ ) {
69  if (tableName == m_tables.at( i )->name() ) {
70  return m_tables.at( i );
71  }
72  }
73  return 0;
74 }
75 
76 pseTable::pseTable()
77 {
78 }
79 
80 pseTable::~pseTable()
81 {
82 }
83 
84 pseTable *pseTable::init()
85 {
86  return 0;
87 }
88 
89 QString pseTable::name() const
90 {
91  return m_name;
92 }
93 
94 QString pseTable::description() const
95 {
96  return m_description;
97 }
98 
99 QList<int> pseTable::elements() const
100 {
101  return m_elementList;
102 }
103 
104 int pseTable::previousOf( int element ) const
105 {
106  int index = m_elementList.indexOf( element );
107  return index > 0 ? m_elementList.at( index - 1 ) : -1;
108 }
109 
110 int pseTable::nextOf( int element ) const
111 {
112  int index = m_elementList.indexOf( element );
113  return index != -1 && ( index < m_elementList.count() - 1 ) ? m_elementList.at( index + 1 ) : -1;
114 }
115 
116 int pseTable::firstElement() const
117 {
118  return m_elementList.first();
119 }
120 
121 int pseTable::lastElement() const
122 {
123  return m_elementList.last();
124 }
125 
126 QPoint pseTable::elementCoords(const int element) const
127 {
128  int x = -1, y = -1;
129  int elementIndex = m_elementList.indexOf( element );
130 
131  if ( elementIndex >= 0 && elementIndex < m_elementList.count() ) {
132  // The positions lists are defined with the base of 1.
133  // But coordinates start mostly with 0.
134  x = m_posX.at( elementIndex ) - 1;
135  y = m_posY.at( elementIndex ) - 1;
136  }
137  return QPoint(x, y);
138 }
139 
140 QPoint pseTable::tableSize() const
141 {
142  int x = 0, y = 0, i;
143 
144  for (i = 0; i < m_posX.count(); ++i) {
145  if ( m_posX.at(i) > x)
146  x = m_posX.at(i);
147 
148  if ( m_posY.at(i) > y)
149  y = m_posY.at(i);
150  }
151  return QPoint(x, y);
152 }
153 
154 int pseTable::numerationAtPos( int xPos ) const
155 {
156  if ( xPos >= 0 && xPos < m_xCoordsNumeration.count() ) {
157  return m_xCoordsNumeration.at( xPos ) - 1;
158  }
159  return -1;
160 }
161 
163 pseRegularTable::pseRegularTable()
164  : pseTable()
165 {
166  m_name = "Classic";
167 
168  m_description = i18n( "Classic Periodic Table" );
169 
170  m_xCoordsNumeration <<
171  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18;
172 
173  m_posX <<
174  1 << 18 <<
175  1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 <<
176  1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 <<
177  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 <<
178  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << //Element 54 (Xe)
179  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << //Element 58 (Ce) 71 (Lu)
180  4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 <<
181  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << //Element 71 (Lr)
182  4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18
183  ;
184 
185  m_posY <<
186  1 << 1 <<
187  2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 <<
188  3 << 3 << 3 << 3 << 3 << 3 << 3 << 3 <<
189  4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 <<
190  5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << //Element 54 (Xe)
191  6 << 6 << 6 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << //Element 71 (Lr)
192  6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 <<
193  7 << 7 << 7 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 <<
194  7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7
195  ;
196 
197  // The classic PS has all Elements
198  if (m_posX.count() == m_posY.count() ) {
199  for (int i = 1; i <= m_posX.count(); i ++) {
200  m_elementList.append(i);
201  }
202  }
203 }
204 
205 pseRegularTable *pseRegularTable::init()
206 {
207  static pseRegularTable thisTable;
208  return &thisTable;
209 }
210 
212 pseLongTable::pseLongTable()
213  : pseTable()
214 {
215  m_name = "Long";
216 
217  m_description = i18n( "Long Periodic Table" );
218 
219  m_xCoordsNumeration <<
220  1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18;
221 
222  m_posX <<
223  1 << 32 <<
224  1 << 2 << 27 <<28 <<29 <<30 <<31 <<32 <<
225  1 << 2 << 27 <<28 <<29 <<30 <<31 <<32 <<
226  1 << 2 << 17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 <<
227  1 << 2 << 17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 <<
228  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 <<
229  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32
230  ;
231 
232  m_posY <<
233  1 << 1 <<
234  2 << 2 << 2 <<2 <<2 <<2 <<2 <<2 <<
235  3 << 3 << 3 <<3 <<3 <<3 <<3 <<3 <<
236  4 << 4 << 4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<
237  5 << 5 << 5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<
238  6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<
239  7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7
240  ;
241 
242  // The long PS has all Elements
243  if (m_posX.count() == m_posY.count() ) {
244  for (int i = 1; i <= m_posX.count(); i ++) {
245  m_elementList.append(i);
246  }
247  }
248 }
249 
250 pseLongTable *pseLongTable::init()
251 {
252  static pseLongTable thisTable;
253  return &thisTable;
254 }
255 
257 pseShortTable::pseShortTable()
258  : pseTable()
259 {
260  m_name = "Short";
261 
262  m_description = i18n( "Short Periodic Table" );
263 
264  m_xCoordsNumeration <<
265  1 << 2 <<13 <<14 <<15 <<16 <<17 <<18;
266 
267  m_posX <<
268  1 << 8 <<//He
269  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Ne
270  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Ar
271  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Kr
272  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Xe
273  1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 <<//Rn
274  1 << 2 //Fr and Ra
275  ;
276 
277  m_posY <<
278  1 << 1 <<//He
279  2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 <<//Ne
280  3 << 3 << 3 << 3 << 3 << 3 << 3 << 3 <<//Ar
281  4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 <<//Kr
282  5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 <<//Xe
283  6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 <<//Rn
284  7 << 7 //Fr and Ra
285  ;
286 
287  m_elementList <<
288  1 << 2 <<//He
289  3 << 4 << 5 << 6 << 7 << 8 << 9 << 10<<//Ne
290  11<< 12<< 13<< 14<< 15<< 16<< 17<< 18<<//Ar
291  19<< 20<< 31<< 32<< 33<< 34<< 35<< 36<<//Kr
292  37<< 38<< 49<< 50<< 51<< 52<< 53<< 54<<//Xe
293  55<< 56<< 81<< 82<< 83<< 84<< 85<< 86<<//Rn
294  87<< 88 //Fr and Ra
295  ;
296 }
297 
298 pseShortTable *pseShortTable::init()
299 {
300  static pseShortTable thisTable;
301  return &thisTable;
302 }
303 
305 pseDTable::pseDTable()
306  : pseTable()
307 {
308  m_name = 'D';
309 
310  m_description = i18n( "Transition Elements" );
311 
312  m_xCoordsNumeration <<
313  3<< 4<< 5<< 6<< 7<< 8<< 9<<10<<11<< 12;
314 
315  m_posX <<
316  1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10<<
317  1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10<<
318  1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10<<
319  1<< 2<< 3<< 4<< 5<< 6<< 7<< 8<< 9<< 10
320  ;
321 
322  m_posY <<
323  1<< 1<< 1<< 1<< 1<< 1<< 1<< 1<< 1<< 1<<
324  2<< 2<< 2<< 2<< 2<< 2<< 2<< 2<< 2<< 2<<
325  3<< 3<< 3<< 3<< 3<< 3<< 3<< 3<< 3<< 3<<
326  4<< 4<< 4<< 4<< 4<< 4<< 4<< 4<< 4<< 4
327  ;
328 
329  m_elementList <<
330  21 << 22 << 23 << 24 << 25 << 26 << 27 << 28 << 29 << 30 <<
331  39 << 40 << 41 << 42 << 43 << 44 << 45 << 46 << 47 << 48 <<
332  57 << 72 << 73 << 74 << 75 << 76 << 77 << 78 << 79 << 80 <<
333  89 << 104<< 105<< 106<< 107<< 108<< 109<< 110<< 111<< 112
334  ;
335 }
336 
337 
338 pseDTable *pseDTable::init()
339 {
340  static pseDTable thisTable;
341  return &thisTable;
342 }
343 
345 pseDZTable::pseDZTable()
346 : pseTable()
347 {
348  m_name = "DZ";
349 
350  m_description = i18n( "DZ Periodic Table" );
351 
352  m_xCoordsNumeration <<
353  1 << 2 <<13 <<14 <<15 <<16 <<17 <<18 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12;
354 
355  m_posX <<
356  1<< 2<<
357  1<< 2<<
358  3<< 4<< 5<< 6<< 7<< 8<<
359  1<< 2<<
360  3<< 4<< 5<< 6<< 7<< 8<<
361  1<< 2<<
362  9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
363  3<< 4<< 5<< 6<< 7<< 8<<
364  1<< 2<<
365  9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
366  3 <<4 <<5 <<6 <<7 <<8 <<
367  1<< 2<<
368  19<<20<<21<<22<<23<<24<<25<<26<<27<<28<<29<<30<<31<<32<<
369  9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
370  3 <<4 <<5 <<6 <<7 <<8 <<
371  1<< 2<<
372  19<<20<<21<<22<<23<<24<<25<<26<<27<<28<<29<<30<<31<<32<<
373  9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<
374  3 <<4 <<5 <<6 <<7 <<8
375  ;
376 
377  m_posY <<
378  1<< 1<<
379  2<< 2<<
380  3<< 3<< 3<< 3<< 3<< 3<<
381  4<< 4<<
382  5<< 5<< 5<< 5<< 5<< 5<<
383  6<< 6<<
384  7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<< 7<<
385  8<< 8<< 8<< 8<< 8<< 8<<
386  9<< 9<<
387  10<<10<<10<<10<<10<<10<<10<<10<<10<<10<<
388  11<<11<<11<<11<<11<<11<<
389  12<<12<<
390 
391  13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<13<<
392  14<<14<<14<<14<<14<<14<<14<<14<<14<<14<<
393  15<<15<<15<<15<<15<<15<<
394  16<<16<<
395  17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<17<<
396  18<<18<<18<<18<<18<<18<<18<<18<<18<<18<<
397  19<<19<<19<<19<<19<<19
398  ;
399 
400  // The DZ PS has all Elements
401  if (m_posX.count() == m_posY.count() ) {
402  for (int i = 1; i <= m_posX.count(); i ++) {
403  m_elementList.append(i);
404  }
405  }
406 
407 }
408 
409 pseDZTable *pseDZTable::init()
410 {
411  static pseDZTable thisTable;
412  return &thisTable;
413 }
pseTable::firstElement
virtual int firstElement() const
Returns the first element of the table.
Definition: psetables.cpp:116
pseTables::~pseTables
~pseTables()
Definition: psetables.cpp:37
pseTable::m_xCoordsNumeration
QList< int > m_xCoordsNumeration
Definition: psetables.h:182
pseDTable::init
static pseDTable * init()
Definition: psetables.cpp:338
pseTable::tableSize
virtual QPoint tableSize() const
Returns the maximal size of the periodic table.
Definition: psetables.cpp:140
pseTable::description
virtual QString description() const
Returns a short description of the periodic table in use.
Definition: psetables.cpp:94
pseTable
defines a Periodic Table.
Definition: psetables.h:104
pseTables::instance
static pseTables * instance()
Definition: psetables.cpp:41
pseTable::pseTable
pseTable()
Definition: psetables.cpp:76
pseTable::elementCoords
virtual QPoint elementCoords(int element) const
Returns the coordinates of an element element in the periodic system.
Definition: psetables.cpp:126
pseTable::elements
virtual QList< int > elements() const
Returns a list with all elements in the actual periodic table.
Definition: psetables.cpp:99
pseLongTable::init
static pseLongTable * init()
Definition: psetables.cpp:250
pseRegularTable
Definition: psetables.h:188
pseTables::tables
QStringList tables() const
Returns a list with the names of the table types we support.
Definition: psetables.cpp:47
pseDZTable::init
static pseDZTable * init()
Definition: psetables.cpp:409
pseTable::m_description
QString m_description
Definition: psetables.h:178
pseTables::getTabletype
pseTable * getTabletype(const int tableType)
Returns the KalziumTableType with the id specified.
Definition: psetables.cpp:57
pseTable::init
static pseTable * init()
Definition: psetables.cpp:84
pseTable::m_elementList
QList< int > m_elementList
Definition: psetables.h:183
pseRegularTable::init
static pseRegularTable * init()
Definition: psetables.cpp:205
pseTable::numerationAtPos
virtual int numerationAtPos(int xPos) const
Returns the Numeration for the current Table according to the position in the Table.
Definition: psetables.cpp:154
pseTable::m_posY
QList< int > m_posY
Definition: psetables.h:181
pseTable::previousOf
virtual int previousOf(int element) const
Returns the element that comes right before the specified element.
Definition: psetables.cpp:104
pseTable::name
virtual QString name() const
Returns the ID of this table type.
Definition: psetables.cpp:89
pseDTable
Definition: psetables.h:215
pseShortTable::init
static pseShortTable * init()
Definition: psetables.cpp:298
pseTable::m_posX
QList< int > m_posX
Definition: psetables.h:180
psetables.h
pseTable::m_name
QString m_name
Definition: psetables.h:177
pseDZTable
Definition: psetables.h:224
pseTables
Holds all periodic system tables and make them accessible.
Definition: psetables.h:68
pseLongTable
Definition: psetables.h:197
pseShortTable
Definition: psetables.h:206
pseTable::nextOf
virtual int nextOf(int element) const
Returns the element that comes right after the specified element.
Definition: psetables.cpp:110
pseTable::~pseTable
virtual ~pseTable()
Definition: psetables.cpp:80
pseTable::lastElement
virtual int lastElement() const
Returns the last element of the table.
Definition: psetables.cpp:121
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:31 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalzium/libscience

Skip menu "kalzium/libscience"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal