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

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(Resources.getMesh("ultimaker2_platform.stl"), self.getStorageDevice('local')))

        mesh2 = SceneNode(mesh)
        mesh2.setMeshData(self.getMeshFileHandler().read(Resources.getMesh("sphere.obj"), self.getStorageDevice('local')))
        mesh2.translate(Vector(0, 50, 0))
        mesh2.scale(20)

        camera = Camera('3d', root)
        camera.translate(Vector(0, 150, 150))
        proj = Matrix()
        proj.setOrtho(-200, 200, -200, 200, -500, 500)
        camera.setProjectionMatrix(proj)
        camera.rotateByAngleAxis(-45, Vector(1, 0, 0))

        camera = Camera('left', root)
        camera.translate(Vector(150, 0, 0))
        camera.rotateByAngleAxis(-90, Vector(0, 1, 0))
        proj = Matrix()
        proj.setOrtho(-200, 200, -200, 200, -500, 500)
        camera.setProjectionMatrix(proj)
        camera.setLocked(True)

        camera = Camera('top', root)
        camera.translate(Vector(0, 150, 0))
        camera.rotateByAngleAxis(-90, Vector(1, 0, 0))
        proj = Matrix()
        proj.setOrtho(-200, 200, -200, 200, -500, 500)
        camera.setProjectionMatrix(proj)
        camera.setLocked(True)

        camera = Camera('front', root)
        camera.translate(Vector(0, 0, 150))
        proj = Matrix()
        proj.setOrtho(-200, 200, -200, 200, -500, 500)
        camera.setProjectionMatrix(proj)
        camera.setLocked(True)

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

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

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

    def registerObjects(self, engine):
        pass

@@ -1120,17 +1120,21 @@
 h(%22s
-phere.obj
+implecube.stl
 %22), 
@@ -1197,20 +1197,21 @@
 (Vector(
+3
 0, 
-5
+3
 0, 0))%0A 
@@ -1229,18 +1229,281 @@
 2.scale(
-20
+10)%0A%0A        mesh3 = SceneNode(mesh)%0A        mesh3.setMeshData(self.getMeshFileHandler().read(Resources.getMesh(%22sphere.obj%22), self.getStorageDevice('local')))%0A        mesh3.translate(Vector(0, 0, 0))%0A%0A        self.getRenderer().setLightPosition(Vector(0, 150, 150)
 )%0A%0A     
@@ -1623,40 +1623,34 @@
 .set
-Ortho(-200, 200, -200, 200, -500
+Perspective(45, 640/480, 1
 , 50
@@ -1712,29 +1712,66 @@
 era.
-rotateByAngleAxis(-45
+setPerspective(True)%0A        camera.lookAt(Vector(0, 0, 0)
 , Ve
@@ -1771,28 +1771,28 @@
  0), Vector(
-1, 0
+0, 1
 , 0))%0A%0A     
@@ -1865,64 +1865,10 @@
 50, 
+5
 0
-, 0))%0A        camera.rotateByAngleAxis(-90, Vector(0, 1
 , 0)
@@ -1929,36 +1929,33 @@
 200, -200, 200, 
--500
+1
 , 500)%0A        c
@@ -1978,32 +1978,88 @@
 ionMatrix(proj)%0A
+        camera.lookAt(Vector(0, 0, 0), Vector(0, 1, 0))%0A
         camera.s
@@ -2159,63 +2159,8 @@
 0))%0A
-        camera.rotateByAngleAxis(-90, Vector(1, 0, 0))%0A
     
@@ -2215,36 +2215,33 @@
 200, -200, 200, 
--500
+1
 , 500)%0A        c
@@ -2264,32 +2264,88 @@
 ionMatrix(proj)%0A
+        camera.lookAt(Vector(0, 0, 0), Vector(0, 1, 0))%0A
         camera.s
@@ -2434,16 +2434,17 @@
 ctor(0, 
+5
 0, 150))
@@ -2516,12 +2516,9 @@
 00, 
--500
+1
 , 50
@@ -2553,32 +2553,88 @@
 ionMatrix(proj)%0A
+        camera.lookAt(Vector(0, 0, 0), Vector(0, 1, 0))%0A
         camera.s

Fix the cameras etc of the default setup