Editor API
UnigineEditor public API
Actions.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/Undo.h>
6 
7 #include <UnigineNode.h>
8 #include <UnigineVector.h>
9 
10 
11 namespace Editor
12 {
13 class Selector;
14 class SelectionActionPrivate;
15 class CreateNodesActionPrivate;
16 class RemoveNodesActionPrivate;
17 class SetNodeTransformActionPrivate;
18 class ReparentNodesActionPrivate;
19 class RenameNodeActionPrivate;
20 class EnableNodeActionPrivate;
21 }
22 
23 
24 namespace Editor
25 {
26 
28 class EDITOR_API SelectionAction : public Action
29 {
30 public:
33  explicit SelectionAction(Selector *s);
34  ~SelectionAction() override;
35 
37  void apply() override;
39  void undo() override;
41  void redo() override { apply(); }
42 
48  bool modifiesWorld() const override { return false; }
55  bool validate() override;
56 
59  static void applySelection(Selector *selector);
62  static void refreshSelection(bool expand = false);
63 
64 public:
65  SelectionActionPrivate *d;
66 };
67 
69 class EDITOR_API CreateNodesAction : public Action
70 {
71 public:
74  explicit CreateNodesAction(const Unigine::NodePtr &node);
77  explicit CreateNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes);
78  ~CreateNodesAction() override;
79 
81  void apply() override;
83  void undo() override;
85  void redo() override;
86 
87  Unigine::Vector<Unigine::NodePtr> getNodes() const;
88 
89 private:
90  CreateNodesActionPrivate *d;
91 };
92 
94 class EDITOR_API RemoveNodesAction : public Action
95 {
96 public:
99  explicit RemoveNodesAction(const Unigine::NodePtr &node);
102  explicit RemoveNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes);
103  ~RemoveNodesAction() override;
104 
106  void apply() override;
108  void undo() override;
110  void redo() override { apply(); }
111 
118  bool validate() override;
119 
120  Unigine::Vector<Unigine::NodePtr> getNodes() const;
121 
122 private:
123  RemoveNodesActionPrivate *d;
124 };
125 
127 class EDITOR_API SetNodeTransformAction : public Action
128 {
129 public:
133  explicit SetNodeTransformAction(const Unigine::NodePtr &node,
134  const Unigine::Math::Mat4 &transform);
135  ~SetNodeTransformAction() override;
136 
138  void apply() override;
140  void undo() override;
142  void redo() override;
149  bool validate() override;
150 
151  Unigine::NodePtr getNode() const;
152 
153 private:
154  SetNodeTransformActionPrivate *d;
155 };
156 
158 class EDITOR_API ReparentNodesAction final : public Action
159 {
160 public:
165  explicit ReparentNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes,
166  const Unigine::NodePtr &new_parent,
167  int new_index = -1);
168  ~ReparentNodesAction() override;
169 
171  void apply() override;
173  void undo() override;
175  void redo() override;
176 
177 private:
178  ReparentNodesActionPrivate *d;
179 };
180 
182 class EDITOR_API RenameNodeAction : public Action
183 {
184 public:
188  explicit RenameNodeAction(const Unigine::NodePtr &node, const char *new_name);
189  ~RenameNodeAction() override;
190 
192  void apply() override;
194  void undo() override;
196  void redo() override;
203  bool validate() override;
204 
205 private:
206  RenameNodeActionPrivate *d;
207 };
208 
210 class EDITOR_API EnableNodeAction : public Action
211 {
212 public:
216  explicit EnableNodeAction(const Unigine::NodePtr &node, bool enabled);
220  EnableNodeAction(const Unigine::Vector<Unigine::NodePtr> &nodes, bool enabled);
221  ~EnableNodeAction() override;
222 
224  void apply() override;
226  void undo() override;
228  void redo() override;
235  bool validate() override;
236 
237 private:
238  EnableNodeActionPrivate *d;
239 };
240 
241 
242 } // namespace Editor
This class is used to represent any user's action changing node's enabled state.
Definition: Actions.h:210
This class is used to represent any user's selection action.
Definition: Actions.h:28
This class is used to represent any user's action removing nodes.
Definition: Actions.h:94
This class is used to represent any user's action setting node transforms.
Definition: Actions.h:127
This class is used to represent any user's action changing node's name.
Definition: Actions.h:182
This class is used to represent any user's action changing nodes parents.
Definition: Actions.h:158
void redo() override
Redoes the previously undone remove nodes action (reverses the undo method).
Definition: Actions.h:110
void redo() override
Redoes the previously undone selection action (reverses the undo method).
Definition: Actions.h:41
This class is used to represent any user's action creating nodes.
Definition: Actions.h:69
This basic class is used to represent any possible user action.
Definition: Undo.h:83
bool modifiesWorld() const override
Indicates whether the action brings any changes to the scene. Selection actions change nothing and sh...
Definition: Actions.h:48