-
Notifications
You must be signed in to change notification settings - Fork 35
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
Integration of the GR Qt device driver #23
Comments
OK, so all is needed is a julia function returning the correct string? If so, this should be a breeze to add. Regarding the widget, it seems that So I think we can get away with passing just the One thing that worries me is that the |
Sounds good - I'll check this.
The environment ( |
I made some tests and it turns out that we can obtain all necessary information using the
So we just need the |
I have added a @tbreloff I wonder if this is generic enough to use in Plots.jl for any backend that supports |
Thank you for the commit. I tried the following example: ENV["QSG_RENDER_LOOP"] = "basic"
using CxxWrap # for safe_cfunction
using QML
using GR
qmlfile = joinpath(dirname(Base.source_path()), "qml", "gr.qml")
# Called from QQuickPaintedItem::paint with the QPainter as an argument
function paint(p)
ENV["GKSwstype"] = 381
ENV["GKSconid"] = "0x"hex(p)
histogram(randn(10000))
return
end
# Convert to cfunction, passing the painter as void*
paint_cfunction = safe_cfunction(paint, Void, (Ptr{Void},))
# paint_cfunction becomes a context property
@qmlapp qmlfile paint_cfunction
exec() ... but I get an error:
Do you have any idea? |
Hmm, did you run |
@barche : Awesome. Now it works: ENV["QSG_RENDER_LOOP"] = "basic"
using CxxWrap # for safe_cfunction
using QML
using GR
qmlfile = joinpath(dirname(Base.source_path()), "qml", "gr.qml")
# Called from QQuickPaintedItem::paint with the QPainter as an argument
function paint(p)
ENV["GKSwstype"] = 381
ENV["GKSconid"] = split(repr(p), "@")[2]
histogram(randn(10000))
return
end
# Convert to cfunction, passing the painter as void*
paint_cfunction = safe_cfunction(paint, Void, (Ptr{Void},))
# paint_cfunction becomes a context property
@qmlapp qmlfile paint_cfunction
exec() Will provide a more challenging example in the GR example section soon ... @tbreloff: GR goes interactive before our QtTerm and JSTerm is finished ... |
Allright, great news! I assume I need to checkout GR to try this? Also, regarding interactivity, I think it would be nice to pass along mouse events from within the graph area (highlight a curve when the mouse is over it, allow selecting a curve, things like that). Would that be possible, and what would be required from the QML side? |
Yes - this only works with GR master. I'll check what's possible regarding interactivity (mouse move events, etc.) ... |
Just tried on OS X, but even after
|
Sorry - I'll have to create a new pre-compiled binary for OSX first. I currently don't have access to the OSX build host - I'll be back in office on Tuesday and let you know ... I am doing all these QML tests with a full GR installation (in |
@barche : How can I obtain the width/height of the current drawable: function paint(p)
ENV["GKSwstype"] = 381
ENV["GKSconid"] = split(repr(p), "@")[2]
plt = gcf()
w, h = ??? # need help here
plt[:size] = (w, h)
histogram(randn(10000))
return
end |
I was just about to push an updated example, asking how to make the plot follow the window size, but you just answered that question. See the updated gr.jl example: dev = device(p)
plt = gcf()
plt[:size] = (width(dev), height(dev)) The paint function argument Now that my son relinquished the computer, I could test this on Arch using the gr-git AUR package, it is amazingly fast! |
(Continuing from #27 (comment), I think this is the more approptiate issue for this) |
The |
I'm also facing (like @barche ) GKS: Qt5 support not compiled in with Any idea? |
It seems the latest macOS GR binaries are not compiled with Qt5 support, I still get the same message. @jheinen can you confirm that? |
Yes - as we build GR from source we didn't notice that Qt5 is missing in the binary distribution. I'm looking for a solution. It's somehow difficult, because our build system is (intentionally) based on macOS X 10.9. We probably need a special build here ... |
@barche , @scls19fr : Please checkout GR master and rebuild using If that fails - I linked the plugin against a Qt 5.7 (built from source) on a OS X Mavericks system - I have to think about another solution. Although I also have a ready-to-use macOS Sierra version, I would prefer to use one(!) version for all systems, which always worked fine (so far). Which Qt5 distribution are you using? |
@jheinen I get the following error:
I am using the homebrew version of Qt (5.8.0 currently). Maybe a solution would be to submit a brew file to the homebrew project for GR? |
I rebuilt with the original export DYLD_FRAMEWORK_PATH=/Users/jheinen/.julia/v0.5/Homebrew/deps/usr/Cellar/qt/5.8.0_2/Frameworks This worked fine on macOS Sierra. We probably can automate this, e.g.: |
I found out, how to obtain the path information for the Qt Frameworks. But, the environment has to be set before starting Julia. @barche : Do you have any idea how to proceed? function initqt()
try
@eval import Homebrew
if Pkg.installed("Homebrew") != nothing
qt = Homebrew.prefix("qt")
path = joinpath(qt, "Frameworks")
if isdir(path)
ENV["DYLD_FRAMEWORK_PATH"] = path
println("Using Qt ", splitdir(qt)[end], " at ", qt)
end
end
end
end |
I think it should be possible to set the rpath during the GR build. However, for O X and to ensure the GR and Qt binaries are compatible, having both available in homebrew would be the most elegant solution. Is the GR build hard to automate? If not, writing a script for homebrew should be easy, especially since homebrew probably has the dependencies require by GR? If GR is built by homebrew, the paths issue will be dealt with automatically. |
Please checkout |
Closing this because QT5 is not longer used. |
Great package!
I would like to directly access the
QQuickPaintedItem
instance within the GR Qt driver. This would allow me to use native Qt drawing commands instead of displaying a pre-rendered image, which is not fast enough.Fur this purpose, the GR Qt driver needs access to the Qt drawable (widget) to obtain the width / height and the vertical / horizontal resolutions (
logicalDpiX/Y
). That latter is not absolutely necessary.Right now, we encode the address of a given widget / painter in our applications into a "connection identifier", which is then passed to the GR driver using an environment variable (
GKSconid
). Would be great to get similar information fromQML.jl
- probably as a string containing thoseQObject
pointers separated by "!" (%p!%p
).The
width()
andheight()
methods seem to be available for theQQuickPaintedItem
- I will see how to avoid thelogicalDpiX/Y
methods, which don't seem to be available.The text was updated successfully, but these errors were encountered: