Test change - can I push OK?
[kdeedu-porting.git] / kalzium / src / kalziumpainter.h
blob364d0ad160763ac0a80f6c8e595130b412b6370c
1 /***************************************************************************
2 * Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef KALZIUMPAINTER_H
21 #define KALZIUMPAINTER_H
23 #include <QByteArray>
24 #include <QRect>
26 #include <chemicaldataobject.h>
28 class QPaintDevice;
29 class QPainter;
30 class KalziumGradientType;
31 class KalziumTableType;
32 class KalziumSchemeType;
33 class KalziumNumerationType;
35 /**
36 * The KalziumPainter is /the/ way to draw a table, any kind of it.
38 * One of the best features of it is that you can construct it once and do
39 * multiple drawing session without destroying it.
41 * A typical usage would be:
42 * @code
43 * // build the classic periodic table
44 * KalziumTableType *table = KalziumTableTypeFactory::instance()->build( "Classic" );
45 * // creating the painter with the table type
46 * KalziumPainter painter = new KalziumPainter( table );
47 * // setting the various options
48 * ...
49 * painter->begin( widget/pixmap/paintdevice );
50 * painter->drawAll();
51 * // draw the element selector for the element with atomic number 20 (Calcium)
52 * painter->drawElementSelector( 20 );
53 * painter->end();
54 * @endcode
56 * @author Pino Toscano
58 class KalziumPainter
60 public:
61 /**
62 * Construct a new KalziumPainter for the table type @p ktt.
64 KalziumPainter( KalziumTableType *ktt );
65 virtual ~KalziumPainter() {}
67 void setTableType( KalziumTableType* ktt ){
68 m_ktt = ktt;
71 enum MODE
73 NORMAL = 0,
74 SOM /**< State of matter*/,
75 TIME/** Timeline*/,
76 GRADIENT
79 /**
80 * Begin painting on the painting device @p pd.
82 void begin( QPaintDevice *pd );
83 /**
84 * Finish painting.
86 void end();
88 KalziumTableType* currentTableType() const;
90 /**
91 * Draw all the things it can: elements and numeration
93 void drawAll();
95 /**
96 * Draw all the elements
98 void drawElements();
101 * Draw the element with atomic number @p element.
102 * Pass a QRect() to the @p r parameter if you want to use the
103 * default rect for that element.
105 void drawElement( int element, const QRect& r = QRect() );
108 * Draw the numeration
110 void drawNumeration();
113 * Paint a marker around the element number @p element
115 void drawElementSelector( int element );
117 void setMode( MODE m );
120 * @return Return the current MODE
122 MODE mode() const{
123 return m_mode;
126 void setScheme( int s );
127 void setScheme( const QByteArray& s );
128 KalziumSchemeType* scheme() const;
130 void setGradient( int cs );
131 void setGradient( const QByteArray& cs );
132 KalziumGradientType* gradient() const;
135 * Set the numeration @p n for the periodic table
137 void setNumeration( int n );
138 void setNumeration( const QByteArray& n );
140 KalziumNumerationType* numeration() const{
141 return m_numeration;
144 void setTemperature( int temp );
146 int temperature() const{
147 return m_temperature;
150 void setTime( int time ){
151 m_time = time;
154 int time() const{
155 return m_time;
158 QBrush brushForElement( int element ) const;
160 private:
161 QPainter *m_painter;
163 KalziumTableType *m_ktt;
165 MODE m_mode;
167 KalziumSchemeType *m_scheme;
168 KalziumGradientType *m_gradient;
170 * the type of the numeration
172 KalziumNumerationType *m_numeration;
174 ///for the state-of-matter
175 int m_temperature;
177 ///for the timeline
178 int m_time;
181 #endif // KALZIUMPAINTER_H