Page 1 of 1

How to bring TCursorTool in front of the grid lines

Posted: Tue Dec 23, 2008 7:30 am
by 10550741
I added a file steema_shimon.zip to demonstrate my problem.

I need that the grid lines will be only on back and when there is a curosr line on the same line, then the cursor line will get priority and will be before the grid line.

In other words in the Z order : the cursor line should be on top and the grid lines should be lower.

Thanks,
Shimon

Posted: Tue Dec 23, 2008 8:57 am
by narcis
Hi Shimon,

TCursorTool is already drawn over the axis grid lines. However, when its pen is set to certain colors it produces the effect you mention. You could try using TPenMode:

Code: Select all

  ChartTool1.Pen.Mode:=pmXor;
According to Delphi's documentation:

TPenMode indicates how a pen color interacts with the color of the canvas it is writing on. The following table lists the possible values:

Mode Pixel color

pmBlack Always black
pmWhite Always white
pmNop Unchanged
pmNot Inverse of canvas background color
pmCopy Pen color specified in Color property
pmNotCopy Inverse of pen color
pmMergePenNot Combination of pen color and inverse of canvas background
pmMaskPenNot Combination of colors common to both pen and inverse of canvas background.
pmMergeNotPen Combination of canvas background color and inverse of pen color
pmMaskNotPen Combination of colors common to both canvas background and inverse of pen
pmMerge Combination of pen color and canvas background color
pmNotMerge Inverse of pmMerge: combination of pen color and canvas background color
pmMask Combination of colors common to both pen and canvas background
pmNotMask Inverse of pmMask: combination of colors common to both pen and canvas background
pmXor Combination of colors in either pen or canvas background, but not both
pmNotXor Inverse of pmXor: combination of colors in either pen or canvas background, but not both


You can try if any of this possible values gives you a better result.

Posted: Tue Dec 23, 2008 10:14 am
by 10550741
I have tried many modes - e.g.

Cursor.Pen.Color := clRed;
Cursor.Pen.Mode := pmBlack;

I am using TCursorTool which is created dynamically.

I can see that the color setting is done OK but the Mode is ignored and I guess it is always xoring but I want pmCopy.

Even when I tries pmBlack I received a red line...

Posted: Tue Dec 23, 2008 10:21 am
by narcis
Hi Shimon,

Yes, this seems a bug to me and I added it (TV52013671) to the list to be fixed for future releases.

Posted: Tue Dec 23, 2008 10:27 am
by 10550741
Is it because I dynamically created it ?

Any workaround ?

Posted: Tue Dec 23, 2008 10:29 am
by narcis
Hi Shimon,

No, it's the same creating cursor tool at designtime. There's no workaround I can think of for now.

Posted: Tue Dec 23, 2008 10:31 am
by 10550741
OK,

Thanks for your prompt responses.

1. When do you think a fix version will be released ?

2. Another related issue. Can I add some label which attached to the line. I am currently using TAnnotationTool but I need to manage its coordinates manually....

Thanks again,
Shimon

Posted: Tue Dec 23, 2008 10:35 am
by narcis
Hi Shimon,

You're welcome.
1. When do you think a fix version will be released ?
I'm sorry but I can't provide an estimate date yet.
2. Another related issue. Can I add some label which attached to the line. I am currently using TAnnotationTool but I need to manage its coordinates manually....
Yes, you can use annotation tool set to custom position in cursor's OnChange event:

Code: Select all

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
  With ChartTool2.Shape do
  begin
    CustomPosition:=True;
    Left:=Chart1.Axes.Bottom.CalcXPosValue(ChartTool1.XValue);
    Top:=Chart1.Axes.Left.CalcYPosValue(ChartTool1.YValue);
  end;
end;

Re: How to bring TCursorTool in front of the grid lines

Posted: Mon Oct 05, 2009 1:38 pm
by narcis
Hi Shimon,

I've been investigating TV52013671 and found that this is by design. The pen mode is set to pmXor when drawing the cursor probably for performance reasons.