mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 16:48:58 +08:00
Merge pull request #4216 from Ultimaker/feature_adjust_zoom_to_printer_size
Adjust maximum zoom to printer size
This commit is contained in:
commit
3d9c7f7eb5
@ -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()
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user