QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
partrectangle.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 PART_RECTANGLE_H
19#define PART_RECTANGLE_H
20
22
24
31{
32 Q_OBJECT
33
34 Q_PROPERTY(QRectF rect READ rect WRITE setRect)
35 Q_PROPERTY(qreal xRadius READ XRadius WRITE setXRadius NOTIFY XRadiusChanged)
36 Q_PROPERTY(qreal yRadius READ YRadius WRITE setYRadius NOTIFY YRadiusChanged)
37 Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
38
39 // constructors, destructor
40 public:
41 PartRectangle(QETElementEditor *, QGraphicsItem *parent = nullptr);
42 ~PartRectangle() override;
43
44 private:
46
47 signals:
52
53 // methods
54 public:
55 enum { Type = UserType + 1109 };
60 int type () const override { return Type; }
61 void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
62 QString name () const override { return(QObject::tr("rectangle", "element part name")); }
63
64 QString xmlName () const override { return(QString("rect")); }
65 const QDomElement toXml (QDomDocument &) const override;
66 void fromXml (const QDomElement &) override;
67
68 QRectF rect() const;
69 void setRect(const QRectF &rect);
70 qreal XRadius() const {return m_xRadius;}
71 void setXRadius(qreal X);
72 qreal YRadius() const {return m_yRadius;}
73 void setYRadius(qreal Y);
74 void setRotation(qreal angle);
75 qreal rotation() const;
76 void flip(qreal axis_y = 0);
77 void mirror(qreal axis_x = 0);
78
79 QRectF sceneGeometricRect() const override;
80 virtual QPointF sceneTopLeft() const;
81
82 QPainterPath shape () const override;
83 QPainterPath shadowShape() const override;
84 QRectF boundingRect() const override;
85 bool isUseless() const override;
86
87 void startUserTransformation(const QRectF &) override;
88 void handleUserTransformation(const QRectF &, const QRectF &) override;
89
90 void addHandler() override;
91 void removeHandler() override;
92
93 protected:
94 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
95 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
96 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
97
98 private:
99 void switchResizeMode();
100 void adjustHandlerPos();
101 void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
102 void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
103 void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
104
105 private:
106 QRectF m_rect,
108 QList<QPointF> saved_points_;
111 QVector<QetGraphicsHandlerItem *> m_handler_vector;
112 qreal m_xRadius = 0,
117 qreal m_rot;
118};
119#endif
CustomElementGraphicPart(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
CustomElementGraphicPart::CustomElementGraphicPart Default constructor. By default,...
Definition customelementgraphicpart.cpp:34
bool isUseless() const override
PartRectangle::isUseless.
Definition partrectangle.cpp:289
qreal m_old_xRadius
Definition partrectangle.h:114
int m_resize_mode
Definition partrectangle.h:109
void setYRadius(qreal Y)
Definition partrectangle.cpp:155
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
Definition partrectangle.cpp:512
void mirror(qreal axis_x=0)
Definition partrectangle.cpp:204
void flip(qreal axis_y=0)
Definition partrectangle.cpp:190
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition partrectangle.h:111
QPainterPath shadowShape() const override
Definition partrectangle.cpp:256
void removeHandler() override
PartRectangle::removeHandler Remove the handlers of this item.
Definition partrectangle.cpp:571
QString xmlName() const override
Definition partrectangle.h:64
QRectF m_old_rect
Definition partrectangle.h:107
QRectF rect
Definition partrectangle.h:34
void adjustHandlerPos()
PartRectangle::adjustHandlerPos.
Definition partrectangle.cpp:429
void YRadiusChanged()
int m_vector_index
Definition partrectangle.h:110
qreal yRadius
Definition partrectangle.h:36
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartRectangle::handlerMousePressEvent.
Definition partrectangle.cpp:463
void rotationChanged()
void XRadiusChanged()
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartRectangle::paint Draw this Rectangle.
Definition partrectangle.cpp:52
virtual QPointF sceneTopLeft() const
PartRectangle::sceneTopLeft.
Definition partrectangle.cpp:235
const QDomElement toXml(QDomDocument &) const override
PartRectangle::toXml Export this rectangle in xml.
Definition partrectangle.cpp:83
void rectChanged()
qreal xRadius
Definition partrectangle.h:35
QString name() const override
Definition partrectangle.h:62
void setRect(const QRectF &rect)
PartRectangle::setRect Sets the item's rectangle to be the given rectangle.
Definition partrectangle.cpp:138
QPainterPath shape() const override
PartRectangle::shape.
Definition partrectangle.cpp:244
void setRotation(qreal angle)
Definition partrectangle.cpp:163
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartRectangle::itemChange.
Definition partrectangle.cpp:339
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartRectangle::handlerMouseMoveEvent.
Definition partrectangle.cpp:481
PartRectangle(QETElementEditor *, QGraphicsItem *parent=nullptr)
PartRectangle::PartRectangle Constructor.
Definition partrectangle.cpp:31
qreal XRadius() const
Definition partrectangle.h:70
void addHandler() override
PartRectangle::addHandler Add handlers for this item.
Definition partrectangle.cpp:541
void startUserTransformation(const QRectF &) override
PartRectangle::startUserTransformation Start the user-induced transformation, provided this primitive...
Definition partrectangle.cpp:300
qreal YRadius() const
Definition partrectangle.h:72
QRectF boundingRect() const override
PartRectangle::boundingRect.
Definition partrectangle.cpp:271
int type() const override
Definition partrectangle.h:60
QList< QPointF > saved_points_
Definition partrectangle.h:108
qreal m_rot
Definition partrectangle.h:117
QRectF sceneGeometricRect() const override
PartRectangle::sceneGeometricRect.
Definition partrectangle.cpp:226
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartRectangle::mouseReleaseEvent Handle mouse release event.
Definition partrectangle.cpp:325
qreal m_old_yRadius
Definition partrectangle.h:115
qreal rotation
Definition partrectangle.h:37
void handleUserTransformation(const QRectF &, const QRectF &) override
PartRectangle::handleUserTransformation Handle the user-induced transformation from initial_selection...
Definition partrectangle.cpp:314
void switchResizeMode()
PartRectangle::switchResizeMode.
Definition partrectangle.cpp:396
qreal m_yRadius
Definition partrectangle.h:113
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartRectangle::sceneEventFilter.
Definition partrectangle.cpp:359
void fromXml(const QDomElement &) override
PartRectangle::fromXml Import the properties of this rectangle from a xml element.
Definition partrectangle.cpp:110
qreal m_xRadius
Definition partrectangle.h:112
void setXRadius(qreal X)
Definition partrectangle.cpp:147
bool m_modifie_radius_equaly
Definition partrectangle.h:116
@ Type
Definition partrectangle.h:55
QRectF m_rect
Definition partrectangle.h:106
Definition qetelementeditor.h:39
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37