]> OCCT Git - occt-copy.git/commitdiff
0031354: Visualization - Dump improvement for V3d, Graphic3d, Aspect CR0_SHI_IR-2020-02-28
authorNatalia ERMOLAEVA <nds@nnov.opencascade.com>
Sat, 11 Apr 2020 07:01:59 +0000 (10:01 +0300)
committerNatalia ERMOLAEVA <nds@nnov.opencascade.com>
Sat, 11 Apr 2020 07:01:59 +0000 (10:01 +0300)
15 files changed:
src/SelectMgr/SelectMgr_Frustum.hxx
src/SelectMgr/SelectMgr_Frustum.lxx
src/SelectMgr/SelectMgr_RectangularFrustum.cxx
src/SelectMgr/SelectMgr_RectangularFrustum.hxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx
src/SelectMgr/SelectMgr_SelectionManager.hxx
src/SelectMgr/SelectMgr_TriangularFrustum.cxx
src/SelectMgr/SelectMgr_TriangularFrustum.hxx
src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx
src/SelectMgr/SelectMgr_TriangularFrustumSet.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
tools/VInspector/FILES
tools/VInspector/VInspector_ItemContextProperties.cxx
tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx [new file with mode: 0644]

index d758bb5e9f0fd1b5f1bfb4cb9e722c3f974b8011..4e97f0a38bc0805755a67ce16b9528fb69e71b59 100644 (file)
@@ -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
index b923f0186465cd7cf9f3e66c59b517d2ea11aaeb..359e3c669d22f30b68c4898244f1ea18bd62173e 100644 (file)
@@ -461,3 +461,49 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const gp_Pnt& thePnt1,
 
   return Standard_True;
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  : 
+//=======================================================================
+template <int N>
+void SelectMgr_Frustum<N>::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)
+  }
+}
index a89e7f3f875a14af72f992f15bc6da395c90f71c..9d282771f0dc2cebef86790bf95784714a7ddbb7 100644 (file)
@@ -750,3 +750,20 @@ void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>
     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)
+}
index 81411401e6bd4459c7109767deee237f8f1006dc..83297a64c0cb2aa16b1d74435ad76a7e3a17adc8 100644 (file)
@@ -129,6 +129,9 @@ public:
   //! Ax + By + Cz + D = 0) to the given vector
   Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& 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,
index 03cbffa88f1517b4d3934add82f78e34887c775e..a3ac21f129472122921ff9ec5f4fd2127b10f22a 100644 (file)
@@ -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())
index 7c81974652ad708b3bf02d433e75b38c92d30a23..cb0c111287b4fb725101caca88dd2035a3cb3735 100644 (file)
@@ -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;
index 1de02a43260607ba358640fe15b7383728ce2399..e7b9aa37c42a340d3f140461ec6a25a805f87854 100644 (file)
@@ -302,3 +302,13 @@ void SelectMgr_TriangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>&
     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
index fcebf8e3a95489bf68dcc9b8e88ae1173ec68922..2a37887542b54397a9fa79de51260adcaa8c7d2e 100644 (file)
@@ -93,6 +93,9 @@ public:
   //! Ax + By + Cz + D = 0) to the given vector
   Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& 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;
index 7da53986e4d8ace260bda86a89e0dfa53c3dd016..b333303cde83a3712983516795d431525744fb23 100644 (file)
@@ -243,4 +243,20 @@ void SelectMgr_TriangularFrustumSet::GetPlanes (NCollection_Vector<SelectMgr_Vec
   }
 }
 
+//=======================================================================
+//function : DumpJson
+//purpose  : 
+//=======================================================================
+void SelectMgr_TriangularFrustumSet::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+  OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_TriangularFrustumSet)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_BaseFrustum)
+
+  for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
+  {
+    const Handle(SelectMgr_TriangularFrustum)& aFrustum = anIter.Value();
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aFrustum.get())
+  }
+}
+
 #undef MEMORY_BLOCK_SIZE
index fc2d4c122c647d3f40ead5cf505a82d69166dc2f..c889342bbd77ccd9219cd2efd7887fca957033fe 100644 (file)
@@ -84,6 +84,9 @@ public:
   //! Ax + By + Cz + D = 0) to the given vector
   Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& 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;
index f42d368d36df07ed58d310130edd2b2bb768fe67..9ed717816863a271397ee993d8207e6a3b588ed6 100644 (file)
@@ -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;
index ecbbb4c3f3da7e14670921e012602ed9968758de..85d375571085a670727c7609309990203147d725 100644 (file)
@@ -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
index 798345f2663c69fc7d2d9816542f255caf2c3579..020d02821cb609f3072d307573503f03a1162e82 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <inspector/VInspector_ItemContext.hxx>
 #include <inspector/VInspector_ItemV3dViewer.hxx>
+#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
 
 // =======================================================================
 // 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 (file)
index 0000000..3846f94
--- /dev/null
@@ -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 <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
+
+#include <AIS.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
+#include <inspector/VInspector_ItemContextProperties.hxx>
+
+// =======================================================================
+// 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<VInspector_ItemContextProperties>(Parent());
+  Handle(SelectMgr_ViewerSelector) aViewerSelector;
+  if (aParentItem)
+  {
+    VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(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<VInspector_ItemSelectMgrViewerSelector*>(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 (file)
index 0000000..aa2d4c7
--- /dev/null
@@ -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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <SelectMgr_ViewerSelector.hxx>
+
+class VInspector_ItemSelectMgrViewerSelector;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelector> 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