notes: better placement and formatting

This commit is contained in:
Laurier Loiselle 2023-03-29 15:20:08 -04:00
parent 6dd9a303af
commit cd695d010f
No known key found for this signature in database
GPG Key ID: 345920CC72089A3F
8 changed files with 98 additions and 16 deletions

View File

@ -21,6 +21,16 @@ metadata:
name: din-6771
sheetsize: A3
notes: |
<ol>
<li> Wire color is a recommendation</li>
<li> Label harnesses with text given in diagram</li>
<li> Label every connector to match the designation in the drawing</li>
<li> Zip tie entire harness at 1ft increments where required.</li>
<li> Cover all cables with 1/2" or 1/8" black sleeving as required. Make it very long for wrapping test</li>
</ol>
templates: # defining templates to be used later on
- &molex_f
type: Molex KK 254

View File

@ -34,3 +34,6 @@ connections:
- X2: [1-4]
- W2: [1-4]
- X3: [1-4]
options:
notes_to_right: False

View File

@ -22,3 +22,12 @@ metadata:
template:
name: din-6771
sheetsize: A3
notes: |
<ol>
<li> Wire color is a recommendation</li>
<li> Label harnesses with text given in diagram</li>
<li> Label every connector to match the designation in the drawing</li>
<li> Zip tie entire harness at 1ft increments where required.</li>
<li> Cover all cables with 1/2" or 1/8" black sleeving as required. Make it very long for wrapping test</li>
</ol>

View File

@ -59,9 +59,9 @@
left: 0;
max-width: 100%;
{% if sheetsize == 'A4' %}
height: calc(100% - {{ [bom_length, 13]|sum }} * 4.25mm);
height: calc(100% - {{ [bom_rows, 13, ]|sum }} * 4.25mm);
{% else %}
height: calc(100% - {{ [bom_length, 13]|max }} * 4.25mm);
height: calc(100% - {{ [bom_rows, 13]|max }} * 4.25mm);
{% endif %}
/* TODO: auto-adapt to height of title block + BOM table;
BOM table might be above (A4) or to the left (A3 and larger) of the title block */
@ -77,6 +77,7 @@
transform: translateY(-50%);
}
</style>
<style type="text/css" media="print">
@ -96,21 +97,16 @@
<body>
<div id="page">
<div id="frame" class={{ sheetsize }}>
<div id="diagram">
<div id="description">
{{ description }}
</div>
{{ diagram }}
<div id="notes">
{{ notes }}
</div>
<div id="description">
{{ description }}
</div>
<div id="diagram">
{{ diagram }}
</div>
{{ notes }}
{{ bom }}
{{ titleblock }}
</div> <!-- /frame -->

47
src/wireviz/templates/notes.html generated Normal file
View File

@ -0,0 +1,47 @@
<style>
.A4 #notes { /* NOTES on top of BOM */
position: absolute;
bottom: calc({{ titleblock_rows + bom_rows + 2 }} * 4.25mm);
right: 0;
}
.A3 #notes, .A2 #notes { /* NOTES on top of title block */
position: absolute;
{% if notes_to_right %}
bottom: calc({{ titleblock_rows + 1 }} * 4.25mm);
right: 0;
{% else %}
bottom: calc({{ bom_rows + 1 }} * 4.25mm);
left: 0;
{% endif %}
}
#notes {
font-size: 14px;
font-style: italic;
}
.A4 #notes {
width:180mm;
}
.A3 #notes, .A2 #notes {
width:80mm;
word-wrap: break-word;
white-space: normal;
}
#notes ol, ul, li {
text-align: left;
}
</style>
<!-- NOTES TEMPLATE --!>
<div id="notes">
<h3>Notes:</h3>
{{ notes }}
</div>

View File

@ -422,6 +422,7 @@ class BomEntry:
@dataclass
class Options:
fontname: PlainText = "arial"
notes_to_right: bool = True
bgcolor: SingleColor = "WH" # will be converted to SingleColor in __post_init__
bgcolor_node: SingleColor = "WH"
bgcolor_connector: SingleColor = None

View File

@ -107,6 +107,7 @@ def generate_html_output(
"generator": f"{wireviz.APP_NAME} {wireviz.__version__} - {wireviz.APP_URL}",
"fontname": options.fontname,
"bgcolor": options.bgcolor.html,
"notes_to_right": options.notes_to_right,
"diagram": svgdata,
"sheet_current": sheet_current,
"sheet_total": sheet_total,
@ -114,7 +115,7 @@ def generate_html_output(
"bom_header": bom_header,
"bom_content": bom_content,
"bom_columns": bom_columns,
"bom_length": len(bom_content),
"bom_rows": len(bom_content),
"titleblock_rows": 9,
}
@ -153,6 +154,12 @@ def generate_html_output(
titleblock_template = get_template_html("titleblock")
replacements["titleblock"] = titleblock_template.render(replacements)
# preparate Notes
if "notes" in replacements:
notes_template = get_template_html("notes")
replacements["notes"] = notes_template.render(replacements)
# generate page template
page_template = get_template_html(template_name)
page_rendered = page_template.render(replacements)

View File

@ -22,3 +22,12 @@ metadata:
template:
name: din-6771
sheetsize: A4
notes: |
<ol>
<li> Wire color is a recommendation</li>
<li> Label harnesses with text given in diagram</li>
<li> Label every connector to match the designation in the drawing</li>
<li> Zip tie entire harness at 1ft increments where required.</li>
<li> Cover all cables with 1/2" or 1/8" black sleeving as required.</li>
</ol>