from Cura.Qt.QtApplication import QtApplication
from Cura.Scene.SceneNode import SceneNode
from Cura.Scene.Camera import Camera
from Cura.Math.Vector import Vector

import os.path

class PrinterApplication(QtApplication):
    def __init__(self):
        super(PrinterApplication, self).__init__()
        
    def run(self):
        self._plugin_registry.loadPlugins({ "type": "Logger"})
        self._plugin_registry.loadPlugins({ "type": "StorageDevice" })
        self._plugin_registry.loadPlugins({ "type": "View" })
        self._plugin_registry.loadPlugins({ "type": "MeshHandler" })
        self._plugin_registry.loadPlugins({ "type": "Tool" })
        
        self.getController().setActiveView("MeshView")

        root = self.getController().getScene().getRoot()
        mesh = SceneNode(root)
        mesh.setMeshData(self.getMeshFileHandler().read("plugins/FileHandlers/STLReader/simpleTestCube.stl",self.getStorageDevice('local')))

        camera = Camera('3d', root)
        camera.translate(Vector(0, 5, 5))
        camera.rotateByAngleAxis(45, Vector(1, 0, 0))

        camera = Camera('left', root)
        camera.translate(Vector(5, 0, 0))
        camera.rotateByAngleAxis(-90, Vector(0, 1, 0))
        camera.setLocked(True)

        self.getController().getScene().setActiveCamera('3d')

        self.log('i',"Application started")

        self.setMainQml(os.path.dirname(__file__) + "/Printer.qml")
        self.initializeEngine()

        if self._engine.rootObjects:
            self.exec_()

    def registerObjects(self, engine):
        pass

@@ -156,16 +156,89 @@
 t Vector
+%0Afrom Cura.Math.Matrix import Matrix%0Afrom Cura.Resources import Resources
 %0A%0Aimport
@@ -931,91 +931,307 @@
 ead(
-%22plugins/FileHandlers/STLReader/simpleTestCube.stl%22,self.getStorageDevice('local'))
+Resources.getMesh(%22ultimaker2_platform.stl%22), self.getStorageDevice('local')))%0A%0A        mesh2 = SceneNode(mesh)%0A        mesh2.setMeshData(self.getMeshFileHandler().read(Resources.getMesh(%22sphere.obj%22), self.getStorageDevice('local')))%0A        mesh2.translate(Vector(0, 50, 0))%0A        mesh2.scale(20
 )%0A%0A 
@@ -1304,15 +1304,139 @@
 (0, 
-5, 5
+150, 150
 ))%0A
+        proj = Matrix()%0A        proj.setOrtho(-200, 200, -200, 200, -500, 500)%0A        camera.setProjectionMatrix(proj)%0A
     
@@ -1464,16 +1464,17 @@
 gleAxis(
+-
 45, Vect
@@ -1557,17 +1557,19 @@
 (Vector(
-5
+150
 , 0, 0))
@@ -1624,32 +1624,675 @@
  1, 0))%0A        
+proj = Matrix()%0A        proj.setOrtho(-200, 200, -200, 200, -500, 500)%0A        camera.setProjectionMatrix(proj)%0A        camera.setLocked(True)%0A%0A        camera = Camera('top', root)%0A        camera.translate(Vector(0, 150, 0))%0A        camera.rotateByAngleAxis(-90, Vector(1, 0, 0))%0A        proj = Matrix()%0A        proj.setOrtho(-200, 200, -200, 200, -500, 500)%0A        camera.setProjectionMatrix(proj)%0A        camera.setLocked(True)%0A%0A        camera = Camera('front', root)%0A        camera.translate(Vector(0, 0, 150))%0A        proj = Matrix()%0A        proj.setOrtho(-200, 200, -200, 200, -500, 500)%0A        camera.setProjectionMatrix(proj)%0A        
 camera.setLocked
@@ -2363,53 +2363,8 @@
 '3d'
-)%0A%0A        self.log('i',%22Application started%22
 )%0A%0A 

Set up more scene stuff in PrinterApplication