TAChart: some cleaning up in Draw() methods
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
In ~115881, there is an update_ver2.diff patch attached, which - among others - added "if IsEmpty then exit" statements to TLineSeries.Draw() and TPolarSeries.Draw(). This was needed, because these series weren't working properly with TCalculatedChartSource - TCalculatedChartSource returns XCount = YCount = MaxInt when it is empty, so TLineSeries and TPolarSeries were trying to perform some actions in a loop from 0 to MaxInt-1 (or MaxInt-2). Adding the "if IsEmpty then exit" statements solved the problem.
On the other hand, performing drawing on series, that are not active, is useless (this can occur, because Draw() is a public method) - this was already discussed in ~114745 (see last lines).
Currently, some series exit their Draw() methods when empty, some other when not active, and some other perform both checks. So I reviewed all the series to make some cleaning up: it's useful to check for "not Active", and it's also good to check for "IsEmpty" in all series, to avoid arising problems like with TCalculatedChartSource (I'm sure that nobody will test every future change, in any of the Draw() methods, by attaching the series to TCalculatedChartSource).
So I'm attaching a patch, which just introduces the same "if IsEmpty or (not Active) then exit" check in almost all series (there are few exceptions from this rule - see below). As a consequence, checks for "Count = 0" were replaced with checks for "IsEmpty"; although this may seem to be equivalent, IsEmpty() is a virtual method, which may be overridden in descendant classes - so there should be no hardcoded checks for just "Count = 0".
Exceptions:
-
In TExpressionSeries.Draw() and TExpressionColorMapSeries.Draw(), "IsEmpty" cannot be determined before the "SetupParser" call. And, directly below the "SetupParser" call, there is an "inherited" call - which calls "IsEmpty" internally.
-
In TFuncSeries.Draw(), "IsEmpty" is not initially called, to handle csDesigning state. But, below, there is an "inherited" call - which calls "IsEmpty" internally.
-
In TParametricCurveSeries.Draw(), "IsEmpty" is not initially called, to handle csDesigning state - the "IsEmpty" call is below.
Mantis conversion info:
- Mantis ID: 35618
- Build: 61262
- Version: 2.1 (SVN)
- Fixed in revision: 61268 (#95ca9460)