Draw while zoomed

Support for Rt-Tools 2D Components for CodeGear Delphi and C++ Builder

Moderator: Horst Reichert

Draw while zoomed

Postby Shendemiar » Thu Dec 03, 2009 12:08 pm

While zoomed, if new data is added, the scales change and the area of zoom changes and it is not nice.

I want the new data drawn yes, if it appears on the zoomed area, but i don't want any axis rescaling, zoom area change or anything.

Which properties I need to alter?

This is what I am using now, but just disables drawing completely while zoomed.

Code: Select all
  // If zoomed, disable autoupdate
  if Graph.ZoomStage=0 then
    begin
      Series.AutoUpdate := true;
    end
  else
    begin
      Series.AutoUpdate := false;
    end;
Shendemiar
 
Posts: 14
Joined: Mon Dec 22, 2008 2:07 pm

Re: Draw while zoomed

Postby Horst Reichert » Sat Dec 05, 2009 8:16 am

To get the effect you like you have to leave the AutoUpdate property of the series untouched as true.
The zooming window of the graph is set by the display ranges of the axes. If one of the axes of the relevant dimension (X/Y) has the StartEnd or StopEnd property set to Autorange, a new data point will result in a rescale of the axis and restores the zoon settings.
If you set the StartEnd or StopEnd property to Fixed and set the ranges to the desired zoom ranges, a new data point will display inside the zoomed range.

Regards Horst
Horst Reichert
 
Posts: 282
Joined: Fri Apr 15, 2005 9:50 am

Re: Draw while zoomed

Postby Shendemiar » Mon Dec 07, 2009 3:18 pm

I don't get it. What do I need to do? Sorry I'm so dumb cannot help it :(

Code: Select all
  // Don't autorange while zoomed
  if not (Graph.ZoomStage = 0) then
    begin
//      ShowMessage('Zoomed');
      Series.XAxis.StartEnd := Fixed;
      Series.XAxis.StopEnd := Fixed;
      Series.YAxis.StartEnd := Fixed;
      Series.YAxis.StopEnd := Fixed;

      Series.XAxis.Start := Series.XData.Minimum // How to get that of the zoomed area;
      Series.XAxis.Stop := Series.XData.Maximum // How to get that of the zoomed area;
      Series.YAxis.Start := Series.YData.Minimum // How to get that of the zoomed area;
      Series.YAxis.Stop := Series.YData.Maximum // How to get that of the zoomed area;
    end
  else
    begin
      Series.XAxis.StartEnd := AutoRange;
      Series.XAxis.StopEnd := AutoRange;
      Series.YAxis.StartEnd := AutoRange;
      Series.YAxis.StopEnd := AutoRange;
    end;
Shendemiar
 
Posts: 14
Joined: Mon Dec 22, 2008 2:07 pm

Re: Draw while zoomed

Postby Horst Reichert » Tue Dec 08, 2009 6:08 pm

Hi,
You are not dumb ;)
I gave you some hints without testing. You know that sometimes you are sure that something must work, but if you try yourself... :roll:
Some fix without warranty that there are no unexpected side effects:

Open RtAxis.pas and alter:
Code: Select all
procedure TRtAxis.RangeModified;
var i: Integer;
begin
  if ((Parent is TRtGraph2D) and (Parent as TRtGraph2D).Loading) or
    (csDestroying in ComponentState) then Exit;
  if CanZoomBack then
  begin
//    if not (StartEnd=RtAxis.AutoRange) then Start := FLastZoomStart[0];
//    if not (StopEnd=RtAxis.AutoRange) then Stop := FLastZoomStop[0];
  end;
  if (FRelatedSeries.Count>0) then
  begin


In your program assign an event handler to the OnEndZoom event of the graph component which sets:

Code: Select all
  XAxis.StartEnd := Fixed;
  XAxis.StopEnd := Fixed;
  YAxis.StartEnd := Fixed;
  YAxis.StopEnd := Fixed;

Hope this works as expected.

Regard Horst
Horst Reichert
 
Posts: 282
Joined: Fri Apr 15, 2005 9:50 am

Re: Draw while zoomed

Postby Shendemiar » Wed Dec 09, 2009 10:38 am

Quite but not exactly, but you lead me to the right place thou.

Here's what I did, and now it behaves like desired.

I edited

Code: Select all
procedure TRtAxis.RangeModified;
var i: Integer;
begin
  if ((Parent is TRtGraph2D) and (Parent as TRtGraph2D).Loading) or
    (csDestroying in ComponentState) then Exit;

  if CanZoomBack then
  begin
    if not (StartEnd=RtAxis.AutoRange) then Start := FLastZoomStart[0];
    if not (StopEnd=RtAxis.AutoRange) then Stop := FLastZoomStop[0];
  end;

  // Added 9.12.09 to prevent autoranging when zoomed
  if not (ZoomStage = 0) then Exit;

  if (FRelatedSeries.Count>0) then
  begin
...
Shendemiar
 
Posts: 14
Joined: Mon Dec 22, 2008 2:07 pm


Return to Rt-Tools 2D for CodeGear VCL Version 3

Who is online

Users browsing this forum: No registered users and 2 guests

cron