moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kalzium / src / pse.h
blob1c35ddddc7d8509970ae8f565263d93461949439
1 /***************************************************************************
2 * Copyright (C) 2003 by Carsten Niehaus *
3 * cniehaus@kde.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef PSE_H
21 #define PSE_H
23 class QLabel;
24 class QPixmap;
25 class QPoint;
26 class QVBoxLayout;
28 #include <qvaluelist.h>
29 #include <qwidget.h>
30 #include <qdialog.h>
31 #include <qtimer.h>
33 #include "element.h"
34 #include "informationdialog_impl.h"
36 /**
37 * @short basic class for the specific PSEs
38 * @author Carsten Niehaus
40 class PSE : public QWidget
42 Q_OBJECT
44 public:
45 /**
46 * Constructor
47 * @param data is the object in which all data is stored
49 PSE( KalziumDataObject *data, QWidget *parent = 0, const char *name = 0);
50 ~PSE();
52 enum NUMERATIONTYPE
54 NO=0, //no numeration
55 CAS = 1, //Chemical Abstract Service
56 IUPAC = 2, //Intern. Union of Pure and Applied Chemistry
57 IUPACOLD = 3 //old IUPAC numeration
60 /**
61 * if this mode is activated a click on a button will not open
62 * a informationdialog
64 virtual void activateMolcalcmode( bool mode ){
65 m_molcalcIsActive = mode;
68 /**
69 * @return if the the learningmode is active or not
71 virtual bool learningMode() const{
72 return m_learningMode;
75 /**
76 * @return if the the molcalc-Modus is active or not
78 virtual bool molcalcMode() const{
79 return m_molcalcIsActive;
82 /**
83 * sets the NUMERATIONTYPE @p num of the periodic table
85 void setNumerationType( int num ){
86 m_num = num;
87 updateNumeration();
90 /**
91 * This method sets the colors of the PSE.
92 @param nr takes 5 different values:
93 @li normal view
94 @li groups
95 @li blocks
96 @li state-of-matter
97 @li acidic behavior
98 @li family view
100 void activateColorScheme( const int nr);
103 * @return the short and descriptive name of this PSE
105 QString shortName() const{
106 return m_ShortName;
110 * This method sets the color for the buttons corresponding to
111 * the given temperature @p temp
112 * @param temp is the temperature to which all buttons will be set
114 void setTemperature( const double temp ){
115 m_temperature = temp;
119 * @para simple if true the table will only show the p and s block
121 void setPSEType( bool simple ){
122 m_isSimple = simple;
126 * returns if the SOM is active or not
128 bool som() const{
129 return m_showSOM;
132 void activateSOMMode( bool som ){
133 m_showSOM = som;
137 * if true the tooltips will be displayed
139 bool m_showTooltip;
142 * This list includes all elementbuttons which are in the
143 * specific PSE. For example. in the simple PSE
144 * the elements of the f- and d-Block would not
145 * be in this list
147 QPtrList<Element> m_PSEElements;
150 * activates or deactivates the legend
152 void showLegend( bool show ){
153 m_showLegend = show;
156 bool showLegend() const{
157 return m_showLegend;
161 * activates or deactivates the learningmode
163 void setLearning( bool learningmode ){
164 m_learningMode = learningmode;
167 bool timeline() const{
168 return m_timeline;
171 void setTimeline( bool timeline ){
172 m_timeline = timeline;
175 int date() const{
176 return m_date;
180 private:
181 ///the date used in the timeline
182 int m_date;
184 bool m_timeline;
186 ///the temperature of the table (for the SOM-feature)
187 double m_temperature;
189 ///if true the State Of Matter will be shown
190 bool m_showSOM;
192 ///Timer used for the tooltop
193 QTimer HoverTimer;
195 KalziumDataObject *d;
197 ///if true the periodic table is in the leraningmode
198 bool m_learningMode;
200 ///the number of the element the mouse-cursor is over
201 int m_tooltipElementNumber;
204 * @return the number of the element at position x/y. If there
205 * is no element it will return 0
207 int ElementNumber( int x, int y );
210 * updates the numeration of the PSE
212 virtual void updateNumeration();
214 ///the currently selected element (the x/y-coordinates)
215 QPoint m_currentPoint;
217 void mouseReleaseEvent( QMouseEvent* );
219 void mouseMoveEvent( QMouseEvent* );
221 ///if true the user looks at periods
222 bool m_Vertikal;
224 QStringList m_IUPAClist;
225 QStringList m_IUPACOLDlist;
227 ///if the the legend will be displayed
228 bool m_showLegend;
231 * this is a short, descriptive name of the PSE
233 QString m_ShortName;
235 ///if true the pse is drawn in simple mode (s+p block only)
236 bool m_isSimple;
238 ///true if the molcalc-mode is active
239 bool m_molcalcIsActive;
242 * the type of the nummeration ( NO, CAS, IUPACOLD, IUPAC )
244 int m_num;
246 ///the internal representation of the table
247 QPixmap *table;
249 ///used for bitBlit. If true the complete table will be drawn
250 bool doFullDraw;
253 protected:
254 virtual void paintEvent( QPaintEvent *e );
256 ///in this method the tooltops are drawn.
257 virtual void drawToolTip( QPainter *p, Element *e );
259 ///called if the user resized the table
260 virtual void resizeEvent( QResizeEvent *e );
262 ///the central place for the drawing of the table
263 virtual void drawPSE( QPainter* p, bool useSimpleView );
265 ///draw the state of matter
266 virtual void drawSOMPSE( QPainter* p );
268 ///draw the lengend
269 virtual void drawLegend( QPainter* p );
271 public slots:
272 void setDate( int date ){
273 m_date = date;
274 //These elements have always been known:
275 //6 16 26 29 33 47 50 51 79 80 82 83
278 void setLearningMode( int horizontal ){
279 if ( horizontal == 1 )
280 m_Vertikal = false;
281 else
282 m_Vertikal = true;
286 * start the calculation of the element over which the mouse-cursor
287 * is over. Finally the siganl ToolTip( int ) is emitted
289 void slotTransientLabel();
292 * this slot updates the currently selected point
294 void slotUpdatePoint( QPoint point );
297 * sets the current element to @p number, activates
298 * the tooltipmode and updates the table
300 void slotToolTip( int number );
302 signals:
304 * this signal is emited when the table is clicked
306 void tableClicked(QPoint);
309 * this signal is emited when an element is clicked
311 void ElementClicked(int);
314 * this signal is emited when the tooltip of an element
315 * has to be displayed
317 void ToolTip(int);
322 #endif