QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
partrectangle.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 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
77 QRectF sceneGeometricRect() const override;
78 virtual QPointF sceneTopLeft() const;
79
80 QPainterPath shape () const override;
81 QPainterPath shadowShape() const override;
82 QRectF boundingRect() const override;
83 bool isUseless() const override;
84
85 void startUserTransformation(const QRectF &) override;
86 void handleUserTransformation(const QRectF &, const QRectF &) override;
87
88 void addHandler() override;
89 void removeHandler() override;
90
91 protected:
92 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
93 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
94 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
95
96 private:
97 void switchResizeMode();
98 void adjusteHandlerPos();
99 void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
100 void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
101 void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
102
103 private:
104 QRectF m_rect,
106 QList<QPointF> saved_points_;
109 QVector<QetGraphicsHandlerItem *> m_handler_vector;
110 qreal m_xRadius = 0,
115 qreal m_rot;
116};
117#endif
The CustomElementGraphicPart class This class is the base for all home-made primitive like line,...
Definition customelementgraphicpart.h:36
Definition partrectangle.h:31
bool isUseless() const override
PartRectangle::isUseless.
Definition partrectangle.cpp:256
qreal m_old_xRadius
Definition partrectangle.h:112
int m_resize_mode
Definition partrectangle.h:107
void setYRadius(qreal Y)
Definition partrectangle.cpp:166
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
Definition partrectangle.cpp:479
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition partrectangle.h:109
QPainterPath shadowShape() const override
Definition partrectangle.cpp:223
void removeHandler() override
PartRectangle::removeHandler Remove the handlers of this item.
Definition partrectangle.cpp:538
QString xmlName() const override
Definition partrectangle.h:64
QRectF m_old_rect
Definition partrectangle.h:105
QRectF rect
Definition partrectangle.h:34
void YRadiusChanged()
int m_vector_index
Definition partrectangle.h:108
qreal yRadius
Definition partrectangle.h:36
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartRectangle::handlerMousePressEvent.
Definition partrectangle.cpp:430
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:202
const QDomElement toXml(QDomDocument &) const override
PartRectangle::toXml Export this rectangle in xml.
Definition partrectangle.cpp:90
void rectChanged()
qreal xRadius
Definition partrectangle.h:35
void adjusteHandlerPos()
PartRectangle::adjusteHandlerPos.
Definition partrectangle.cpp:396
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:149
QPainterPath shape() const override
PartRectangle::shape.
Definition partrectangle.cpp:211
void setRotation(qreal angle)
Definition partrectangle.cpp:174
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartRectangle::itemChange.
Definition partrectangle.cpp:306
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartRectangle::handlerMouseMoveEvent.
Definition partrectangle.cpp:448
qreal XRadius() const
Definition partrectangle.h:70
void addHandler() override
PartRectangle::addHandler Add handlers for this item.
Definition partrectangle.cpp:508
void startUserTransformation(const QRectF &) override
PartRectangle::startUserTransformation Start the user-induced transformation, provided this primitive...
Definition partrectangle.cpp:267
qreal YRadius() const
Definition partrectangle.h:72
QRectF boundingRect() const override
PartRectangle::boundingRect.
Definition partrectangle.cpp:238
@ Type
Definition partrectangle.h:55
int type() const override
Definition partrectangle.h:60
QList< QPointF > saved_points_
Definition partrectangle.h:106
qreal m_rot
Definition partrectangle.h:115
QRectF sceneGeometricRect() const override
PartRectangle::sceneGeometricRect.
Definition partrectangle.cpp:193
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartRectangle::mouseReleaseEvent Handle mouse release event.
Definition partrectangle.cpp:292
qreal m_old_yRadius
Definition partrectangle.h:113
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:281
void switchResizeMode()
PartRectangle::switchResizeMode.
Definition partrectangle.cpp:363
qreal m_yRadius
Definition partrectangle.h:111
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartRectangle::sceneEventFilter.
Definition partrectangle.cpp:326
void fromXml(const QDomElement &) override
PartRectangle::fromXml Import the properties of this rectangle from a xml element.
Definition partrectangle.cpp:121
qreal m_xRadius
Definition partrectangle.h:110
void setXRadius(qreal X)
Definition partrectangle.cpp:158
bool m_modifie_radius_equaly
Definition partrectangle.h:114
QRectF m_rect
Definition partrectangle.h:104
Definition qetelementeditor.h:39
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37