Line drawing

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

Line drawing

Post by dpatch » Thu Jul 31, 2014 2:03 pm

I have simple code in the mouse down event that saved the x/y position than in the mouse move event, erase the old line and draw a new one to the new point, giving a rubber band effect. I am drawing the line on an image so I have to XOR the line on and off the image instead of just clearing the canvas. This code no longer seems to work, I can not get the old line to be xor'd off the canvas. Has something changed that I am not aware of? I have tried different pen modes and brush styles but cant seem to get it to work. Any thoughts? Thanks!

The code looks like this...

Code: Select all

      Chart1.Canvas.Pen.Color := clWhite;
//      Chart1.Canvas.Brush.Style := bsClear;
//       Chart1.Canvas.Pen.Mode := pmNot;
      Chart1.Canvas.Brush.Style := bsSolid;
      Chart1.Canvas.Pen.Mode := pmXor;

      // Remove the old line
      Chart1.Canvas.Pen.Width := 1;
      Chart1.Canvas.Line(DistPT1.X, DistPT1.Y, DistPT2.X, DistPT2.Y);

      // Save new point
      DistPT2.X := X;
      DistPT2.Y := Y;

      // Draw the new line
      Chart1.Canvas.Pen.Width := 1;
      //Chart1.Canvas.Pen.Mode := pmNot;
      Chart1.Canvas.Pen.Mode := pmXor;
      Chart1.Canvas.Line(DistPT1.X, DistPT1.Y, DistPT2.X, DistPT2.Y);

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

Re: Line drawing

Post by dpatch » Fri Aug 01, 2014 9:51 pm

Does anyone have any idea how to XOR a line on the a ColorGridSeries? This used to work and no longer seems to.

Thanks in advance!

jens.mertelmeyer
Newbie
Newbie
Posts: 60
Joined: Fri Nov 22, 2013 12:00 am

Re: Line drawing

Post by jens.mertelmeyer » Mon Aug 04, 2014 8:31 am

Isn't there a Chart tool for exactly that already built in?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Line drawing

Post by Sandra » Mon Aug 04, 2014 12:00 pm

Hello dpatch,
I have made a simple code, based with the code you use in MouseMove and it works fine for me. See code below:

Code: Select all

uses TeCanvas;
var DistPT1,DistPT2 :TPoint;
procedure TForm2.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    DistPT1.X := X;
DistPT1.Y := Y;
end;

procedure TForm2.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if Chart1.ChartRect.Contains(DistPT1) then
begin
  Chart1.Canvas.Pen.Color := clWhite;
  // Chart1.Canvas.Brush.Style := bsClear;
  // Chart1.Canvas.Pen.Mode := pmNot;
  Chart1.Canvas.Brush.Style := bsSolid;
  Chart1.Canvas.Pen.Mode := pmXor;

  // Remove the old line
  Chart1.Canvas.Pen.Width := 1;
  Chart1.Canvas.Line(DistPT1.X, DistPT1.Y, DistPT2.X, DistPT2.Y);

  // Save new point
  DistPT2.X := X;
  DistPT2.Y := Y;

  // Draw the new line
  Chart1.Canvas.Pen.Width := 1;
  //Chart1.Canvas.Pen.Mode := pmNot;
  Chart1.Canvas.Pen.Mode := pmXor;
  Chart1.Canvas.Line(DistPT1.X, DistPT1.Y, DistPT2.X, DistPT2.Y);
end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Series1.FillSampleValues(10);
end;
Could you tell us if you can reproduce the problem with my previous code? Also, would be very grateful if you can tell us which version of TeeChart Pro VCL/FMX are you using?

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Re: Line drawing

Post by dpatch » Mon Aug 04, 2014 1:02 pm

Sandra,

Thanks for your response. I am a source code client using TeeChart Pro v2013 32 bit. My application is now exactly like the code you have in this post. When I move the mouse, the old lines still are not removed. I have attached a screen shot showing my issue. This image was drawn on a TColorGridSeries. As you can see in the image, the white lines at the bottom were created after a mouse down and mouse move events.
Attachments
Line Drawing.jpg
Line Drawing.jpg (82.18 KiB) Viewed 25347 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Line drawing

Post by Sandra » Tue Aug 05, 2014 11:56 am

Hello dpatch,

Many thanks for your information. The problem you are experiencing doesn't occur for me using latest TeeChart Pro VCL/FMX source code and the code I have attached for you in my last post.
Could you please download the TeeChart Pro Source code 2014 and check again if the problem, you are experiencing, still appears? You can get the latest TeeChart Pro VCL/FMX source code from our customer download page.
If the problem persist using latest version, we would be very grateful if you can send us a simple project where the problem appear, because we can reproduce it here and try to find a good solution for you.

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Re: Line drawing

Post by dpatch » Wed Aug 06, 2014 12:37 pm

Thanks again for you response. I downloaded the latest version and installed it. When I open the project I get the following errors. I first get this one:
First Load Error.jpg
First Load Error.jpg (29 KiB) Viewed 25291 times
I then get this one:
Second Load Error.jpg
Second Load Error.jpg (49.07 KiB) Viewed 25292 times
Any thoughts? I think I have all the paths correct, but I must not. Can you advise me on how to fix this? Thanks in advance.

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

Re: Line drawing

Post by dpatch » Wed Aug 06, 2014 12:48 pm

OK, I uninstalled 2014 and reinstall it and this fixed the install problem. And, more importantly, the new version also fixed the line drawing problem.

It also made some unexpected changes to my color palette. I will look into that and ask further question if needed.

Thanks again!!

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

Re: Line drawing

Post by dpatch » Wed Aug 06, 2014 2:53 pm

OK, I have worked through all the issues except the color palette. Before installing the latest update, my image was drawn as shown above. Now, without code change, the image color is drawn as shown here:
Image Color.jpg
Image Color.jpg (107.75 KiB) Viewed 25286 times
What do you think changed? I call ClearPalette and AddPalette the same as I always have. It seems that where the palette is getting initialized internally has changed, meaning it is being initialized after I set it. If I set it again after displaying the incorrect image, it modifies the palette and displays the image as I expect. Any insight would be helpful.

Thanks!

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

Re: Line drawing

Post by Yeray » Thu Aug 07, 2014 9:55 am

Hello,
dpatch wrote:OK, I have worked through all the issues except the color palette. Before installing the latest update, my image was drawn as shown above. Now, without code change, the image color is drawn as shown here:

What do you think changed? I call ClearPalette and AddPalette the same as I always have. It seems that where the palette is getting initialized internally has changed, meaning it is being initialized after I set it. If I set it again after displaying the incorrect image, it modifies the palette and displays the image as I expect. Any insight would be helpful.
Can you please try to 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: Line drawing

Post by dpatch » Thu Aug 07, 2014 2:10 pm

Well I guess I could, but I am sure that If I write a small app it may work. There is something in the order of events in my current app that is causing the palette to be reinitialized to the default. Can you tell me where in your code this initialization occurs?

Thanks

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

Re: Line drawing

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

Hello,
dpatch wrote:Well I guess I could, but I am sure that If I write a small app it may work. There is something in the order of events in my current app that is causing the palette to be reinitialized to the default. Can you tell me where in your code this initialization occurs?
TColorGridSeries inherits from TCustom3DPaletteSeries, and its constructor is who initializes the palette (it actually initializes a ColorRange).

If you suspect the events are playing a determining role in the problem, then the simple application I asked for should probably include some of them. I mean, when we ask for a simple example application to reproduce a problem, we mean "as simple as possible" while still reproducing the problem, of course. But please, understand without such project the investigations we can do are very limited.
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: Line drawing

Post by dpatch » Fri Aug 08, 2014 7:10 pm

Yeray,

OK, I attached a small project showing my inability to change the color palette. This code used to work, and every once in a while I make a change in the chart editor that causes the color on either the plot or the legend to change and be correct. But, it is not repeatable. Once it changed the plot when I switched between GDI and GDI+. another time it changed the legend when I made it not visible, then visible again.

I took this example from another example I sent you a number of years ago. In that example, we were debugging something else, but the colors worked and the "PolyLine method also worked. I have included a snapshot of the screen for you to see what the colors should be.

When you look at the app attached, do you see anything wrong?

Thanks.
Color Grid.zip
(239.27 KiB) Downloaded 878 times

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

Re: Line drawing

Post by Yeray » Mon Aug 11, 2014 10:36 am

Hello,

I've tried your testing application with all the versions from v2012.07 to the actual v2014.11 and found the palette seems to change from v2014.10. And switching to GDI doesn't change it.
Here is how it looks in v2013.09:
ColorGrid_v2013.09.png
ColorGrid_v2013.09.png (21.7 KiB) Viewed 25171 times
And this is how it looks in v2014.10 and v2014.11:
ColorGrid_v2014.11.png
ColorGrid_v2014.11.png (21.66 KiB) Viewed 25165 times
I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=880
dpatch wrote:every once in a while I make a change in the chart editor that causes the color on either the plot or the legend to change and be correct. But, it is not repeatable. Once it changed the plot when I switched between GDI and GDI+. another time it changed the legend when I made it not visible, then visible again.
In the tests I've made up to now, I haven't found a setting in the editor that makes the colorgrid to look as before.
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

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

Re: Line drawing

Post by Yeray » Mon Aug 11, 2014 1:03 pm

Hello,
Yeray wrote:I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=880
I found where the problem started and a possible fix for it.
Since you are a source code customer, you could change, at TeeSurfa.pas, this method:

Code: Select all

Procedure TCustom3DPaletteSeries.CheckPaletteEmpty;
begin
  if (Count>0) and ( (Length(FPalette)=0) or IDirtyPalette ) then
     CreateDefaultPalette;
end;
For this:

Code: Select all

Procedure TCustom3DPaletteSeries.CheckPaletteEmpty;
begin
  if (Count>0) and ( (Length(FPalette)=0) or not IDirtyPalette ) then
     CreateDefaultPalette;
end;
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