Hello everybody,
as the window hosting my OCC application can be resized, I've noticed that the zoom factor is adjusted in some way (sometimes) when the user changes the window sizes. More in detail, I've seen that when the X size is modified, the zoom level tends to stay the same as long as the scene length is (more or less) equal to the scene width, without caring if the visibility of the scene changes (some objects to the left or to the right could be hidden by the narrowed borders of the viewer). When the window becomes narrower, then a zoom out operation is automatically performed (it appears) in order to keep the visibility qualitatively similar along the Y axis. If the width of the viewer is changed instead, a zoom in or out operation is immediately performed as if the Y dimension is somehow to be kept into account more than the X one. At first I though it was a problem in my application but I saw that also a sample application coming with the C# wrapper (which I'm using) has the same behaviour (see attached pictures, where the zoom in or out is done only in certain circumstances)
I was expecting that a zoom in or out operation is performed every time there is a resize of the viewer. Is it possible to get such a behaviour? Or, other than that, is it possible to disable any zoom in or out operation when resizing the viewer?
Many thanks in advance for your help.
Author
Discussion
8 archived replies
Posts are displayed in their archived order.
01Commenter-1
Did you ever find a solution for this?
Struggling like mad: the underlying opencascade view is being stretched to fit the new window size. Tried lots of attempts at forcing it back to position, but the Scale factors are always returning 1 before/after the resize - and attempt to reset them with SetAxialScale() (based on new window scale) isn't fixing it.
02Commenter-2
All that V3d_View does with camera on resize is basically updates it's aspect ratio V3d_View::MustBeResized() -> V3d_View::SetRatio() -> Graphic3d_Camera::SetAspect().
When window's width is larger than height - visually changing width looks like view is fit vertically and expands/shrinks horizontally, changing height looks like zooming in/out view.
When window's height is larger than width - visually changing height looks like view is fit horizontally and expands/shrinks vertically, changing width looks like zooming in/out view.
If the default behavior doesn't match your application needs, you may implement your own logic on window resizing by updating Graphic3d_Camera interface accessible via V3d_View::Camera().
03Commenter-1
Thanks for the reply - it helps!
Given what you've just said, I'm wondering if there is something going wrong with the underlying scaling calculations. Using example code...
So, the main difference between the codebases is my Zoom() call. But - I would expect a zoom window to be respected on a rescale (wrt the canvas, not the window)? Instead, increasing the window size actually increases the zoom window, as opposed to either (a) ignoring it completely or (b) maintaining the zoom aspect. Easier to describe in pictures, attached. Even more annoying is that myView->Scale() doesn't change its value (3.82) upon a window resize event (despite the obvious change in scale in the view)
Once again I suspect its my misunderstanding somewhere - just doesn't seem to add up.
04Commenter-1
As an update to this, I've spent a lot of time wrapping view/camera code to correct both scaling and also an offset problem introduced by resizing.
The conclusion so that is that this is a QT6 / QOpenGlWidget / OpenGL problem. I came to this after correcting the camera/view, only to find:
a. got massive pixelation of objects after resizing upwards
b. there is an artifical offset introduced in-screen, whereby view point (0,0,0) no longer aligns to "reality" - e.g. my circular grid thinks its at 0, but view is reporting the At() position of 0 offset from where the grid thinks its at.
No, I didn't. Can you expand a little more on this?
If this is related just to mouse position then it won't help as I'm not getting as far as mouse input: just displaying a circular grid and watching it disappear off the side of the window when I resize!
07Commenter-3
You also need to factor in the correct size when the V3d_View requests the size of your Aspect_Window derived class. Something like.