-
Notifications
You must be signed in to change notification settings - Fork 757
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
classlib: Plotter: extend tick labels #5942
classlib: Plotter: extend tick labels #5942
Conversation
6160771
to
a488f87
Compare
52ddc9e
to
30d0626
Compare
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.
Thanks @mtmccrea ! I have some cosmetic comments/questions. I'm dismissing my comments for now :)
This comment was marked as outdated.
This comment was marked as outdated.
I think it is completely fine to have a discussion like this before a final version. |
OK, I would consider this "review-ready" at this point 😆. I've updated the topic post with some details and examples. As mentioned there, I won't get to complete docs before RC2, but I think the interface is stable at this point (pending any feedback), so could go into the RC. And I plan to do a hefty cleanup of the commit history once the discussion concludes here. I've resolved a number of the Conversations above, but left some open in case you'd like to respond, otherwise feel free to Resolve them if you're satisfied. Thanks! |
150ea1e
to
f79a73f
Compare
Thanks everyone for the efforts you are putting in on this! I’m just a bit worried that you may be overdoing it. As far as I am concerned, the .labelOffset functionality in SC 3.12 was good enough, it just wasn’t documented - and then it broke in 3.13 RC 1.
From: Marcin Pączkowski ***@***.***>
Sent: Wednesday, 4 January 2023 11:55
To: supercollider/supercollider ***@***.***>
Cc: sternsc ***@***.***>; Mention ***@***.***>
Subject: Re: [supercollider/supercollider] classlib: Plotter: extend tick labels (PR #5942)
@dyfer commented on this pull request.
________________________________
In SCClassLibrary/Common/GUI/PlusGUI/Math/PlotView.sc<#5942 (comment)>:
- gridRect = viewRect.insetBy(hinset, vinset) + [hshift, vshift, 0, 0];
- drawGrid.bounds = gridRect;
+ // First calculate vertical space needed for tick and axis labels
+ // to determine if X labels will be hidden based on the view height.
+ // (If so, Y labels that overhang vertically may need to also be hidden).
+
+ tkBHang = max(xTkBHang, yTkBHang);
+
+ // if there's label overhang, give it its margin
+ tkBMargin = if(tkBHang > 0) { labelMargin } { 0 };
+ tkTMargin = if(yTkTHang > 0) { labelMargin } { 0 };
+
+ // only the largest margin of all elements is needed
+ bottomMargin = maxItem([xAxMargin, borderMargin, tkBMargin]);
+
+ // add up all elements extending below the grid
My preference is to not include any manual non-standard formatting. I acknowledge that it looks better, but I believe even more strongly that (almost?) everything should be formatted automatically.
OTOH, the automatic liner<https://github.com/supercollider/supercollider/actions/runs/3832847520/jobs/6523627143#step:3:59> for the class library files (which is set to not cause CI to fail since some existing .sc files don't conform) does not seem to catch this as an issue. So... maybe this is acceptable?
—
Reply to this email directly, view it on GitHub<#5942 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAXQZNAOWQSYINC6FPLCE4DWQVJHFANCNFSM6AAAAAATI7OX5A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@sternsc So just as a heads up, your code will still likely need to be updated. Here's an example that recreates some of the things you missed about the previous version (in particular labelOffset, and strings appended to tick labels): // ~ Old Plotter replicated functionality: x labels at top, with strings appended
(
var gridHeight, freq = 22;
p = 101.collect({ |i| sin((i/1000)*2*pi* freq)}).plot;
gridHeight = p.plots[0].plotBounds.height;
p.setGridProperties(\x,
\labelAnchor, \topLeft,
\labelAlign, \left,
\labelOffset, 8 @ gridHeight.neg,
\labelAppendString, " xxx",
\constrainLabelExtents, true,
).setGridProperties(\y,
\labelAnchor, \bottomLeft,
\labelAlign, \left,
\labelOffset, 3 @ -3
);
) If you plan for your views to dynamically resize, you can make sure extreme tick label offsets stay in place this way: (
// Because use the view height to set the x tick label offset, update label offset on resize.
p.interactionView.onResize_({ |v|
var gridHeight = p.plots[0].plotBounds.height;
p.setGridProperties(\x, \labelOffset, 8 @ (gridHeight.neg+10))
});
) |
Settable now with, e.g., Size or Point.
add methods labelSize, labelAlign, labelAnchor optional constraints on label extents add labelAppendString property adjust tick label size when string is appended to label convert labelSize from inst var to method fix variable inlining refactor label space calc to its own method Plotter:-drawLabels update position WRT the grid bounds unify label padding between plotter and grid, simplify calc rename labelX/Y -> axisLabelX/Y enclose multi-conditional bool tests in function add convenience methods for drawing grid bounding lines add axis label font, check for gridOn vars before drawing bounding grid lines
axis labels aren't inherent in DrawGrid, so it's misleading to have them in the preview.
f79a73f
to
867b5f0
Compare
I've cleaned up the commit history. |
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've only found one typo.
All the rest is good, I think. You made a TODO-note in the code, it would be good to resolve further issues, but I think these are minor things. Thanks a lot!
font, fcolor); | ||
Pen.pop; | ||
}; | ||
this.draw; // draw the drid |
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.
drid -> grid
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.
(you can leave out the comment, it is redundant)
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.
Thanks for catching this. Removed.
Only set x axis label to units when numChannels < 4
a80865d
to
0de631b
Compare
Thanks to all!
Unfortunately I won’t have time soon to try the new code – I don’t have a build environment for all of SC set up and ready to go. Would it work to get only the relevant .sc files (Plotter, GridLines etc) from the latest version, and replace the ones in 3.12.2, just to try? If so, which files exactly?
From: Marcin Pączkowski ***@***.***>
Sent: Tuesday, 10 January 2023 22:28
To: supercollider/supercollider ***@***.***>
Cc: sternsc ***@***.***>; Mention ***@***.***>
Subject: Re: [supercollider/supercollider] classlib: Plotter: extend tick labels (PR #5942)
Thank you @mtmccrea<https://github.com/mtmccrea> for your work on this and @telephon<https://github.com/telephon> for the review.
@sternsc<https://github.com/sternsc> could you confirm that the changes here fix the issues you've encountered?
—
Reply to this email directly, view it on GitHub<#5942 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAXQZNDBRHIFAIR4NKXFJUDWRXH5DANCNFSM6AAAAAATI7OX5A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
For macOS and Windows you can download the builds from GitHub actions (see "details" next to the CI checks, or the "Checks" tab on top, then click "Summary" and find artifacts on the bottom right, after scrolling down).
If might. I'd try all the .sc files changed in this PR (see "Files changed" on top) and additionally the ones which were changed in #5161 (but of course taken from the branch in this PR). |
the first thing you can try to just copy the whole class library over. If there weren't any changes to kernel classes and primitives, it might just work. If it doesn't, you could try copy the GUI classes. |
I didn't suggest this since AFAIR there were some changes to the interpreter and when I tried using class library from a recent |
OK, thanks. I won’t have time to do this soon, I have confidence in the changes made and in the process, and I don’t want to hold up the next RC release, so don’t wait for me.
From: Marcin Pączkowski ***@***.***>
Sent: Wednesday, 11 January 2023 14:00
To: supercollider/supercollider ***@***.***>
Cc: sternsc ***@***.***>; Mention ***@***.***>
Subject: Re: [supercollider/supercollider] classlib: Plotter: extend tick labels (PR #5942)
the first thing you can try to just copy the whole class library over.
I didn't suggest this since AFAIR there were some changes to the interpreter and when I tried using class library from a recent develop on the SC 3.12 build it didn't work. But yes, this would typically be the first thing to try.
—
Reply to this email directly, view it on GitHub<#5942 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAXQZNFFPPBYUX7YTZXIFCDWR2VEXANCNFSM6AAAAAATI7OX5A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@sternsc here is code that reproduces the grids you showed in your previous post. Example Code
(Including behavior for update on resize). So I think the functionality you've described is covered here. |
Thanks for your kind example @mtmccrea , it looks great! Looking forward to it! |
Thanks so much @mtmccrea !
What do you think? Sorry for dragging this out! |
Yes spec unit auto label functionality was removed (IIRC, in response to the last PR). Some background: `3.12.2` default behavior:Just plotting a stereo buffer:
`3.13-rc` to achieve the old behavior (with new space padding):
Notice Moving forward:
If I'm not mistaken, @telephon authored the original approach, so may have thoughts on this. |
Yes, but it requires extra code.
I do think it should.
With this one I could go either way. I like the visual aspect of the "new" way, but it does take a bit more space around the plot. |
I'm fine either way, there is much improvement. |
13b6f87
to
10c5a51
Compare
10c5a51
to
470f687
Compare
OK thanks, I've made the units show by default (in the axis label—easy to change this default if we hear feedback from users in the RC). I've also added these methods to the docs. |
good! let us know when it is ready for merge. |
It's ready on my end :) |
Super, thanks for 3.13.0-rc2. I've tested the new Grid-related stuff and found the following:
I've been able to work my way around to this result by overriding .getParams and twiddling with calls to .appendLabel, as shown by this code excerpt from the end of ExponentialGridLines.getParams:
` All the linear stuff works fine and I have gotten the grids plotted as I like them. Thanks a lot for your work on this! Hope this is of some help. And I can live with overriding - you can't cater to everyone's preferences... |
Purpose and Motivation
This follows up #5161, in response to feedback about retaining previous functionality in how the tick labels are handled in
DrawGrid
.In particular this adds functionality so that you can achieve the same look as previous version of SC:
This PR is unfinished but as it's blocking the next RC, I'm posting it early so those involved can comment on what's been done so far. @dyfer @sternsc.This required basically a complete overhaul of how the new tick/axis label spacing is calculated so that everything resizes properly.
As such, I have a good amount of testing to do.This PR is now ready for review (I'll clean up the commit history at the final stage).
Depending on the timeline of the RC, documentation won't be the priority, but I'll submit that as a separate PR later if the RC makes it out before I get to it.
Here's a few examples of the new interface to set
Plot
andDrawDrid
properties fromPlotter
.The three above examples produce these plots:
Note that because I opted not to add convenience methods to
Plotter
that would allow direct access to setting grid properties at this time, that is accomplished with thePlotter:-setGridProperties
, which mimics the behavior ofPlotter:-setGridProperties:-setProperties
, in that it accepts a list of key-value pairs.The advantage is that setting multiple parameters (as is likely when customizing your grid) is more compact than multiple method calls to individual parameters for each axis. The downside is the user doesn't get the benefit of auto-complete for hints about to the available parameters. So I'll add a section to the docs in the future that will list the grid and plot parameters.
Types of changes
To-do list