forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Graphic Zoom

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
stenlou



Joined: 24 Jun 2008
Posts: 30
Location: Germany and Denmark

PostPosted: Wed Nov 20, 2013 2:47 pm    Post subject: Graphic Zoom Reply with quote

Is there any way of zooming into a graphic window?

Sten
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Nov 20, 2013 4:02 pm    Post subject: Reply with quote

One way is to use %gr together with a metafile for resizing.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Wed Nov 20, 2013 10:18 pm    Post subject: Reply with quote

If I understand your question; to enable zoom, you have to detect the mouse or wheel action and then have a response which redraws the image. I think you need to write the code to manage the mouse interrupts and respond accordingly for an identified zoom or pan request.
There is no automatic function that I know of.

Copy_Graphics_Region@ offers some zoom capability with images, especially if you use a background virtual image of the screen, but there can be a comprimise of image quality with this approach.
I've often contemplated this approach to manage pan.
It all depends on the way the original image is defined.
I tend to draw my images based on shaded polygons, so I redraw the image to a new scale. It can be packages as a single "call draw_image".

John
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Thu Nov 21, 2013 2:33 am    Post subject: Reply with quote

Zooming is naturally present in the OpenGL graphics. You use mouse scrollbar or mouse keys and all magically zoomes by itself looking very professionally, you just add one-two lines into the text. I mentioned that in "User Examples" (PM me for the source if intertested, no time to place the sources again to the some site and follow if they are automatically removed or not)

In 2D graphics all that has to be made by the programmer, it takes time to make it look professional, but is doable and it works without hiccups too. Here you also can use the scrollbar or select zoomable area with the mouse and then redraw all your graphics. I can not post that example, it is a bit large and shaddy and is part of larger code but in principle i can sent it too. All that was done in Fortran and Clearwin+, by the way. And it does not use metafile_resize and copy_graphics_region which are OK for zooming of graphics images but may not look good for scientific graphics


Last edited by DanRRight on Thu Nov 21, 2013 11:00 pm; edited 2 times in total
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Nov 21, 2013 11:13 am    Post subject: Reply with quote

Hi Stenlou,

You get an insight into scaling and positioning from using a %gr area with a %pv pivot, and then dealing with window resize event. provided that you are using modern hardware, and your graphic is not uber complex, then the redraw is more or less instant. Your graphics image will represent either a real world object, where the scaling is the same in x and y, or an object like a graph, where the scaling in x and y can be different. On first drawing, you may well calculate the one (or two) scale factors from the size in pixels of the %gr area, which you can get using GET_GRAPHICAL_RESOLUTION@.

I normally centre my images, so there are two coordinate offsets (in x and y) to position the image - there's no reason why you shouldn't map a position such as the corner of the screen to a specific point in the graphical object.

Panning the image is a matter of changing one or both of the offsets, zooming is a matter of changing the scale factor(s) - in either case, followed by a redraw. Redrawing is facilitated if you keep all of your drawing code in a single routine (which may call other routines) but which forms a suitable entry point for the screen refresh operations.

Next, you need to decide how you will implement zooming. One way is a menu with various zoom factors that you can use to modify your scaling. Another method is to have a button on a toolbar that when selected, gives you (say) a magnifying glass cursor. If you click on your graphics area, your callback to %gr can give you the position in the object that might be used to re-centre the object (alter the offsets) and change the scaling factor up or down. You could decide to do this on the basis of a left button click or right button click - or using Shift Alt or Ctrl modifier keys. If you do this, then you will find that too big a zoom step is user-unfriendly, and non-linear steps are sometimes better than linear ones.

A third method is to enable graphical area selections via a toolbar button, use GET_GRAPHICS_SELECTED_AREA@ to get the extents you want to zoom IN to, adjust the scaling and offsets, and then redraw. Your toolbar button callback would need to change the cursor, and set a flag which you can read in the %gr callback, so that you know when to use the GET_GRAPHICS_SELECTED_AREA@ call. A disadvantage of the area-selection zoom method is that it doesn't allow you to zoom OUT (which needs another functional control to do, say a 'fit to screen' button), and for an object with the same scaling in x and y, the code to adjust the scaling is a few lines more complex.

You can also interrogate the mouse wheel to get your zoom factor, which obviates the need for either a cursor change, or finding a selected area.

I use two simple functions to map the real world to the %gr area, and two equally simple functions to get back to real world coordinates from pixel positions. These functions use the scale factor(s) and offsets.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
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


Powered by phpBB © 2001, 2005 phpBB Group