This commit is contained in:
Thomas Forgione 2024-07-07 23:12:39 +02:00
parent e6dec9168e
commit 28051e0ff4
4 changed files with 24 additions and 7 deletions

8
app.py
View File

@ -28,9 +28,11 @@ def object(id: int):
return render_template('object.html', object=object)
@app.route("/calibration")
def calibration():
return render_template('calibration.html')
@app.route("/calibration/<id>")
def calibration(id: int):
conn = db.get()
object = db.Object.get_from_id(id, conn)
return render_template('calibration.html', object=object)
@app.route('/static/<path:path>')

View File

@ -3,9 +3,10 @@
{% block content %}
<section class="section">
<div class="container">
<h1 class="title is-2">Visualisation de l'étalonnage de {{ object.name }}</h1>
<div class="columns">
<div class="column">
<h1 class="title">Positions 3D des LEDs</h1>
<h2 class="title is-3">Positions 3D des LEDs</h2>
<div id="visualiser-container">
<div id="visualiser">
<div id="info">
@ -15,7 +16,7 @@
</div>
</div>
<div class="column">
<h1 class="title">Vue de la LED selectionnée</h1>
<h2 class="title is-3">Vue de la LED selectionnée</h2>
<div>
<img id="led-view">
</div>

View File

@ -4,6 +4,14 @@
<section class="section">
<div class="container">
<h1 class="title">{{ object.name }}</h1>
<div class="field is-grouped is-grouped-multiline">
<div class="control">
<a href="/calibration/{{ object.id }}" class="tags has-addons">
<span class="tag is-dark">étalonnage</span>
<span class="tag is-success">fait</span>
</a>
</div>
</div>
</div>
</section>
{% endblock content %}

View File

@ -43,6 +43,9 @@ function getImageElementById(id: string): HTMLImageElement {
* The class that manages the interface for the calibration visualisation.
*/
export class Engine {
/** The id of the object to scan. */
objectId: number;
/** HTML element on which the renderer will be added. */
domElement: HTMLElement;
@ -102,12 +105,15 @@ export class Engine {
/** Initialises the engine. */
static async create(domId: string) {
let objectId = parseInt(window.location.pathname.split('/')[2], 10);
let domElement = getElementById(domId);
let engine = new Engine();
engine.objectId = objectId;
engine.domElement = domElement;
engine.initHtml();
let request = await fetch('/data/calibration.json');
let request = await fetch('/data/' + objectId + '/calibration.json');
let calibration = await request.json();
engine.initScene(calibration);
engine.initListeners();
@ -290,7 +296,7 @@ export class Engine {
showImage(led: Led): void {
if (led.on) {
this.selectedObject.innerText = led.name + ' (' + (<number> this.leds.currentLedIndex + 1) + '/' + this.leds.children.length + ')';
this.ledView.src = '/data/small/' + led.name;
this.ledView.src = '/data/' + this.objectId + '/' + led.name;
this.ledView.style.display = 'block';
} else {
this.selectedObject.innerText = 'aucune';