From aab0cded0ead3720adc034c57f99d94ee8066702 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Aug 2018 12:02:28 +0200 Subject: [PATCH 1/3] Adjust maximum zoom to printer size Previously the maximum distance you could zoom out was 2000. Now it's variable depending on how large your printer is. I've put it to 5 so that it works out to be approximately the same maximum zoom level for normal sized printers (like 25 cube build volume approximately). This should make it possible to zoom out completely for large sized printers. --- cura/BuildVolume.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 87f0eb543e..667247eac9 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -3,6 +3,7 @@ from cura.Scene.CuraSceneNode import CuraSceneNode from cura.Settings.ExtruderManager import ExtruderManager +from UM.Application import Application #To modify the maximum zoom level. from UM.i18n import i18nCatalog from UM.Scene.Platform import Platform from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator @@ -552,6 +553,11 @@ class BuildVolume(SceneNode): if self._engine_ready: self.rebuild() + diagonal_size = math.sqrt(self._width * self._width + self._height * self._height + self._depth * self._depth) + camera = Application.getInstance().getController().getCameraTool() + if camera: + camera.setZoomRange(min = 1, max = diagonal_size * 5) #You can zoom out up to 5 times the diagonal across your screen (to see models bigger than your volume). + def _onEngineCreated(self): self._engine_ready = True self.rebuild() From da39e842f111206b9c362e4a6f354cc3b9ac06ce Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 15 Aug 2018 09:25:24 +0200 Subject: [PATCH 2/3] Move getting diagonal size out to separate function --- cura/BuildVolume.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 667247eac9..5aa3873c89 100755 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -171,6 +171,12 @@ class BuildVolume(SceneNode): if shape: self._shape = shape + ## Get the length of the 3D diagonal through the build volume. + # + # This gives a sense of the scale of the build volume in general. + def getDiagonalSize(self) -> float: + return math.sqrt(self._width * self._width + self._height * self._height + self._depth * self._depth) + def getDisallowedAreas(self) -> List[Polygon]: return self._disallowed_areas @@ -553,10 +559,9 @@ class BuildVolume(SceneNode): if self._engine_ready: self.rebuild() - diagonal_size = math.sqrt(self._width * self._width + self._height * self._height + self._depth * self._depth) camera = Application.getInstance().getController().getCameraTool() if camera: - camera.setZoomRange(min = 1, max = diagonal_size * 5) #You can zoom out up to 5 times the diagonal across your screen (to see models bigger than your volume). + camera.setZoomRange(min = 1, max = self.getDiagonalSize() * 5) #You can zoom out up to 5 times the diagonal. This gives some space around the volume. def _onEngineCreated(self): self._engine_ready = True From f1a7b23a5ca6b517396b5a51fce28a65fb5fb1c5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 15 Aug 2018 09:52:39 +0200 Subject: [PATCH 3/3] Adjust default position of camera based on diagonal size --- cura/CuraActions.py | 3 ++- cura/CuraApplication.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cura/CuraActions.py b/cura/CuraActions.py index 1b2c6c576c..93a18318df 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -50,7 +50,8 @@ class CuraActions(QObject): scene = cura.CuraApplication.CuraApplication.getInstance().getController().getScene() camera = scene.getActiveCamera() if camera: - camera.setPosition(Vector(-80, 250, 700)) + diagonal_size = cura.CuraApplication.CuraApplication.getInstance().getBuildVolume().getDiagonalSize() + camera.setPosition(Vector(-80, 250, 700) * diagonal_size / 375) camera.setPerspective(True) camera.lookAt(Vector(0, 0, 0)) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 6164fc8756..955bc4df5f 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -776,7 +776,7 @@ class CuraApplication(QtApplication): # Initialize camera root = controller.getScene().getRoot() camera = Camera("3d", root) - camera.setPosition(Vector(-80, 250, 700)) + camera.setPosition(Vector(-80, 250, 700) * self.getBuildVolume().getDiagonalSize() / 375) camera.setPerspective(True) camera.lookAt(Vector(0, 0, 0)) controller.getScene().setActiveCamera("3d")