From 12ecf3b19b6fcd8e965278e82b6fe1c1e4e65db5 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Mon, 7 Mar 2022 02:46:38 +0100 Subject: [PATCH] Adding LatexExpression, LaTeX integration for texts (needs a comment tho) - Simplified label rendering for both Latex and normal mode - Texts now can integrate latex expressions in latex mode - There is now a toggle for texts to use normal fonts or integrate latex - Updated translation sources. --- LogarithmPlotter/i18n/lp_de.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_en.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_es.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_fr.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_hu.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_nb_NO.ts | 133 +++++++++++------ LogarithmPlotter/i18n/lp_template.ts | 133 +++++++++++------ .../Setting/LatexExpression.qml | 28 ++++ .../ad5001/LogarithmPlotter/js/objs/common.js | 134 ++++++++---------- .../ad5001/LogarithmPlotter/js/objs/text.js | 66 ++++----- LogarithmPlotter/util/latex.py | 4 +- 11 files changed, 722 insertions(+), 441 deletions(-) create mode 100644 LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Setting/LatexExpression.qml 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 - + About LogarithmPlotter Über LogarithmPlotter @@ -529,12 +529,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" comment - + Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} Beispiel: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ-*), ]0;1[, {3;4;5} - + The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) 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. - + Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... 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-Magnitude - + Bode Magnitudes Bode-Magnituden - + + low-pass Tiefpass - + + high-pass 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 + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -781,12 +815,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" phasebode - + Bode Phase Bode-Phase - + Bode Phases Bode-Phasen @@ -807,108 +841,108 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" prop - + expression Ausdruck - + definitionDomain Definitionsbereich - + destinationDomain Reichweite - - - - + + + + - - - + + + labelPosition Position des Etiketts - + displayMode Anzeigemodus - - - + + + - - - + + + labelX X-Position des Etiketts - - + + drawPoints Unentschiedene Punkte - - + + drawDashedLines Gestrichelte Linien anzeigen - - + + om_0 ω₀ - + pass Pass - + gain Größenordnung - + omGraduation Teilung auf ω zeigen - + phase Phase - + unit Einheit - + x X - + y Y - + pointStyle Punkt-Stil @@ -922,6 +956,11 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" text Inhalt + + + disableLatex + + targetElement @@ -948,12 +987,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Wertposition des Ziels - + defaultExpression Standardausdruck - + baseValues Initialisierungswerte @@ -978,12 +1017,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" sequence - + Sequence Folge - + Sequences Folgen @@ -991,8 +1030,8 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" sommegainsbode - + Bode Magnitudes Sum Bode-Magnituden Summe @@ -1000,8 +1039,8 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" sommephasesbode - + Bode Phases Sum 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 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} Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} - + The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) 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ₙ₊₁... 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 Magnitude - + Bode Magnitudes Bode Magnitudes - + + low-pass low-pass - + + high-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 + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -781,12 +815,12 @@ These settings can be changed at any time from the "Settings" menu. phasebode - + Bode Phase Bode Phase - + Bode Phases Bode Phases @@ -807,108 +841,108 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression Expression - + definitionDomain Domain - + destinationDomain Range - - - - + + + + - - - + + + labelPosition Label position - + displayMode Display mode - - - + + + - - - + + + labelX Label's X position - - + + drawPoints Show points - - + + drawDashedLines Show dashed lines - - + + om_0 ω₀ - + pass Pass - + gain Magnitude gain - + omGraduation Show graduation on ω₀ - + phase Phase - + unit Unit to use - + x X - + y Y - + pointStyle Point style @@ -922,6 +956,11 @@ These settings can be changed at any time from the "Settings" menu.text Content + + + disableLatex + + targetElement @@ -948,12 +987,12 @@ These settings can be changed at any time from the "Settings" menu.Target's value position - + defaultExpression Default expression - + baseValues Initialisation values @@ -978,12 +1017,12 @@ These settings can be changed at any time from the "Settings" menu. sequence - + Sequence Sequence - + Sequences Sequences @@ -991,8 +1030,8 @@ These settings can be changed at any time from the "Settings" menu. sommegainsbode - + Bode Magnitudes Sum Bode Magnitudes Sum @@ -1000,8 +1039,8 @@ These settings can be changed at any time from the "Settings" menu. sommephasesbode - + Bode Phases Sum 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 - + About LogarithmPlotter Sobre LogarithmPlotter @@ -528,12 +528,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 definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) @@ -543,7 +543,7 @@ These settings can be changed at any time from the "Settings" menu. - + Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... @@ -606,26 +606,60 @@ These settings can be changed at any time from the "Settings" menu. gainbode - + Bode Magnitude - + Bode Magnitudes - + + low-pass - + + high-pass + + latex + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -753,12 +787,12 @@ These settings can be changed at any time from the "Settings" menu. phasebode - + Bode Phase - + Bode Phases @@ -779,108 +813,108 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression - + definitionDomain - + destinationDomain - - - - + + + + - - - + + + labelPosition - + displayMode - - - + + + - - - + + + labelX - - + + drawPoints - - + + drawDashedLines - - + + om_0 - + pass - + gain - + omGraduation - + phase - + unit - + x - + y - + pointStyle @@ -894,6 +928,11 @@ These settings can be changed at any time from the "Settings" menu.text + + + disableLatex + + targetElement @@ -920,12 +959,12 @@ These settings can be changed at any time from the "Settings" menu. - + defaultExpression - + baseValues @@ -946,12 +985,12 @@ These settings can be changed at any time from the "Settings" menu. sequence - + Sequence - + Sequences @@ -959,8 +998,8 @@ These settings can be changed at any time from the "Settings" menu. sommegainsbode - + Bode Magnitudes Sum @@ -968,8 +1007,8 @@ These settings can be changed at any time from the "Settings" menu. sommephasesbode - + Bode Phases Sum 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 - + About LogarithmPlotter À propos de LogarithmPlotter @@ -537,12 +537,12 @@ These settings can always be changed at any time from the "Settings" m comment - + Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} Par exemple : R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} - + The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) 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: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... 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 - + Bode Magnitude Gain de Bode - + Bode Magnitudes Gains de Bode - + + low-pass passe-bas - + + high-pass 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 + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -790,12 +824,12 @@ These settings can always be changed at any time from the "Settings" m phasebode - + Bode Phase Phase de Bode - + Bode Phases Phases de Bode @@ -816,108 +850,108 @@ These settings can always be changed at any time from the "Settings" m prop - + expression Expression - + definitionDomain Domaine de définition - + destinationDomain Portée - - - - + + + + - - - + + + labelPosition Position de l'étiquette - + displayMode Mode d'affichage - - - + + + - - - + + + labelX Position en X de l'étiquette - - + + drawPoints Afficher les points - - + + drawDashedLines Afficher les pointillés - - + + om_0 ω₀ - + pass Passe - + gain Gain - + omGraduation Afficher la graduation sur ω₀ - + phase Phase - + unit Unité de la phase - + x X - + y Y - + pointStyle Style du point @@ -931,6 +965,11 @@ These settings can always be changed at any time from the "Settings" m text Contenu + + + disableLatex + + targetElement @@ -957,12 +996,12 @@ These settings can always be changed at any time from the "Settings" m Position de la valeur de la cible - + defaultExpression Expression - + baseValues Valeurs d'initialisation @@ -987,12 +1026,12 @@ These settings can always be changed at any time from the "Settings" m sequence - + Sequence Suite - + Sequences Suites @@ -1000,8 +1039,8 @@ These settings can always be changed at any time from the "Settings" m sommegainsbode - + Bode Magnitudes Sum Sommes des gains de Bode @@ -1009,8 +1048,8 @@ These settings can always be changed at any time from the "Settings" m sommephasesbode - + Bode Phases Sum 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 - + About LogarithmPlotter 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 - + Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} Példák: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} - + The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) 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. - + Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... 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 Magnitude Bode-nagyságrend - + Bode Magnitudes Bode-nagyságrendek - + + low-pass aluláteresztő - + + high-pass 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 + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + 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 Phase Bode-fázis - + Bode Phases 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 - + expression Kifejezés - + definitionDomain Abszcissza tartomány - + destinationDomain Ordináta tartomány - - - - + + + + - - - + + + labelPosition Címke helyzete - + displayMode Megjelenítési mód - - - + + + - - - + + + labelX Címke X helyzete - - + + drawPoints Pontok megjelenítése - - + + drawDashedLines Szaggatott vonalak megjelenítése - - + + om_0 ω₀ - + pass Áteresztő - + gain Nagyságrend nyeresége - + omGraduation ω₀ érettségi megjelenítése - + phase Fázis - + unit Egység használata - + x X - + y Y - + pointStyle 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. text Tartalom + + + disableLatex + + targetElement @@ -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 - + defaultExpression Alapértelmezett kifejezés - + baseValues 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 - + Sequence Sorozat - + Sequences 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 Magnitudes Sum 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 Phases Sum 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 - + About LogarithmPlotter Om @@ -529,12 +529,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. comment - + Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5} - + The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) @@ -544,7 +544,7 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... @@ -607,22 +607,24 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. gainbode - + Bode Magnitude Bode-magnitude - + Bode Magnitudes Bode-magnituder - + + low-pass lavpass - + + high-pass høypass @@ -650,6 +652,38 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.%1 %2 skjult. + + latex + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -777,12 +811,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. phasebode - + Bode Phase Bode-fase - + Bode Phases Bode-faser @@ -803,108 +837,108 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. prop - + expression - + definitionDomain - + destinationDomain - - - - + + + + - - - + + + labelPosition - + displayMode - - - + + + - - - + + + labelX - - + + drawPoints - - + + drawDashedLines - - + + om_0 - + pass - + gain - + omGraduation - + phase - + unit - + x - + y - + pointStyle @@ -918,6 +952,11 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.text + + + disableLatex + + targetElement @@ -944,12 +983,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + defaultExpression - + baseValues @@ -970,12 +1009,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. sequence - + Sequence Følge - + Sequences Følger @@ -983,8 +1022,8 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. sommegainsbode - + Bode Magnitudes Sum Bode-magnitudesum @@ -992,8 +1031,8 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. sommephasesbode - + Bode Phases Sum 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 - + About LogarithmPlotter @@ -528,12 +528,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 definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...) @@ -543,7 +543,7 @@ These settings can be changed at any time from the "Settings" menu. - + Note: Use %1[n] to refer to %1ₙ, %1[n+1] for %1ₙ₊₁... @@ -606,26 +606,60 @@ These settings can be changed at any time from the "Settings" menu. gainbode - + Bode Magnitude - + Bode Magnitudes - + + low-pass - + + high-pass + + latex + + + No Latex installation found. +If you already have a latex distribution installed, make sure it's installed on your path. +Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. + + + + + DVIPNG was not found. Make sure you include it from your Latex distribution. + + + + + An exception occured within the creation of the latex formula. +Process '{}' ended with a non-zero return code {}: + +{} +Please make sure your latex installation is correct and report a bug if so. + + + + + An exception occured within the creation of the latex formula. +Process '{}' took too long to finish: +{} +Please make sure your latex installation is correct and report a bug if so. + + + name @@ -753,12 +787,12 @@ These settings can be changed at any time from the "Settings" menu. phasebode - + Bode Phase - + Bode Phases @@ -779,108 +813,108 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression - + definitionDomain - + destinationDomain - - - - + + + + - - - + + + labelPosition - + displayMode - - - + + + - - - + + + labelX - - + + drawPoints - - + + drawDashedLines - - + + om_0 - + pass - + gain - + omGraduation - + phase - + unit - + x - + y - + pointStyle @@ -894,6 +928,11 @@ These settings can be changed at any time from the "Settings" menu.text + + + disableLatex + + targetElement @@ -920,12 +959,12 @@ These settings can be changed at any time from the "Settings" menu. - + defaultExpression - + baseValues @@ -946,12 +985,12 @@ These settings can be changed at any time from the "Settings" menu. sequence - + Sequence - + Sequences @@ -959,8 +998,8 @@ These settings can be changed at any time from the "Settings" menu. sommegainsbode - + Bode Magnitudes Sum @@ -968,8 +1007,8 @@ These settings can be changed at any time from the "Settings" menu. sommephasesbode - + Bode Phases Sum 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: