QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetgraphicsitem.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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 "../qet.h"
22
23#include <QGraphicsObject>
24
25class Diagram;
26
27class QetGraphicsItem : public QGraphicsObject
28{
29 Q_OBJECT
30
31 public:
32 //constructor destructor
33 QetGraphicsItem(QGraphicsItem *parent = nullptr);
34 ~QetGraphicsItem() override = 0;
35
36 //public method
37 Diagram *diagram () const;
38 virtual void setPos (const QPointF &p);
39 virtual void setPos (qreal x, qreal y);
40
41 virtual bool isMovable () const
42{return is_movable_;}
43 virtual void setMovable (bool movable) { is_movable_ = movable;}
44
45 bool isHovered() const;
46
47 virtual void editProperty () {}
48 virtual QString name ()const
49{return QString("");}
50
52
53 //protected method
54 protected:
55 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
56 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
57 void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
58 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
59 void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
60 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
61
62 protected:
68
69 private:
70 bool m_hovered{false};
71
72};
73
74#endif // QETGRAPHICSITEM_H
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
Definition qetgraphicsitem.h:28
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
QetGraphicsItem::mouseReleaseEvent handle mouse release click.
Definition qetgraphicsitem.cpp:155
virtual void setMovable(bool movable)
Definition qetgraphicsitem.h:43
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
Definition qetgraphicsitem.cpp:103
virtual void editProperty()
Definition qetgraphicsitem.h:47
bool snap_to_grid_
Definition qetgraphicsitem.h:65
QET::GraphicsItemState state() const
QetGraphicsItem::state.
Definition qetgraphicsitem.cpp:75
virtual QString name() const
Definition qetgraphicsitem.h:48
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
Definition qetgraphicsitem.cpp:163
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition qetgraphicsitem.cpp:85
QET::GraphicsItemState m_state
Definition qetgraphicsitem.h:67
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Definition qetgraphicsitem.cpp:114
virtual void setPos(const QPointF &p)
Definition qetgraphicsitem.cpp:50
virtual bool isMovable() const
Definition qetgraphicsitem.h:41
bool m_hovered
Definition qetgraphicsitem.h:70
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Definition qetgraphicsitem.cpp:169
bool isHovered() const
Definition qetgraphicsitem.cpp:67
QPointF m_mouse_to_origin_movement
Definition qetgraphicsitem.h:66
~QetGraphicsItem() override=0
Definition qetgraphicsitem.cpp:34
bool m_first_move
Definition qetgraphicsitem.h:64
Diagram * diagram() const
Definition qetgraphicsitem.cpp:41
bool is_movable_
Definition qetgraphicsitem.h:63
GraphicsItemState
Definition qet.h:34
@ GIOK
General state.
Definition qet.h:35