Canvas does not allow drawing..

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Brino
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: dublin

Canvas does not allow drawing..

Post by Brino » Fri Apr 16, 2004 3:22 pm

I am getting a "canvas does not allow drawing" exception from TCanvas.RequiredState procedure in graphics.pas in the VCL...

it is occuring while i am running a realtime plot with 1000+ points...
the points are being drawn onto the Chart.Canvas in a similar fashion to TFastLineSeries (overriding NotifyNewValue procedure) through a separate thread to the main application thread...

the exception seems to get raised randomly during a run... though it also seems more frequent when the mouse is moving (main app thread maybe interfering with the drawing of the chart...)

any suggestions greatly appreciated....

edulopes
Newbie
Newbie
Posts: 2
Joined: Fri Nov 15, 2002 12:00 am
Location: Brazil
Contact:

I have the same problem

Post by edulopes » Fri Apr 16, 2004 3:43 pm

I have the same problem, and I use Teechart 5.03 with Delphi7. Is this your case?

I'd like to know if this problem have a solucion in another version of TeeChart.

Brino
Newbie
Newbie
Posts: 5
Joined: Fri Nov 15, 2002 12:00 am
Location: dublin

Post by Brino » Fri Apr 16, 2004 3:56 pm

it's TeeChart 5.02 with Delphi 6...

On delphi faq's it is said that this is unsafe code as accessing the one canvas from different threads will cause problems - i.e. potentially the canvas will attempt to be drawn by both threads simultaneously

it is suggested to use TCanvas.Lock and TCanvas.Unlock while drawing ...
and this might solve the problem..

But TChart doesn't seem to allow you lock the chart for drawing.... as the Chart.Canvas is a TCanvas3D and doesn't directly inherit from the VCL TCanvas, and i don't know how i could prevent a thread from accessing the canvas ... (maybe i'm barking up the wrong tree here..)

etc.etc..

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Apr 19, 2004 12:35 pm

Hi.

One thing that might work would be to disable the chart drawing while you're modifying series data points. In short, set chart AutoRepaint property to false before you start modifying series values and then at the end (when you need a redraw), set the AutoRepaint back to true and refresh the chart by calling the TChart.Repaint method. I've discussed some of the problems with real-time plotting in one of my articles. Check the following article
Marjan Slatinek,
http://www.steema.com

edulopes
Newbie
Newbie
Posts: 2
Joined: Fri Nov 15, 2002 12:00 am
Location: Brazil
Contact:

With T7 I don't have problem

Post by edulopes » Fri Apr 30, 2004 7:48 pm

Well, I don't get a solution using AutoRepaint = False .....

but I've tested the T6 and T7 and with T6 the problem still happend
with T7 the problem disappeared!

p.s: The problem is not the number of points ploted, but the number of charts that I try to plot in the screen.

Post Reply