Author |
Topic  |
|
swhite
5 Posts |
Posted - 06 Sep 2005 : 19:27:37
|
I have a ChartView object that displays several different ChartPlots, but not all simultaneously. My user interface provides buttons that allow the user to switch between the ChartPlots, and the program responds to button presses by calling setChartObjEnable() with either OBJECT_ENABLE or OBJECT_DISABLE on each of the plot objects.
I also have a (subclass of) DataToolTip that listens for the selection of individual data points. My problem is that the DataToolTip appears to allow the selection of points from the disabled plots. The effect is that the user can sometimes click in an area of the graph that appears to contain no points, and yet manage to select an "invisible" point.
Is this a bug, or have I missed something?
As a workaround, I will try removing and adding the plot objects instead of disabling them, but this solution is not quite so neat.
Regards, Simon
|
|
quinncurtis
1164 Posts |
Posted - 07 Sep 2005 : 09:03:47
|
It is better to remove the plot objects from the ChartView chart object list, rather than disabling them.
Using the ChartView.AddChartObject and ChartView.DeleteChartObj (the delete is a misnomer, it really just removes the object from the ChartView's chart object list and does not delete it), is much more efficient because it does not require the software to search through an unlimited number of plots in order to identify the plot object, and then to look up whether or not it is enabled or disabled. It does not involve any more code than setting the chart objects enable or disable flag.
That said, the software should probably ignore disabled plots when doing a hit test on the object. This is a major change to the software because in order to remain consistent it requires modifying code in 5-10 classes, in 3 different version of the software. |
 |
|
swhite
5 Posts |
Posted - 08 Sep 2005 : 13:30:04
|
I'm now adding and deleting them and the program is working as I expected. The reason I said this was not so neat from my point of view is that I have to check whether the ChartView already contains the Plot before I add (or delete) it. I wouldn't want to add the same plot object twice, or attempt to delete an object that is not already there. Does the code already check for these conditions internally?
It seemed to me that this step would be unnecessary if the disabling worked as I had expected, but I now understand your argument about efficiency and having fewer objects to iterate through upon receipt of mouseEvents.
Thx |
 |
|
quinncurtis
1164 Posts |
Posted - 08 Sep 2005 : 14:44:16
|
When you use the ChartView.deleteChartObj method, if the object isn't found nothing bad happens. If you call ChartView.addChartObj twice for the same object, it will be entered twice into the ChartView chart object list, something you do want to avoid, but not something that will cause a crash. If you are not already keeping track some other way, then set/get the chart objects chartObjEnable flag to keep track of whether to object is in the ChartView chart object list. |
 |
|
|
Topic  |
|
|
|