mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 18:16:20 +00:00
Allow arbitrary locations for leaders and section levels.
This commit is contained in:
@@ -787,9 +787,13 @@ class SvgWriter():
|
|||||||
line['stroke-dasharray'] = '3, 2'
|
line['stroke-dasharray'] = '3, 2'
|
||||||
|
|
||||||
if self.ifc_cutter.leader_obj:
|
if self.ifc_cutter.leader_obj:
|
||||||
|
matrix_world = self.ifc_cutter.leader_obj.matrix_world
|
||||||
for spline in self.ifc_cutter.leader_obj.data.splines:
|
for spline in self.ifc_cutter.leader_obj.data.splines:
|
||||||
classes = ['annotation', 'leader']
|
classes = ['annotation', 'leader']
|
||||||
d = ' '.join(['L {} {}'.format((x_offset + p.co.x) * self.scale, (y_offset - p.co.y) * self.scale) for p in spline.points])
|
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in spline.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:])
|
d = 'M{}'.format(d[1:])
|
||||||
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
||||||
path['marker-end'] = 'url(#leader-marker)'
|
path['marker-end'] = 'url(#leader-marker)'
|
||||||
@@ -821,20 +825,23 @@ class SvgWriter():
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
if self.ifc_cutter.section_level_obj:
|
if self.ifc_cutter.section_level_obj:
|
||||||
|
matrix_world = self.ifc_cutter.section_level_obj.matrix_world
|
||||||
for spline in self.ifc_cutter.section_level_obj.data.splines:
|
for spline in self.ifc_cutter.section_level_obj.data.splines:
|
||||||
classes = ['annotation', 'section-level']
|
classes = ['annotation', 'section-level']
|
||||||
d = ' '.join(['L {} {}'.format((x_offset + p.co.x) * self.scale, (y_offset - p.co.y) * self.scale) for p in spline.points])
|
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in spline.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:])
|
d = 'M{}'.format(d[1:])
|
||||||
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
||||||
path['marker-start'] = 'url(#section-level-marker)'
|
path['marker-start'] = 'url(#section-level-marker)'
|
||||||
path['stroke-dasharray'] = '12.5, 3, 3, 3'
|
path['stroke-dasharray'] = '12.5, 3, 3, 3'
|
||||||
text_position = Vector((
|
text_position = Vector((
|
||||||
(x_offset + spline.points[0].co.x) * self.scale,
|
(x_offset + projected_points[0].x) * self.scale,
|
||||||
((y_offset - spline.points[0].co.y) * self.scale) - 3.5
|
((y_offset - projected_points[0].y) * self.scale) - 3.5
|
||||||
))
|
))
|
||||||
# TODO: unhardcode m unit
|
# TODO: unhardcode m unit
|
||||||
rl = ((self.ifc_cutter.section_level_obj.matrix_world @
|
rl = (matrix_world @ spline.points[0].co.xyz).z
|
||||||
spline.points[0].co).xyz + self.ifc_cutter.section_level_obj.location).z
|
|
||||||
self.svg.add(self.svg.text('RL +{:.3f}m'.format(rl), insert=tuple(text_position), **{
|
self.svg.add(self.svg.text('RL +{:.3f}m'.format(rl), insert=tuple(text_position), **{
|
||||||
'font-size': '4.13', # 2.5
|
'font-size': '4.13', # 2.5
|
||||||
'font-family': 'OpenGost Type B TT',
|
'font-family': 'OpenGost Type B TT',
|
||||||
@@ -904,8 +911,8 @@ class SvgWriter():
|
|||||||
if i+1 >= len(spline.points):
|
if i+1 >= len(spline.points):
|
||||||
continue
|
continue
|
||||||
classes = ['annotation', 'dimension']
|
classes = ['annotation', 'dimension']
|
||||||
v0_global = matrix_world @ spline.points[i].co
|
v0_global = matrix_world @ spline.points[i].co.xyz
|
||||||
v1_global = matrix_world @ spline.points[i+1].co
|
v1_global = matrix_world @ spline.points[i+1].co.xyz
|
||||||
v0 = self.project_point_onto_camera(v0_global)
|
v0 = self.project_point_onto_camera(v0_global)
|
||||||
v1 = self.project_point_onto_camera(v1_global)
|
v1 = self.project_point_onto_camera(v1_global)
|
||||||
start = Vector(((x_offset + v0.x), (y_offset - v0.y)))
|
start = Vector(((x_offset + v0.x), (y_offset - v0.y)))
|
||||||
@@ -928,9 +935,11 @@ class SvgWriter():
|
|||||||
line['marker-end'] = 'url(#dimension-marker-end)'
|
line['marker-end'] = 'url(#dimension-marker-end)'
|
||||||
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
# Standard font sizes 1.8, 2.5, 3.5, 5, 7
|
||||||
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
# Equivalent for OpenGost Type B: 2.97, 4.13, 5.78, 8.25, 11.55
|
||||||
if text_override is None:
|
if text_override is not None:
|
||||||
text_override = str(round(dimension))
|
text = text_override
|
||||||
self.svg.add(self.svg.text(text_override, insert=tuple(text_position), **{
|
else:
|
||||||
|
text = str(round(dimension))
|
||||||
|
self.svg.add(self.svg.text(text, insert=tuple(text_position), **{
|
||||||
'transform': 'rotate({} {} {})'.format(
|
'transform': 'rotate({} {} {})'.format(
|
||||||
rotation,
|
rotation,
|
||||||
text_position.x,
|
text_position.x,
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class BIM_PT_camera(Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
engine = context.engine
|
engine = context.engine
|
||||||
return context.camera and (engine in cls.COMPAT_ENGINES) and \
|
return context.camera and \
|
||||||
hasattr(context.active_object.data, "BIMCameraProperties")
|
hasattr(context.active_object.data, "BIMCameraProperties")
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user