From 4aab344a187434b48b9d2f09090abe0f998d1f2a Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 7 Jul 2024 16:52:24 +0200 Subject: protoboard: add split front/back view in webthing --- gerbonara/cad/primitives.py | 1 + gerbonara/cad/protoserve.py | 6 ++-- gerbonara/cad/protoserve_data/protoserve.html | 43 ++++++++++++++++++++------- 3 files changed, 36 insertions(+), 14 deletions(-) (limited to 'gerbonara/cad') diff --git a/gerbonara/cad/primitives.py b/gerbonara/cad/primitives.py index c659274..9c7d9dc 100644 --- a/gerbonara/cad/primitives.py +++ b/gerbonara/cad/primitives.py @@ -135,6 +135,7 @@ class Board: force_bounds=force_bounds) def pretty_svg(self, side='top', margin=0, arg_unit=MM, svg_unit=MM, force_bounds=None, inkscape=False, colors=None): + print('Pretty svg', side) return self.layer_stack().to_pretty_svg(side=side, margin=margin, arg_unit=arg_unit, svg_unit=svg_unit, force_bounds=force_bounds, inkscape=inkscape, colors=colors) diff --git a/gerbonara/cad/protoserve.py b/gerbonara/cad/protoserve.py index 3271af1..c3224e3 100644 --- a/gerbonara/cad/protoserve.py +++ b/gerbonara/cad/protoserve.py @@ -159,11 +159,11 @@ def to_board(obj): mounting_hole_offset=mounting_hole_offset, unit=unit) -@app.route('/preview.svg', methods=['POST']) -async def preview(): +@app.route('/preview_.svg', methods=['POST']) +async def preview(side): obj = await request.get_json() board = to_board(obj) - return Response(str(board.pretty_svg()), mimetype='image/svg+xml') + return Response(str(board.pretty_svg(side=side)), mimetype='image/svg+xml') @app.route('/gerbers.zip', methods=['POST']) async def gerbers(): diff --git a/gerbonara/cad/protoserve_data/protoserve.html b/gerbonara/cad/protoserve_data/protoserve.html index c42ce6c..7a11626 100644 --- a/gerbonara/cad/protoserve_data/protoserve.html +++ b/gerbonara/cad/protoserve_data/protoserve.html @@ -177,11 +177,14 @@ input[type="text"]:focus:valid { position: relative; grid-area: main; padding: 20px; + display: flex; + flex-direction: column; + flex-wrap: wrap; + align-items: stretch; } -#preview-image { - width: 100%; - height: 100%; +#preview > img { + flex-grow: 1; object-fit: contain; } @@ -316,7 +319,8 @@ input[type="text"]:focus:valid {
- Automatically generated preview image + Automatically generated top side preview image + Automatically generated bottom side preview image