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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problem "synching" two separate images...
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - Dec 13 2012 :  05:46:23  Show Profile  Reply
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;

w2m

USA
1990 Posts

Posted - Dec 13 2012 :  09:26:38  Show Profile  Reply
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
Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Dec 13 2012 :  11:20:40  Show Profile  Reply
Thank you Bill - as ever, I am in your debt - I'll give it a try in the morning!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: