Shootoff as svg & center oversized targets

This commit is contained in:
bogo
2024-10-04 14:07:39 +02:00
parent d8e9eb7ba8
commit f92496b83a
4 changed files with 51 additions and 54 deletions

13
app.py
View File

@@ -296,16 +296,23 @@ def generate_pdf_custom():
'ts2': (TS2_HEIGHT, TS2_WIDTH), 'ts2': (TS2_HEIGHT, TS2_WIDTH),
'popper': (POPPER_HEIGHT, POPPER_WIDTH), 'popper': (POPPER_HEIGHT, POPPER_WIDTH),
}[target_type] }[target_type]
target_height=scale * original_target_height
target_width=scale * original_target_width
if (size == 'a4' and target_width > 21) or (size == 'a3' and target_width > 29.7):
oversized = True
else:
oversized = False
rendered_html = render_template( rendered_html = render_template(
'pdf_template_custom.html', 'pdf_template_custom.html',
distance=distance, distance=distance,
size=size, size=size,
target_height=scale * original_target_height, target_height=target_height,
target_width=scale * original_target_width, target_width=target_width,
gap=scale * IPSC_GAP + scale * original_target_width, gap=scale * IPSC_GAP + scale * original_target_width,
target_type=target_type, target_type=target_type,
simulated_distance=simulated_distance simulated_distance=simulated_distance,
oversized=oversized
) )
# return rendered_html # return rendered_html

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@@ -30,6 +30,16 @@
left: 0; left: 0;
right: 0; right: 0;
} }
.content-oversized {
position: relative;
height: {{target_height}}cm; /* Paper height */
overflow: hidden; /* Hide overflow on both sides */
}
.content-oversized svg {
position: absolute;
left: 50%; /* Move to the center */
transform: translateX(-50%); /* Center the SVG horizontally */
}
.mounting-point { .mounting-point {
height: 10mm; height: 10mm;
@@ -44,6 +54,17 @@
text-align: center; text-align: center;
} }
.mounting-info-oversized {
font-size: xx-small;
color: #ccc;
text-align: center;
position: absolute;
z-index: 111;
bottom: 1.5cm;
left: 50%;
transform: translateX(-50%);
}
.preview { .preview {
display: block; display: block;
border-bottom: solid 1px black; border-bottom: solid 1px black;
@@ -61,7 +82,7 @@
<body> <body>
<div class="page-break"> <div class="page-break">
<div class="content"> <div class="content{% if oversized %}-oversized{% endif %}">
{% with target_width=target_width, target_height=target_height %} {% with target_width=target_width, target_height=target_height %}
{% if target_type == 'ipsc' %} {% if target_type == 'ipsc' %}
{%include 'ipsc_svg.html'%} {%include 'ipsc_svg.html'%}
@@ -74,7 +95,7 @@
{% endif%} {% endif%}
{% endwith %} {% endwith %}
<br> <br>
<div class="mounting-info"> <div class="mounting-info{% if oversized %}-oversized{% endif %}">
{%trans%}Target{%endtrans%}: {{ target_type|upper }} | {%trans%}Simulated distance{%endtrans%}: {{ simulated_distance }}m | {%trans%}Place target on{%endtrans%}: {{distance}}m {%trans%}Target{%endtrans%}: {{ target_type|upper }} | {%trans%}Simulated distance{%endtrans%}: {{ simulated_distance }}m | {%trans%}Place target on{%endtrans%}: {{distance}}m
<br> <br>
Steel Training Steel Training

View File

@@ -66,6 +66,7 @@
border-top: solid 1px black; border-top: solid 1px black;
width: 100%; width: 100%;
height: 75mm; height: 75mm;
text-align: center;
} }
.preview-post { .preview-post {
@@ -82,31 +83,18 @@
<div class="preview"> <div class="preview">
{% for i in range(target_count) %} {% for i in range(target_count) %}
<div style="margin: 20mm {{preview_scale*25}}cm 0 {{preview_scale*25}}cm; display: inline-block;">
{% if i == target_count-1 %} {% if i == target_count-1 %}
<div class="post preview-post" {% with target_width=preview_scale * 30, target_height=preview_scale * 85 %}
style="width: {{ preview_scale * 150}}mm; height: {{ preview_scale * 550 }}mm; left: {{i * preview_scale * 1000}}mm"> {% include 'popper_svg.html' %}
<div class="target circle" style=" {% endwith %}
width: {{ preview_scale * 300 }}mm;
height: {{ preview_scale * 300 }}mm;
bottom: {{ (preview_scale * 550) - ((preview_scale * 300)/2) }}mm;
right: {{ (preview_scale * (300/2)) - (preview_scale * 150 * 1.5) }}mm;
">
</div>
</div>
{% else %} {% else %}
<div class="post preview-post" {% with target_width=preview_scale * 20, target_height=preview_scale * 56 %}
style="width: {{ preview_scale * 100}}mm; height: {{ preview_scale * 360 }}mm; left: {{i * preview_scale * 1000}}mm"> {% include 'popper_svg.html' %}
<div class="target circle" style=" {% endwith %}
width: {{ preview_scale * 200 }}mm;
height: {{ preview_scale * 200 }}mm;
bottom: {{ (preview_scale * 360) - ((preview_scale * 200)/2) }}mm;
right: {{ (preview_scale * (200/2)) - (preview_scale * 100 * 1.5) }}mm;
">
</div>
</div>
{% endif %} {% endif %}
</div>
{% endfor %} {% endfor %}
</div> </div>
<p>{%trans%}Wall length required{%endtrans%}: {{ wall_length|round(1,'ceil') }}cm</p> <p>{%trans%}Wall length required{%endtrans%}: {{ wall_length|round(1,'ceil') }}cm</p>
@@ -124,32 +112,13 @@
<div class="page-break"> <div class="page-break">
<div class="content"> <div class="content">
{% if i == target_count-1 %} {% if i == target_count-1 %}
{% with target_width=scale * 30, target_height=scale * 85 %}
<div class="post" {% include 'popper_svg.html' %}
{% endwith %}
style="width: {{ scale * 150}}mm; height: {{ scale * 550 }}mm;">
<div class="target circle" style="
width: {{ scale * 300 }}mm;
height: {{ scale * 300 }}mm;
bottom: {{ (scale * 550) - ((scale * 300)/2) }}mm;
right: {{ (scale * (300/2)) - (scale * 150 * 1.5) }}mm;
">
</div>
</div>
{% else %} {% else %}
<div class="post" {% with target_width=scale * 20, target_height=scale * 56 %}
style="width: {{ scale * 100}}mm; height: {{ scale * 360 }}mm;"> {% include 'popper_svg.html' %}
<div class="target circle" style=" {% endwith %}
width: {{ scale * 200 }}mm;
height: {{ scale * 200 }}mm;
bottom: {{ (scale * 360) - ((scale * 200)/2) }}mm;
right: {{ (scale * (200/2)) - (scale * 100 * 1.5) }}mm;
">
</div>
</div>
{% endif %} {% endif %}
{% if i==0 %} {% if i==0 %}
<div class="mounting-info">{%trans%}ZERO point{%endtrans%} (Shootoff)</div> <div class="mounting-info">{%trans%}ZERO point{%endtrans%} (Shootoff)</div>