From cd695d010fe5c299fc9decf1227e6eac5c41ddfa Mon Sep 17 00:00:00 2001 From: Laurier Loiselle Date: Wed, 29 Mar 2023 15:20:08 -0400 Subject: [PATCH] notes: better placement and formatting --- examples/demo02.yml | 10 ++++++ examples/ex05.yml | 3 ++ examples/metadata.yml | 9 ++++++ src/wireviz/templates/din-6771.html | 26 +++++++--------- src/wireviz/templates/notes.html | 47 +++++++++++++++++++++++++++++ src/wireviz/wv_dataclasses.py | 1 + src/wireviz/wv_output.py | 9 +++++- tutorial/metadata.yml | 9 ++++++ 8 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 src/wireviz/templates/notes.html diff --git a/examples/demo02.yml b/examples/demo02.yml index 5e94df7..32f8b47 100644 --- a/examples/demo02.yml +++ b/examples/demo02.yml @@ -21,6 +21,16 @@ metadata: name: din-6771 sheetsize: A3 + notes: | +
    +
  1. Wire color is a recommendation
  2. +
  3. Label harnesses with text given in diagram
  4. +
  5. Label every connector to match the designation in the drawing
  6. +
  7. Zip tie entire harness at 1ft increments where required.
  8. +
  9. Cover all cables with 1/2" or 1/8" black sleeving as required. Make it very long for wrapping test
  10. +
+ + templates: # defining templates to be used later on - &molex_f type: Molex KK 254 diff --git a/examples/ex05.yml b/examples/ex05.yml index 98a1a34..93531a3 100644 --- a/examples/ex05.yml +++ b/examples/ex05.yml @@ -34,3 +34,6 @@ connections: - X2: [1-4] - W2: [1-4] - X3: [1-4] + +options: + notes_to_right: False diff --git a/examples/metadata.yml b/examples/metadata.yml index 18357ef..525241c 100644 --- a/examples/metadata.yml +++ b/examples/metadata.yml @@ -22,3 +22,12 @@ metadata: template: name: din-6771 sheetsize: A3 + + notes: | +
    +
  1. Wire color is a recommendation
  2. +
  3. Label harnesses with text given in diagram
  4. +
  5. Label every connector to match the designation in the drawing
  6. +
  7. Zip tie entire harness at 1ft increments where required.
  8. +
  9. Cover all cables with 1/2" or 1/8" black sleeving as required. Make it very long for wrapping test
  10. +
diff --git a/src/wireviz/templates/din-6771.html b/src/wireviz/templates/din-6771.html index 6513a73..3948eeb 100644 --- a/src/wireviz/templates/din-6771.html +++ b/src/wireviz/templates/din-6771.html @@ -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%); } + + + + +
+ +

Notes:

+ {{ notes }} + +
diff --git a/src/wireviz/wv_dataclasses.py b/src/wireviz/wv_dataclasses.py index f184663..6980056 100644 --- a/src/wireviz/wv_dataclasses.py +++ b/src/wireviz/wv_dataclasses.py @@ -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 diff --git a/src/wireviz/wv_output.py b/src/wireviz/wv_output.py index e27857e..043177b 100644 --- a/src/wireviz/wv_output.py +++ b/src/wireviz/wv_output.py @@ -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) diff --git a/tutorial/metadata.yml b/tutorial/metadata.yml index e519840..11ccf88 100644 --- a/tutorial/metadata.yml +++ b/tutorial/metadata.yml @@ -22,3 +22,12 @@ metadata: template: name: din-6771 sheetsize: A4 + + notes: | +
    +
  1. Wire color is a recommendation
  2. +
  3. Label harnesses with text given in diagram
  4. +
  5. Label every connector to match the designation in the drawing
  6. +
  7. Zip tie entire harness at 1ft increments where required.
  8. +
  9. Cover all cables with 1/2" or 1/8" black sleeving as required.
  10. +