Hi Vincent, "V. de Weger" <[EMAIL PROTECTED]> wrote on 02/01/2007 09:53:29 AM:
> One of our customers uses 'preset keys'. They can save a zoomed and panned > SVG and reload that in a later run of the application. This has been > implemented by saving the rendering transform to a file and apply that > transform the second run. > As long as they do this on the same PC it works fine. When they reload on a > machine with either less virtual screens (usually they use machines with 4 > screens in a 2x2 setup), or with different screen resolutions the SVG is > reloaded on a different pan position. Is it really a different pan position? I would expect that the upper left corner would be the same, is that not the case? > (1) What is the best way to do this? I guess whe have to use the > getViewing/getRendering/getViewBox api's in some order/configuration, but we > can't figure out the correct way. You probably need to figure out the region of the document that is "actually" displayed. This is best done by using 'getScreenCTM' on the root SVG element [M], taking the inverse of that matrix [I], then mapping the corners of the JSVGCanvas through the [I] matrix. This is probably the information you want to record for later playback. Then once the document is loaded, you will want to use the current getScreenCTM to calculate a 'delta' transform to apply to the current rendering transform in order to make the recorded corner points visible (this will take into account the different 'viewing transform' established by the viewbox and the new canvas size). If you don't need to worry about rotation you can do something like get the screen CTM map the upper left corner to 'display' space the result is the "location" of the previous upper left corner on the screen (which might not be on the screen any more). You then want to create a transform with the negative of that coordinate as the translate (this will 'pan' the document so that corner is at 0,0 on the screen). Then you can map the lower right corner through the screen CTM. This will allow you to calculate the size of the original view on the screen with the current screen CTM. This can then be used to calculate a scale factor to apply (after the translate). > (2) Do we have to set the aspect ratio to a specific value? When you get the size of the old screen on the new screen you can notice that the aspect ratios don't match. At this point you can choose one of two basic strategies, fit or slice. If you choose fit, then you select your scale so the relatively larger of the two dimensions set's your scale (essentially selecting the smaller scale factor) - this will lead to some extra content being seen in the other dimension (probably fine for a mapping application), slice uses the relatively smaller of the two dimension (essentially selecting the larger scale factor) - this will lead to some cropping. In either of these two cases you will probably need to tweak the transform's translate to keep stuff centered. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
