| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <pybind11/pybind11.h> |
| 4 |
|
| 5 |
#include "iscript.h" |
| 6 |
#include "iscriptinterface.h" |
| 7 |
#include "ilayer.h" |
| 8 |
|
| 9 |
#include "SceneGraphInterface.h" |
| 10 |
|
| 11 |
namespace script |
| 12 |
{ |
| 13 |
|
| 14 |
class LayerVisitor |
| 15 |
{ |
| 16 |
public: |
| 17 |
virtual ~LayerVisitor() {} |
| 18 |
virtual void visit(int layerID, const std::string& layerName) = 0; |
| 19 |
}; |
| 20 |
|
| 21 |
// Wrap around the LayerVisitor interface |
| 22 |
class LayerVisitorWrapper : |
| 23 |
public LayerVisitor |
| 24 |
{ |
| 25 |
public: |
| 26 |
void visit(int layerID, const std::string& layerName) override |
| 27 |
{ |
| 28 |
// Wrap this method to python |
| 29 |
PYBIND11_OVERLOAD_PURE( |
| 30 |
void, /* Return type */ |
| 31 |
LayerVisitor, /* Parent class */ |
| 32 |
visit, /* Name of function in C++ (must match Python name) */ |
| 33 |
layerID, /* Argument(s) */ |
| 34 |
layerName |
| 35 |
); |
| 36 |
} |
| 37 |
}; |
| 38 |
|
| 39 |
class LayerInterface : |
| 40 |
public IScriptInterface |
| 41 |
{ |
| 42 |
public: |
| 43 |
int createLayer(const std::string& name); |
| 44 |
int createLayer(const std::string& name, int layerID); |
| 45 |
void deleteLayer(const std::string& name); |
| 46 |
void foreachLayer(LayerVisitor& visitor); |
| 47 |
int getLayerID(const std::string &name); |
| 48 |
std::string getLayerName(int layerID); |
| 49 |
bool layerExists(int layerID); |
| 50 |
bool renameLayer(int layerID, const std::string& newLayerName); |
| 51 |
int getFirstVisibleLayer(); |
| 52 |
int getActiveLayer(); |
| 53 |
void setActiveLayer(int layerID); |
| 54 |
bool layerIsVisible(const std::string& layerName); |
| 55 |
bool layerIsVisible(int layerID); |
| 56 |
void setLayerVisibility(const std::string& layerName, bool visible); |
| 57 |
void setLayerVisibility(int layerID, bool visible); |
| 58 |
void addSelectionToLayer(const std::string& layerName); |
| 59 |
void addSelectionToLayer(int layerID); |
| 60 |
void moveSelectionToLayer(const std::string& layerName); |
| 61 |
void moveSelectionToLayer(int layerID); |
| 62 |
void removeSelectionFromLayer(const std::string& layerName); |
| 63 |
void removeSelectionFromLayer(int layerID); |
| 64 |
void setSelected(int layerID, bool selected); |
| 65 |
int getParentLayer(int layerId); |
| 66 |
void setParentLayer(int childLayerId, int parentLayerId); |
| 67 |
|
| 68 |
// IScriptInterface implementation |
| 69 |
void registerInterface(py::module& scope, py::dict& globals) override; |
| 70 |
}; |
| 71 |
|
| 72 |
} // namespace script |