forked from youen/assembly_handbook
Improved performances and fixed bugs
This commit is contained in:
parent
25c5149e9f
commit
e5c06a5796
@ -32,7 +32,8 @@ class AHB_New_Step:
|
||||
|
||||
if prev_view is None:
|
||||
step_number = 1
|
||||
keep_updated = False
|
||||
keep_updated = True
|
||||
raster_view = True
|
||||
template_file_name = freecad_path + '/share/Mod/TechDraw/Templates/A4_Landscape_blank.svg'
|
||||
parent_group = None
|
||||
else:
|
||||
@ -41,6 +42,12 @@ class AHB_New_Step:
|
||||
if prev_page_group is not None:
|
||||
parent_group = prev_page_group.getParentGroup()
|
||||
keep_updated = prev_page.KeepUpdated
|
||||
try:
|
||||
raster_view = prev_page.Assembly_handbook_RasterView
|
||||
except:
|
||||
raster_view = True
|
||||
if raster_view:
|
||||
keep_updated = False
|
||||
template_file_name = prev_page.Template.Template
|
||||
numbers = re.findall(r'\d+', prev_page.Label)
|
||||
if len(numbers) == 0: prev_number = 0
|
||||
@ -65,6 +72,9 @@ class AHB_New_Step:
|
||||
view.Perspective = False
|
||||
view.addProperty("App::PropertyString", "Assembly_handbook_PreviousStepView", "Assembly_handbook")
|
||||
view.addProperty("App::PropertyBool", "Assembly_handbook_RasterView", "Assembly_handbook")
|
||||
view.Assembly_handbook_RasterView = raster_view
|
||||
if raster_view:
|
||||
view.Visibility = False
|
||||
if prev_view is None:
|
||||
try:
|
||||
workbench.techDrawExtensions.setCurrentViewDirection(view)
|
||||
@ -81,7 +91,11 @@ class AHB_New_Step:
|
||||
view.XSource = prev_view.XSource
|
||||
|
||||
page.addView(view)
|
||||
view.recompute()
|
||||
|
||||
if raster_view:
|
||||
view.purgeTouched()
|
||||
else:
|
||||
view.recompute()
|
||||
|
||||
# search for views after the prev view to relink them after the new view (i.e. we insert the new view as an intermediate step)
|
||||
# TODO: re-number next steps if needed
|
||||
|
@ -54,28 +54,29 @@ class AHB_View_Annotate:
|
||||
|
||||
# Create a new balloon if needed
|
||||
if balloon is None:
|
||||
partName = partLink.Name
|
||||
if workbench.techDrawExtensions.isNewPartInView(view, partLink):
|
||||
partName = partLink.Name
|
||||
|
||||
balloonName = partName + "_Balloon"
|
||||
balloonName = partName + "_Balloon"
|
||||
|
||||
balloon = doc.addObject("TechDraw::DrawViewBalloon", balloonName)
|
||||
balloon.SourceView = overlay_view
|
||||
balloon = doc.addObject("TechDraw::DrawViewBalloon", balloonName)
|
||||
balloon.SourceView = overlay_view
|
||||
|
||||
balloon.addProperty("App::PropertyXLink", "Assembly_handbook_Source", "Assembly_handbook")
|
||||
balloon.Assembly_handbook_Source = (partLink, partLink.Name)
|
||||
balloon.addProperty("App::PropertyXLink", "Assembly_handbook_Source", "Assembly_handbook")
|
||||
balloon.Assembly_handbook_Source = (partLink, partLink.Name)
|
||||
|
||||
balloon.addProperty("App::PropertyFloat", "Assembly_handbook_OriginOffsetX", "Assembly_handbook")
|
||||
balloon.addProperty("App::PropertyFloat", "Assembly_handbook_OriginOffsetY", "Assembly_handbook")
|
||||
balloon.addProperty("App::PropertyFloat", "Assembly_handbook_OriginOffsetX", "Assembly_handbook")
|
||||
balloon.addProperty("App::PropertyFloat", "Assembly_handbook_OriginOffsetY", "Assembly_handbook")
|
||||
|
||||
page.addView(balloon)
|
||||
page.addView(balloon)
|
||||
|
||||
workbench.techDrawExtensions.updateBalloon(balloon)
|
||||
workbench.techDrawExtensions.updateBalloon(balloon)
|
||||
|
||||
balloon.X = int(balloon.OriginX) + 20
|
||||
balloon.Y = int(balloon.OriginY) + 20
|
||||
balloon.X = int(balloon.OriginX) + 20
|
||||
balloon.Y = int(balloon.OriginY) + 20
|
||||
|
||||
if not workbench.techDrawExtensions.isNewPartInView(view, partLink):
|
||||
balloon.ViewObject.Visibility = False
|
||||
if not workbench.techDrawExtensions.isNewPartInView(view, partLink):
|
||||
balloon.ViewObject.Visibility = False
|
||||
else:
|
||||
workbench.techDrawExtensions.updateBalloon(balloon)
|
||||
|
||||
|
@ -183,7 +183,8 @@ class RasterView:
|
||||
self.image_view.Assembly_handbook_ViewVolumeHeight = viewVolume.getHeight()
|
||||
self.image_view.Assembly_handbook_ViewVolumeDepth = viewVolume.getDepth()
|
||||
|
||||
docView.saveImage(self.image_file_name, 4096, 4096, "#ffffff")
|
||||
max_res = 4096
|
||||
docView.saveImage(self.image_file_name, int(min(max_res, viewVolume.getWidth() * view.Scale * 10)), int(min(max_res, viewVolume.getHeight() * view.Scale * 10)), "#ffffff")
|
||||
|
||||
finally:
|
||||
for obj, props in objects_to_reset.items():
|
||||
|
@ -150,7 +150,7 @@ class TechDrawExtensions:
|
||||
overlay_frame = App.ActiveDocument.addObject("Part::Part2DObjectPython", overlay_frame_name)
|
||||
Draft.Wire(overlay_frame)
|
||||
pos = raster_view.projectImageViewPointTo3D(App.Vector(0,0,0))
|
||||
pos2 = raster_view.projectImageViewPointTo3D(App.Vector(0,0.0001,1))
|
||||
pos2 = raster_view.projectImageViewPointTo3D(App.Vector(0.001,0.001,1))
|
||||
overlay_frame.Points = [pos, pos2]
|
||||
Draft.ViewProviderWire(overlay_frame.ViewObject)
|
||||
overlay_frame.recompute()
|
||||
@ -161,7 +161,7 @@ class TechDrawExtensions:
|
||||
overlay_frame2 = App.ActiveDocument.addObject("Part::Part2DObjectPython", overlay_frame2_name)
|
||||
Draft.Wire(overlay_frame2)
|
||||
pos = raster_view.projectImageViewPointTo3D(App.Vector(1,1,0))
|
||||
pos2 = raster_view.projectImageViewPointTo3D(App.Vector(1,1.0001,1))
|
||||
pos2 = raster_view.projectImageViewPointTo3D(App.Vector(1.001,1.001,1))
|
||||
overlay_frame2.Points = [pos, pos2]
|
||||
Draft.ViewProviderWire(overlay_frame2.ViewObject)
|
||||
overlay_frame2.recompute()
|
||||
@ -205,7 +205,6 @@ class TechDrawExtensions:
|
||||
balloon.ViewObject.Visibility = old_Visibility
|
||||
balloon.recompute()
|
||||
|
||||
page.KeepUpdated = True # once we have hidden the source view, there should be no performance issue
|
||||
overlay.recompute()
|
||||
page.recompute()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user