QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
partarc.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_ARC_H
19#define PART_ARC_H
20
21#include "abstractpartellipse.h"
22
25
32{
33 Q_OBJECT
34
35 public:
36 PartArc(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
37 ~PartArc() override;
38
39 private:
40 PartArc(const PartArc &);
41 // methods
42 public:
43 enum { Type = UserType + 1101 };
48 int type() const override { return Type; }
49 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
50
51 //Name and XML
52 QString name() const override { return(QObject::tr("arc", "element part name")); }
53 QString xmlName() const override { return(QString("arc")); }
54 const QDomElement toXml (QDomDocument &) const override;
55 void fromXml (const QDomElement &) override;
56
57 QPainterPath shape() const override;
58 QPainterPath shadowShape() const override;
60 void setStartAngle(const int &start_angle) override {AbstractPartEllipse::setStartAngle(start_angle); adjusteHandlerPos();}
61 void setSpanAngle(const int &span_angle) override {AbstractPartEllipse::setSpanAngle(span_angle); adjusteHandlerPos();}
62 QRectF sceneGeometricRect() const 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 adjusteHandlerPos();
75 void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
76 void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
77 void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
78
79 private:
84 QPointF m_span_point;
85 QVector<QetGraphicsHandlerItem *> m_handler_vector;
86};
87#endif
The AbstractPartEllipse class This is the base class for all ellipse based item like ellipse,...
Definition abstractpartellipse.h:40
QRectF rect
Definition abstractpartellipse.h:44
virtual void setSpanAngle(const int &span_angle)
AbstractPartEllipse::setSpanAngle Returns the span angle of an ellipse segment in 16ths of a degree....
Definition abstractpartellipse.cpp:167
virtual void setRect(const QRectF &rect)
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
Definition abstractpartellipse.cpp:122
virtual void setStartAngle(const int &start_angle)
AbstractPartEllipse::setStartAngle Sets the start angle for an ellipse segment to angle,...
Definition abstractpartellipse.cpp:151
The PartArc class This class represents an elliptical arc primitive which may be used to compose the ...
Definition partarc.h:32
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMouseMoveEvent.
Definition partarc.cpp:355
QPointF m_span_point
Definition partarc.h:84
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
PartArc::mouseReleaseEvent Handle mouse release event.
Definition partarc.cpp:184
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartArc::sceneEventFilter.
Definition partarc.cpp:218
QString xmlName() const override
Definition partarc.h:53
void adjusteHandlerPos()
PartArc::adjusteHandlerPos.
Definition partarc.cpp:290
void addHandler() override
PartArc::addHandler Add handlers for this item.
Definition partarc.cpp:429
QPropertyUndoCommand * m_undo_command
Definition partarc.h:80
void switchResizeMode()
PartArc::switchResizeMode.
Definition partarc.cpp:255
void fromXml(const QDomElement &) override
PartArc::fromXml Import the properties of this arc from a xml element.
Definition partarc.cpp:125
int m_resize_mode
Definition partarc.h:82
void setSpanAngle(const int &span_angle) override
AbstractPartEllipse::setSpanAngle Returns the span angle of an ellipse segment in 16ths of a degree....
Definition partarc.h:61
@ Type
Definition partarc.h:43
void setRect(const QRectF &rect) override
AbstractPartEllipse::setRect Sets the item's ellipse geometry to rect. The rectangle's left edge defi...
Definition partarc.h:59
~PartArc() override
PartArc::~PartArc Destructor.
Definition partarc.cpp:42
void setStartAngle(const int &start_angle) override
AbstractPartEllipse::setStartAngle Sets the start angle for an ellipse segment to angle,...
Definition partarc.h:60
void removeHandler() override
PartArc::removeHandler Remove the handlers of this item.
Definition partarc.cpp:460
int type() const override
Definition partarc.h:48
QString name() const override
Definition partarc.h:52
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition partarc.h:85
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartArc::paint Draw this arc.
Definition partarc.cpp:55
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMousePressEvent.
Definition partarc.cpp:316
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartArc::handlerMouseReleaseEvent.
Definition partarc.cpp:389
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartArc::itemChange.
Definition partarc.cpp:198
QPropertyUndoCommand * m_undo_command2
Definition partarc.h:81
PartArc(const PartArc &)
QRectF sceneGeometricRect() const override
PartArc::sceneGeometricRect.
Definition partarc.cpp:174
int m_vector_index
Definition partarc.h:83
const QDomElement toXml(QDomDocument &) const override
PartArc::toXml Export this arc in xml.
Definition partarc.cpp:105
QPainterPath shape() const override
PartArc::shape.
Definition partarc.cpp:140
QPainterPath shadowShape() const override
Definition partarc.cpp:153
Definition qetelementeditor.h:39
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
Definition qpropertyundocommand.h:34
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37