Editor API
UnigineEditor public API
Selector.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/Constants.h>
6 #include <editor/EditorGlobal.h>
7 
8 #include <UnigineNode.h>
9 #include <UnigineVector.h>
10 #include <UnigineHashSet.h>
11 
12 
13 namespace Unigine
14 {
15 class UGUID;
16 }
17 
18 namespace Editor {
19 class IndexList;
20 
21 namespace Internal {
22 class SelectorGUIDsPrivate;
23 class SelectorNodesPrivate;
24 class IndexListPrivate;
25 }}
26 
27 
28 namespace Editor
29 {
30 
33 {
43  SELECTOR_USER = 0x0100
44 };
45 
47 // Selector.
49 class EDITOR_API Selector
50 {
51 public:
52  Selector();
53  virtual ~Selector();
56  virtual int type() const = 0;
59  virtual bool equal(const Selector *selector) const = 0;
62  virtual Selector *clone () const = 0;
63 };
64 
66 // SelectorGUIDs.
68 // TODO(SiN_Bizkit: 04/11/19): Choose a clear name.
70 class EDITOR_API SelectorGUIDs : public Selector
71 {
72 public:
76  static SelectorGUIDs *createRuntimesSelector (Unigine::Vector<Unigine::UGUID> guids);
80  static SelectorGUIDs *createMaterialsSelector (Unigine::Vector<Unigine::UGUID> guids);
84  static SelectorGUIDs *createPropertiesSelector(Unigine::Vector<Unigine::UGUID> guids);
85 
90  SelectorGUIDs(int type, Unigine::Vector<Unigine::UGUID> guids);
91  ~SelectorGUIDs() override;
92 
95  int type() const override;
99  bool equal(const Selector *selector) const override;
102  SelectorGUIDs *clone() const override;
103 
106  Unigine::Vector<Unigine::UGUID> guids() const;
107 
110  bool contains(const Unigine::UGUID &guid) const;
111 
114  bool empty() const;
115 
116 private:
117  ::Editor::Internal::SelectorGUIDsPrivate *d;
118 };
119 
121 // SelectorNodes.
126 class EDITOR_API SelectorNodes : public Selector
127 {
128 public:
131  static SelectorNodes *createObjectsSelector(const Unigine::Vector<Unigine::NodePtr> &nodes);
132 
134  enum SubType
135  {
137  INDEXED = 0,
139  USER = 0x0100
140  };
141 
146  class EDITOR_API SubItemList
147  {
148  public:
149  SubItemList();
150  virtual ~SubItemList();
151 
152  virtual int type() const = 0;
156  virtual bool equal(SubItemList *other) const = 0;
159  virtual void merge(SubItemList *other) = 0;
162  virtual void exclude(Constants::SubObjectType sub) = 0;
163 
164  virtual SubItemList *clone() const = 0;
165  };
166 
167  SelectorNodes();
168  explicit SelectorNodes(const Unigine::Vector<Unigine::NodePtr> &nodes);
169  ~SelectorNodes() override;
170 
173  int type() const override;
177  bool equal(const Selector *selector) const override;
180  SelectorNodes *clone() const override;
181 
184  Unigine::Vector<Unigine::NodePtr> getNodes() const;
187  int size() const;
190  bool empty() const;
191 
194  void extend(const Unigine::NodePtr &node);
197  void extend(const Unigine::Vector<Unigine::NodePtr> &nodes);
201  void extend(const Unigine::NodePtr &node, SubItemList *subs);
202 
205  void exclude(const Unigine::NodePtr &node);
208  void exclude(const Unigine::Vector<Unigine::NodePtr> &nodes);
213  void exclude(Constants::SubObjectType stype);
214 
218  bool contains(const Unigine::NodePtr &node) const;
219 
223  SubItemList *getSubItemList(int node_id) const;
227  SubItemList *getSubItemList(const Unigine::NodePtr &node) const;
235  IndexList *getIndexList(int node_id) const;
243  IndexList *getIndexList(const Unigine::NodePtr &node) const;
244 
254  Unigine::HashSet<int> getIntersectedIndexes(Constants::SubObjectType stype) const;
255 
262  void resetCache();
263 
264  // `expand` flag is a shitty solution to pass a param to the `WorldModel.`. Refactor this.
265  [[deprecated]]
266  void setNeedExpand(bool value);
267  [[deprecated]]
268  bool isNeedExpand() const;
269 
270 private:
271  ::Editor::Internal::SelectorNodesPrivate *d;
272 };
273 
278 class EDITOR_API IndexList : public SelectorNodes::SubItemList
279 {
280 public:
281  IndexList();
282  ~IndexList() override;
283 
289  void extend(Constants::SubObjectType stype, int index);
295  void extend(Constants::SubObjectType stype, int from, int to);
296 
299  int type() const override;
303  bool equal(SubItemList *other) const override;
306  void merge(SubItemList *other) override;
307 
312  void exclude(Constants::SubObjectType stype) override;
318  void exclude(Constants::SubObjectType stype, int index);
319 
325  bool contains(Constants::SubObjectType stype, int index) const;
326 
330  Unigine::HashSet<int> getSubObjectIndexes(Constants::SubObjectType stype) const;
333  bool empty(Constants::SubObjectType stype) const;
337  int size(Constants::SubObjectType stype) const;
338 
341  IndexList *clone() const override;
342 
343 private:
344  ::Editor::Internal::IndexListPrivate *d;
345 };
346 
347 
348 } // namespace Editor
Materials selector.
Definition: Selector.h:37
Definition: Actions.h:11
Definition: Selector.h:49
Beginning of the range of user-defined types. Types are referred to as SELECTOR_USER+0,...
Definition: Selector.h:43
Definition: Constants.h:69
Selector for GUIDs-based items (materials, properties, runtimes). An item of this type is associated ...
Definition: Selector.h:70
SubObjectType
Type of selectable subobjects for various types of nodes.
Definition: Constants.h:43
Properties selector.
Definition: Selector.h:39
SelectorType
Selector type, defines the type of selected entities. The first 256 types are reserved by UNIGINE,...
Definition: Selector.h:32
This class represents a list of selected subitems of a selected node. When an object is selected,...
Definition: Selector.h:146
Nodes selector.
Definition: Selector.h:35
SubType
Subitem type. The first 256 types are reserved by UNIGINE, user subitem types start from USER + i (25...
Definition: Selector.h:134
This class represents a list of indices of selected subitems of a selected node. When an object is se...
Definition: Selector.h:278
This class is used to manage selected nodes along with their subobjects (such as surfaces,...
Definition: Selector.h:126
Runtimes selector.
Definition: Selector.h:41