Post Reply 
Nonpareil status
10-29-2023, 09:27 AM
Post: #60
Nonpareil 2, now with SVG!
I'm not sure whether I'll build a new release of the current Nonpareil code base. I've been very frustrated with the bitmap (PNG) graphics, which don't scale up well other than by integer multiples. I've long wanted to use SVG (Scalable Vector Graphics) files instead. I also wanted to switch to using the Qt6 toolkit (which has some SVG support), instead of GTK+ 2. Updating to GTK+ 4 is harder than I expected, and I don't want to put time into that. Of course, using Qt6 generally requires programming in C++ or Python, so in order to make this all happen, I embarked on a major rewrite in C++, which will eventually be Nonpareil 2.0.

I've worked on two separate parts, the simulation core and the user interface, but so far I don't have them actually tied together, as I've been debugging them independently. At first I reimplemented the bitmap graphics user interface, and had that working with Qt6, but since I'm not satisfied with bitmaps, I started working on redoing it using SVG. Eventually I'll have to write the glue layer that interfaces between the simulation core and the user interface.

The most difficult part of the user interface so far has been that, while an SVG file is XML, and while the QSvgRenderer loads the XML into memory in something basically like a DOM, Qt6 doesn't provide any interface whatsoever for the client to modify, or even examine, the DOM.. I expected to do automatic color value adjustments to lighten keys for mouse hover, and darken them for mouse click, like in my GTK+ and now Qt6 bitmap interfaces, but I thought I'd just be able to tweak an attribute in the already-resident DOM and call update(), and that's not possible. (Short of hacking Qt6 itself, which is a recipe for disaster.)

I wasted some time trying to use a QGraphicsEffect, which can apply effects to painting, which is the low-level operation that all Qt rendering, including QSvgRenderer, goes through. There's an underlying QPixmapFilter class to do transformation like convolutions on the pixel data. Unfortunately the QPixmapFilter class was public in Qt 4.8, but is private in Qt 5 and later. Also QGraphicsEffect doesn't publicly expose the ability to install a QPixMap filter. This seems awful. Nevertheless, I wrote my own subclass of QGraphicsEffect, and had it almost working.

If I use one of the standard effects Qt6 provides, like QGraphicsBlurEffect, it seems to work correctly even with the QSvgGraphicsItem. but if I use my own custom QGraphicsEffect, the rendering of the "source" pixmap for the filter (from the SVG) is at lower resolution than the display. There are choices for device coordinates or source coordinates, but neither seem to do the right thing.

Anyhow, I've set that aside and taken another approach. Previously I had the QSvgRenderer load the SVG file for the whole calculator, and then I use that same QSvgRenderer for all QGraphicsSvgItems. You can tell a QGraphicsSvgItem to render only a particular subtree of the SVG file, so I have subtrees for the base, overlay, all the keys, and various display elements, and all were using the same QSvgRenderer from the same XML file.

I've changed it so that I read the SVG file into a buffer, then load it into an XML file, and update the button style attributes for the different colors, and write SVG back to two more buffers, which then get loaded into two new QSvgRenderers, one for hovered-upon buttons and one for clicked buttons.

Now the code that changes the button state just changes the button's QSvgRenderer and calls update().

Geez, this has been a huge amount of work, but I've finally getting somewhere.

I still have more work on the display in SVG, and in making a halfway-decent looking SVG file. Last year I paid an artist to produce a good 12C SVG file for me, but we got into a dispute over the contract terms regarding the license of the work, so now I can't use it and am just out the money, which fortunately wasn't a huge amount. So now I'm trying to put together my own, which won't be quite as pretty, but should be at least as good as the old Nonpareil bitmaps.

Oh, and I still have some work to do to get it to render text in the font I want. I can't depend on particular fonts being present on the user's computer, and I don't want to install fonts, so I want them embedded in the SVG. But QSvgRenderer does not support embedded fonts, so I have to do another bit of manipulation on the SVG loaded into memory, extract the font, and hand it off to the QFontDatabase.

I hope to have in a few weeks a UI prototype ready to offer to folks that might want to try it. The simulation won't be hooked up.

Once I have working SVG files for all of the supported calculators, I plan to remove the bitmap (PNG) support entirely.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Nonpareil status - brouhaha - 10-06-2022, 11:31 PM
RE: Nonpareil status - teenix - 10-07-2022, 12:24 AM
RE: Nonpareil status - Thomas Klemm - 10-11-2022, 04:02 PM
RE: Nonpareil status - johanw - 10-12-2022, 03:30 PM
RE: Nonpareil status - Mark H. Shin - 10-12-2022, 10:42 PM
RE: Nonpareil status - brouhaha - 10-13-2022, 05:28 PM
HP--91 and HP-19C progress - brouhaha - 10-15-2022, 02:28 AM
RE: Nonpareil status - teenix - 10-15-2022, 03:21 AM
RE: Nonpareil status - brouhaha - 10-15-2022, 04:17 PM
RE: Nonpareil status - PANAMATIK - 10-15-2022, 02:20 PM
RE: Nonpareil status - brouhaha - 10-15-2022, 04:25 PM
RE: Nonpareil status - Thomas Okken - 10-15-2022, 06:11 PM
RE: Nonpareil status - brouhaha - 10-15-2022, 06:33 PM
RE: Nonpareil status - Joe Horn - 10-15-2022, 07:33 PM
RE: Nonpareil status - brouhaha - 10-15-2022, 08:29 PM
RE: Nonpareil status - teenix - 10-16-2022, 05:50 AM
RE: Nonpareil status - brouhaha - 10-16-2022, 08:43 AM
RE: Nonpareil status - teenix - 10-16-2022, 09:56 AM
RE: Nonpareil status - brouhaha - 10-16-2022, 08:41 AM
RE: Nonpareil status - brouhaha - 10-16-2022, 08:07 PM
RE: Nonpareil status - teenix - 10-16-2022, 10:15 PM
RE: Nonpareil status - brouhaha - 10-17-2022, 04:16 PM
RE: Nonpareil status - teenix - 10-18-2022, 07:40 AM
RE: Nonpareil status - teenix - 10-18-2022, 12:30 AM
RE: Nonpareil status - teenix - 10-18-2022, 11:11 PM
RE: Nonpareil status - brouhaha - 10-20-2022, 05:28 AM
RE: Nonpareil status - Mike T. - 10-20-2022, 08:49 PM
RE: Nonpareil status - Thomas Okken - 10-20-2022, 09:00 PM
RE: Nonpareil status - Mark H. Shin - 10-20-2022, 10:53 PM
RE: Nonpareil status - brouhaha - 10-22-2022, 12:04 AM
RE: Nonpareil status - brouhaha - 10-22-2022, 12:09 AM
RE: Nonpareil status - eshazen - 10-23-2022, 07:40 PM
RE: Nonpareil status - brouhaha - 10-24-2022, 05:18 AM
RE: Nonpareil status - eshazen - 10-24-2022, 04:53 PM
RE: Nonpareil status - brouhaha - 10-24-2022, 06:31 PM
RE: Nonpareil status - brouhaha - 10-29-2022, 05:16 AM
RE: Nonpareil status - brouhaha - 11-01-2022, 01:27 AM
RE: Nonpareil status - Mark H. Shin - 11-01-2022, 10:23 AM
RE: Nonpareil status - brouhaha - 11-02-2022, 05:52 AM
97 graphics - brouhaha - 11-04-2022, 05:37 AM
RE: Nonpareil status - brouhaha - 11-07-2022, 08:04 PM
RE: Nonpareil status - brouhaha - 11-16-2022, 06:19 AM
RE: Nonpareil status - Didier Lachieze - 11-16-2022, 06:27 AM
RE: Nonpareil status - brouhaha - 11-16-2022, 06:33 AM
RE: Nonpareil status - rprosperi - 11-16-2022, 02:07 PM
RE: Nonpareil status - brouhaha - 11-16-2022, 05:49 PM
RE: Nonpareil status - Mark H. Shin - 11-19-2022, 04:19 PM
RE: Nonpareil status - brouhaha - 11-20-2022, 09:38 AM
RE: Nonpareil status - Didier Lachieze - 11-20-2022, 03:01 PM
RE: Nonpareil status - Mark H. Shin - 11-20-2022, 10:45 PM
Nonpareil on HiDPI displays - brouhaha - 12-13-2022, 01:24 AM
HP-55 (RE: Nonpareil status) - brouhaha - 12-27-2022, 12:25 AM
RE: Nonpareil status - teenix - 12-27-2022, 03:17 AM
RE: Nonpareil status - brouhaha - 12-27-2022, 04:17 AM
publicity - brouhaha - 01-08-2023, 10:24 PM
RE: Nonpareil status - agarza - 01-09-2023, 05:08 PM
Nonpareil 2, now with SVG! - brouhaha - 10-29-2023 09:27 AM
RE: Nonpareil status - Mike T. - 11-03-2023, 12:21 AM
RE: Nonpareil status - brouhaha - 11-03-2023, 03:45 AM



User(s) browsing this thread: 1 Guest(s)