[Bug?] V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V)

When copying a V3d_OrthographicView via
V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V)
the default view mapping is not preserved but just set to the current view mapping of V.

The problem becomes visible if the view V was scaled and the new view is scaled again because scaling is relative to the default view mapping.

A possible solutiong might be to change:

V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V) {
MyType = V3d_ORTHOGRAPHIC ;
MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;
SetViewMappingDefault() ;
SetViewOrientationDefault() ;
}

to:

V3d_OrthographicView::V3d_OrthographicView (const Handle(V3d_Viewer)& VM, const Handle(V3d_OrthographicView)& V):V3d_View (VM,V) {
MyType = V3d_ORTHOGRAPHIC ;
MyViewMapping.SetProjection(Visual3d_TOP_PARALLEL) ;

Visual3d_ViewMapping oldMapping(MyViewMapping);
V->ResetViewMapping();
SetViewMapping( V->ViewMapping() ) ;

SetViewMappingDefault() ;
SetViewOrientationDefault() ;

SetViewMapping( oldMapping ) ;
}

In the same way also V3d_PerspectiveView would have to be changed.

Do you regard this as a bug and possible fix?

Regards,
Timo

Timo Roth's picture

In order to reproduce the problem you can use the Import-Export MFC sample.

Modify samples/mfc/05_ImportExport/src/ImportExportDoc.cpp
@@ -265 +265 @@
- Fit();
+ //Fit();

Modify samples/mfc/Common/OCC_3dView.cpp:

@@ -12,0 +13 @@
+#include
@@ -114,0 +116,3 @@
+
+ // scale first view
+ myView->SetScale(0.3);
@@ -115,0 +120,9 @@
+ if (myView->Type() == V3d_ORTHOGRAPHIC)
+ {
+ // create second view
+ Handle_V3d_View oldView = myView;
+ myView = new V3d_OrthographicView(GetDocument()->GetViewer(), (Handle_V3d_OrthographicView &) oldView );
+ // scale second view
+ myView->SetScale(0.3);
+ V3d::SwitchViewsinWindow( oldView, myView );
+ }

Now, when you start the Import Export sample and click (twice) on the button for creating a box, it will appear without being fit on the window.
If you comment out the scaling of the second view the box will be bigger, although second view is just a copy of the first view and is scaled by the same factor.

Timo