Skip to content
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

wrong image size on Ubuntu with Julia Display #53

Open
piever opened this issue Jan 23, 2018 · 14 comments
Open

wrong image size on Ubuntu with Julia Display #53

piever opened this issue Jan 23, 2018 · 14 comments

Comments

@piever
Copy link

piever commented Jan 23, 2018

Running "example/plot.jl" gives me this:

qml

I think it may be a linux specific problem (I installed QML using the libraries in #52).

@piever
Copy link
Author

piever commented Jan 26, 2018

Update: it is actually not strictly a QML issue. The display size issue only happen with the GR backend. Gtk is also affected, for example:

using Plots, Gtk
gr()
plot(rand(100))
tmp = tempname() * ".png"
savefig(tmp)

img = GtkImage(tmp)

win = GtkWindow("test")
push!(win, img)
showall(win)

would show an image much bigger than the original png. It wouldn't happen with a different backend (have tried plotlyjs to confirm). I suspect it started with #1318, I'm pinging @jheinen as he probably knows what's going on.

@barche
Copy link
Collaborator

barche commented Jan 29, 2018

Hi,

Sorry for my late reply, but this is probably the device pixel ratio. The gr.jl example takes this into account. The trick is to pass the QML item to the callback, and then use the effectiveDevicePixelRatio function to get the ratio between image pixels and screen pixels.

@piever
Copy link
Author

piever commented Jan 29, 2018

Hi, thanks for looking into this. I actually do not believe this has to do with effectiveDevicePixelRatio as it used to work fine on my Mac retina screen (which has an effectiveDevicePixelRatio of 2). I believe the issue is specific to GR due to the way they save PNG, which changed recently (see for example this comment ). Can you reproduce the problem if you check out the latest Plots and GR and try the example on your setup?

@jheinen
Copy link

jheinen commented Jan 29, 2018

There s no need to use PNGs in QML/GR environments. You can directly draw into the widget provided by Qt, which is much faster.

GR example: https://github.com/jheinen/GR.jl/blob/master/examples/qml_ex.jl
Plots + GR example: https://github.com/jheinen/GR.jl/blob/master/examples/qml_plots_ex.jl

QML file: https://github.com/jheinen/GR.jl/blob/master/examples/qml_ex.qml

@piever
Copy link
Author

piever commented Jan 29, 2018

Thanks, I'll try that in my use case.

@jheinen
Copy link

jheinen commented Jan 29, 2018

@piever
Copy link
Author

piever commented Jan 29, 2018

Probably not the right place to report this, but I'm having issues running your example on Ubuntu:

julia> Pkg.status("GR")
 - GR                            0.25.0

julia> ENV["GRDIR"]=""
""

julia> Pkg.build("GR")

julia> GR.version()
"0.28.0"

julia> include(joinpath(Pkg.dir("GR", "examples"), "qml_plots_ex.jl"))
GKS: Qt5 support not compiled in

I imagine is a similar issue to this comment but for the Ubuntu precompiled binaries.

I get the QML window, with the slider, which detects my mouse position but no plot appears:

gr_qml

@jheinen
Copy link

jheinen commented Jan 30, 2018

We have to fix this in our CI environment or provide a method which would allow the user to build such extensions, e.g. the Qt5 plugin. You are using Ubuntu, right?

@piever
Copy link
Author

piever commented Jan 30, 2018

Yes, I have an ubuntu machine (which has this issue) and a mac (on which I can run your QML+GR example). Thanks for looking into this!

@jheinen
Copy link

jheinen commented Jan 30, 2018

Are you using Ubuntu, Hombrew or the official qt.io Qt5 ?

@piever
Copy link
Author

piever commented Jan 30, 2018

I installed QML libraries on my ubuntu machine using this command:

sudo apt-get -y install cmake cmake-data qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtquick-dialogs qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qmlscene qt5-default

@piever
Copy link
Author

piever commented Feb 14, 2018

Update: I've noticed that, at least on Gtk, the GR plot saved as svg displays correctly as a GtkImage. I was wondering whether it's possible to change the JuliaDisplay type in QML to use svg format rather than png to display the plot. In Plots.jl language that would be mimeformat "image/svg+xml" rather than "image/png". If you believe that for some backends png is better (which may well be) there could be an attribute of JuliaDisplay that allows the user to choose between svg and png.

barche added a commit that referenced this issue Feb 18, 2018
@barche
Copy link
Collaborator

barche commented Feb 18, 2018

Well, this was easier than I thought, so now it uses SVG if available and falls back to PNG otherwise. Probably some config options would be good to have, as well as a translation of the Julia MIME type to Qt so all Qt image formats would be supported automatically.

The plots example in master automatically picks this up.

@jheinen
Copy link

jheinen commented Jun 19, 2018

In the meantime, you can use native GR/Qt graphics with QML, as shown in this GR example.
qml gr_on_ubuntu

So, there is no need for PNGs or SVGs to display graphics in QML. The above method is much faster!

barche pushed a commit to JuliaGraphics/jlqml that referenced this issue Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants