DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiple pages in SimpleGraph

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
P_G
Member


Joined: 14 Jun 2004
Posts: 44
Location: Germany

PostPosted: 25/01/05 10:34    Post subject: Multiple pages in SimpleGraph Reply with quote

Hello there,

I was looking for a way to have multiple pages in a SimpleGraph. Of course this could be a feature for future releases ***hint, hint***
Or does anyone have a workaround for splitting the contents of a SimpleGraph to several pages of a PrintPreview?

BTW - Kambiz, are you still programming Question I think I read something about you stopping the development of freeware components (But I might be wrong). This would be really sad...

P_G
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 27/01/05 10:16    Post subject: Reply with quote

As a workaround, you can get metafile of the graph, and then print on each page one part of the image.

I'm still programming because it's my profession. I hope one day I find my interest back to continue freeware component development.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Stefan
Moderator


Joined: 27 Sep 2004
Posts: 100
Location: Belgium, Antwerp

PostPosted: 27/01/05 15:11    Post subject: Reply with quote

Hey,

I really like the idea of splitting up the Graph into pages in the runtime-design state. I'll put it on my "i-wish-i-had-more-time"-list Wink
Any thoughts on the subject; on how to implement or how it should "look" are more than very welcome...

Cheers,
Stefan
Back to top
View user's profile Send private message Send e-mail
P_G
Member


Joined: 14 Jun 2004
Posts: 44
Location: Germany

PostPosted: 29/01/05 20:43    Post subject: Reply with quote

I really love this forum! What more can I say ...?
Very Happy
I hope, one day you find back your interest in programming freeware components, Kambiz. Your components rock !!!

With best regards, P_G
Back to top
View user's profile Send private message
MeW
Member


Joined: 17 Feb 2005
Posts: 6
Location: Netherlands

PostPosted: 17/02/05 18:41    Post subject: Reply with quote

I've developed a multipage printing routine for TSimpleGraph and TPrintPreview. It's quite simple once you get the hang of it. From my Preview form I can adjust the scale of the Diagram from 10% to 200% using a Trackbar. Upon changing this bar the callback routine is triggered to re-generate the printer document.

Here comes the code:

Code:
procedure TMainFrm.Printgraph(aPrintPreview: TPrintPreview; aScale: real);
var
  R: TRect;
  ImageSize, PrintSize: TPoint;
  x, y: integer;
begin
  aPrintPreview.BeginDoc;

  R := aPrintPreview.PrinterPageBounds;
  PrintSize.X := R.Right-R.Left;
  PrintSize.Y := R.Bottom-R.Top;
  ImageSize.X := Trunc(PrintSize.X * aScale); { aScale is [0.1 - 2] }
  ImageSize.Y := Trunc(PrintSize.Y * aScale);

  if (ImageSize.X > PrintSize.X) or
    (ImageSize.Y > PrintSize.Y) then
  begin
    { multipage printing }
    x := 0;
    y := 0;
    while (x < ImageSize.X) and (y < ImageSize.Y) do
    begin
      R := Rect(0, 0, ImageSize.X, ImageSize.Y);
      OffsetRect(R, -x, -y);
      FGraph.Print(aPrintPreview.Canvas, R); { or some other stretched drawing thing }
      { step horizontally }
      if (x + PrintSize.X < ImageSize.X) then
      begin
        Inc(x, PrintSize.X);
        aPrintPreview.NewPage;
      end
      else
      begin
        x := 0;
        Inc(y, PrintSize.Y);
        { step vertically }
        if (y < ImageSize.Y) then
        begin
          aPrintPreview.NewPage;
        end
        else
        begin
          y := 0;
          Break;
        end;
      end;
    end;
  end
  else
  begin
    { centered single page printing }
    InflateRect(R,
      -(PrintSize.X - ImageSize.X) div 2,
      -(PrintSize.Y - ImageSize.Y) div 2);
    FGraph.Print(aPrintPreview.Canvas, R);
  end;
  aPrintPreview.EndDoc;
end;


Works like magic if you don't mind me saying so.
Back to top
View user's profile Send private message
MeW
Member


Joined: 17 Feb 2005
Posts: 6
Location: Netherlands

PostPosted: 19/02/05 20:10    Post subject: Centering and Overlap Reply with quote

I've extended the previous code post with a centering option (works for single and multipage) and an overlap % for multipage. Have fun.
Code:

procedure TMainFrm.Printgraph(
  aPrintPreview: TPrintPreview;
  aScale: real;
  aCenter: boolean;
  aOverlapMultipage: real);
var
  R: TRect;
  ImageSize, PrintSize: TPoint;
  Centering: TPoint;
  x, y: integer;
begin
  aPrintPreview.BeginDoc;

  R := aPrintPreview.PrinterPageBounds;
  PrintSize.X := R.Right-R.Left;
  PrintSize.Y := R.Bottom-R.Top;
  ImageSize.X := Trunc(PrintSize.X * aScale);
  ImageSize.Y := Trunc(PrintSize.Y * aScale);
  FillChar(Centering, SizeOf(Centering), #0);

  if (ImageSize.X > PrintSize.X) or
    (ImageSize.Y > PrintSize.Y) then
  begin
    { multipage printing }
    if (aOverlapMultipage < 0) then aOverlapMultipage := 0;
    if (aOverlapMultipage > 0.5) then aOverlapMultipage := 0.5;

    if (aCenter) then
    begin
      Centering.X := (PrintSize.X - (ImageSize.X mod PrintSize.X)) div 2;
      Centering.Y := (PrintSize.Y - (ImageSize.Y mod PrintSize.Y)) div 2;
    end;
    x := 0;
    y := 0;
    while (x < ImageSize.X) and (y < ImageSize.Y) do
    begin
      R := Rect(0, 0, ImageSize.X, ImageSize.Y);
      OffsetRect(R, -x + Centering.X, -y + Centering.Y);
      FGraph.Print(aPrintPreview.Canvas, R);
      { step horizontally }
      if (x + PrintSize.X < ImageSize.X) then
      begin
        Inc(x, trunc(PrintSize.X * (1-aOverlapMultiPage)));
        aPrintPreview.NewPage;
      end
      else
      begin
        x := 0;
        Inc(y, trunc(PrintSize.Y * (1-aOverlapMultipage)));
        { step vertically }
        if (y < ImageSize.Y) then
        begin
          aPrintPreview.NewPage;
        end;
      end;
    end;
  end
  else
  begin
    { single page printing }
    InflateRect(R,
      -(PrintSize.X - ImageSize.X) div 2,
      -(PrintSize.Y - ImageSize.Y) div 2);
    if (not aCenter) then
      OffsetRect(R,
        -(PrintSize.X - ImageSize.X) div 2,
        -(PrintSize.Y - ImageSize.Y) div 2);
    FGraph.Print(aPrintPreview.Canvas, R);
  end;
  aPrintPreview.EndDoc;
end;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group