Manually zooming to a specific region on colorgrids
Manually zooming to a specific region on colorgrids
I am using a TColorGridSeries to display my data. The axis extents on my image are +/-8 in both x and y that I set using SetMinMax. When I use your zoom tool, I can zoom way in and then pan to see the image parts that are not visible. Is there a way to specify the zoom on each axis manually? For example say I have my image that is +/8 but I want to set the axis extents to +/-3. If I use SetMinMax then the image is cropped when I pan.
Thanks in advance.
dave
Thanks in advance.
dave
Re: Manually zooming to a specific region on colorgrids
I would have thought this would woprk, but the plot is just empty...
Chart1.Axes.Top.SetMinMax(Chart1[SIndex].MinXValue * xScaleMul + xScaleOff, // This gives me the +/- 8 on the axis so all data is present
Chart1[SIndex].MaxXValue * xScaleMul + xScaleOff );
Chart1.Axes.Right.SetMinMax(Chart1[SIndex].MinYValue * zScaleMul + zScaleOff,
Chart1[SIndex].MaxYValue * zScaleMul + zScaleOff );
Chart1.ZoomRect(rect(Chart1.Series[0].CalcXPosValue(-3), Chart1.Series[0].CalcXPosValue(-3), // But when I add this, the image is blank. I I remove
Chart1.Series[0].CalcXPosValue(-3), Chart1.Series[0].CalcXPosValue(-3))); // this the entire image is there
Chart1.Axes.Top.SetMinMax(Chart1[SIndex].MinXValue * xScaleMul + xScaleOff, // This gives me the +/- 8 on the axis so all data is present
Chart1[SIndex].MaxXValue * xScaleMul + xScaleOff );
Chart1.Axes.Right.SetMinMax(Chart1[SIndex].MinYValue * zScaleMul + zScaleOff,
Chart1[SIndex].MaxYValue * zScaleMul + zScaleOff );
Chart1.ZoomRect(rect(Chart1.Series[0].CalcXPosValue(-3), Chart1.Series[0].CalcXPosValue(-3), // But when I add this, the image is blank. I I remove
Chart1.Series[0].CalcXPosValue(-3), Chart1.Series[0].CalcXPosValue(-3))); // this the entire image is there
Re: Manually zooming to a specific region on colorgrids
Have also tried this...
Chart1.Axes.Top.SetMinMax(Chart1[SIndex].MinXValue * xScaleMul + xScaleOff,
Chart1[SIndex].MaxXValue * xScaleMul + xScaleOff );
Chart1.Axes.Right.SetMinMax(Chart1[SIndex].MinYValue * zScaleMul + zScaleOff,
Chart1[SIndex].MaxYValue * zScaleMul + zScaleOff );
Chart1.AllowZoom := True;
Rect.Left := Chart1.Axes.Top.CalcXPosValue( -3.0 ) ;
Rect.Top := Chart1.Axes.Right.CalcYPosValue( 3.0 ) ;
Rect.Right := Chart1.Axes.Top.CalcXPosValue( 3.0 ) ;
Rect.Bottom:= Chart1.Axes.Right.CalcYPosValue( -3.0 ) ;
Chart1.ZoomRect( Rect );
As a footnote, I added the data using bottom/Left axes as integers and hide them, then filled in the top/Right axis as shown above (and make them visible) for speed reasons since they were floating point.
Chart1.Axes.Top.SetMinMax(Chart1[SIndex].MinXValue * xScaleMul + xScaleOff,
Chart1[SIndex].MaxXValue * xScaleMul + xScaleOff );
Chart1.Axes.Right.SetMinMax(Chart1[SIndex].MinYValue * zScaleMul + zScaleOff,
Chart1[SIndex].MaxYValue * zScaleMul + zScaleOff );
Chart1.AllowZoom := True;
Rect.Left := Chart1.Axes.Top.CalcXPosValue( -3.0 ) ;
Rect.Top := Chart1.Axes.Right.CalcYPosValue( 3.0 ) ;
Rect.Right := Chart1.Axes.Top.CalcXPosValue( 3.0 ) ;
Rect.Bottom:= Chart1.Axes.Right.CalcYPosValue( -3.0 ) ;
Chart1.ZoomRect( Rect );
As a footnote, I added the data using bottom/Left axes as integers and hide them, then filled in the top/Right axis as shown above (and make them visible) for speed reasons since they were floating point.
Re: Manually zooming to a specific region on colorgrids
Hello,
The axis SetMinMax function seems to work fine for me in a simple example with a TColorGrid and some sample values.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
The axis SetMinMax function seems to work fine for me in a simple example with a TColorGrid and some sample values.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Manually zooming to a specific region on colorgrids
Yes, I will give you an example here. But, remember SetMinMax works fine for me as well. The problem with it is that it truncates all the data outside the visible region. If I ujse SetMinMax then try to pan using the mouse, the plot is just white, only the original data defined in the "SetMinMax region" is present. I think it is the ZoomRect function that I want, Does that function work for you? I will try to send something today.
Re: Manually zooming to a specific region on colorgrids
I also have the data file nut it is too large to upload. Its 1 meg zipped, maybe I can email it to you or you? I have actually given it to you before, it's called DataFile.dat
- Attachments
-
- Zoom Test.zip
- Test for programatically zooming on an image.
- (7.44 KiB) Downloaded 588 times
Re: Manually zooming to a specific region on colorgrids
Hello,
Anyway, I could skip using it using "random*10" instead of using "ImgData[i,j]" at your AddXY calls.
The loop where we add the data looks as follows:
Note this populates a ColorGrid with x values from 1 to 512, and the same for the z values.
Then, if you want to zoom to display the zone in the horizontal axis between -3 and 3, and the same for the vertical axis, I'd expect a result showing part of the colorgrid and part out of the colorgrid.
I see two options of code to put at your ApplyZoomBtnClick, that give me similar results:
- Option 1. Use SetMinMax function from Bottom and Left axes instead of Top and Right:
- Option 2. Use CalcPosValue for values -3 and 3, and from bottom and Left axes to define the Zoom rectangle:
I found a Data.bin file but I wasn't able to load it to your application.dave wrote:I also have the data file nut it is too large to upload. Its 1 meg zipped, maybe I can email it to you or you? I have actually given it to you before, it's called DataFile.dat
Anyway, I could skip using it using "random*10" instead of using "ImgData[i,j]" at your AddXY calls.
The loop where we add the data looks as follows:
Code: Select all
for i := 0 to 511 do
for j := 0 to 511 do
(Chart1.Series[0] as TColorGridSeries).AddXYZ(i+1, random*10{ImgData[i,j]}, j+1);
Then, if you want to zoom to display the zone in the horizontal axis between -3 and 3, and the same for the vertical axis, I'd expect a result showing part of the colorgrid and part out of the colorgrid.
I see two options of code to put at your ApplyZoomBtnClick, that give me similar results:
- Option 1. Use SetMinMax function from Bottom and Left axes instead of Top and Right:
Code: Select all
Chart1.Axes.Bottom.SetMinMax(-3, 3);
Chart1.Axes.Left.SetMinMax(-3, 3);
Code: Select all
rect:=TeeRect(Chart1.Axes.Bottom.CalcPosValue(-3), Chart1.Axes.Left.CalcPosValue(-3),
Chart1.Axes.Bottom.CalcPosValue(3), Chart1.Axes.Left.CalcPosValue(3));
Chart1.ZoomRect(rect);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Manually zooming to a specific region on colorgrids
Yeray,
Thanks for your response. Attached are 4 ascii text files containing the data I wanted to send. Will you please append these files together in order (1 to 4) and use the appended file as input data for my original test. This will show an image that you can use the mouse to zoom to a specific area and see what I am trying to do. If you display my image and then left-click the mouse and zoom to an area around one feature of the image, that feature will appear on the plot in the zoomed window. The axes will update correctly to the zoomed window. You will now be able to (using the mouse) pan left, right up or down and see the rest of the image move into your zoomed window. This is what I want to do programmatically (not zooming with the mouse). If you instead use SetMinMax, the image does not change, just the axis labels do. The entire image is still shown, not zoomed. If you use the 3rd option I show in my example, you have to use the mouse and pan MANY times to the right before the image comes into view in the zoomed window. I am trying to zoom on a feature in the original image just as it does with the mouse and be able to pan and/or zoom back out to see the entire image at full scale again.
I hope this is more clear. Thanks
dave
Thanks for your response. Attached are 4 ascii text files containing the data I wanted to send. Will you please append these files together in order (1 to 4) and use the appended file as input data for my original test. This will show an image that you can use the mouse to zoom to a specific area and see what I am trying to do. If you display my image and then left-click the mouse and zoom to an area around one feature of the image, that feature will appear on the plot in the zoomed window. The axes will update correctly to the zoomed window. You will now be able to (using the mouse) pan left, right up or down and see the rest of the image move into your zoomed window. This is what I want to do programmatically (not zooming with the mouse). If you instead use SetMinMax, the image does not change, just the axis labels do. The entire image is still shown, not zoomed. If you use the 3rd option I show in my example, you have to use the mouse and pan MANY times to the right before the image comes into view in the zoomed window. I am trying to zoom on a feature in the original image just as it does with the mouse and be able to pan and/or zoom back out to see the entire image at full scale again.
I hope this is more clear. Thanks
dave
- Attachments
-
- File 3.zip
- (380.91 KiB) Downloaded 696 times
-
- File 2.zip
- (380.96 KiB) Downloaded 691 times
-
- File 1.zip
- (380.11 KiB) Downloaded 683 times
Re: Manually zooming to a specific region on colorgrids
Here is the forth file in the set.
- Attachments
-
- File 4.zip
- (387.82 KiB) Downloaded 692 times
Re: Manually zooming to a specific region on colorgrids
Yeray,
I figured it out! I can programmatically zoom using Try 2 and 3 if I get the chart correct pixel locations mapped correctly to the rect.TopLeft and rect.BottomRight. The problem was on my end.
BUT, please save the data file I sent you because I have another issue that you can help me with later using that same data file. I will put a separate thread in later. It has to do with drawing lines on the same image. It is something you helped me with before, but I think that one of the sSteema updates broke it.
Thanks again SO much for your support!
dave
I figured it out! I can programmatically zoom using Try 2 and 3 if I get the chart correct pixel locations mapped correctly to the rect.TopLeft and rect.BottomRight. The problem was on my end.
BUT, please save the data file I sent you because I have another issue that you can help me with later using that same data file. I will put a separate thread in later. It has to do with drawing lines on the same image. It is something you helped me with before, but I think that one of the sSteema updates broke it.
Thanks again SO much for your support!
dave
Re: Manually zooming to a specific region on colorgrids
Hello,
I'm glad to hear you found how to make it work as you wish!
http://www.teechart.net/support/downloa ... hp?id=5853
http://www.teechart.net/support/downloa ... hp?id=5854
http://www.teechart.net/support/downloa ... hp?id=5855
http://www.teechart.net/support/downloa ... hp?id=5856
I'm glad to hear you found how to make it work as you wish!
No problem. Note you can put the links to your attachments in the new thread. Ie:dave wrote:please save the data file I sent you because I have another issue that you can help me with later using that same data file. I will put a separate thread in later. It has to do with drawing lines on the same image. It is something you helped me with before, but I think that one of the sSteema updates broke it.
http://www.teechart.net/support/downloa ... hp?id=5853
http://www.teechart.net/support/downloa ... hp?id=5854
http://www.teechart.net/support/downloa ... hp?id=5855
http://www.teechart.net/support/downloa ... hp?id=5856
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |