diff --git a/LogarithmPlotter/i18n/lp_de.ts b/LogarithmPlotter/i18n/lp_de.ts
index 5fc986d..f6184d1 100644
--- a/LogarithmPlotter/i18n/lp_de.ts
+++ b/LogarithmPlotter/i18n/lp_de.ts
@@ -5,7 +5,7 @@
About
-
+ Über LogarithmPlotter
@@ -529,12 +529,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
comment
-
+ Beispiel: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ-*), ]0;1[, {3;4;5}
-
+ Die folgenden Parameter werden verwendet, wenn der Definitionsbereich eine nicht kontinuierliche Menge ist. (Beispiel: ℕ, ℤ, Mengen wie {0;3}...)
@@ -544,7 +544,7 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
Hinweis: Geben Sie die Wahrscheinlichkeit für jeden Wert an.
-
+ Hinweis: Verwenden Sie %1[n], um sich auf %1ₙ zu beziehen, %1[n+1] für %1ₙ₊₁…
@@ -607,22 +607,24 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
gainbode
-
+ Bode-Magnitude
-
+ Bode-Magnituden
-
+
+ Tiefpass
-
+
+ Hochpass
@@ -654,6 +656,38 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
Der Name von %1 %2 wurde in %3 geändert.
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -781,12 +815,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
phasebode
-
+ Bode-Phase
-
+ Bode-Phasen
@@ -807,108 +841,108 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
prop
-
+ Ausdruck
-
+ Definitionsbereich
-
+ Reichweite
-
-
-
-
+
+
+
+
-
-
-
+
+
+ Position des Etiketts
-
+ Anzeigemodus
-
-
-
+
+
+
-
-
-
+
+
+ X-Position des Etiketts
-
-
+
+ Unentschiedene Punkte
-
-
+
+ Gestrichelte Linien anzeigen
-
-
+
+ ω₀
-
+ Pass
-
+ Größenordnung
-
+ Teilung auf ω zeigen
-
+ Phase
-
+ Einheit
-
+ X
-
+ Y
-
+ Punkt-Stil
@@ -922,6 +956,11 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
Inhalt
+
+
+
+
+
@@ -948,12 +987,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
Wertposition des Ziels
-
+ Standardausdruck
-
+ Initialisierungswerte
@@ -978,12 +1017,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
sequence
-
+ Folge
-
+ Folgen
@@ -991,8 +1030,8 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
sommegainsbode
-
+ Bode-Magnituden Summe
@@ -1000,8 +1039,8 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen"
sommephasesbode
-
+ Bode-Phasen Summe
diff --git a/LogarithmPlotter/i18n/lp_en.ts b/LogarithmPlotter/i18n/lp_en.ts
index fd9567a..9d07cde 100644
--- a/LogarithmPlotter/i18n/lp_en.ts
+++ b/LogarithmPlotter/i18n/lp_en.ts
@@ -5,7 +5,7 @@
About
-
+ About LogarithmPlotter
@@ -529,12 +529,12 @@ These settings can be changed at any time from the "Settings" menu.
comment
-
+ Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}
-
+ The following parameters are used when the domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}…)
@@ -544,7 +544,7 @@ These settings can be changed at any time from the "Settings" menu.Note: Specify the probability for each value.
-
+ Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁…
@@ -607,22 +607,24 @@ These settings can be changed at any time from the "Settings" menu.
gainbode
-
+ Bode Magnitude
-
+ Bode Magnitudes
-
+
+ low-pass
-
+
+ high-pass
@@ -654,6 +656,38 @@ These settings can be changed at any time from the "Settings" menu.Name of %1 %2 changed to %3.
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -781,12 +815,12 @@ These settings can be changed at any time from the "Settings" menu.
phasebode
-
+ Bode Phase
-
+ Bode Phases
@@ -807,108 +841,108 @@ These settings can be changed at any time from the "Settings" menu.
prop
-
+ Expression
-
+ Domain
-
+ Range
-
-
-
-
+
+
+
+
-
-
-
+
+
+ Label position
-
+ Display mode
-
-
-
+
+
+
-
-
-
+
+
+ Label's X position
-
-
+
+ Show points
-
-
+
+ Show dashed lines
-
-
+
+ ω₀
-
+ Pass
-
+ Magnitude gain
-
+ Show graduation on ω₀
-
+ Phase
-
+ Unit to use
-
+ X
-
+ Y
-
+ Point style
@@ -922,6 +956,11 @@ These settings can be changed at any time from the "Settings" menu.text
Content
+
+
+
+
+
@@ -948,12 +987,12 @@ These settings can be changed at any time from the "Settings" menu.Target's value position
-
+ Default expression
-
+ Initialisation values
@@ -978,12 +1017,12 @@ These settings can be changed at any time from the "Settings" menu.
sequence
-
+ Sequence
-
+ Sequences
@@ -991,8 +1030,8 @@ These settings can be changed at any time from the "Settings" menu.
sommegainsbode
-
+ Bode Magnitudes Sum
@@ -1000,8 +1039,8 @@ These settings can be changed at any time from the "Settings" menu.
sommephasesbode
-
+ Bode Phases Sum
diff --git a/LogarithmPlotter/i18n/lp_es.ts b/LogarithmPlotter/i18n/lp_es.ts
index fe30649..4af05f8 100644
--- a/LogarithmPlotter/i18n/lp_es.ts
+++ b/LogarithmPlotter/i18n/lp_es.ts
@@ -5,7 +5,7 @@
About
-
+ Sobre LogarithmPlotter
@@ -528,12 +528,12 @@ These settings can be changed at any time from the "Settings" menu.
comment
-
+
-
+
@@ -543,7 +543,7 @@ These settings can be changed at any time from the "Settings" menu.
-
+
@@ -606,26 +606,60 @@ These settings can be changed at any time from the "Settings" menu.
gainbode
-
+
-
+
-
+
+
-
+
+
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -753,12 +787,12 @@ These settings can be changed at any time from the "Settings" menu.
phasebode
-
+
-
+
@@ -779,108 +813,108 @@ These settings can be changed at any time from the "Settings" menu.
prop
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -894,6 +928,11 @@ These settings can be changed at any time from the "Settings" menu.text
+
+
+
+
+
@@ -920,12 +959,12 @@ These settings can be changed at any time from the "Settings" menu.
-
+
-
+
@@ -946,12 +985,12 @@ These settings can be changed at any time from the "Settings" menu.
sequence
-
+
-
+
@@ -959,8 +998,8 @@ These settings can be changed at any time from the "Settings" menu.
sommegainsbode
-
+
@@ -968,8 +1007,8 @@ These settings can be changed at any time from the "Settings" menu.
sommephasesbode
-
+
diff --git a/LogarithmPlotter/i18n/lp_fr.ts b/LogarithmPlotter/i18n/lp_fr.ts
index 42ef942..1038ab0 100644
--- a/LogarithmPlotter/i18n/lp_fr.ts
+++ b/LogarithmPlotter/i18n/lp_fr.ts
@@ -5,7 +5,7 @@
About
-
+ À propos de LogarithmPlotter
@@ -537,12 +537,12 @@ These settings can always be changed at any time from the "Settings" m
comment
-
+ Par exemple : R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}
-
+ Les paramètres suivants sont utilisés lorsque le domaine de définition est un ensemble non-continu. (Ex : ℕ, ℤ, des ensembles comme {0;3}…)
@@ -552,7 +552,7 @@ These settings can always be changed at any time from the "Settings" m
Note : Spécifiez la probabilité pour chaque valeur.
-
+ Note : Utilisez %1[n] pour faire référence à %1ₙ, %1[n+1] pour %1ₙ₊₁...Note : Utilisez %1[n] pour faire référence à %1ₙ, %1[n+1] pour %1ₙ₊₁…
@@ -616,22 +616,24 @@ These settings can always be changed at any time from the "Settings" m
gainbode
-
+ Gain de Bode
-
+ Gains de Bode
-
+
+ passe-bas
-
+
+ passe-haut
@@ -663,6 +665,38 @@ These settings can always be changed at any time from the "Settings" m
Le nom de %1 %2 a été changé en %3.
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -790,12 +824,12 @@ These settings can always be changed at any time from the "Settings" m
phasebode
-
+ Phase de Bode
-
+ Phases de Bode
@@ -816,108 +850,108 @@ These settings can always be changed at any time from the "Settings" m
prop
-
+ Expression
-
+ Domaine de définition
-
+ Portée
-
-
-
-
+
+
+
+
-
-
-
+
+
+ Position de l'étiquette
-
+ Mode d'affichage
-
-
-
+
+
+
-
-
-
+
+
+ Position en X de l'étiquette
-
-
+
+ Afficher les points
-
-
+
+ Afficher les pointillés
-
-
+
+ ω₀
-
+ Passe
-
+ Gain
-
+ Afficher la graduation sur ω₀
-
+ Phase
-
+ Unité de la phase
-
+ X
-
+ Y
-
+ Style du point
@@ -931,6 +965,11 @@ These settings can always be changed at any time from the "Settings" m
Contenu
+
+
+
+
+
@@ -957,12 +996,12 @@ These settings can always be changed at any time from the "Settings" m
Position de la valeur de la cible
-
+ Expression
-
+ Valeurs d'initialisation
@@ -987,12 +1026,12 @@ These settings can always be changed at any time from the "Settings" m
sequence
-
+ Suite
-
+ Suites
@@ -1000,8 +1039,8 @@ These settings can always be changed at any time from the "Settings" m
sommegainsbode
-
+ Sommes des gains de Bode
@@ -1009,8 +1048,8 @@ These settings can always be changed at any time from the "Settings" m
sommephasesbode
-
+ Somme des phases de Bode
diff --git a/LogarithmPlotter/i18n/lp_hu.ts b/LogarithmPlotter/i18n/lp_hu.ts
index 0ee9d08..e9d34a2 100644
--- a/LogarithmPlotter/i18n/lp_hu.ts
+++ b/LogarithmPlotter/i18n/lp_hu.ts
@@ -5,7 +5,7 @@
About
-
+ LogarithmPlotter névjegye
@@ -529,12 +529,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
comment
-
+ Példák: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}
-
+ A következő paraméterek használatosak, ha a tartomány nem folytonos halmaz. (Példák: ℕ, ℤ, olyan halmazok, mint a {0;3}…)
@@ -544,7 +544,7 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
Megjegyzés: Adja meg az egyes értékek valószínűségét.
-
+ Megjegyzés: A(z) %1[n] használatával hivatkozhat erre: %1ₙ, a(z) %1[n+1] használatával hivatkozhat erre: %1ₙ₊₁, …
@@ -607,22 +607,24 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
gainbode
-
+ Bode-nagyságrend
-
+ Bode-nagyságrendek
-
+
+ aluláteresztő
-
+
+ felüláteresztő
@@ -650,6 +652,38 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
%1 %2 rejtve.
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -777,12 +811,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
phasebode
-
+ Bode-fázis
-
+ Bode-fázisok
@@ -803,108 +837,108 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
prop
-
+ Kifejezés
-
+ Abszcissza tartomány
-
+ Ordináta tartomány
-
-
-
-
+
+
+
+
-
-
-
+
+
+ Címke helyzete
-
+ Megjelenítési mód
-
-
-
+
+
+
-
-
-
+
+
+ Címke X helyzete
-
-
+
+ Pontok megjelenítése
-
-
+
+ Szaggatott vonalak megjelenítése
-
-
+
+ ω₀
-
+ Áteresztő
-
+ Nagyságrend nyeresége
-
+ ω₀ érettségi megjelenítése
-
+ Fázis
-
+ Egység használata
-
+ X
-
+ Y
-
+ Pontstílus
@@ -918,6 +952,11 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
Tartalom
+
+
+
+
+
@@ -944,12 +983,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
Cél értékpozíciója
-
+ Alapértelmezett kifejezés
-
+ Kezdeményezési értékek
@@ -970,12 +1009,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
sequence
-
+ Sorozat
-
+ Sorozatok
@@ -983,8 +1022,8 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
sommegainsbode
-
+ Bode-nagyságrendek összege
@@ -992,8 +1031,8 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben.
sommephasesbode
-
+ Bode-fázisok összege
diff --git a/LogarithmPlotter/i18n/lp_nb_NO.ts b/LogarithmPlotter/i18n/lp_nb_NO.ts
index cacb689..4426396 100644
--- a/LogarithmPlotter/i18n/lp_nb_NO.ts
+++ b/LogarithmPlotter/i18n/lp_nb_NO.ts
@@ -5,7 +5,7 @@
About
-
+ Om
@@ -529,12 +529,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
comment
-
+
-
+
@@ -544,7 +544,7 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
-
+
@@ -607,22 +607,24 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
gainbode
-
+ Bode-magnitude
-
+ Bode-magnituder
-
+
+ lavpass
-
+
+ høypass
@@ -650,6 +652,38 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.%1 %2 skjult.
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -777,12 +811,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
phasebode
-
+ Bode-fase
-
+ Bode-faser
@@ -803,108 +837,108 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
prop
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -918,6 +952,11 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.text
+
+
+
+
+
@@ -944,12 +983,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
-
+
-
+
@@ -970,12 +1009,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
sequence
-
+ Følge
-
+ Følger
@@ -983,8 +1022,8 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
sommegainsbode
-
+ Bode-magnitudesum
@@ -992,8 +1031,8 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.
sommephasesbode
-
+ Bode-fasesum
diff --git a/LogarithmPlotter/i18n/lp_template.ts b/LogarithmPlotter/i18n/lp_template.ts
index d1dcea8..7099743 100644
--- a/LogarithmPlotter/i18n/lp_template.ts
+++ b/LogarithmPlotter/i18n/lp_template.ts
@@ -5,7 +5,7 @@
About
-
+
@@ -528,12 +528,12 @@ These settings can be changed at any time from the "Settings" menu.
comment
-
+
-
+
@@ -543,7 +543,7 @@ These settings can be changed at any time from the "Settings" menu.
-
+
@@ -606,26 +606,60 @@ These settings can be changed at any time from the "Settings" menu.
gainbode
-
+
-
+
-
+
+
-
+
+
+
+ latex
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+name
@@ -753,12 +787,12 @@ These settings can be changed at any time from the "Settings" menu.
phasebode
-
+
-
+
@@ -779,108 +813,108 @@ These settings can be changed at any time from the "Settings" menu.
prop
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -894,6 +928,11 @@ These settings can be changed at any time from the "Settings" menu.text
+
+
+
+
+
@@ -920,12 +959,12 @@ These settings can be changed at any time from the "Settings" menu.
-
+
-
+
@@ -946,12 +985,12 @@ These settings can be changed at any time from the "Settings" menu.
sequence
-
+
-
+
@@ -959,8 +998,8 @@ These settings can be changed at any time from the "Settings" menu.
sommegainsbode
-
+
@@ -968,8 +1007,8 @@ These settings can be changed at any time from the "Settings" menu.
sommephasesbode
-
+
diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/LatexExpression.qml b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/LatexExpression.qml
new file mode 100644
index 0000000..bc8897c
--- /dev/null
+++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/LatexExpression.qml
@@ -0,0 +1,28 @@
+/**
+ * LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
+ * Copyright (C) 2022 Ad5001
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+import QtQuick 2.12
+import QtQuick.Controls 2.12
+
+Image {
+ id: expr
+ property string expression
+
+ src: Latex.render(expression).split(',')[0]
+}
diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js
index 0d03bb6..599766d 100644
--- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js
+++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js
@@ -219,47 +219,15 @@ class DrawableObject {
* @param {string|Enum} labelPosition - Position of the label relative to the marked position
* @param {number} posX - Component of the marked position on the x-axis
* @param {number} posY - Component of the marked position on the y-axis
+ * @param {bool} forceText - Force the rendering of the label as text.
*/
- drawLabel(canvas, ctx, labelPosition, posX, posY) {
- if(true) { // TODO: Check for user setting with Latex.
+ drawLabel(canvas, ctx, labelPosition, posX, posY, forceText = false) {
+ let offset
+ if(!forceText && true) { // TODO: Check for user setting with Latex.
// With latex
- let offset = 8
let drawLblCb = function(canvas, ctx, ltxImg) {
- switch(this.labelPosition) {
- case 'center':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY-ltxImg.height/2, ltxImg.width, ltxImg.height)
- break;
- case 'top':
- case 'above':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY-(ltxImg.height+offset), ltxImg.width, ltxImg.height)
- break;
- case 'bottom':
- case 'below':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY+offset, ltxImg.width, ltxImg.height)
- break;
- case 'left':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+offset), posY-ltxImg.height/2, ltxImg.width, ltxImg.height)
- break;
- case 'right':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX+offset, posY-ltxImg.height/2, ltxImg.width, ltxImg.height)
- break;
- case 'top-left':
- case 'above-left':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+offset), posY-(ltxImg.height+offset), ltxImg.width, ltxImg.height)
- break;
- case 'top-right':
- case 'above-right':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX+offset, posY-(ltxImg.height+offset), ltxImg.width, ltxImg.height)
- break;
- case 'bottom-left':
- case 'below-left':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+offset), posY+offset, ltxImg.width, ltxImg.height)
- break;
- case 'bottom-right':
- case 'below-right':
- canvas.drawVisibleImage(ctx, ltxImg.source, posX+offset, posY+offset, ltxImg.width, ltxImg.height)
- break;
- }
+ this.drawLabelDivergence(labelPosition, 8, ltxImg, posX, posY,
+ (x,y) => canvas.drawVisibleImage(ctx, ltxImg.source, x, y, ltxImg.width, ltxImg.height))
}
let ltxLabel = this.getLatexLabel();
if(ltxLabel != "")
@@ -269,43 +237,59 @@ class DrawableObject {
// Without latex
let text = this.getLabel()
ctx.font = `${canvas.textsize}px sans-serif`
- let textSize = canvas.measureText(ctx, text)
- let offset = 4
- switch(labelPosition) {
- case 'center':
- canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height/2)
- break;
- case 'top':
- case 'above':
- canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height-offset)
- break;
- case 'bottom':
- case 'below':
- canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY+offset)
- break;
- case 'left':
- canvas.drawVisibleText(ctx, text, posX-textSize.width-offset, posY-textSize.height/2)
- break;
- case 'right':
- canvas.drawVisibleText(ctx, text, posX+offset, posY-textSize.height/2)
- break;
- case 'top-left':
- case 'above-left':
- canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height-offset)
- break;
- case 'top-right':
- case 'above-right':
- canvas.drawVisibleText(ctx, text, posX+offset, posY-textSize.height-offset)
- break;
- case 'bottom-left':
- case 'below-left':
- canvas.drawVisibleText(ctx, text, posX-textSize.width-offset, posY+offset)
- break;
- case 'bottom-right':
- case 'below-right':
- canvas.drawVisibleText(ctx, text, posX+offset, posY+offset)
- break;
- }
+ this.drawLabelDivergence(labelPosition, 4, canvas.measureText(ctx, text), posX, posY,
+ (x,y) => canvas.drawVisibleText(ctx, text, x, y))
+ }
+ }
+
+
+ /**
+ * Applicates a \c drawFunction with two position arguments depending on
+ * both the \c posX and \c posY of where the label should be displayed,
+ * and the \c labelPosition which declares the label should be displayed
+ * relatively to that position.
+ * @param {string|Enum} labelPosition - Position of the label relative to the marked position
+ * @param {number} offset - Margin between the position and the object to be drawn
+ * @param {Dictionary} size - Size of the label item, containing two properties, "width" and "height"
+ * @param {number} posX - Component of the marked position on the x-axis
+ * @param {number} posY - Component of the marked position on the y-axis
+ * @param {function} drawFunction - Function with two arguments (x, y) that will be called to draw the label
+ */
+ drawLabelDivergence(labelPosition, offset, size, posX, posY, drawFunction) {
+ switch(labelPosition) {
+ case 'center':
+ drawFunction(posX-size.width/2, posY-size.height/2)
+ break;
+ case 'top':
+ case 'above':
+ drawFunction(posX-size.width/2, posY-size.height-offset)
+ break;
+ case 'bottom':
+ case 'below':
+ drawFunction(posX-size.width/2, posY+offset)
+ break;
+ case 'left':
+ drawFunction(posX-size.width-offset, posY-size.height/2)
+ break;
+ case 'right':
+ drawFunction(posX+offset, posY-size.height/2)
+ break;
+ case 'top-left':
+ case 'above-left':
+ drawFunction(posX-size.width, posY-size.height-offset)
+ break;
+ case 'top-right':
+ case 'above-right':
+ drawFunction(posX+offset, posY-size.height-offset)
+ break;
+ case 'bottom-left':
+ case 'below-left':
+ drawFunction(posX-size.width-offset, posY+offset)
+ break;
+ case 'bottom-right':
+ case 'below-right':
+ drawFunction(posX+offset, posY+offset)
+ break;
}
}
diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/text.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/text.js
index 92d27f5..edfa9f5 100644
--- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/text.js
+++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/text.js
@@ -37,11 +37,12 @@ class Text extends Common.DrawableObject {
[QT_TRANSLATE_NOOP('prop','x')]: 'Expression',
[QT_TRANSLATE_NOOP('prop','y')]: 'Expression',
[QT_TRANSLATE_NOOP('prop','labelPosition')]: P.Enum.Positioning,
- [QT_TRANSLATE_NOOP('prop','text')]: 'string'
+ [QT_TRANSLATE_NOOP('prop','text')]: 'string',
+ [QT_TRANSLATE_NOOP('prop','disableLatex')]: 'boolean'
}}
constructor(name = null, visible = true, color = null, labelContent = 'null',
- x = 1, y = 0, labelPosition = 'center', text = 'New text') {
+ x = 1, y = 0, labelPosition = 'center', text = 'New text', disableLatex = false) {
if(name == null) name = Common.getNewName('t')
super(name, visible, color, labelContent)
this.type = 'Point'
@@ -51,50 +52,45 @@ class Text extends Common.DrawableObject {
this.y = y
this.labelPosition = labelPosition
this.text = text
+ this.disableLatex = disableLatex
}
getReadableString() {
return `${this.name} = "${this.text}"`
}
+ latexMarkupText() {
+ let txt = this.text
+ let i
+ for(i = 0; txt.includes('$$'); i++)
+ if(i & 0x01) // Every odd number
+ txt = txt.replace('$$', '\\textrm{')
+ else
+ txt = txt.replace('$$', '}')
+ if(i & 0x01) // Finished by a }
+ txt += "{"
+ return txt
+ }
+
+ getLatexString() {
+ return `${Latex.variable(this.name)} = "\\textrm{${this.latexMarkupText()}}"`
+ }
+
export() {
return [this.name, this.visible, this.color.toString(), this.labelContent, this.x.toEditableString(), this.y.toEditableString(), this.labelPosition, this.text]
}
+ getLabel() {
+ return this.text
+ }
+
+ getLatexLabel() {
+ return `\\textrm{${this.latexMarkupText()}}`
+ }
+
draw(canvas, ctx) {
- var [canvasX, canvasY] = [canvas.x2px(this.x.execute()), canvas.y2px(this.y.execute())]
- ctx.font = `${canvas.textsize}px sans-serif`
- var textSize = ctx.measureText(this.text).width
- switch(this.labelPosition) {
- case 'center':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+4)
- break;
- case 'top':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY-16)
- break;
- case 'bottom':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+16)
- break;
- case 'left':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY+4)
- break;
- case 'right':
- canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+4)
- break;
- case 'top-left':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY-16)
- break;
- case 'top-right':
- canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY-16)
- break;
- case 'bottom-left':
- canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY+16)
- break;
- case 'bottom-right':
- canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+16)
- break;
-
- }
+ let yOffset = this.disableLatex ? canvas.textsize-4 : 0
+ this.drawLabel(canvas, ctx, this.labelPosition, canvas.x2px(this.x.execute()), canvas.y2px(this.y.execute())+yOffset, this.disableLatex)
}
}
diff --git a/LogarithmPlotter/util/latex.py b/LogarithmPlotter/util/latex.py
index 1f4c098..7822f49 100644
--- a/LogarithmPlotter/util/latex.py
+++ b/LogarithmPlotter/util/latex.py
@@ -143,11 +143,11 @@ class Latex(QObject):
"""
proc = Popen(process, stdout=PIPE, stderr=PIPE, cwd=self.tempdir.name)
try:
- out, err = proc.communicate(timeout=5) # 5 seconds is already FAR too long.
+ out, err = proc.communicate(timeout=2) # 2 seconds is already FAR too long.
if proc.returncode != 0:
# Process errored
QMessageBox.warning(None, "LogarithmPlotter - Latex",
- QCoreApplication.translate("latex", "An exception occured within the creation of the latex formula.\nProcess '{}' ended with a non-zero return code {}:\n{}\nPlease make sure your latex installation is correct and report a bug if so.")
+ QCoreApplication.translate("latex", "An exception occured within the creation of the latex formula.\nProcess '{}' ended with a non-zero return code {}:\n\n{}\nPlease make sure your latex installation is correct and report a bug if so.")
.format(" ".join(process), proc.returncode, str(out, 'utf8')+"\n"+str(err,'utf8')))
raise Exception(" ".join(process) + " process exited with return code " + str(proc.returncode) + ":\n" + str(out, 'utf8')+"\n"+str(err,'utf8'))
except TimeoutExpired as e: