]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin
authornds <nds@opencascade.com>
Fri, 1 Feb 2019 12:12:15 +0000 (15:12 +0300)
committernds <nds@opencascade.com>
Fri, 1 Feb 2019 12:12:15 +0000 (15:12 +0300)
- transform persistent apply to preview of presentations
- Graphic3d_Camera matrices values in property panel
- SelectMgr_Selection values in property panel.

tools/VInspector/VInspector_ItemBase.hxx
tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx
tools/VInspector/VInspector_ItemGraphic3dCamera.cxx
tools/VInspector/VInspector_ItemPresentableObject.cxx
tools/VInspector/VInspector_ItemPrs3dPresentation.cxx
tools/VInspector/VInspector_ItemSelectMgrSelection.cxx
tools/VInspector/VInspector_ItemSelectMgrSelection.hxx
tools/VInspector/VInspector_Tools.cxx
tools/VInspector/VInspector_Tools.hxx
tools/VInspector/VInspector_Window.cxx

index e815323692cd3e38efc0a6bcf023ee23c6ee0df7..48b9922ba613333d5d0760196c440d84fee8953d 100644 (file)
@@ -24,6 +24,8 @@
 #include <inspector/TreeModel_ItemBase.hxx>
 #include <inspector/ViewControl_EditType.hxx>
 
+class Graphic3d_TransformPers;
+
 class VInspector_ItemBase;
 typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
 
@@ -56,6 +58,9 @@ public:
   virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
   { (void)thePresentations; }
 
+  //! Returns transform persistent of the item or NULL
+  Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
+
   //! Returns shape of the item parameters
   //! \return generated shape of the item parameters
   Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
@@ -117,6 +122,7 @@ protected:
 
   Handle(AIS_InteractiveContext) myContext; //!< the current context
   TopoDS_Shape myPresentationShape; //!< item presentation shape
+  Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
 };
 
 #endif
\ No newline at end of file
index 0b42ce1b2592a43a7d7e692834d67156123be714..447917b89ed5919fb3b93a6b4b6294701fed975a 100644 (file)
@@ -60,6 +60,8 @@ void VInspector_ItemGraphic3dCStructure::Init()
 
   Handle(Prs3d_Presentation) aPresentation = aParentItem->GetPresentation();
   myCStructure = aPresentation->CStructure();
+  if (!myCStructure.IsNull())
+    myTransformPersistence = myCStructure->TransformPersistence();
 
   TreeModel_ItemBase::Init();
 }
@@ -72,6 +74,7 @@ void VInspector_ItemGraphic3dCStructure::Reset()
 {
   VInspector_ItemBase::Reset();
   myCStructure = NULL;
+  myTransformPersistence = NULL;
 }
 
 // =======================================================================
index de75ed67827a325c4d7ded2906a8852056145d13..e8ec58a51e01ea1c983bb37dec262c4c9e7a1f92 100644 (file)
@@ -241,6 +241,24 @@ QVariant VInspector_ItemGraphic3dCamera::GetTableData (const int theRow, const i
                                   : QVariant (ViewControl_Tools::ToString (aCamera->Direction()).ToCString());
     case 19: return isFirstColumn ? (!isToolTip ? QVariant ("ViewDimensions") : QVariant ("View plane size at center (target) point and distance between ZFar and ZNear planes"))
                                   : ViewControl_Tools::ToString (aCamera->ViewDimensions()).ToCString();
+
+    case 20: return ViewControl_Table::SeparatorData();
+    case 21: return isFirstColumn ? QVariant ("TransformMatrices (D):") : QVariant();
+    case 22: return ViewControl_Table::SeparatorData();
+
+    case 23: return isFirstColumn ? QVariant ("OrientationMatrix") : VInspector_Tools::ToVariant (aCamera->OrientationMatrix());
+    case 24: return isFirstColumn ? QVariant ("ProjectionMatrix")  : VInspector_Tools::ToVariant (aCamera->ProjectionMatrix());
+    case 25: return isFirstColumn ? QVariant ("ProjectionStereoLeft") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeft());
+    case 26: return isFirstColumn ? QVariant ("ProjectionStereoRight") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRight());
+
+    case 27: return ViewControl_Table::SeparatorData();
+    case 28: return isFirstColumn ? QVariant ("TransformMatrices (F):") : QVariant();
+    case 29: return ViewControl_Table::SeparatorData();
+
+    case 30: return isFirstColumn ? QVariant ("OrientationMatrixF") : VInspector_Tools::ToVariant (aCamera->OrientationMatrixF());
+    case 31: return isFirstColumn ? QVariant ("ProjectionMatrixF")  : VInspector_Tools::ToVariant (aCamera->ProjectionMatrixF());
+    case 32: return isFirstColumn ? QVariant ("ProjectionStereoLeftF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeftF());
+    case 33: return isFirstColumn ? QVariant ("ProjectionStereoRightF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRightF());
   }
   return QVariant();
 }
index fa13d132124e505aa307675f5254b15325e78901..33fd3c7915728a1ad20269bbb047b7116a733a17 100644 (file)
@@ -204,6 +204,7 @@ void VInspector_ItemPresentableObject::Init()
   }
 
   setInteractiveObject (anIO);
+  myTransformPersistence = anIO->TransformPersistence();
   UpdatePresentationShape();
   TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
 }
@@ -218,6 +219,7 @@ void VInspector_ItemPresentableObject::Reset()
 
   SetContext (NULL);
   setInteractiveObject (NULL);
+  myTransformPersistence = NULL;
 }
 
 // =======================================================================
index 77fcb7a59458a9c82e643214512f8fe824685071..a66c4a4e2a766a151545e7b824b9ead7ea7ad974 100644 (file)
@@ -176,7 +176,7 @@ QVariant VInspector_ItemPrs3dPresentation::GetTableData (const int theRow, const
   switch (theRow)
   {
     case 0: return ViewControl_Table::SeparatorData();
-    case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Graphic3d_Structure)->Name())
+    case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Prs3d_Presentation)->Name())
                                  : ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
     case 2: return ViewControl_Table::SeparatorData();
     case 3: return isFirstColumn ? QVariant ("DisplayPriority") : QVariant (aPrs->DisplayPriority());
index 6fe75887dfe658615e785b37f2cf83c26b5967c4..529de360d620d69ddfc429d84d5f4bb7da615344 100644 (file)
@@ -189,3 +189,40 @@ void VInspector_ItemSelectMgrSelection::initItem() const
   const_cast<VInspector_ItemSelectMgrSelection*>(this)->Init();
   // an empty method to don't initialize the main label, as it was not cleared in Reset()
 }
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrSelection::GetTableRowCount() const
+{
+  return 10;
+}
+
+// =======================================================================
+// function : GetTableData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrSelection::GetTableData (const int theRow, const int theColumn, const int theRole) const
+{
+  if (theRole != Qt::DisplayRole)
+    return QVariant();
+
+  bool isFirstColumn = theColumn == 0;
+
+  Handle(SelectMgr_Selection) aSelection = GetSelection();
+  switch (theRow)
+  {
+    case 0: return isFirstColumn ? QVariant ("Mode") : QVariant (aSelection->Mode());
+    case 1: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aSelection->Sensitivity());
+    case 2: return isFirstColumn ? QVariant ("UpdateStatus")
+                                 : QVariant ((int)aSelection->UpdateStatus()); // TODO! SelectMgr_TypeOfUpdate
+    case 3: return isFirstColumn ? QVariant ("BVHUpdateStatus")
+                                 : QVariant ((int)aSelection->BVHUpdateStatus()); // TODO! SelectMgr_TypeOfBVHUpdate
+    case 4: return isFirstColumn ? QVariant ("GetSelectionState")
+                                 : QVariant ((int)aSelection->GetSelectionState()); // TODO! SelectMgr_StateOfSelection
+
+    default: return QVariant();
+  }
+  return QVariant();
+}
index 058cfbdba0e06ed0452b470fbe3b2311e994b86d..c44721e71356756762368edab4238cb1e4addd46 100644 (file)
@@ -52,6 +52,15 @@ public:
   //! Resets cached values
   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
+    //! Returns number of table rows
+  //! \return an integer value
+  virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+  //! Returns table value for the row in form: <function name> <function value>
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
+
 protected:
 
   //! Initializes the current item. It is empty because Reset() is also empty.
index ffb486318bd9dc904cdd92a02f49f141c42d8cc6..1d1f575c5b08f839b7550b07e300602ee6829881 100644 (file)
@@ -589,7 +589,7 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_Box& theBoundingBox)
       theBoundingBox.IsXThin (Precision::Confusion()) ||
       theBoundingBox.IsYThin (Precision::Confusion()) ||
       theBoundingBox.IsZThin (Precision::Confusion()))
-    return TopoDS_Shape();
+    return TopoDS_Shape(); // TODO: display shape for thin box, like in the same method for Select3D_BndBox3d
 
   BRepPrimAPI_MakeBox aBoxBuilder(theBoundingBox.CornerMin(), theBoundingBox.CornerMax());
   return aBoxBuilder.Shape();
@@ -610,6 +610,16 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding
   Standard_Boolean aThinOnX = fabs (aPntMin.X() - aPntMax.X()) < Precision::Confusion();
   Standard_Boolean aThinOnY = fabs (aPntMin.Y() - aPntMax.Y()) < Precision::Confusion();
   Standard_Boolean aThinOnZ = fabs (aPntMin.Z() - aPntMax.Z()) < Precision::Confusion();
+
+  if (((int)aThinOnX + (int)aThinOnY + (int)aThinOnZ) > 1) // thin box in several directions is a point
+  {
+    BRep_Builder aBuilder;
+    TopoDS_Compound aCompound;
+    aBuilder.MakeCompound (aCompound);
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (aPntMin));
+    return aCompound;
+  }
+
   if (aThinOnX || aThinOnY || aThinOnZ)
   {
     gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ;
@@ -620,14 +630,14 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding
       aPnt3 = gp_Pnt(aPntMin.X(), aPntMax.Y(), aPntMax.Z());
       aPnt4 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMax.Z());
     }
-    if (aThinOnY)
+    else if (aThinOnY)
     {
       aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
       aPnt2 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMin.Z());
       aPnt3 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMax.Z());
       aPnt4 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMax.Z());
     }
-    if (aThinOnZ)
+    else if (aThinOnZ)
     {
       aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
       aPnt2 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMin.Z());
@@ -698,6 +708,50 @@ QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_BoundBuffer)& theBo
   return QVariant();
 }
 
+//=======================================================================
+//function : ToVariant
+//purpose  :
+//=======================================================================
+QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4d& theMatrix)
+{
+  TCollection_AsciiString aValues;
+  for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
+  {
+    for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
+    {
+      aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
+      if (aColId != theMatrix.Rows())
+        aValues += ",";
+    }
+    if (aRowId != theMatrix.Rows())
+      aValues += "  ";
+  }
+
+  return aValues.ToCString();
+}
+
+//=======================================================================
+//function : ToVariant
+//purpose  :
+//=======================================================================
+QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4& theMatrix)
+{
+  TCollection_AsciiString aValues;
+  for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
+  {
+    for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
+    {
+      aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
+      if (aColId != theMatrix.Rows())
+        aValues += ",";
+    }
+    if (aRowId != theMatrix.Rows())
+      aValues += "  ";
+  }
+
+  return aValues.ToCString();
+}
+
 //=======================================================================
 //function : ToString
 //purpose  :
index 385bfaa145ba27cf4e5da6aa5bf870edc4696652..fc8790bd2cfbf4de5f436284c370523274d9ba80 100644 (file)
@@ -19,6 +19,8 @@
 #include <AIS_InteractiveContext.hxx>
 #include <Bnd_Box.hxx>
 #include <Graphic3d_Buffer.hxx>
+#include <Graphic3d_Mat4.hxx>
+#include <Graphic3d_Mat4d.hxx>
 #include <Select3D_BndBox3d.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard.hxx>
@@ -206,6 +208,16 @@ public:
   //! \return string presentation
   Standard_EXPORT static QVariant ToVariant (const Handle(Graphic3d_BoundBuffer)& theBoundBuffer);
 
+  //! Convert matrix values into a text presentation
+  //! \param theMatrix a matrix of elements
+  //! \return string presentation
+  Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4d& theMatrix);
+
+  //! Convert matrix values into a text presentation
+  //! \param theMatrix a matrix of elements
+  //! \return string presentation
+  Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4& theMatrix);
+
   Standard_EXPORT static QString ToString (const Graphic3d_Attribute& theAttribute);
 
 };
index 2910aa8cf5fc6efd3db2d820543853e9ef63cd2a..36de69592dfd5171f929958b45ed68036fb12dea 100644 (file)
@@ -434,18 +434,14 @@ Handle(Graphic3d_TransformPers) VInspector_Window::GetSelectedTransformPers()
     if (!aVItem)
       continue;
 
-    Handle(AIS_InteractiveObject) anIO;
-    while (aVItem && anIO.IsNull())
+    while (aVItem)
     {
-      VInspector_ItemPresentableObjectPtr aPrsObjectItem = itemDynamicCast<VInspector_ItemPresentableObject>(aVItem);
-      if (aPrsObjectItem)
-      {
-        anIO = aPrsObjectItem->GetInteractiveObject();
-      }
+      Handle(Graphic3d_TransformPers) aPers = aVItem->TransformPersistence();
+      if (!aPers.IsNull())
+        return aPers;
+
       aVItem = itemDynamicCast<VInspector_ItemBase>(aVItem->Parent());
     }
-    if (!anIO.IsNull() && !anIO->TransformPersistence().IsNull())
-      return anIO->TransformPersistence();
   }
   return Handle(Graphic3d_TransformPers)();
 }