1 /***************************************************************************
2 * Copyright (C) 2003-2007 by Carsten Niehaus *
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. *
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. *
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
26 class KalziumGradientType
;
34 #include "kalziumpainter.h"
36 #include <chemicaldataobject.h>
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
54 * @param parent parent widget
56 PeriodicTableView( QWidget
*parent
= 0 );
60 * Draw the full table next time
65 * Sets the numeration type to the one with index @p which.
67 void setNumeration( int which
);
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
);
77 * Generate a SVG from the current table and save it in the file @p filename
79 void generateSvg(const QString
& filename
);
82 * Sets the scheme to use.
83 * @param nr is the index of the new scheme
85 void activateColorScheme( const int nr
);
88 * @return the KalziumSchemeType of the current view
90 KalziumSchemeType
* scheme() const;
93 * @return the short and descriptive name of this PeriodicTableView
95 QString
shortName() const{
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;
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
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
153 KalziumPainter
*m_painter
;
158 * Used to delay the emit of MouseOver().
161 int m_prevHoverElement
;
164 virtual void paintEvent( QPaintEvent
*e
);
165 virtual void mouseReleaseEvent( QMouseEvent
* );
166 virtual void mousePressEvent( QMouseEvent
* event
);
167 virtual void mouseMoveEvent( QMouseEvent
* );
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
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
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
);
208 * this signal is emitted when an element is clicked
210 void ElementClicked(int);
213 * This signal is emitted when the mouse pointer is
216 void MouseOver( int );
218 void ModeChanged( KalziumPainter::MODE
);
220 void TableTypeChanged( KalziumTableType
* );
222 void GradientTypeChanged( KalziumGradientType
* );
224 void SchemeChanged( KalziumSchemeType
* );