diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index a794d5168d..5bf62ef55b 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -122,14 +122,13 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); myView->CopySettings (theView->View()); + myDefaultViewPoint = theView->myDefaultViewPoint; + myDefaultViewAxis = theView->myDefaultViewAxis; - myDefaultCamera = new Graphic3d_Camera(); + myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera()); myImmediateUpdate = Standard_False; SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor()); - SetAxis (0.0, 0.0, 0.0, 1.0, 1.0, 1.0); - SetViewMappingDefault(); - SetViewOrientationDefault(); theViewer->AddView (this); Init(); myImmediateUpdate = Standard_True; diff --git a/src/V3d/V3d_Viewer.hxx b/src/V3d/V3d_Viewer.hxx index 4e1c1d5653..306ed9f954 100644 --- a/src/V3d/V3d_Viewer.hxx +++ b/src/V3d/V3d_Viewer.hxx @@ -172,6 +172,10 @@ public: //! Gives the default type of SHADING. void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myShadingModel = theType; } + //! Returns the default type of View (orthographic or perspective projection) to be returned by CreateView() method. + V3d_TypeOfView DefaultTypeOfView() const { return myDefaultTypeOfView; } + + //! Set the default type of View (orthographic or perspective projection) to be returned by CreateView() method. void SetDefaultTypeOfView (const V3d_TypeOfView theType) { myDefaultTypeOfView = theType; } //! Returns the default background colour object. diff --git a/src/ViewerTest/ViewerTest.hxx b/src/ViewerTest/ViewerTest.hxx index 6990048f93..65a77d3915 100644 --- a/src/ViewerTest/ViewerTest.hxx +++ b/src/ViewerTest/ViewerTest.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,8 +32,6 @@ class AIS_InteractiveContext; class AIS_InteractiveObject; -class TCollection_AsciiString; -class Standard_Transient; class Image_PixMap; class V3d_View; class V3d_Viewer; @@ -49,14 +48,22 @@ public: Standard_EXPORT static void Factory (Draw_Interpretor& theDI); //! Creates view with default or custom name - //! and add this name in map to manage muliple views - //! implemented in ViewerTest_ViewerCommands.cxx + //! and adds this name in map to manage multiple views. + //! Implemented in ViewerTest_ViewerCommands.cxx. + //! @param thePxLeft left position of newly created window + //! @param thePxTop top position of newly created window + //! @param thePxWidth width of newly created window + //! @param thePxHeight height of newly created window + //! @param theViewName name of newly created View + //! @oaram theDisplayName display name + //! @param theViewToClone when specified, the new View will copy properties of existing one Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0, const Standard_Integer thePxTop = 0, const Standard_Integer thePxWidth = 0, const Standard_Integer thePxHeight = 0, - const Standard_CString theViewName = "", - const Standard_CString theDisplayName = ""); + const TCollection_AsciiString& theViewName = "", + const TCollection_AsciiString& theDisplayName = "", + const Handle(V3d_View)& theViewToClone = Handle(V3d_View)()); Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 1c1edadafc..76ca3799f8 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -529,8 +529,9 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft const Standard_Integer thePxTop, const Standard_Integer thePxWidth, const Standard_Integer thePxHeight, - Standard_CString theViewName, - Standard_CString theDisplayName) + const TCollection_AsciiString& theViewName, + const TCollection_AsciiString& theDisplayName, + const Handle(V3d_View)& theViewToClone) { // Default position and dimension of the viewer window. // Note that left top corner is set to be sufficiently small to have @@ -542,6 +543,10 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft Standard_Integer aPxWidth = 409; Standard_Integer aPxHeight = 409; Standard_Boolean toCreateViewer = Standard_False; + if (!theViewToClone.IsNull()) + { + theViewToClone->Window()->Size (aPxWidth, aPxHeight); + } Handle(OpenGl_GraphicDriver) aGraphicDriver; ViewerTest_Names aViewNames(theViewName); @@ -711,7 +716,16 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft VT_GetWindow()->SetVirtual (Draw_VirtualWindows); // View setup - Handle(V3d_View) aView = a3DViewer->CreateView(); + Handle(V3d_View) aView; + if (!theViewToClone.IsNull()) + { + aView = new V3d_View (a3DViewer, theViewToClone); + } + else + { + aView = new V3d_View (a3DViewer, a3DViewer->DefaultTypeOfView()); + } + aView->SetWindow (VT_GetWindow()); ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer); @@ -779,6 +793,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha { TCollection_AsciiString aViewName, aDisplayName; Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0; + Handle(V3d_View) aCopyFrom; TCollection_AsciiString aName, aValue; for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) { @@ -839,6 +854,15 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha { aDisplayName = theArgVec[++anArgIt]; } + else if (!ViewerTest::CurrentView().IsNull() + && aCopyFrom.IsNull() + && (anArgCase == "-copy" + || anArgCase == "-clone" + || anArgCase == "-cloneactive" + || anArgCase == "-cloneactiveview")) + { + aCopyFrom = ViewerTest::CurrentView(); + } // old syntax else if (ViewerTest::SplitParameter (anArg, aName, aValue)) { @@ -906,8 +930,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha } TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight, - aViewName.ToCString(), - aDisplayName.ToCString()); + aViewName, aDisplayName, aCopyFrom); theDi << aViewId; return 0; } @@ -6404,10 +6427,8 @@ static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const ? int(anImgRef->SizeY() * 2) : int(anImgRef->SizeY()); TCollection_AsciiString aDisplayName; - TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, - aWinSizeX, aWinSizeY, - aViewName.ToCString(), - aDisplayName.ToCString()); + TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aWinSizeX, aWinSizeY, + aViewName, aDisplayName); Standard_Real aRatio = anImgRef->Ratio(); Standard_Real aSizeX = 1.0; @@ -11646,7 +11667,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) const char *group = "ZeViewer"; theCommands.Add("vinit", "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]" - "\n\t\t: [-exitOnClose] [-closeOnEscape]" + "\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive]" #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) "\n\t\t: [-display displayName]" #endif @@ -11662,6 +11683,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) #endif "\n\t\t: -left, -top pixel position of left top corner of the window." "\n\t\t: -width, -height width and heigth of window respectively." + "\n\t\t: -cloneActive floag to copy camera and dimensions of active view." "\n\t\t: -exitOnClose when specified, closing the view will exit application." "\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape." "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",