TRectangleTool and TContourSeries
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
TRectangleTool and TContourSeries
Hello,
i have to select a list of areas in a TContourSeries. My fist thouth was to use the TRectangleTool to draw several rectangles on a TContourSeries. Than i have to detect if a specific point from the series is in this area. And if so i had to compute e.g. the average of the z-values of all points in this rectangle. Is thera any way to detect if a point of a TContourSeries is "under" a TRectangleTool ?
Your sincerely
Willi Ebert
i have to select a list of areas in a TContourSeries. My fist thouth was to use the TRectangleTool to draw several rectangles on a TContourSeries. Than i have to detect if a specific point from the series is in this area. And if so i had to compute e.g. the average of the z-values of all points in this rectangle. Is thera any way to detect if a point of a TContourSeries is "under" a TRectangleTool ?
Your sincerely
Willi Ebert
Re: TRectangleTool and TContourSeries
Hello Willi Ebert,
Have you tried using the IntersectRect function?
You could use the TContourSeries CellBounds method to get the cells rectangles and the TRectangleTool Bounds property to get the tool rectangle.
Have you tried using the IntersectRect function?
You could use the TContourSeries CellBounds method to get the cells rectangles and the TRectangleTool Bounds property to get the tool rectangle.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
the problem is the method CellBounds is not documented is your "TeeChart Pro v2011 VCL Library..." or elsewhere. So can't use it. And second screen coordinates doesn't help me.Only coordinates from the contourseries helps me.
Your sincerely
Willi
the problem is the method CellBounds is not documented is your "TeeChart Pro v2011 VCL Library..." or elsewhere. So can't use it. And second screen coordinates doesn't help me.Only coordinates from the contourseries helps me.
Your sincerely
Willi
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
i have found now a some documents about the TRectangleTool. I used it like in your Tool_RectangleAllowDragResize.pas. But if the TRectangleTool is connected to the same chart as i uses for datasource of a TBarSeries to display the histogram of the ContourSeries2, the barseries can't get data from the ContourSeries2 and i get a EAccessViolation.
ToolRectChartWave := TRectangleTool.Create(self);
// Add to Chart
ChartWave.Tools.Add(ToolRectChartWave);
SeriesPlHistogram.DataSources.Add(ContourSeries2);
for i:=1 to SeriesPlHistogram.Count-1 do
begin
if SeriesPlHistogram.YValues=aPlMaxHistoTemp then YMinIndex:=i
end;
try
aPlMaxHisto := round(SeriesPlHistogram.XValues[YMinIndex]) ;
except on EAccessViolation do begin end;
end;
And if the ToolRectChartWave is not connecte to ChartWave i get no EAccessViolation and aPlMaxHisto is valid
Can you help me?
Your sincerely
Willi
i have found now a some documents about the TRectangleTool. I used it like in your Tool_RectangleAllowDragResize.pas. But if the TRectangleTool is connected to the same chart as i uses for datasource of a TBarSeries to display the histogram of the ContourSeries2, the barseries can't get data from the ContourSeries2 and i get a EAccessViolation.
ToolRectChartWave := TRectangleTool.Create(self);
// Add to Chart
ChartWave.Tools.Add(ToolRectChartWave);
SeriesPlHistogram.DataSources.Add(ContourSeries2);
for i:=1 to SeriesPlHistogram.Count-1 do
begin
if SeriesPlHistogram.YValues=aPlMaxHistoTemp then YMinIndex:=i
end;
try
aPlMaxHisto := round(SeriesPlHistogram.XValues[YMinIndex]) ;
except on EAccessViolation do begin end;
end;
And if the ToolRectChartWave is not connecte to ChartWave i get no EAccessViolation and aPlMaxHisto is valid
Can you help me?
Your sincerely
Willi
Re: TRectangleTool and TContourSeries
Hello Willi,
Could you please arrange a simple example project we can run as-is to reproduce the situation and the problem here?
Thanks in advance.
Could you please arrange a simple example project we can run as-is to reproduce the situation and the problem here?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
thank you very much for your response. I know a "simple" ample is your approach to find the error. But please understand our project as often not "simple" so we can't make a sample project to display a error. So i can' send you a sample. Please ask me some question so i can answer your question to solve the problem.
Your sincerely
Willi
thank you very much for your response. I know a "simple" ample is your approach to find the error. But please understand our project as often not "simple" so we can't make a sample project to display a error. So i can' send you a sample. Please ask me some question so i can answer your question to solve the problem.
Your sincerely
Willi
Re: TRectangleTool and TContourSeries
Hello Willi,
I understand that the customer's final applications are often complex and not always transferable. What we usually ask for is a simple testing application, where the customer "only" extracts the chart where he/she has found a problem. This is what we mean when we ask for "a simple example project we can run as-is to reproduce a problem".
Sometimes the problem can be reproduced loading a tee file created on the customer side. But this "only" sends the chart configuration and in this case the code to allow the user interaction could also be relevant.
I understand that the customer's final applications are often complex and not always transferable. What we usually ask for is a simple testing application, where the customer "only" extracts the chart where he/she has found a problem. This is what we mean when we ask for "a simple example project we can run as-is to reproduce a problem".
Sometimes the problem can be reproduced loading a tee file created on the customer side. But this "only" sends the chart configuration and in this case the code to allow the user interaction could also be relevant.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
the problem with the TRectangletool is solved. Finally i created the TRectangletool in the form create procedure and not in the form show procedure.
But now i have still the problem that CellBounds method is only defined for TColorGridSeries and not for TContourSeries. Can you help me?
Your sincerely
Willi
the problem with the TRectangletool is solved. Finally i created the TRectangletool in the form create procedure and not in the form show procedure.
But now i have still the problem that CellBounds method is only defined for TColorGridSeries and not for TContourSeries. Can you help me?
Your sincerely
Willi
Re: TRectangleTool and TContourSeries
Hello Willi,
I'm afraid I understood it wrong. I'm not sure why I understood you were using TColorGridSeries instead of TContourSeries (and as you noticed the CellBounds function isn't present for TContourSeries). Excuse me for the confusion.
Now I'm not sure to understand what areas you want to select in your TContourSeries. An area defined by two levels? It would be similar to a filled TContourSeries?
I'm afraid I understood it wrong. I'm not sure why I understood you were using TColorGridSeries instead of TContourSeries (and as you noticed the CellBounds function isn't present for TContourSeries). Excuse me for the confusion.
Now I'm not sure to understand what areas you want to select in your TContourSeries. An area defined by two levels? It would be similar to a filled TContourSeries?
Code: Select all
Series1.Brush.Style:=bsSolid;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
thank you very much for your reply. The TContourSeries we use to have good pictures of our date. Internaly we use the xyz-triplets. Therfore we have to know witch xz-point is in a user controlled area of this series. The user can alter the size and position of this are and than we had to compute e.g. the histogram of all y-values of all points in this area. Therefor we us the TRectangleTool now to draw this area. My question is, how can i detect if a point from the series is in this rectangle, and than i will add this point to a list or a second sere to compute the date.
I will you sen a picture of a sample 2D Contourseries with a TRectangleTool. The purpose is to compute e.g. the mean value or other statistical values from the z Values from all points in the area of TRectangletool.
thank you very much for your reply. The TContourSeries we use to have good pictures of our date. Internaly we use the xyz-triplets. Therfore we have to know witch xz-point is in a user controlled area of this series. The user can alter the size and position of this are and than we had to compute e.g. the histogram of all y-values of all points in this area. Therefor we us the TRectangleTool now to draw this area. My question is, how can i detect if a point from the series is in this rectangle, and than i will add this point to a list or a second sere to compute the date.
I will you sen a picture of a sample 2D Contourseries with a TRectangleTool. The purpose is to compute e.g. the mean value or other statistical values from the z Values from all points in the area of TRectangletool.
- Attachments
-
- Unbenannt.PNG (45.03 KiB) Viewed 13644 times
Re: TRectangleTool and TContourSeries
Hello Willi,
Thanks for the explanation and the picture. It clarifies the problem a little bit.
Taking the code another customer shared here, I made an example of how you could get the list of a TContourSeries indexes under a TRectangleTool:
Note I'm highlighting the values found under the rectangle but you probably only want the TIntegerArray returned by the GetPointsFromRect function (selIndexes).
Thanks for the explanation and the picture. It clarifies the problem a little bit.
Taking the code another customer shared here, I made an example of how you could get the list of a TContourSeries indexes under a TRectangleTool:
Code: Select all
//...
type
TIntegerArray = array of Integer;
//...
private
procedure ChartTool1Dragging(Sender: TObject);
procedure ChartTool1Resizing(Sender: TObject);
function GetPointsFromRect(AChart: TChart; ASerie: TChartSeries; ARect: TRect): TIntegerArray;
//...
uses TeeSurfa, TeeTools, TeCanvas;
var selIndexes: TIntegerArray;
procedure TForm1.FormCreate(Sender: TObject);
var points: TIntegerArray;
begin
Chart1.View3D:=false;
Chart1.Legend.Visible:=false;
with Chart1.AddSeries(TContourSeries) as TContourSeries do
begin
FillSampleValues(100);
Brush.Style:=bsSolid;
CellPen.Visible:=true;
CellPen.Color:=clGrayText;
end;
with Chart1.Tools.Add(TRectangleTool) as TRectangleTool do
begin
Width:=100;
Height:=100;
Left:=100;
Top:=100;
OnDragging:=ChartTool1Dragging;
OnResizing:=ChartTool1Resizing;
end;
Chart1.Draw;
selIndexes:=GetPointsFromRect(Chart1, Chart1[0], (Chart1.Tools[0] as TRectangleTool).Bounds);
end;
procedure TForm1.ChartTool1Dragging(Sender: TObject);
begin
selIndexes:=GetPointsFromRect(Chart1, Chart1[0], (Chart1.Tools[0] as TRectangleTool).Bounds);
end;
procedure TForm1.ChartTool1Resizing(Sender: TObject);
var points: TIntegerArray;
begin
selIndexes:=GetPointsFromRect(Chart1, Chart1[0], (Chart1.Tools[0] as TRectangleTool).Bounds);
end;
function TForm1.GetPointsFromRect(AChart: TChart; ASerie: TChartSeries; ARect: TRect): TIntegerArray;
var
Left, Right, Top, Bottom: Double;
Ctr: Integer;
tmpValueList: TChartValueList;
begin
if (ARect.Left > ARect.Right) then
begin
Ctr := ARect.Left;
ARect.Left := ARect.Right;
ARect.Right := Ctr;
end;
if (ARect.Top > ARect.Bottom) then
begin
Ctr := ARect.Top;
ARect.Top := ARect.Bottom;
ARect.Bottom := Ctr;
end;
Left := ASerie.GetHorizAxis.CalcPosPoint(ARect.Left);
Right := ASerie.GetHorizAxis.CalcPosPoint(ARect.Right);
Top := ASerie.GetVertAxis.CalcPosPoint(ARect.Top);
Bottom := ASerie.GetVertAxis.CalcPosPoint(ARect.Bottom);
if ASerie is TCustom3DSeries then
tmpValueList:=(ASerie as TCustom3DSeries).ZValues
else
tmpValueList:=ASerie.YValues;
SetLength(Result, 0);
for Ctr := 0 To ASerie.Count - 1 do
begin
if ((ASerie.XValues[Ctr] >= Left) and (ASerie.XValues[Ctr] <= Right) and (tmpValueList[Ctr] >= Bottom) and (tmpValueList[Ctr] <= Top)) then
begin
SetLength(Result, Length(Result) + 1);
Result[Length(Result) - 1] := Ctr;
ASerie.ValueColor[Ctr]:=clYellow;
end
else
ASerie.ValueColor[Ctr]:=clTeeColor;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 26
- Joined: Wed Aug 25, 2010 12:00 am
Re: TRectangleTool and TContourSeries
Hello Yeray,
thank you very much. This is exactly the solution i am looking for.
Your sincerely
Willi
thank you very much. This is exactly the solution i am looking for.
Your sincerely
Willi
Re: TRectangleTool and TContourSeries
Hi Willi,
I'm glad to hear that!
I'm glad to hear that!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |