Debian Codegraph @

include/iselectionset.h

raw
1 #pragma once
2
3 #include "imodule.h"
4 #include "inode.h"
5 #include <set>
6
7 #include <sigc++/signal.h>
8
9 namespace selection
10 {
11
12 class ISelectionSet
13 {
14 public:
15 // The name of this set
16 virtual const std::string& getName() = 0;
17
18 // Checks whether this set is empty
19 virtual bool empty() = 0;
20
21 // Selects all member nodes of this set
22 virtual void select() = 0;
23
24 // De-selects all member nodes of this set
25 virtual void deselect() = 0;
26
27 // Removes all members, leaving this set as empty
28 virtual void clear() = 0;
29
30 // Clears this set and loads the currently selected nodes in the
31 // scene as new members into this set.
32 virtual void assignFromCurrentScene() = 0;
33
34 // Adds the given node to this set
35 virtual void addNode(const scene::INodePtr& node) = 0;
36
37 // Returns the nodes contained in this selection set.
38 virtual std::set<scene::INodePtr> getNodes() = 0;
39 };
40 typedef std::shared_ptr<ISelectionSet> ISelectionSetPtr;
41
42 class ISelectionSetManager
43 {
44 public:
45 typedef std::shared_ptr<ISelectionSetManager> Ptr;
46
47 virtual ~ISelectionSetManager() {}
48
49 /**
50 * Signal emitted when the list of selection sets has been changed, by
51 * deletion or addition.
52 */
53 virtual sigc::signal<void> signal_selectionSetsChanged() const = 0;
54
55 class Visitor
56 {
57 public:
58 virtual ~Visitor() {}
59 virtual void visit(const ISelectionSetPtr& set) = 0;
60 };
61
62 /**
63 * greebo: Traverses the list of selection sets using
64 * the given visitor class.
65 */
66 virtual void foreachSelectionSet(Visitor& visitor) = 0;
67
68 typedef std::function<void(const ISelectionSetPtr&)> VisitorFunc;
69
70 /**
71 * greebo: Traverses the list of selection sets using the given functor.
72 */
73 virtual void foreachSelectionSet(const VisitorFunc& functor) = 0;
74
75 /**
76 * greebo: Creates a new selection set with the given name.
77 * If a selection with that name is already registered, the existing
78 * one is returned.
79 */
80 virtual ISelectionSetPtr createSelectionSet(const std::string& name) = 0;
81
82 /**
83 * Removes the named selection set. If the named set is
84 * not existing, nothing happens.
85 */
86 virtual void deleteSelectionSet(const std::string& name) = 0;
87
88 /**
89 * Deletes all sets.
90 */
91 virtual void deleteAllSelectionSets() = 0;
92
93 /**
94 * Finds the named selection set.
95 *
96 * @returns the found selection set or NULL if the set is not existent.
97 */
98 virtual ISelectionSetPtr findSelectionSet(const std::string& name) = 0;
99 };
100
101 class ISelectionSetModule :
102 public RegisterableModule
103 {
104 public:
105 virtual ~ISelectionSetModule() {}
106
107 virtual ISelectionSetManager::Ptr createSelectionSetManager() = 0;
108 };
109
110 } // namespace
111
112 const char* const MODULE_SELECTIONSETS = "SelectionSetModule";
113
114 inline selection::ISelectionSetModule& GlobalSelectionSetModule()
115 {
116 static module::InstanceReference<selection::ISelectionSetModule> _reference(MODULE_SELECTIONSETS);
117 return _reference;
118 }