New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading SVG files for Icons (annotations). #10104
base: master
Are you sure you want to change the base?
Conversation
@@ -53,6 +53,7 @@ QString Helper::omnotebookFileTypes = "OMNotebook Files (*.onb *.onbz *.nb)"; | |||
QString Helper::ngspiceNetlistFileTypes = "ngspice Netlist Files (*.cir *.sp *.spice)"; | |||
QString Helper::imageFileTypes = "SVG (*.svg);;PNG image (*.png);;Windows BMP image (*.bmp);;TIFF (*.tiff)"; | |||
QString Helper::bitmapFileTypes = "Image Files (*.png *.bmp *.jpg *.jpeg);;PNG image (*.png);;Windows BMP image (*.bmp);;JPEG (*.jpg *.jpeg)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: the "bitmapFileTypes" image filter has its usage for selecting bitmap textures somewhere in 3D animation viewer, so not extending this one with SVG as it's not the intention of this PR to alter this accidentally.
@casella, are there any formatting standards you stick to in this project? Writing because my editor settings (almost) by default makes plenty of changes (like include order sorting/grouping). Are you accepting such formatting changes mixed with functional changes? What's your policy here? Sorry for plenty of question at once. Better to clarify upfront... |
@achary read this https://github.com/OpenModelica/OpenModelica/tree/master/OMEdit#coding-style For includes we first include our own files and then the Qt headers. |
@adeas31 Thanks. I think it only scratches the surface, but I'll try to stick. |
@achary I guess you can also get an idea by looking at the existing codebase. |
|
||
painter->drawImage(target, mImage.mirrored()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This is the root place where the change actually needed to be applied at. Instead of always drawing a bitmap image, now, we now delegate the painting operation to whatever the mpRenderer
(runtime polymorphic type) has been constructed. Bitmap images render pretty much the same way (see BitmapRenderer
class) and SVG images use QSvgRenderer
under the hood instead (see `SvgRenderer class).
7bbb1b1
to
d5ccc88
Compare
The change ended up being slightly more involving than I've imagined prior seeing the code. IMO the |
d5ccc88
to
ce8713e
Compare
SVGs are permitted image types (as per modelica specification). Support for SVG as a valid image type usable in annotation is added.
ce8713e
to
75984a9
Compare
75984a9
to
014e6bd
Compare
@adeas31 can you please review and merge if you think this is OK? Thanks! |
You need to check the logs to see what is wrong:
Sometimes jobs simply timeout... Or crash inside of Jenkins itself and it has nothing to do with the code. Sometimes it's GitHub that is slow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't look at the implementation details yet.
I compiled the code and it is not working as expected. For example, look at Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.FullRobot
. Also create a new model and try adding a bitmap to it.
FYI I also get message, QIODevice::read (QFile, "modelica:\Modelica\Resources\Images\Mechanics\MultiBody\Examples\Systems\RobotR3\robot_kr15.png"): device not open |
Oh, that's worrying. I'll see if I can reproduce it. |
|
SVGs are permitted image types (as per Modelica specification). Support for SVG as a valid image type usable in annotation is added.
Related Issues
#10102
Purpose
as in the issue.
Approach
The app decides, based on the decoded base64 content, whether it deals with one of binary formats (PNG, JPG) that can be simply pushed to QPixmap and alike, without worrying about them, or whether it's SVG and needs slightly different rendering path. For that it constructs one of appropriate image renderers.
This PR where it stands, makes SVG files first-class citizens and improves quality of their renderings in the UI (can be zoomed in without pixelization).
Screens
The SVG file
doc/images/logo.svg
was used here:and with larger zoom: