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);
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 
265 
270 class EDITOR_API IndexList : public SelectorNodes::SubItemList
271 {
272 public:
273  IndexList();
274  ~IndexList() override;
275 
281  void extend(Constants::SubObjectType stype, int index);
287  void extend(Constants::SubObjectType stype, int from, int to);
288 
291  int type() const override;
295  bool equal(SubItemList *other) const override;
298  void merge(SubItemList *other) override;
299 
304  void exclude(Constants::SubObjectType stype) override;
310  void exclude(Constants::SubObjectType stype, int index);
311 
317  bool contains(Constants::SubObjectType stype, int index) const;
318 
322  QSet<int> getSubObjectIndexes(Constants::SubObjectType stype) const;
325  bool empty(Constants::SubObjectType stype) const;
329  int size(Constants::SubObjectType stype) const;
330 
333  IndexList *clone() const override;
334 
335 private:
336  ::Editor::Internal::IndexListPrivate *d;
337 };
338 
339 
340 } // 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:270
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