QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
editorcommands.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 EDITOR_COMMANDS_H
19#define EDITOR_COMMANDS_H
21#include "../qgimanager.h"
22#include "elementcontent.h"
23#include "elementscene.h"
24#include "elementview.h"
38
39
46class ElementEditionCommand : public QUndoCommand
47{
48 // constructors, destructor
49 public:
51 ElementView * = nullptr,
52 QUndoCommand * = nullptr);
53 ElementEditionCommand(const QString &,
54 ElementScene * = nullptr,
55 ElementView * = nullptr,
56 QUndoCommand * = nullptr);
57 ~ElementEditionCommand() override;
58 private:
60
61 // methods
62 public:
65 ElementView *elementView() const;
67
68 // attributes
69 protected:
73};
74
79 // constructors, destructor
80 public:
81 CutPartsCommand(ElementScene *, const QList<QGraphicsItem *>&, QUndoCommand * = nullptr);
82 ~CutPartsCommand() override;
83 private:
85};
86
91 // constructors, destructor
92 public:
93 MovePartsCommand(const QPointF &, ElementScene *, const QList<QGraphicsItem *>&, QUndoCommand * = nullptr);
94 ~MovePartsCommand() override;
95 private:
97
98 // methods
99 public:
100 void undo() override;
101 void redo() override;
102
103 // attributes
104 private:
106 QList<QGraphicsItem *> moved_parts;
108 QPointF movement;
111};
112
117 // constructors, destructor
118 public:
119 ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand * = nullptr);
120 ~ChangeNamesCommand() override;
121 private:
123
124 // methods
125 public:
126 void undo() override;
127 void redo() override;
128
129 // attributes
130 private:
135};
136
142{
143 // constructors, destructor
144 public:
145 ChangeZValueCommand(ElementScene *, QET::DepthOption , QUndoCommand * = nullptr);
146 ~ChangeZValueCommand() override;
147 private:
149
150 // methods
151 public:
152 void undo() override;
153 void redo() override;
154
155 private:
156 void applyBringForward(const QList<QGraphicsItem *> &);
157 void applyRaise(const QList<QGraphicsItem *> &);
158 void applyLower(const QList<QGraphicsItem *> &);
159 void applySendBackward(const QList<QGraphicsItem *> &);
160
161 // attributes
162 private:
164 QHash<QGraphicsItem *, qreal> undo_hash;
166 QHash<QGraphicsItem *, qreal> redo_hash;
169};
170
175 // constructors, destructor
176 public:
177 ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand * = nullptr);
179 private:
181
182 // methods
183 public:
184 void undo() override;
185 void redo() override;
186
187 // attributes
188 private:
193};
194
199 // constructors, destructor
200 public:
201 ScalePartsCommand(ElementScene * = nullptr, QUndoCommand * = nullptr);
202 ~ScalePartsCommand() override;
203 private:
205
206 // methods
207 public:
208 void undo() override;
209 void redo() override;
210 ElementScene *elementScene() const;
211 void setScaledPrimitives(const QList<CustomElementPart *> &);
212 QList<CustomElementPart *> scaledPrimitives() const;
213 void setTransformation(const QRectF &, const QRectF &);
214 QPair<QRectF, QRectF> transformation();
215
216 protected:
217 void scale(const QRectF &before, const QRectF &after);
218 void adjustText();
219
220 // attributes
221 private:
223 QList<CustomElementPart *> scaled_primitives_;
227 QRectF new_rect_;
230};
231
233{
234 public:
236 ElementData old_data,
237 ElementData new_data,
238 QUndoCommand *parent = nullptr);
240
241 void undo() override;
242 void redo() override;
243
244 private:
247};
248
253
255{
256
257public:
258 RotateElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
259 void undo() override;
260 void redo() override;
261
262private:
264 QList<QGraphicsItem*> m_items;
265
266};
267
269{
270
271public:
272 RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
273 void undo() override;
274 void redo() override;
275
276private:
278 QList<QGraphicsItem*> m_items;
279
280};
281
289{
290public:
291 MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
292 void undo() override;
293 void redo() override;
294private:
296 QList<QGraphicsItem*> m_items;
297 qreal m_axis_x = 0;
298};
299
307{
308public:
309 FlipElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
310 void undo() override;
311 void redo() override;
312private:
314 QList<QGraphicsItem*> m_items;
315 qreal m_axis_y = 0;
316};
317
318#endif
ChangeInformationsCommand(const ChangeInformationsCommand &)
QString old_informations_
Former information.
Definition editorcommands.h:190
QString new_informations_
New information.
Definition editorcommands.h:192
~ChangeInformationsCommand() override
Destructeur.
Definition editorcommands.cpp:340
ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand *=nullptr)
Definition editorcommands.cpp:332
void redo() override
Refait le changement d'autorisation pour les connexions internes.
Definition editorcommands.cpp:353
void undo() override
Annule le changement d'autorisation pour les connexions internes.
Definition editorcommands.cpp:345
NamesList names_after
List of new names.
Definition editorcommands.h:134
ChangeNamesCommand(ElementScene *, const NamesList &, const NamesList &, QUndoCommand *=nullptr)
Definition editorcommands.cpp:166
ChangeNamesCommand(const ChangeNamesCommand &)
void redo() override
Refait le changement.
Definition editorcommands.cpp:192
~ChangeNamesCommand() override
Destructeur.
Definition editorcommands.cpp:179
void undo() override
Annule le changement.
Definition editorcommands.cpp:184
NamesList names_before
List of former names.
Definition editorcommands.h:132
void applyLower(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:292
ChangeZValueCommand(const ChangeZValueCommand &)
void redo() override
Refait les changements de zValue.
Definition editorcommands.cpp:247
ChangeZValueCommand(ElementScene *, QET::DepthOption, QUndoCommand *=nullptr)
Definition editorcommands.cpp:205
void undo() override
Annule les changements de zValue.
Definition editorcommands.cpp:241
QHash< QGraphicsItem *, qreal > redo_hash
associates impacted primitives with their new zValues
Definition editorcommands.h:166
void applyBringForward(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:256
QHash< QGraphicsItem *, qreal > undo_hash
associates impacted primitives with their former zValues
Definition editorcommands.h:164
void applySendBackward(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:311
QET::DepthOption m_option
kind of treatment to apply
Definition editorcommands.h:168
void applyRaise(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:274
~ChangeZValueCommand() override
Destructeur.
Definition editorcommands.cpp:236
CutPartsCommand(ElementScene *, const QList< QGraphicsItem * > &, QUndoCommand *=nullptr)
Definition editorcommands.cpp:101
~CutPartsCommand() override
Destructeur.
Definition editorcommands.cpp:112
CutPartsCommand(const CutPartsCommand &)
DeletePartsCommand(QPointer< ElementScene > scene, const QVector< QGraphicsItem * > &parts, QUndoCommand *parent=nullptr)
DeletePartsCommand::DeletePartsCommand.
Definition deletepartscommand.cpp:27
The ElementData class WARNING This class inherit from PropertiesInterface but only fromXml is actuall...
Definition elementdata.h:36
void setElementView(ElementView *)
Definition editorcommands.cpp:90
ElementView * elementView() const
Definition editorcommands.cpp:82
~ElementEditionCommand() override
Definition editorcommands.cpp:60
ElementEditionCommand(const ElementEditionCommand &)
ElementScene * elementScene() const
Definition editorcommands.cpp:67
ElementEditionCommand(ElementScene *=nullptr, ElementView *=nullptr, QUndoCommand *=nullptr)
ElementEditionCommand::ElementEditionCommand Constructs an ElementEditionCommand, thus embedding the ...
Definition editorcommands.cpp:29
ElementView * m_view
Definition editorcommands.h:72
ElementScene * m_scene
Element editor/view/scene the command should take place on.
Definition editorcommands.h:71
void setElementScene(ElementScene *)
Definition editorcommands.cpp:75
The ElementScene class This class is the canvas allowing the visual edition of an electrical element....
Definition elementscene.h:46
Definition elementview.h:27
ElementScene * m_scene
Definition editorcommands.h:313
qreal m_axis_y
Definition editorcommands.h:315
FlipElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr)
Definition editorcommands.cpp:740
QList< QGraphicsItem * > m_items
Definition editorcommands.h:314
void redo() override
FlipElementsCommand::redo.
Definition editorcommands.cpp:750
void undo() override
FlipElementsCommand::undo.
Definition editorcommands.cpp:784
ElementScene * m_scene
Definition editorcommands.h:295
QList< QGraphicsItem * > m_items
Definition editorcommands.h:296
void redo() override
MirrorElementsCommand::redo.
Definition editorcommands.cpp:701
qreal m_axis_x
Definition editorcommands.h:297
MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr)
Definition editorcommands.cpp:691
void undo() override
MirrorElementsCommand::undo.
Definition editorcommands.cpp:734
~MovePartsCommand() override
Destructeur.
Definition editorcommands.cpp:138
QPointF movement
applied movement
Definition editorcommands.h:108
void redo() override
Refait le deplacement.
Definition editorcommands.cpp:149
void undo() override
Annule le deplacement.
Definition editorcommands.cpp:143
QList< QGraphicsItem * > moved_parts
List of moved primitives.
Definition editorcommands.h:106
MovePartsCommand(const QPointF &, ElementScene *, const QList< QGraphicsItem * > &, QUndoCommand *=nullptr)
Definition editorcommands.cpp:124
MovePartsCommand(const MovePartsCommand &)
bool first_redo
Prevent the first call to redo().
Definition editorcommands.h:110
Definition nameslist.h:37
QList< QGraphicsItem * > m_items
Definition editorcommands.h:264
RotateElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr)
Definition editorcommands.cpp:500
ElementScene * m_scene
Definition editorcommands.h:263
void redo() override
RotateElementsCommand::redo.
Definition editorcommands.cpp:558
void undo() override
RotateElementsCommand::undo.
Definition editorcommands.cpp:509
ElementScene * m_scene
Definition editorcommands.h:277
QList< QGraphicsItem * > m_items
Definition editorcommands.h:278
void undo() override
RotateFineElementsCommand::undo.
Definition editorcommands.cpp:614
RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr)
Definition editorcommands.cpp:605
void redo() override
RotateFineElementsCommand::redo.
Definition editorcommands.cpp:643
bool first_redo
Prevent the first call to redo().
Definition editorcommands.h:229
QList< CustomElementPart * > scaled_primitives_
List of moved primitives.
Definition editorcommands.h:223
void setScaledPrimitives(const QList< CustomElementPart * > &)
Definition editorcommands.cpp:408
QRectF original_rect_
original rect items fit in
Definition editorcommands.h:225
void redo() override
Definition editorcommands.cpp:388
void scale(const QRectF &before, const QRectF &after)
Definition editorcommands.cpp:448
void adjustText()
Definition editorcommands.cpp:462
~ScalePartsCommand() override
Definition editorcommands.cpp:373
void undo() override
Definition editorcommands.cpp:380
QList< CustomElementPart * > scaledPrimitives() const
Definition editorcommands.cpp:416
QPair< QRectF, QRectF > transformation()
Definition editorcommands.cpp:440
ScalePartsCommand(ElementScene *=nullptr, QUndoCommand *=nullptr)
Definition editorcommands.cpp:365
ElementScene * elementScene() const
Definition editorcommands.cpp:400
ScalePartsCommand(const ScalePartsCommand &)
void setTransformation(const QRectF &, const QRectF &)
ScalePartsCommand::setTransformation Define the transformation applied by this command.
Definition editorcommands.cpp:429
QRectF new_rect_
new rect items should fit in
Definition editorcommands.h:227
void redo() override
Definition editorcommands.cpp:495
void undo() override
Definition editorcommands.cpp:490
ElementData m_new
Definition editorcommands.h:246
changeElementDataCommand(ElementScene *scene, ElementData old_data, ElementData new_data, QUndoCommand *parent=nullptr)
changeElementDataCommand::changeElementDataCommand Change the properties of the drawn element
Definition editorcommands.cpp:479
ElementData m_old
Definition editorcommands.h:245
~changeElementDataCommand() override
Definition editorcommands.h:239
DepthOption
List the various kind of changes for the zValue.
Definition qet.h:42