Debian Codegraph @

plugins/script/interfaces/SelectionGroupInterface.h

raw
1 #pragma once
2
3 #include <pybind11/pybind11.h>
4
5 #include "iscript.h"
6 #include "iscriptinterface.h"
7 #include "iselectiongroup.h"
8
9 #include "SceneGraphInterface.h"
10
11 namespace script
12 {
13
14 // ========== SelectionGroup Handling ==========
15
16 class SelectionGroupVisitor
17 {
18 public:
19 virtual ~SelectionGroupVisitor() {}
20 virtual void visit(const scene::INodePtr& node) = 0;
21 };
22
23 // Wrap around the ISelectionSetManager::Visitor interface
24 class SelectionGroupVisitorWrapper :
25 public SelectionGroupVisitor
26 {
27 public:
28 void visit(const scene::INodePtr& node) override
29 {
30 // Wrap this method to python
31 PYBIND11_OVERLOAD_PURE(
32 void, /* Return type */
33 SelectionGroupVisitor, /* Parent class */
34 visit, /* Name of function in C++ (must match Python name) */
35 ScriptSceneNode(node) /* Argument(s) */
36 );
37 }
38 };
39
40 class ScriptSelectionGroup
41 {
42 private:
43 selection::ISelectionGroupPtr _group;
44
45 static std::string _emptyStr;
46 public:
47 ScriptSelectionGroup(const selection::ISelectionGroupPtr& group);
48
49 std::size_t getId();
50 const std::string& getName();
51 void setName(const std::string& name);
52 void addNode(const ScriptSceneNode& node);
53 void removeNode(const scene::INodePtr& node);
54 std::size_t size();
55 void setSelected(int selected);
56 void foreachNode(SelectionGroupVisitor& visitor);
57 };
58
59 class SelectionGroupInterface :
60 public IScriptInterface
61 {
62 public:
63 ScriptSelectionGroup createSelectionGroup();
64 ScriptSelectionGroup getSelectionGroup(std::size_t id);
65 ScriptSelectionGroup findOrCreateSelectionGroup(std::size_t id);
66 void setGroupSelected(std::size_t id, int selected);
67 void deleteAllSelectionGroups();
68 void deleteSelectionGroup(std::size_t id);
69
70 // IScriptInterface implementation
71 void registerInterface(py::module& scope, py::dict& globals) override;
72 };
73
74 } // namespace script