QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
editorcommands.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 EDITOR_COMMANDS_H
19#define EDITOR_COMMANDS_H
20#include "../editor/graphicspart/customelementpart.h"
21#include "../qgimanager.h"
22#include "elementcontent.h"
23#include "elementscene.h"
24#include "elementview.h"
36#include "../QPropertyUndoCommand/qpropertyundocommand.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
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
268#endif
Definition editorcommands.h:174
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:353
void redo() override
Refait le changement d'autorisation pour les connexions internes.
Definition editorcommands.cpp:366
void undo() override
Annule le changement d'autorisation pour les connexions internes.
Definition editorcommands.cpp:358
Definition editorcommands.h:116
NamesList names_after
List of new names.
Definition editorcommands.h:134
ChangeNamesCommand(const ChangeNamesCommand &)
void redo() override
Refait le changement.
Definition editorcommands.cpp:191
~ChangeNamesCommand() override
Destructeur.
Definition editorcommands.cpp:178
void undo() override
Annule le changement.
Definition editorcommands.cpp:183
NamesList names_before
List of former names.
Definition editorcommands.h:132
Definition editorcommands.h:142
void applyLower(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:298
ChangeZValueCommand(const ChangeZValueCommand &)
void redo() override
Refait les changements de zValue.
Definition editorcommands.cpp:246
void undo() override
Annule les changements de zValue.
Definition editorcommands.cpp:240
QHash< QGraphicsItem *, qreal > redo_hash
associates impacted primitives with their new zValues
Definition editorcommands.h:166
void applyBringForward(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:255
QHash< QGraphicsItem *, qreal > undo_hash
associates impacted primitives with their former zValues
Definition editorcommands.h:164
void applySendBackward(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:324
QET::DepthOption m_option
kind of treatment to apply
Definition editorcommands.h:168
void applyRaise(const QList< QGraphicsItem * > &)
Definition editorcommands.cpp:273
~ChangeZValueCommand() override
Destructeur.
Definition editorcommands.cpp:235
Definition editorcommands.h:78
~CutPartsCommand() override
Destructeur.
Definition editorcommands.cpp:111
CutPartsCommand(const CutPartsCommand &)
The DeletePartsCommand class Class used to remove part from an element scene.
Definition deletepartscommand.h:33
The ElementData class WARNING This class inherit from PropertiesInterface but only fromXml is actuall...
Definition elementdata.h:32
The ElementEditionCommand class ElementEditionCommand is the base class for all commands classes invo...
Definition editorcommands.h:47
void setElementView(ElementView *)
Definition editorcommands.cpp:89
ElementView * elementView() const
Definition editorcommands.cpp:81
~ElementEditionCommand() override
Definition editorcommands.cpp:59
ElementEditionCommand(const ElementEditionCommand &)
ElementScene * elementScene() const
Definition editorcommands.cpp:66
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:74
The ElementScene class This class is the canvas allowing the visual edition of an electrical element....
Definition elementscene.h:46
Definition elementview.h:27
Definition editorcommands.h:90
~MovePartsCommand() override
Destructeur.
Definition editorcommands.cpp:137
QPointF movement
applied movement
Definition editorcommands.h:108
void redo() override
Refait le deplacement.
Definition editorcommands.cpp:148
void undo() override
Annule le deplacement.
Definition editorcommands.cpp:142
QList< QGraphicsItem * > moved_parts
List of moved primitives.
Definition editorcommands.h:106
MovePartsCommand(const MovePartsCommand &)
bool first_redo
Prevent the first call to redo()
Definition editorcommands.h:110
Definition nameslist.h:31
The RotateSelectionInESCommand class Rotate the selected items in the element editor.
Definition editorcommands.h:255
QList< QGraphicsItem * > m_items
Definition editorcommands.h:264
ElementScene * m_scene
Definition editorcommands.h:263
void redo() override
RotateElementsCommand::redo.
Definition editorcommands.cpp:550
void undo() override
RotateElementsCommand::undo.
Definition editorcommands.cpp:522
Definition editorcommands.h:198
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:421
QRectF original_rect_
original rect items fit in
Definition editorcommands.h:225
void redo() override
Definition editorcommands.cpp:401
void scale(const QRectF &before, const QRectF &after)
Definition editorcommands.cpp:461
void adjustText()
Definition editorcommands.cpp:475
~ScalePartsCommand() override
Definition editorcommands.cpp:386
void undo() override
Definition editorcommands.cpp:393
QList< CustomElementPart * > scaledPrimitives() const
Definition editorcommands.cpp:429
QPair< QRectF, QRectF > transformation()
Definition editorcommands.cpp:453
ElementScene * elementScene() const
Definition editorcommands.cpp:413
ScalePartsCommand(const ScalePartsCommand &)
void setTransformation(const QRectF &, const QRectF &)
ScalePartsCommand::setTransformation Define the transformation applied by this command.
Definition editorcommands.cpp:442
QRectF new_rect_
new rect items should fit in
Definition editorcommands.h:227
Definition editorcommands.h:233
void redo() override
Definition editorcommands.cpp:508
void undo() override
Definition editorcommands.cpp:503
ElementData m_new
Definition editorcommands.h:246
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:41