Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zooming - not from the center (Read 4835 times)
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Zooming - not from the center
May 29th, 2007 at 12:12pm
Print Post  
Hi,

Is there a way to change a zoom no from the center of the diagram?
I'll explain: let's say I need to zoom on a box - is there a way to zoom so that the box will be in the center of the zooming?

thanks,
Yoav
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zooming - not from the center
Reply #1 - May 29th, 2007 at 12:56pm
Print Post  
Hi,

I think bringIntoView() will center the view on the box, but only if the box is not currently visible. So you might call the zoom() method, scroll to a location where the box won’t be visible, and call bringIntoView() to center on the box.

Stoyan
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: Zooming - not from the center
Reply #2 - May 29th, 2007 at 1:13pm
Print Post  
Thanks - I'll try it later on.
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: Zooming - not from the center
Reply #3 - Jun 13th, 2007 at 2:05pm
Print Post  
Hi,

Ok, so now I move the view to the box and zoom on it. What's now? I didn't need the box to move to the center - only to zoom on a coordinate on screen. So now I move the diagram back?

Moreover, BringIntoView moves the view to an item.
I don't want to zoom on an item - I need the functionality that whenever user's mouse stands, the zoom will be to that apot.
So I know how to identify the document coordinates of the mouse, but how do I zoom to that point?

Thanks,
Yoav
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zooming - not from the center
Reply #4 - Jun 13th, 2007 at 4:51pm
Print Post  
So I thought you need to zoom on a specific box. You could do the following to zoom on any document point:

Code
Select All
// we need the following point to remain where it is after zoom
Point2D zoomHere = ...;
Point zoomHereScreenPoint = fc.DocToDevice(zoomHere);

// the zoom method zooms relatively to the scroll position
fc.setZoomFactor(...);

// check how much the document point has been offset by the zoom
Point2D afterZoom = fc.deviceToDoc(zoomHereScreenPoint);

// add the offset to scrollX/scrollY to make the initial document point coincide with the on-screen zoom center point
fc.setScrollX(fc.getScrollX() - zoomHere.x + afterZoom.x);
fc.setScrollY(fc.getScrollY() - zoomHere.y + afterZoom.y);
 



I haven't actually tested this but it should be pretty close to what you need. If it doesn't work, try swapping the + and - signs in the last two lines.

Stoyan
  
Back to top
 
IP Logged
 
ymoran00
Full Member
***
Offline



Posts: 163
Joined: May 2nd, 2007
Re: Zooming - not from the center
Reply #5 - Jun 14th, 2007 at 10:02am
Print Post  
I used this code for other issues - scrolling diagram according to mouse clicks - and it's great.
Thanks a lot!
Yoav
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint