| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <pybind11/pybind11.h> |
| 4 |
|
| 5 |
#include "iscript.h" |
| 6 |
#include "iscriptinterface.h" |
| 7 |
#include "iselectionset.h" |
| 8 |
|
| 9 |
namespace script |
| 10 |
{ |
| 11 |
|
| 12 |
// ========== SelectionSet Handling ========== |
| 13 |
|
| 14 |
class ScriptSelectionSet |
| 15 |
{ |
| 16 |
private: |
| 17 |
selection::ISelectionSetPtr _set; |
| 18 |
|
| 19 |
static std::string _emptyStr; |
| 20 |
public: |
| 21 |
ScriptSelectionSet(const selection::ISelectionSetPtr& set); |
| 22 |
|
| 23 |
const std::string& getName(); |
| 24 |
bool empty(); |
| 25 |
void select(); |
| 26 |
void deselect(); |
| 27 |
void clear(); |
| 28 |
void assignFromCurrentScene(); |
| 29 |
}; |
| 30 |
|
| 31 |
// Wrap around the ISelectionSetManager::Visitor interface |
| 32 |
class SelectionSetVisitorWrapper : |
| 33 |
public selection::ISelectionSetManager::Visitor |
| 34 |
{ |
| 35 |
public: |
| 36 |
void visit(const selection::ISelectionSetPtr& set) override |
| 37 |
{ |
| 38 |
// Wrap this method to python |
| 39 |
PYBIND11_OVERLOAD_PURE( |
| 40 |
void, /* Return type */ |
| 41 |
selection::ISelectionSetManager::Visitor, /* Parent class */ |
| 42 |
visit, /* Name of function in C++ (must match Python name) */ |
| 43 |
ScriptSelectionSet(set) /* Argument(s) */ |
| 44 |
); |
| 45 |
} |
| 46 |
}; |
| 47 |
|
| 48 |
class SelectionSetInterface : |
| 49 |
public IScriptInterface |
| 50 |
{ |
| 51 |
public: |
| 52 |
// SelectionSetManager wrappers |
| 53 |
void foreachSelectionSet(selection::ISelectionSetManager::Visitor& visitor); |
| 54 |
ScriptSelectionSet createSelectionSet(const std::string& name); |
| 55 |
void deleteSelectionSet(const std::string& name); |
| 56 |
void deleteAllSelectionSets(); |
| 57 |
ScriptSelectionSet findSelectionSet(const std::string& name); |
| 58 |
|
| 59 |
// IScriptInterface implementation |
| 60 |
void registerInterface(py::module& scope, py::dict& globals) override; |
| 61 |
}; |
| 62 |
|
| 63 |
} // namespace script |