Editor API
UnigineEditor public API
Selector.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <Constants.h>
6 
7 #include <EditorGlobal.h>
8 #include <UnigineNode.h>
9 #include <QVector>
10 
11 
12 namespace Unigine
13 {
14 class UGUID;
15 }
16 
17 namespace Editor {
18 class IndexList;
19 
20 namespace Internal {
21 class SelectorGUIDsPrivate;
22 class SelectorNodesPrivate;
23 class IndexListPrivate;
24 }}
25 
26 
27 namespace Editor
28 {
29 
32 {
42  SELECTOR_USER = 0x0100
43 };
44 
46 // Selector.
48 class EDITOR_API Selector
49 {
50 public:
51  Selector();
52  virtual ~Selector();
55  virtual int type() const = 0;
58  virtual bool equal(const Selector *selector) const = 0;
61  virtual Selector *clone () const = 0;
62 };
63 
65 // SelectorGUIDs.
67 // TODO(SiN_Bizkit: 04/11/19): Choose a clear name.
69 class EDITOR_API SelectorGUIDs : public Selector
70 {
71 public:
75  static SelectorGUIDs *createRuntimesSelector (QVector<Unigine::UGUID> guids);
79  static SelectorGUIDs *createMaterialsSelector (QVector<Unigine::UGUID> guids);
83  static SelectorGUIDs *createPropertiesSelector(QVector<Unigine::UGUID> guids);
84 
89  SelectorGUIDs(int type, QVector<Unigine::UGUID> guids);
90  ~SelectorGUIDs() override;
91 
94  int type() const override;
98  bool equal(const Selector *selector) const override;
101  SelectorGUIDs *clone() const override;
102 
105  QVector<Unigine::UGUID> guids() const;
106 
107 private:
108  ::Editor::Internal::SelectorGUIDsPrivate *d;
109 };
110 
112 // SelectorNodes.
117 class EDITOR_API SelectorNodes : public Selector
118 {
119 public:
122  static SelectorNodes *createObjectsSelector(const QVector<Unigine::NodePtr> &nodes);
123 
125  enum SubType
126  {
128  INDEXED = 0,
130  USER = 0x0100
131  };
132 
138  {
139  public:
140  SubItemList();
141  virtual ~SubItemList();
142 
143  virtual int type() const = 0;
147  virtual bool equal(SubItemList *other) const = 0;
150  virtual void merge(SubItemList *other) = 0;
153  virtual void exclude(Constants::SubObjectType sub) = 0;
154 
155  virtual SubItemList *clone() const = 0;
156  };
157 
158  SelectorNodes();
159  explicit SelectorNodes(const QVector<Unigine::NodePtr> &nodes);
160  ~SelectorNodes() override;
161 
164  int type() const override;
168  bool equal(const Selector *selector) const override;
171  SelectorNodes *clone() const override;
172 
175  QVector<Unigine::NodePtr> getNodes() const;
178  int size() const;
181  bool empty() const;
182 
185  void extend(const Unigine::NodePtr &node);
188  void extend(const QVector<Unigine::NodePtr> &nodes);
192  void extend(const Unigine::NodePtr &node, SubItemList *subs);
193 
196  void exclude(const Unigine::NodePtr &node);
199  void exclude(const QVector<Unigine::NodePtr> &nodes);
204  void exclude(Constants::SubObjectType stype);
205 
209  bool contains(const Unigine::NodePtr &node) const;
210 
214  SubItemList *getSubItemList(int node_id) const;
218  SubItemList *getSubItemList(const Unigine::NodePtr &node) const;
226  IndexList *getIndexList(int node_id) const;
234  IndexList *getIndexList(const Unigine::NodePtr &node) const;
235 
245  QSet<int> getIntersectedIndexes(Constants::SubObjectType stype) const;
246 
253  void resetCache();
254 
255  // `expand` flag is a shitty solution to pass a param to the `WorldModel.`. Refactor this.
256  [[deprecated]]
257  void setNeedExpand(bool value);
258  [[deprecated]]
259  bool isNeedExpand() const;
260 
261 private:
262  ::Editor::Internal::SelectorNodesPrivate *d;
263 };
264 
269 class EDITOR_API IndexList : public SelectorNodes::SubItemList
270 {
271 public:
272  IndexList();
273  ~IndexList() override;
274 
280  void extend(Constants::SubObjectType stype, int index);
286  void extend(Constants::SubObjectType stype, int from, int to);
287 
290  int type() const override;
294  bool equal(SubItemList *other) const override;
297  void merge(SubItemList *other) override;
298 
303  void exclude(Constants::SubObjectType stype) override;
309  void exclude(Constants::SubObjectType stype, int index);
310 
316  bool contains(Constants::SubObjectType stype, int index) const;
317 
321  QSet<int> getSubObjectIndexes(Constants::SubObjectType stype) const;
324  bool empty(Constants::SubObjectType stype) const;
328  int size(Constants::SubObjectType stype) const;
329 
332  IndexList *clone() const override;
333 
334 private:
335  ::Editor::Internal::IndexListPrivate *d;
336 };
337 
338 
339 } // namespace Editor
Materials selector.
Definition: Selector.h:36
Definition: Actions.h:9
Definition: Selector.h:48
Beginning of the range of user-defined types. Types are referred to as SELECTOR_USER+0,...
Definition: Selector.h:42
Definition: Selector.h:12
Selector for GUIDs-based items (materials, properties, runtimes). An item of this type is associated ...
Definition: Selector.h:69
SubObjectType
Type of selectable subobjects for various types of nodes.
Definition: Constants.h:37
Properties selector.
Definition: Selector.h:38
SelectorType
Selector type, defines the type of selected entities. The first 256 types are reserved by UNIGINE,...
Definition: Selector.h:31
This class represents a list of selected subitems of a selected node. When an object is selected,...
Definition: Selector.h:137
Nodes selector.
Definition: Selector.h:34
SubType
Subitem type. The first 256 types are reserved by UNIGINE, user subitem types start from USER + i (25...
Definition: Selector.h:125
This class represents a list of indices of selected subitems of a selected node. When an object is se...
Definition: Selector.h:269
This class is used to manage selected nodes along with their subobjects (such as surfaces,...
Definition: Selector.h:117
Runtimes selector.
Definition: Selector.h:40