Page 1 of 1

TCursor refresh bug

Posted: Tue Nov 15, 2011 10:36 am
by 16560328
Hi,

I have a problem with the cursor not working correctly after moving a form outside the screen (or mainform for MDI) and back.
The cursor will be visibly stuck but it is possible to move it around.
If you minimize the form and restore it the cursor has moved and is working again.
But as soon as you move it outside again it is bugged.

I have included a sample project where this happens.
Simply move part of the form outside the screen and back then try to use the cursor.

Is there a fix or workaround?

Delphi XE with Update 1, 15.0.3953.35171
TeeChart Pro v2011.03.30407 Win32

Re: TCursor refresh bug

Posted: Tue Nov 15, 2011 12:51 pm
by 16560328
Calling Repaint on the cursor fixes the problem.

But I'm not sure when to call it.

If I put it in the Cursor.OnChange the CPU use goes up to 10% when scrolling instead of 0-2%.
In the Form.OnPaint it is good for MDI but if the TChart goes off screen the paint event doesn't trigger.

Re: TCursor refresh bug

Posted: Tue Nov 15, 2011 1:08 pm
by 16560328
I ended up by calling it in the TChart.OnMouseEnter.

But I can see that it could fail if there are some non mouse events that change the form position or size.

Re: TCursor refresh bug

Posted: Wed Nov 16, 2011 11:36 am
by yeray
Hello Kjaran,

I think I reproduced it. Could you please confirm this is what you are suffering?
If I put another window partially covering the chart and the cursor, like here:
back.png
back.png (8.16 KiB) Viewed 8630 times
Then, when I take the chart back to the front and I try to drag the cursor tool, only the part that was hidden is repainted in the correct position:
move.png
move.png (25.48 KiB) Viewed 8636 times
If this is what you suffered, I could reproduce it with v2011.03 but not with the actual sources so it should be fixed with the next maintenance release. And the application doesn't seem to demand more CPU either.

Re: TCursor refresh bug

Posted: Wed Nov 16, 2011 12:16 pm
by 16560328
Hi Yeray

Yes this is what I was experiencing. I look forward to the next release then.

Kjaran

Re: TCursor refresh bug

Posted: Thu Feb 16, 2012 5:22 pm
by 16560328
Hi,

I have now updated to the "TeeChart Pro v2011.04.41118 32bit VCL" and indeed my original problem has been solved, many thanks. :)
And still using "Delphi XE with Update 1, 15.0.3953.35171".

But a new problem was introduced.

If I zoom the cursor again becomes hidden but responds to the mouse hovering and fires events etc.
But calling repaint, redraw, active on the cursor does not show it.
Instead if I unzoom it becomes visible again.

I have included a small sample project where this is possible.
A form with a TChart, TFastSeries with random data and a vertical TCursorTool.
If zoomed on the bottom 1/3 of the chart the cursor becomes hidden, but not on the top 1/3 (weird?).
The cursor in this sample becomes fixed by scrolling up or unzooming.
Zoom.png
TheZoomRectangle
Zoom.png (7.4 KiB) Viewed 8559 times
PostZoom_NoCursorVisible.png
Post zoom, the cursor is now hidden
PostZoom_NoCursorVisible.png (6.08 KiB) Viewed 8576 times
Is there a fix or workaround?

Re: TCursor refresh bug

Posted: Fri Feb 17, 2012 9:44 am
by 16560328
Hi,

Found a fix for my main project. For the OnScroll and OnZoom events I set the cursor series axis to automatic.
Chart1.LeftAxis.Automatic:= true;

This can be used, in my case, since the axis for the cursor is never shown.
But I guess in the cases where it is not this would still be an issue.

Kjaran

Re: TCursor refresh bug

Posted: Mon Feb 20, 2012 10:34 am
by narcis
Hi Kjaran,

I've made some tests with your project and found that the problem is not consistent and I don't even think it is a bug. Actually the cursor disappears for me when the zoom rectangle dimensions proportions are rather different from the chart rectangle proportions and therefore the zoom rectangle can not be exactly what you drew and hence sometimes the cursor being left out. Is this the behaviour you experienced?
Found a fix for my main project. For the OnScroll and OnZoom events I set the cursor series axis to automatic.
Chart1.LeftAxis.Automatic:= true;
Doing so would probably undo zoom/scroll in your chart.

Re: TCursor refresh bug

Posted: Mon Feb 20, 2012 1:56 pm
by 16560328
Hi NarcĂ­s,

The two screen-shots are actual shots of the chart. The only modifications I made was to crop the form.

The first screen-shot is while I'm holding the left mouse button down just before releasing it, the rectangle is the zoom rectangle drawn by teechart.
The second is just after releasing the mouse button to zoom in.

The problem as you say is not consistent but this rectangle, on my machine at least, always renders the cursor invisible.
I've only found rectangles that hide the cursor that are very close to or go below the bottom axis.

"Doing so would probably undo zoom/scroll in your chart."
This sample project is simply the smallest code I found to reproduce my error, and would indeed in this sample undo the zoom.
In my actual application the cursor uses a series that is hidden and the axis is never visible.
Setting the axis to automatic solves the cursor visibility problem, and has no side effects since the axis is already hidden.

I thank you for looking into this matter but I'm satisfied with the current workaround and consider this solved.

Kjaran

Re: TCursor refresh bug

Posted: Tue Feb 21, 2012 9:41 am
by yeray
Hi Kjaran,

I'm happy to hear you are satisfied with the workaround you found, but I've added it to the defect list anyway since I could reproduce it (TV52016047).