Browse Source

Added possibility to manually define a view volume, and fixed some bugs

master
Youen 1 year ago
parent
commit
8a9c6d8069
  1. 23
      ahb_raster_view.py

23
ahb_raster_view.py

@ -125,6 +125,7 @@ class RasterView:
duplicated_parts = {}
try:
# construct new scene with links to the parts we want
sceneGroup = tmp_doc.addObject('App::DocumentObjectGroup', 'Scene')
prev_parts = []
new_parts = []
for part in view.XSource:
@ -150,7 +151,7 @@ class RasterView:
for other_part in other_parts:
other_objects = self._flatten_objects_tree([other_part])
for obj in self._flatten_objects_tree([link]):
if obj in other_objects:
if self._should_render(obj) and obj in other_objects:
is_conflicting = True
if is_conflicting:
@ -162,6 +163,9 @@ class RasterView:
part_copy.Label = part.Label
duplicated_parts[link.LinkedObject] = part_copy
link.LinkedObject = part_copy
part_copy.ViewObject.Visibility = False
sceneGroup.addObject(link)
if is_new_part:
new_parts.append(link)
@ -200,7 +204,22 @@ class RasterView:
rot *= coin.SbRotation(coin.SbVec3f(0,0,1), coin.SbVec3f(view.Direction.x,view.Direction.y,view.Direction.z))
cam.orientation.setValue(rot)
tmp_doc_view.fitAll()
targetViewVolume = None
try:
targetViewVolume = view.Assembly_handbook_ViewVolume
except:
pass
if targetViewVolume is None:
tmp_doc_view.fitAll()
else:
sceneGroup.ViewObject.Visibility = False
viewVolumeLink = tmp_doc.addObject('App::Link', 'ViewVolume')
viewVolumeLink.LinkedObject = targetViewVolume
viewVolumeLink.Placement = targetViewVolume.Placement
tmp_doc_view.fitAll()
tmp_doc.removeObject(viewVolumeLink.Name)
sceneGroup.ViewObject.Visibility = True
viewVolume = cam.getViewVolume(0.0)
self.image_view.Assembly_handbook_ViewVolumeWidth = viewVolume.getWidth()

Loading…
Cancel
Save