Files
M1730-Scale/README.md
T

109 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# M1730-Scale
SVG scale artwork and web generator for M1730 analog panel meters. Scales are typeset in **ГОСТ тип А** (GOST type A), the Russian technical drafting standard typeface.
## Repository layout
```
M1730-Scale_template.svg Inkscape working file (background, tick marks, labels)
M1730-Scale_paths.svg Paths-only export — text converted to outlines
M1730-Scale_text.svg Live-text export — embedded font, editable labels
fonts/ ГОСТ тип А TTF (required for Docker build)
web/ Flask web generator
k8s/ Kubernetes manifests
Dockerfile Container build
```
## SVG files
All canvases are **157.18 × 26.68 mm**. The coordinate origin is offset: layer 1 carries `transform="translate(-37.352226,-90.454928)"`, so absolute SVG coordinates begin around x=37, y=90.
| File | Purpose |
|---|---|
| `M1730-Scale_template.svg` | Master Inkscape file. Contains background path, tick marks, unit label, numeric labels, and range label. Edit this one. |
| `M1730-Scale_paths.svg` | All text converted to outlines. Use for cutting plotters, laser engravers, or any workflow where fonts must not be embedded as live text. |
| `M1730-Scale_text.svg` | Live `<text>` nodes with the font embedded as base64. Smaller file; requires an SVG viewer that supports embedded fonts. |
Open files in **Inkscape** (developed with v1.4.3). There is no build step — edit the SVG directly or use the web generator.
## Web generator
A Flask app that generates scale SVGs from a form. Supports two output modes switchable in the UI:
- **Paths** — glyphs rendered as outlines via fontTools; opens cleanly in Inkscape, Illustrator, and cutting software
- **Text** — live `<text>` elements with the GOST font embedded as base64
### Run locally
```bash
source .venv/bin/activate
cd web && python app.py # http://localhost:5000
```
The font must be installed at `/usr/local/share/fonts/г/ГОСТ_тип_А.ttf`.
### Form parameters
| Field | Description |
|---|---|
| Unit | Symbol shown in the left panel (e.g. `U`, `mA`, `%`). Supports inline markup — see below |
| Range label | Text inside the coloured bar on the right (e.g. `5mA`) |
| Mapping | **Linear**, **√** (square root), or **Log**. Major ticks are always evenly spaced physically; the mapping controls their values and how minor ticks are placed within each interval. See below. |
| Min / Max | Numeric range of the scale |
| Major intervals | Number of major tick intervals |
| Minor per interval | Minor ticks between each pair of major ticks |
| Labels | Number of numeric labels; Labels 1 should divide evenly into Major intervals |
| Custom labels | Optional comma-separated labels that override the calculated numbers; their count sets the number of labels. Leave blank to auto-calculate |
| Label size (mm) | Font size of the numeric labels, in millimetres (default `9`) |
Calculated numbers are rendered in fixed-point notation at 4 significant figures — never scientific (e.g. `10000`, not `1e+04`).
### Scale mappings
| Mapping | Major tick values | Minor tick placement | Constraints |
|---|---|---|---|
| Linear | Evenly spaced | Uniform | None |
| √ | Quadratic (0, 1, 4, 9 … × max) — compresses low values | Crowded toward the low end of each interval | Min ≥ 0 |
| Log | Geometric (min × r⁰, r¹, r² …) — each interval spans the same ratio | Crowded toward the high end of each interval | Min and Max > 0 |
The √ mapping is typical for AC RMS current and power meters, where needle deflection is proportional to the square of the measured quantity.
### Unit markup
The Unit field accepts a lightweight shorthand (no LaTeX engine — everything is drawn as glyph paths in the ГОСТ тип А font and auto-sized to fit the panel):
| Markup | Result |
|---|---|
| `cm^2` | superscript (`^{...}` for multiple characters) |
| `H_2O` | subscript (`_{...}` for multiple characters) |
| `{1/2}` | stacked fraction with a horizontal rule; a bare `/` stays inline |
Constructs nest: `{m/s^2}` is a fraction with a superscript in the denominator, `x^{1/2}` a superscripted fraction. A unit containing markup is always emitted as paths, even in text-output mode, since it is a composite of glyphs and a rule.
## Container
```bash
# Copy the font first (not redistributed via the registry)
cp /usr/local/share/fonts/г/ГОСТ_тип_А.ttf fonts/
docker build -t m1730-scale:latest .
docker run -p 5000:5000 m1730-scale:latest
```
The production image is at `git.baumann.gr/adebaumann/m1730-generator`.
## Kubernetes
Manifests in `k8s/` deploy to the `works` namespace with a Traefik v2 IngressRoute at `works.baumann.gr/M1730-generator`.
```bash
# Managed by ArgoCD — push to git to deploy
git push
```
Resources: namespace, deployment (1 replica, gunicorn), ClusterIP service, Traefik IngressRoute + stripPrefix middleware.
## License
GPL-3.0 — see [LICENSE](LICENSE).