Test change - can I push OK?
[kdeedu-porting.git] / kalzium / src / periodictableview.h
blobde92279c9518084c55cd712956c6d4b0a2cd7615
1 /***************************************************************************
2 * Copyright (C) 2003-2007 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef PeriodicTableView_H
22 #define PeriodicTableView_H
24 class Element;
25 class KalziumPainter;
26 class KalziumGradientType;
28 #include <QTimer>
29 #include <QWidget>
30 #include <QPoint>
31 #include <QPixmap>
32 #include <QMap>
34 #include "kalziumpainter.h"
36 #include <chemicaldataobject.h>
38 /**
39 * A PeriodicTableView is the widget on which we paint a periodic table.
41 * It does not contain any code for painting, as all the painting routines
42 * belongs to KalziumPainter.
44 * @author Carsten Niehaus
45 * @author Pino Toscano
47 class PeriodicTableView : public QWidget
49 Q_OBJECT
51 public:
52 /**
53 * Constructor
54 * @param parent parent widget
56 PeriodicTableView( QWidget *parent = 0 );
57 ~PeriodicTableView();
59 /**
60 * Draw the full table next time
62 void setFullDraw();
64 /**
65 * Sets the numeration type to the one with index @p which.
67 void setNumeration( int which );
69 /**
70 * put the limit for the @p type specified, but do not actually (de)activate it
71 * @param type type of the @p value
72 * @param value the value of the the limit for @p type
74 void setValueLimit( int value, ChemicalDataObject::BlueObelisk type );
76 /**
77 * Generate a SVG from the current table and save it in the file @p filename
79 void generateSvg(const QString& filename);
81 /**
82 * Sets the scheme to use.
83 * @param nr is the index of the new scheme
85 void activateColorScheme( const int nr);
87 /**
88 * @return the KalziumSchemeType of the current view
90 KalziumSchemeType* scheme() const;
92 /**
93 * @return the short and descriptive name of this PeriodicTableView
95 QString shortName() const{
96 return m_ShortName;
99 /**
100 * @return the current gradient type
102 KalziumGradientType* gradient() const;
105 * sets te KalziumGradientType
107 void setGradient( int which );
109 void setMode( KalziumPainter::MODE m );
112 * @return the current KalziumPainter::MODE
114 KalziumPainter::MODE mode() const;
117 * @param type the type of value which is searched for
118 * @return the value of the @p type
120 int sliderValue( ChemicalDataObject::BlueObelisk type );
123 * @return the QBrush for the Element @p element
125 QBrush brushForElement( int element ) const;
127 KalziumTableType* tableType() const;
129 private:
130 QMap <ChemicalDataObject::BlueObelisk, int> m_sliderValueList;
133 * the currently selected element
135 int m_currentElement;
138 * this is a short, descriptive name of the PeriodicTableView
140 QString m_ShortName;
143 * implements double buffering of the widget.
145 QPixmap *table; // The basic PeriodicTableView
146 QPixmap *table2; // Basic PeriodicTableView + extra data such as tooltip, etc
149 * used for bitBlit. If true the complete table will be drawn
151 bool doFullDraw;
153 KalziumPainter *m_painter;
155 QPoint m_startDrag;
158 * Used to delay the emit of MouseOver().
160 QTimer m_hoverTimer;
161 int m_prevHoverElement;
163 protected:
164 virtual void paintEvent( QPaintEvent *e );
165 virtual void mouseReleaseEvent( QMouseEvent* );
166 virtual void mousePressEvent( QMouseEvent* event );
167 virtual void mouseMoveEvent( QMouseEvent* );
169 public slots:
171 * This method sets the color for the buttons corresponding to
172 * the given temperature @p temp
173 * @param temp is the temperature to which all buttons will be set
175 void setTemperature( int temp );
177 void setTime( int time );
179 void slotChangeTable( int table );
182 * this slot removes the selection of any point
184 void unSelect();
186 private slots:
188 * If called this slot will emit the signal MouseOver( num )
189 * where num is the number of the element the mouse if over.
190 * If the mouse is not over an element nothing will be emitted
191 * @see MouseOver()
193 void slotMouseover();
196 * this slot updates the currently selected point
198 void selectPoint( const QPoint& point );
201 * this slot updates the element given in the @p num
202 * @param num The number of the selected element
204 void selectElement( int num );
206 signals:
208 * this signal is emitted when an element is clicked
210 void ElementClicked(int);
213 * This signal is emitted when the mouse pointer is
214 * over an element
216 void MouseOver( int );
218 void ModeChanged( KalziumPainter::MODE );
220 void TableTypeChanged( KalziumTableType * );
222 void GradientTypeChanged( KalziumGradientType * );
224 void SchemeChanged( KalziumSchemeType * );
228 #endif