Plasma Engine  2.0
Loading...
Searching...
No Matches
SelectionManager.h
1#pragma once
2
3#include <ToolsFoundation/Object/DocumentObjectBase.h>
4#include <ToolsFoundation/ToolsFoundationDLL.h>
5
6class plDocument;
8
10{
11 enum class Type
12 {
13 SelectionCleared,
14 SelectionSet,
15 ObjectAdded,
16 ObjectRemoved,
17 };
18
19 Type m_Type;
20 const plDocument* m_pDocument;
21 const plDocumentObject* m_pObject;
22};
23
25class PL_TOOLSFOUNDATION_DLL plSelectionManager
26{
27public:
29
30 // \brief Storage for the selection so it can be swapped when using multiple sub documents.
31 class Storage : public plRefCounted
32 {
33 public:
35 plSet<plUuid> m_SelectionSet;
36 const plDocumentObjectManager* m_pObjectManager = nullptr;
38 };
39
40public:
41 plSelectionManager(const plDocumentObjectManager* pObjectManager);
43
44 void Clear();
45 void AddObject(const plDocumentObject* pObject);
46 void RemoveObject(const plDocumentObject* pObject, bool bRecurseChildren = false);
47 void SetSelection(const plDocumentObject* pSingleObject);
48 void SetSelection(const plDeque<const plDocumentObject*>& selection);
49 void ToggleObject(const plDocumentObject* pObject);
50
52 const plDocumentObject* GetCurrentObject() const;
53
55 const plDeque<const plDocumentObject*>& GetSelection() const { return m_pSelectionStorage->m_SelectionList; }
56
57 bool IsSelectionEmpty() const { return m_pSelectionStorage->m_SelectionList.IsEmpty(); }
58
60 const plDeque<const plDocumentObject*> GetTopLevelSelection() const;
61
63 const plDeque<const plDocumentObject*> GetTopLevelSelection(const plRTTI* pBase) const;
64
65 bool IsSelected(const plDocumentObject* pObject) const;
66 bool IsParentSelected(const plDocumentObject* pObject) const;
67
68 const plDocument* GetDocument() const;
69
71 plSharedPtr<plSelectionManager::Storage> GetStorage() { return m_pSelectionStorage; }
72
73private:
74 void TreeEventHandler(const plDocumentObjectStructureEvent& e);
75 bool RecursiveRemoveFromSelection(const plDocumentObject* pObject);
76
77 friend class plDocument;
78
80
81 plCopyOnBroadcastEvent<const plDocumentObjectStructureEvent&>::Unsubscriber m_ObjectStructureUnsubscriber;
82 plCopyOnBroadcastEvent<const plSelectionManagerEvent&>::Unsubscriber m_EventsUnsubscriber;
83};
bool IsEmpty() const
Checks whether no elements are active in the deque.
Definition Deque_inl.h:601
Definition Deque.h:270
Definition Document.h:57
Definition DocumentObjectBase.h:11
Represents to content of a document. Every document has exactly one root object under which all objec...
Definition DocumentObjectManager.h:116
Definition Event.h:177
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
Base class for reference counted objects.
Definition RefCounted.h:52
Definition SelectionManager.h:32
Selection Manager stores a set of selected document objects.
Definition SelectionManager.h:26
const plDeque< const plDocumentObject * > & GetSelection() const
Returns the selection in the same order the objects were added to the list.
Definition SelectionManager.h:55
Definition Set.h:238
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
Used by plDocumentObjectManager::m_StructureEvents.
Definition DocumentObjectManager.h:45
Definition SelectionManager.h:10