diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 87f0eb543e..5aa3873c89 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 @@ -170,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 @@ -552,6 +559,10 @@ class BuildVolume(SceneNode): if self._engine_ready: self.rebuild() + camera = Application.getInstance().getController().getCameraTool() + if camera: + 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 self.rebuild() 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 df25522be3..23a11a2bb3 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -780,7 +780,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")