Page 1 of 1

Scrolling & ProcessorLoad

Posted: Tue Apr 01, 2008 1:20 pm
by 9232480
Hi,

Using TeeChart 7.04 I've created a 1000 points sweepchart which cycles around when at the end of data. In 'RealTime', a point in a serie is replaced.
This works very well, with a total processorload of 0 - 2 % for the whole data acquisition application.

The customer is able to scroll (pan) only vertically in the graph during running. Both the Left (Y) and Bottom (X) axes are fixed scaled, ClipPoints = False and all other tricks for fast graphing are implemented.

However, when the customers scrolls too extensively, firmly holding down the right mouse button and fastmoving of the mouse, the processorloads increases > 90%. This will cause loss of data...
This might be obvious, as you should not hold down the right mousebutton in this way, though I'm not in front of the customer every day.

Is'nt there a flag somewehere wich I could check in the OnAllowScroll event to disable scrolling when a scroll is active? i.e. slowing down the excessive repaints?

Thanks in advance for your support!

Kind regards,

Davy

Posted: Tue Apr 01, 2008 1:29 pm
by narcis
Hi Davy,

First of all, please notice that latest TeeChart Pro v7 VCL release available at the client download area is v7.12. You may be interested in using that version and check if it solves the problem at your end.

Alternativelly you can use the OnMouseMove event (or any other mouse event) like this:

Code: Select all

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if (Shift = Chart1.ScrollMouseButton) then
    Chart1.AllowPanning := false
  else
    Chart1.AllowPanning := true;
end;

Posted: Tue Apr 01, 2008 2:01 pm
by 9232480
Hi Narcis,

Thanks for your reply.
I assume that this code is the same as you propose:

Code: Select all

if (ssRight in Shift) then
    Chart1.AllowPanning := pmNone
else
   Chart1.AllowPanning := pmVertical;

This code just disable scrolling at all, which is not our goal.

Customer should be able to Pan, but without excessive repaints when holding the R mouse button firmly down while fast moving the mouse.


Kind regards,

Davy.

TeeChart 7.04 & Delphi 7

Posted: Tue Apr 01, 2008 2:05 pm
by narcis
Hi Davy,

Yes, sorry, my code doesn't even compile :(.

Latest binary release for Delphi 7 is v7.07 while latest sourcecode version is v7.12. Could you please try if those versions enhance the performance at your end?

Posted: Tue Apr 01, 2008 2:39 pm
by 9232480
Hi Narcis,

Have installed binary release 7.07 and there is no enhancement of the performance.

Kind regards,

Davy

Posted: Wed Apr 02, 2008 9:02 am
by yeray
Hi Davy,

Here i can suggest you two possibilities depending on the repaint frequency you wish.

You could disable autorepaint when right mouse button is pressed and only repaint and draw new values when user holds up the right mouse:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = Chart1.ScrollMouseButton then
    Chart1.AutoRepaint := false;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = Chart1.ScrollMouseButton then
  begin
    Chart1.AutoRepaint := true;
    Chart1.Repaint;
  end;
end;
And the other possibility is adding a timer and give him a repaint interval:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = Chart1.ScrollMouseButton then
  begin
    Chart1.AutoRepaint := false;
    Timer1.Enabled := true;
  end;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button = Chart1.ScrollMouseButton then
    Timer1.Enabled := false;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Chart1.AutoRepaint := true;
  Chart1.Repaint;
  Chart1.AutoRepaint := false;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer1.Interval := 1000;
  Timer1.Enabled := false;
end;

Posted: Wed Apr 02, 2008 10:20 am
by 9232480
Hi Yeray,

Thanks for your idea's. They have stimulated my creativity!

As there is a running timer in the application for observing and processing data acquisition data, I can use this timer as well for slowing down repaints when customer is teasing the application.

Kind regards,

Davy

Posted: Fri Apr 04, 2008 9:33 am
by yeray
Hi Davy,

I'm really glad to see that!