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