Page 1 of 1

Manually zooming to a specific region on colorgrids

Posted: Sat Apr 16, 2016 3:20 pm
by 16577760
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

Re: Manually zooming to a specific region on colorgrids

Posted: Sat Apr 16, 2016 7:13 pm
by 16577760
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

Re: Manually zooming to a specific region on colorgrids

Posted: Sat Apr 16, 2016 8:06 pm
by 16577760
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.

Re: Manually zooming to a specific region on colorgrids

Posted: Mon Apr 18, 2016 3:21 pm
by yeray
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?

Re: Manually zooming to a specific region on colorgrids

Posted: Tue Apr 19, 2016 11:46 am
by 16577760
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

Posted: Tue Apr 19, 2016 3:52 pm
by 16577760
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

Re: Manually zooming to a specific region on colorgrids

Posted: Wed Apr 20, 2016 8:57 am
by yeray
Hello,
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
I found a Data.bin file but I wasn't able to load it to your application.
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);
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:

Code: Select all

  Chart1.Axes.Bottom.SetMinMax(-3, 3);
  Chart1.Axes.Left.SetMinMax(-3, 3);
setminmax.png
setminmax.png (6.38 KiB) Viewed 14096 times
- Option 2. Use CalcPosValue for values -3 and 3, and from bottom and Left axes to define the Zoom rectangle:

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);
zoomrect.png
zoomrect.png (5.55 KiB) Viewed 14095 times

Re: Manually zooming to a specific region on colorgrids

Posted: Wed Apr 20, 2016 12:51 pm
by 16577760
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

Re: Manually zooming to a specific region on colorgrids

Posted: Wed Apr 20, 2016 12:52 pm
by 16577760
Here is the forth file in the set.

Re: Manually zooming to a specific region on colorgrids

Posted: Wed Apr 20, 2016 2:36 pm
by 16577760
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

Re: Manually zooming to a specific region on colorgrids

Posted: Thu Apr 21, 2016 10:59 am
by yeray
Hello,

I'm glad to hear you found how to make it work as you wish!
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.
No problem. Note you can put the links to your attachments in the new thread. Ie:
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