QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
partterminal.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_TERMINAL_H
19#define PART_TERMINAL_H
20
23
24#include <QUuid>
25
31{
32 Q_OBJECT
33
35 Q_PROPERTY(QString terminal_name READ terminalName WRITE setTerminalName)
37 Q_PROPERTY(bool show_name READ showName WRITE setShowName)
38 Q_PROPERTY(QPointF label_pos READ labelPos WRITE setLabelPos)
39 Q_PROPERTY(QFont label_font READ labelFont WRITE setLabelFont)
40 Q_PROPERTY(qreal label_rotation READ labelRotation WRITE setLabelRotation)
41 Q_PROPERTY(Qt::Alignment label_halignment READ labelHAlignment WRITE setLabelHAlignment)
42 Q_PROPERTY(Qt::Alignment label_valignment READ labelVAlignment WRITE setLabelVAlignment)
43 Q_PROPERTY(bool label_frame READ labelFrame WRITE setLabelFrame)
44 Q_PROPERTY(QColor label_color READ labelColor WRITE setLabelColor)
47
48 public:
49 // constructors, destructor
50 PartTerminal(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
51 ~PartTerminal() override;
52 private:
54
55 signals:
69
70 // methods
71 public:
72 enum { Type = UserType + 1106 };
77 int type() const override { return Type; }
78 QString xmlName() const override { return(QString("terminal")); }
79 void fromXml(const QDomElement &) override;
80 const QDomElement toXml(QDomDocument &) const override;
81 void paint(
82 QPainter *painter,
83 const QStyleOptionGraphicsItem *,
84 QWidget *) override;
85
86 QPainterPath shape() const override;
87 QPainterPath shadowShape() const override;
88 QRectF boundingRect() const override;
89 bool isUseless() const override;
90 QRectF sceneGeometricRect() const override;
91 void startUserTransformation(const QRectF &) override;
92 void handleUserTransformation(const QRectF &, const QRectF &) override;
93
94 Qet::Orientation orientation() const {return d -> m_orientation;}
96
97 void setRotation(qreal angle);
98 qreal rotation() const;
99 void flip(qreal axis_y = 0);
100 void mirror(qreal axis_x = 0);
101 void nextOrientation();
102 void previousOrientation();
103
104
105 QString terminalName() const { return d -> m_name; }
106 void setTerminalName(const QString& name);
107
108 QString name() const override { return QObject::tr("Borne");}
109
110 TerminalData::Type terminalType() const {return d->m_type;}
112
113 bool showName() const { return d->m_show_name; }
114 void setShowName(bool show);
115
116 QPointF labelPos() const { return d->m_label_pos; }
117 void setLabelPos(QPointF pos);
118
119 QFont labelFont() const { return d->m_label_font; }
120 void setLabelFont(QFont font);
121
122 qreal labelRotation() const { return d->m_label_rotation; }
123 void setLabelRotation(qreal rotation);
124
125 Qt::Alignment labelHAlignment() const { return d->m_label_halignment; }
126 void setLabelHAlignment(Qt::Alignment align);
127
128 Qt::Alignment labelVAlignment() const { return d->m_label_valignment; }
129 void setLabelVAlignment(Qt::Alignment align);
130
131 bool labelFrame() const { return d->m_label_frame; }
132 void setLabelFrame(bool frame);
133
134 QColor labelColor() const { return d->m_label_color; }
135 void setLabelColor(QColor color);
136
137 bool useMasterLabel() const { return d->m_use_master_label; }
138 void setUseMasterLabel(bool use);
139
140 int masterLabelIndex() const { return d->m_master_label_index; }
141 void setMasterLabelIndex(int index);
142
143 void setNewUuid();
144
145 QRectF labelRect() const;
146
147 protected:
148 void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
149 void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
150 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
151
152 private:
153 void updateSecondPoint();
154 TerminalData* d; // pointer to the terminal data
155
156 private:
158 bool m_dragging_label = false;
160};
161#endif
Color color
Definition customelementgraphicpart.h:44
CustomElementGraphicPart(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
CustomElementGraphicPart::CustomElementGraphicPart Default constructor. By default,...
Definition customelementgraphicpart.cpp:34
void mirror(qreal axis_x=0)
PartTerminal::mirror turn part from left to right.
Definition partterminal.cpp:317
void nextOrientation()
Definition partterminal.cpp:334
QRectF labelRect() const
PartTerminal::labelRect.
Definition partterminal.cpp:220
Qt::Alignment label_halignment
Definition partterminal.h:41
void setMasterLabelIndex(int index)
Definition partterminal.cpp:471
void flip(qreal axis_y=0)
PartTerminal::flip turn part upside down.
Definition partterminal.cpp:296
int master_label_index
Definition partterminal.h:46
PartTerminal(QETElementEditor *editor, QGraphicsItem *parent=nullptr)
PartTerminal::PartTerminal.
Definition partterminal.cpp:31
void setLabelFont(QFont font)
Definition partterminal.cpp:410
void updateSecondPoint()
Definition partterminal.cpp:485
void labelVAlignmentChanged()
void setUseMasterLabel(bool use)
Definition partterminal.cpp:463
void setLabelFrame(bool frame)
Definition partterminal.cpp:446
Qt::Alignment labelHAlignment() const
Definition partterminal.h:125
TerminalData::Type terminal_type
Definition partterminal.h:36
void fromXml(const QDomElement &) override
Definition partterminal.cpp:51
void setLabelPos(QPointF pos)
Definition partterminal.cpp:401
void setRotation(qreal angle)
Definition partterminal.cpp:258
TerminalData::Type terminalType() const
Definition partterminal.h:110
bool isUseless() const override
Definition partterminal.cpp:502
void nameChanged()
void setLabelRotation(qreal rotation)
Definition partterminal.cpp:419
QFont label_font
Definition partterminal.h:39
QPointF labelPos() const
Definition partterminal.h:116
qreal label_rotation
Definition partterminal.h:40
bool label_frame
Definition partterminal.h:43
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
Definition partterminal.cpp:73
bool use_master_label
Definition partterminal.h:45
void setLabelVAlignment(Qt::Alignment align)
Definition partterminal.cpp:437
Qet::Orientation orientation
Definition partterminal.h:34
void terminalTypeChanged()
qreal labelRotation() const
Definition partterminal.h:122
void handleUserTransformation(const QRectF &, const QRectF &) override
Definition partterminal.cpp:530
Qt::Alignment labelVAlignment() const
Definition partterminal.h:128
void labelFrameChanged()
Qt::Alignment label_valignment
Definition partterminal.h:42
QPointF saved_position_
Definition partterminal.h:157
int type() const override
Definition partterminal.h:77
void setOrientation(Qet::Orientation ori)
Definition partterminal.cpp:246
void labelHAlignmentChanged()
Qet::Orientation orientation() const
Definition partterminal.h:94
void masterLabelIndexChanged()
void useMasterLabelChanged()
QFont labelFont() const
Definition partterminal.h:119
QRectF sceneGeometricRect() const override
Definition partterminal.cpp:513
void setLabelHAlignment(Qt::Alignment align)
Definition partterminal.cpp:428
void orientationChanged()
QString name() const override
Definition partterminal.h:108
TerminalData * d
Definition partterminal.h:154
@ Type
Definition partterminal.h:72
qreal rotation() const
PartTerminal::rotation.
Definition partterminal.cpp:282
void labelFontChanged()
QPainterPath shadowShape() const override
PartTerminal::shadowShape.
Definition partterminal.cpp:186
void setNewUuid()
Definition partterminal.cpp:387
QString terminalName() const
Definition partterminal.h:105
void labelRotationChanged()
QRectF boundingRect() const override
PartTerminal::boundingRect.
Definition partterminal.cpp:200
void setTerminalType(TerminalData::Type type)
PartTerminal::setTerminalType Set the type of terminal to 'type'.
Definition partterminal.cpp:378
const QDomElement toXml(QDomDocument &) const override
Definition partterminal.cpp:62
void setLabelColor(QColor color)
Definition partterminal.cpp:455
QColor labelColor() const
Definition partterminal.h:134
void startUserTransformation(const QRectF &) override
Definition partterminal.cpp:522
QPainterPath shape() const override
PartTerminal::shape.
Definition partterminal.cpp:165
void previousOrientation()
Definition partterminal.cpp:348
bool labelFrame() const
Definition partterminal.h:131
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Definition partterminal.cpp:569
QString xmlName() const override
Definition partterminal.h:78
QColor label_color
Definition partterminal.h:44
void labelPosChanged()
void setTerminalName(const QString &name)
PartTerminal::setTerminalName.
Definition partterminal.cpp:367
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition partterminal.cpp:536
QPointF label_pos
Definition partterminal.h:38
bool showName() const
Definition partterminal.h:113
bool show_name
Definition partterminal.h:37
int masterLabelIndex() const
Definition partterminal.h:140
QString terminal_name
Definition partterminal.h:35
bool useMasterLabel() const
Definition partterminal.h:137
void labelColorChanged()
void showNameChanged()
void setShowName(bool show)
Definition partterminal.cpp:392
bool m_dragging_label
Definition partterminal.h:158
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Definition partterminal.cpp:549
QPointF m_original_label_pos
Definition partterminal.h:159
Definition qetelementeditor.h:39
Orientation
Orientation (used for electrical elements and their terminals).
Definition qet.h:211
The TerminalData class Data of the terminal. Stored in extra class so it can be used by PartTerminal ...
Definition terminaldata.h:39
Type
Definition terminaldata.h:43