Editor API
UnigineEditor public API
Actions.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <Undo.h>
6 #include <UnigineNode.h>
7 
8 
9 namespace Editor
10 {
11 class Selector;
12 class SelectionActionPrivate;
13 class RemoveNodesActionPrivate;
14 class SetNodeTransformActionPrivate;
15 class ReparentNodesActionPrivate;
16 class RenameNodeActionPrivate;
17 class EnableNodeActionPrivate;
18 }
19 
20 
21 namespace Editor
22 {
23 
25 class EDITOR_API SelectionAction : public Action
26 {
27 public:
30  explicit SelectionAction(Selector *s);
31  ~SelectionAction() override;
32 
34  void apply() override;
36  void undo() override;
38  void redo() override { apply(); }
39 
45  bool modifiesWorld() const override { return false; }
52  bool validate() override;
53 
56  static void applySelection(Selector *selector);
59  static void refreshSelection(bool expand = false);
60 
61 public:
62  SelectionActionPrivate *d;
63 };
64 
66 class EDITOR_API RemoveNodesAction : public Action
67 {
68 public:
71  explicit RemoveNodesAction(const Unigine::NodePtr &node);
74  explicit RemoveNodesAction(const QVector<Unigine::NodePtr> &nodes);
75  ~RemoveNodesAction() override;
76 
78  void apply() override;
80  void undo() override;
82  void redo() override { apply(); }
83 
90  bool validate() override;
91 
92  QVector<Unigine::NodePtr> getNodes() const;
93 
94 private:
95  RemoveNodesActionPrivate *d;
96 };
97 
99 class EDITOR_API SetNodeTransformAction : public Action
100 {
101 public:
105  SetNodeTransformAction(const Unigine::NodePtr &node,
106  const Unigine::Math::Mat4 &transform);
107  ~SetNodeTransformAction() override;
108 
110  void apply() override;
112  void undo() override;
114  void redo() override;
121  bool validate() override;
122 
123  Unigine::NodePtr getNode() const;
124 
125 private:
126  SetNodeTransformActionPrivate *d;
127 };
128 
130 class EDITOR_API ReparentNodesAction final : public Action
131 {
132 public:
137  ReparentNodesAction(const QVector<Unigine::NodePtr> &nodes,
138  const Unigine::NodePtr &new_parent,
139  int new_index = -1);
140  ~ReparentNodesAction() override;
141 
143  void apply() override;
145  void undo() override;
147  void redo() override;
148 
149 private:
150  ReparentNodesActionPrivate *d;
151 };
152 
154 class EDITOR_API RenameNodeAction : public Action
155 {
156 public:
160  RenameNodeAction(const Unigine::NodePtr &node, const QString &new_name);
161  ~RenameNodeAction() override;
162 
164  void apply() override;
166  void undo() override;
168  void redo() override;
175  bool validate() override;
176 
177 private:
178  RenameNodeActionPrivate *d;
179 };
180 
182 class EDITOR_API EnableNodeAction : public Action
183 {
184 public:
188  EnableNodeAction(const Unigine::NodePtr &node, bool enabled);
189  ~EnableNodeAction() override;
190 
192  void apply() override;
194  void undo() override;
196  void redo() override;
203  bool validate() override;
204 
205 private:
206  EnableNodeActionPrivate *d;
207 };
208 
209 
210 } // namespace Editor
This class is used to represent any user's action changing node's enabled state.
Definition: Actions.h:182
Definition: Actions.h:9
Definition: Selector.h:48
This class is used to represent any user's selection action.
Definition: Actions.h:25
This class is used to represent any user's action removing nodes.
Definition: Actions.h:66
SelectionActionPrivate * d
Definition: Actions.h:62
This class is used to represent any user's action setting node transforms.
Definition: Actions.h:99
This class is used to represent any user's action changing node's name.
Definition: Actions.h:154
This class is used to represent any user's action changing nodes parents.
Definition: Actions.h:130
void redo() override
Redoes the previously undone remove nodes action (reverses the undo method).
Definition: Actions.h:82
void redo() override
Redoes the previously undone selection action (reverses the undo method).
Definition: Actions.h:38
This basic class is used to represent any possible user action.
Definition: Undo.h:82
bool modifiesWorld() const override
Indicates whether the action brings any changes to the scene. Selection actions change nothing and sh...
Definition: Actions.h:45