ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problem "synching" two separate images...

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bmesser Posted - Dec 13 2012 : 05:46:23
Hi

I have two images - weather charts from different forecast models for the same day with approximately the same image size and map background - displayed in two separate tool windows. I want to synch the two imageEnView components so that where ever I pan and how ever much I zoom in one is mirrored in the image in the other window. When I add the code below to both units I obviously get feedback from the changes I make which ruin any chances of synching the images. Is there any clever method of tying the two images together to make this work?

Bruce.

procedure ImageViewChange(Sender: TObject; Change: Integer);
begin
  if assigned(fmEditAnalysisDlg) and fmEditAnalysisDlg.Visible then
  begin
    fmEditAnalysisDlg.Image.Zoom  :=Image.Zoom;
    fmEditAnalysisDlg.Image.ViewX :=Image.ViewX;
    fmEditAnalysisDlg.Image.ViewY :=Image.ViewY;
  end;
end;
2   L A T E S T    R E P L I E S    (Newest First)
bmesser Posted - Dec 13 2012 : 11:20:40
Thank you Bill - as ever, I am in your debt - I'll give it a try in the morning!
w2m Posted - Dec 13 2012 : 09:26:38
You have to handle zoom as well as ViewChange and you also need a public variable so that only one view change is executed:

Main Form
type
  TFormMain = class(TForm)
...
  public
    { Public declarations }
    ViewChange1Changing: boolean;
    ViewChange2Changing: boolean;
...
end;

procedure TFormMain.ImageEnView1ZoomIn(Sender: TObject; var NewZoom: double);
begin
  ImageEnView1.Zoom := NewZoom;
  Form1.ImageENView1.Zoom := NewZoom;
  TrackBar1.Position := Round(NewZoom);
  Form1.TrackBar1.Position := Round(NewZoom);
  StatusBar1.Panels[0].Text := 'Zoom: ' + IntToStr(Round(ImageEnView1.Zoom));
end;

procedure TFormMain.ImageEnView1ZoomOut(Sender: TObject; var NewZoom: double);
begin
  ImageEnView1.Zoom := NewZoom;
  Form1.ImageEnView1.Zoom := NewZoom;
  TrackBar1.Position := Round(NewZoom);
  Form1.TrackBar1.Position := Round(NewZoom);
  StatusBar1.Panels[0].Text := 'Zoom: ' + IntToStr(Round(ImageEnView1.Zoom));
end;

procedure TFormMain.ImageEnView1ViewChange(Sender: TObject; Change: integer);
begin
  if (Change = 0) and (not ViewChange2Changing) then
  begin
    ViewChange1Changing := True;
    Form1.ImageEnView1.ViewX := ImageEnView1.ViewX;
    Form1.ImageEnView1.ViewY := ImageEnView1.ViewY;
    Form1.ImageEnView1.Update;
    StatusBar1.Panels[1].Text := 'ViewX: ' + IntToStr(ImageEnView1.ViewX);
    StatusBar1.Panels[2].Text := 'ViewY: ' + IntToStr(ImageEnView1.ViewY);
    Form1.StatusBar1.Panels[1].Text := 'ViewX: ' + IntToStr(Form1.ImageEnView1.ViewX);
    Form1.StatusBar1.Panels[2].Text := 'ViewY: ' + IntToStr(Form1.ImageEnView1.ViewY);
    ViewChange1Changing := False;
  end;
end;

Secondary Form
procedure TForm1.ImageEnView1ZoomIn(Sender: TObject; var NewZoom: Double);
begin
  FormMain.ImageEnView1.Zoom := NewZoom;
  ImageEnView1.Zoom := NewZoom;
  TrackBar1.Position := Round(NewZoom);
  FormMain.TrackBar1.Position := Round(NewZoom);
  StatusBar1.Panels[0].Text := 'Zoom: ' + IntToStr(Round(ImageEnView1.Zoom));
end;

procedure TForm1.ImageEnView1ZoomOut(Sender: TObject; var NewZoom: Double);
begin
  FormMain.ImageEnView1.Zoom := NewZoom;
  ImageEnView1.Zoom := NewZoom;
  TrackBar1.Position := Round(NewZoom);
  FormMain.TrackBar1.Position := Round(NewZoom);
  StatusBar1.Panels[0].Text := 'Zoom: ' + IntToStr(Round(ImageEnView1.Zoom));
end;

procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
begin
  if (Change = 0) and (not FormMain.ViewChange1Changing) then
  begin
    FormMain.ViewChange2Changing := True;
    FormMain.ImageEnView1.ViewX := ImageEnView1.ViewX;
    FormMain.ImageEnView1.ViewY := ImageEnView1.ViewY;
    ImageEnView1.Update;
    StatusBar1.Panels[1].Text := 'ViewX: ' + IntToStr(ImageEnView1.ViewX);
    StatusBar1.Panels[2].Text := 'ViewY: ' + IntToStr(ImageEnView1.ViewY);
    FormMain.StatusBar1.Panels[1].Text := 'ViewX: ' + IntToStr(FormMain.ImageEnView1.ViewX);
    FormMain.StatusBar1.Panels[2].Text := 'ViewY: ' + IntToStr(FormMain.ImageEnView1.ViewY);
    FormMain.ViewChange2Changing := False;
  end;
end;



76.68 KB

You may download a demo here:
https://dl.dropbox.com/u/3695621/TwoViewsInTwoWindows.zip

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html