mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 21:19:01 +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.Scene.CuraSceneNode import CuraSceneNode
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
from UM.Application import Application #To modify the maximum zoom level.
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Scene.Platform import Platform
|
from UM.Scene.Platform import Platform
|
||||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||||
@ -170,6 +171,12 @@ class BuildVolume(SceneNode):
|
|||||||
if shape:
|
if shape:
|
||||||
self._shape = 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]:
|
def getDisallowedAreas(self) -> List[Polygon]:
|
||||||
return self._disallowed_areas
|
return self._disallowed_areas
|
||||||
|
|
||||||
@ -552,6 +559,10 @@ class BuildVolume(SceneNode):
|
|||||||
if self._engine_ready:
|
if self._engine_ready:
|
||||||
self.rebuild()
|
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):
|
def _onEngineCreated(self):
|
||||||
self._engine_ready = True
|
self._engine_ready = True
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
@ -50,7 +50,8 @@ class CuraActions(QObject):
|
|||||||
scene = cura.CuraApplication.CuraApplication.getInstance().getController().getScene()
|
scene = cura.CuraApplication.CuraApplication.getInstance().getController().getScene()
|
||||||
camera = scene.getActiveCamera()
|
camera = scene.getActiveCamera()
|
||||||
if camera:
|
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.setPerspective(True)
|
||||||
camera.lookAt(Vector(0, 0, 0))
|
camera.lookAt(Vector(0, 0, 0))
|
||||||
|
|
||||||
|
@ -780,7 +780,7 @@ class CuraApplication(QtApplication):
|
|||||||
# Initialize camera
|
# Initialize camera
|
||||||
root = controller.getScene().getRoot()
|
root = controller.getScene().getRoot()
|
||||||
camera = Camera("3d", root)
|
camera = Camera("3d", root)
|
||||||
camera.setPosition(Vector(-80, 250, 700))
|
camera.setPosition(Vector(-80, 250, 700) * self.getBuildVolume().getDiagonalSize() / 375)
|
||||||
camera.setPerspective(True)
|
camera.setPerspective(True)
|
||||||
camera.lookAt(Vector(0, 0, 0))
|
camera.lookAt(Vector(0, 0, 0))
|
||||||
controller.getScene().setActiveCamera("3d")
|
controller.getScene().setActiveCamera("3d")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user