1
/**********************************************************************
2
ElementItem - Element Item, part of the Periodic Table Graphics View for
5
Copyright (C) 2007-2009 by Marcus D. Hanwell
6
Copyright (C) 2010 by Etienne Rebetez
8
This file is part of the Avogadro molecular editor project.
9
For more information, see <http://avogadro.openmolecules.net/>
11
Kalzium is free software; you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as published by
13
the Free Software Foundation; either version 2.1 of the License, or
14
(at your option) any later version.
16
Kalzium is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
**********************************************************************/
27
#ifndef ELEMENTITEM_P_H
28
#define ELEMENTITEM_P_H
30
#include <QGraphicsItem>
31
#include "kalziumdataobject.h"
32
#include "kalziumelementproperty.h"
34
#include <chemicaldataobject.h>
38
* @author Marcus D. Hanwell, Etienne Rebetez
39
* @brief An element item, intended to display a single element.
41
* This class implements a QGraphicsItem for displaying single elements in a
42
* perdiodic table. It currently allows the setting of the proton number.
43
* All other information come frome the kalziumElementProperty class.
45
class ElementItem : public QGraphicsObject
51
* Constructor. Should be called with the element number for this item. The
52
* constructor uses setData to set the element number using the key 0. This
53
* is then used by PeriodicTable to figure out which element was clicked on.
55
ElementItem(KalziumElementProperty *property, int elementNumber = 0);
63
* @return the bounding rectangle of the element item.
65
QRectF boundingRect() const;
68
* @return the painter path which is also a rectangle in this case.
70
QPainterPath shape() const;
73
* This is where most of the action takes place. The element box is drawn
74
* along with its symbol.
76
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
83
QString getCurrentElementValue();
86
* Width and height of the elements.
88
int m_width, m_height;
90
* The proton number of the item - all other attributes are derived from this.
95
* The element numbers symbol.
100
* The color of the element which will also be used as the background color
107
QColor m_borderColor;
111
KalziumElementProperty *m_property;
114
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
115
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
119
#endif // ELEMENTITEM_P_H