Merge pull request #4216 from Ultimaker/feature_adjust_zoom_to_printer_size

Adjust maximum zoom to printer size
This commit is contained in:
Diego Prado Gesto 2018-08-15 13:19:46 +02:00 committed by GitHub
commit 3d9c7f7eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -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()

View File

@ -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))

View File

@ -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")