two questions (about SG and PrintPreview components)

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

two questions (about SG and PrintPreview components)

Postby lbc » February 4th, 2004, 8:08 am

Dear Sir
first of all congratulations for your EXCELLENT components, they are really one of the best piece of delphi software i have found around

Now I would appreciate if you could kindly give me a clue about two questions

1) SimpleGraph Demo:
very nice and useful application, i just wonder why moving the shapes (at least on my sysetm (win XP home) seems slow enough. I have also tried to disable the "snap to grid" option but unfortunately the same thing occurs.
How to make the shapes moving around the canvas a little bit faster ?
(when i say "slow" i refer comparing to other graph applications, like OpenOffice Draw, i mean there the shapes "follow" the mouse quickly, in SG they seem "snapped").
It's not a big issue of course, but it would be really great if the shapes could be moved quickly also in SG (as i said Excellent application indeed).

2) PrintPreview (or, better, PaperPreview)
While i have been able to use printpreview without problems, what is exactly the purpose of the PaperPreview component? Infact i haven't found any documentation about it. Is there any sample about it?

thanks in advance for any info/help about the above and again sincere contratulations for your EXCELLENT work!
lbc
Junior Member
Junior Member
 
Posts: 48
Joined: February 4th, 2004, 7:50 am
Location: Italy

Postby Kambiz » February 4th, 2004, 11:47 am

I would like to thank you for your encouraging words. And, I am glad to hear you found these components useful.

  1. The slow movement of object on SG could be because of grids. Especially when grid's size is more than 8 pixels, it could be slower. Honestly, the main reason for this problem is my lack of knowledge to implement a better algorithm to draw objects.
  2. TPaperPreview has been used by TPrintPreview. I thought maybe somebody find a reson to use it alone, so I registered it as a control.

Regards,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

thanks

Postby lbc » February 4th, 2004, 3:36 pm

Dear Mr Kambiz
thank you very much for your reply
I confirm that your components are both useful and excellent: very neat piece of software indeed, also very handful to learn something about how to write a good component
by the way in my opinion also your website is very good and easy to navigate

Keep up the excellent work!

best regards
lbc
Junior Member
Junior Member
 
Posts: 48
Joined: February 4th, 2004, 7:50 am
Location: Italy

Postby Kambiz » February 5th, 2004, 11:38 am

Thank you so much! :oops:
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby lbc » February 6th, 2004, 10:17 am

Dear Mr Kambiz
as i said It's really true: your components rule! I have downloaded tons and tons of components but yours seem to me among the BEST (both useful and fine) ever found all around the many delphi sites

Now, As far as the SG "slow shapes moving" little issue I have found inside my snippet base (sorry don't remember where exactly found this snippet) the following "simple drawing program". It seems to me that the shapes can be moved here a little bit faster (at least on my Win XP hoe system).
Unfortunately I am non as expert and great programmer as you and currently i am not able to locate the SG compmenent or demo code section in order to insert these lines and hopefully get a little fatser response in the SG demo shapes moving action, but i post it here just in case this could help you a little bit for example in a future SG release.

Of course i don't know if this example is too simple to you, or if it can't be actually included in SG due to different implementation concepts or similiar things anyway i hope it helps!

again my sincere thanks and congratulations for your excellent work

Code: Select all
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Line1: TMenuItem;
    Rectangle1: TMenuItem;
    Circle1: TMenuItem;
    RoundRectangle1: TMenuItem;
    RoundSquare1: TMenuItem;
    Square1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure PopupMenuClick(Sender: TObject);
    procedure DrawGhost;
  private
    ObjType : TShapeType;
    NewObj  : TShape;
    X1,Y1   : Integer;
    X2,Y2   : Integer;
    X3,Y3   : Integer;
    Grabbed : Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Canvas.Pen.Mode := pmXOr;
  Canvas.Pen.Style := psDot;
  ObjType := stCircle;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  L,T,W,H : Integer;
begin
  if Button <> mbLeft then exit;
  if (X=X1) and (Y=Y1) then exit;
  DrawGhost; // Undraw the last rubber-banding image
  X2 := X; Y2 := Y;
  NewObj := TShape.Create(Self);
  with NewObj do
    begin
      // We don't need to worry about destroying these shapes. They are in the Form's
      // components list and will be automatically destroyed when the form closes.
      Parent := Self;
      Shape := ObjType;
      // Setup mouse handlers for shape
      OnMouseDown := ShapeMouseDown;
      OnMouseUp := ShapeMouseUp;
      OnMouseMove := ShapeMouseMove;
      if X1 < X2 then L := X1    else L := X2;
      if X1 < X2 then W := X2-X1 else W := X1-X2;
      if Y1 < Y2 then T := Y1    else T := Y2;
      if Y1 < Y2 then H := Y2-Y1 else H := Y1-Y2;
      if ObjType in [stCircle,stSquare,stRoundSquare] then
        if W < H then H := W else W := H;
      SetBounds(L,T,W,H);
    end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button <> mbLeft then exit;
  X1 := X; Y1 := Y; X2 := X; Y2 := Y;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if ssLeft in Shift then
    begin
      DrawGhost;  // Undraw the last image
      X2 := X; Y2 := Y;
      DrawGhost;  // Draw the new image
    end;
end;

procedure TForm1.ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Grabbed := False;
end;

procedure TForm1.ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  // Bring the shape to the front
  (Sender as TShape).BringToFront;
  // Save where the mouse goes down inside this shape
  X3 := X; Y3 := Y;
  Grabbed := True;
end;

procedure TForm1.ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if Grabbed then
    with (Sender as TShape) do
      // Move the shape to the new location
      SetBounds(Left+X-X3,Top+Y-Y3,Width,Height);
end;

procedure TForm1.PopupMenuClick(Sender: TObject);
begin
  // Change the checked item
  (Sender as TMenuItem).Checked := True;
  // Save the type of shape we selected
  ObjType := TShapeType((Sender as TMenuItem).Tag);
end;

procedure TForm1.DrawGhost;
begin
  // Draw a rubber-banding image of the object
  with Canvas do
  if ObjType in [stCircle,stEllipse] then
    Arc(X1,Y1,X2,Y2,X1,Y1,X1,Y1)
  else
    begin
      PolyLine([Point(X1,Y1),Point(X2,Y1),Point(X2,Y2)]);
      PolyLine([Point(X1,Y1),Point(X1,Y2),Point(X2,Y2)]);
    end;
end;

end.

 
lbc
Junior Member
Junior Member
 
Posts: 48
Joined: February 4th, 2004, 7:50 am
Location: Italy

Postby Kambiz » February 6th, 2004, 8:11 pm

Definitely the above code is much faster than SG.
I think it's faster because:
  1. It doesn't draw grids
  2. It doesn't fill the body of objects with brush or background image
  3. It doesn't draw the object's caption
  4. It doesn't calculate the intersection points of objects and links
  5. It doesn't draw markers of the selection
  6. It doesn't calculate the scroll bars' range and position

Cheers,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron