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 };
65 
67 class EDITOR_API RemoveNodesAction : public Action
68 {
69 public:
72  explicit RemoveNodesAction(const Unigine::NodePtr &node);
75  explicit RemoveNodesAction(const QVector<Unigine::NodePtr> &nodes);
76  ~RemoveNodesAction() override;
77 
79  void apply() override;
81  void undo() override;
83  void redo() override { apply(); }
84 
91  bool validate() override;
92 
93  QVector<Unigine::NodePtr> getNodes() const;
94 private:
95  RemoveNodesActionPrivate *d;
96 
97 };
98 
100 class EDITOR_API SetNodeTransformAction : public Action
101 {
102 public:
106  SetNodeTransformAction(const Unigine::NodePtr &node,
107  const Unigine::Math::Mat4 &transform);
108  ~SetNodeTransformAction() override;
109 
111  void apply() override;
113  void undo() override;
115  void redo() override;
122  bool validate() override;
123 
124  Unigine::NodePtr getNode() const;
125 
126 private:
127  SetNodeTransformActionPrivate *d;
128 };
129 
131 class EDITOR_API ReparentNodesAction final : public Action
132 {
133 public:
138  ReparentNodesAction(const QVector<Unigine::NodePtr> &nodes,
139  const Unigine::NodePtr &new_parent,
140  int new_index = -1);
141  ~ReparentNodesAction() override;
142 
144  void apply() override;
146  void undo() override;
148  void redo() override;
149 
150 private:
151  ReparentNodesActionPrivate *d;
152 };
153 
155 class EDITOR_API RenameNodeAction : public Action
156 {
157 public:
161  RenameNodeAction(const Unigine::NodePtr &node, const QString &new_name);
162  ~RenameNodeAction() override;
163 
165  void apply() override;
167  void undo() override;
169  void redo() override;
176  bool validate() override;
177 
178 private:
179  RenameNodeActionPrivate *d;
180 };
181 
183 class EDITOR_API EnableNodeAction : public Action
184 {
185 public:
189  EnableNodeAction(const Unigine::NodePtr &node, bool enabled);
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:183
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:67
SelectionActionPrivate * d
Definition: Actions.h:62
This class is used to represent any user's action setting node transforms.
Definition: Actions.h:100
This class is used to represent any user's action changing node's name.
Definition: Actions.h:155
This class is used to represent any user's action changing nodes parents.
Definition: Actions.h:131
void redo() override
Redoes the previously undone remove nodes action (reverses the undo method).
Definition: Actions.h:83
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