Skip to content

Commit

Permalink
Merge branch 'python_layer_interface'
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 13, 2020
2 parents e27e13c + 76160ca commit 8a91501
Show file tree
Hide file tree
Showing 7 changed files with 477 additions and 1 deletion.
57 changes: 57 additions & 0 deletions install/scripts/test.py
Expand Up @@ -313,3 +313,60 @@ def visit(self, node):
camview = GlobalCameraManager.getActiveView()
print(camview.getCameraOrigin())
camview.setCameraOrigin(dr.Vector3(50,0,50))

# Layer Functionality
def printLayers():
class LayerPrinter(dr.LayerVisitor):
def visit(self, layerID, layerName):
print(layerID, layerName)
layerPrinter = LayerPrinter()
GlobalLayerManager.foreachLayer(layerPrinter)
print("=================")

print("Layers:")
printLayers()

print("Test create")
print(GlobalLayerManager.createLayer("One"))
print(GlobalLayerManager.createLayer("Two"))
print(GlobalLayerManager.createLayer("Forty-two", 42))
print(GlobalLayerManager.createLayer("TwoAgain", 2))
printLayers()

print("Test delete")
print(GlobalLayerManager.deleteLayer("NotALayer"))
print(GlobalLayerManager.deleteLayer("TwoAgain"))
printLayers()

print("Test get")
print(GlobalLayerManager.getLayerID("Forty-two"))
print(GlobalLayerManager.getLayerName(42))

print("Test exists")
print(GlobalLayerManager.layerExists(123))
print(GlobalLayerManager.layerExists(42))

print("Test rename")
print(GlobalLayerManager.renameLayer(42, "Forty-two"))
print(GlobalLayerManager.renameLayer(42, "Two"))
print(GlobalLayerManager.renameLayer(42, "HHGTTG"))

print("Test active")
GlobalLayerManager.setActiveLayer(3)
print(GlobalLayerManager.getActiveLayer())
GlobalLayerManager.setActiveLayer(2)
print(GlobalLayerManager.getActiveLayer())

print("Test visible")
GlobalLayerManager.setLayerVisibility("One", False)
print(GlobalLayerManager.layerIsVisible("One"))
GlobalLayerManager.setLayerVisibility("One", True)
print(GlobalLayerManager.layerIsVisible("One"))

GlobalLayerManager.setLayerVisibility(1, False)
print(GlobalLayerManager.layerIsVisible(1))
GlobalLayerManager.setLayerVisibility(1, True)
print(GlobalLayerManager.layerIsVisible(1))

GlobalLayerManager.setSelected(0, True)
GlobalLayerManager.moveSelectionToLayer(1)
3 changes: 2 additions & 1 deletion plugins/script/Makefile.am
Expand Up @@ -42,4 +42,5 @@ script_la_SOURCES = ScriptingSystem.cpp \
interfaces/SelectionSetInterface.cpp \
interfaces/SelectionGroupInterface.cpp \
interfaces/SoundInterface.cpp \
interfaces/GameInterface.cpp
interfaces/GameInterface.cpp \
interfaces/LayerInterface.cpp
2 changes: 2 additions & 0 deletions plugins/script/ScriptingSystem.cpp
Expand Up @@ -43,6 +43,7 @@
#include "interfaces/SelectionSetInterface.h"
#include "interfaces/SelectionGroupInterface.h"
#include "interfaces/CameraInterface.h"
#include "interfaces/LayerInterface.h"

#include "PythonModule.h"

Expand Down Expand Up @@ -448,6 +449,7 @@ void ScriptingSystem::initialiseModule(const IApplicationContext& ctx)
addInterface("SelectionSetInterface", std::make_shared<SelectionSetInterface>());
addInterface("SelectionGroupInterface", std::make_shared<SelectionGroupInterface>());
addInterface("CameraInterface", std::make_shared<CameraInterface>());
addInterface("LayerInterface", std::make_shared<LayerInterface>());

GlobalCommandSystem().addCommand(
"RunScript",
Expand Down

0 comments on commit 8a91501

Please sign in to comment.