mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Users can now specify a symbol for text annotation
This commit is contained in:
@@ -714,6 +714,7 @@ class SvgWriter():
|
||||
|
||||
self.add_stylesheet()
|
||||
self.add_markers()
|
||||
self.add_symbols()
|
||||
self.add_patterns()
|
||||
self.draw_background_image()
|
||||
self.draw_background_elements()
|
||||
@@ -740,6 +741,12 @@ class SvgWriter():
|
||||
for child in root.getchildren():
|
||||
self.svg.defs.add(External(child))
|
||||
|
||||
def add_symbols(self):
|
||||
tree = ET.parse('{}templates/symbols.svg'.format(self.ifc_cutter.data_dir))
|
||||
root = tree.getroot()
|
||||
for child in root.getchildren():
|
||||
self.svg.defs.add(External(child))
|
||||
|
||||
def add_patterns(self):
|
||||
return
|
||||
tree = ET.parse('{}templates/patterns.svg'.format(self.ifc_cutter.data_dir))
|
||||
@@ -906,11 +913,23 @@ class SvgWriter():
|
||||
'dominant-baseline': 'middle'
|
||||
}))
|
||||
|
||||
self.draw_text_annotations()
|
||||
|
||||
def draw_text_annotations(self):
|
||||
x_offset = self.raw_width / 2
|
||||
y_offset = self.raw_height / 2
|
||||
|
||||
for text_obj in self.ifc_cutter.text_objs:
|
||||
loc, rot, scale = self.ifc_cutter.camera_obj.matrix_world.decompose()
|
||||
pos = (text_obj.location - self.ifc_cutter.camera_obj.location) @ rot.to_matrix()
|
||||
text_position = Vector(((x_offset + pos.x), (y_offset - pos.y)))
|
||||
|
||||
if text_obj.data.BIMTextProperties.symbol != 'None':
|
||||
self.svg.add(self.svg.use(
|
||||
'#{}'.format(text_obj.data.BIMTextProperties.symbol),
|
||||
insert=tuple(text_position * self.scale)
|
||||
))
|
||||
|
||||
if text_obj.data.align_x == 'CENTER':
|
||||
text_anchor = 'middle'
|
||||
elif text_obj.data.align_x == 'RIGHT':
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
<path d="M 5 20 L 15 10" class="annotation" style="stroke-width:3;" />
|
||||
</g>
|
||||
</marker>
|
||||
<marker id="grid-marker" markerHeight="35" markerWidth="35" orient="auto" refX="17.5" refY="17.5">
|
||||
<circle cx="17.5" cy="17.5" fill="white" stroke="black" r="15" style="stroke-width: 2"/>
|
||||
<marker id="grid-marker" markerHeight="40" markerWidth="40" orient="auto" refX="20" refY="20">
|
||||
<circle cx="20" cy="20" fill="white" stroke="black" r="17" style="stroke-width: 2"/>
|
||||
</marker>
|
||||
<marker id="leader-marker" markerHeight="7" markerWidth="10" orient="auto" refX="10" refY="3.5">
|
||||
<path d="M 0 0 L 0 7 L 10 3.5" class="annotation" style="fill:black;" />
|
||||
|
||||
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="rectangle-tag">
|
||||
<rect x="-6" y="-2.5" width="12" height="5" fill="white" stroke="black" style="stroke-width: 0.25;" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 356 B |
@@ -404,6 +404,10 @@ class BIMTextProperties(PropertyGroup):
|
||||
('5.0', '5.0', ''),
|
||||
('7.0', '7.0', ''),
|
||||
], update=refreshFontSize, name='Font Size')
|
||||
symbol: EnumProperty(items=[
|
||||
('None', 'None', ''),
|
||||
('rectangle-tag', 'Rectangle Tag', ''),
|
||||
], update=refreshFontSize, name='Symbol')
|
||||
|
||||
|
||||
class DocumentInformation(PropertyGroup):
|
||||
|
||||
@@ -660,6 +660,9 @@ class BIM_PT_text(Panel):
|
||||
row = layout.row()
|
||||
row.prop(props, 'font_size')
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'symbol')
|
||||
|
||||
|
||||
class BIM_PT_owner(Panel):
|
||||
bl_label = "Owner History"
|
||||
|
||||
Reference in New Issue
Block a user