QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
partplctable.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 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 PARTPLCTABLE_H
19#define PARTPLCTABLE_H
20
23
24#include <QVector>
25
34{
35 Q_OBJECT
36
37 Q_PROPERTY(QRectF rect READ rect WRITE setRect)
38
39 public:
40 PartPlcTable(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
41 ~PartPlcTable() override;
42
43 enum { Type = UserType + 1120 };
44 int type () const override { return Type; }
45 void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
46 QString name () const override { return QObject::tr("table PLC", "element part name"); }
47
48 QString xmlName () const override { return QString("plc_table"); }
49 const QDomElement toXml (QDomDocument &) const override;
50 void fromXml (const QDomElement &) override;
51
52 QRectF rect() const;
53 void setRect(const QRectF &rect);
54
55 QRectF sceneGeometricRect() const override;
56 QPainterPath shape () const override;
57 QPainterPath shadowShape() const override;
58 QRectF boundingRect() const override;
59 bool isUseless() const override;
60
61 void startUserTransformation(const QRectF &) override;
62 void handleUserTransformation(const QRectF &, const QRectF &) override;
63
64 void addHandler() override;
65 void removeHandler() override;
66
67 protected:
68 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
69 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
70 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
71
72 private:
73 void switchResizeMode();
74 void adjustHandlerPos();
75 void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
76 void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
77 void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
78 QSizeF calculateTableSize() const;
79
80 private:
81 QRectF m_rect,
83 QList<QPointF> saved_points_;
86 QVector<QetGraphicsHandlerItem *> m_handler_vector;
87};
88
89#endif // PARTPLCTABLE_H
CustomElementGraphicPart(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
CustomElementGraphicPart::CustomElementGraphicPart Default constructor. By default,...
Definition customelementgraphicpart.cpp:34
PartPlcTable(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
PartPlcTable::PartPlcTable Constructor.
Definition partplctable.cpp:38
void handleUserTransformation(const QRectF &, const QRectF &) override
PartPlcTable::handleUserTransformation.
Definition partplctable.cpp:506
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartPlcTable::sceneEventFilter.
Definition partplctable.cpp:560
QSizeF calculateTableSize() const
PartPlcTable::calculateTableSize Calculate the table size from PLC data in the element scene.
Definition partplctable.cpp:56
void removeHandler() override
PartPlcTable::removeHandler Remove the handlers of this item.
Definition partplctable.cpp:690
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartPlcTable::itemChange.
Definition partplctable.cpp:526
int m_vector_index
Definition partplctable.h:85
QRectF m_rect
Definition partplctable.h:81
void startUserTransformation(const QRectF &) override
PartPlcTable::startUserTransformation.
Definition partplctable.cpp:494
@ Type
Definition partplctable.h:43
QRectF sceneGeometricRect() const override
PartPlcTable::sceneGeometricRect.
Definition partplctable.cpp:430
int m_resize_mode
Definition partplctable.h:84
const QDomElement toXml(QDomDocument &) const override
PartPlcTable::toXml Export this PLC table part in xml.
Definition partplctable.cpp:370
void switchResizeMode()
PartPlcTable::switchResizeMode.
Definition partplctable.cpp:596
QPainterPath shape() const override
PartPlcTable::shape.
Definition partplctable.cpp:439
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
Definition partplctable.cpp:661
QString xmlName() const override
Definition partplctable.h:48
QRectF rect
Definition partplctable.h:37
QString name() const override
Definition partplctable.h:46
QPainterPath shadowShape() const override
Definition partplctable.cpp:454
bool isUseless() const override
PartPlcTable::isUseless.
Definition partplctable.cpp:485
QRectF m_old_rect
Definition partplctable.h:82
QRectF boundingRect() const override
PartPlcTable::boundingRect.
Definition partplctable.cpp:469
void setRect(const QRectF &rect)
PartPlcTable::setRect Sets the item's rectangle to be the given rectangle.
Definition partplctable.cpp:416
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartPlcTable::paint Draw this PLC table.
Definition partplctable.cpp:160
void fromXml(const QDomElement &) override
PartPlcTable::fromXml Import the properties of this PLC table part from a xml element.
Definition partplctable.cpp:388
int type() const override
Definition partplctable.h:44
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartPlcTable::mouseReleaseEvent.
Definition partplctable.cpp:515
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition partplctable.h:86
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
Definition partplctable.cpp:648
QList< QPointF > saved_points_
Definition partplctable.h:83
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
Definition partplctable.cpp:640
~PartPlcTable() override
PartPlcTable::~PartPlcTable.
Definition partplctable.cpp:46
void addHandler() override
PartPlcTable::addHandler Do not add resize handlers - table size is data-driven. Move is handled by t...
Definition partplctable.cpp:681
void adjustHandlerPos()
PartPlcTable::adjustHandlerPos.
Definition partplctable.cpp:619
Definition qetelementeditor.h:39
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37