From: Natalia ERMOLAEVA Date: Sat, 11 Apr 2020 07:01:59 +0000 (+0300) Subject: 0031354: Visualization - Dump improvement for V3d, Graphic3d, Aspect X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR0_SHI_IR-2020-02-28;p=occt-copy.git 0031354: Visualization - Dump improvement for V3d, Graphic3d, Aspect --- diff --git a/src/SelectMgr/SelectMgr_Frustum.hxx b/src/SelectMgr/SelectMgr_Frustum.hxx index d758bb5e9f..4e97f0a38b 100644 --- a/src/SelectMgr/SelectMgr_Frustum.hxx +++ b/src/SelectMgr/SelectMgr_Frustum.hxx @@ -58,6 +58,9 @@ public: SelectMgr_Frustum() : SelectMgr_BaseFrustum() {}; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: // SAT Tests for different objects diff --git a/src/SelectMgr/SelectMgr_Frustum.lxx b/src/SelectMgr/SelectMgr_Frustum.lxx index b923f01864..359e3c669d 100644 --- a/src/SelectMgr/SelectMgr_Frustum.lxx +++ b/src/SelectMgr/SelectMgr_Frustum.lxx @@ -461,3 +461,49 @@ Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt1, return Standard_True; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +template +void SelectMgr_Frustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const +{ + OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) + + const Standard_Integer anIncFactor = (myIsOrthographic && N == 4) ? 2 : 1; + for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < N + 1; aPlaneIdx += anIncFactor) + { + const gp_Vec& aPlane = myPlanes[aPlaneIdx]; + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aPlane) + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxVertsProjections[aPlaneIdx]) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMinVertsProjections[aPlaneIdx]) + } + + for (Standard_Integer aVertIdx = 0; aVertIdx < N * 2; ++aVertIdx) + { + const gp_Pnt& aVertex = myVertices[aVertIdx]; + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &aVertex) + } + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic) + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder) + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera) + + for (Standard_Integer anIndex = 0; anIndex < 3; anIndex++) + { + Standard_Real aMaxOrthoVertsProjections = myMaxOrthoVertsProjections[anIndex]; + Standard_Real aMinOrthoVertsProjections = myMinOrthoVertsProjections[anIndex]; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aMaxOrthoVertsProjections) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aMinOrthoVertsProjections) + } + + for (Standard_Integer anIndex = 0; anIndex < 6; anIndex++) + { + gp_Vec anEdgeDir = myEdgeDirs[anIndex]; + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &anEdgeDir) + } +} diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index a89e7f3f87..9d282771f0 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -750,3 +750,20 @@ void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector thePlaneEquations.Append (anEquation); } } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_RectangularFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_RectangularFrustum) + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_Frustum) + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myNearPickedPnt) + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myFarPickedPnt) + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewRayDir) + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMousePos) + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myScale) +} diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx index 81411401e6..83297a64c0 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -129,6 +129,9 @@ public: //! Ax + By + Cz + D = 0) to the given vector Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; + protected: Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1, diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index 03cbffa88f..a3ac21f129 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -495,7 +495,7 @@ void SelectMgr_SelectingVolumeManager::DumpJson (Standard_OStream& theOStream, S for (Standard_Integer anIdx = 0; anIdx < VolumeTypesNb; ++anIdx) { const Handle(SelectMgr_BaseFrustum)& aSelectingVolume = mySelectingVolumes[anIdx]; - OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aSelectingVolume.get()) + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aSelectingVolume.get()) } OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myViewClipPlanes.get()) diff --git a/src/SelectMgr/SelectMgr_SelectionManager.hxx b/src/SelectMgr/SelectMgr_SelectionManager.hxx index 7c81974652..cb0c111287 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.hxx @@ -35,6 +35,9 @@ public: //! Return the Selector. const Handle(SelectMgr_ViewerSelector)& Selector() const { return mySelector; } + + //! Return the Selector. + void SetSelector (const Handle(SelectMgr_ViewerSelector)& theSelector) { mySelector = theSelector; } //! Returns true if the manager contains the selectable object theObject. Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx index 1de02a4326..e7b9aa37c4 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.cxx @@ -302,3 +302,13 @@ void SelectMgr_TriangularFrustum::GetPlanes (NCollection_Vector& thePlaneEquations.Append (aPlaneEquation); } } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_TriangularFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_TriangularFrustum) + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_Frustum) +} \ No newline at end of file diff --git a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx index fcebf8e3a9..2a37887542 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustum.hxx @@ -93,6 +93,9 @@ public: //! Ax + By + Cz + D = 0) to the given vector Standard_EXPORT virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; + private: void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index 7da53986e4..b333303cde 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -243,4 +243,20 @@ void SelectMgr_TriangularFrustumSet::GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; + private: SelectMgr_TriangFrustums myFrustums; diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index f42d368d36..9ed7178168 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -1059,7 +1059,7 @@ void SelectMgr_ViewerSelector::DumpJson (Standard_OStream& theOStream, Standard_ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToUpdateTolerance) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mystored.Extent()) - OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &mySelectingVolumeMgr) + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &mySelectingVolumeMgr) OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &mySelectableObjects) Standard_Integer aNbOfSelectableObjects = 0; diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index ecbbb4c3f3..85d3755710 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -21,6 +21,8 @@ VInspector_ItemHistoryType.hxx VInspector_ItemHistoryTypeInfo.hxx VInspector_ItemPresentableObject.cxx VInspector_ItemPresentableObject.hxx +VInspector_ItemSelectMgrViewerSelector.cxx +VInspector_ItemSelectMgrViewerSelector.hxx VInspector_ItemV3dViewer.cxx VInspector_ItemV3dViewer.hxx VInspector_ToolActionType.hxx diff --git a/tools/VInspector/VInspector_ItemContextProperties.cxx b/tools/VInspector/VInspector_ItemContextProperties.cxx index 798345f266..020d02821c 100644 --- a/tools/VInspector/VInspector_ItemContextProperties.cxx +++ b/tools/VInspector/VInspector_ItemContextProperties.cxx @@ -17,6 +17,7 @@ #include #include +#include // ======================================================================= // function : initValue @@ -40,7 +41,7 @@ QVariant VInspector_ItemContextProperties::initValue (int theItemRole) const // ======================================================================= int VInspector_ItemContextProperties::initRowCount() const { - return 1; // V3d_Viewer + return 2; // V3d_Viewer, SelectMgr_ViewerSelector } // ======================================================================= @@ -49,7 +50,10 @@ int VInspector_ItemContextProperties::initRowCount() const // ======================================================================= TreeModel_ItemBasePtr VInspector_ItemContextProperties::createChild (int theRow, int theColumn) { - return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn); + if (theRow == 0) + return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn); + + return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn); } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx new file mode 100644 index 0000000000..3846f94018 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -0,0 +1,105 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemSelectMgrViewerSelector::initRowCount() const +{ + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemSelectMgrViewerSelector::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + if (GetViewerSelector().IsNull()) + return Column() == 0 ? "Empty viewer selector" : ""; + + return Column() == 0 ? GetViewerSelector()->DynamicType()->Name() : QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::Init() +{ + VInspector_ItemContextPropertiesPtr aParentItem = itemDynamicCast(Parent()); + Handle(SelectMgr_ViewerSelector) aViewerSelector; + if (aParentItem) + { + VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(aParentItem->Parent()); + if (aParentContextItem) + { + Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext(); + aViewerSelector = aContext->MainSelector(); + } + } + myViewerSelector = aViewerSelector; + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::Reset() +{ + VInspector_ItemBase::Reset(); + + myViewerSelector = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initStream +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::initStream (Standard_OStream& theOStream) const +{ + Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + if (aViewerSelector.IsNull()) + return; + + aViewerSelector->DumpJson (theOStream); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx new file mode 100644 index 0000000000..aa2d4c7fb3 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx @@ -0,0 +1,85 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemSelectMgrViewerSelector_H +#define VInspector_ItemSelectMgrViewerSelector_H + +#include +#include + +#include + +class VInspector_ItemSelectMgrViewerSelector; +typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrViewerSelectorPtr; + +//! \class VInspector_ItemSelectMgrViewerSelector +//! Parent item is context properties, that corresponds to SelectMgr_ViewerSelector +class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemSelectMgrViewerSelectorPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemSelectMgrViewerSelectorPtr (new VInspector_ItemSelectMgrViewerSelector (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemSelectMgrViewerSelector() Standard_OVERRIDE {}; + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns data object of the item. + //! \return object + virtual const Handle(Standard_Transient)& Object() const { initItem(); return myViewerSelector; } + + //! Returns the current viewer, init item if it was not initialized yet + //! \return interactive object + Handle(SelectMgr_ViewerSelector) GetViewerSelector() const { return Handle(SelectMgr_ViewerSelector)::DownCast (Object()); } + +protected: + //! Initializes the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + VInspector_ItemSelectMgrViewerSelector (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +protected: + + Handle(SelectMgr_ViewerSelector) myViewerSelector; //!< the current viewer selector +}; + +#endif