mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Compare commits
	
		
			76 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 18cdf56cc0 | ||
|  | 880673e140 | ||
|  | 709d5bc643 | ||
|  | a88f783f06 | ||
|  | 808fe6da6f | ||
|  | 25eb491ecb | ||
|  | 574aefbd8b | ||
|  | 3e808c6d85 | ||
|  | 9177ac4304 | ||
|  | d245c96421 | ||
|  | 204220c02d | ||
|  | bd589ecb13 | ||
|  | 5d9001e64c | ||
|  | f9867c61da | ||
|  | f74b8d6eb2 | ||
|  | ff493ac526 | ||
|  | 387dbcf7a4 | ||
|  | f94f3fa625 | ||
|  | 518b9e1f88 | ||
|  | 299c27aaa2 | ||
|  | cfae2a6bd3 | ||
|  | 1a947ff9bf | ||
|  | 9a9a9e426a | ||
|  | f57a37a355 | ||
|  | 9a0591d112 | ||
|  | cd273443db | ||
|  | 8bbce6dd71 | ||
|  | d3e2f1315a | ||
|  | 7eaf863106 | ||
|  | f3241dfa8d | ||
|  | 606224e7ab | ||
|  | 4ea818969f | ||
|  | f595efb1f5 | ||
|  | 6a48592ca6 | ||
|  | 0beac3c48f | ||
|  | f187846bf3 | ||
|  | d1aa84b543 | ||
|  | ed8b036536 | ||
|  | 61e83d5eba | ||
|  | 7f2913e8da | ||
|  | 66e788b195 | ||
|  | 743e449020 | ||
|  | c09de9cf82 | ||
|  | 441f24a3ae | ||
|  | 4faf936a21 | ||
|  | 9e2d6f890f | ||
|  | 47965fe633 | ||
|  | ce7ddf858b | ||
|  | be33d31c92 | ||
|  | d7fc5d10f9 | ||
|  | 2e7a406f63 | ||
|  | 1689d58010 | ||
|  | f0a8fca5fe | ||
|  | 4ea7217758 | ||
|  | 550051a688 | ||
|  | 4ea12d2e1d | ||
|  | 7567c8a609 | ||
|  | bc7295f4f1 | ||
|  | 788a431606 | ||
|  | 51bc2628bb | ||
|  | 85a565dc82 | ||
|  | 24df218897 | ||
|  | 4c90e53a98 | ||
|  | da925f5694 | ||
|  | 5cda1901a6 | ||
|  | 35633ae0ee | ||
|  | e40d74c337 | ||
|  | 046a8f7f3e | ||
|  | 713df876b9 | ||
|  | 05608a6dda | ||
|  | 2263b38f1f | ||
|  | c994835895 | ||
|  | f2d68f13d7 | ||
|  | f00bfbe3fc | ||
|  | 1b0f1616c8 | ||
|  | 8abe02a48c | 
							
								
								
									
										2
									
								
								.github/workflows/ccpp.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/ccpp.yml
									
									
									
									
										vendored
									
									
								
							| @@ -86,7 +86,7 @@ jobs: | ||||
|         wsl --import fedora fedora install.tar.gz | ||||
|         wsl --set-default fedora | ||||
|         wsl sh -c 'dnf -y install https://github.com/rpmsphere/noarch/raw/master/r/rpmsphere-release-40-1.noarch.rpm' | ||||
|         wsl sh -c 'dnf -y install --setop=install_weak_deps=False gcc gcc-c++ protobuf-c-compiler protobuf-devel fmt-devel systemd-devel sqlite-devel wxGTK-devel mingw32-gcc mingw32-gcc-c++ mingw32-zlib-static mingw32-protobuf-static mingw32-sqlite-static mingw32-wxWidgets3-static mingw32-libpng-static mingw32-libjpeg-static mingw32-libtiff-static mingw32-nsis png2ico' | ||||
|         wsl sh -c 'dnf -y install --setop=install_weak_deps=False gcc gcc-c++ protobuf-c-compiler protobuf-devel fmt-devel systemd-devel sqlite-devel wxGTK-devel mingw32-gcc mingw32-gcc-c++ mingw32-zlib-static mingw32-protobuf-static mingw32-sqlite-static mingw32-wxWidgets3-static mingw32-libpng-static mingw32-libjpeg-static mingw32-libtiff-static mingw32-nsis qt-devel mingw32-png2ico' | ||||
|  | ||||
|     - name: fix line endings | ||||
|       run: | | ||||
|   | ||||
							
								
								
									
										3
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/release.yml
									
									
									
									
										vendored
									
									
								
							| @@ -59,7 +59,6 @@ jobs: | ||||
|       with: | ||||
|         tag-name: dev | ||||
|         force-branch: false | ||||
|         git-directory: 'fluxengine' | ||||
|       env: | ||||
|         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||
|  | ||||
| @@ -93,7 +92,7 @@ jobs: | ||||
|     - uses: actions/checkout@v4 | ||||
|  | ||||
|     - name: brew | ||||
|       run: brew install sqlite pkg-config libusb protobuf wxwidgets fmt make coreutils dylibbundler libjpeg | ||||
|       run: brew install sqlite pkg-config libusb protobuf wxwidgets fmt make coreutils dylibbundler libjpeg qt@5 | ||||
|  | ||||
|     - name: make | ||||
|       run: | | ||||
|   | ||||
							
								
								
									
										11
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								Makefile
									
									
									
									
									
								
							| @@ -39,9 +39,13 @@ endif | ||||
|  | ||||
| HOSTCC = gcc | ||||
| HOSTCXX = g++ -std=c++17 | ||||
| HOSTCFLAGS = -g -O3 | ||||
| HOSTCFLAGS = -g -Os | ||||
| HOSTLDFLAGS = | ||||
|  | ||||
| QTBINS = $(shell $(PKG_CONFIG) Qt5Core --variable=host_bins) | ||||
| UIC = $(QTBINS)/uic | ||||
| RCC = $(QTBINS)/rcc | ||||
|  | ||||
| REALOBJ = .obj | ||||
| OBJ = $(REALOBJ)/$(BUILDTYPE) | ||||
| DESTDIR ?= | ||||
| @@ -65,6 +69,9 @@ ifeq ($(OS), Windows_NT) | ||||
| 		-Wno-deprecated-enum-float-conversion \ | ||||
| 		-Wno-deprecated-enum-enum-conversion | ||||
|  | ||||
| 	# For static qt5. | ||||
| 	#export PKG_CONFIG_PATH = $(MINGWBIN)/../qt5-static/lib/pkgconfig | ||||
|  | ||||
| 	# Required to get the gcc run - time libraries on the path. | ||||
| 	export PATH := $(PATH):$(MINGWBIN) | ||||
| endif | ||||
| @@ -72,6 +79,8 @@ endif | ||||
| # Special OSX settings. | ||||
|  | ||||
| ifeq ($(shell uname),Darwin) | ||||
| 	export PKG_CONFIG_PATH = /usr/local/opt/qt@5/lib/pkgconfig | ||||
|  | ||||
| 	LDFLAGS += \ | ||||
| 		-framework IOKit \ | ||||
| 		-framework Foundation  | ||||
|   | ||||
| @@ -257,6 +257,10 @@ package, written by Robert Leslie et al, taken from | ||||
| https://www.mars.org/home/rob/proj/hfs. It is GPL 2.0 licensed. Please see the | ||||
| contents of the directory for the full text. | ||||
|  | ||||
| As an exception, `dep/verdigris` contains a partial copy of the verdigris | ||||
| package, taken from https://github.com/woboq/verdigris. It is dual LGPL/GPLv2 | ||||
| licensed. Please see the contents of the directory for the full text. | ||||
|  | ||||
| __Important:__ Because of all these exceptions, if you distribute the | ||||
| FluxEngine package as a whole, you must comply with the terms of _all_ of the | ||||
| licensing terms. This means that __effectively the FluxEngine package is | ||||
|   | ||||
							
								
								
									
										2
									
								
								build.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								build.py
									
									
									
									
									
								
							| @@ -99,6 +99,8 @@ export( | ||||
|     items={ | ||||
|         "fluxengine$(EXT)": "src+fluxengine", | ||||
|         "fluxengine-gui$(EXT)": "src/gui", | ||||
|         "fluxengine-imager$(EXT)": "src/gui2+imager", | ||||
|         "fluxengine-filer$(EXT)": "src/gui2+filer", | ||||
|         "brother120tool$(EXT)": "tools+brother120tool", | ||||
|         "brother240tool$(EXT)": "tools+brother240tool", | ||||
|         "upgrade-flux-file$(EXT)": "tools+upgrade-flux-file", | ||||
|   | ||||
							
								
								
									
										37
									
								
								dep/verdigris/ChangeLog
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								dep/verdigris/ChangeLog
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| Version 1.3 (August 2022) | ||||
|  * Add C++ API to allow meta programming your properties | ||||
|  * Added Option to reduce macro spam a bit (W_NO_PROPERTY_MACRO) | ||||
|  * Build with MSVC 2017, 2019, 2022 | ||||
|  * Support from Qt 5.9 to 5.15 and Qt 6.0.0 to Qt 6.3.0 | ||||
|  | ||||
| Version 1.2 (Juli 2019) | ||||
|  * Added W_OBJECT_IMPL_INLINE / W_GADGET_IMPL_INLINE / W_NAMESPACE_IMPL_INLINE (#51) | ||||
|  * Fix multiple-definition linker errors caused by W_NAMESPACE macro (#54) | ||||
|  * Fix build with MSVC 2019 (#46) | ||||
|  * Massive compile time improvements (#66) | ||||
|  * Qbs project files (#63) | ||||
|  * Tested with to Qt 5.13 | ||||
|  | ||||
| Version 1.1 (September 2018) | ||||
|  * Auto-detect the access specifier. (No need to add W_Access::Private or | ||||
|    W_Access::Protected anymore) | ||||
|  * Optimized compilation time for classes with many properties | ||||
|  * Removed the need to set feature macro on MSVC | ||||
|  * Don't make the staticMetaObject a constexpr as it breaks C++17 Q_GADGET | ||||
|    declared in another translation unit (#38) | ||||
|  * Workaround MSVC 2017 Update 7 compiler crash (#30) | ||||
|  * Automatically mark the properties as FINAL for final classes (#40) | ||||
|  * Added support for enum class in Q_ENUM | ||||
|  * Added support enum alias (Qt 5.12 freature) | ||||
|  | ||||
| Version 1.0 (February 2018) | ||||
|  * Error out early without C++14 (#2) | ||||
|  * Set Designable and Scriptable flags by default so it works with QML (#3) | ||||
|  * Fix usage of Q_PRIVATE_PROPERTY (#5) | ||||
|  * Added MSVC 2017 support (#6) | ||||
|  * Support C++17 noexcept function part of the function signature (#9) | ||||
|  * Added W_NAMESPACE/W_NAMESPACE_IMPL and W_ENUM_NS/W_FLAG_NS/W_CASSINFO_NS | ||||
|  * Support for NOTIFY signal in parent class (Qt 5.10 feature) | ||||
|  * Imported new tests from Qt 5.10 | ||||
|  | ||||
| Initial Release (May 2016) | ||||
							
								
								
									
										165
									
								
								dep/verdigris/LICENSE.LGPLv3
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								dep/verdigris/LICENSE.LGPLv3
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,165 @@ | ||||
|  | ||||
|  | ||||
|             GNU LESSER GENERAL PUBLIC LICENSE | ||||
|                 Version 3, 29 June 2007 | ||||
|  | ||||
|  Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||||
| Everyone is permitted to copy and distribute verbatim copies of this | ||||
| licensedocument, but changing it is not allowed. | ||||
|  | ||||
| This version of the GNU Lesser General Public License incorporates | ||||
| the terms and conditions of version 3 of the GNU General Public | ||||
| License, supplemented by the additional permissions listed below. | ||||
|  | ||||
| 0. Additional Definitions. | ||||
|  | ||||
|  As used herein, “this License” refers to version 3 of the GNU Lesser | ||||
| General Public License, and the “GNU GPL” refers to version 3 of the | ||||
| GNU General Public License. | ||||
|  | ||||
|  “The Library” refers to a covered work governed by this License, | ||||
| other than an Application or a Combined Work as defined below. | ||||
|  | ||||
|  An “Application” is any work that makes use of an interface provided | ||||
| by the Library, but which is not otherwise based on the Library. | ||||
| Defining a subclass of a class defined by the Library is deemed a mode | ||||
| of using an interface provided by the Library. | ||||
|  | ||||
|  A “Combined Work” is a work produced by combining or linking an | ||||
| Application with the Library. The particular version of the Library | ||||
| with which the Combined Work was made is also called the “Linked | ||||
| Version”. | ||||
|  | ||||
|  The “Minimal Corresponding Source” for a Combined Work means the | ||||
| Corresponding Source for the Combined Work, excluding any source code | ||||
| for portions of the Combined Work that, considered in isolation, are | ||||
| based on the Application, and not on the Linked Version. | ||||
|  | ||||
|  The “Corresponding Application Code” for a Combined Work means the | ||||
| object code and/or source code for the Application, including any data | ||||
| and utility programs needed for reproducing the Combined Work from the | ||||
| Application, but excluding the System Libraries of the Combined Work. | ||||
|  | ||||
| 1. Exception to Section 3 of the GNU GPL. | ||||
|  | ||||
|  You may convey a covered work under sections 3 and 4 of this License | ||||
| without being bound by section 3 of the GNU GPL. | ||||
|  | ||||
| 2. Conveying Modified Versions. | ||||
|  | ||||
|  If you modify a copy of the Library, and, in your modifications, a | ||||
| facility refers to a function or data to be supplied by an Application | ||||
| that uses the facility (other than as an argument passed when the | ||||
| facility is invoked), then you may convey a copy of the modified | ||||
| version: | ||||
|  | ||||
|     a) under this License, provided that you make a good faith effort | ||||
|     to ensure that, in the event an Application does not supply the | ||||
|     function or data, the facility still operates, and performs | ||||
|     whatever part of its purpose remains meaningful, or | ||||
|  | ||||
|     b) under the GNU GPL, with none of the additional permissions of | ||||
|     this License applicable to that copy. | ||||
|  | ||||
| 3. Object Code Incorporating Material from Library Header Files. | ||||
|  | ||||
|  The object code form of an Application may incorporate material from | ||||
| a header file that is part of the Library. You may convey such object | ||||
| code under terms of your choice, provided that, if the incorporated | ||||
| material is not limited to numerical parameters, data structure | ||||
| layouts and accessors, or small macros, inline functions and templates | ||||
| (ten or fewer lines in length), you do both of the following: | ||||
|  | ||||
|     a) Give prominent notice with each copy of the object code that | ||||
|     the Library is used in it and that the Library and its use are | ||||
|     covered by this License. | ||||
|  | ||||
|     b) Accompany the object code with a copy of the GNU GPL and this | ||||
|     license document. | ||||
|  | ||||
| 4. Combined Works. | ||||
|  | ||||
|  You may convey a Combined Work under terms of your choice that, taken | ||||
| together, effectively do not restrict modification of the portions of | ||||
| the Library contained in the Combined Work and reverse engineering for | ||||
| debugging such modifications, if you also do each of the following: | ||||
|  | ||||
|     a) Give prominent notice with each copy of the Combined Work that | ||||
|     the Library is used in it and that the Library and its use are | ||||
|     covered by this License. | ||||
|  | ||||
|     b) Accompany the Combined Work with a copy of the GNU GPL and this | ||||
|     license document. | ||||
|  | ||||
|     c) For a Combined Work that displays copyright notices during | ||||
|     execution, include the copyright notice for the Library among | ||||
|     these notices, as well as a reference directing the user to the | ||||
|     copies of the GNU GPL and this license document. | ||||
|  | ||||
|     d) Do one of the following: | ||||
|  | ||||
|         0) Convey the Minimal Corresponding Source under the terms of | ||||
|         this License, and the Corresponding Application Code in a form | ||||
|         suitable for, and under terms that permit, the user to | ||||
|         recombine or relink the Application with a modified version of | ||||
|         the Linked Version to produce a modified Combined Work, in the | ||||
|         manner specified by section 6 of the GNU GPL for conveying | ||||
|         Corresponding Source. | ||||
|  | ||||
|         1) Use a suitable shared library mechanism for linking with | ||||
|         the Library. A suitable mechanism is one that (a) uses at run | ||||
|         time a copy of the Library already present on the user's | ||||
|         computer system, and (b) will operate properly with a modified | ||||
|         version of the Library that is interface-compatible with the | ||||
|         Linked Version. | ||||
|  | ||||
|     e) Provide Installation Information, but only if you would | ||||
|     otherwise be required to provide such information under section 6 | ||||
|     of the GNU GPL, and only to the extent that such information is | ||||
|     necessary to install and execute a modified version of the | ||||
|     Combined Work produced by recombining or relinking the Application | ||||
|     with a modified version of the Linked Version. (If you use option | ||||
|     4d0, the Installation Information must accompany the Minimal | ||||
|     Corresponding Source and Corresponding Application Code. If you | ||||
|     use option 4d1, you must provide the Installation Information in | ||||
|     the manner specified by section 6 of the GNU GPL for conveying | ||||
|     Corresponding Source.) | ||||
|  | ||||
| 5. Combined Libraries. | ||||
|  | ||||
|  You may place library facilities that are a work based on the Library | ||||
| side by side in a single library together with other library | ||||
| facilities that are not Applications and are not covered by this | ||||
| License, and convey such a combined library under terms of your | ||||
| choice, if you do both of the following: | ||||
|  | ||||
|     a) Accompany the combined library with a copy of the same work | ||||
|     based on the Library, uncombined with any other library | ||||
|     facilities, conveyed under the terms of this License. | ||||
|  | ||||
|     b) Give prominent notice with the combined library that part of | ||||
|     it is a work based on the Library, and explaining where to find | ||||
|     the accompanying uncombined form of the same work. | ||||
|  | ||||
| 6. Revised Versions of the GNU Lesser General Public License. | ||||
|  | ||||
|  The Free Software Foundation may publish revised and/or new versions | ||||
| of the GNU Lesser General Public License from time to time. Such new | ||||
| versions will be similar in spirit to the present version, but may | ||||
| differ in detail to address new problems or concerns. | ||||
|  | ||||
| Each version is given a distinguishing version number. If the Library | ||||
| as you received it specifies that a certain numbered version of the | ||||
| GNU Lesser General Public License “or any later version” applies to | ||||
| it, you have the option of following the terms and conditions either | ||||
| of that published version or of any later version published by the | ||||
| Free Software Foundation. If the Library as you received it does not | ||||
| specify a version number of the GNU Lesser General Public License, | ||||
| you may choose any version of the GNU Lesser General Public License | ||||
| ever published by the Free Software Foundation. | ||||
|  | ||||
| If the Library as you received it specifies that a proxy can decide | ||||
| whether future versions of the GNU Lesser General Public License shall | ||||
| apply, that proxy's public statement of acceptance of any version is | ||||
| permanent authorization for you to choose that version for the Library. | ||||
|  | ||||
							
								
								
									
										112
									
								
								dep/verdigris/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								dep/verdigris/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,112 @@ | ||||
| ## About | ||||
|  | ||||
| This (header-only) library can be used to create an application using Qt, without the need of the | ||||
| moc (MetaObject Compiler). It uses a different set of macro than Qt and templated constexpr code to | ||||
| generate the QMetaObject at compile-time. It is entirely binary compatible with Qt. | ||||
|  | ||||
| Blog post presenting the project: https://woboq.com/blog/verdigris-qt-without-moc.html (2016) | ||||
|  | ||||
| Blog post with some implementation details: https://woboq.com/blog/verdigris-implementation-tricks.html (2018) | ||||
|  | ||||
| Browse code online: https://code.woboq.org/woboq/verdigris | ||||
|  | ||||
| Github Actions: [](https://github.com/woboq/verdigris/actions/workflows/clang.yml) [](https://github.com/woboq/verdigris/actions/workflows/gcc.yml) [](https://github.com/woboq/verdigris/actions/workflows/windows.yml) | ||||
| Appveyor: | ||||
| [](https://ci.appveyor.com/project/ogoffart/verdigris) | ||||
|  | ||||
| ## Documentation | ||||
|  | ||||
| For an introduction, see the [tutorial.cpp](https://code.woboq.org/woboq/verdigris/tutorial/tutorial.cpp.html). | ||||
| See also a more detailed documetation of the macros in the source code. | ||||
|  | ||||
| ## Status | ||||
|  | ||||
| Almost all features of Qt are working. The Qt test have been ported. | ||||
|  | ||||
| Features that are not yet working: | ||||
|  - Q_PLUGIN_METADATA: This would require compiling to the Qt's binary json. Out of scope for now. | ||||
|  - QML_ELEMENT: This is a Qt6 feature that automatically registers the QObjects for QML. Out of scope for now. | ||||
|  - BINDABLE: Needs to be backported to the current C++ and Qt requirements. | ||||
|  - QMetaMethod::tag(): Not yet implemented, could be supported if needed, but is not really needed | ||||
|                        for anything. (not even tested by Qt's auto test) | ||||
|  - Q_ENUM: Working, but requires to repeat the name of every enum value. Could be improved. | ||||
|  | ||||
| **New features compared to Qt with moc:** | ||||
|  - Support for templated QObject. | ||||
|  - Support for QObject nested in another class. | ||||
|  | ||||
| ## How to Use | ||||
|  | ||||
| The library consist of only two headers files. You can either copy these header files in your | ||||
| project, or adjust the include paths so that the compiler finds them. | ||||
| You will find the headers in the 'src/' sub-directory. | ||||
| Also make sure to set your compiler in, at least, C++14 mode. With qmake, you can do that with | ||||
| `CONFIG += c++14`. | ||||
|  | ||||
| Tested with Qt >= 5.9. | ||||
| Need a compiler that can do C++14 relaxed constexpr such as GCC 5.1 or Clang 3.5, or MSVC 2017 | ||||
|  | ||||
| ### Translations | ||||
|  | ||||
| When running `lupdate`, add the argument `-tr-function-alias Q_DECLARE_TR_FUNCTIONS+=W_OBJECT` to | ||||
| avoid the warning that your class are not using the Q_OBJECT macro. | ||||
|  | ||||
| ### Correspondance Table | ||||
|  | ||||
| This table show the correspondence between Qt macro and Verdigris macro: | ||||
|  | ||||
| | Qt macro                                     | Use the Verdigris macro instead                   | | ||||
| |----------------------------------------------|---------------------------------------------------| | ||||
| | `Q_OBJECT`                                   | `W_OBJECT(MyClass)` ...  `W_OBJECT_IMPL(MyClass)` | | ||||
| | `public slots: void mySlot(int x);`          |  `void mySlot(int x); W_SLOT(mySlot)`             | | ||||
| | `signals: void mySignal(int x);`             |  `void mySignal(int x) W_SIGNAL(mySignal,x)`	     | | ||||
| | `Q_PROPERTY(int myProperty WRITE setProp READ getProp NOTIFY propChanged)` | `W_PROPERTY(int, myProperty WRITE setProp READ getProp NOTIFY propChanged)` | | ||||
| | `Q_GADGET`                                   | `W_GADGET(MyClass)` ...  `W_GADGET_IMPL(MyClass)` | | ||||
| | `Q_INVOKABLE void myFunction(int foo);`      |  `void myFunction(int foo); W_INVOKABLE(myFunction)` | ||||
| | `Q_INVOKABLE MyClass(int foo);`              |  `MyClass(int foo); W_CONSTRUCTOR(int)`           | | ||||
| | `Q_CLASSINFO("foo", "bar")`                  | `W_CLASSINFO("foo", "bar")`                       | | ||||
| | `Q_DECLARE_INTERFACE(MyInterface, "my.interface")` ... `Q_INTERFACE(MyInterface)`     | `Q_DECLARE_INTERFACE(MyInterface, "my.interface")` ... `W_INTERFACE(MyInterface)` | | ||||
| | `Q_NAMESPACE`                                | `W_NAMESPACE(MyNs)` ...  `W_NAMESPACE_IMPL(MyNs)` | | ||||
| | Q_ENUM/Q_FLAG/Q_ENUM_NS/Q_FLAG_NS            | W_ENUM/W_FLAG/W_ENUM_NS/W_FLAG_NS                 | | ||||
|  | ||||
| ## Who uses Verdigris ? | ||||
|  | ||||
| * [Ossia Score](https://ossia.io/), an interactive intermedia sequencer. ([github](https://github.com/OSSIA/score)) | ||||
|   It uses Verdigris in productions. Verdigris allowed ossia score to use template with their QObject's, and solve some trouble with the build system. | ||||
|  | ||||
|  | ||||
| <img align="right" src="https://woboq.com/logos/isotronic.png"> | ||||
|  | ||||
| * [ISOTRONIC GmbH](https://isotronic.de/), a provider for visual inspection QA systems for automatic glass vial manufacturing, uses Verdigris in production: | ||||
| > The transition from standard Qt affected more than 100 source code files and was done in not much more than a day. The reason for the switch was to be able to use a build system that has no interface for Qt's MOC process. In the rare cases of questions or problems the Verdigris team was quick and competent in resolving the issues. After more than 6 months of real-world experience we are still very happy with that decision. | ||||
|  | ||||
| * If you are using Verdigris and want to appear here, please open an issue, or a pull request | ||||
|  | ||||
| ## Context | ||||
|  | ||||
| The macros were inspired by [CopperSpice](http://www.copperspice.com/). | ||||
| The template code was based on previous work: | ||||
| https://woboq.com/blog/reflection-in-cpp-and-qt-moc.html | ||||
|  | ||||
| Differences with CopperSpice: | ||||
|  | ||||
| 1. Contrary to CopperSpice, this is not a fork of Qt, but just an alternative set of macro to define | ||||
|    Qt objects and signals and slot in a way that is binary compatible with Qt, but does not require | ||||
|    moc. This is to be used with the normal Qt. CopperSpice being an entire fork of Qt, it has more | ||||
|    differences with Qt and is not kept up to date with all the new features coming in Qt. | ||||
| 2. The QMetaObject is built at compile time in the read only section (like what moc does). | ||||
|    CopperSpice builds it at run-time when the library is loaded. So CopperSpice takes more memory | ||||
|    and load slower. | ||||
| 3. With CopperSpice, you cannot declare your slot within the class definition. | ||||
| 4. CopperSpice uses `__LINE__` in its macro making it impossible to declare several things in one line | ||||
|    or to declare objects or properties from macros. | ||||
| 5. The usability of some macro was (in our opinion) improved. | ||||
| 6. The additional Q_OBJECT_IMPL | ||||
|  | ||||
|  | ||||
| ## Licence | ||||
|  | ||||
| Like Qt, this library is under the dual licence LGPLv3 and GPLv2. | ||||
| Being header-only, this removes many of the obligations of the LGPLv3. | ||||
|  | ||||
| If you have any questions or remark please email  info@woboq.com | ||||
							
								
								
									
										2
									
								
								dep/verdigris/README.upstream
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								dep/verdigris/README.upstream
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| This is a trimmed version 1.3 of Verdigris, obtained from here: | ||||
| https://github.com/woboq/verdigris/releases/tag/v1.3 | ||||
							
								
								
									
										10
									
								
								dep/verdigris/build.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								dep/verdigris/build.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| from build.c import clibrary | ||||
|  | ||||
| clibrary( | ||||
|     name="verdigris", | ||||
|     hdrs={ | ||||
|         "wobjectcpp.h": "./src/wobjectcpp.h", | ||||
|         "wobjectdefs.h": "./src/wobjectdefs.h", | ||||
|         "wobjectimpl.h": "./src/wobjectimpl.h", | ||||
|     }, | ||||
| ) | ||||
							
								
								
									
										270
									
								
								dep/verdigris/src/wobjectcpp.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										270
									
								
								dep/verdigris/src/wobjectcpp.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,270 @@ | ||||
| #pragma once | ||||
| #include "wobjectdefs.h" | ||||
|  | ||||
| namespace w_internal { | ||||
| #if __cplusplus <= 201700L | ||||
| template<bool... Bs> | ||||
| constexpr bool all() { | ||||
|     bool b = true; | ||||
|     ordered2<bool>({(b = b && Bs)...}); | ||||
|     return b; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| template<class F, int Flags, class IC = int, class ParamTypes = w_internal::StringViewArray<>, class ParamNames = w_internal::StringViewArray<>> | ||||
| struct MetaMethodInfoBuilder { | ||||
|     StringView name; | ||||
|     F func; | ||||
|     ParamTypes paramTypes{}; | ||||
|     ParamNames paramNames{}; | ||||
|     static constexpr int flags = Flags; | ||||
|     using IntegralConstant = IC; | ||||
|  | ||||
| #if __cplusplus > 201700L | ||||
|     template<class... Args, class = std::enable_if_t<(std::is_same_v<std::decay_t<Args>, StringView> && ...)>> | ||||
| #else | ||||
|     template<class... Args, class = std::enable_if_t<w_internal::all<std::is_same<std::decay_t<Args>, StringView>::value...>()>> | ||||
| #endif | ||||
|     constexpr auto setParamTypes(Args... paramTypes) const | ||||
|         -> MetaMethodInfoBuilder<F, Flags, IC, w_internal::StringViewArray<sizeof... (Args)>, ParamNames> { | ||||
|         return {name, func, {paramTypes...}, paramNames}; | ||||
|     } | ||||
| #if __cplusplus > 201700L | ||||
|     template<class... Args, class = std::enable_if_t<(std::is_same_v<std::decay_t<Args>, StringView> && ...)>> | ||||
| #else | ||||
|     template<class... Args, class = std::enable_if_t<w_internal::all<std::is_same<std::decay_t<Args>, StringView>::value...>()>> | ||||
| #endif | ||||
|     constexpr auto setParamNames(Args... paramNames) const | ||||
|         -> MetaMethodInfoBuilder<F, Flags, IC, ParamTypes, w_internal::StringViewArray<sizeof... (Args)>> { | ||||
|         return {name, func, paramTypes, {paramNames...}}; | ||||
|     } | ||||
|     template<int... fs> | ||||
|     constexpr auto addFlags(w_internal::W_MethodFlags<fs>...) const | ||||
| #if __cplusplus > 201700L | ||||
|         -> MetaMethodInfoBuilder<F, (fs | ... | Flags), IC, ParamTypes, ParamNames> { | ||||
| #else | ||||
|         -> MetaMethodInfoBuilder<F, w_internal::summed<fs ..., Flags>, IC, ParamTypes, ParamNames> { | ||||
| #endif | ||||
|             return {name, func, paramTypes, paramNames}; | ||||
|     } | ||||
|     template<class IC2> | ||||
|     constexpr auto setIntegralConstant() const -> MetaMethodInfoBuilder<F, Flags, IC2, ParamTypes, ParamNames> { | ||||
|         return {name, func, paramTypes, paramNames}; | ||||
|     } | ||||
|  | ||||
|     constexpr auto build() const -> w_internal::MetaMethodInfo<F, Flags, IC, ParamTypes, ParamNames> { | ||||
|         return {func, name, paramTypes, paramNames}; | ||||
|     } | ||||
| }; | ||||
|  | ||||
| } // namespace w_internal | ||||
|  | ||||
| namespace w_cpp { | ||||
|  | ||||
| /// Very simple constexpr version of std::string_view | ||||
| /// | ||||
| /// example usage: | ||||
| ///     constexpr char text[6] = "Hello"; // if you have a string literal use `viewLiteral` below. | ||||
| ///     constexpr auto view = w_cpp::StringView{&text[0], &text[5]}; | ||||
| /// | ||||
| /// \note the end pointer has to point behind the last character | ||||
| using w_internal::StringView; | ||||
|  | ||||
| /// Array of StringView | ||||
| /// | ||||
| /// example usage: | ||||
| ///     auto array = w_cpp::StringViewArray<2>{{w_cpp::viewLiteral("Hello"), w_cpp::viewLiteral("World")}}; | ||||
| ///     array.data[1] = w_cpp::viewLiteral("World !!!"); | ||||
| using w_internal::StringViewArray; | ||||
|  | ||||
| /// Generate a constexpr StringView from a C++ string literal. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     constexpr auto view = w_cpp::viewLiteral{"Hello"}; | ||||
| using w_internal::viewLiteral; | ||||
|  | ||||
| /// Store a compile time sequence of enum values | ||||
| /// | ||||
| /// example usage: | ||||
| ///     enum class Level { Easy, Normal, Hard }; | ||||
| ///     constexpr auto sequence = w_cpp::enum_sequence<Level, Level::Easy, Level::Normal, Level::Hard>{}; | ||||
| using w_internal::enum_sequence; | ||||
|  | ||||
| /// create a compile time property description for registraton usage | ||||
| /// | ||||
| /// \arg T the type of the property | ||||
| /// \arg name the compile time StringView for the property name | ||||
| /// \arg type the compile time StringView for the type of the property | ||||
| /// | ||||
| /// Following methods may be called in chain: | ||||
| /// * .setGetter(F) - set the member function that returns the value of the property `() -> T` | ||||
| /// * .setSetter(F) - set the member function that changes the value of the property `(T) -> void` | ||||
| /// * .setMember(M) - set the class attribute to read and write the value of the property | ||||
| /// * .setNotify(F) - set the member function that represents the changed signal for the property | ||||
| /// * .setReset(F) - set the member function that resets the property value to it's default | ||||
| /// * .addFlag<F>() - add one or multiple flags for the property | ||||
| template<typename T> | ||||
| constexpr auto makeProperty(StringView name, StringView type) { | ||||
|     return w_internal::MetaPropertyInfo<T>{ name, type, {}, {}, {}, {}, {} }; | ||||
| } | ||||
|  | ||||
| /// create a builder for a signal description | ||||
| /// | ||||
| /// \arg name the compile time StringView for the function name | ||||
| /// \arg func the member function that implements the signal | ||||
| /// | ||||
| /// Following methods may be call in chain: | ||||
| /// * .setParamNames(StringView...) - set the names for all the function parameters (optional) | ||||
| /// * .setParamTypes(StringView...) - set the names of for all parameter types | ||||
| /// * .addFlag(Flags...) - add some methods flags | ||||
| /// * .setIntegralConstant<T>() - set a compile time integral value type as a unique identifier | ||||
| /// * .build() - build the final MethodInfo for this signal | ||||
| template<typename F> | ||||
| constexpr auto makeSignalBuilder(StringView name, F func) -> w_internal::MetaMethodInfoBuilder<F, W_MethodType::Signal.value> { | ||||
|     return {name, func}; | ||||
| } | ||||
|  | ||||
| /// create a compile time enum description for registraton usage | ||||
| /// | ||||
| /// \arg Enum type | ||||
| /// \arg name the compile time StringView for the enum name | ||||
| /// \arg memberValueSequence the compile time enum_sequence of all enum member values | ||||
| /// \arg memberNames the compile time StringViewArray of all enum member names | ||||
| /// | ||||
| /// \note to correct map between values and names, member values in memberValueSequence must be in the same order as member names in memberNames | ||||
| template<typename Enum, Enum... Values> | ||||
| constexpr auto makeEnumInfo(StringView name, w_internal::enum_sequence<Enum, Values...> memberValueSequence, w_internal::StringViewArray<sizeof...(Values)> memberNames) { | ||||
|     return w_internal::makeMetaEnumInfo<Enum, false>(name, 0, memberValueSequence, memberNames); | ||||
| } | ||||
|  | ||||
| /// create a compile time flags description for registraton usage | ||||
| /// | ||||
| /// \arg Enum type | ||||
| /// \arg name the compile time StringView for the flag name | ||||
| /// \arg enumAliasName the compile time StringView for the enum name that is used as alias by flags | ||||
| /// \arg memberValueSequence the compile time enum_sequence of all enum member values | ||||
| /// \arg memberNames the compile time StringViewArray of all enum member names | ||||
| /// | ||||
| /// \note to correct map between values and names, member values in memberValueSequence must be in the same order as member names in memberNames | ||||
| template<typename Enum, Enum... Values> | ||||
| constexpr auto makeFlagInfo(StringView name, StringView enumAliasName, w_internal::enum_sequence<Enum, Values...> memberValueSequence, w_internal::StringViewArray<sizeof...(Values)> memberNames) { | ||||
|     return w_internal::makeMetaEnumInfo<Enum, true>(name, enumAliasName, memberValueSequence, memberNames); | ||||
| } | ||||
|  | ||||
| } // namespace w_cpp | ||||
|  | ||||
| /// \macro W_CPP_PROPERTY(callback) | ||||
| /// allows to create multiple properties from a templated structure using regular C++. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     template<size_t I> | ||||
| ///     struct MyProperties; | ||||
| ///     template<> | ||||
| ///     struct MyProperties<0> { | ||||
| ///         constexpr static auto property = w_cpp::makeProperty<QString>(w_cpp::viewLiteral("name"), w_cpp::viewLiteral("QString")) | ||||
| ///             .setGetter(&Example::getName); | ||||
| ///     }; | ||||
| ///     W_CPP_PROPERTY(MyProperties) | ||||
| /// | ||||
| /// \note you have to ensure that the struct is only valid for some `I`s. | ||||
| #define W_CPP_PROPERTY(a) \ | ||||
|     static constexpr size_t W_MACRO_CONCAT(a,_O) = w_internal::stateCount<__COUNTER__, w_internal::PropertyStateTag, W_ThisType**>; \ | ||||
|     template<size_t I> \ | ||||
|     friend constexpr auto w_state(w_internal::Index<I>, w_internal::PropertyStateTag, W_ThisType**) W_RETURN((a<I-W_MACRO_CONCAT(a,_O)>::property)) | ||||
|  | ||||
| /// \macro W_CPP_SIGNAL(callback) | ||||
| /// allows to register multiple signals from a templated structure using regular C++. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     template<size_t I> | ||||
| ///     struct MySignals; | ||||
| ///     template<> | ||||
| ///     struct MySignals<0> { | ||||
| ///         constexpr static auto signal = w_cpp::makeSignalBuilder(w_cpp::viewLiteral("nameChanged"), &Example::nameChanged).build(); | ||||
| ///     }; | ||||
| ///     W_CPP_SIGNAL(MySignals) | ||||
| /// | ||||
| /// \note you have to ensure that the struct is only valid for some `I`s. | ||||
| #define W_CPP_SIGNAL(a) \ | ||||
|     static constexpr size_t W_MACRO_CONCAT(a,_O) = w_internal::stateCount<__COUNTER__, w_internal::SignalStateTag, W_ThisType**>; \ | ||||
|     template<size_t I> \ | ||||
|     friend constexpr auto w_state(w_internal::Index<I>, w_internal::SignalStateTag, W_ThisType**) W_RETURN((a<I-W_MACRO_CONCAT(a,_O)>::signal)) | ||||
|  | ||||
| /// \macro W_CPP_SIGNAL_IMPL(type, callback, index) | ||||
| /// allows to implement a signal | ||||
| /// | ||||
| /// example usage: | ||||
| ///     template<size_t I> | ||||
| ///     void notifyPropertyChanged() W_CPP_SIGNAL_IMPL(decltype (&tst_CppApi::notifyPropertyChanged<I>), MySignals, I, 0) | ||||
| /// | ||||
| #define W_CPP_SIGNAL_IMPL(type, a, i, ...) \ | ||||
|     constexpr int index = W_ThisType::W_MACRO_CONCAT(a,_O) + i; \ | ||||
|     return w_internal::SignalImplementation<type, index>{this}(__VA_ARGS__) | ||||
|  | ||||
| /// \macro W_CPP_ENUM(type, callback) | ||||
| /// allows to register a enum type for a QObject type from a templated structure using regular C++. | ||||
| /// additionally enum can be declared outside QObject where it is registered. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     enum class Level { Easy, Normal, Hard }; | ||||
| /// | ||||
| ///     template<class T> | ||||
| ///     struct MyEnums; | ||||
| ///     template<> | ||||
| ///     struct MyEnums<Level> { | ||||
| ///         constexpr static auto enumInfo = w_cpp::makeEnumInfo( | ||||
| ///             w_cpp::viewLiteral("Level"), | ||||
| ///             w_cpp::enum_sequence<Level, Level::Easy, Level::Normal, Level::Hard>{}, | ||||
| ///             w_cpp::StringViewArray<3>{ | ||||
| ///                 {w_cpp::viewLiteral("Easy"), w_cpp::viewLiteral("Normal"), w_cpp::viewLiteral("Hard")}}); | ||||
| ///     }; | ||||
| ///     W_CPP_ENUM(Level, MyEnums) | ||||
| /// | ||||
| #define W_CPP_ENUM(type, a) \ | ||||
|     W_STATE_APPEND(EnumState, a<type>::enumInfo) \ | ||||
|     Q_ENUM(type) | ||||
|  | ||||
| /// \macro W_CPP_ENUM_NS(type, callback) | ||||
| /// allows to register a enum type for a namespace that was declarated with W_NAMESPACE from a templated structure using regular C++. | ||||
| /// additionally enum can be declared outside namespace where it is registered. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     Similar to usage of W_CPP_ENUM but you must use W_CPP_ENUM_NS instead of W_CPP_ENUM | ||||
| #define W_CPP_ENUM_NS(type, a) \ | ||||
|     W_STATE_APPEND_NS(EnumState, a<type>::enumInfo) \ | ||||
|     Q_ENUM_NS(type) | ||||
|  | ||||
| /// \macro W_CPP_FLAG(type, callback) | ||||
| /// allows to register a enum type as QFlags for a QObject type from a templated structure using regular C++. | ||||
| /// additionally enum can be declared outside QObject where it is registered. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     enum class Filter { None = 0x00, Name = 0x01, Comment = 0x02, Any = Name | Comment }; | ||||
| /// | ||||
| ///     Q_DECLARE_FLAGS(Filters, Filter) | ||||
| ///     template<> | ||||
| ///     struct MyEnums<Filters> { | ||||
| ///         constexpr static auto flagInfo = w_cpp::makeFlagInfo( | ||||
| ///             w_cpp::viewLiteral("Filters"), | ||||
| ///             w_cpp::viewLiteral("Filter"), | ||||
| ///             w_cpp::enum_sequence<Filter, Filter::None, Filter::Name, Filter::Comment, Filter::Any>{}, | ||||
| ///             w_cpp::StringViewArray<4>{{w_cpp::viewLiteral("None"), | ||||
| ///                                        w_cpp::viewLiteral("Name"), | ||||
| ///                                        w_cpp::viewLiteral("Comment"), | ||||
| ///                                        w_cpp::viewLiteral("Any")}}); | ||||
| ///     }; | ||||
| ///     W_CPP_FLAG(Filters, MyEnums) | ||||
| /// | ||||
| #define W_CPP_FLAG(type, a) \ | ||||
|     W_STATE_APPEND(EnumState, a<type>::flagInfo) \ | ||||
|     Q_FLAG(type) | ||||
|  | ||||
| /// \macro W_CPP_FLAG_NS(type, callback) | ||||
| /// allows to register a enum type as QFlags for a namespace that was declarated with W_NAMESPACE from a templated structure using regular C++. | ||||
| /// additionally enum can be declared outside namespace where it is registered. | ||||
| /// | ||||
| /// example usage: | ||||
| ///     Similar to usage of W_CPP_FLAG but you must use W_CPP_FLAG_NS instead of W_CPP_FLAG | ||||
| #define W_CPP_FLAG_NS(type, a) \ | ||||
|     W_STATE_APPEND_NS(EnumState, a<type>::flagInfo) \ | ||||
|     Q_FLAG_NS(type) | ||||
							
								
								
									
										1036
									
								
								dep/verdigris/src/wobjectdefs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1036
									
								
								dep/verdigris/src/wobjectdefs.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1426
									
								
								dep/verdigris/src/wobjectimpl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1426
									
								
								dep/verdigris/src/wobjectimpl.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -26,6 +26,7 @@ static const std::vector<FluxConstructor> fluxConstructors = { | ||||
|     {/* The .flux format must be first. */ | ||||
|         .name = "FluxEngine (.flux)", | ||||
|      .pattern = std::regex("^(.*\\.flux)$"), | ||||
|      .glob = "*.flux", | ||||
|      .source = | ||||
|             [](auto& s, auto* proto) | ||||
|         { | ||||
| @@ -40,6 +41,7 @@ static const std::vector<FluxConstructor> fluxConstructors = { | ||||
|     { | ||||
|      .name = "Supercard Pro (.scp)", | ||||
|      .pattern = std::regex("^(.*\\.scp)$"), | ||||
|      .glob = "*.scp", | ||||
|      .source = | ||||
|             [](auto& s, auto* proto) | ||||
|         { | ||||
| @@ -53,6 +55,7 @@ static const std::vector<FluxConstructor> fluxConstructors = { | ||||
|         }, }, | ||||
|     {.name = "AppleSauce (.a2r)", | ||||
|      .pattern = std::regex("^(.*\\.a2r)$"), | ||||
|      .glob = "*.a2r", | ||||
|      .source = | ||||
|             [](auto& s, auto* proto) | ||||
|         { | ||||
| @@ -66,6 +69,7 @@ static const std::vector<FluxConstructor> fluxConstructors = { | ||||
|         }}, | ||||
|     {.name = "CatWeazle (.cwf)", | ||||
|      .pattern = std::regex("^(.*\\.cwf)$"), | ||||
|      .glob = "*.cwf", | ||||
|      .source = | ||||
|             [](auto& s, auto* proto) | ||||
|         { | ||||
| @@ -599,4 +603,4 @@ bool Config::hasDecoder() | ||||
| const std::vector<FluxConstructor>& Config::getFluxFormats() | ||||
| { | ||||
|     return fluxConstructors; | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -60,6 +60,7 @@ struct FluxConstructor | ||||
| { | ||||
|     std::string name; | ||||
|     std::regex pattern; | ||||
|     std::string glob; | ||||
|     std::function<void(const std::string& filename, FluxSourceProto*)> source; | ||||
|     std::function<void(const std::string& filename, FluxSinkProto*)> sink; | ||||
| }; | ||||
|   | ||||
| @@ -23,6 +23,7 @@ struct TrackDataFlux | ||||
|     std::shared_ptr<const Fluxmap> fluxmap; | ||||
|     std::vector<std::shared_ptr<const Record>> records; | ||||
|     std::vector<std::shared_ptr<const Sector>> sectors; | ||||
|     nanoseconds_t rotationalPeriod; | ||||
| }; | ||||
|  | ||||
| struct TrackFlux | ||||
|   | ||||
| @@ -38,10 +38,10 @@ void FluxmapReader::getNextEvent(int& event, unsigned& ticks) | ||||
|     event = F_EOF; | ||||
| } | ||||
|  | ||||
| void FluxmapReader::skipToEvent(int event) | ||||
| bool FluxmapReader::skipToEvent(int event) | ||||
| { | ||||
|     unsigned ticks; | ||||
|     findEvent(event, ticks); | ||||
|     return findEvent(event, ticks); | ||||
| } | ||||
|  | ||||
| bool FluxmapReader::findEvent(int event, unsigned& ticks) | ||||
|   | ||||
| @@ -43,7 +43,7 @@ public: | ||||
|     } | ||||
|  | ||||
|     void getNextEvent(int& event, unsigned& ticks); | ||||
|     void skipToEvent(int event); | ||||
|     bool skipToEvent(int event); | ||||
|     bool findEvent(int event, unsigned& ticks); | ||||
|     unsigned readInterval(nanoseconds_t clock); /* with debounce support */ | ||||
|  | ||||
|   | ||||
| @@ -206,8 +206,8 @@ std::shared_ptr<const TrackInfo> Layout::getLayoutOfTrack( | ||||
|         layoutdata.MergeFrom(f); | ||||
|     } | ||||
|  | ||||
|     trackInfo->numTracks = globalConfig()->layout().tracks(); | ||||
|     trackInfo->numSides = globalConfig()->layout().sides(); | ||||
|     trackInfo->numLogicalTracks = globalConfig()->layout().tracks(); | ||||
|     trackInfo->numLogicalSides = globalConfig()->layout().sides(); | ||||
|     trackInfo->sectorSize = layoutdata.sector_size(); | ||||
|     trackInfo->logicalTrack = logicalTrack; | ||||
|     trackInfo->logicalSide = logicalSide; | ||||
| @@ -241,6 +241,11 @@ std::shared_ptr<const TrackInfo> Layout::getLayoutOfTrack( | ||||
|         trackInfo->naturalToFilesystemSectorMap[lid] = fid; | ||||
|     } | ||||
|  | ||||
|     trackInfo->numPhysicalTracks = | ||||
|         Layout::remapTrackLogicalToPhysical(trackInfo->numLogicalTracks); | ||||
|     trackInfo->numPhysicalSides = | ||||
|         Layout::remapSideLogicalToPhysical(trackInfo->numLogicalSides); | ||||
|  | ||||
|     return trackInfo; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -68,8 +68,13 @@ private: | ||||
|     TrackInfo& operator=(const TrackInfo&); | ||||
|  | ||||
| public: | ||||
|     unsigned numTracks = 0; | ||||
|     unsigned numSides = 0; | ||||
|     /* Size of the logical layout. */ | ||||
|     unsigned numLogicalTracks = 0; | ||||
|     unsigned numLogicalSides = 0; | ||||
|  | ||||
|     /* Size of the physical layout. */ | ||||
|     unsigned numPhysicalTracks = 0; | ||||
|     unsigned numPhysicalSides = 0; | ||||
|  | ||||
|     /* The number of sectors in this track. */ | ||||
|     unsigned numSectors = 0; | ||||
|   | ||||
| @@ -20,6 +20,7 @@ std::shared_ptr<TrackDataFlux> Decoder::decodeToSectors( | ||||
|     _trackdata = std::make_shared<TrackDataFlux>(); | ||||
|     _trackdata->fluxmap = fluxmap; | ||||
|     _trackdata->trackInfo = trackInfo; | ||||
|     _trackdata->rotationalPeriod = globalConfig()->drive().rotational_period_ms() * 1e6; | ||||
|  | ||||
|     FluxmapReader fmr(*fluxmap); | ||||
|     _fmr = &fmr; | ||||
|   | ||||
| @@ -98,7 +98,7 @@ public: | ||||
|     void setBaudRate(int baudRate) override | ||||
|     { | ||||
|         DCB dcb = {.DCBlength = sizeof(DCB), | ||||
|             .BaudRate = baudRate, | ||||
|             .BaudRate = (DWORD) baudRate, | ||||
|             .fBinary = true, | ||||
|             .ByteSize = 8, | ||||
|             .Parity = NOPARITY, | ||||
|   | ||||
							
								
								
									
										171
									
								
								src/gui2/build.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								src/gui2/build.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,171 @@ | ||||
| from build.ab import simplerule, Rule, Target | ||||
| from build.c import cxxprogram, cxxlibrary | ||||
| from build.pkg import package | ||||
| import config | ||||
|  | ||||
| package(name="Qt5Widgets", package="Qt5Widgets") | ||||
| package(name="Qt5Concurrent", package="Qt5Concurrent") | ||||
|  | ||||
|  | ||||
| @Rule | ||||
| def uic(self, name, src: Target = None, dest=None): | ||||
|     simplerule( | ||||
|         replaces=self, | ||||
|         ins=[src], | ||||
|         outs=["=" + dest], | ||||
|         commands=["$(UIC) -g cpp -o {outs[0]} {ins[0]}"], | ||||
|         label="UIC", | ||||
|     ) | ||||
|  | ||||
|  | ||||
| for n in ["imager", "filer", "frame"]: | ||||
|     uic(name=n + "_h", src="./" + n + ".ui", dest=n + ".h") | ||||
|  | ||||
| simplerule( | ||||
|     name="resources_cc", | ||||
|     ins=["./resources.qrc"], | ||||
|     outs=["=resources.cc"], | ||||
|     commands=["$(RCC) -g cpp --name resources -o {outs[0]} {ins[0]}"], | ||||
|     label="RCC", | ||||
| ) | ||||
|  | ||||
| cxxlibrary( | ||||
|     name="framelib", | ||||
|     srcs=[ | ||||
|         "./main.cc", | ||||
|         "./mainwindow.cc", | ||||
|         "./drivecomponent.cc", | ||||
|         "./formatcomponent.cc", | ||||
|         "./fluxvisualiserwidget.cc", | ||||
|         "./fluxview.cc", | ||||
|         "./fluxview.h", | ||||
|         "./imagevisualiserwidget.cc", | ||||
|         "./viewnavigator.cc", | ||||
|         "./viewnavigator.h", | ||||
|         "./scene.cc", | ||||
|         ".+resources_cc", | ||||
|     ], | ||||
|     hdrs={ | ||||
|         "globals.h": "./globals.h", | ||||
|         "mainwindow.h": "./mainwindow.h", | ||||
|         "frame.h": ".+frame_h", | ||||
|         "fluxvisualiserwidget.h": "./fluxvisualiserwidget.h", | ||||
|         "imagevisualiserwidget.h": "./imagevisualiserwidget.h", | ||||
|     }, | ||||
|     cflags=["-fPIC"], | ||||
|     deps=[ | ||||
|         "lib/config", | ||||
|         "lib/core", | ||||
|         "lib/data", | ||||
|         "lib/external", | ||||
|         "lib/algorithms", | ||||
|         "lib/vfs", | ||||
|         ".+Qt5Concurrent", | ||||
|         ".+Qt5Widgets", | ||||
|         "dep/verdigris", | ||||
|     ], | ||||
| ) | ||||
|  | ||||
| cxxprogram( | ||||
|     name="imager", | ||||
|     srcs=[ | ||||
|         "./mainwindow-imager.cc", | ||||
|         "./scene.cc", | ||||
|         ".+imager_h", | ||||
|     ], | ||||
|     cflags=["-fPIC"], | ||||
|     ldflags=["$(QT5_EXTRA_LIBS)"], | ||||
|     deps=[ | ||||
|         ".+imager_h", | ||||
|         "+fmt_lib", | ||||
|         "+protobuf_lib", | ||||
|         "+protocol", | ||||
|         "+z_lib", | ||||
|         ".+framelib", | ||||
|         ".+Qt5Concurrent", | ||||
|         ".+Qt5Widgets", | ||||
|         "dep/adflib", | ||||
|         "dep/fatfs", | ||||
|         "dep/hfsutils", | ||||
|         "dep/libusbp", | ||||
|         "dep/verdigris", | ||||
|         "extras+icons", | ||||
|         "lib/config", | ||||
|         "lib/core", | ||||
|         "lib/data", | ||||
|         "lib/external", | ||||
|         "src/formats", | ||||
|         "src/gui/drivetypes", | ||||
|     ], | ||||
| ) | ||||
|  | ||||
| cxxprogram( | ||||
|     name="filer", | ||||
|     srcs=[ | ||||
|         "./mainwindow-filer.cc", | ||||
|         ".+filer_h", | ||||
|     ], | ||||
|     cflags=["-fPIC"], | ||||
|     ldflags=["$(QT5_EXTRA_LIBS)"], | ||||
|     deps=[ | ||||
|         ".+filer_h", | ||||
|         "+fmt_lib", | ||||
|         "+protobuf_lib", | ||||
|         "+protocol", | ||||
|         "+z_lib", | ||||
|         ".+framelib", | ||||
|         ".+Qt5Concurrent", | ||||
|         ".+Qt5Widgets", | ||||
|         "dep/adflib", | ||||
|         "dep/fatfs", | ||||
|         "dep/hfsutils", | ||||
|         "dep/libusbp", | ||||
|         "dep/verdigris", | ||||
|         "extras+icons", | ||||
|         "lib/config", | ||||
|         "lib/core", | ||||
|         "lib/data", | ||||
|         "lib/external", | ||||
|         "src/formats", | ||||
|         "src/gui/drivetypes", | ||||
|     ], | ||||
| ) | ||||
|  | ||||
| if config.osx: | ||||
|     simplerule( | ||||
|         name="fluxengine_pkg", | ||||
|         ins=[".+fluxengine_app"], | ||||
|         outs=["=FluxEngine.pkg"], | ||||
|         commands=[ | ||||
|             "pkgbuild --quiet --install-location /Applications --component {ins[0]} {outs[0]}" | ||||
|         ], | ||||
|         label="PKGBUILD", | ||||
|     ) | ||||
|  | ||||
|     simplerule( | ||||
|         name="fluxengine_app", | ||||
|         ins=[ | ||||
|             ".+imager", | ||||
|             "extras+fluxengine_icns", | ||||
|             "extras/FluxEngine.app.template/", | ||||
|         ], | ||||
|         outs=["=FluxEngine.app"], | ||||
|         commands=[ | ||||
|             "rm -rf {outs[0]}", | ||||
|             "cp -a {ins[2]} {outs[0]}", | ||||
|             "touch {outs[0]}", | ||||
|             "cp {ins[0]} {outs[0]}/Contents/MacOS/fluxengine-gui", | ||||
|             "mkdir -p {outs[0]}/Contents/Resources", | ||||
|             "cp {ins[1]} {outs[0]}/Contents/Resources/FluxEngine.icns", | ||||
|             "dylibbundler -of -x {outs[0]}/Contents/MacOS/fluxengine-gui -b -d {outs[0]}/Contents/libs -cd > /dev/null", | ||||
|             "cp $$(brew --prefix wxwidgets)/README.md $@/Contents/libs/wxWidgets.md", | ||||
|             "cp $$(brew --prefix protobuf)/LICENSE $@/Contents/libs/protobuf.txt", | ||||
|             "cp $$(brew --prefix fmt)/LICENSE.rst $@/Contents/libs/fmt.rst", | ||||
|             "cp $$(brew --prefix libpng)/LICENSE $@/Contents/libs/libpng.txt", | ||||
|             "cp $$(brew --prefix libjpeg)/README $@/Contents/libs/libjpeg.txt", | ||||
|             "cp $$(brew --prefix abseil)/LICENSE $@/Contents/libs/abseil.txt", | ||||
|             "cp $$(brew --prefix libtiff)/LICENSE.md $@/Contents/libs/libtiff.txt", | ||||
|             "cp $$(brew --prefix zstd)/LICENSE $@/Contents/libs/zstd.txt", | ||||
|         ], | ||||
|         label="MKAPP", | ||||
|     ) | ||||
							
								
								
									
										464
									
								
								src/gui2/drivecomponent.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										464
									
								
								src/gui2/drivecomponent.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,464 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/usb/usbfinder.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "globals.h" | ||||
| #include "drivecomponent.h" | ||||
| #include "mainwindow.h" | ||||
| #include <QStandardItemModel> | ||||
| #include <range/v3/all.hpp> | ||||
|  | ||||
| static const char* DRIVE = "drive/"; | ||||
| static const char* SELECTED_DRIVE = "drive/drive"; | ||||
|  | ||||
| class DriveComponentImpl : public DriveComponent, public QObject | ||||
| { | ||||
|     W_OBJECT(DriveComponentImpl) | ||||
|  | ||||
| public: | ||||
|     class ConfigurationForm : public QStandardItem, public QObject | ||||
|     { | ||||
|         W_OBJECT(ConfigurationForm) | ||||
|  | ||||
|     public: | ||||
|         ConfigurationForm(QWidget* widget, | ||||
|             DriveComponentImpl* dci, | ||||
|             QIcon icon, | ||||
|             const std::string text): | ||||
|             QStandardItem(icon, QString::fromStdString(text)), | ||||
|             _widget(widget), | ||||
|             _dci(dci), | ||||
|             _mw(dci->_mainWindow) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|     public: | ||||
|         virtual std::string id() const = 0; | ||||
|         virtual void collectConfig() const = 0; | ||||
|  | ||||
|         virtual void loadSavedState() = 0; | ||||
|         virtual void connectAll() = 0; | ||||
|         virtual void updateSavedState() const = 0; | ||||
|         W_SLOT(updateSavedState) | ||||
|  | ||||
|     public: | ||||
|         QWidget* widget() const | ||||
|         { | ||||
|             return _widget; | ||||
|         } | ||||
|  | ||||
|     protected: | ||||
|         QString qid() const | ||||
|         { | ||||
|             return DRIVE + QString::fromStdString(id()); | ||||
|         } | ||||
|  | ||||
|     protected: | ||||
|         QWidget* _widget; | ||||
|         DriveComponentImpl* _dci; | ||||
|         MainWindow* _mw; | ||||
|     }; | ||||
|  | ||||
|     class FluxConfigurationForm : public ConfigurationForm | ||||
|     { | ||||
|     public: | ||||
|         FluxConfigurationForm(DriveComponentImpl* dci): | ||||
|             ConfigurationForm(dci->_mainWindow->fluxDevicePage, | ||||
|                 dci, | ||||
|                 QIcon(":/ui/extras/fluxfile.png"), | ||||
|                 "Flux file") | ||||
|         { | ||||
|         } | ||||
|  | ||||
|     public: | ||||
|         std::string id() const override | ||||
|         { | ||||
|             return "flux"; | ||||
|         } | ||||
|  | ||||
|         void collectConfig() const override | ||||
|         { | ||||
|             auto fluxFile = _mw->filenameEdit->text().toStdString(); | ||||
|  | ||||
|             const FluxConstructor* fc = &Config::getFluxFormats()[0]; | ||||
|             if (fc->sink) | ||||
|                 fc->sink( | ||||
|                     fluxFile, globalConfig().overrides()->mutable_flux_sink()); | ||||
|             if (fc->source) | ||||
|                 fc->source(fluxFile, | ||||
|                     globalConfig().overrides()->mutable_flux_source()); | ||||
|  | ||||
|             QString rpmOverride = | ||||
|                 _mw->rpmOverrideComboBox->currentData().toString(); | ||||
|             if (rpmOverride == "300") | ||||
|                 globalConfig() | ||||
|                     .overrides() | ||||
|                     ->mutable_drive() | ||||
|                     ->set_rotational_period_ms(200); | ||||
|             else if (rpmOverride == "360") | ||||
|                 globalConfig() | ||||
|                     .overrides() | ||||
|                     ->mutable_drive() | ||||
|                     ->set_rotational_period_ms(166); | ||||
|             else if (rpmOverride == "override") | ||||
|             { | ||||
|                 float value = _mw->rpmOverrideValue->value(); | ||||
|                 globalConfig() | ||||
|                     .overrides() | ||||
|                     ->mutable_drive() | ||||
|                     ->set_rotational_period_ms(60e3 / value); | ||||
|             } | ||||
|  | ||||
|             QString driveTypeOverride = | ||||
|                 _mw->driveTypeOverrideComboBox->currentData().toString(); | ||||
|             if (driveTypeOverride != "default") | ||||
|                 globalConfig().overrides()->MergeFrom( | ||||
|                     *drivetypes.at(driveTypeOverride.toStdString())); | ||||
|         } | ||||
|  | ||||
|         void loadSavedState() override | ||||
|         { | ||||
|             _mw->filenameEdit->setText( | ||||
|                 app->value(qid() + "/filename").toString()); | ||||
|  | ||||
|             _mw->rpmOverrideComboBox->addItem( | ||||
|                 "Use value in file", QVariant("default")); | ||||
|             _mw->rpmOverrideComboBox->addItem( | ||||
|                 "300 rpm / 200 ms", QVariant("300")); | ||||
|             _mw->rpmOverrideComboBox->addItem( | ||||
|                 "360 rpm / 166 ms", QVariant("360")); | ||||
|             _mw->rpmOverrideComboBox->addItem( | ||||
|                 "Custom value", QVariant("custom")); | ||||
|             QString rpmType = app->value(qid() + "/rpmType").toString(); | ||||
|             setByString(_mw->rpmOverrideComboBox, rpmType); | ||||
|             _mw->rpmOverrideValue->setEnabled(rpmType == "custom"); | ||||
|  | ||||
|             _mw->driveTypeOverrideComboBox->addItem( | ||||
|                 "Use value in file", QVariant("default")); | ||||
|             for (auto& d : drivetypes) | ||||
|             { | ||||
|                 _mw->driveTypeOverrideComboBox->addItem( | ||||
|                     QString::fromStdString(d.second->comment()), | ||||
|                     QVariant(QString::fromStdString(d.first))); | ||||
|             } | ||||
|             setByString(_mw->driveTypeOverrideComboBox, | ||||
|                 app->value(qid() + "/driveType").toString()); | ||||
|  | ||||
|             _mw->rpmOverrideValue->setValue( | ||||
|                 app->value(qid() + "/customRpm").toInt()); | ||||
|         } | ||||
|  | ||||
|         void connectAll() override | ||||
|         { | ||||
|             connect(_mw->filenameEdit, | ||||
|                 &QLineEdit::editingFinished, | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->driveTypeOverrideComboBox, | ||||
|                 QOverload<int>::of(&QComboBox::activated), | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->rpmOverrideComboBox, | ||||
|                 QOverload<int>::of(&QComboBox::activated), | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->rpmOverrideValue, | ||||
|                 QOverload<int>::of(&QSpinBox::valueChanged), | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|  | ||||
|             connect(_mw->openButton, | ||||
|                 &QPushButton::clicked, | ||||
|                 [this]() | ||||
|                 { | ||||
|                     std::string formats = Config::getFluxFormats() | | ||||
|                                           ranges::views::transform( | ||||
|                                               [](const FluxConstructor& f) | ||||
|                                               { | ||||
|                                                   return f.glob; | ||||
|                                               }) | | ||||
|                                           ranges::views::filter( | ||||
|                                               [](const std::string& s) | ||||
|                                               { | ||||
|                                                   return !s.empty(); | ||||
|                                               }) | | ||||
|                                           ranges::views::intersperse(" ") | | ||||
|                                           ranges::views::join | | ||||
|                                           ranges::to<std::string>(); | ||||
|                     QFileDialog dialogue(_mw); | ||||
|                     dialogue.setFileMode(QFileDialog::ExistingFile); | ||||
|                     dialogue.setNameFilter( | ||||
|                         QString::fromStdString("Flux files (" + formats + ")")); | ||||
|  | ||||
|                     QStringList fileNames; | ||||
|                     if (dialogue.exec()) | ||||
|                         _mw->filenameEdit->setText( | ||||
|                             dialogue.selectedFiles().first()); | ||||
|                 }); | ||||
|         } | ||||
|  | ||||
|         void updateSavedState() const override | ||||
|         { | ||||
|             app->setValue(qid() + "/filename", _mw->filenameEdit->text()); | ||||
|  | ||||
|             QString rpmType = | ||||
|                 _mw->rpmOverrideComboBox->currentData().toString(); | ||||
|             app->setValue(qid() + "/rpmType", rpmType); | ||||
|             _mw->rpmOverrideValue->setEnabled(rpmType == "custom"); | ||||
|  | ||||
|             app->setValue(qid() + "/customRpm", _mw->rpmOverrideValue->value()); | ||||
|  | ||||
|             app->setValue(qid() + "/driveType", | ||||
|                 _mw->driveTypeOverrideComboBox->currentData().toString()); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     class DriveConfigurationForm : public ConfigurationForm | ||||
|     { | ||||
|     public: | ||||
|         DriveConfigurationForm( | ||||
|             DriveComponentImpl* dci, QIcon icon, const std::string& label): | ||||
|             ConfigurationForm( | ||||
|                 dci->_mainWindow->hardwareDevicePage, dci, icon, label) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|         void collectConfig() const override | ||||
|         { | ||||
|             globalConfig().overrides()->mutable_drive()->set_high_density( | ||||
|                 _mw->highDensityToggle->isChecked()); | ||||
|  | ||||
|             auto driveTypeId = | ||||
|                 _mw->driveTypeComboBox->currentData().toString().toStdString(); | ||||
|             globalConfig().overrides()->MergeFrom(*drivetypes.at(driveTypeId)); | ||||
|  | ||||
|             auto filename = | ||||
|                 fmt::format("drive:{}", _mw->driveComboBox->currentIndex()); | ||||
|             globalConfig().setFluxSink(filename); | ||||
|             globalConfig().setFluxSource(filename); | ||||
|             globalConfig().setVerificationFluxSource(filename); | ||||
|         } | ||||
|  | ||||
|         void loadSavedState() override | ||||
|         { | ||||
|             _mw->driveComboBox->setCurrentIndex( | ||||
|                 app->value(qid() + "/drive").toInt()); | ||||
|  | ||||
|             QString driveType = app->value(qid() + "/driveType").toString(); | ||||
|             for (auto& d : drivetypes) | ||||
|             { | ||||
|                 _mw->driveTypeComboBox->addItem( | ||||
|                     QString::fromStdString(d.second->comment()), | ||||
|                     QVariant(QString::fromStdString(d.first))); | ||||
|                 if (QString::fromStdString(d.first) == driveType) | ||||
|                     _mw->driveTypeComboBox->setCurrentIndex( | ||||
|                         _mw->driveTypeComboBox->count() - 1); | ||||
|             } | ||||
|  | ||||
|             _mw->highDensityToggle->setCheckState( | ||||
|                 app->value(qid() + "/highDensity").toBool() ? Qt::Checked | ||||
|                                                             : Qt::Unchecked); | ||||
|         } | ||||
|  | ||||
|         void connectAll() override | ||||
|         { | ||||
|             connect(_mw->portLineEdit, | ||||
|                 &QLineEdit::editingFinished, | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->driveComboBox, | ||||
|                 QOverload<int>::of(&QComboBox::activated), | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->driveTypeComboBox, | ||||
|                 QOverload<int>::of(&QComboBox::activated), | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|             connect(_mw->highDensityToggle, | ||||
|                 &QCheckBox::stateChanged, | ||||
|                 this, | ||||
|                 &ConfigurationForm::updateSavedState); | ||||
|         } | ||||
|  | ||||
|         void updateSavedState() const override | ||||
|         { | ||||
|             app->setValue(qid() + "/drive", _mw->driveComboBox->currentIndex()); | ||||
|  | ||||
|             app->setValue(qid() + "/driveType", | ||||
|                 _mw->driveTypeComboBox->currentData().toString()); | ||||
|  | ||||
|             app->setValue( | ||||
|                 qid() + "/highDensity", _mw->highDensityToggle->isChecked()); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     class ManualDriveConfigurationForm : public DriveConfigurationForm | ||||
|     { | ||||
|     public: | ||||
|         ManualDriveConfigurationForm(DriveComponentImpl* dci): | ||||
|             DriveConfigurationForm(dci, | ||||
|                 QIcon(":/ui/extras/hardware.png"), | ||||
|                 "Greaseweazle\n(configured manually)") | ||||
|         { | ||||
|         } | ||||
|  | ||||
|     public: | ||||
|         std::string id() const override | ||||
|         { | ||||
|             return "device/manual"; | ||||
|         } | ||||
|  | ||||
|         void collectConfig() const override | ||||
|         { | ||||
|             DriveConfigurationForm::collectConfig(); | ||||
|             globalConfig() | ||||
|                 .overrides() | ||||
|                 ->mutable_usb() | ||||
|                 ->mutable_greaseweazle() | ||||
|                 ->set_port(_mw->portLineEdit->text().toStdString()); | ||||
|         } | ||||
|  | ||||
|         void loadSavedState() override | ||||
|         { | ||||
|             DriveConfigurationForm::loadSavedState(); | ||||
|             _mw->portLineEdit->setText(app->value(qid() + "/port").toString()); | ||||
|         } | ||||
|  | ||||
|         void updateSavedState() const override | ||||
|         { | ||||
|             app->setValue(qid() + "/port", _mw->portLineEdit->text()); | ||||
|             DriveConfigurationForm::updateSavedState(); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     class DetectedDriveConfigurationForm : public DriveConfigurationForm | ||||
|     { | ||||
|     public: | ||||
|         DetectedDriveConfigurationForm(DriveComponentImpl* dci, | ||||
|             const std::string& type, | ||||
|             const std::string& id, | ||||
|             std::shared_ptr<CandidateDevice>& device): | ||||
|             DriveConfigurationForm(dci, | ||||
|                 QIcon(":/ui/extras/hardware.png"), | ||||
|                 fmt::format("{}\n{}", type, id)), | ||||
|             _type(type), | ||||
|             _id(id), | ||||
|             _device(device) | ||||
|         { | ||||
|             _mw->portLineEdit->setEnabled(false); | ||||
|         } | ||||
|  | ||||
|         void loadSavedState() override | ||||
|         { | ||||
|             _mw->portLineEdit->setText( | ||||
|                 QString::fromStdString(_device->serialPort)); | ||||
|         } | ||||
|  | ||||
|     public: | ||||
|         std::string id() const override | ||||
|         { | ||||
|             return "device/" + _id; | ||||
|         } | ||||
|  | ||||
|     private: | ||||
|         std::shared_ptr<CandidateDevice>& _device; | ||||
|         std::string _type; | ||||
|         std::string _id; | ||||
|     }; | ||||
|  | ||||
| public: | ||||
|     DriveComponentImpl(MainWindow* mainWindow): _mainWindow(mainWindow) | ||||
|     { | ||||
|         setParent(mainWindow); | ||||
|         _devicesModel.setColumnCount(1); | ||||
|         _mainWindow->deviceSelectionComboBox->setModel(&_devicesModel); | ||||
|  | ||||
|         addForm(new ManualDriveConfigurationForm(this)); | ||||
|         addForm(new FluxConfigurationForm(this)); | ||||
|  | ||||
|         auto devices = runOnWorkerThread(findUsbDevices).result(); | ||||
|         for (auto& it : devices) | ||||
|             addForm(new DetectedDriveConfigurationForm( | ||||
|                 this, getDeviceName(it->type), it->serial, it)); | ||||
|  | ||||
|         auto currentFormId = | ||||
|             app->value(SELECTED_DRIVE).toString().toStdString(); | ||||
|         int currentFormIndex = findFormById(currentFormId, 0); | ||||
|         _mainWindow->deviceSelectionComboBox->setCurrentIndex(currentFormIndex); | ||||
|         changeSelectedDevice(currentFormIndex); | ||||
|  | ||||
|         _mainWindow->connect(_mainWindow->deviceSelectionComboBox, | ||||
|             QOverload<int>::of(&QComboBox::activated), | ||||
|             this, | ||||
|             &DriveComponentImpl::changeSelectedDevice); | ||||
|         _mainWindow->connect(_mainWindow->deviceSelectionComboBox, | ||||
|             QOverload<int>::of(&QComboBox::activated), | ||||
|             this, | ||||
|             &DriveComponentImpl::updateSavedState); | ||||
|  | ||||
|         _mainWindow->updateGeometry(); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     void addForm(ConfigurationForm* form) | ||||
|     { | ||||
|         form->loadSavedState(); | ||||
|         form->connectAll(); | ||||
|  | ||||
|         _forms.append(form); | ||||
|         _devicesModel.appendRow(form); | ||||
|     } | ||||
|  | ||||
|     int findFormById(const std::string& id, int def) | ||||
|     { | ||||
|         for (int i = 0; i < _forms.size(); i++) | ||||
|             if (_forms[i]->id() == id) | ||||
|                 return i; | ||||
|         return def; | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void changeSelectedDevice(int index) | ||||
|     { | ||||
|         _mainWindow->driveStackedWidget->setCurrentIndex(index); | ||||
|     } | ||||
|     W_SLOT(changeSelectedDevice) | ||||
|  | ||||
|     void updateSavedState() | ||||
|     { | ||||
|         int selectedForm = _mainWindow->deviceSelectionComboBox->currentIndex(); | ||||
|         ConfigurationForm* form = _forms[selectedForm]; | ||||
|  | ||||
|         app->setValue(SELECTED_DRIVE, QString::fromStdString(form->id())); | ||||
|     } | ||||
|     W_SLOT(updateSavedState) | ||||
|  | ||||
| public: | ||||
|     void collectConfig() override | ||||
|     { | ||||
|         int selectedForm = _mainWindow->deviceSelectionComboBox->currentIndex(); | ||||
|         ConfigurationForm* form = _forms.at(selectedForm); | ||||
|         form->collectConfig(); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     static void setByString(QComboBox* combobox, QString value) | ||||
|     { | ||||
|         int i = combobox->findData(QVariant(value)); | ||||
|         if (i == -1) | ||||
|             i = 0; | ||||
|         combobox->setCurrentIndex(i); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     MainWindow* _mainWindow; | ||||
|     QStandardItemModel _devicesModel; | ||||
|     QList<ConfigurationForm*> _forms; | ||||
| }; | ||||
|  | ||||
| W_OBJECT_IMPL(DriveComponentImpl) | ||||
| W_OBJECT_IMPL(DriveComponentImpl::ConfigurationForm) | ||||
|  | ||||
| DriveComponent* DriveComponent::create(MainWindow* mainWindow) | ||||
| { | ||||
|     return new DriveComponentImpl(mainWindow); | ||||
| } | ||||
							
								
								
									
										12
									
								
								src/gui2/drivecomponent.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/gui2/drivecomponent.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| #pragma once | ||||
|  | ||||
| class MainWindow; | ||||
|  | ||||
| class DriveComponent | ||||
| { | ||||
| public: | ||||
|     static DriveComponent* create(MainWindow* mainWindow); | ||||
|  | ||||
| public: | ||||
|     virtual void collectConfig() = 0; | ||||
| }; | ||||
							
								
								
									
										25
									
								
								src/gui2/filer.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/gui2/filer.ui
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>Filer</class> | ||||
|  <widget class="QWidget" name="Filer"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>494</width> | ||||
|     <height>250</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="sizePolicy"> | ||||
|    <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||
|     <horstretch>0</horstretch> | ||||
|     <verstretch>0</verstretch> | ||||
|    </sizepolicy> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"/> | ||||
|  </widget> | ||||
|  <resources> | ||||
|   <include location="resources.qrc"/> | ||||
|  </resources> | ||||
|  <connections/> | ||||
| </ui> | ||||
							
								
								
									
										118
									
								
								src/gui2/fluxview.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								src/gui2/fluxview.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,118 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/data/fluxmap.h" | ||||
| #include "lib/data/flux.h" | ||||
| #include "lib/data/layout.h" | ||||
| #include "lib/data/fluxmapreader.h" | ||||
| #include "globals.h" | ||||
| #include "fluxview.h" | ||||
| #include "scene.h" | ||||
| #include <QConicalGradient> | ||||
| #include <range/v3/all.hpp> | ||||
|  | ||||
| class FluxViewImpl : public FluxView | ||||
| { | ||||
|     struct track_t; | ||||
|  | ||||
| public: | ||||
|     void setTrackData( | ||||
|         int track, std::shared_ptr<const Fluxmap>& fluxmap) override | ||||
|     { | ||||
|         auto& t = _trackData[track]; | ||||
|         t.fluxmap = fluxmap; | ||||
|         t.pulses.clear(); | ||||
|         t.indices.clear(); | ||||
|  | ||||
|         FluxmapReader fmr(*fluxmap); | ||||
|         t.firstIndexTimestamp = 0; | ||||
|         while (!fmr.eof()) | ||||
|         { | ||||
|             int type; | ||||
|             unsigned ticks; | ||||
|             fmr.getNextEvent(type, ticks); | ||||
|  | ||||
|             nanoseconds_t here = fmr.tell().ns(); | ||||
|             if (type & F_BIT_INDEX) | ||||
|                 t.indices.push_back(here); | ||||
|             if (type & F_BIT_PULSE) | ||||
|                 t.pulses.push_back(here); | ||||
|             if (type & F_EOF) | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void clear() override | ||||
|     { | ||||
|         _trackData.clear(); | ||||
|     } | ||||
|  | ||||
|     void redraw(QPainter& painter, | ||||
|         nanoseconds_t startPos, | ||||
|         nanoseconds_t endPos, | ||||
|         int track, | ||||
|         double height) | ||||
|     { | ||||
|         auto& t = _trackData[track]; | ||||
|         if (!t.fluxmap) | ||||
|             return; | ||||
|  | ||||
|         /* Number of on-screen pixels per drawing unit. */ | ||||
|         double pixelsPerUnit = painter.worldTransform().m11(); | ||||
|  | ||||
|         /* Width of an on-screen pixel in drawing units. */ | ||||
|         double granularity = 1.0 / pixelsPerUnit; | ||||
|  | ||||
|         /* Number of nanoseconds per on-screen pixel. */ | ||||
|         double nsPerPixel = granularity * FLUXVIEWER_NS_PER_UNIT; | ||||
|  | ||||
|         painter.setBrush(Qt::NoBrush); | ||||
|  | ||||
|         int pixel = 0; | ||||
|         int count = 0; | ||||
|         int i = 0; | ||||
|  | ||||
|         for (nanoseconds_t here : t.pulses) | ||||
|         { | ||||
|             if (here < startPos) | ||||
|                 continue; | ||||
|             if (here > endPos) | ||||
|                 break; | ||||
|  | ||||
|             int thisPixel = here / nsPerPixel; | ||||
|             if (thisPixel != pixel) | ||||
|             { | ||||
|                 if (count != 0) | ||||
|                 { | ||||
|                     double x = pixel * granularity; | ||||
|                     double countPerNs = count / nsPerPixel; | ||||
|                     double density = std::clamp( | ||||
|                         countPerNs / FLUXVIEWER_GRADIENT_ADJUST, 0.0, 1.0); | ||||
|                     int c = 255 - density * 255.0; | ||||
|                     painter.setPen(QPen( | ||||
|                         QColor(0, c, c), granularity * FLUXVIEWER_LINE_WIDTH)); | ||||
|                     painter.drawLine(QLineF(x, 0, x, height)); | ||||
|                     count = 0; | ||||
|                 } | ||||
|                 pixel = thisPixel; | ||||
|             } | ||||
|  | ||||
|             count++; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     struct track_t | ||||
|     { | ||||
|         std::shared_ptr<const Fluxmap> fluxmap; | ||||
|         nanoseconds_t firstIndexTimestamp = 0; | ||||
|         std::vector<nanoseconds_t> pulses; | ||||
|         std::vector<nanoseconds_t> indices; | ||||
|     }; | ||||
|  | ||||
|     std::map<int, track_t> _trackData; | ||||
| }; | ||||
|  | ||||
| std::unique_ptr<FluxView> FluxView::create() | ||||
| { | ||||
|     return std::make_unique<FluxViewImpl>(); | ||||
| } | ||||
							
								
								
									
										22
									
								
								src/gui2/fluxview.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/gui2/fluxview.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| #pragma once | ||||
|  | ||||
| static constexpr double FLUXVIEWER_NS_PER_UNIT = 100000.0; | ||||
| static constexpr double FLUXVIEWER_GRADIENT_ADJUST = 0.001; | ||||
| static constexpr double FLUXVIEWER_LINE_WIDTH = 1.1; | ||||
|  | ||||
| class FluxView | ||||
| { | ||||
| public: | ||||
|     static std::unique_ptr<FluxView> create(); | ||||
|  | ||||
| public: | ||||
|     virtual void setTrackData( | ||||
|         int track, std::shared_ptr<const Fluxmap>& fluxmap) = 0; | ||||
|     virtual void clear() = 0; | ||||
|  | ||||
|     virtual void redraw(QPainter& painter, | ||||
|         nanoseconds_t startPos, | ||||
|         nanoseconds_t endPos, | ||||
|         int track, | ||||
|         double height) = 0; | ||||
| }; | ||||
							
								
								
									
										237
									
								
								src/gui2/fluxvisualiserwidget.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										237
									
								
								src/gui2/fluxvisualiserwidget.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,237 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/data/fluxmap.h" | ||||
| #include "lib/data/flux.h" | ||||
| #include "lib/data/layout.h" | ||||
| #include "lib/data/fluxmapreader.h" | ||||
| #include "globals.h" | ||||
| #include "fluxvisualiserwidget.h" | ||||
| #include "fluxview.h" | ||||
| #include "scene.h" | ||||
| #include "viewnavigator.h" | ||||
| #include <range/v3/all.hpp> | ||||
|  | ||||
| W_OBJECT_IMPL(FluxVisualiserWidget) | ||||
|  | ||||
| class DiskFlux; | ||||
| class TrackFlux; | ||||
|  | ||||
| static constexpr double VSCALE_TRACK_SIZE = 10; | ||||
| static constexpr double VMARGIN_SIZE = 30; | ||||
| static constexpr double HMARGIN_SIZE = 40; | ||||
| static constexpr int MINIMUM_TICK_DISTANCE = 10; | ||||
| static constexpr int MAXIMUM_TRACKS = 82; | ||||
| static constexpr double SIDE_SPACING = 90; | ||||
|  | ||||
| static constexpr double DEFAULT_SCALE = 0.25; | ||||
|  | ||||
| static constexpr QRect CENTRED( | ||||
|     -(INT_MAX / 2), -(INT_MAX / 2), INT_MAX, INT_MAX); | ||||
|  | ||||
| class FluxVisualiserWidgetImpl : public FluxVisualiserWidget | ||||
| { | ||||
| private: | ||||
|     struct track_t; | ||||
|  | ||||
| public: | ||||
|     FluxVisualiserWidgetImpl(): _viewNavigator(ViewNavigator::create(this, 2.0)) | ||||
|     { | ||||
|         clearData(); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void resizeEvent(QResizeEvent* event) override {} | ||||
|  | ||||
| public: | ||||
|     void clearData() override | ||||
|     { | ||||
|         _tracks.clear(); | ||||
|         _numTracks = 0; | ||||
|         _totalDuration = 0; | ||||
|         _fluxView[0] = FluxView::create(); | ||||
|         _fluxView[1] = FluxView::create(); | ||||
|         repaint(); | ||||
|         resetView(); | ||||
|     } | ||||
|  | ||||
|     void setTrackData(std::shared_ptr<const TrackFlux> track) override | ||||
|     { | ||||
|         key_t key = { | ||||
|             track->trackInfo->physicalTrack, track->trackInfo->physicalSide}; | ||||
|         _numTracks = std::max(_numTracks, track->trackInfo->numPhysicalTracks); | ||||
|  | ||||
|         std::shared_ptr<const Fluxmap> data = | ||||
|             track->trackDatas.front()->fluxmap; | ||||
|         _fluxView[track->trackInfo->physicalSide]->setTrackData( | ||||
|             key.first, data); | ||||
|         _totalDuration = std::max(_totalDuration, data->duration()); | ||||
|  | ||||
|         repaint(); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void resetView() override | ||||
|     { | ||||
|         _viewNavigator->setScale(DEFAULT_SCALE); | ||||
|         _viewNavigator->setOrigin(rect().width() / 2 / DEFAULT_SCALE - | ||||
|                                       HMARGIN_SIZE * 1.2 / DEFAULT_SCALE, | ||||
|             rect().height() / 2 / DEFAULT_SCALE - | ||||
|                 VMARGIN_SIZE * 1.2 / DEFAULT_SCALE); | ||||
|     } | ||||
|  | ||||
| protected: | ||||
|     void paintEvent(QPaintEvent* event) override | ||||
|     { | ||||
|         QPainter painter(this); | ||||
|         painter.setRenderHint(QPainter::Antialiasing); | ||||
|  | ||||
|         /* Draw the flux view. */ | ||||
|  | ||||
|         painter.save(); | ||||
|         _viewNavigator->transform(painter); | ||||
|  | ||||
|         QRectF world = | ||||
|             painter.worldTransform().inverted().mapRect(QRectF(event->rect())); | ||||
|         double topTrack = world.top() / VSCALE_TRACK_SIZE; | ||||
|         double bottomTrack = world.bottom() / VSCALE_TRACK_SIZE; | ||||
|         nanoseconds_t left = world.left() * FLUXVIEWER_NS_PER_UNIT; | ||||
|         nanoseconds_t right = world.right() * FLUXVIEWER_NS_PER_UNIT; | ||||
|         painter.setPen(palette().color(QPalette::Text)); | ||||
|         painter.setBrush(Qt::NoBrush); | ||||
|  | ||||
|         for (int side = 0; side <= 1; side++) | ||||
|         { | ||||
|             for (int i = 0; i < _numTracks; i++) | ||||
|             { | ||||
|                 painter.save(); | ||||
|                 painter.translate( | ||||
|                     0, VSCALE_TRACK_SIZE * (i + side * SIDE_SPACING)); | ||||
|                 painter.setPen(palette().color(QPalette::Text)); | ||||
|                 _fluxView[side]->redraw( | ||||
|                     painter, left, right, i, VSCALE_TRACK_SIZE); | ||||
|  | ||||
|                 painter.setPen(palette().color(QPalette::Base)); | ||||
|                 painter.drawLine(left / FLUXVIEWER_NS_PER_UNIT, | ||||
|                     0, | ||||
|                     right / FLUXVIEWER_NS_PER_UNIT, | ||||
|                     0); | ||||
|                 painter.restore(); | ||||
|             } | ||||
|         } | ||||
|         painter.restore(); | ||||
|  | ||||
|         /* Draw the margins. */ | ||||
|  | ||||
|         painter.setPen(Qt::NoPen); | ||||
|         painter.setBrush(QColor(255, 255, 255, 200)); | ||||
|         painter.drawRect(0, 0, rect().width(), VMARGIN_SIZE); | ||||
|         painter.drawRect( | ||||
|             0, VMARGIN_SIZE, HMARGIN_SIZE, rect().height() - VMARGIN_SIZE); | ||||
|  | ||||
|         /* Draw the horizontal scale. */ | ||||
|  | ||||
|         { | ||||
|             double nanosecondsPerPixel = (right - left) / rect().width(); | ||||
|  | ||||
|             int yy = VMARGIN_SIZE * 4 / 5; | ||||
|             uint64_t tickStep = 1000; | ||||
|             while ((tickStep / nanosecondsPerPixel) < MINIMUM_TICK_DISTANCE) | ||||
|                 tickStep *= 10; | ||||
|  | ||||
|             painter.setPen(QPen(palette().color(QPalette::Text), 0)); | ||||
|             painter.setBrush(Qt::NoBrush); | ||||
|  | ||||
|             nanoseconds_t dataLeft = std::max(left, 0.0); | ||||
|             nanoseconds_t dataRight = std::min(right, _totalDuration); | ||||
|  | ||||
|             painter.drawLine((dataLeft - left) / nanosecondsPerPixel, | ||||
|                 yy, | ||||
|                 (dataRight - left) / nanosecondsPerPixel, | ||||
|                 yy); | ||||
|             uint64_t tick = | ||||
|                 std::max(floor(dataLeft / tickStep) * tickStep, 0.0); | ||||
|             while (tick < dataRight) | ||||
|             { | ||||
|                 int xx = (tick - left) / nanosecondsPerPixel; | ||||
|                 int ts = VMARGIN_SIZE / 5; | ||||
|                 if ((tick % (10 * tickStep)) == 0) | ||||
|                     ts = VMARGIN_SIZE / 4; | ||||
|                 if ((tick % (100 * tickStep)) == 0) | ||||
|                     ts = VMARGIN_SIZE / 3; | ||||
|  | ||||
|                 if ((tick % (10 * tickStep)) == 0) | ||||
|                 { | ||||
|                     painter.drawText(xx - 512, | ||||
|                         0, | ||||
|                         1024, | ||||
|                         VMARGIN_SIZE / 2, | ||||
|                         Qt::AlignCenter, | ||||
|                         QString::fromStdString( | ||||
|                             fmt::format("{:.3f}ms", tick / 1e6))); | ||||
|                 } | ||||
|  | ||||
|                 painter.drawLine(xx, yy, xx, yy - ts); | ||||
|  | ||||
|                 tick += tickStep; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /* Draw the vertical scale. */ | ||||
|  | ||||
|         for (int side = 0; side <= 1; side++) | ||||
|         { | ||||
|             painter.save(); | ||||
|             painter.setPen(QPen(palette().color(QPalette::Text), 0)); | ||||
|             painter.setBrush(Qt::NoBrush); | ||||
|  | ||||
|             double xx = HMARGIN_SIZE * 4 / 5; | ||||
|             double ys = rect().height() / (bottomTrack - topTrack); | ||||
|             double w = std::clamp(xx * 4 / 3 - ys / 2, xx / 2, xx); | ||||
|             double yy0 = (side * 90 - topTrack) * ys; | ||||
|  | ||||
|             QFont font; | ||||
|             font.setPixelSize(std::clamp(ys * 2 / 3, 2.0, HMARGIN_SIZE / 3)); | ||||
|             painter.setFont(font); | ||||
|  | ||||
|             for (int t = 0; t < MAXIMUM_TRACKS; t++) | ||||
|             { | ||||
|                 double yy = yy0 + t * ys; | ||||
|                 double yt = yy + ys * 0.5 / VSCALE_TRACK_SIZE; | ||||
|                 double yb = yy + ys * 9.5 / VSCALE_TRACK_SIZE; | ||||
|                 painter.drawLine(xx, yt, w, yt); | ||||
|                 painter.drawLine(xx, yb, w, yb); | ||||
|                 painter.drawLine(xx, yt, xx, yb); | ||||
|  | ||||
|                 painter.save(); | ||||
|                 painter.setTransform( | ||||
|                     QTransform().translate(xx / 2, yy + ys * .5)); | ||||
|  | ||||
|                 painter.drawText(CENTRED, | ||||
|                     Qt::AlignCenter, | ||||
|                     QString::fromStdString(fmt::format("{}.{}", side, t))); | ||||
|                 painter.restore(); | ||||
|             } | ||||
|             painter.restore(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     typedef std::pair<unsigned, unsigned> key_t; | ||||
|  | ||||
|     struct track_t | ||||
|     { | ||||
|         std::shared_ptr<const TrackFlux> flux; | ||||
|         std::vector<float> densityMap; | ||||
|     }; | ||||
|  | ||||
|     std::map<key_t, track_t> _tracks; | ||||
|     unsigned _numTracks = 0; | ||||
|     nanoseconds_t _totalDuration; | ||||
|     std::unique_ptr<FluxView> _fluxView[2]; | ||||
|     std::unique_ptr<ViewNavigator> _viewNavigator; | ||||
| }; | ||||
|  | ||||
| FluxVisualiserWidget* FluxVisualiserWidget::create() | ||||
| { | ||||
|     return new FluxVisualiserWidgetImpl(); | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/gui2/fluxvisualiserwidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/gui2/fluxvisualiserwidget.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <QGraphicsView> | ||||
|  | ||||
| class FluxVisualiserWidget : public QWidget | ||||
| { | ||||
|     W_OBJECT(FluxVisualiserWidget) | ||||
|  | ||||
| public: | ||||
|     virtual void clearData() = 0; | ||||
|     virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0; | ||||
|  | ||||
|     virtual void resetView() = 0; | ||||
|  | ||||
| public: | ||||
|     static FluxVisualiserWidget* create(); | ||||
| }; | ||||
							
								
								
									
										237
									
								
								src/gui2/formatcomponent.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										237
									
								
								src/gui2/formatcomponent.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,237 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/config/proto.h" | ||||
| #include "globals.h" | ||||
| #include "formatcomponent.h" | ||||
| #include "mainwindow.h" | ||||
| #include <QStandardItemModel> | ||||
| #include <QTableView> | ||||
| #include <QHeaderView> | ||||
| #include <range/v3/all.hpp> | ||||
|  | ||||
| static const char* FORMAT = "format/format"; | ||||
| static const char* CUSTOM_FORMAT_FILENAME = "format/customFormatFilename"; | ||||
| static const char* USE_CUSTOM_FORMAT = "format/useCustomFormat"; | ||||
| static const char* FORMAT_OPTIONS_PREFIX = "format/options"; | ||||
|  | ||||
| class FormatComponentImpl : public FormatComponent, public QObject | ||||
| { | ||||
|     W_OBJECT(FormatComponentImpl) | ||||
|  | ||||
| private: | ||||
|     class OptionCheckBox : public QCheckBox | ||||
|     { | ||||
|     public: | ||||
|         OptionCheckBox(QString label, const OptionProto* option): | ||||
|             QCheckBox(label), | ||||
|             option(option) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|         const OptionProto* option; | ||||
|     }; | ||||
|  | ||||
| public: | ||||
|     FormatComponentImpl(MainWindow* mainWindow): _mainWindow(mainWindow) | ||||
|     { | ||||
|         setParent(mainWindow); | ||||
|  | ||||
|         /* Configure the formats drop-down list. */ | ||||
|  | ||||
|         std::string defaultFormat = | ||||
|             app->value(FORMAT, QVariant("ibm")).toString().toStdString(); | ||||
|  | ||||
|         _formatsModel.clear(); | ||||
|         _formatsModel.setColumnCount(2); | ||||
|         _formatsModel.setHorizontalHeaderLabels( | ||||
|             QStringList{"Name", "Description"}); | ||||
|         int selectedRow = 0; | ||||
|         for (const auto& it : formats) | ||||
|         { | ||||
|             if (it.second->is_extension()) | ||||
|                 continue; | ||||
|  | ||||
|             if (it.first == defaultFormat) | ||||
|                 selectedRow = _formatsModel.rowCount(); | ||||
|  | ||||
|             QStandardItem* nameItem = | ||||
|                 new QStandardItem(QString::fromStdString(it.first)); | ||||
|             nameItem->setData(QVariant(QString::fromStdString(it.first))); | ||||
|  | ||||
|             QList<QStandardItem*> row{nameItem, | ||||
|                 new QStandardItem( | ||||
|                     QString::fromStdString(it.second->shortname()))}; | ||||
|             _formatsModel.appendRow(row); | ||||
|         } | ||||
|         _mainWindow->formatSelectionComboBox->setModel(&_formatsModel); | ||||
|         _mainWindow->formatSelectionComboBox->setModelColumn(0); | ||||
|  | ||||
|         QTableView* view = new QTableView; | ||||
|         view->setSelectionBehavior(QAbstractItemView::SelectRows); | ||||
|         view->horizontalHeader()->setStretchLastSection(true); | ||||
|         view->verticalHeader()->hide(); | ||||
|         _mainWindow->formatSelectionComboBox->setView(view); | ||||
|  | ||||
|         /* Update from defaults */ | ||||
|  | ||||
|         _mainWindow->formatSelectionComboBox->setCurrentIndex(selectedRow); | ||||
|         changeSelectedFormat(selectedRow); | ||||
|  | ||||
|         if (app->value(USE_CUSTOM_FORMAT).toBool()) | ||||
|             _mainWindow->customFormatRadioButton->click(); | ||||
|         else | ||||
|             _mainWindow->builtInFormatRadioButton->click(); | ||||
|  | ||||
|         _mainWindow->customFormatFilenameEdit->setText( | ||||
|             app->value(CUSTOM_FORMAT_FILENAME).toString()); | ||||
|  | ||||
|         /* GUI hookup */ | ||||
|  | ||||
|         _mainWindow->connect(_mainWindow->formatButtonGroup, | ||||
|             &QButtonGroup::idClicked, | ||||
|             this, | ||||
|             &FormatComponentImpl::updateSavedState); | ||||
|         _mainWindow->connect(_mainWindow->customFormatFilenameEdit, | ||||
|             &QLineEdit::editingFinished, | ||||
|             this, | ||||
|             &FormatComponentImpl::updateSavedState); | ||||
|         _mainWindow->connect(_mainWindow->formatSelectionComboBox, | ||||
|             QOverload<int>::of(&QComboBox::activated), | ||||
|             this, | ||||
|             &FormatComponentImpl::changeSelectedFormat); | ||||
|         _mainWindow->connect(_mainWindow->formatSelectionComboBox, | ||||
|             QOverload<int>::of(&QComboBox::activated), | ||||
|             this, | ||||
|             &FormatComponentImpl::updateSavedState); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void collectConfig() override | ||||
|     { | ||||
|         std::string formatId = getCurrentFormatId(); | ||||
|         globalConfig().readBaseConfigFile(formatId); | ||||
|  | ||||
|         for (auto& option : collectOptions()) | ||||
|             globalConfig().applyOption(option.toStdString()); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void changeSelectedFormat(int index) | ||||
|     { | ||||
|         auto item = _formatsModel.item(index); | ||||
|         QString formatId = item->data().toString(); | ||||
|         const ConfigProto* config = formats.at(formatId.toStdString()); | ||||
|  | ||||
|         auto* layout = _mainWindow->formatOptionsContainerLayout; | ||||
|         while (auto item = layout->takeAt(0)) | ||||
|             delete item->widget(); | ||||
|  | ||||
|         QSet<QString> settings = | ||||
|             app->value(QString(FORMAT_OPTIONS_PREFIX) + "/" + formatId) | ||||
|                 .value<QStringList>() | | ||||
|             ranges::to<QSet>(); | ||||
|  | ||||
|         for (auto& group : config->option_group()) | ||||
|         { | ||||
|             std::string groupName = group.comment(); | ||||
|             if (groupName == "$formats") | ||||
|                 groupName = "Format variant"; | ||||
|             groupName += ":"; | ||||
|  | ||||
|             QComboBox* qb = new QComboBox(); | ||||
|             int selectedItem = 0; | ||||
|             for (auto& option : group.option()) | ||||
|             { | ||||
|                 QString name = QString::fromStdString(option.name()); | ||||
|                 if (settings.contains(name)) | ||||
|                     selectedItem = qb->count(); | ||||
|                 qb->addItem(QString::fromStdString(option.comment()), name); | ||||
|             } | ||||
|             qb->setCurrentIndex(selectedItem); | ||||
|  | ||||
|             layout->addWidget(new QLabel(QString::fromStdString(groupName))); | ||||
|             layout->addWidget(qb); | ||||
|  | ||||
|             _mainWindow->connect(qb, | ||||
|                 QOverload<int>::of(&QComboBox::activated), | ||||
|                 this, | ||||
|                 &FormatComponentImpl::updateSavedState); | ||||
|         } | ||||
|  | ||||
|         for (auto& option : config->option()) | ||||
|         { | ||||
|             QCheckBox* rb = new OptionCheckBox( | ||||
|                 QString::fromStdString(option.comment()), &option); | ||||
|             rb->setCheckState( | ||||
|                 settings.contains(QString::fromStdString(option.name())) | ||||
|                     ? Qt::Checked | ||||
|                     : Qt::Unchecked); | ||||
|             layout->addWidget(rb); | ||||
|  | ||||
|             _mainWindow->connect(rb, | ||||
|                 &QCheckBox::stateChanged, | ||||
|                 this, | ||||
|                 &FormatComponentImpl::updateSavedState); | ||||
|         } | ||||
|  | ||||
|         if (layout->count() == 0) | ||||
|             layout->addWidget(new QLabel("No options for this format!")); | ||||
|     } | ||||
|     W_SLOT(changeSelectedFormat) | ||||
|  | ||||
|     void updateSavedState() | ||||
|     { | ||||
|         app->setValue(USE_CUSTOM_FORMAT, | ||||
|             _mainWindow->customFormatRadioButton->isChecked()); | ||||
|         app->setValue(CUSTOM_FORMAT_FILENAME, | ||||
|             _mainWindow->customFormatFilenameEdit->text()); | ||||
|  | ||||
|         std::string formatId = getCurrentFormatId(); | ||||
|         const ConfigProto* config = formats.at(formatId); | ||||
|         app->setValue(FORMAT, QString::fromStdString(formatId)); | ||||
|  | ||||
|         auto* layout = _mainWindow->formatOptionsContainerLayout; | ||||
|         QStringList options = collectOptions() | ranges::to<QStringList>(); | ||||
|         app->setValue(QString(FORMAT_OPTIONS_PREFIX) + "/" + | ||||
|                           QString::fromStdString(formatId), | ||||
|             QVariant(options)); | ||||
|     } | ||||
|     W_SLOT(updateSavedState) | ||||
|  | ||||
| private: | ||||
|     QSet<QString> collectOptions() const | ||||
|     { | ||||
|         auto* layout = _mainWindow->formatOptionsContainerLayout; | ||||
|         QSet<QString> options; | ||||
|         for (int i = 0; i < layout->count(); i++) | ||||
|         { | ||||
|             QWidget* w = layout->itemAt(i)->widget(); | ||||
|             if (QComboBox* cb = dynamic_cast<QComboBox*>(w)) | ||||
|                 options.insert(cb->currentData().toString()); | ||||
|             else if (OptionCheckBox* cb = dynamic_cast<OptionCheckBox*>(w)) | ||||
|             { | ||||
|                 if (cb->isChecked()) | ||||
|                     options.insert(QString::fromStdString(cb->option->name())); | ||||
|             } | ||||
|         } | ||||
|         return options; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::string getCurrentFormatId() const | ||||
|     { | ||||
|         int index = _mainWindow->formatSelectionComboBox->currentIndex(); | ||||
|         auto item = _formatsModel.item(index); | ||||
|         return item->data().toString().toStdString(); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     MainWindow* _mainWindow; | ||||
|     QStandardItemModel _formatsModel; | ||||
| }; | ||||
| W_OBJECT_IMPL(FormatComponentImpl) | ||||
|  | ||||
| FormatComponent* FormatComponent::create(MainWindow* mainWindow) | ||||
| { | ||||
|     return new FormatComponentImpl(mainWindow); | ||||
| } | ||||
							
								
								
									
										12
									
								
								src/gui2/formatcomponent.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/gui2/formatcomponent.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| #pragma once | ||||
|  | ||||
| class MainWindow; | ||||
|  | ||||
| class FormatComponent | ||||
| { | ||||
| public: | ||||
|     static FormatComponent* create(MainWindow* mainWindow); | ||||
|  | ||||
| public: | ||||
|     virtual void collectConfig() = 0; | ||||
| }; | ||||
							
								
								
									
										806
									
								
								src/gui2/frame.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										806
									
								
								src/gui2/frame.ui
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,806 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>MainWindow</class> | ||||
|  <widget class="QMainWindow" name="MainWindow"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>1644</width> | ||||
|     <height>893</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="windowTitle"> | ||||
|    <string>MainWindow</string> | ||||
|   </property> | ||||
|   <property name="windowIcon"> | ||||
|    <iconset resource="resources.qrc"> | ||||
|     <normaloff>:/ui/extras/icon.png</normaloff>:/ui/extras/icon.png</iconset> | ||||
|   </property> | ||||
|   <property name="styleSheet"> | ||||
|    <string notr="true">QTabWidget::pane { | ||||
| //	border: 1px black; | ||||
| //	border-style: solid; | ||||
| } | ||||
| </string> | ||||
|   </property> | ||||
|   <widget class="QWidget" name="centralwidget"> | ||||
|    <property name="enabled"> | ||||
|     <bool>true</bool> | ||||
|    </property> | ||||
|    <property name="sizePolicy"> | ||||
|     <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||||
|      <horstretch>0</horstretch> | ||||
|      <verstretch>0</verstretch> | ||||
|     </sizepolicy> | ||||
|    </property> | ||||
|    <property name="styleSheet"> | ||||
|     <string notr="true"/> | ||||
|    </property> | ||||
|    <layout class="QVBoxLayout" name="verticalLayout_6"> | ||||
|     <item> | ||||
|      <widget class="QSplitter" name="splitter_3"> | ||||
|       <property name="orientation"> | ||||
|        <enum>Qt::Orientation::Horizontal</enum> | ||||
|       </property> | ||||
|       <property name="handleWidth"> | ||||
|        <number>5</number> | ||||
|       </property> | ||||
|       <widget class="QSplitter" name="splitter"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Orientation::Vertical</enum> | ||||
|        </property> | ||||
|        <property name="handleWidth"> | ||||
|         <number>5</number> | ||||
|        </property> | ||||
|        <widget class="QGroupBox" name="driveConfigurationBox"> | ||||
|         <property name="sizePolicy"> | ||||
|          <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> | ||||
|           <horstretch>0</horstretch> | ||||
|           <verstretch>0</verstretch> | ||||
|          </sizepolicy> | ||||
|         </property> | ||||
|         <property name="title"> | ||||
|          <string>Drive configuration</string> | ||||
|         </property> | ||||
|         <layout class="QVBoxLayout" name="verticalLayout_9"> | ||||
|          <property name="leftMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="topMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="rightMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="bottomMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <item> | ||||
|           <widget class="QScrollArea" name="scrollArea_2"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="frameShape"> | ||||
|             <enum>QFrame::Shape::NoFrame</enum> | ||||
|            </property> | ||||
|            <property name="horizontalScrollBarPolicy"> | ||||
|             <enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum> | ||||
|            </property> | ||||
|            <property name="sizeAdjustPolicy"> | ||||
|             <enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum> | ||||
|            </property> | ||||
|            <property name="widgetResizable"> | ||||
|             <bool>true</bool> | ||||
|            </property> | ||||
|            <widget class="QWidget" name="scrollAreaWidgetContents_2"> | ||||
|             <property name="geometry"> | ||||
|              <rect> | ||||
|               <x>0</x> | ||||
|               <y>0</y> | ||||
|               <width>873</width> | ||||
|               <height>462</height> | ||||
|              </rect> | ||||
|             </property> | ||||
|             <property name="sizePolicy"> | ||||
|              <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> | ||||
|               <horstretch>0</horstretch> | ||||
|               <verstretch>0</verstretch> | ||||
|              </sizepolicy> | ||||
|             </property> | ||||
|             <layout class="QVBoxLayout" name="verticalLayout_4"> | ||||
|              <item> | ||||
|               <widget class="QLabel" name="label_16"> | ||||
|                <property name="text"> | ||||
|                 <string>Device:</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QComboBox" name="deviceSelectionComboBox"> | ||||
|                <property name="editable"> | ||||
|                 <bool>false</bool> | ||||
|                </property> | ||||
|                <property name="iconSize"> | ||||
|                 <size> | ||||
|                  <width>48</width> | ||||
|                  <height>48</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QStackedWidget" name="driveStackedWidget"> | ||||
|                <property name="sizePolicy"> | ||||
|                 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> | ||||
|                  <horstretch>0</horstretch> | ||||
|                  <verstretch>0</verstretch> | ||||
|                 </sizepolicy> | ||||
|                </property> | ||||
|                <property name="lineWidth"> | ||||
|                 <number>0</number> | ||||
|                </property> | ||||
|                <property name="currentIndex"> | ||||
|                 <number>1</number> | ||||
|                </property> | ||||
|                <widget class="QWidget" name="hardwareDevicePage"> | ||||
|                 <property name="sizePolicy"> | ||||
|                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> | ||||
|                   <horstretch>0</horstretch> | ||||
|                   <verstretch>0</verstretch> | ||||
|                  </sizepolicy> | ||||
|                 </property> | ||||
|                 <layout class="QFormLayout" name="formLayout"> | ||||
|                  <property name="leftMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="topMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="rightMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="bottomMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <item row="0" column="1"> | ||||
|                   <widget class="QLineEdit" name="portLineEdit"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="3" column="0"> | ||||
|                   <widget class="QLabel" name="label_61"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Drive:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="3" column="1"> | ||||
|                   <widget class="QComboBox" name="driveComboBox"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <item> | ||||
|                     <property name="text"> | ||||
|                      <string>0</string> | ||||
|                     </property> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <property name="text"> | ||||
|                      <string>1</string> | ||||
|                     </property> | ||||
|                    </item> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="4" column="0"> | ||||
|                   <widget class="QLabel" name="label_71"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Drive type:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="4" column="1"> | ||||
|                   <widget class="QComboBox" name="driveTypeComboBox"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="7" column="0"> | ||||
|                   <widget class="QLabel" name="label_15"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Sample time:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="7" column="1"> | ||||
|                   <widget class="QRadioButton" name="defaultSampleTimeCheckbox"> | ||||
|                    <property name="enabled"> | ||||
|                     <bool>false</bool> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Default for format</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="6" column="1"> | ||||
|                   <widget class="QCheckBox" name="highDensityToggle"> | ||||
|                    <property name="text"> | ||||
|                     <string>High density disk inserted</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="0" column="0"> | ||||
|                   <widget class="QLabel" name="label_4"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Port:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="9" column="1"> | ||||
|                   <spacer name="verticalSpacer_2"> | ||||
|                    <property name="orientation"> | ||||
|                     <enum>Qt::Orientation::Vertical</enum> | ||||
|                    </property> | ||||
|                    <property name="sizeHint" stdset="0"> | ||||
|                     <size> | ||||
|                      <width>20</width> | ||||
|                      <height>40</height> | ||||
|                     </size> | ||||
|                    </property> | ||||
|                   </spacer> | ||||
|                  </item> | ||||
|                  <item row="8" column="1"> | ||||
|                   <layout class="QHBoxLayout" name="horizontalLayout_7"> | ||||
|                    <item> | ||||
|                     <widget class="QRadioButton" name="customSampleTimeCheckBox"> | ||||
|                      <property name="enabled"> | ||||
|                       <bool>false</bool> | ||||
|                      </property> | ||||
|                      <property name="text"> | ||||
|                       <string>Custom:</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QSpinBox" name="customSampleTimeSpinbox"> | ||||
|                      <property name="sizePolicy"> | ||||
|                       <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                        <horstretch>0</horstretch> | ||||
|                        <verstretch>0</verstretch> | ||||
|                       </sizepolicy> | ||||
|                      </property> | ||||
|                      <property name="accelerated"> | ||||
|                       <bool>true</bool> | ||||
|                      </property> | ||||
|                      <property name="suffix"> | ||||
|                       <string>ms</string> | ||||
|                      </property> | ||||
|                      <property name="minimum"> | ||||
|                       <number>50</number> | ||||
|                      </property> | ||||
|                      <property name="maximum"> | ||||
|                       <number>1000</number> | ||||
|                      </property> | ||||
|                      <property name="singleStep"> | ||||
|                       <number>50</number> | ||||
|                      </property> | ||||
|                      <property name="value"> | ||||
|                       <number>300</number> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                   </layout> | ||||
|                  </item> | ||||
|                 </layout> | ||||
|                </widget> | ||||
|                <widget class="QWidget" name="fluxDevicePage"> | ||||
|                 <property name="sizePolicy"> | ||||
|                  <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> | ||||
|                   <horstretch>0</horstretch> | ||||
|                   <verstretch>0</verstretch> | ||||
|                  </sizepolicy> | ||||
|                 </property> | ||||
|                 <layout class="QFormLayout" name="formLayout1"> | ||||
|                  <property name="leftMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="topMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="rightMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <property name="bottomMargin"> | ||||
|                   <number>0</number> | ||||
|                  </property> | ||||
|                  <item row="0" column="0"> | ||||
|                   <widget class="QLabel" name="label_6"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Filename:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="0" column="1"> | ||||
|                   <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||||
|                    <item> | ||||
|                     <widget class="QLineEdit" name="filenameEdit"> | ||||
|                      <property name="sizePolicy"> | ||||
|                       <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                        <horstretch>0</horstretch> | ||||
|                        <verstretch>0</verstretch> | ||||
|                       </sizepolicy> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QToolButton" name="openButton"> | ||||
|                      <property name="text"> | ||||
|                       <string>Open</string> | ||||
|                      </property> | ||||
|                      <property name="icon"> | ||||
|                       <iconset theme="document-open"/> | ||||
|                      </property> | ||||
|                      <property name="toolButtonStyle"> | ||||
|                       <enum>Qt::ToolButtonStyle::ToolButtonFollowStyle</enum> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                   </layout> | ||||
|                  </item> | ||||
|                  <item row="1" column="0"> | ||||
|                   <widget class="QLabel" name="label_7"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>RPM:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="1" column="1"> | ||||
|                   <widget class="QComboBox" name="rpmOverrideComboBox"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="editable"> | ||||
|                     <bool>false</bool> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="3" column="0"> | ||||
|                   <widget class="QLabel" name="label"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                    <property name="text"> | ||||
|                     <string>Drive type:</string> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="3" column="1"> | ||||
|                   <widget class="QComboBox" name="driveTypeOverrideComboBox"> | ||||
|                    <property name="sizePolicy"> | ||||
|                     <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                      <horstretch>0</horstretch> | ||||
|                      <verstretch>0</verstretch> | ||||
|                     </sizepolicy> | ||||
|                    </property> | ||||
|                   </widget> | ||||
|                  </item> | ||||
|                  <item row="2" column="1"> | ||||
|                   <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
|                    <item> | ||||
|                     <widget class="QLabel" name="label_2"> | ||||
|                      <property name="text"> | ||||
|                       <string>Custom:</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                    <item> | ||||
|                     <widget class="QSpinBox" name="rpmOverrideValue"> | ||||
|                      <property name="sizePolicy"> | ||||
|                       <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                        <horstretch>0</horstretch> | ||||
|                        <verstretch>0</verstretch> | ||||
|                       </sizepolicy> | ||||
|                      </property> | ||||
|                      <property name="suffix"> | ||||
|                       <string> rpm</string> | ||||
|                      </property> | ||||
|                     </widget> | ||||
|                    </item> | ||||
|                   </layout> | ||||
|                  </item> | ||||
|                  <item row="4" column="1"> | ||||
|                   <spacer name="verticalSpacer"> | ||||
|                    <property name="orientation"> | ||||
|                     <enum>Qt::Orientation::Vertical</enum> | ||||
|                    </property> | ||||
|                    <property name="sizeHint" stdset="0"> | ||||
|                     <size> | ||||
|                      <width>20</width> | ||||
|                      <height>40</height> | ||||
|                     </size> | ||||
|                    </property> | ||||
|                   </spacer> | ||||
|                  </item> | ||||
|                 </layout> | ||||
|                </widget> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </widget> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </widget> | ||||
|        <widget class="QGroupBox" name="formatConfigurationBox"> | ||||
|         <property name="sizePolicy"> | ||||
|          <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> | ||||
|           <horstretch>0</horstretch> | ||||
|           <verstretch>0</verstretch> | ||||
|          </sizepolicy> | ||||
|         </property> | ||||
|         <property name="title"> | ||||
|          <string>Format configuration</string> | ||||
|         </property> | ||||
|         <layout class="QVBoxLayout" name="verticalLayout_15"> | ||||
|          <property name="leftMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="topMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="rightMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <property name="bottomMargin"> | ||||
|           <number>0</number> | ||||
|          </property> | ||||
|          <item> | ||||
|           <widget class="QScrollArea" name="scrollArea"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="frameShape"> | ||||
|             <enum>QFrame::Shape::NoFrame</enum> | ||||
|            </property> | ||||
|            <property name="frameShadow"> | ||||
|             <enum>QFrame::Shadow::Plain</enum> | ||||
|            </property> | ||||
|            <property name="lineWidth"> | ||||
|             <number>0</number> | ||||
|            </property> | ||||
|            <property name="horizontalScrollBarPolicy"> | ||||
|             <enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum> | ||||
|            </property> | ||||
|            <property name="sizeAdjustPolicy"> | ||||
|             <enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum> | ||||
|            </property> | ||||
|            <property name="widgetResizable"> | ||||
|             <bool>true</bool> | ||||
|            </property> | ||||
|            <widget class="QWidget" name="scrollAreaWidgetContents"> | ||||
|             <property name="geometry"> | ||||
|              <rect> | ||||
|               <x>0</x> | ||||
|               <y>0</y> | ||||
|               <width>873</width> | ||||
|               <height>321</height> | ||||
|              </rect> | ||||
|             </property> | ||||
|             <property name="sizePolicy"> | ||||
|              <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||||
|               <horstretch>0</horstretch> | ||||
|               <verstretch>0</verstretch> | ||||
|              </sizepolicy> | ||||
|             </property> | ||||
|             <layout class="QVBoxLayout" name="verticalLayout_5"> | ||||
|              <property name="leftMargin"> | ||||
|               <number>9</number> | ||||
|              </property> | ||||
|              <property name="topMargin"> | ||||
|               <number>9</number> | ||||
|              </property> | ||||
|              <item> | ||||
|               <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,100,0"> | ||||
|                <item row="0" column="2" colspan="2"> | ||||
|                 <widget class="QComboBox" name="formatSelectionComboBox"> | ||||
|                  <property name="sizePolicy"> | ||||
|                   <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                    <horstretch>0</horstretch> | ||||
|                    <verstretch>0</verstretch> | ||||
|                   </sizepolicy> | ||||
|                  </property> | ||||
|                 </widget> | ||||
|                </item> | ||||
|                <item row="0" column="1"> | ||||
|                 <widget class="QRadioButton" name="builtInFormatRadioButton"> | ||||
|                  <property name="text"> | ||||
|                   <string>Built-in</string> | ||||
|                  </property> | ||||
|                  <attribute name="buttonGroup"> | ||||
|                   <string notr="true">formatButtonGroup</string> | ||||
|                  </attribute> | ||||
|                 </widget> | ||||
|                </item> | ||||
|                <item row="1" column="1"> | ||||
|                 <widget class="QRadioButton" name="customFormatRadioButton"> | ||||
|                  <property name="enabled"> | ||||
|                   <bool>false</bool> | ||||
|                  </property> | ||||
|                  <property name="text"> | ||||
|                   <string>From file</string> | ||||
|                  </property> | ||||
|                  <attribute name="buttonGroup"> | ||||
|                   <string notr="true">formatButtonGroup</string> | ||||
|                  </attribute> | ||||
|                 </widget> | ||||
|                </item> | ||||
|                <item row="0" column="0"> | ||||
|                 <widget class="QLabel" name="label_3"> | ||||
|                  <property name="text"> | ||||
|                   <string>Format:</string> | ||||
|                  </property> | ||||
|                  <property name="alignment"> | ||||
|                   <set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set> | ||||
|                  </property> | ||||
|                 </widget> | ||||
|                </item> | ||||
|                <item row="1" column="2"> | ||||
|                 <widget class="QLineEdit" name="customFormatFilenameEdit"> | ||||
|                  <property name="sizePolicy"> | ||||
|                   <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||||
|                    <horstretch>0</horstretch> | ||||
|                    <verstretch>0</verstretch> | ||||
|                   </sizepolicy> | ||||
|                  </property> | ||||
|                 </widget> | ||||
|                </item> | ||||
|                <item row="1" column="3"> | ||||
|                 <widget class="QToolButton" name="customFormatOpenButton"> | ||||
|                  <property name="text"> | ||||
|                   <string>Open</string> | ||||
|                  </property> | ||||
|                  <property name="icon"> | ||||
|                   <iconset theme="document-open"/> | ||||
|                  </property> | ||||
|                  <property name="toolButtonStyle"> | ||||
|                   <enum>Qt::ToolButtonStyle::ToolButtonFollowStyle</enum> | ||||
|                  </property> | ||||
|                  <property name="arrowType"> | ||||
|                   <enum>Qt::ArrowType::NoArrow</enum> | ||||
|                  </property> | ||||
|                 </widget> | ||||
|                </item> | ||||
|               </layout> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QGroupBox" name="groupBox_3"> | ||||
|                <property name="title"> | ||||
|                 <string>Per-format options</string> | ||||
|                </property> | ||||
|                <layout class="QVBoxLayout" name="verticalLayout_10"> | ||||
|                 <item> | ||||
|                  <layout class="QVBoxLayout" name="formatOptionsContainerLayout"/> | ||||
|                 </item> | ||||
|                </layout> | ||||
|               </widget> | ||||
|              </item> | ||||
|              <item> | ||||
|               <spacer name="verticalSpacer_3"> | ||||
|                <property name="orientation"> | ||||
|                 <enum>Qt::Orientation::Vertical</enum> | ||||
|                </property> | ||||
|                <property name="sizeHint" stdset="0"> | ||||
|                 <size> | ||||
|                  <width>20</width> | ||||
|                  <height>40</height> | ||||
|                 </size> | ||||
|                </property> | ||||
|               </spacer> | ||||
|              </item> | ||||
|              <item> | ||||
|               <widget class="QPushButton" name="pushButton_5"> | ||||
|                <property name="enabled"> | ||||
|                 <bool>false</bool> | ||||
|                </property> | ||||
|                <property name="sizePolicy"> | ||||
|                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | ||||
|                  <horstretch>0</horstretch> | ||||
|                  <verstretch>0</verstretch> | ||||
|                 </sizepolicy> | ||||
|                </property> | ||||
|                <property name="text"> | ||||
|                 <string>Configuration editor</string> | ||||
|                </property> | ||||
|               </widget> | ||||
|              </item> | ||||
|             </layout> | ||||
|            </widget> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </widget> | ||||
|       </widget> | ||||
|       <widget class="QSplitter" name="splitter_2"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Orientation::Vertical</enum> | ||||
|        </property> | ||||
|        <property name="handleWidth"> | ||||
|         <number>5</number> | ||||
|        </property> | ||||
|        <widget class="QFrame" name="container"> | ||||
|         <property name="sizePolicy"> | ||||
|          <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||
|           <horstretch>0</horstretch> | ||||
|           <verstretch>0</verstretch> | ||||
|          </sizepolicy> | ||||
|         </property> | ||||
|         <property name="frameShape"> | ||||
|          <enum>QFrame::Shape::StyledPanel</enum> | ||||
|         </property> | ||||
|         <property name="frameShadow"> | ||||
|          <enum>QFrame::Shadow::Raised</enum> | ||||
|         </property> | ||||
|        </widget> | ||||
|        <widget class="QPlainTextEdit" name="logViewerEdit"> | ||||
|         <property name="sizePolicy"> | ||||
|          <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | ||||
|           <horstretch>0</horstretch> | ||||
|           <verstretch>0</verstretch> | ||||
|          </sizepolicy> | ||||
|         </property> | ||||
|         <property name="styleSheet"> | ||||
|          <string notr="true">font-family: monospace;</string> | ||||
|         </property> | ||||
|         <property name="horizontalScrollBarPolicy"> | ||||
|          <enum>Qt::ScrollBarPolicy::ScrollBarAsNeeded</enum> | ||||
|         </property> | ||||
|         <property name="documentTitle"> | ||||
|          <string/> | ||||
|         </property> | ||||
|         <property name="lineWrapMode"> | ||||
|          <enum>QPlainTextEdit::LineWrapMode::NoWrap</enum> | ||||
|         </property> | ||||
|         <property name="readOnly"> | ||||
|          <bool>true</bool> | ||||
|         </property> | ||||
|         <property name="plainText"> | ||||
|          <string/> | ||||
|         </property> | ||||
|         <property name="backgroundVisible"> | ||||
|          <bool>false</bool> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </widget> | ||||
|      </widget> | ||||
|     </item> | ||||
|    </layout> | ||||
|   </widget> | ||||
|   <widget class="QMenuBar" name="menubar"> | ||||
|    <property name="geometry"> | ||||
|     <rect> | ||||
|      <x>0</x> | ||||
|      <y>0</y> | ||||
|      <width>1644</width> | ||||
|      <height>25</height> | ||||
|     </rect> | ||||
|    </property> | ||||
|    <widget class="QMenu" name="menuFile"> | ||||
|     <property name="title"> | ||||
|      <string>File</string> | ||||
|     </property> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionE_xit"/> | ||||
|    </widget> | ||||
|    <widget class="QMenu" name="menuEdit"> | ||||
|     <property name="title"> | ||||
|      <string>Edit</string> | ||||
|     </property> | ||||
|     <addaction name="actionCu_t"/> | ||||
|     <addaction name="actionCopy"/> | ||||
|     <addaction name="actionPaste"/> | ||||
|    </widget> | ||||
|    <addaction name="menuFile"/> | ||||
|    <addaction name="menuEdit"/> | ||||
|   </widget> | ||||
|   <widget class="QStatusBar" name="statusbar"/> | ||||
|   <action name="actionE_xit"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="application-exit"/> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>E&xit</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCu_t"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="edit-cut"/> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>Cu&t</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionCopy"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="edit-copy"/> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Copy</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionPaste"> | ||||
|    <property name="icon"> | ||||
|     <iconset theme="edit-paste"/> | ||||
|    </property> | ||||
|    <property name="text"> | ||||
|     <string>&Paste</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|  <resources> | ||||
|   <include location="resources.qrc"/> | ||||
|  </resources> | ||||
|  <connections/> | ||||
|  <buttongroups> | ||||
|   <buttongroup name="formatButtonGroup"/> | ||||
|  </buttongroups> | ||||
| </ui> | ||||
							
								
								
									
										65
									
								
								src/gui2/globals.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								src/gui2/globals.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/core/logger.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "frame.h" | ||||
| #include "wobjectdefs.h" | ||||
| #include "wobjectimpl.h" | ||||
| #include <QtWidgets> | ||||
| #include <QThreadPool> | ||||
| #include <QtConcurrent> | ||||
|  | ||||
| class TrackFlux; | ||||
| class DiskFlux; | ||||
| class Image; | ||||
|  | ||||
| Q_DECLARE_METATYPE(const ConfigProto*) | ||||
| W_REGISTER_ARGTYPE(std::shared_ptr<const TrackFlux>) | ||||
| W_REGISTER_ARGTYPE(std::shared_ptr<const DiskFlux>) | ||||
| W_REGISTER_ARGTYPE(std::shared_ptr<const Image>) | ||||
|  | ||||
| extern QThreadPool workerThreadPool; | ||||
|  | ||||
| class UserInterface : public Ui_MainWindow | ||||
| { | ||||
| }; | ||||
|  | ||||
| class Application : public QApplication, public QSettings | ||||
| { | ||||
| public: | ||||
|     Application(int& argc, char** argv); | ||||
|     virtual ~Application(); | ||||
| }; | ||||
|  | ||||
| extern bool isGuiThread(); | ||||
| extern bool isWorkerThreadRunning(); | ||||
| extern void postToUiThread(std::function<void()> callback); | ||||
| extern void runOnUiThread(std::function<void()> callback); | ||||
| extern QFuture<void> safeRunOnWorkerThread(std::function<void()> callback); | ||||
|  | ||||
| extern const std::map<std::string, const ConfigProto*> drivetypes; | ||||
|  | ||||
| template <typename F> | ||||
| static inline auto runOnWorkerThread(F callback) | ||||
| { | ||||
|     return QtConcurrent::run(&workerThreadPool, | ||||
|         [=]() | ||||
|         { | ||||
|             return callback(); | ||||
|         }); | ||||
| } | ||||
|  | ||||
| template <typename R> | ||||
| static inline R runOnUiThread(std::function<R()> callback) | ||||
| { | ||||
|     R retvar; | ||||
|     runOnUiThread( | ||||
|         [&]() | ||||
|         { | ||||
|             retvar = callback(); | ||||
|         }); | ||||
|     return retvar; | ||||
| } | ||||
|  | ||||
| extern Application* app; | ||||
							
								
								
									
										188
									
								
								src/gui2/imager.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								src/gui2/imager.ui
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,188 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <ui version="4.0"> | ||||
|  <class>Imager</class> | ||||
|  <widget class="QWidget" name="Imager"> | ||||
|   <property name="geometry"> | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>494</width> | ||||
|     <height>250</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="sizePolicy"> | ||||
|    <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||
|     <horstretch>0</horstretch> | ||||
|     <verstretch>0</verstretch> | ||||
|    </sizepolicy> | ||||
|   </property> | ||||
|   <layout class="QVBoxLayout" name="verticalLayout"> | ||||
|    <item> | ||||
|     <widget class="QTabWidget" name="tabWidget"> | ||||
|      <property name="tabShape"> | ||||
|       <enum>QTabWidget::TabShape::Triangular</enum> | ||||
|      </property> | ||||
|      <property name="currentIndex"> | ||||
|       <number>0</number> | ||||
|      </property> | ||||
|      <property name="movable"> | ||||
|       <bool>false</bool> | ||||
|      </property> | ||||
|      <widget class="QWidget" name="tab"> | ||||
|       <property name="sizePolicy"> | ||||
|        <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||
|         <horstretch>0</horstretch> | ||||
|         <verstretch>0</verstretch> | ||||
|        </sizepolicy> | ||||
|       </property> | ||||
|       <attribute name="title"> | ||||
|        <string>Flux view</string> | ||||
|       </attribute> | ||||
|       <layout class="QVBoxLayout" name="verticalLayout_3"> | ||||
|        <item> | ||||
|         <widget class="QFrame" name="frame"> | ||||
|          <property name="frameShape"> | ||||
|           <enum>QFrame::Shape::WinPanel</enum> | ||||
|          </property> | ||||
|          <property name="frameShadow"> | ||||
|           <enum>QFrame::Shadow::Sunken</enum> | ||||
|          </property> | ||||
|          <layout class="QVBoxLayout" name="verticalLayout_2"> | ||||
|           <property name="leftMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="topMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="rightMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <property name="bottomMargin"> | ||||
|            <number>0</number> | ||||
|           </property> | ||||
|           <item> | ||||
|            <widget class="QFrame" name="fluxViewContainer"> | ||||
|             <property name="sizePolicy"> | ||||
|              <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> | ||||
|               <horstretch>0</horstretch> | ||||
|               <verstretch>0</verstretch> | ||||
|              </sizepolicy> | ||||
|             </property> | ||||
|             <property name="styleSheet"> | ||||
|              <string notr="true">QFrame { | ||||
| background: white; | ||||
| } | ||||
| </string> | ||||
|             </property> | ||||
|             <property name="frameShape"> | ||||
|              <enum>QFrame::Shape::StyledPanel</enum> | ||||
|             </property> | ||||
|             <property name="frameShadow"> | ||||
|              <enum>QFrame::Shadow::Sunken</enum> | ||||
|             </property> | ||||
|             <layout class="QVBoxLayout" name="verticalLayout_12"> | ||||
|              <property name="leftMargin"> | ||||
|               <number>0</number> | ||||
|              </property> | ||||
|              <property name="topMargin"> | ||||
|               <number>0</number> | ||||
|              </property> | ||||
|              <property name="rightMargin"> | ||||
|               <number>0</number> | ||||
|              </property> | ||||
|              <property name="bottomMargin"> | ||||
|               <number>0</number> | ||||
|              </property> | ||||
|             </layout> | ||||
|            </widget> | ||||
|           </item> | ||||
|          </layout> | ||||
|         </widget> | ||||
|        </item> | ||||
|       </layout> | ||||
|      </widget> | ||||
|      <widget class="QWidget" name="tab_2"> | ||||
|       <attribute name="title"> | ||||
|        <string>Image view</string> | ||||
|       </attribute> | ||||
|       <layout class="QVBoxLayout" name="verticalLayout_13"> | ||||
|        <item> | ||||
|         <widget class="QFrame" name="imageViewContainer"> | ||||
|          <property name="frameShape"> | ||||
|           <enum>QFrame::Shape::StyledPanel</enum> | ||||
|          </property> | ||||
|          <property name="frameShadow"> | ||||
|           <enum>QFrame::Shadow::Raised</enum> | ||||
|          </property> | ||||
|          <layout class="QVBoxLayout" name="verticalLayout_14"/> | ||||
|         </widget> | ||||
|        </item> | ||||
|       </layout> | ||||
|      </widget> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QFrame" name="commandButtonFrame"> | ||||
|      <layout class="QGridLayout" name="gridLayout"> | ||||
|       <property name="leftMargin"> | ||||
|        <number>0</number> | ||||
|       </property> | ||||
|       <property name="topMargin"> | ||||
|        <number>0</number> | ||||
|       </property> | ||||
|       <property name="rightMargin"> | ||||
|        <number>0</number> | ||||
|       </property> | ||||
|       <property name="bottomMargin"> | ||||
|        <number>0</number> | ||||
|       </property> | ||||
|       <item row="0" column="1"> | ||||
|        <widget class="QPushButton" name="loadImageButton"> | ||||
|         <property name="text"> | ||||
|          <string>Load image</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="document-open"/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item row="0" column="0"> | ||||
|        <widget class="QPushButton" name="readDiskButton"> | ||||
|         <property name="text"> | ||||
|          <string>Read from disk</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="media-playback-start"/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item row="0" column="4"> | ||||
|        <widget class="QPushButton" name="writeDiskButton"> | ||||
|         <property name="text"> | ||||
|          <string>Write to disk</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="media-record"/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item row="0" column="3"> | ||||
|        <widget class="QPushButton" name="saveImageButton"> | ||||
|         <property name="text"> | ||||
|          <string>Save image</string> | ||||
|         </property> | ||||
|         <property name="icon"> | ||||
|          <iconset theme="document-save"/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </widget> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <resources> | ||||
|   <include location="resources.qrc"/> | ||||
|  </resources> | ||||
|  <connections/> | ||||
| </ui> | ||||
							
								
								
									
										226
									
								
								src/gui2/imagevisualiserwidget.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								src/gui2/imagevisualiserwidget.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,226 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/data/flux.h" | ||||
| #include "lib/data/layout.h" | ||||
| #include "lib/data/image.h" | ||||
| #include "lib/data/sector.h" | ||||
| #include "lib/data/fluxmapreader.h" | ||||
| #include "globals.h" | ||||
| #include "imagevisualiserwidget.h" | ||||
| #include "scene.h" | ||||
| #include <QWheelEvent> | ||||
| #include <QFrame> | ||||
| #include <QConicalGradient> | ||||
| #include <range/v3/all.hpp> | ||||
|  | ||||
| W_OBJECT_IMPL(ImageVisualiserWidget) | ||||
|  | ||||
| class DiskFlux; | ||||
| class TrackFlux; | ||||
|  | ||||
| static constexpr int WIDTH = 300; | ||||
| static constexpr int HEIGHT = 500; | ||||
|  | ||||
| class ImageVisualiserWidgetImpl : public ImageVisualiserWidget | ||||
| { | ||||
| private: | ||||
|     class SectorGraphicsItem : public QGraphicsRectItem | ||||
|     { | ||||
|     public: | ||||
|         SectorGraphicsItem(std::shared_ptr<const Sector> sector, | ||||
|             qreal x, | ||||
|             qreal y, | ||||
|             qreal width, | ||||
|             qreal height, | ||||
|             const QBrush& brush): | ||||
|             QGraphicsRectItem(x, y, width, height), | ||||
|             _sector(sector) | ||||
|         { | ||||
|             setPen(QPen(Qt::NoPen)); | ||||
|             setBrush(brush); | ||||
|             setAcceptHoverEvents(true); | ||||
|         } | ||||
|  | ||||
|     protected: | ||||
|         void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override | ||||
|         { | ||||
|             if (scene() && !scene()->views().isEmpty() && | ||||
|                 scene()->views().first() && | ||||
|                 scene()->views().first()->viewport()) | ||||
|             { | ||||
|                 QGraphicsView* view = scene()->views().first(); | ||||
|                 QPointF scenePos = mapToScene(boundingRect().bottomRight()); | ||||
|                 QPoint viewportPos = view->mapFromScene(scenePos); | ||||
|                 QPoint tooltipPos = view->viewport()->mapToGlobal(viewportPos); | ||||
|  | ||||
|                 QToolTip::showText(tooltipPos, | ||||
|                     QString::fromStdString( | ||||
|                         fmt::format("Track: {} Head: {} Sector: {}\nStatus: {}", | ||||
|                             _sector->logicalTrack, | ||||
|                             _sector->logicalSide, | ||||
|                             _sector->logicalSector, | ||||
|                             Sector::statusToString(_sector->status)))); | ||||
|             } | ||||
|  | ||||
|             setPen(QPen(QColorConstants::Magenta)); | ||||
|         } | ||||
|  | ||||
|         void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override | ||||
|         { | ||||
|             QToolTip::hideText(); | ||||
|             setPen(QPen(Qt::NoPen)); | ||||
|         } | ||||
|  | ||||
|     private: | ||||
|         std::shared_ptr<const Sector> _sector; | ||||
|     }; | ||||
|  | ||||
| public: | ||||
|     ImageVisualiserWidgetImpl(): _scene(new Scene()) | ||||
|     { | ||||
|         setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||||
|         setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||||
|         setFrameShape(QFrame::NoFrame); | ||||
|         setScene(_scene); | ||||
|  | ||||
|         redraw(); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void resizeEvent(QResizeEvent* event) override | ||||
|     { | ||||
|         fitInView(sceneRect(), Qt::KeepAspectRatio); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void setTrackData(std::shared_ptr<const TrackFlux> track) | ||||
|     { | ||||
|         key_t key = { | ||||
|             track->trackInfo->logicalTrack, track->trackInfo->logicalSide}; | ||||
|  | ||||
|         _sectors.erase(key); | ||||
|         for (auto& sector : track->sectors) | ||||
|             _sectors.insert({key, sector}); | ||||
|         _trackInfos.insert({key, track->trackInfo}); | ||||
|         _numTracks = track->trackInfo->numLogicalTracks; | ||||
|  | ||||
|         redraw(); | ||||
|     } | ||||
|  | ||||
|     void setDiskData(std::shared_ptr<const DiskFlux> disk) {} | ||||
|  | ||||
| private: | ||||
|     void redraw() | ||||
|     { | ||||
|         _scene->clear(); | ||||
|  | ||||
|         if (_numTracks != 0) | ||||
|         { | ||||
|             QPen black(QColorConstants::Black, 0); | ||||
|             _scene->addLine(WIDTH / 2, 0, WIDTH / 2, HEIGHT, black); | ||||
|  | ||||
|             float step = (float)HEIGHT / (float)(_numTracks + 1); | ||||
|             float border = step * 0.2; | ||||
|             float size = step * 0.8; | ||||
|             float top = step; | ||||
|  | ||||
|             size_t maxSectors = 0; | ||||
|             for (int track = 0; track < _numTracks; track++) | ||||
|             { | ||||
|                 auto drawSectors = [&](int side) | ||||
|                 { | ||||
|                     key_t key = {track, side}; | ||||
|                     std::vector<std::shared_ptr<const Sector>> sectors; | ||||
|                     for (auto it = _sectors.lower_bound(key); | ||||
|                         it != _sectors.upper_bound(key); | ||||
|                         it++) | ||||
|                         sectors.push_back(it->second); | ||||
|                     std::sort(sectors.begin(), | ||||
|                         sectors.end(), | ||||
|                         sectorPointerSortPredicate); | ||||
|                     maxSectors = std::max(maxSectors, sectors.size()); | ||||
|  | ||||
|                     float y = top + (float)track * step; | ||||
|                     float x = WIDTH / 2; | ||||
|                     if (side == 0) | ||||
|                         x -= size * 2; | ||||
|                     else | ||||
|                         x += size; | ||||
|  | ||||
|                     for (int sectorId = 0; sectorId < sectors.size(); | ||||
|                         sectorId++) | ||||
|                     { | ||||
|                         std::shared_ptr<const Sector> sector = | ||||
|                             sectors.at(sectorId); | ||||
|  | ||||
|                         QColor colour; | ||||
|                         switch (sector->status) | ||||
|                         { | ||||
|                             case Sector::OK: | ||||
|                                 colour = QColorConstants::DarkGreen; | ||||
|                                 break; | ||||
|  | ||||
|                             case Sector::MISSING: | ||||
|                             case Sector::DATA_MISSING: | ||||
|                                 colour = QColorConstants::Cyan; | ||||
|                                 break; | ||||
|  | ||||
|                             default: | ||||
|                                 colour = QColorConstants::Red; | ||||
|                         } | ||||
|  | ||||
|                         QBrush brush(colour); | ||||
|                         SectorGraphicsItem* item = new SectorGraphicsItem( | ||||
|                             sector, x, y, size, size, brush); | ||||
|                         _scene->addItem(item); | ||||
|  | ||||
|                         if (side == 0) | ||||
|                             x -= step; | ||||
|                         else | ||||
|                             x += step; | ||||
|                     } | ||||
|                 }; | ||||
|  | ||||
|                 drawSectors(0); | ||||
|                 drawSectors(1); | ||||
|             } | ||||
|  | ||||
|             QFont font; | ||||
|             font.setPixelSize(step); | ||||
|             _scene->addAlignedText(WIDTH / 2 - step, | ||||
|                 step, | ||||
|                 "Side 0", | ||||
|                 font, | ||||
|                 Qt::AlignRight | Qt::AlignBottom); | ||||
|             _scene->addAlignedText(WIDTH / 2 + step, | ||||
|                 step, | ||||
|                 "Side 1", | ||||
|                 font, | ||||
|                 Qt::AlignLeft | Qt::AlignBottom); | ||||
|  | ||||
|             float sideWidth = (maxSectors + 1) * step; | ||||
|             setSceneRect( | ||||
|                 {WIDTH / 2 - sideWidth, 0, WIDTH / 2 + sideWidth, HEIGHT}); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             _scene->addAlignedText(WIDTH / 2, HEIGHT / 2, "No image loaded!"); | ||||
|             setSceneRect({0, 0, WIDTH, HEIGHT}); | ||||
|         } | ||||
|  | ||||
|         fitInView(sceneRect(), Qt::KeepAspectRatio); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     typedef std::pair<int, int> key_t; | ||||
|  | ||||
|     Scene* _scene; | ||||
|     std::multimap<key_t, std::shared_ptr<const Sector>> _sectors; | ||||
|     std::map<key_t, std::shared_ptr<const TrackInfo>> _trackInfos; | ||||
|     unsigned _numTracks; | ||||
| }; | ||||
|  | ||||
| ImageVisualiserWidget* ImageVisualiserWidget::create() | ||||
| { | ||||
|     return new ImageVisualiserWidgetImpl(); | ||||
| } | ||||
							
								
								
									
										15
									
								
								src/gui2/imagevisualiserwidget.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/gui2/imagevisualiserwidget.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <QGraphicsView> | ||||
|  | ||||
| class ImageVisualiserWidget : public QGraphicsView | ||||
| { | ||||
|     W_OBJECT(ImageVisualiserWidget) | ||||
|  | ||||
| public: | ||||
|     virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0; | ||||
|     virtual void setDiskData(std::shared_ptr<const DiskFlux> disk) = 0; | ||||
|  | ||||
| public: | ||||
|     static ImageVisualiserWidget* create(); | ||||
| }; | ||||
							
								
								
									
										128
									
								
								src/gui2/main.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								src/gui2/main.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,128 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/core/logger.h" | ||||
| #include "globals.h" | ||||
| #include "mainwindow.h" | ||||
| #include <QtConcurrent> | ||||
|  | ||||
| Application* app; | ||||
| QThreadPool workerThreadPool; | ||||
|  | ||||
| Application::~Application() {} | ||||
|  | ||||
| class ApplicationImpl : public Application | ||||
| { | ||||
| public: | ||||
|     ApplicationImpl(int& argc, char** argv): Application(argc, argv) | ||||
|     { | ||||
|         /* Must be set _before_ the main window is created. */ | ||||
|  | ||||
|         app = this; | ||||
|  | ||||
|         _mainWindow = MainWindow::create(); | ||||
|         _mainWindow->show(); | ||||
|  | ||||
|         Logger::setLogger( | ||||
|             [&](const AnyLogMessage& message) | ||||
|             { | ||||
|                 if (isGuiThread()) | ||||
|                     _mainWindow->logMessage(message); | ||||
|                 else | ||||
|                     postToUiThread( | ||||
|                         [message, this]() | ||||
|                         { | ||||
|                             _mainWindow->logMessage(message); | ||||
|                         }); | ||||
|             }); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::unique_ptr<MainWindow> _mainWindow; | ||||
| }; | ||||
|  | ||||
| bool isGuiThread() | ||||
| { | ||||
|     return (QThread::currentThread() == QCoreApplication::instance()->thread()); | ||||
| } | ||||
|  | ||||
| bool isWorkerThreadRunning() | ||||
| { | ||||
|     return workerThreadPool.activeThreadCount() != 0; | ||||
| } | ||||
|  | ||||
| /* Asynchronously run the callback on the UI thread. */ | ||||
| void postToUiThread(std::function<void()> callback) | ||||
| { | ||||
|     QMetaObject::invokeMethod((QApplication*)app, callback); | ||||
| } | ||||
|  | ||||
| /* Synchronously run the callback on the UI thread. */ | ||||
| void runOnUiThread(std::function<void()> callback) | ||||
| { | ||||
|     if (isGuiThread()) | ||||
|         callback(); | ||||
|     else | ||||
|     { | ||||
|         QSemaphore semaphore(0); | ||||
|         QMetaObject::invokeMethod((QApplication*)app, | ||||
|             [&]() | ||||
|             { | ||||
|                 try | ||||
|                 { | ||||
|                     callback(); | ||||
|                 } | ||||
|                 catch (const ErrorException& e) | ||||
|                 { | ||||
|                     log("Fatal error: {}", e.message); | ||||
|                 } | ||||
|                 catch (...) | ||||
|                 { | ||||
|                     log("Mysterious uncaught exception!"); | ||||
|                 } | ||||
|                 semaphore.release(1); | ||||
|             }); | ||||
|         semaphore.acquire(1); | ||||
|     } | ||||
| } | ||||
|  | ||||
| QFuture<void> safeRunOnWorkerThread(std::function<void()> callback) | ||||
| { | ||||
|     return QtConcurrent::run(&workerThreadPool, | ||||
|         [=]() | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 callback(); | ||||
|             } | ||||
|             catch (const ErrorException& e) | ||||
|             { | ||||
|                 log("Fatal error: {}", e.message); | ||||
|             } | ||||
|             catch (const std::exception& e) | ||||
|             { | ||||
|                 log("Fatal error: {}", e.what()); | ||||
|             } | ||||
|             catch (...) | ||||
|             { | ||||
|                 log("Uncaught exception!"); | ||||
|             } | ||||
|         }); | ||||
| } | ||||
|  | ||||
| Application::Application(int& argc, char** argv): | ||||
|     QApplication(argc, argv), | ||||
|     QSettings("Cowlark Technologies", "FluxEngine") | ||||
| { | ||||
| } | ||||
|  | ||||
| int main(int argc, char** argv) | ||||
| { | ||||
| #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||||
|     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | ||||
| #endif | ||||
|     qRegisterMetaType<const ConfigProto*>(); | ||||
|     Q_INIT_RESOURCE(resources); | ||||
|     workerThreadPool.setMaxThreadCount(1); | ||||
|  | ||||
|     ApplicationImpl impl(argc, argv); | ||||
|     return app->exec(); | ||||
| } | ||||
							
								
								
									
										84
									
								
								src/gui2/mainwindow-filer.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								src/gui2/mainwindow-filer.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/algorithms/readerwriter.h" | ||||
| #include "lib/core/utils.h" | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/decoders/decoders.h" | ||||
| #include "arch/arch.h" | ||||
| #include "globals.h" | ||||
| #include "mainwindow.h" | ||||
| #include "filer.h" | ||||
| #include "fluxvisualiserwidget.h" | ||||
| #include "imagevisualiserwidget.h" | ||||
|  | ||||
| class MainWindowImpl : public MainWindow, protected Ui_Filer | ||||
| { | ||||
|     W_OBJECT(MainWindowImpl) | ||||
|  | ||||
| private: | ||||
|     enum State | ||||
|     { | ||||
|         STATE_IDLE, | ||||
|         STATE_READING, | ||||
|         STATE_WRITING | ||||
|     }; | ||||
|  | ||||
| public: | ||||
|     MainWindowImpl() | ||||
|     { | ||||
|         Ui_Filer::setupUi(container); | ||||
|  | ||||
|         setState(STATE_IDLE); | ||||
|     } | ||||
|  | ||||
| protected: | ||||
|     /* Runs on the UI thread. */ | ||||
|     void logMessage(const AnyLogMessage& message) | ||||
|     { | ||||
|         std::visit(overloaded{/* Fallback --- do nothing */ | ||||
|                        [&](const auto& m) | ||||
|                        { | ||||
|                        }, | ||||
|  | ||||
|                        /* A track has been read. */ | ||||
|                        [&](std::shared_ptr<const TrackReadLogMessage> m) | ||||
|                        { | ||||
|                        }, | ||||
|  | ||||
|                        /* A complete disk has been read. */ | ||||
|                        [&](std::shared_ptr<const DiskReadLogMessage> m) | ||||
|                        { | ||||
|                        }, | ||||
|  | ||||
|                        /* Large-scale operation end. */ | ||||
|                        [&](std::shared_ptr<const EndOperationLogMessage> m) | ||||
|                        { | ||||
|                        }}, | ||||
|             message); | ||||
|  | ||||
|         MainWindow::logMessage(message); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     void updateState() | ||||
|     { | ||||
|         setState(_state); | ||||
|     } | ||||
|  | ||||
|     void setState(int state) | ||||
|     { | ||||
|         settingsCanBeChanged(state == STATE_IDLE); | ||||
|  | ||||
|         _state = state; | ||||
|     } | ||||
|     W_SLOT(setState) | ||||
|  | ||||
| private: | ||||
|     int _state; | ||||
| }; | ||||
| W_OBJECT_IMPL(MainWindowImpl) | ||||
|  | ||||
| std::unique_ptr<MainWindow> MainWindow::create() | ||||
| { | ||||
|     return std::make_unique<MainWindowImpl>(); | ||||
| } | ||||
							
								
								
									
										153
									
								
								src/gui2/mainwindow-imager.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								src/gui2/mainwindow-imager.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,153 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/algorithms/readerwriter.h" | ||||
| #include "lib/core/utils.h" | ||||
| #include "lib/fluxsource/fluxsource.h" | ||||
| #include "lib/decoders/decoders.h" | ||||
| #include "arch/arch.h" | ||||
| #include "globals.h" | ||||
| #include "mainwindow.h" | ||||
| #include "imager.h" | ||||
| #include "fluxvisualiserwidget.h" | ||||
| #include "imagevisualiserwidget.h" | ||||
|  | ||||
| class MainWindowImpl : public MainWindow, protected Ui_Imager | ||||
| { | ||||
|     W_OBJECT(MainWindowImpl) | ||||
|  | ||||
| private: | ||||
|     enum State | ||||
|     { | ||||
|         STATE_IDLE, | ||||
|         STATE_READING, | ||||
|         STATE_WRITING | ||||
|     }; | ||||
|  | ||||
| public: | ||||
|     MainWindowImpl() | ||||
|     { | ||||
|         Ui_Imager::setupUi(container); | ||||
|  | ||||
|         /* Flux visualiser */ | ||||
|  | ||||
|         _fluxVisualiserWidget = FluxVisualiserWidget::create(); | ||||
|         fluxViewContainer->layout()->addWidget(_fluxVisualiserWidget); | ||||
|  | ||||
|         // connect(fluxSideComboBox, | ||||
|         //     QOverload<int>::of(&QComboBox::activated), | ||||
|         //     _fluxVisualiserWidget, | ||||
|         //     &FluxVisualiserWidget::setVisibleSide); | ||||
|         // connect(fluxContrastSlider, | ||||
|         //     &QAbstractSlider::valueChanged, | ||||
|         //     [this](int value) | ||||
|         //     { | ||||
|         //         _fluxVisualiserWidget->setGamma(value / 100.0); | ||||
|         //     }); | ||||
|         // fluxContrastSlider->setValue(500); | ||||
|  | ||||
|         /* Image visualiser */ | ||||
|  | ||||
|         _imageVisualiserWidget = ImageVisualiserWidget::create(); | ||||
|         imageViewContainer->layout()->addWidget(_imageVisualiserWidget); | ||||
|  | ||||
|         /* Controls */ | ||||
|  | ||||
|         connect(readDiskButton, | ||||
|             &QAbstractButton::clicked, | ||||
|             this, | ||||
|             &MainWindowImpl::readDisk); | ||||
|  | ||||
|         setState(STATE_IDLE); | ||||
|     } | ||||
|  | ||||
| protected: | ||||
|     /* Runs on the UI thread. */ | ||||
|     void logMessage(const AnyLogMessage& message) | ||||
|     { | ||||
|         std::visit(overloaded{/* Fallback --- do nothing */ | ||||
|                        [&](const auto& m) | ||||
|                        { | ||||
|                        }, | ||||
|  | ||||
|                        /* A track has been read. */ | ||||
|                        [&](std::shared_ptr<const TrackReadLogMessage> m) | ||||
|                        { | ||||
|                            _fluxVisualiserWidget->setTrackData(m->track); | ||||
|                            _imageVisualiserWidget->setTrackData(m->track); | ||||
|                        }, | ||||
|  | ||||
|                        /* A complete disk has been read. */ | ||||
|                        [&](std::shared_ptr<const DiskReadLogMessage> m) | ||||
|                        { | ||||
|                            _currentDisk = m->disk; | ||||
|                            updateState(); | ||||
|                        }, | ||||
|  | ||||
|                        /* Large-scale operation end. */ | ||||
|                        [&](std::shared_ptr<const EndOperationLogMessage> m) | ||||
|                        { | ||||
|                        }}, | ||||
|             message); | ||||
|  | ||||
|         MainWindow::logMessage(message); | ||||
|     } | ||||
|  | ||||
| public: | ||||
| private: | ||||
|     void readDisk() | ||||
|     { | ||||
|         if (isWorkerThreadRunning()) | ||||
|             return; | ||||
|  | ||||
|         collectConfig(); | ||||
|         ::emergencyStop = false; | ||||
|         setState(STATE_READING); | ||||
|         _fluxVisualiserWidget->resetView(); | ||||
|  | ||||
|         runThen( | ||||
|             [this]() | ||||
|             { | ||||
|                 auto fluxSource = FluxSource::create(globalConfig()); | ||||
|                 auto decoder = Arch::createDecoder(globalConfig()); | ||||
|                 auto diskflux = readDiskCommand(*fluxSource, *decoder); | ||||
|             }, | ||||
|             [this]() | ||||
|             { | ||||
|                 setState(STATE_IDLE); | ||||
|             }); | ||||
|     } | ||||
|     W_SLOT(readDisk) | ||||
|  | ||||
| private: | ||||
|     void updateState() | ||||
|     { | ||||
|         setState(_state); | ||||
|     } | ||||
|  | ||||
|     void setState(int state) | ||||
|     { | ||||
|         settingsCanBeChanged(state == STATE_IDLE); | ||||
|         commandButtonFrame->setEnabled(state == STATE_IDLE); | ||||
|  | ||||
|         _stopWidget->setEnabled(state != STATE_IDLE); | ||||
|         _progressWidget->setEnabled(state != STATE_IDLE); | ||||
|  | ||||
|         saveImageButton->setEnabled((bool)_currentDisk); | ||||
|         writeDiskButton->setEnabled((bool)_currentDisk); | ||||
|  | ||||
|         _state = state; | ||||
|     } | ||||
|     W_SLOT(setState) | ||||
|  | ||||
| private: | ||||
|     std::shared_ptr<const DiskFlux> _currentDisk; | ||||
|     FluxVisualiserWidget* _fluxVisualiserWidget; | ||||
|     ImageVisualiserWidget* _imageVisualiserWidget; | ||||
|     int _state; | ||||
| }; | ||||
| W_OBJECT_IMPL(MainWindowImpl) | ||||
|  | ||||
| std::unique_ptr<MainWindow> MainWindow::create() | ||||
| { | ||||
|     return std::make_unique<MainWindowImpl>(); | ||||
| } | ||||
							
								
								
									
										113
									
								
								src/gui2/mainwindow.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								src/gui2/mainwindow.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,113 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/algorithms/readerwriter.h" | ||||
| #include "lib/core/utils.h" | ||||
| #include "globals.h" | ||||
| #include "mainwindow.h" | ||||
| #include "drivecomponent.h" | ||||
| #include "formatcomponent.h" | ||||
|  | ||||
| W_OBJECT_IMPL(MainWindow) | ||||
|  | ||||
| MainWindow::MainWindow(): | ||||
|     _logStreamBuf( | ||||
|         [this](const std::string& s) | ||||
|         { | ||||
|             logViewerEdit->moveCursor(QTextCursor::End); | ||||
|             logViewerEdit->insertPlainText(QString::fromStdString(s)); | ||||
|             logViewerEdit->ensureCursorVisible(); | ||||
|         }), | ||||
|     _logStream(&_logStreamBuf), | ||||
|     _logRenderer(LogRenderer::create(_logStream)) | ||||
| { | ||||
|     setupUi(this); | ||||
|  | ||||
|     _progressWidget = new QProgressBar(); | ||||
|     _progressWidget->setMinimum(0); | ||||
|     _progressWidget->setMaximum(100); | ||||
|     _progressWidget->setEnabled(false); | ||||
|     _progressWidget->setAlignment(Qt::AlignRight); | ||||
|     statusbar->addPermanentWidget(_progressWidget); | ||||
|  | ||||
|     _stopWidget = new QToolButton(); | ||||
|     _stopWidget->setText("Stop"); | ||||
|     statusbar->addPermanentWidget(_stopWidget); | ||||
|  | ||||
|     connect(_stopWidget, | ||||
|         &QPushButton::clicked, | ||||
|         this, | ||||
|         [&]() | ||||
|         { | ||||
|             ::emergencyStop = true; | ||||
|         }); | ||||
|  | ||||
|     _driveComponent = DriveComponent::create(this); | ||||
|     _formatComponent = FormatComponent::create(this); | ||||
| } | ||||
|  | ||||
| void MainWindow::runThen( | ||||
|     std::function<void()> workCb, std::function<void()> completionCb) | ||||
| { | ||||
|     QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this); | ||||
|     watcher->setFuture(safeRunOnWorkerThread(workCb)); | ||||
|     connect(watcher, &QFutureWatcher<void>::finished, completionCb); | ||||
|     connect(watcher, | ||||
|         &QFutureWatcher<void>::finished, | ||||
|         watcher, | ||||
|         &QFutureWatcher<void>::deleteLater); | ||||
| } | ||||
|  | ||||
| /* Runs on the UI thread. */ | ||||
| void MainWindow::logMessage(const AnyLogMessage& message) | ||||
| { | ||||
|     std::visit(overloaded{/* Fallback --- do nothing */ | ||||
|                    [&](const auto& m) | ||||
|                    { | ||||
|                    }, | ||||
|  | ||||
|                    /* Large-scale operation start. */ | ||||
|                    [&](std::shared_ptr<const BeginOperationLogMessage> m) | ||||
|                    { | ||||
|                        _progressWidget->setValue(0); | ||||
|                    }, | ||||
|  | ||||
|                    /* Large-scale operation end. */ | ||||
|                    [&](std::shared_ptr<const EndOperationLogMessage> m) | ||||
|                    { | ||||
|                        _progressWidget->setValue(100); | ||||
|                    }, | ||||
|  | ||||
|                    /* Large-scale operation progress. */ | ||||
|                    [&](std::shared_ptr<const OperationProgressLogMessage> m) | ||||
|                    { | ||||
|                        _progressWidget->setValue(m->progress); | ||||
|                    }}, | ||||
|         message); | ||||
|  | ||||
|     _logRenderer->add(message); | ||||
|     _logStream.flush(); | ||||
| } | ||||
|  | ||||
| void MainWindow::collectConfig() | ||||
| { | ||||
|     try | ||||
|     { | ||||
|         globalConfig().clear(); | ||||
|         _formatComponent->collectConfig(); | ||||
|         _driveComponent->collectConfig(); | ||||
|     } | ||||
|     catch (const ErrorException& e) | ||||
|     { | ||||
|         log("Fatal error: {}", e.message); | ||||
|     } | ||||
|     catch (...) | ||||
|     { | ||||
|         log("Mysterious uncaught exception!"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void MainWindow::settingsCanBeChanged(bool state) | ||||
| { | ||||
|     driveConfigurationBox->setEnabled(state); | ||||
|     formatConfigurationBox->setEnabled(state); | ||||
| } | ||||
							
								
								
									
										60
									
								
								src/gui2/mainwindow.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								src/gui2/mainwindow.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "lib/core/logger.h" | ||||
| #include "globals.h" | ||||
|  | ||||
| class DriveComponent; | ||||
| class FormatComponent; | ||||
|  | ||||
| class CallbackOstream : public std::streambuf | ||||
| { | ||||
| public: | ||||
|     CallbackOstream(std::function<void(const std::string&)> cb): _cb(cb) {} | ||||
|  | ||||
| public: | ||||
|     std::streamsize xsputn(const char* p, std::streamsize n) override | ||||
|     { | ||||
|         _cb(std::string(p, n)); | ||||
|         return n; | ||||
|     } | ||||
|  | ||||
|     int_type overflow(int_type v) override | ||||
|     { | ||||
|         char c = v; | ||||
|         _cb(std::string(&c, 1)); | ||||
|         return 1; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     std::function<void(const std::string&)> _cb; | ||||
| }; | ||||
|  | ||||
| class MainWindow : public QMainWindow, public Ui_MainWindow | ||||
| { | ||||
|     W_OBJECT(MainWindow) | ||||
|  | ||||
| public: | ||||
|     static std::unique_ptr<MainWindow> create(); | ||||
|  | ||||
| public: | ||||
|     MainWindow(); | ||||
|  | ||||
| public: | ||||
|     virtual void logMessage(const AnyLogMessage& message); | ||||
|     void collectConfig(); | ||||
|     void updateState(); | ||||
|  | ||||
| protected: | ||||
|     void settingsCanBeChanged(bool state); | ||||
|     void runThen( | ||||
|         std::function<void()> workCb, std::function<void()> completionCb); | ||||
|  | ||||
| protected: | ||||
|     QAbstractButton* _stopWidget; | ||||
|     QProgressBar* _progressWidget; | ||||
|     std::ostream _logStream; | ||||
|     CallbackOstream _logStreamBuf; | ||||
|     std::unique_ptr<LogRenderer> _logRenderer; | ||||
|     DriveComponent* _driveComponent; | ||||
|     FormatComponent* _formatComponent; | ||||
| }; | ||||
							
								
								
									
										7
									
								
								src/gui2/resources.qrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/gui2/resources.qrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| <RCC> | ||||
|   <qresource prefix="ui"> | ||||
|     <file>../../extras/icon.png</file> | ||||
|     <file>../../extras/fluxfile.png</file> | ||||
|     <file>../../extras/hardware.png</file> | ||||
|   </qresource> | ||||
| </RCC> | ||||
							
								
								
									
										25
									
								
								src/gui2/scene.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/gui2/scene.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| #include "scene.h" | ||||
| #include <QGraphicsSimpleTextItem> | ||||
|  | ||||
| QGraphicsSimpleTextItem* Scene::addAlignedText(qreal x, | ||||
|     qreal y, | ||||
|     const QString& text, | ||||
|     const QFont& font, | ||||
|     Qt::Alignment alignment) | ||||
| { | ||||
|     QGraphicsSimpleTextItem* item = addSimpleText(text, font); | ||||
|     QRectF bounds = item->boundingRect(); | ||||
|  | ||||
|     if (alignment & Qt::AlignHCenter) | ||||
|         x -= bounds.width() / 2; | ||||
|     if (alignment & Qt::AlignRight) | ||||
|         x -= bounds.width(); | ||||
|  | ||||
|     if (alignment & Qt::AlignVCenter) | ||||
|         y -= bounds.height() / 2; | ||||
|     if (alignment & Qt::AlignBottom) | ||||
|         y -= bounds.height(); | ||||
|  | ||||
|     item->setPos(x, y); | ||||
|     return item; | ||||
| } | ||||
							
								
								
									
										13
									
								
								src/gui2/scene.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/gui2/scene.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <QGraphicsScene> | ||||
|  | ||||
| class Scene : public QGraphicsScene | ||||
| { | ||||
| public: | ||||
|     QGraphicsSimpleTextItem* addAlignedText(qreal x, | ||||
|         qreal y, | ||||
|         const QString& text, | ||||
|         const QFont& font = QFont(), | ||||
|         Qt::Alignment alignment = Qt::AlignHCenter | Qt::AlignVCenter); | ||||
| }; | ||||
							
								
								
									
										133
									
								
								src/gui2/viewnavigator.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								src/gui2/viewnavigator.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,133 @@ | ||||
| #include "lib/core/globals.h" | ||||
| #include "lib/config/config.h" | ||||
| #include "lib/data/fluxmap.h" | ||||
| #include "lib/data/flux.h" | ||||
| #include "lib/data/layout.h" | ||||
| #include "lib/data/fluxmapreader.h" | ||||
| #include "globals.h" | ||||
| #include "fluxvisualiserwidget.h" | ||||
| #include "fluxview.h" | ||||
| #include "scene.h" | ||||
| #include "viewnavigator.h" | ||||
| #include <QWheelEvent> | ||||
|  | ||||
| class ViewNavigatorImpl : public ViewNavigator | ||||
| { | ||||
| public: | ||||
|     ViewNavigatorImpl(QWidget* obj, double xpower): _obj(obj), _xpower(xpower) | ||||
|     { | ||||
|         _obj->installEventFilter(this); | ||||
|     } | ||||
|  | ||||
|     bool eventFilter(QObject* dest, QEvent* event) | ||||
|     { | ||||
|         if (dest == _obj) | ||||
|         { | ||||
|             switch (event->type()) | ||||
|             { | ||||
|                 case QEvent::MouseButtonPress: | ||||
|                     mousePressEvent((QMouseEvent*)event); | ||||
|                     return true; | ||||
|  | ||||
|                 case QEvent::MouseMove: | ||||
|                     mouseMoveEvent((QMouseEvent*)event); | ||||
|                     return true; | ||||
|  | ||||
|                 case QEvent::MouseButtonRelease: | ||||
|                     mouseReleaseEvent((QMouseEvent*)event); | ||||
|                     return true; | ||||
|  | ||||
|                 case QEvent::Wheel: | ||||
|                     mouseWheelEvent((QWheelEvent*)event); | ||||
|                     return true; | ||||
|             } | ||||
|         } | ||||
|         return QObject::eventFilter(dest, event); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     void mousePressEvent(QMouseEvent* event) | ||||
|     { | ||||
|         event->accept(); | ||||
|         _reference = event->pos(); | ||||
|         app->setOverrideCursor(Qt::ClosedHandCursor); | ||||
|         _obj->setMouseTracking(true); | ||||
|     } | ||||
|  | ||||
|     void mouseMoveEvent(QMouseEvent* event) | ||||
|     { | ||||
|         event->accept(); | ||||
|         QPointF d = event->pos() - _reference; | ||||
|         _delta += {d.x() * 1.0 / xscale(), d.y() * 1.0 / yscale()}; | ||||
|         _reference = event->pos(); | ||||
|         _obj->update(); | ||||
|     } | ||||
|  | ||||
|     void mouseReleaseEvent(QMouseEvent* event) | ||||
|     { | ||||
|         event->accept(); | ||||
|         app->restoreOverrideCursor(); | ||||
|         _obj->setMouseTracking(false); | ||||
|     } | ||||
|  | ||||
|     void mouseWheelEvent(QWheelEvent* event) | ||||
|     { | ||||
|         event->accept(); | ||||
|  | ||||
|         QPointF pos = event->position() - _obj->rect().center(); | ||||
|         _delta -= {pos.x() / xscale(), pos.y() / yscale()}; | ||||
|         double amount = event->angleDelta().y() / 100.0; | ||||
|         if (amount > 0) | ||||
|             _scale *= amount; | ||||
|         else | ||||
|             _scale /= -amount; | ||||
|         _delta += {pos.x() / xscale(), pos.y() / yscale()}; | ||||
|         _obj->update(); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void setScale(double scale) override | ||||
|     { | ||||
|         _scale = scale; | ||||
|         _obj->update(); | ||||
|     } | ||||
|  | ||||
|     void setOrigin(double x, double y) | ||||
|     { | ||||
|         _delta = {-x, -y}; | ||||
|         _obj->update(); | ||||
|     } | ||||
|  | ||||
| public: | ||||
|     void transform(QPainter& painter) override | ||||
|     { | ||||
|         painter.translate(_obj->rect().center()); | ||||
|         painter.scale(xscale(), yscale()); | ||||
|         painter.translate(_delta); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     double xscale() const | ||||
|     { | ||||
|         return pow(_scale, std::clamp(_xpower * _scale * 0.5, 1.0, _xpower)); | ||||
|     } | ||||
|  | ||||
|     double yscale() const | ||||
|     { | ||||
|         return _scale; | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     QWidget* _obj; | ||||
|     double _xpower; | ||||
|     QRectF _rect; | ||||
|     QPointF _reference; | ||||
|     QPointF _delta; | ||||
|     double _scale = 1.0; | ||||
| }; | ||||
|  | ||||
| std::unique_ptr<ViewNavigator> ViewNavigator::create( | ||||
|     QWidget* obj, double xpower) | ||||
| { | ||||
|     return std::make_unique<ViewNavigatorImpl>(obj, xpower); | ||||
| } | ||||
							
								
								
									
										14
									
								
								src/gui2/viewnavigator.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/gui2/viewnavigator.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #pragma once | ||||
|  | ||||
| class ViewNavigator : public QObject | ||||
| { | ||||
| public: | ||||
|     static std::unique_ptr<ViewNavigator> create(QWidget* obj, double xpower); | ||||
|  | ||||
| public: | ||||
|     virtual void setScale(double scale) = 0; | ||||
|     virtual void setOrigin(double x, double y) = 0; | ||||
|  | ||||
| public: | ||||
|     virtual void transform(QPainter& painter) = 0; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user