-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Fix errorbar and bracket interaction with transform functions #3012
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b179c8d
replace scene_to_screen with plot_to_screen
ffreyer 8496772
consider input space for projection
ffreyer 54451ca
relax type constraints
ffreyer 4104697
remove print
ffreyer 893e538
update bracket
ffreyer 802614b
fix missing update of text positions
ffreyer 3be2826
update on trans_func and model
ffreyer 9eadfe8
update NEWS
ffreyer cd47b1e
fix interaction with model transformation
ffreyer 039ea28
add test
jkrumbiegel df90afe
Merge branch 'master' into ff/fix_errorbars
jkrumbiegel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,19 +187,18 @@ function _plot_bars!(plot, linesegpairs, is_in_y_direction) | |
|
||
scene = parent_scene(plot) | ||
|
||
whiskers = lift(plot, linesegpairs, scene.camera.projectionview, | ||
scene.camera.pixel_space, whiskerwidth) do pairs, _, _, whiskerwidth | ||
Comment on lines
-190
to
-191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With |
||
whiskers = lift(plot, linesegpairs, scene.camera.projectionview, plot.model, | ||
scene.px_area, transform_func(plot), whiskerwidth) do pairs, _, _, _, _, whiskerwidth | ||
|
||
endpoints = [p for pair in pairs for p in pair] | ||
|
||
screenendpoints = scene_to_screen(endpoints, scene) | ||
screenendpoints = plot_to_screen(plot, endpoints) | ||
|
||
screenendpoints_shifted_pairs = map(screenendpoints) do sep | ||
(sep .+ f_if(is_in_y_direction[], reverse, Point(0, -whiskerwidth/2)), | ||
sep .+ f_if(is_in_y_direction[], reverse, Point(0, whiskerwidth/2))) | ||
end | ||
|
||
screen_to_scene([p for pair in screenendpoints_shifted_pairs for p in pair], scene) | ||
return [p for pair in screenendpoints_shifted_pairs for p in pair] | ||
end | ||
whiskercolors = Observable{RGBColors}() | ||
map!(plot, whiskercolors, color) do color | ||
|
@@ -229,37 +228,53 @@ function _plot_bars!(plot, linesegpairs, is_in_y_direction) | |
linesegments!( | ||
plot, whiskers, color = whiskercolors, linewidth = whiskerlinewidths, | ||
visible = visible, colormap = colormap, colorrange = colorrange, | ||
inspectable = inspectable, transparency = transparency | ||
inspectable = inspectable, transparency = transparency, space = :pixel, | ||
model = Mat4f(I) # overwrite scale!() / translate!() / rotate!() | ||
) | ||
plot | ||
end | ||
|
||
function scene_to_screen(pts, scene) | ||
p4 = to_ndim.(Vec4f, to_ndim.(Vec3f, pts, 0.0), 1.0) | ||
p1m1 = Ref(scene.camera.projectionview[]) .* p4 | ||
projected = Ref(inv(scene.camera.pixel_space[])) .* p1m1 | ||
[Point2.(p[Vec(1, 2)]...) for p in projected] | ||
function plot_to_screen(plot, points::AbstractVector) | ||
cam = parent_scene(plot).camera | ||
space = to_value(get(plot, :space, :data)) | ||
spvm = clip_to_space(cam, :pixel) * space_to_clip(cam, space) * transformationmatrix(plot)[] | ||
|
||
return map(points) do p | ||
transformed = apply_transform(transform_func(plot), p, space) | ||
p4d = spvm * to_ndim(Point4f, to_ndim(Point3f, transformed, 0), 1) | ||
return Point2f(p4d) / p4d[4] | ||
end | ||
end | ||
|
||
function screen_to_scene(pts, scene) | ||
p4 = to_ndim.(Vec4f, to_ndim.(Vec3f, pts, 0.0), 1.0) | ||
p1m1 = Ref(scene.camera.pixel_space[]) .* p4 | ||
projected = Ref(inv(scene.camera.projectionview[])) .* p1m1 | ||
[Point2.(p[Vec(1, 2)]...) for p in projected] | ||
function plot_to_screen(plot, p::VecTypes) | ||
cam = parent_scene(plot).camera | ||
space = to_value(get(plot, :space, :data)) | ||
spvm = clip_to_space(cam, :pixel) * space_to_clip(cam, space) * transformationmatrix(plot)[] | ||
transformed = apply_transform(transform_func(plot), p, space) | ||
p4d = spvm * to_ndim(Point4f, to_ndim(Point3f, transformed, 0), 1) | ||
return Point2f(p4d) / p4d[4] | ||
end | ||
|
||
function scene_to_screen(p::T, scene) where T <: Point | ||
p4 = to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) | ||
p1m1 = scene.camera.projectionview[] * p4 | ||
projected = inv(scene.camera.pixel_space[]) * p1m1 | ||
T(projected[Vec(1, 2)]...) | ||
function screen_to_plot(plot, points::AbstractVector) | ||
cam = parent_scene(plot).camera | ||
space = to_value(get(plot, :space, :data)) | ||
mvps = inv(transformationmatrix(plot)[]) * clip_to_space(cam, space) * space_to_clip(cam, :pixel) | ||
itf = inverse_transform(transform_func(plot)) | ||
|
||
return map(points) do p | ||
pre_transform = mvps * to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) | ||
p3 = Point3f(pre_transform) / pre_transform[4] | ||
return apply_transform(itf, p3, space) | ||
end | ||
end | ||
|
||
function screen_to_scene(p::T, scene) where T <: Point | ||
p4 = to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) | ||
p1m1 = scene.camera.pixel_space[] * p4 | ||
projected = inv(scene.camera.projectionview[]) * p1m1 | ||
T(projected[Vec(1, 2)]...) | ||
function screen_to_plot(plot, p::VecTypes) | ||
cam = parent_scene(plot).camera | ||
space = to_value(get(plot, :space, :data)) | ||
mvps = inv(transformationmatrix(plot)[]) * clip_to_space(cam, space) * space_to_clip(cam, :pixel) | ||
pre_transform = mvps * to_ndim(Vec4f, to_ndim(Vec3f, p, 0.0), 1.0) | ||
p3 = Point3f(pre_transform) / pre_transform[4] | ||
return apply_transform(itf, p3, space) | ||
end | ||
|
||
# ignore whiskers when determining data limits | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Currently
space = :pixel
still includes model transformation (at least in GLMakie). Sinceplot_to_screen
deals with them now, they'd be included twice. To prevent that I'm overwriting model/transformation. I'm using transformation for series because model doesn't get passed down.