From f5988cdbb5fefb57123e477e7b7263f7c48659e7 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 1 Feb 2019 15:12:15 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin - 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 | 6 ++ .../VInspector_ItemGraphic3dCStructure.cxx | 3 + .../VInspector_ItemGraphic3dCamera.cxx | 18 ++++++ .../VInspector_ItemPresentableObject.cxx | 2 + .../VInspector_ItemPrs3dPresentation.cxx | 2 +- .../VInspector_ItemSelectMgrSelection.cxx | 37 ++++++++++++ .../VInspector_ItemSelectMgrSelection.hxx | 9 +++ tools/VInspector/VInspector_Tools.cxx | 60 ++++++++++++++++++- tools/VInspector/VInspector_Tools.hxx | 12 ++++ tools/VInspector/VInspector_Window.cxx | 14 ++--- 10 files changed, 150 insertions(+), 13 deletions(-) diff --git a/tools/VInspector/VInspector_ItemBase.hxx b/tools/VInspector/VInspector_ItemBase.hxx index e815323692..48b9922ba6 100644 --- a/tools/VInspector/VInspector_ItemBase.hxx +++ b/tools/VInspector/VInspector_ItemBase.hxx @@ -24,6 +24,8 @@ #include #include +class Graphic3d_TransformPers; + class VInspector_ItemBase; typedef QExplicitlySharedDataPointer VInspector_ItemBasePtr; @@ -56,6 +58,9 @@ public: virtual void GetPresentations (NCollection_List& 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 diff --git a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx index 0b42ce1b25..447917b89e 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx @@ -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; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx index de75ed6782..e8ec58a51e 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx @@ -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(); } diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index fa13d13212..33fd3c7915 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -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; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx index 77fcb7a594..a66c4a4e2a 100644 --- a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx @@ -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()); diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx index 6fe75887df..529de360d6 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx @@ -189,3 +189,40 @@ void VInspector_ItemSelectMgrSelection::initItem() const const_cast(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(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelection.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelection.hxx index 058cfbdba0..c44721e713 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelection.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelection.hxx @@ -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: + //! \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. diff --git a/tools/VInspector/VInspector_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index ffb486318b..1d1f575c5b 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -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 : diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index 385bfaa145..fc8790bd2c 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -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); }; diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 2910aa8cf5..36de69592d 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -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(aVItem); - if (aPrsObjectItem) - { - anIO = aPrsObjectItem->GetInteractiveObject(); - } + Handle(Graphic3d_TransformPers) aPers = aVItem->TransformPersistence(); + if (!aPers.IsNull()) + return aPers; + aVItem = itemDynamicCast(aVItem->Parent()); } - if (!anIO.IsNull() && !anIO->TransformPersistence().IsNull()) - return anIO->TransformPersistence(); } return Handle(Graphic3d_TransformPers)(); } -- 2.39.5