mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Support solid line annotations using curve data
This commit is contained in:
@@ -867,33 +867,13 @@ class SvgWriter():
|
|||||||
'dominant-baseline': 'middle'
|
'dominant-baseline': 'middle'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if self.ifc_cutter.hidden_obj:
|
for obj in self.ifc_cutter.hidden_objs:
|
||||||
matrix_world = self.ifc_cutter.hidden_obj.matrix_world
|
self.draw_line_annotation(obj, ['hidden'])
|
||||||
for edge in self.ifc_cutter.hidden_obj.data.edges:
|
|
||||||
classes = ['annotation', 'hidden']
|
|
||||||
v0_global = matrix_world @ self.ifc_cutter.hidden_obj.data.vertices[edge.vertices[0]].co.xyz
|
|
||||||
v1_global = matrix_world @ self.ifc_cutter.hidden_obj.data.vertices[edge.vertices[1]].co.xyz
|
|
||||||
v0 = self.project_point_onto_camera(v0_global)
|
|
||||||
v1 = self.project_point_onto_camera(v1_global)
|
|
||||||
start = Vector(((x_offset + v0.x), (y_offset - v0.y)))
|
|
||||||
end = Vector(((x_offset + v1.x), (y_offset - v1.y)))
|
|
||||||
vector = end - start
|
|
||||||
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
|
||||||
end=tuple(end * self.scale), class_=' '.join(classes)))
|
|
||||||
line['stroke-dasharray'] = '3, 2'
|
|
||||||
|
|
||||||
if self.ifc_cutter.leader_obj:
|
for obj in self.ifc_cutter.solid_objs:
|
||||||
matrix_world = self.ifc_cutter.leader_obj.matrix_world
|
self.draw_line_annotation(obj, ['solid'])
|
||||||
for spline in self.ifc_cutter.leader_obj.data.splines:
|
|
||||||
classes = ['annotation', 'leader']
|
self.draw_line_annotation(self.ifc_cutter.leader_obj, ['leader'])
|
||||||
points = self.get_spline_points(spline)
|
|
||||||
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in points]
|
|
||||||
d = ' '.join(['L {} {}'.format(
|
|
||||||
(x_offset + p.x) * self.scale, (y_offset - p.y) * self.scale)
|
|
||||||
for p in projected_points])
|
|
||||||
d = 'M{}'.format(d[1:])
|
|
||||||
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
|
||||||
path['marker-end'] = 'url(#leader-marker)'
|
|
||||||
|
|
||||||
if self.ifc_cutter.plan_level_obj:
|
if self.ifc_cutter.plan_level_obj:
|
||||||
for spline in self.ifc_cutter.plan_level_obj.data.splines:
|
for spline in self.ifc_cutter.plan_level_obj.data.splines:
|
||||||
@@ -971,6 +951,22 @@ class SvgWriter():
|
|||||||
|
|
||||||
self.draw_text_annotations()
|
self.draw_text_annotations()
|
||||||
|
|
||||||
|
def draw_line_annotation(self, obj, classes):
|
||||||
|
# TODO: properly scope these offsets
|
||||||
|
x_offset = self.raw_width / 2
|
||||||
|
y_offset = self.raw_height / 2
|
||||||
|
|
||||||
|
classes.extend(['annotation'])
|
||||||
|
matrix_world = obj.matrix_world
|
||||||
|
for spline in obj.data.splines:
|
||||||
|
points = self.get_spline_points(spline)
|
||||||
|
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in points]
|
||||||
|
d = ' '.join(['L {} {}'.format(
|
||||||
|
(x_offset + p.x) * self.scale, (y_offset - p.y) * self.scale)
|
||||||
|
for p in projected_points])
|
||||||
|
d = 'M{}'.format(d[1:])
|
||||||
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
||||||
|
|
||||||
def draw_text_annotations(self):
|
def draw_text_annotations(self):
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
y_offset = self.raw_height / 2
|
y_offset = self.raw_height / 2
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; }
|
.cut { fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.35; }
|
||||||
.background { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
.background { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
||||||
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
.annotation { fill: none; stroke: black; stroke-linecap: 'round'; stroke-width: 0.25; }
|
||||||
|
.hidden { stroke-dasharray: 3, 2; }
|
||||||
|
.leader { marker-end: url(#leader-marker); }
|
||||||
|
.solid {}
|
||||||
|
|||||||
@@ -1580,7 +1580,8 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.stair_obj = None
|
ifc_cutter.stair_obj = None
|
||||||
ifc_cutter.dimension_obj = None
|
ifc_cutter.dimension_obj = None
|
||||||
ifc_cutter.equal_obj = None
|
ifc_cutter.equal_obj = None
|
||||||
ifc_cutter.hidden_obj = None
|
ifc_cutter.hidden_objs = []
|
||||||
|
ifc_cutter.solid_objs = []
|
||||||
ifc_cutter.plan_level_obj = None
|
ifc_cutter.plan_level_obj = None
|
||||||
ifc_cutter.section_level_obj = None
|
ifc_cutter.section_level_obj = None
|
||||||
ifc_cutter.grid_objs = []
|
ifc_cutter.grid_objs = []
|
||||||
@@ -1595,7 +1596,9 @@ class CutSection(bpy.types.Operator):
|
|||||||
elif 'Dimension' in obj.name:
|
elif 'Dimension' in obj.name:
|
||||||
ifc_cutter.dimension_obj = obj
|
ifc_cutter.dimension_obj = obj
|
||||||
elif 'Hidden' in obj.name:
|
elif 'Hidden' in obj.name:
|
||||||
ifc_cutter.hidden_obj = obj
|
ifc_cutter.hidden_objs.append(obj)
|
||||||
|
elif 'Solid' in obj.name:
|
||||||
|
ifc_cutter.solid_objs.append(obj)
|
||||||
elif 'IfcGrid' in obj.name:
|
elif 'IfcGrid' in obj.name:
|
||||||
ifc_cutter.grid_objs.append(obj)
|
ifc_cutter.grid_objs.append(obj)
|
||||||
elif 'Plan Level' in obj.name:
|
elif 'Plan Level' in obj.name:
|
||||||
@@ -1841,17 +1844,8 @@ class SetViewPreset2(bpy.types.Operator):
|
|||||||
bpy.context.scene.display.shading.light = 'FLAT'
|
bpy.context.scene.display.shading.light = 'FLAT'
|
||||||
bpy.context.scene.display.shading.color_type = 'SINGLE'
|
bpy.context.scene.display.shading.color_type = 'SINGLE'
|
||||||
bpy.context.scene.display.shading.single_color = (1, 1, 1)
|
bpy.context.scene.display.shading.single_color = (1, 1, 1)
|
||||||
bpy.context.scene.use_nodes = True
|
bpy.context.scene.view_settings.use_curve_mapping = True
|
||||||
rgb_curves = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeCurveRGB')
|
bpy.context.scene.view_settings.curve_mapping.curves[3].points.new(.4, 0) # Increase black contrast
|
||||||
rgb_curves.mapping.curves[3].points.new(.4, 0) # Increase black contrast
|
|
||||||
rgb_curves.mapping.update()
|
|
||||||
for node in bpy.context.scene.node_tree.nodes:
|
|
||||||
if node.type == 'R_LAYERS':
|
|
||||||
render_layers = node
|
|
||||||
elif node.type == 'COMPOSITE':
|
|
||||||
composite = node
|
|
||||||
bpy.context.scene.node_tree.links.new(render_layers.outputs[0], rgb_curves.inputs[1])
|
|
||||||
bpy.context.scene.node_tree.links.new(rgb_curves.outputs[0], composite.inputs[0])
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user