QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
partline.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_LINE_H
19#define PART_LINE_H
20
21#include "../../qet.h"
23
26
37{
38 Q_OBJECT
39
41 Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
42 Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
43 Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
44 Q_PROPERTY(QLineF line READ line WRITE setLine)
45
46 // constructors, destructor
47 public:
48 PartLine(QETElementEditor *, QGraphicsItem * = nullptr);
49 ~PartLine() override;
50 private:
52
53 signals:
59
60
61 // methods
62 public:
63 enum { Type = UserType + 1104 };
64
69 int type() const override { return Type; }
70 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
71 QString name() const override { return(QObject::tr("ligne", "element part name")); }
72 QString xmlName() const override { return(QString("line")); }
73 const QDomElement toXml(QDomDocument &) const override;
74 void fromXml(const QDomElement &) override;
75 virtual QPointF sceneP1() const;
76 virtual QPointF sceneP2() const;
77 QPainterPath shape() const override;
78 QPainterPath shadowShape() const override;
79 QRectF boundingRect() const override;
80 bool isUseless() const override;
81 QRectF sceneGeometricRect() const override;
82 void startUserTransformation(const QRectF &) override;
83 void handleUserTransformation(const QRectF &, const QRectF &) override;
84 static uint requiredLengthForEndType(const Qet::EndType &);
85 static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
86
87 QLineF line() const;
88 void setLine(const QLineF &line);
90 void setFirstEndType(const Qet::EndType &et);
92 void setSecondEndType(const Qet::EndType &et);
93 qreal firstEndLength() const {return first_length;}
94 void setFirstEndLength(const qreal &l);
95 qreal secondEndLength() const {return second_length;}
96 void setSecondEndLength(const qreal &l);
97 void setRotation(qreal angle);
98 qreal rotation() const;
99
100 void addHandler() override;
101 void removeHandler() override;
102
103 protected:
104 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
105 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
106
107 private:
108 void adjusteHandlerPos();
109 void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
110 void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
111 void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
112
113 QPainterPath path() const;
114 QRectF firstEndCircleRect() const;
115 QRectF secondEndCircleRect() const;
116
117 /*****************/
120
123 QList<QPointF> saved_points_;
124 QLineF m_line;
127 QVector<QetGraphicsHandlerItem *> m_handler_vector;
128 qreal m_rot;
129};
130#endif
The CustomElementGraphicPart class This class is the base for all home-made primitive like line,...
Definition customelementgraphicpart.h:36
Definition partline.h:37
QLineF m_line
Definition partline.h:124
void secondEndTypeChanged()
void setFirstEndLength(const qreal &l)
Definition partline.cpp:556
qreal second_length
Definition partline.h:122
qreal first_length
Definition partline.h:119
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
PartLine::paint Draw this line.
Definition partline.cpp:74
void addHandler() override
PartLine::addHandler Add handlers for this item.
Definition partline.cpp:291
Qet::EndType first_end
Definition partline.h:118
void firstEndTypeChanged()
int m_vector_index
Definition partline.h:125
Qet::EndType end2
Definition partline.h:41
qreal m_rot
Definition partline.h:128
virtual QPointF sceneP1() const
PartLine::sceneP1.
Definition partline.cpp:327
QRectF secondEndCircleRect() const
PartLine::secondEndCircleRect.
Definition partline.cpp:408
QString xmlName() const override
Definition partline.h:72
Qet::EndType secondEndType() const
Definition partline.h:91
static uint requiredLengthForEndType(const Qet::EndType &)
PartLine::requiredLengthForEndType.
Definition partline.cpp:55
virtual QPointF sceneP2() const
PartLine::sceneP2.
Definition partline.cpp:336
void fromXml(const QDomElement &) override
PartLine::fromXml Import the properties of this line from a xml element.
Definition partline.cpp:137
QPainterPath shadowShape() const override
Definition partline.cpp:366
void lineChanged()
void firstEndLengthChanged()
QLineF line
Definition partline.h:44
QRectF boundingRect() const override
PartLine::boundingRect.
Definition partline.cpp:426
@ Type
Definition partline.h:63
QString name() const override
Definition partline.h:71
void handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartLine::handlerMousePressEvent.
Definition partline.cpp:235
QPainterPath path() const
PartLine::path.
Definition partline.cpp:594
void setFirstEndType(const Qet::EndType &et)
Definition partline.cpp:540
qreal length1
Definition partline.h:42
Qet::EndType second_end
Definition partline.h:121
void handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartLine::handlerMouseReleaseEvent.
Definition partline.cpp:276
void handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
PartLine::handlerMouseMoveEvent.
Definition partline.cpp:251
void setLine(const QLineF &line)
Definition partline.cpp:531
qreal length2
Definition partline.h:43
static QList< QPointF > fourEndPoints(const QPointF &, const QPointF &, const qreal &)
PartLine::fourEndPoints Return the four interesting point needed to draw the shape at extremity of li...
Definition partline.cpp:507
const QDomElement toXml(QDomDocument &) const override
PartLine::toXml Export this line in xml.
Definition partline.cpp:113
QPropertyUndoCommand * m_undo_command
Definition partline.h:126
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
PartLine::itemChange.
Definition partline.cpp:156
QPainterPath shape() const override
PartLine::shape.
Definition partline.cpp:345
qreal rotation() const
Definition partline.cpp:582
void setSecondEndType(const Qet::EndType &et)
Definition partline.cpp:548
qreal firstEndLength() const
Definition partline.h:93
void secondEndLengthChanged()
bool isUseless() const override
PartLine::isUseless.
Definition partline.cpp:450
void setSecondEndLength(const qreal &l)
Definition partline.cpp:565
QList< QPointF > saved_points_
Definition partline.h:123
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
PartLine::sceneEventFilter.
Definition partline.cpp:176
QRectF firstEndCircleRect() const
PartLine::firstEndCircleRect.
Definition partline.cpp:390
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition partline.h:127
Qet::EndType end1
Definition partline.h:40
void handleUserTransformation(const QRectF &, const QRectF &) override
PartLine::handleUserTransformation Handle the user-induced transformation from initial_selection_rect...
Definition partline.cpp:486
void adjusteHandlerPos()
PartLine::adjusteHandlerPos Adjust the position of the handler item.
Definition partline.cpp:214
QRectF sceneGeometricRect() const override
PartLine::sceneGeometricRect.
Definition partline.cpp:462
int type() const override
Definition partline.h:69
void startUserTransformation(const QRectF &) override
PartLine::startUserTransformation Start the user-induced transformation, provided this primitive is c...
Definition partline.cpp:473
Qet::EndType firstEndType() const
Definition partline.h:89
void setRotation(qreal angle)
Definition partline.cpp:574
void removeHandler() override
PartLine::removeHandler Remove the handlers of this item.
Definition partline.cpp:314
qreal secondEndLength() const
Definition partline.h:95
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
Definition qet.h:192
EndType
This enum lists the various available endings for line primitives when drawing an electrical element.
Definition qet.h:197