mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Add support for rendering disallowed areas
This commit is contained in:
parent
f75c2db13c
commit
e6bd9f8cc6
2 changed files with 45 additions and 1 deletions
|
@ -24,6 +24,9 @@ class BuildVolume(SceneNode):
|
||||||
self._grid_mesh = None
|
self._grid_mesh = None
|
||||||
self._grid_material = None
|
self._grid_material = None
|
||||||
|
|
||||||
|
self._disallowed_areas = []
|
||||||
|
self._disallowed_area_mesh = None
|
||||||
|
|
||||||
def setWidth(self, width):
|
def setWidth(self, width):
|
||||||
self._width = width
|
self._width = width
|
||||||
|
|
||||||
|
@ -33,6 +36,9 @@ class BuildVolume(SceneNode):
|
||||||
def setDepth(self, depth):
|
def setDepth(self, depth):
|
||||||
self._depth = depth
|
self._depth = depth
|
||||||
|
|
||||||
|
def setDisallowedAreas(self, areas):
|
||||||
|
self._disallowed_areas = areas
|
||||||
|
|
||||||
def render(self, renderer):
|
def render(self, renderer):
|
||||||
if not self.getMeshData():
|
if not self.getMeshData():
|
||||||
return True
|
return True
|
||||||
|
@ -51,6 +57,8 @@ class BuildVolume(SceneNode):
|
||||||
|
|
||||||
renderer.queueNode(self, material = self._material, mode = Renderer.RenderLines)
|
renderer.queueNode(self, material = self._material, mode = Renderer.RenderLines)
|
||||||
renderer.queueNode(self, mesh = self._grid_mesh, material = self._grid_material)
|
renderer.queueNode(self, mesh = self._grid_mesh, material = self._grid_material)
|
||||||
|
if self._disallowed_area_mesh:
|
||||||
|
renderer.queueNode(self, mesh = self._disallowed_area_mesh, material = self._material)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def rebuild(self):
|
def rebuild(self):
|
||||||
|
@ -94,3 +102,18 @@ class BuildVolume(SceneNode):
|
||||||
for n in range(0, 6):
|
for n in range(0, 6):
|
||||||
v = self._grid_mesh.getVertex(n)
|
v = self._grid_mesh.getVertex(n)
|
||||||
self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])
|
self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2])
|
||||||
|
|
||||||
|
if self._disallowed_areas:
|
||||||
|
mb = MeshBuilder()
|
||||||
|
for area in self._disallowed_areas:
|
||||||
|
mb.addQuad(
|
||||||
|
area[0],
|
||||||
|
area[1],
|
||||||
|
area[2],
|
||||||
|
area[3],
|
||||||
|
color = Color(0.8, 0.8, 0.8, 1.0)
|
||||||
|
)
|
||||||
|
|
||||||
|
self._disallowed_area_mesh = mb.getData()
|
||||||
|
else:
|
||||||
|
self._disallowed_area_mesh = None
|
||||||
|
|
|
@ -45,6 +45,7 @@ class PrinterApplication(QtApplication):
|
||||||
])
|
])
|
||||||
self._physics = None
|
self._physics = None
|
||||||
self._volume = None
|
self._volume = None
|
||||||
|
self._platform = None
|
||||||
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
||||||
|
|
||||||
def _loadPlugins(self):
|
def _loadPlugins(self):
|
||||||
|
@ -75,7 +76,7 @@ class PrinterApplication(QtApplication):
|
||||||
self._physics = PlatformPhysics(controller)
|
self._physics = PlatformPhysics(controller)
|
||||||
|
|
||||||
root = controller.getScene().getRoot()
|
root = controller.getScene().getRoot()
|
||||||
platform = Platform(root)
|
self._platform = Platform(root)
|
||||||
|
|
||||||
self._volume = BuildVolume(root)
|
self._volume = BuildVolume(root)
|
||||||
|
|
||||||
|
@ -233,8 +234,28 @@ class PrinterApplication(QtApplication):
|
||||||
self._volume.setWidth(machine.getSettingValueByKey('machine_width'))
|
self._volume.setWidth(machine.getSettingValueByKey('machine_width'))
|
||||||
self._volume.setHeight(machine.getSettingValueByKey('machine_height'))
|
self._volume.setHeight(machine.getSettingValueByKey('machine_height'))
|
||||||
self._volume.setDepth(machine.getSettingValueByKey('machine_depth'))
|
self._volume.setDepth(machine.getSettingValueByKey('machine_depth'))
|
||||||
|
|
||||||
|
disallowed_areas = machine.getSettingValueByKey('machine_disallowed_areas')
|
||||||
|
areas = []
|
||||||
|
if disallowed_areas:
|
||||||
|
|
||||||
|
for area in disallowed_areas:
|
||||||
|
polygon = []
|
||||||
|
polygon.append(Vector(area[0][0], 0.1, area[0][1]))
|
||||||
|
polygon.append(Vector(area[1][0], 0.1, area[1][1]))
|
||||||
|
polygon.append(Vector(area[2][0], 0.1, area[2][1]))
|
||||||
|
polygon.append(Vector(area[3][0], 0.1, area[3][1]))
|
||||||
|
areas.append(polygon)
|
||||||
|
self._volume.setDisallowedAreas(areas)
|
||||||
|
|
||||||
self._volume.rebuild()
|
self._volume.rebuild()
|
||||||
|
|
||||||
|
offset = machine.getSettingValueByKey('machine_platform_offset')
|
||||||
|
if offset:
|
||||||
|
self._platform.setPosition(Vector(offset[0], offset[1], offset[2]))
|
||||||
|
else:
|
||||||
|
self._platform.setPosition(Vector(0.0, 0.0, 0.0))
|
||||||
|
|
||||||
removableDrivesChanged = pyqtSignal()
|
removableDrivesChanged = pyqtSignal()
|
||||||
|
|
||||||
@pyqtProperty("QStringList", notify = removableDrivesChanged)
|
@pyqtProperty("QStringList", notify = removableDrivesChanged)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue