diff --git a/LogarithmPlotter/i18n/lp_de.ts b/LogarithmPlotter/i18n/lp_de.ts index d6d6ee9..5fc986d 100644 --- a/LogarithmPlotter/i18n/lp_de.ts +++ b/LogarithmPlotter/i18n/lp_de.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter Über LogarithmPlotter @@ -279,7 +279,7 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" ListSetting - + + Add Entry + Neuer Eintrag @@ -507,12 +507,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" changelog - + Could not fetch changelog: Server error {}. Changelog konnte nicht geholt werden: Server-Fehler {}. - + Could not fetch update: {}. Changelog konnte nicht geholt werden: {}. @@ -529,17 +529,17 @@ 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}...) - + Note: Specify the probability for each value. Hinweis: Geben Sie die Wahrscheinlichkeit für jeden Wert an. @@ -554,7 +554,7 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" - + %1: %1: @@ -594,12 +594,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" function - + Function Funktion - + Functions Funktionen @@ -794,12 +794,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" point - + Point Punkt - + Points Punkte @@ -807,26 +807,26 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" prop - + expression Ausdruck - + definitionDomain Definitionsbereich - + destinationDomain Reichweite - + - - + + @@ -836,15 +836,15 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Position des Etiketts - + displayMode Anzeigemodus - + - + @@ -852,13 +852,13 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" X-Position des Etiketts - + drawPoints Unentschiedene Punkte - + drawDashedLines Gestrichelte Linien anzeigen @@ -895,25 +895,25 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Einheit - + x X - + y Y - + pointStyle Punkt-Stil - + probabilities Wahrscheinlichkeiten @@ -965,12 +965,12 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" repartition - + Repartition Verteilungsfunktion - + Repartition functions Verteilungsfunktionen @@ -1022,22 +1022,22 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" update - + An update for LogarithPlotter (v{}) is available. Ein Aktualisierung für LogarithmPlotter (v{}) ist verfügbar. - + No update available. Keine Aktualisierung verfügbar. - + Could not fetch update information: Server error {}. Es konnten keine Aktualisierungsinformationen abgerufen werden: Server-Fehler {}. - + Could not fetch update information: {}. Es konnten keine Aktualisierungsinformationen abgerufen werden:{}. diff --git a/LogarithmPlotter/i18n/lp_en.ts b/LogarithmPlotter/i18n/lp_en.ts index c721ac3..fd9567a 100644 --- a/LogarithmPlotter/i18n/lp_en.ts +++ b/LogarithmPlotter/i18n/lp_en.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter About LogarithmPlotter @@ -279,7 +279,7 @@ These settings can be changed at any time from the "Settings" menu. ListSetting - + + Add Entry + Add Entry @@ -507,12 +507,12 @@ These settings can be changed at any time from the "Settings" menu. changelog - + Could not fetch changelog: Server error {}. Could not fetch changelog: Server error {}. - + Could not fetch update: {}. Could not fetch changelog: {}. @@ -529,17 +529,17 @@ 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}…) - + Note: Specify the probability for each value. Note: Specify the probability for each value. @@ -554,7 +554,7 @@ These settings can be changed at any time from the "Settings" menu. - + %1: %1: @@ -594,12 +594,12 @@ These settings can be changed at any time from the "Settings" menu. function - + Function Function - + Functions Functions @@ -794,12 +794,12 @@ These settings can be changed at any time from the "Settings" menu. point - + Point Point - + Points Points @@ -807,26 +807,26 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression Expression - + definitionDomain Domain - + destinationDomain Range - + - - + + @@ -836,15 +836,15 @@ These settings can be changed at any time from the "Settings" menu.Label position - + displayMode Display mode - + - + @@ -852,13 +852,13 @@ These settings can be changed at any time from the "Settings" menu.Label's X position - + drawPoints Show points - + drawDashedLines Show dashed lines @@ -895,25 +895,25 @@ These settings can be changed at any time from the "Settings" menu.Unit to use - + x X - + y Y - + pointStyle Point style - + probabilities Probabilities list @@ -965,12 +965,12 @@ These settings can be changed at any time from the "Settings" menu. repartition - + Repartition Distribution - + Repartition functions Distribution functions @@ -1022,22 +1022,22 @@ These settings can be changed at any time from the "Settings" menu. update - + An update for LogarithPlotter (v{}) is available. An update for LogarithmPlotter (v{}) is available. - + No update available. No update available. - + Could not fetch update information: Server error {}. Could not fetch update information: Server error {}. - + Could not fetch update information: {}. Could not fetch update information: {}. diff --git a/LogarithmPlotter/i18n/lp_es.ts b/LogarithmPlotter/i18n/lp_es.ts index 16c53ff..fe30649 100644 --- a/LogarithmPlotter/i18n/lp_es.ts +++ b/LogarithmPlotter/i18n/lp_es.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter Sobre LogarithmPlotter @@ -278,7 +278,7 @@ These settings can be changed at any time from the "Settings" menu. ListSetting - + + Add Entry @@ -506,12 +506,12 @@ These settings can be changed at any time from the "Settings" menu. changelog - + Could not fetch changelog: Server error {}. - + Could not fetch update: {}. @@ -528,17 +528,17 @@ 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}...) - + Note: Specify the probability for each value. @@ -553,7 +553,7 @@ These settings can be changed at any time from the "Settings" menu. - + %1: @@ -593,12 +593,12 @@ These settings can be changed at any time from the "Settings" menu. function - + Function - + Functions @@ -766,12 +766,12 @@ These settings can be changed at any time from the "Settings" menu. point - + Point - + Points @@ -779,26 +779,26 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression - + definitionDomain - + destinationDomain - + - - + + @@ -808,15 +808,15 @@ These settings can be changed at any time from the "Settings" menu. - + displayMode - + - + @@ -824,13 +824,13 @@ These settings can be changed at any time from the "Settings" menu. - + drawPoints - + drawDashedLines @@ -867,25 +867,25 @@ These settings can be changed at any time from the "Settings" menu. - + x - + y - + pointStyle - + probabilities @@ -933,12 +933,12 @@ These settings can be changed at any time from the "Settings" menu. repartition - + Repartition - + Repartition functions @@ -990,22 +990,22 @@ These settings can be changed at any time from the "Settings" menu. update - + An update for LogarithPlotter (v{}) is available. - + No update available. - + Could not fetch update information: Server error {}. - + Could not fetch update information: {}. diff --git a/LogarithmPlotter/i18n/lp_fr.ts b/LogarithmPlotter/i18n/lp_fr.ts index 2fb1234..42ef942 100644 --- a/LogarithmPlotter/i18n/lp_fr.ts +++ b/LogarithmPlotter/i18n/lp_fr.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter À propos de LogarithmPlotter @@ -287,7 +287,7 @@ These settings can always be changed at any time from the "Settings" m ListSetting - + + Add Entry + Nouvelle entrée @@ -515,12 +515,12 @@ These settings can always be changed at any time from the "Settings" m changelog - + Could not fetch changelog: Server error {}. Impossible de récupérer l'historique des modifications : Erreur de serveur {}. - + Could not fetch update: {}. Impossible de récupérer l'historique des modifications : {}. @@ -537,17 +537,17 @@ 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}…) - + Note: Specify the probability for each value. Note : Spécifiez la probabilité pour chaque valeur. @@ -563,7 +563,7 @@ These settings can always be changed at any time from the "Settings" m - + %1: %1 : @@ -603,12 +603,12 @@ These settings can always be changed at any time from the "Settings" m function - + Function Fonction - + Functions Fonctions @@ -803,12 +803,12 @@ These settings can always be changed at any time from the "Settings" m point - + Point Point - + Points Points @@ -816,26 +816,26 @@ These settings can always be changed at any time from the "Settings" m prop - + expression Expression - + definitionDomain Domaine de définition - + destinationDomain Portée - + - - + + @@ -845,15 +845,15 @@ These settings can always be changed at any time from the "Settings" m Position de l'étiquette - + displayMode Mode d'affichage - + - + @@ -861,13 +861,13 @@ These settings can always be changed at any time from the "Settings" m Position en X de l'étiquette - + drawPoints Afficher les points - + drawDashedLines Afficher les pointillés @@ -904,25 +904,25 @@ These settings can always be changed at any time from the "Settings" m Unité de la phase - + x X - + y Y - + pointStyle Style du point - + probabilities Liste de probabilités @@ -974,12 +974,12 @@ These settings can always be changed at any time from the "Settings" m repartition - + Repartition Répartition - + Repartition functions Fonctions de répartition @@ -1031,22 +1031,22 @@ These settings can always be changed at any time from the "Settings" m update - + An update for LogarithPlotter (v{}) is available. Une mise à jour de LogarithmPlotter (v{}) est disponible. - + No update available. À jour. - + Could not fetch update information: Server error {}. Impossible de récupérer les informations de mise à jour. Erreur du serveur {}. - + Could not fetch update information: {}. Impossible de récupérer les informations de mise à jour. {}. diff --git a/LogarithmPlotter/i18n/lp_hu.ts b/LogarithmPlotter/i18n/lp_hu.ts index 43a5bad..0ee9d08 100644 --- a/LogarithmPlotter/i18n/lp_hu.ts +++ b/LogarithmPlotter/i18n/lp_hu.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter LogarithmPlotter névjegye @@ -279,7 +279,7 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. ListSetting - + + Add Entry + Bejegyzés hozzáadása @@ -507,12 +507,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. changelog - + Could not fetch changelog: Server error {}. Nem sikerült lekérni a változásnaplót: Kiszolgálóhiba: {}. - + Could not fetch update: {}. Nem sikerült lekérni a változásnaplót: {}. @@ -529,17 +529,17 @@ 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}…) - + Note: Specify the probability for each value. Megjegyzés: Adja meg az egyes értékek valószínűségét. @@ -554,7 +554,7 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. - + %1: %1: @@ -594,12 +594,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. function - + Function Függvény - + Functions Függvények @@ -790,12 +790,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. point - + Point Pont - + Points Pontok @@ -803,26 +803,26 @@ 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 - + - - + + @@ -832,15 +832,15 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. Címke helyzete - + displayMode Megjelenítési mód - + - + @@ -848,13 +848,13 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. Címke X helyzete - + drawPoints Pontok megjelenítése - + drawDashedLines Szaggatott vonalak megjelenítése @@ -891,25 +891,25 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. Egység használata - + x X - + y Y - + pointStyle Pontstílus - + probabilities Valószínűségek listája @@ -957,12 +957,12 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. repartition - + Repartition Elosztás - + Repartition functions Elosztási függvények @@ -1014,22 +1014,22 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. update - + An update for LogarithPlotter (v{}) is available. Elérhető a Logaritmus-ábrázoló ({} verzió) frissítése. - + No update available. Nincs telepíthető frissítés. - + Could not fetch update information: Server error {}. Nem sikerült lekérni a frissítési adatokat: Kiszolgálóhiba: {}. - + Could not fetch update information: {}. Nem sikerült lekérni a frissítési adatokat: {}. diff --git a/LogarithmPlotter/i18n/lp_nb_NO.ts b/LogarithmPlotter/i18n/lp_nb_NO.ts index 898785b..cacb689 100644 --- a/LogarithmPlotter/i18n/lp_nb_NO.ts +++ b/LogarithmPlotter/i18n/lp_nb_NO.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter Om @@ -279,7 +279,7 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. ListSetting - + + Add Entry @@ -507,12 +507,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. changelog - + Could not fetch changelog: Server error {}. - + Could not fetch update: {}. @@ -529,17 +529,17 @@ 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}...) - + Note: Specify the probability for each value. @@ -554,7 +554,7 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + %1: @@ -594,12 +594,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. function - + Function Funksjon - + Functions Funksjoner @@ -790,12 +790,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. point - + Point Punkt - + Points Punkter @@ -803,26 +803,26 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. prop - + expression - + definitionDomain - + destinationDomain - + - - + + @@ -832,15 +832,15 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + displayMode - + - + @@ -848,13 +848,13 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + drawPoints - + drawDashedLines @@ -891,25 +891,25 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + x - + y - + pointStyle - + probabilities @@ -957,12 +957,12 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. repartition - + Repartition Distribusjon - + Repartition functions Distribusjonsfunksjoner @@ -1014,22 +1014,22 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. update - + An update for LogarithPlotter (v{}) is available. En ny versjon av LogartimePlotter (v{}) er tilgjengelig - + No update available. Ingen nye versjoner. - + Could not fetch update information: Server error {}. Fant ikke ut om det er noen nye versjoner. Tjenerfeil {}. - + Could not fetch update information: {}. Kunne ikke hente info om hvorvidt det er nye versjoner: {}. diff --git a/LogarithmPlotter/i18n/lp_template.ts b/LogarithmPlotter/i18n/lp_template.ts index d3888b9..d1dcea8 100644 --- a/LogarithmPlotter/i18n/lp_template.ts +++ b/LogarithmPlotter/i18n/lp_template.ts @@ -5,7 +5,7 @@ About - + About LogarithmPlotter @@ -278,7 +278,7 @@ These settings can be changed at any time from the "Settings" menu. ListSetting - + + Add Entry @@ -506,12 +506,12 @@ These settings can be changed at any time from the "Settings" menu. changelog - + Could not fetch changelog: Server error {}. - + Could not fetch update: {}. @@ -528,17 +528,17 @@ 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}...) - + Note: Specify the probability for each value. @@ -553,7 +553,7 @@ These settings can be changed at any time from the "Settings" menu. - + %1: @@ -593,12 +593,12 @@ These settings can be changed at any time from the "Settings" menu. function - + Function - + Functions @@ -766,12 +766,12 @@ These settings can be changed at any time from the "Settings" menu. point - + Point - + Points @@ -779,26 +779,26 @@ These settings can be changed at any time from the "Settings" menu. prop - + expression - + definitionDomain - + destinationDomain - + - - + + @@ -808,15 +808,15 @@ These settings can be changed at any time from the "Settings" menu. - + displayMode - + - + @@ -824,13 +824,13 @@ These settings can be changed at any time from the "Settings" menu. - + drawPoints - + drawDashedLines @@ -867,25 +867,25 @@ These settings can be changed at any time from the "Settings" menu. - + x - + y - + pointStyle - + probabilities @@ -933,12 +933,12 @@ These settings can be changed at any time from the "Settings" menu. repartition - + Repartition - + Repartition functions @@ -990,22 +990,22 @@ These settings can be changed at any time from the "Settings" menu. update - + An update for LogarithPlotter (v{}) is available. - + No update available. - + Could not fetch update information: Server error {}. - + Could not fetch update information: {}. diff --git a/LogarithmPlotter/logarithmplotter.py b/LogarithmPlotter/logarithmplotter.py index 2ce7b94..56985e2 100644 --- a/LogarithmPlotter/logarithmplotter.py +++ b/LogarithmPlotter/logarithmplotter.py @@ -22,7 +22,7 @@ start_time = time() from PySide2.QtWidgets import QApplication from PySide2.QtQml import QQmlApplicationEngine -from PySide2.QtCore import QTranslator, QLocale +from PySide2.QtCore import Qt, QTranslator, QLocale from PySide2.QtGui import QIcon from tempfile import TemporaryDirectory @@ -89,6 +89,7 @@ def run(): app.setApplicationName("LogarithmPlotter") app.setOrganizationName("Ad5001") app.styleHints().setShowShortcutsInContextMenus(True) + app.setAttribute(Qt.AA_EnableHighDpiScaling) app.setWindowIcon(QIcon(path.realpath(path.join(getcwd(), "logarithmplotter.svg")))) # Installing translators diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/latex.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/latex.js index 35bc2dc..e036960 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/latex.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/latex.js @@ -83,7 +83,7 @@ function functionToLatex(f, args) { * @param {string} vari - variable to convert * @returns {string} */ -function variableToLatex(vari) { +function variable(vari) { let unicodechars = ["α","β","γ","δ","ε","ζ","η", "π","θ","κ","λ","μ","ξ","ρ", "ς","σ","τ","φ","χ","ψ","ω", @@ -185,7 +185,7 @@ function expressionToLatex(tokens) { break; case ExprEval.IVAR: case ExprEval.IVARNAME: - nstack.push(variableToLatex(item.value.toString())); + nstack.push(variable(item.value.toString())); break; case ExprEval.IOP1: // Unary operator n1 = nstack.pop(); diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js index c602224..0d03bb6 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/common.js @@ -20,10 +20,16 @@ .import "../utils.js" as Utils .import "../objects.js" as Objects +.import "../math/latex.js" as Latex // This file contains the default data to be imported from all other objects - +/** + * Creates a new name for an object, based on the \c allowedLetters. + * If variables with each of the allowedLetters is created, a subscript + * number is added to the name. + * @return {string} New unused name for a new object. + */ function getNewName(allowedLetters) { // Allows to get a new name, based on the allowed letters, // as well as adding a sub number when needs be. @@ -38,33 +44,70 @@ function getNewName(allowedLetters) { return ret } +/** + * Class to extend for every type of object that + * can be drawn on the canvas. + */ class DrawableObject { - // Class to extend for every type of object that - // can be drawn on the canvas. - - // Base name of the object. Needs to be constant over time. + /** + * Base name of the object. Needs to be constant over time. + * @return {string} Type of the object. + */ static type(){return 'Unknown'} - // (Potentially translated) name of the object to be shown to the user. + /** + * Translated name of the object to be shown to the user. + * @return {string} + */ static displayType(){return 'Unknown'} - // Label used for the list on the ObjectsList sidebar. + /** + * Translated name of the object in plural form to be shown to the user. + * @return {string} + */ static displayTypeMultiple(){return 'Unknowns'} - // Whether this object can be created by the user - // or are instantiated by other objects. + /** + * True if this object can be created by the user, false if it can only + * be instantiated by other objects + * @return {bool} + */ static createable() {return true} - // Properties are set with key as property name and - // value as it's type name (e.g 'Expression', 'string'...), - // an Enum for enumerations, an ObjectType for DrawableObjects - // with a specific type, a List instance for lists, a - // Dictionary instance for dictionaries... - // Used for property modifier in the sidebar. + + /** + * List of properties used in the Object Editor. + * + * Properties are set with key as property name and + * value as it's type name (e.g 'Expression', 'string'...), + * an Enum for enumerations, an ObjectType for DrawableObjects + * with a specific type, a List instance for lists, a + * Dictionary instance for dictionaries... + * + * If the property is to be translated, the key should be passed + * through the QT_TRANSLATE_NOOP macro in that form: + * [QT_TRANSLATE_NOOP('prop','key')] + * Enums that are translated should be indexed in parameters.js and + * then be linked directly here. + * + * @return {Dictionary} + */ static properties() {return {}} - // Whether the object can be executed (instance of ExecutableObject) + /** + * True if this object can be executed, so that an y value might be computed + * for an x value. Only ExecutableObjects have that property set to true. + * @return {bool} + */ static executable() {return false} + /** + * Base constructor for the object. + * @param {string} name - Name of the object + * @param {bool} visible - true if the object is visible, false otherwise. + * @param {color} color - Color of the object (can be string or QColor) + * @param {Enum} labelContent - One of 'null', 'name' or 'name + value' describing the content of the label. + * @constructor() + */ constructor(name, visible = true, color = null, labelContent = 'name + value') { if(color == null) color = Utils.getRandomColor() this.type = 'Unknown' @@ -75,19 +118,40 @@ class DrawableObject { this.requiredBy = [] } + /** + * Serilizes the object in an array that can be JSON serialized. + * These parameters will be re-entered in the constructor when restored. + * @return {array} + */ export() { // Should return what will be inputed as arguments when a file is loaded (serializable form) return [this.name, this.visible, this.color.toString(), this.labelContent] } + /** + * String representing the object that will be displayed to the user. + * It allows for 2 lines and translated text, but it shouldn't be too long. + * @return {string} + */ getReadableString() { return `${this.name} = Unknown` } - toLatexString() { + /** + * Latex markuped version of the readable string. + * Every non latin character should be passed as latex symbols and formulas + * should be in latex form. + * See ../latex.js for helper methods. + * @return {string} + */ + getLatexString() { return this.getReadableString() } + /** + * Readable string content of the label depending on the value of the \c latexContent. + * @return {string} + */ getLabel() { switch(this.labelContent) { case 'name': @@ -100,24 +164,37 @@ class DrawableObject { } } + /** + * Latex markup string content of the label depending on the value of the \c latexContent. + * Every non latin character should be passed as latex symbols and formulas + * should be in latex form. + * See ../latex.js for helper methods. + * @return {string} + */ getLatexLabel() { switch(this.labelContent) { case 'name': - return this.name + return Latex.variable(this.name) case 'name + value': - return this.toLatexString() + return this.getLatexString() case 'null': return '' } } + /** + * Callback method when one of the properties of the object is updated. + */ update() { for(var req of this.requiredBy) { req.update() } } + /** + * Callback method when the object is about to get deleted. + */ delete() { for(var toRemove of this.requiredBy) { toRemove.delete() @@ -125,28 +202,164 @@ class DrawableObject { } } + /** + * Abstract method. Draw the object onto the \c canvas with the 2D context \c ctx. + * @param {Canvas} canvas + * @param {Context2D} ctx + */ draw(canvas, ctx) {} + + /** + * Automaticly draw the label of the object on the \c canvas with the 2D context \c ctx. + * This method takes into account both the \c posX and \c posY of where the label + * should be displayed, including the \c labelPosition relative to it. + * @param {Canvas} canvas + * @param {Context2D} ctx + * @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 + */ + drawLabel(canvas, ctx, labelPosition, posX, posY) { + if(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; + } + } + let ltxLabel = this.getLatexLabel(); + if(ltxLabel != "") + canvas.renderLatexImage(ltxLabel, this.color, drawLblCb.bind(this)) + //canvas.drawVisibleImage(ctx, ltxImg.source, posX, posY) + } else { + // 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; + } + } + } + toString() { return this.name; } } +/** + * Class to be extended for every object on which + * an y for a x can be computed with the execute function. + * If a value cannot be found during execute, it will + * return null. However, theses same x values will + * return false when passed to canExecute. + */ class ExecutableObject extends DrawableObject { - // Class to be extended for every class upon which we - // calculate an y for a x with the execute function. - // If a value cannot be found during execute, it should - // return null. However, theses values should - // return false when passed to canExecute. + /** + * Returns the corresponding y value for an x value. + * If the object isn't defined on the given x, then + * this function will return null. + * + * @param {number} x + * @returns {number|null} + */ execute(x = 1) {return 0} + /** + * Returns false if the object isn't defined on the given x, true otherwise. + * + * @param {number} x + * @returns {bool} + */ canExecute(x = 1) {return true} - // Simplify returns the simplified string of the expression. + /** + * Returns the simplified expression string for a given x. + * + * @param {number} x + * @returns {bool} + */ simplify(x = 1) {return '0'} - // Whether the object can be executed (instance of ExecutableObject) + + /** + * True if this object can be executed, so that an y value might be computed + * for an x value. Only ExecutableObjects have that property set to true. + * @return {bool} + */ static executable() {return true} } + +/** + * Registers the object \c obj in the object list. + * @param {DrawableObject} obj - Object to be registered. + */ function registerObject(obj) { // Registers an object to be used in LogarithmPlotter. // This function is called from autoload.js diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js index c640a8d..464ddda 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/function.js @@ -29,18 +29,6 @@ class Function extends Common.ExecutableObject { static type(){return 'Function'} static displayType(){return qsTr('Function')} static displayTypeMultiple(){return qsTr('Functions')} - /*static properties() {return { - 'expression': 'Expression', - 'definitionDomain': 'Domain', - 'destinationDomain': 'Domain', - 'comment1': 'Ex: R+* (ℝ⁺*), N (ℕ), Z-* (ℤ⁻*), ]0;1[, {3;4;5}', - 'labelPosition': P.Enum.Position, - 'displayMode': new P.Enum('application', 'function'), - 'labelX': 'number', - 'comment2': 'The following parameters are used when the definition domain is a non-continuous set. (Ex: ℕ, ℤ, sets like {0;3}...)', - 'drawPoints': 'boolean', - 'drawDashedLines': 'boolean' - }}*/ static properties() {return { [QT_TRANSLATE_NOOP('prop','expression')]: 'Expression', [QT_TRANSLATE_NOOP('prop','definitionDomain')]: 'Domain', @@ -88,11 +76,11 @@ class Function extends Common.ExecutableObject { } } - toLatexString() { + getLatexString() { if(this.displayMode == 'application') { - return `${Latex.variableToLatex(this.name)}:\\begin{array}{llll}${this.definitionDomain.latexMarkup} & \\rightarrow & ${this.destinationDomain.latexMarkup}\\\\x & \\mapsto & ${this.expression.latexMarkup}\\end{array}` + return `${Latex.variable(this.name)}:\\begin{array}{llll}${this.definitionDomain.latexMarkup} & \\rightarrow & ${this.destinationDomain.latexMarkup}\\\\x & \\mapsto & ${this.expression.latexMarkup}\\end{array}` } else { - return `\\begin{array}{l}${Latex.variableToLatex(this.name)}(x) = ${this.expression.latexMarkup}\\\\ D_{${this.name}} = ${this.definitionDomain.latexMarkup}\\end{array}` + return `\\begin{array}{l}${Latex.variable(this.name)}(x) = ${this.expression.latexMarkup}\\\\ D_{${this.name}} = ${this.definitionDomain.latexMarkup}\\end{array}` } } @@ -121,71 +109,7 @@ class Function extends Common.ExecutableObject { draw(canvas, ctx) { Function.drawFunction(canvas, ctx, this.expression, this.definitionDomain, this.destinationDomain, this.drawPoints, this.drawDashedLines) // Label - var text = this.getLabel() - ctx.font = `${canvas.textsize}px sans-serif` - var textSize = canvas.measureText(ctx, text) - var posX = canvas.x2px(this.labelX) - var posY = canvas.y2px(this.execute(this.labelX)) - - let drawLabel = function(canvas, ctx, ltxImg) { - switch(this.labelPosition) { - case 'above': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'below': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY+10, ltxImg.width, ltxImg.height) - break; - case 'left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'above-left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'above-right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'below-left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY+10, ltxImg.width, ltxImg.height) - break; - case 'below-right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY+10, ltxImg.width, ltxImg.height) - break; - } - } - let ltxLabel = this.getLatexLabel(); - if(ltxLabel != "") - canvas.renderLatexImage(ltxLabel, this.color, drawLabel.bind(this)) - //canvas.drawVisibleImage(ctx, ltxImg.source, posX, posY) - - /*switch(this.labelPosition) { - case 'above': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height) - break; - case 'below': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY+textSize.height) - break; - case 'left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height/2) - break; - case 'right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height/2) - break; - case 'above-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height) - break; - case 'above-right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height) - break; - case 'below-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY+textSize.height) - break; - case 'below-right': - canvas.drawVisibleText(ctx, text, posX, posY+textSize.height) - break; - }*/ + this.drawLabel(canvas, ctx, this.labelPosition, canvas.x2px(this.labelX), canvas.y2px(this.execute(this.labelX))) } static drawFunction(canvas, ctx, expr, definitionDomain, destinationDomain, drawPoints = true, drawDash = true) { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/gainbode.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/gainbode.js index 8d0543c..86b6dd3 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/gainbode.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/gainbode.js @@ -25,19 +25,13 @@ .import "../mathlib.js" as MathLib .import "../historylib.js" as HistoryLib .import "../parameters.js" as P +.import "../math/latex.js" as Latex + class GainBode extends Common.ExecutableObject { static type(){return 'Gain Bode'} static displayType(){return qsTr('Bode Magnitude')} static displayTypeMultiple(){return qsTr('Bode Magnitudes')} - /*static properties() {return { - 'om_0': new P.ObjectType('Point'), - 'pass': new P.Enum('high', 'low'), - 'gain': 'Expression', - 'labelPosition': new P.Enum('above', 'below', 'left', 'right', 'above-left', 'above-right', 'below-left', 'below-right'), - 'labelX': 'number', - 'omGraduation': 'boolean' - }}*/ static properties() {return { [QT_TRANSLATE_NOOP('prop','om_0')]: new P.ObjectType('Point'), [QT_TRANSLATE_NOOP('prop','pass')]: P.Enum.BodePass, @@ -81,6 +75,14 @@ class GainBode extends Common.ExecutableObject { return `${this.name}: ${pass}; ${this.om_0.name} = ${this.om_0.x}\n ${' '.repeat(this.name.length)}${this.gain.toString(true)} dB/dec` } + getLatexString() { + let pass = this.pass == "low" ? qsTr("low-pass") : qsTr("high-pass"); + return `\\mathrm{${Latex.variable(this.name)}:}\\begin{array}{l} + \\textrm{${pass}};${Latex.variable(this.om_0.name)} = ${this.om_0.x.latexMarkup} \\\\ + ${this.gain.latexMarkup}\\textrm{ dB/dec} + \\end{array}` + } + export() { return [this.name, this.visible, this.color.toString(), this.labelContent, this.om_0.name, this.pass.toString(), this.gain.toEditableString(), this.labelPosition, this.labelX, this.omGraduation] @@ -131,38 +133,9 @@ class GainBode extends Common.ExecutableObject { var dashPxSize = 10 for(var i = 0; i < canvas.canvasSize.height && this.omGraduation; i += dashPxSize*2) canvas.drawLine(ctx, xpos, i, xpos, i+dashPxSize) + // Label - var text = this.getLabel() - ctx.font = `${canvas.textsize}px sans-serif` - var textSize = canvas.measureText(ctx, text) - var posX = canvas.x2px(this.labelX) - var posY = canvas.y2px(this.execute(this.labelX)) - switch(this.labelPosition) { - case 'above': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height) - break; - case 'below': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY+textSize.height) - break; - case 'left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height/2) - break; - case 'right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height/2) - break; - case 'above-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height) - break; - case 'above-right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height) - break; - case 'below-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY+textSize.height) - break; - case 'below-right': - canvas.drawVisibleText(ctx, text, posX, posY+textSize.height) - break; - } + this.drawLabel(canvas, ctx, this.labelPosition, canvas.x2px(this.labelX), canvas.y2px(this.execute(this.labelX))) } update() { diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/point.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/point.js index dd1fc1e..66ba301 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/point.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/point.js @@ -29,12 +29,6 @@ class Point extends Common.DrawableObject { static displayType(){return qsTr('Point')} static displayTypeMultiple(){return qsTr('Points')} - /*static properties() {return { - 'x': 'Expression', - 'y': 'Expression', - 'labelPosition': new P.Enum('above', 'below', 'left', 'right', 'above-left', 'above-right', 'below-left', 'below-right'), - 'pointStyle': new P.Enum('●', '✕', '+'), - }}*/ static properties() {return { [QT_TRANSLATE_NOOP('prop','x')]: 'Expression', [QT_TRANSLATE_NOOP('prop','y')]: 'Expression', @@ -59,8 +53,8 @@ class Point extends Common.DrawableObject { return `${this.name} = (${this.x}, ${this.y})` } - toLatexString() { - return `${Latex.variableToLatex(this.name)} = \\left(${this.x.latexMarkup}, ${this.y.latexMarkup}\\right)` + getLatexString() { + return `${Latex.variable(this.name)} = \\left(${this.x.latexMarkup}, ${this.y.latexMarkup}\\right)` } export() { @@ -85,44 +79,6 @@ class Point extends Common.DrawableObject { ctx.fillRect(canvasX-1, canvasY-pointSize/2, 2, pointSize) break; } - - let drawLabel = function(canvas, ctx, ltxImg) { - switch(this.labelPosition) { - case 'top': - case 'above': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX-ltxImg.width/2, canvasY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'bottom': - case 'below': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX-ltxImg.width/2, canvasY+10, ltxImg.width, ltxImg.height) - break; - case 'left': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX-(ltxImg.width+10), canvasY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'right': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX+10, canvasY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'top-left': - case 'above-left': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX-(ltxImg.width+10), canvasY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'top-right': - case 'above-right': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX+10, canvasY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'bottom-left': - case 'below-left': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX-(ltxImg.width+10), canvasY+10, ltxImg.width, ltxImg.height) - break; - case 'bottom-right': - case 'below-right': - canvas.drawVisibleImage(ctx, ltxImg.source, canvasX+10, canvasY+10, ltxImg.width, ltxImg.height) - break; - } - } - let ltxLabel = this.getLatexLabel(); - if(ltxLabel != "") - canvas.renderLatexImage(ltxLabel, this.color, drawLabel.bind(this)) - //canvas.drawVisibleImage(ctx, ltxImg.source, canvasX, canvasY) + this.drawLabel(canvas, ctx, this.labelPosition, canvasX, canvasY) } } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js index ff6b12a..da8c4e1 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/objs/repartition.js @@ -68,9 +68,9 @@ class RepartitionFunction extends Common.ExecutableObject { return `F_${this.name}(x) = P(${this.name} ≤ x)\n` + keys.map(idx => `P(${this.name}=${idx})=${this.probabilities[idx]}`).join("; ") } - toLatexString() { + getLatexString() { let keys = Object.keys(this.probabilities).sort((a,b) => a-b); - let varName = Latex.variableToLatex(this.name) + let varName = Latex.variable(this.name) return `\\begin{array}{l}F_{${varName}}(x) = P(${varName} \\le x)\\\\` + keys.map(idx => `P(${varName}=${idx})=${this.probabilities[idx]}`).join("; ") + '\\end{array}' } @@ -153,71 +153,7 @@ class RepartitionFunction extends Common.ExecutableObject { } // Label - var text = this.getLabel() - ctx.font = `${canvas.textsize}px sans-serif` - var textSize = canvas.measureText(ctx, text) - var posX = canvas.x2px(this.labelX) - var posY = canvas.y2px(this.execute(this.labelX)) - - let drawLabel = function(canvas, ctx, ltxImg) { - switch(this.labelPosition) { - case 'above': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'below': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-ltxImg.width/2, posY+10, ltxImg.width, ltxImg.height) - break; - case 'left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY-ltxImg.height/2, ltxImg.width, ltxImg.height) - break; - case 'above-left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'above-right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY-(ltxImg.height+10), ltxImg.width, ltxImg.height) - break; - case 'below-left': - canvas.drawVisibleImage(ctx, ltxImg.source, posX-(ltxImg.width+10), posY+10, ltxImg.width, ltxImg.height) - break; - case 'below-right': - canvas.drawVisibleImage(ctx, ltxImg.source, posX+10, posY+10, ltxImg.width, ltxImg.height) - break; - } - } - let ltxLabel = this.getLatexLabel(); - console.log(ltxLabel) - if(ltxLabel != "") - canvas.renderLatexImage(ltxLabel, this.color, drawLabel.bind(this)) - /* - switch(this.labelPosition) { - case 'above': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY-textSize.height) - break; - case 'below': - canvas.drawVisibleText(ctx, text, posX-textSize.width/2, posY+textSize.height) - break; - case 'left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height/2) - break; - case 'right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height/2) - break; - case 'above-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY-textSize.height) - break; - case 'above-right': - canvas.drawVisibleText(ctx, text, posX, posY-textSize.height) - break; - case 'below-left': - canvas.drawVisibleText(ctx, text, posX-textSize.width, posY+textSize.height) - break; - case 'below-right': - canvas.drawVisibleText(ctx, text, posX, posY+textSize.height) - break; - }*/ + this.drawLabel(canvas, ctx, this.labelPosition, canvas.x2px(this.labelX), canvas.y2px(this.execute(this.labelX))) } }