Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOptimize clipping calls #1661 #1662
Conversation
Basically looks good to me. I'm glad that everything still has control over it's clipping rectangle, even if it doesn't set it. |
return base.GetClippingRect(); | ||
} | ||
|
||
return new OxyRect(0, 0, double.PositiveInfinity, double.PositiveInfinity); |
This comment has been minimized.
This comment has been minimized.
VisualMelon
Sep 20, 2020
Contributor
Should we introduce a standard Everything
OxyRect (like DataPoint.Invalidate
) to which we can compare in the code that sets the clipping rectangle to check it isn't an 'Everything' OxyRect?
Also, the ImageSharp render context won't cope with out-of-bounds clipping rects; I should probably fix that. It also looks like it blits back too much of the clipped-buffer... I should probably fix that too.
This comment has been minimized.
This comment has been minimized.
VisualMelon
Sep 20, 2020
Contributor
Thinking about it further, that would be useful if GetClippingRect
where moved to PlotElement
, but might also create confusion if it can't be used to splat a rectangle over the whole screen when passed as an argument to a drawing method (which I happen to do in some code I have, though I can't remember why). Perhaps a better option would be to use PlotModel.PlotBounds
.
This comment has been minimized.
This comment has been minimized.
Jonarw
Sep 20, 2020
Author
Member
Should we introduce a standard Everything OxyRect (like DataPoint.Invalidate) to which we can compare in the code that sets the clipping rectangle to check it isn't an 'Everything' OxyRect?
Good idea!
Also, the ImageSharp render context won't cope with out-of-bounds clipping rects
Actually I guess it doesn't have to when we implement your first suggestion.
Thinking about it further, that would be useful if GetClippingRect where moved to PlotElement, but might also create confusion if it can't be used to splat a rectangle over the whole screen when passed as an argument to a drawing method (which I happen to do in some code I have, though I can't remember why). Perhaps a better option would be to use PlotModel.PlotBounds.
I am not quite sure I get your point here? We do clip to plot bounds anyway here, so out-of-bounds clipping rects will be trimmed down here.
This comment has been minimized.
This comment has been minimized.
VisualMelon
Sep 20, 2020
•
Contributor
That last comment was a bit jumbled, I shouldn't worry about; trimming should cover everything smartly. (I somehow missed it was already being done)
|
||
foreach (var plotElement in plotElements) | ||
{ | ||
var currentClippingRect = (plotElement as ITransposablePlotElement)?.GetClippingRect(); |
This comment has been minimized.
This comment has been minimized.
VisualMelon
Sep 20, 2020
Contributor
Is there any reason we shouldn't move GetClippingRect
to PlotElement
? It doesn't make sense for this to be restricted to transposable elements.
This comment has been minimized.
This comment has been minimized.
VisualMelon
Sep 20, 2020
Contributor
I'm a bit unsure that Annotation
should implement ITransposablePlotElement
directly (Series
doesn't). TileMapAnnotation
, for example, isn't transpoable, and we have to work around that in ExampleLibrary.Utilities.PlotModelUtilities
.
This comment has been minimized.
This comment has been minimized.
Jonarw
Sep 20, 2020
Author
Member
Is there any reason we shouldn't move GetClippingRect to PlotElement? It doesn't make sense for this to be restricted to transposable elements.
I can remember considering this briefly, but for some reason I can't remember I decided against it. But if I think about it now it actually does make a lot of sense, so I'll give it a try.
I'm a bit unsure that Annotation should implement ITransposablePlotElement directly (Series doesn't). TileMapAnnotation, for example, isn't transpoable, and we have to work around that in ExampleLibrary.Utilities.PlotModelUtilities.
Well Series
doesn't even have XAxis
and YAxis
properties, which Annotation
does have. I guess we could introduce a IXyAxisPlotElement
and make ITransposablePlotElement
inherit from this. Annotation
would then only implement IXyAxisPlotElement
and we'd have also have TransposableAnnotation
. I'll give it a try and see how it looks.
So this went a bit further than planned, but I do think the design makes more sense now. Basically I realized that it can be problematic that the |
Should we disable/comment out the |
@Jonarw feel free to disable them for the moment, but I take it there is no reason your changes make it unviable? I'll and get some stuff done tomorrow (e.g. review this, tidy up the margin PR, fix maps): I'm a bit busy today. |
Jonarw commentedSep 20, 2020
Fixes #1661.
Checklist
Changes proposed in this pull request:
Render
methods ofSeries
andAnnotation
sDrawClippedXxx()
extensionsRemarks
PathAnnotation.ClipText
property for obvious reasons was broken by these changes. As it didn't quite seem to fit the overall design anyway and appears not to be very widely used, I decided to remove it. The only place that actually used this property was the Train Schedule example. As I quite liked this example I fixed it using anAxis
for the station labels, which seems more sensible to me anyway.CandleStickAndVolumeSeries
could only be fixed by a rather ugly hack. If anything, this indicates to me that this series violates some of the design principles the library is built around, so I applied the hack and marked it as obsolete with the recommendation to use separateCandleStickSeries
andVolumeSeries
instead.Annotation
s could return different clipping rectangles depending on whether you useAnnotation.GetClippingRect()
or theITransposablePlotElement.GetClippingRect()
extension. As this is not an ideal situation, I slightly changed the design here to make it more consistent.@oxyplot/admins