From c828b4fba8a40b87cb89e608edbdfe27e1926fab Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Sun, 11 Jul 2021 16:18:01 +0200 Subject: [PATCH] Updating build, providing CI, fixing a few bugs --- .drone/.drone.yml | 44 +++++++++++++++++++ LogarithmPlotter/__init__.py | 4 +- .../{LogGraph.qml => LogarithmPlotter.qml} | 18 +++++++- LogarithmPlotter/qml/js/objects.js | 2 +- LogarithmPlotter/qml/js/utils.js | 2 +- README.md | 7 +-- linux/debian/depends | 2 +- 7 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 .drone/.drone.yml rename LogarithmPlotter/qml/{LogGraph.qml => LogarithmPlotter.qml} (93%) diff --git a/.drone/.drone.yml b/.drone/.drone.yml new file mode 100644 index 0000000..199952c --- /dev/null +++ b/.drone/.drone.yml @@ -0,0 +1,44 @@ +kind: pipeline +name: build-test + +platform: + os: linux + arch: amd64 + +steps: +- name: Linux test + image: ad5001/ubuntu-pyside2-xvfb:hirsute-5.15.2 + commands: + - xvfb-run python3 run.py --test-build + - xvfb-run python3 run.py --test-build ./.drone/test1.lpf + - xvfb-run python3 run.py --test-build ./.drone/test2.lpf + when: + event: [ push, tag ] + +- name: Windows test + image: ad5001/ubuntu-pyside2-xvfb-wine:win7-5.15.2 + commands: + - # For some reason, launching GUI apps with wine, even with xvfb-run, fails. + - #xvfb-run python run.py --test-build + - #xvfb-run python run.py --test-build ./.drone/test1.lpf + - #xvfb-run python run.py --test-build ./.drone/test2.lpf + when: + event: [ push, tag ] + + +- name: Linux packaging + image: ad5001/accountfree-build-img:hirsute-5.15.2 + commands: + - bash package-linux.sh + when: + event: [ push, tag ] + + +- name: Windows building + image: ad5001/accountfree-build-img-wine:win7-5.15.2 + commands: + - bash build-wine.sh + - bash package-wine.sh + when: + event: [ push, tag ] + diff --git a/LogarithmPlotter/__init__.py b/LogarithmPlotter/__init__.py index 76fa225..76e418d 100644 --- a/LogarithmPlotter/__init__.py +++ b/LogarithmPlotter/__init__.py @@ -109,13 +109,13 @@ def run(): engine = QQmlApplicationEngine() helper = Helper() engine.rootContext().setContextProperty("Helper", helper) + engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv) engine.addImportPath(os.path.realpath(os.path.join(os.getcwd(), "qml"))) - engine.load(os.path.realpath(os.path.join(os.getcwd(), "qml", "LogGraph.qml"))) + engine.load(os.path.realpath(os.path.join(os.getcwd(), "qml", "LogarithmPlotter.qml"))) os.chdir(pwd) if len(argv) > 0 and os.path.exists(argv[-1]) and argv[-1].split('.')[-1] in ['json', 'lgg', 'lpf']: - print(argv[-1]) engine.rootObjects()[0].loadDiagram(argv[-1]) os.chdir(os.path.dirname(os.path.realpath(__file__))) diff --git a/LogarithmPlotter/qml/LogGraph.qml b/LogarithmPlotter/qml/LogarithmPlotter.qml similarity index 93% rename from LogarithmPlotter/qml/LogGraph.qml rename to LogarithmPlotter/qml/LogarithmPlotter.qml index 3e9dada..5d1bd96 100644 --- a/LogarithmPlotter/qml/LogGraph.qml +++ b/LogarithmPlotter/qml/LogarithmPlotter.qml @@ -125,6 +125,11 @@ ApplicationWindow { textsize: settings.textsize showxgrad: settings.showxgrad showygrad: settings.showygrad + + onPainted: if(TestBuild == true) { + console.log("Plot drawn in canvas, terminating test of build in 100ms.") + testBuildTimer.start() + } } function saveDiagram(filename) { @@ -161,6 +166,7 @@ ApplicationWindow { } function loadDiagram(filename) { + console.log("Loading file '" + filename + "'.") var data = JSON.parse(Helper.load(filename)) var error = ""; if(Object.keys(data).includes("type") && data["type"] == "logplotv1") { @@ -216,8 +222,11 @@ ApplicationWindow { error = "Invalid file provided." } if(error != "") { - + console.log(error) + // TODO: Error handling } + drawCanvas.requestPaint() + console.log("Loaded file '" + filename + "'.") } Timer { @@ -227,6 +236,13 @@ ApplicationWindow { onTriggered: sidebarSelector.currentIndex = 0 } + Timer { + id: testBuildTimer + repeat: false + interval: 100 + onTriggered: Qt.quit() // Quit after paint on test build + } + function copyDiagramToClipboard() { var file = Helper.gettmpfile() drawCanvas.save(file) diff --git a/LogarithmPlotter/qml/js/objects.js b/LogarithmPlotter/qml/js/objects.js index dd069ca..478ff89 100644 --- a/LogarithmPlotter/qml/js/objects.js +++ b/LogarithmPlotter/qml/js/objects.js @@ -1300,7 +1300,7 @@ class Text extends DrawableObject { constructor(name = null, visible = true, color = null, labelContent = 'null', x = 1, y = 0, labelPosition = 'center', text = 'New text') { - if(name == null) name = "tex" + getNewName('t') + if(name == null) name = getNewName('t') super(name, visible, color, labelContent) this.type = 'Point' if(typeof x == 'number' || typeof x == 'string') x = new MathLib.Expression(x.toString()) diff --git a/LogarithmPlotter/qml/js/utils.js b/LogarithmPlotter/qml/js/utils.js index 650b944..ecd38fb 100644 --- a/LogarithmPlotter/qml/js/utils.js +++ b/LogarithmPlotter/qml/js/utils.js @@ -259,7 +259,7 @@ function makeExpressionReadable(str) { [/(\d|\))×/g, '$1'], //[/×(\d|\()/g, '$1'], [/\(([^)(+.\/-]+)\)/g, "$1"], - [/integral\((.+), ?(.+), ?("|')(.+)("|'), ?("|')(.+)("|')\)/g, function(match, a, b, p1, body, p2, p3, by, p4) { + [/integral\((.+),\s?(.+),\s?("|')(.+)("|'),\s?("|')(.+)("|')\)/g, function(match, a, b, p1, body, p2, p3, by, p4) { if(a.length < b.length) { return `∫${textsub(a)}${textsup(b)} ${body} d${by}` } else { diff --git a/README.md b/README.md index 46259d5..f2355b9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# LogarithmPlotter +# ![icon](https://git.ad5001.eu/Ad5001/LogarithmicPlotter/raw/branch/master/logplotter.svg) LogarithmPlotter Create graphs with logarithm scales, namely BODE diagrams. @@ -9,11 +9,12 @@ You can simply run LogarithmPlotter using `python3 run.py`. ## Install ### Generate installers: -You can generate installers from AccountFree after installing all the dependencies: +You can generate installers from AccountFree after installing all the dependencies: +For all builds, you need [Python 3](https://python.org) with [PySide2](https://pypi.org/project/PySide2/) installable with `pip install PySide2`. - Windows installer: - You need `pyinstaller`. You can install it using `pip install pyinstaller`. - Run the `build-windows.bat` script (or `build-wine.sh` if you're cross-compiling with wine on Linux) to build an exe for LogarithmPlotter. - - You also [NSIS](https://nsis.sourceforge.io/Main_Page) (Linux users can install the `nsis` package). + - You also need [NSIS](https://nsis.sourceforge.io/Main_Page) (Linux users can install the [nsis](https://pkgs.org/download/nsis) package). - Run the `package-windows.bat` script (or `package.wine.sh`if you're cross-compiling on Linux). You will find a logarithmplotter-setup.exe installer in the dist/accountfree/ folder. - MacOS Archive creator installer: - You need `pyinstaller`. You can install it using `pip install pyinstaller`. diff --git a/linux/debian/depends b/linux/debian/depends index 1494f2e..717d393 100644 --- a/linux/debian/depends +++ b/linux/debian/depends @@ -1 +1 @@ -python3-pip, qt5-default (>= 5.12.0), qml-module-qtquick-controls2 (>= 5.12.0), qml-module-qtmultimedia (>= 5.12.0), qml-module-qtgraphicaleffects (>= 5.12.0), qml-module-qtquick2 (>= 5.12.0), qml-module-qtqml-models2 (>= 5.12.0), qml-module-qtquick-controls (>= 5.12.0), python3-pyside2.qtcore (>= 5.12.0), python3-pyside2.qtqml (>= 5.12.0), python3-pyside2.qtgui (>= 5.12.0), python3-pyside2.qtquick (>= 5.12.0), python3-pyside2.qtwidgets (>= 5.12.0), python3-pyside2.qtmultimedia (>= 5.12.0), python3-pyside2.qtnetwork (>= 5.12.0) +python3-pip, qt5-default (>= 5.15.0), qml-module-qtquick-controls2 (>= 5.15.0), qml-module-qtmultimedia (>= 5.15.0), qml-module-qtgraphicaleffects (>= 5.15.0), qml-module-qtquick2 (>= 5.15.0), qml-module-qtqml-models2 (>= 5.15.0), qml-module-qtquick-controls (>= 5.15.0), python3-pyside2.qtcore (>= 5.15.0), python3-pyside2.qtqml (>= 5.15.0), python3-pyside2.qtgui (>= 5.15.0), python3-pyside2.qtquick (>= 5.15.0), python3-pyside2.qtwidgets (>= 5.15.0), python3-pyside2.qtmultimedia (>= 5.15.0), python3-pyside2.qtnetwork (>= 5.15.0)