Page 1 of 2

Line drawing

Posted: Thu Jul 31, 2014 2:03 pm
by 16568742
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);

Re: Line drawing

Posted: Fri Aug 01, 2014 9:51 pm
by 16568742
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!

Re: Line drawing

Posted: Mon Aug 04, 2014 8:31 am
by 16567885
Isn't there a Chart tool for exactly that already built in?

Re: Line drawing

Posted: Mon Aug 04, 2014 12:00 pm
by 10050769
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,

Re: Line drawing

Posted: Mon Aug 04, 2014 1:02 pm
by 16568742
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.

Re: Line drawing

Posted: Tue Aug 05, 2014 11:56 am
by 10050769
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,

Re: Line drawing

Posted: Wed Aug 06, 2014 12:37 pm
by 16568742
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 24911 times
I then get this one:
Second Load Error.jpg
Second Load Error.jpg (49.07 KiB) Viewed 24912 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.

Re: Line drawing

Posted: Wed Aug 06, 2014 12:48 pm
by 16568742
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!!

Re: Line drawing

Posted: Wed Aug 06, 2014 2:53 pm
by 16568742
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 24906 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!

Re: Line drawing

Posted: Thu Aug 07, 2014 9:55 am
by yeray
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.

Re: Line drawing

Posted: Thu Aug 07, 2014 2:10 pm
by 16568742
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

Re: Line drawing

Posted: Fri Aug 08, 2014 9:55 am
by yeray
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.

Re: Line drawing

Posted: Fri Aug 08, 2014 7:10 pm
by 16568742
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 846 times

Re: Line drawing

Posted: Mon Aug 11, 2014 10:36 am
by yeray
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 24791 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 24785 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.

Re: Line drawing

Posted: Mon Aug 11, 2014 1:03 pm
by yeray
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;