1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0026127: Visualization - Default camera is not copied in copy constructor of V3d_View

V3d_View copy constructor now copies DefaultCamera() from specified View.
Draw Harness command vinit - added new argument -cloneActive.
This commit is contained in:
kgv 2018-03-08 13:52:01 +03:00 committed by bugmaster
parent 81ce8c4de3
commit 9e04ccdcf8
4 changed files with 52 additions and 20 deletions

View File

@ -122,14 +122,13 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)&
myView = theViewer->Driver()->CreateView (theViewer->StructureManager()); myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
myView->CopySettings (theView->View()); myView->CopySettings (theView->View());
myDefaultViewPoint = theView->myDefaultViewPoint;
myDefaultViewAxis = theView->myDefaultViewAxis;
myDefaultCamera = new Graphic3d_Camera(); myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera());
myImmediateUpdate = Standard_False; myImmediateUpdate = Standard_False;
SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor()); SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor());
SetAxis (0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
SetViewMappingDefault();
SetViewOrientationDefault();
theViewer->AddView (this); theViewer->AddView (this);
Init(); Init();
myImmediateUpdate = Standard_True; myImmediateUpdate = Standard_True;

View File

@ -172,6 +172,10 @@ public:
//! Gives the default type of SHADING. //! Gives the default type of SHADING.
void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myShadingModel = theType; } 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; } void SetDefaultTypeOfView (const V3d_TypeOfView theType) { myDefaultTypeOfView = theType; }
//! Returns the default background colour object. //! Returns the default background colour object.

View File

@ -24,6 +24,7 @@
#include <Standard_CString.hxx> #include <Standard_CString.hxx>
#include <Standard_DefineAlloc.hxx> #include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx> #include <Standard_Macro.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_HArray1OfTransient.hxx> #include <TColStd_HArray1OfTransient.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <TopTools_HArray1OfShape.hxx> #include <TopTools_HArray1OfShape.hxx>
@ -31,8 +32,6 @@
class AIS_InteractiveContext; class AIS_InteractiveContext;
class AIS_InteractiveObject; class AIS_InteractiveObject;
class TCollection_AsciiString;
class Standard_Transient;
class Image_PixMap; class Image_PixMap;
class V3d_View; class V3d_View;
class V3d_Viewer; class V3d_Viewer;
@ -49,14 +48,22 @@ public:
Standard_EXPORT static void Factory (Draw_Interpretor& theDI); Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
//! Creates view with default or custom name //! Creates view with default or custom name
//! and add this name in map to manage muliple views //! and adds this name in map to manage multiple views.
//! implemented in ViewerTest_ViewerCommands.cxx //! 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, Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0,
const Standard_Integer thePxTop = 0, const Standard_Integer thePxTop = 0,
const Standard_Integer thePxWidth = 0, const Standard_Integer thePxWidth = 0,
const Standard_Integer thePxHeight = 0, const Standard_Integer thePxHeight = 0,
const Standard_CString theViewName = "", const TCollection_AsciiString& theViewName = "",
const Standard_CString theDisplayName = ""); const TCollection_AsciiString& theDisplayName = "",
const Handle(V3d_View)& theViewToClone = Handle(V3d_View)());
Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName); Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);

View File

@ -529,8 +529,9 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
const Standard_Integer thePxTop, const Standard_Integer thePxTop,
const Standard_Integer thePxWidth, const Standard_Integer thePxWidth,
const Standard_Integer thePxHeight, const Standard_Integer thePxHeight,
Standard_CString theViewName, const TCollection_AsciiString& theViewName,
Standard_CString theDisplayName) const TCollection_AsciiString& theDisplayName,
const Handle(V3d_View)& theViewToClone)
{ {
// Default position and dimension of the viewer window. // Default position and dimension of the viewer window.
// Note that left top corner is set to be sufficiently small to have // 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 aPxWidth = 409;
Standard_Integer aPxHeight = 409; Standard_Integer aPxHeight = 409;
Standard_Boolean toCreateViewer = Standard_False; Standard_Boolean toCreateViewer = Standard_False;
if (!theViewToClone.IsNull())
{
theViewToClone->Window()->Size (aPxWidth, aPxHeight);
}
Handle(OpenGl_GraphicDriver) aGraphicDriver; Handle(OpenGl_GraphicDriver) aGraphicDriver;
ViewerTest_Names aViewNames(theViewName); ViewerTest_Names aViewNames(theViewName);
@ -711,7 +716,16 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
VT_GetWindow()->SetVirtual (Draw_VirtualWindows); VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
// View setup // 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()); aView->SetWindow (VT_GetWindow());
ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer); ViewerTest::GetAISContext()->RedrawImmediate (a3DViewer);
@ -779,6 +793,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
{ {
TCollection_AsciiString aViewName, aDisplayName; TCollection_AsciiString aViewName, aDisplayName;
Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0; Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
Handle(V3d_View) aCopyFrom;
TCollection_AsciiString aName, aValue; TCollection_AsciiString aName, aValue;
for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt) 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]; aDisplayName = theArgVec[++anArgIt];
} }
else if (!ViewerTest::CurrentView().IsNull()
&& aCopyFrom.IsNull()
&& (anArgCase == "-copy"
|| anArgCase == "-clone"
|| anArgCase == "-cloneactive"
|| anArgCase == "-cloneactiveview"))
{
aCopyFrom = ViewerTest::CurrentView();
}
// old syntax // old syntax
else if (ViewerTest::SplitParameter (anArg, aName, aValue)) 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, TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
aViewName.ToCString(), aViewName, aDisplayName, aCopyFrom);
aDisplayName.ToCString());
theDi << aViewId; theDi << aViewId;
return 0; return 0;
} }
@ -6404,10 +6427,8 @@ static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const
? int(anImgRef->SizeY() * 2) ? int(anImgRef->SizeY() * 2)
: int(anImgRef->SizeY()); : int(anImgRef->SizeY());
TCollection_AsciiString aDisplayName; TCollection_AsciiString aDisplayName;
TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aWinSizeX, aWinSizeY,
aWinSizeX, aWinSizeY, aViewName, aDisplayName);
aViewName.ToCString(),
aDisplayName.ToCString());
Standard_Real aRatio = anImgRef->Ratio(); Standard_Real aRatio = anImgRef->Ratio();
Standard_Real aSizeX = 1.0; Standard_Real aSizeX = 1.0;
@ -11646,7 +11667,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
const char *group = "ZeViewer"; const char *group = "ZeViewer";
theCommands.Add("vinit", theCommands.Add("vinit",
"vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]" "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)) #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
"\n\t\t: [-display displayName]" "\n\t\t: [-display displayName]"
#endif #endif
@ -11662,6 +11683,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
#endif #endif
"\n\t\t: -left, -top pixel position of left top corner of the window." "\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: -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: -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: -closeOnEscape when specified, view will be closed on pressing Escape."
"\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.", "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",