Poly Line Drawing

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
dpatch
Newbie
Newbie
Posts: 19
Joined: Mon Mar 10, 2014 12:00 am

Poly Line Drawing

Post by dpatch » Wed Aug 06, 2014 10:45 pm

I decided to start another thread different from the "Line Drawing" thread. This one relates to the Canvas.PolyLine method instead of the Canvas.Line method. I am using TChart Pro version 2014.11.140512 32 bit VCL. Again, this code used to work before upgrading to version 2013......

I collect a set of X/Y points in an array through a series of Mouse Down events. In the mouse move event, I Call the PolyLine method to erase the last and redraw the new multi-vertex line with the last segment showing the "rubber band" effect. With this update (like the Canvas.Line method) the old line is not being XOR'd off the image. The following code is being used.

Any thoughts? Thanks in advance.

Code: Select all

          Chart1.Canvas.Pen.Color := clWhite;
          Chart1.Canvas.Brush.Style := bsSolid;
          Chart1.Canvas.Pen.Mode := pmXor;
          Chart1.Canvas.Pen.Width := 1;

          // Remove the old line
          Chart1.Canvas.Polyline(PT_Array);

          // Save new point
          PT_Array[High(PT_Array)].X := X;
          PT_Array[High(PT_Array)].Y := Y;

          // Draw the new line
          Chart1.Canvas.Polyline(PT_Array);

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Poly Line Drawing

Post by Yeray » Thu Aug 07, 2014 1:40 pm

Hello,

Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

dpatch
Newbie
Newbie
Posts: 19
Joined: Mon Mar 10, 2014 12:00 am

Re: Poly Line Drawing

Post by dpatch » Thu Aug 07, 2014 3:39 pm

Attached is a very small application that demonstrates the problem.

Thanks
Chart.zip
(81.02 KiB) Downloaded 814 times

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Poly Line Drawing

Post by Yeray » Fri Aug 08, 2014 9:15 am

Hello,

And what TeeChart version gives the expected result with that testing application?

Note the last TeeChart versions are using GDIPlus as default render canvas. This could be the change affecting your application.
You could try moving back to GDI as explained here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

dpatch
Newbie
Newbie
Posts: 19
Joined: Mon Mar 10, 2014 12:00 am

Re: Poly Line Drawing

Post by dpatch » Fri Aug 08, 2014 1:44 pm

I'm not sure I totally understand your last post. This used to work prior to version 2013...

I tried switching from GDI+ to GDI but when I did, nothing was drawn. No other changes were made. When I switched it back the old behavior resumed, meaning lines were not XOR'd off the canvas.

When you looked at the example code I sent, did you see something wrong with the code? Did the XOR pen work for you? Did you try changing the canvas to GDI and if so, did anything draw?

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Poly Line Drawing

Post by Yeray » Fri Aug 08, 2014 3:19 pm

Hello,

Excuse me if I haven't expressed myself clearly enough.

I've reproduced the problem with your application in Delphi 7 and TeeChart v2014.11 down to 2013.08. With the the default GDIPlus, the lines don't seem to be removed. And with GDI no lines are drawn.
And with TeeChart v2012.07 I got the same result than with v2014.11 and GDI: no lines are drawn.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

dpatch
Newbie
Newbie
Posts: 19
Joined: Mon Mar 10, 2014 12:00 am

Re: Poly Line Drawing

Post by dpatch » Fri Aug 08, 2014 4:13 pm

I'm sorry if I seem frustrated. It's just that I can no longer support my clients with this version 2014 or 2013 of TCharts.

At some point I in the upgrade process (I thought it was version 2013) I began having trouble drawing on the chart with both the Line method (see my earlier post) and the PolyLine method. When I up graded to version 2014 the Line method began to work but the I can no longer set the color palette on the TColorGridSeries until after I display the image.

When was GDI+ added. There seems to be a problem with that. Maybe if I go back to a version before GDI+. I hate to uninstall TCharts and start re-installing older versions until I find the one that last worked. I'm not sure what that version was, as I was just notified of this defect recently by my client.

Do you have any recommendations?
Thanks

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Poly Line Drawing

Post by Yeray » Mon Aug 11, 2014 8:24 am

Hello,
dpatch wrote:I'm sorry if I seem frustrated. It's just that I can no longer support my clients with this version 2014 or 2013 of TCharts.

At some point I in the upgrade process (I thought it was version 2013) I began having trouble drawing on the chart with both the Line method (see my earlier post) and the PolyLine method. When I up graded to version 2014 the Line method began to work but the I can no longer set the color palette on the TColorGridSeries until after I display the image.

When was GDI+ added. There seems to be a problem with that. Maybe if I go back to a version before GDI+. I hate to uninstall TCharts and start re-installing older versions until I find the one that last worked. I'm not sure what that version was, as I was just notified of this defect recently by my client.

Do you have any recommendations?
GDIPlus has been there since very very early, we just moved it to be the default engine recently (from v2013.08) but you can still activate GDI as mentioned before.
Since the problems you experienced seem to have started with v2013, switching back to GDI seems to be a reasonable suggestion for you to give it a try.

However, I tried your application with v2012.07 and nothing was drawn either in GDI nor in GDIPlus. See the attached application. It's your application modified so you are able top switch between GDI/GDIPlus and I included two exes, built with v2012.07 and with v2014.11.
Chart.zip
(1019.25 KiB) Downloaded 736 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

dpatch
Newbie
Newbie
Posts: 19
Joined: Mon Mar 10, 2014 12:00 am

Re: Poly Line Drawing

Post by dpatch » Mon Aug 11, 2014 3:11 pm

Yeray,

I will give them a try here, but expect the same results you got. I did some further investigation and found that I moved from TCharts V8.05.50522 to a version of TCharts 2013 when I moved to Delphi XE3. I dusted off an old computer and the Line & PolyLine methods as well as setting the color palette (see Line Drawing post) worked fine in version 8 of TCharts. The caveat here is that that was on the Windows XP environment running Delphi version 10.0.2558.35231 with Update 2.

The fix you gave me for TSurfa.pas now has everything fixed except the PolyLine method. I will implement my own PolyLine method using the Line method for now until this issue is fixed.

Thanks for your help.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Poly Line Drawing

Post by Yeray » Tue Aug 12, 2014 3:13 pm

Hello,

I see changing Canvas.Polyline for a loop calling Canvas.Line makes the XOR to work fine.
I've simplified your application a little bit more and attached it to a ticket I've opened in the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=883

In TeeChart previous to v2013.08, the Canvas was GDI by default and the Polyline function does the XOR correctly in it.
In TeeChart v2013.08 and above, you should use Line instead of Polyline, that does the XOR correctly, internally using GDI instead of GDIPlus

Code: Select all

  for i:=Low(PTarray) to High(PTarray)-1 do
    Chart1.Canvas.Line(PTarray[i], PTarray[i+1]);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply