QElectroTech  0.8-dev
qetgraphicsitem.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech 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  QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef QETGRAPHICSITEM_H
19 #define QETGRAPHICSITEM_H
20 
21 #include <QGraphicsObject>
22 #include "qet.h"
23 
24 class Diagram;
25 
26 class QetGraphicsItem : public QGraphicsObject
27 {
28  Q_OBJECT
29 
30  public:
31  //constructor destructor
32  QetGraphicsItem(QGraphicsItem *parent = nullptr);
33  ~QetGraphicsItem() override = 0;
34 
35  //public methode
36  Diagram *diagram () const;
37  virtual void setPos (const QPointF &p);
38  virtual void setPos (qreal x, qreal y);
39 
40  virtual bool isMovable () const {return is_movable_;}
41  virtual void setMovable (bool movable) { is_movable_ = movable;}
42 
43  virtual void editProperty () {}
44  virtual QString name ()const {return QString("");}
45 
47 
48  //protected method
49  protected:
50  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
51  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
52  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
53  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
54 
55  protected:
61 
62 };
63 
64 #endif // QETGRAPHICSITEM_H
ElementsMover::beginMovement
int beginMovement(Diagram *, QGraphicsItem *=nullptr)
ElementsMover::beginMovement Start a new movement.
Definition: elementsmover.cpp:65
QetGraphicsItem
Definition: qetgraphicsitem.h:27
qetgraphicsitem.h
QetGraphicsItem::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
QetGraphicsItem::mouseReleaseEvent handle mouse release click.
Definition: qetgraphicsitem.cpp:149
QetGraphicsItem::diagram
Diagram * diagram() const
Definition: qetgraphicsitem.cpp:40
QET::GraphicsItemState
GraphicsItemState
Definition: qet.h:38
QetGraphicsItem::setMovable
virtual void setMovable(bool movable)
Definition: qetgraphicsitem.h:41
QetGraphicsItem::name
virtual QString name() const
Definition: qetgraphicsitem.h:44
ElementsMover::endMovement
void endMovement()
ElementsMover::endMovement Ended the current movement by creating an undo added to the undostack of t...
Definition: elementsmover.cpp:150
QetGraphicsItem::~QetGraphicsItem
~QetGraphicsItem() override=0
Definition: qetgraphicsitem.cpp:33
ElementsMover::continueMovement
void continueMovement(const QPointF &)
ElementsMover::continueMovement Add a move to the current movement.
Definition: elementsmover.cpp:112
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
qet.h
QET::GIOK
@ GIOK
General state.
Definition: qet.h:39
QetGraphicsItem::is_movable_
bool is_movable_
Definition: qetgraphicsitem.h:56
QetGraphicsItem::QetGraphicsItem
QetGraphicsItem(QGraphicsItem *parent=nullptr)
QetGraphicsItem::QetGraphicsItem Default constructor.
Definition: qetgraphicsitem.cpp:26
QetGraphicsItem::m_state
QET::GraphicsItemState m_state
Definition: qetgraphicsitem.h:60
QetGraphicsItem::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition: qetgraphicsitem.cpp:79
QetGraphicsItem::editProperty
virtual void editProperty()
Definition: qetgraphicsitem.h:43
QetGraphicsItem::m_first_move
bool m_first_move
Definition: qetgraphicsitem.h:57
QetGraphicsItem::mouseMoveEvent
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Definition: qetgraphicsitem.cpp:108
Diagram::elementsMover
ElementsMover & elementsMover()
Diagram::elementsMover.
Definition: diagram.cpp:2057
Diagram::snapToGrid
static QPointF snapToGrid(const QPointF &p)
Diagram::snapToGrid Return a nearest snap point of p.
Definition: diagram.cpp:2240
QetGraphicsItem::m_mouse_to_origin_movement
QPointF m_mouse_to_origin_movement
Definition: qetgraphicsitem.h:59
QetGraphicsItem::setPos
virtual void setPos(const QPointF &p)
Definition: qetgraphicsitem.cpp:49
QetGraphicsItem::snap_to_grid_
bool snap_to_grid_
Definition: qetgraphicsitem.h:58
QetGraphicsItem::mouseDoubleClickEvent
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition: qetgraphicsitem.cpp:97
QetGraphicsItem::isMovable
virtual bool isMovable() const
Definition: qetgraphicsitem.h:40
QetGraphicsItem::state
QET::GraphicsItemState state() const
QetGraphicsItem::state.
Definition: qetgraphicsitem.cpp:70
diagram.h