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

GLVisualize backend #93

Closed
tbreloff opened this issue Dec 18, 2015 · 13 comments
Closed

GLVisualize backend #93

tbreloff opened this issue Dec 18, 2015 · 13 comments

Comments

@tbreloff
Copy link
Member

cc: @dlfivefifty @SimonDanisch First PR is merged in dev! I'll collect a TODO list and any issues/progress here and in the comments.

@tbreloff
Copy link
Member Author

A long way to go, but this is the first time I've been able to see something on screen!

glvisualize(); x = 1:50; y=x; f(x,y) = sin(x)+cos(y)
contour(x,y,f,fill=true)

tmp

@tbreloff
Copy link
Member Author

I'll be honest, I'm having trouble understanding the right way to add components. Maybe you could supply a few bare-minimum examples (using GLVisualize, not Plots) of how to do a few basic plots:

  • dots
  • lines
  • text
  • how to change colors (can it be a different color for each dot/line?)
  • how to change sizes
  • how to programatically set the view area so the whole plot is shown without needing mouse commands
  • anything else basic you can think of...

@dlfivefifty
Copy link
Contributor

Figured out how to do dots:

using GLVisualize,GLAbstraction, GeometryTypes
window, renderloop = glscreen()
pts=[Point(0.1f0,0.2f0,0.3f0),Point(0.1f0,0.2f0,0.4f0)]
view(visualize(pts))
@async renderloop()

On 19 Dec 2015, at 2:12 AM, Tom Breloff notifications@github.com wrote:

I'll be honest, I'm having trouble understanding the right way to add components. Maybe you could supply a few bare-minimum examples (using GLVisualize, not Plots) of how to do a few basic plots:

dots
lines
text
how to change colors (can it be a different color for each dot/line?)
how to change sizes
how to programatically set the view area so the whole plot is shown without needing mouse commands
anything else basic you can think of...

Reply to this email directly or view it on GitHub #93 (comment).

@dlfivefifty
Copy link
Contributor

Here does different colours. Note that if you call view(visualize..) after the @async renderloop() it adds to the current plot, so that should support plot! commands. @SimonDanisch https://github.com/simondanisch had a way to clear the current plot, which could be used for regular plot() commands. I think its not possible to have more than one window at the same time, though.

using GLVisualize,GLAbstraction, GeometryTypes,Colors
window, renderloop = glscreen()
pts=[Point(0.1f0,0.2f0,0.3f0),Point(0.1f0,0.2f0,0.4f0),Point(0.2f0,0.1f0,0.3f0),Point(0.f0,0.f0,0.f0)]
view(visualize(pts[1:2];color=RGBA{Float32}(1.,0.,0,1.)))
view(visualize(pts[3:4];color=RGBA{Float32}(0,1.,0,1.)))
@async renderloop()

On 19 Dec 2015, at 9:36 AM, Sheehan Olver solver@mac.com wrote:

Figured out how to do dots:

using GLVisualize,GLAbstraction, GeometryTypes
window, renderloop = glscreen()
pts=[Point(0.1f0,0.2f0,0.3f0),Point(0.1f0,0.2f0,0.4f0)]
view(visualize(pts))
@async renderloop()

On 19 Dec 2015, at 2:12 AM, Tom Breloff <notifications@github.com mailto:notifications@github.com> wrote:

I'll be honest, I'm having trouble understanding the right way to add components. Maybe you could supply a few bare-minimum examples (using GLVisualize, not Plots) of how to do a few basic plots:

dots
lines
text
how to change colors (can it be a different color for each dot/line?)
how to change sizes
how to programatically set the view area so the whole plot is shown without needing mouse commands
anything else basic you can think of...

Reply to this email directly or view it on GitHub #93 (comment).

@mmagnuski
Copy link

This looks great!

@SimonDanisch
Copy link
Member

Sorry, I put all my work into releasing GLVisualize currently.
Here are a few examples:

#Circles
    positions = Point2f0[....]
    view(visualize(positions,
        shape=CIRCLE,
        style=Cint(OUTLINED)|Cint(FILLED) # not necessary in next2 anymore
        color=RGBA{Float32}/Vector{RGBA{Float32}},
        stroke_color=RGBA{Float32}/Vector{RGBA{Float32}},
        scale= Vec2f0
    ), method=:orthographic_pixel)

function draw(img::GLVisualizeBackend, prim::LinePrimitive)
    N = length(prim.points)
    N <= 1 && return
    points = Point2f0[absolute_native_units(img, p) for p in prim.points]
    if N == 2 # currently a workaround, partly fixed in next2 branch
        a,b = points
        ab = b-a
        points = vcat(a-(ab*0.00001f0),a,b,b+(ab*0.00001f0))
    end
    view(visualize(Signal(points), :lines,
        color=RGBA{Float32}/Vector{RGBA{Float32}},
        thickness=Float32
    ), method=:orthographic_pixel)
end

function Compose.draw(img::GLVisualizeBackend, prim::RectanglePrimitive)
    positions=Point2f0[...]
    view(visualize(positions,
        shape=RECTANGLE
       style=Cint(OUTLINED)|Cint(FILLED) # not necessary in next2 anymore
        scale=Vec3f0,
        color=RGBA{Float32}/Vector{RGBA{Float32}},
        stroke_color=RGBA{Float32}/Vector{RGBA{Float32}},
        stroke_width=Float32,
    ), img.screen, method=:orthographic_pixel)
end


function Compose.draw(img::GLVisualizeBackend, prim::Compose.BitmapPrimitive)
    xyz = Vec3f0(...)
    scale = Vec3f0(...)
    view(visualize(::Union{Image/Matrix{Color}}, model=translationmatrix(xyz)*scalematrix(scale)), method=:orthographic_pixel)
end

function Compose.draw(img::GLVisualizeBackend, prim::Compose.TextPrimitive)
    pos     = Vec2f0(...)
    s   = Vec3f0(..., 1)
    obj     = visualize(::AbstractString, model=scalematrix(s), color=RGBA{Float32})
    bb    = boundingbox(obj).value
    w,h,_   = width(bb)
    x,y,_ = minimum(bb)
    pos     -= Point2f0(x, y)
# a lot of noise, positioning the text like Compose wants to have it.
    transmat = eye(Mat{4,4,Float32})
    if prim.rot.theta != 0.0
        pivot = Vec3f0(absolute_native_units(img, prim.rot.offset), 0)
        rot = GLAbstraction.rotationmatrix_z(Float32(-prim.rot.theta))
        transmat *= translationmatrix(pivot)*rot*translationmatrix(-pivot)
    end
    if prim.halign != Compose.hleft || prim.valign != Compose.vbottom
        if prim.halign == Compose.hcenter
            pos = (pos[1] - (w/2f0), pos[2])
        elseif prim.halign == Compose.hright
            pos = (pos[1] - w, pos[2])
        end
        if prim.valign == Compose.vcenter
            pos = (pos[1], pos[2] - h/2f0)
        elseif prim.valign == Compose.vtop
            pos = (pos[1], pos[2] - h)
        end
    end
    transmat *= translationmatrix(Vec3f0(pos..., 0))
    GLAbstraction.transformation(obj, transmat)
    view(obj, img.screen, method=:orthographic_pixel)
end

Sorry if this doesn't work right away, I couldn't test this, since I need to leave now!

There are inconsistencies, like that lines need to be supplied as a Signal, which are fixed in the next2 branch of GLVisualize. Next2 is nearly feature complete, but still has a few bugs and is not fully tested yet, which is where all my work is going to currently.

Here are 2 issues with a little bit of troubleshooting:
JuliaGL/GLVisualize.jl#46
JuliaGL/GLVisualize.jl#47
And there was an issue due to a change in GeometryTypes master, so when you do Pkg.update(), you might need to checkout another commit in GeoemtryTypes:

cd GeometryTypes
git checkout master
git checkout 762f23a14528e5085d81cfb3659da321f9e85786

Best,
Simon

@SimonDanisch
Copy link
Member

in the future, this is the way to go:
visualize((Primitive, Positions)), where you can leave out the position.
Primitive can be most types in GeometryTypes (Circle, Rectangle, Cube, etc), 3D Meshes and unicode signs as Chars...

@tbreloff
Copy link
Member Author

I know that GLVisualize has been improving daily... I'm wondering how stable the interface is at this point. If we implement the backend code for Plots, will it stop working next week? I don't want to sink too much time into it if everything will still be changing. (thanks for the monster effort on that @SimonDanisch )

@SimonDanisch
Copy link
Member

It should be quite stable ;)
At some point you might want to target what I'm talking about in JuliaGeometry/GeometryTypes.jl#46, but that's not there yet and it won't replace the old API (it's rather another layer that the GLVisualize API will target) ;)
How to update and draw stuff as fast as possible might change slightly in the future.
If well done, the code that is specific to GLVisualize should be very short anyways!
Please don't hesitate to open issues or write me directly! I'm definitely willing to help :)

@dlfivefifty
Copy link
Contributor

I started fixing the backend, I'll finish that up and make a pull request

Sent from my iPhone

On 11 Mar 2016, at 01:47, Simon notifications@github.com wrote:

It should be quite stable ;)
At some point you might want to target what I'm talking about in JuliaGeometry/GeometryTypes.jl#46, but that's not there yet and it won't replace the old API (it's rather another layer that the GLVisualize API will target) ;)
How to update and draw stuff as fast as possible might change slightly in the future.
If well done, the code that is specific to GLVisualize should be very short anyways!
Please don't hesitate to open issues or write me directly! I'm definitely willing to help :)


Reply to this email directly or view it on GitHub.

@tbreloff tbreloff added enhancement improving existing functionality help wanted labels May 4, 2016
@tbreloff
Copy link
Member Author

i just cleaned up the glvisualize backend code. I think we could tackle this in a similar fashion to GR. Everything gets drawn all at once in the gl_display method. I started it off with the same functionality as before (surface plots), and was able to install and view with:

using Plots; glvisualize(); surface(rand(100,20))

Anyone want to hack on this during JuliaCon?

@SimonDanisch
Copy link
Member

Awesome!
Yess, I'm all in! :)
I'll be there starting tomorrow and I'll leave on 3rd of June!
I have to prepare my talk until the 22nd, but afterwards, hacking this will be one of my top priorities (and talking about Visualize IR and RecipeBase )
Spoiler, I'm working on some GUI:
image

@tbreloff
Copy link
Member Author

See: #374

@tbreloff tbreloff added GLVisualize and removed enhancement improving existing functionality help wanted labels Sep 7, 2016
anowacki added a commit to anowacki/Plots.jl that referenced this issue Jan 6, 2017
Rather than specifying a specific typeface, set the font
*family* in the `family` field of `Font` as `sans-serif`
by default.

Fixes JuliaPlots#593.
t-bltg pushed a commit that referenced this issue Oct 6, 2022
t-bltg added a commit that referenced this issue Oct 6, 2022
* use Dates

* Add compat for RecipesBase

* Fix badges

* Plots test

* Fix travis

* Forgot using

* Update .travis.yml

Co-Authored-By: Anshul Singhvi <asinghvi17@simons-rock.edu>

* Use ds/rewrite

* Try with --project


Credit: Fredrik Ekre

* Use latest stable julia version

* Allow failures on MacOS

* Docs deployment

* Literate + enable deploy

* Update Project.toml

* fix missing comma

* Fix error

* try fixing repo name

* small change to trigger CI

* play better with Literate

* allow type recipes for `Number`s in arrays and surfaces

* small fixes

* skip maybestrings

* fix ambiguity

* Add badge

* Fix build badge link

* Show status only for master branch

* Fix README docs link

* remove subdomain

* Create TagBot.yml

* fix surface type recipe

* bump version

* fix error for grouping

* bump version

* further grouping fixes

* bump version

* fix plotting functions

* bump version

* downgrade version

* fix plotting rowvector of functions

* bump version

* support parametric type in `@userplot`

* add docs for parametric type in `@userplot`

* bump version

* fix grouping

* bump version

* bump PlotUtils compat

* bump version

* add zulip chat link to readme [skip ci]

* add zulip link [skip ci]

* Fix typo in docs

`AbstractArry` -> `AbstractArray`

* add hook after series decomposition (#52)

* add process_sliced_series_attributes!

* export process_slice_series_attrributes!

* remove `kw`

* Update Project.toml

[skip ci]

* Initial pass at CI

* Add script from Plots

* Update to MakieRecipes

* comment out artifact uploads

* Plots test

* CairoMakie tests

* Forgot using

* Update .travis.yml

Co-Authored-By: Anshul Singhvi <asinghvi17@simons-rock.edu>

* Use ds/rewrite

* Try with --project

* Another try

Credit: Fredrik Ekre

* Import examples from MakieRecipes

* add separately

* dev

* $(mktemp -d)

* Update .github/workflows/CI.yml

Co-Authored-By: Anshul Singhvi <asinghvi17@simons-rock.edu>

* use temp_for_test

* fix typo

* Update .github/workflows/CI.yml

* ensure that images are uploaded

* Pass a begin block to testset

* fix the macro

* seriously, I forgot .png?

* Update .travis.yml

* Fix split_attribute (#53)

* Fix a typo in the `recipe_pipeline!` constructor (#54)

* bump version

* fix time and period recipes

* bump version

* Fix typo (#56)

* implement `Base.axes` for `Volume`

* bump version

* Update group.jl

* implement iterate for Surface and Volume

* bump version

* use NaNMath log functions

* Add one_arg_shorthands macro (#73)

* Add one_arg_shorthands macro

* export one_arg_shorthands

* patch version [skip ci]

* Add :mesh3d as 3d series type (#62)

* 0.1.12 [skip ci]

* add compat for NaNMath

* dispatch processing of axis args on the plot object (#63)

* dispatch processing of axis args on the plot object

* Update type_recipe.jl

* Update type_recipe.jl

* Update type_recipe.jl

* add to API

* Update api.jl

* 0.1.13

* remove one_arg_shorthands macro (#74)

It didn't work out as intended

* 1.1.0

* more friendly error when x,y shape mis-match

* AbstractDict plot sorted

* more friendly error when x,y shape mis-match (#65)

* more friendly error when x,y shape mis-match

* don't touch z

* Update src/user_recipe.jl

Co-authored-by: Daniel Schwabeneder <daschw@disroot.org>

* switch to github-actions and update runtests.jl to run Plots test images

* update CI.yml

* keep makie tests

* move `signature_string` to RecipesPipeline

* minor version bump

* Revert "minor version bump"

This reverts commit 63c713b7808adf305484a9724cef9eabae2a0702.

* move `warn_on_recipe_aliases!` from Plots and add some `@nospecialize`

* add CompileBot

* minor version bump

* add precompile statements

* bump version

* add new line at end of file

* add recipe for list of NamedTuples

* add newline

* update tagbot action

* add recipe for list of NamedTuples

* move `warn_on_recipe_aliases!` from Plots and add some `@nospecialize`

* update tagbot action

* Fix broken histogram and stepbins plotting

* Increase package version to v0.2.1

* Update precompile_*.jl file

* add TestImages test dependency

* refine friendly error (#75)

* Update precompile_*.jl file

* don't stringify argument to `warn_on_recipe_aliases!` early
needs matching Plots changes

* minor release

* add `@nospecialize` annotations

* release

* update CompileBot

* update TESTCMD in CI

* fix TESTCMD in compilebot action

* Update precompile_*.jl file

* release

* Update README.md

[skip ci]

* don't catch all the MethodErrors (#87)

* don't catch all the MethodErrors

* remove `@show`

* 0.3.3 [skip ci]

* add mesh3d for GR

* v0.3.4

* Small improvement in inferrability (#82)

* 1.1.2 [skip ci]

* CI: tentative fix

* CI: add LinearAlgebra (#96)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>

* Test for error value from `apply_recipe` fallback. (#95)

* v0.3.5 [skip ci]

* Add `Downloads` test dependency

Complement #3766

* Remove try/catch needed for compatibility with Plots.jl v1.21.0 and earlier (#97)

* Improve groups perf from O(MxN) to O(M) (#98)

* Update MakieRecipes URL

* Update precompile_*.jl file (#91)

* v0.3.6 [skip ci]

* Revert try/catch for patch version

* v0.3.7 (#101) [skip ci]

* v0.4.0 (#102) [skip ci]

* Avoid Vararg UnionAll dispatch (#104)

* Avoid Vararg UnionAll dispatch

Fixes JuliaPlots/RecipesPipeline.jl#103

* fix fix

Co-authored-by: Simon Christ <SimonChrist@gmx.de>

* 0.4.1 [skip ci]

* move layout macro from plots (#85)

* 1.2.0 [skip ci]

* remove pct

* 1.2.1 [skip ci]

* Update Project.toml

* respect defaults for fillrange and ribbon (#106)

* respect defaults for fillrange and ribbon

* remove fillrange and ribbon handling from RecipesPipeline

* update ci

* set version

* Update CI.yml

* move documentation to gh-actions

* update run commands

* Update Documentation.yml

* Allow `NanMath` 1.0 - bump version (#108)

Co-authored-by: t-bltg <tf.bltg@gmail.com>

* Fix `unzip` for empty vectors (#110)

* 0.5.2 [skip ci]

* update url with https://docs.juliaplots.org/stable/generated/supported/#Keyword-Arguments (#89)

* Update precompile_*.jl file (#109)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>

* run  snoopcompile on pust to master only

* update compat bounds (#111)

* 0.6.0 [skip ci]

* Update precompile_*.jl file (#112)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>

* `SnoopCompile` labels

* use ssh key for `TagBot` (#91)

* fix julia scripts in markdown (#90)

* add missing language specification in md

* replace type with struct

* fix `SnoopCompile` (#113)

* update compat bounds

* run snoop on master only

* update precompile

* Update precompile_*.jl file (#114)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>

* 0.6.1 [skip ci]

* fix plotting `Union{Missing,Real}` arrays (#116)

* Update precompile_*.jl file (#115)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>

* 0.6.2 [skip ci]

* fix formatters (#118)

* 0.6.3 [skip ci]

* Update precompile_*.jl file (#117)

Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>

* Create invalidations.yml (#93)

This is based on https://github.com/julia-actions/julia-invalidations. Adding such checks came up in https://discourse.julialang.org/t/potential-performance-regressions-in-julia-1-8-for-special-un-precompiled-type-dispatches-and-how-to-fix-them/86359. I suggest to add this check here since this package is widely used as a dependency.

* rework precompilation using `SnoopPrecompile` - document `@layout` (#94)

* document `@layout`

* rewok precompile statements using `SnoopPrecompile`

* add ci

* bump julia to `1.6` for failing CI

* 1.3.0

* more efficient `DefaultsDict` iteration (#121)

* bump julia version in `ci` (#122)

* 0.6.4

* Add methods to access separate keysets of the DefaultsDict (#124)

* bump version [skip ci]

* DefaultsDict - correctness and performance tweaks for large numbers of series (#126)

* 0.6.6 [skip ci]

* Fix a deprecated syntax in docs of macro `@recipe` (#95)

* fix broken docs

* remove

* remove un-needed files

* RP tests

Co-authored-by: Daniel Schwabeneder <daschw@disroot.org>
Co-authored-by: Sebastian Micluța-Câmpeanu <m.c.sebastian95@gmail.com>
Co-authored-by: Sebastian Micluța-Câmpeanu <31181429+SebastianM-C@users.noreply.github.com>
Co-authored-by: Anshul Singhvi <asinghvi17@simons-rock.edu>
Co-authored-by: Lirimy <31124605+Lirimy@users.noreply.github.com>
Co-authored-by: mtsch <matijacufar@gmail.com>
Co-authored-by: Simon Christ <SimonChrist@gmx.de>
Co-authored-by: JonasIsensee <jonas.isensee@web.de>
Co-authored-by: Michael Abbott <me@pseudomac>
Co-authored-by: Benoit Pasquier <4486578+briochemc@users.noreply.github.com>
Co-authored-by: Michael Krabbe Borregaard <mkborregaard@snm.ku.dk>
Co-authored-by: Adrian Dawid <dwd31415@users.noreply.github.com>
Co-authored-by: Moelf <proton@jling.dev>
Co-authored-by: Oliver Schulz <oschulz@mpp.mpg.de>
Co-authored-by: daschw <daschw@users.noreply.github.com>
Co-authored-by: Moelf <Moelf@users.noreply.github.com>
Co-authored-by: Jeremy Bejanin <jeremy.bejanin@gmail.com>
Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>
Co-authored-by: Tim Holy <tim.holy@gmail.com>
Co-authored-by: Nicholas Bauer <nicholasbauer@outlook.com>
Co-authored-by: Mike Keehan <21029749+mdkeehan@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Christopher Rackauckas <chrisrackauckas@gmail.com>
Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
Co-authored-by: Rafael Schouten <rafaelschouten@gmail.com>
Co-authored-by: MrHenning <5331081+MrHenning@users.noreply.github.com>
Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Ryan <25192197+singularitti@users.noreply.github.com>
Jonas-a-Zimmermann pushed a commit to Jonas-a-Zimmermann/Plots.jl that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants