From 8525647671176d592f640e66fcbadca778f945d6 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 30 Apr 2019 12:02:26 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin - some of selection components covering --- src/Bnd/Bnd_Range.cxx | 11 +- src/Bnd/Bnd_Range.hxx | 5 + src/Message/Message_Report.cxx | 19 ++ src/Message/Message_Report.hxx | 3 + src/SelectMgr/SelectMgr.cxx | 35 +++ src/SelectMgr/SelectMgr.hxx | 25 ++ src/SelectMgr/SelectMgr_BaseFrustum.cxx | 17 ++ src/SelectMgr/SelectMgr_BaseFrustum.hxx | 5 + src/SelectMgr/SelectMgr_Frustum.hxx | 4 + src/SelectMgr/SelectMgr_Frustum.lxx | 44 +++ .../SelectMgr_RectangularFrustum.cxx | 56 +++- .../SelectMgr_RectangularFrustum.hxx | 7 + .../SelectMgr_SelectableObjectSet.cxx | 8 + .../SelectMgr_SelectingVolumeManager.cxx | 5 + .../SelectMgr_SelectingVolumeManager.hxx | 13 + src/SelectMgr/SelectMgr_ViewClipRange.hxx | 11 + src/SelectMgr/SelectMgr_ViewerSelector.cxx | 10 +- src/SelectMgr/SelectMgr_ViewerSelector.hxx | 6 + src/StdSelect/StdSelect_ViewerSelector3d.cxx | 9 + src/TopoDS/TopoDS_AlertAttribute.hxx | 7 +- src/gp/gp_XY.hxx | 12 + src/gp/gp_XY.lxx | 34 +++ src/gp/gp_XYZ.hxx | 11 + src/gp/gp_XYZ.lxx | 47 +++- .../MessageModel/MessageModel_ActionType.hxx | 1 + tools/MessageModel/MessageModel_Actions.cxx | 41 +++ tools/MessageModel/MessageModel_Actions.hxx | 3 + .../MessageModel/MessageModel_ItemReport.cxx | 21 ++ .../MessageModel/MessageModel_ItemReport.hxx | 3 + tools/MessageView/MessageView_Window.cxx | 20 +- tools/TKTreeModel/EXTERNLIB | 1 + tools/TreeModel/TreeModel_ItemBase.cxx | 3 + tools/TreeModel/TreeModel_ItemBase.hxx | 6 + tools/TreeModel/TreeModel_ItemProperties.hxx | 8 +- tools/VInspector/FILES | 13 + tools/VInspector/VInspector_ItemBVHTree.cxx | 259 ++++++++++++++++++ tools/VInspector/VInspector_ItemBVHTree.hxx | 125 +++++++++ .../VInspector/VInspector_ItemBVHTreeNode.cxx | 96 +++++++ .../VInspector/VInspector_ItemBVHTreeNode.hxx | 86 ++++++ tools/VInspector/VInspector_ItemContainer.cxx | 96 +++++++ tools/VInspector/VInspector_ItemContainer.hxx | 87 ++++++ .../VInspector_ItemContainerAPI.hxx | 50 ++++ .../VInspector_ItemSelectMgrBaseFrustum.cxx | 15 + .../VInspector_ItemSelectMgrBaseFrustum.hxx | 3 + ...ector_ItemSelectMgrSelectableObjectSet.cxx | 188 +++++++++++++ ...ector_ItemSelectMgrSelectableObjectSet.hxx | 102 +++++++ ...or_ItemSelectMgrSelectingVolumeManager.cxx | 22 +- ...or_ItemSelectMgrSelectingVolumeManager.hxx | 5 + ...pector_ItemSelectMgrSensitiveEntitySet.cxx | 137 +++++++++ ...pector_ItemSelectMgrSensitiveEntitySet.hxx | 108 ++++++++ ...VInspector_ItemSelectMgrViewerSelector.cxx | 104 ++++++- ...VInspector_ItemSelectMgrViewerSelector.hxx | 33 ++- .../VInspector_PropertiesCreator.cxx | 40 +++ .../VInspector_PropertiesCreator.hxx | 47 ++++ tools/VInspector/VInspector_Tools.cxx | 24 ++ tools/VInspector/VInspector_Tools.hxx | 6 + tools/VInspector/VInspector_Window.cxx | 42 ++- .../VInspectorPaneAIS_PropertiesCreator.hxx | 6 - tools/View/View_Displayer.cxx | 2 +- tools/View/View_Viewer.cxx | 15 + tools/ViewControl/FILES | 2 + .../ViewControl_PropertiesStream.cxx | 160 +++++++++++ .../ViewControl_PropertiesStream.hxx | 90 ++++++ 63 files changed, 2428 insertions(+), 46 deletions(-) create mode 100644 tools/VInspector/VInspector_ItemBVHTree.cxx create mode 100644 tools/VInspector/VInspector_ItemBVHTree.hxx create mode 100644 tools/VInspector/VInspector_ItemBVHTreeNode.cxx create mode 100644 tools/VInspector/VInspector_ItemBVHTreeNode.hxx create mode 100644 tools/VInspector/VInspector_ItemContainer.cxx create mode 100644 tools/VInspector/VInspector_ItemContainer.hxx create mode 100644 tools/VInspector/VInspector_ItemContainerAPI.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx create mode 100644 tools/VInspector/VInspector_PropertiesCreator.cxx create mode 100644 tools/VInspector/VInspector_PropertiesCreator.hxx create mode 100644 tools/ViewControl/ViewControl_PropertiesStream.cxx create mode 100644 tools/ViewControl/ViewControl_PropertiesStream.hxx diff --git a/src/Bnd/Bnd_Range.cxx b/src/Bnd/Bnd_Range.cxx index 63d0961343..6edacda768 100644 --- a/src/Bnd/Bnd_Range.cxx +++ b/src/Bnd/Bnd_Range.cxx @@ -174,4 +174,13 @@ void Bnd_Range::Split(const Standard_Real theVal, { theList.Append(Bnd_Range(aValPrev, myLast)); } -} \ No newline at end of file +} + +//======================================================================= +//function : ToString +//purpose : +//======================================================================= +TCollection_AsciiString Bnd_Range::ToString() const +{ + return TCollection_AsciiString ("[") + myFirst + ", " + myLast + "]"; +} diff --git a/src/Bnd/Bnd_Range.hxx b/src/Bnd/Bnd_Range.hxx index 0c006d27d9..a478e2f0a2 100644 --- a/src/Bnd/Bnd_Range.hxx +++ b/src/Bnd/Bnd_Range.hxx @@ -18,6 +18,7 @@ #include #include +#include #include @@ -256,6 +257,10 @@ public: return ((myFirst == theOther.myFirst) && (myLast == theOther.myLast)); } + //! Covers point into string in format: [myFirst, myLast] + //! \return the string value + Standard_EXPORT TCollection_AsciiString ToString() const; + private: Standard_Real myFirst; //!< Start of range diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index c56de714e0..9f753c09f6 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -293,6 +293,25 @@ void Message_Report::Clear (const Handle(Standard_Type)& theType) } } +//======================================================================= +//function : Delete +//purpose : +//======================================================================= + +void Message_Report::Delete (Message_Gravity theGravity, const Message_ListOfAlert& theAlerts) +{ + if (theAlerts.IsEmpty()) + return; + + Message_ListOfAlert anAlerts = myAlerts[theGravity]; + + for (Message_ListOfAlert::Iterator anIt (theAlerts); anIt.More(); anIt.Next()) + { + if (myAlerts[theGravity].Contains (anIt.Value())) + myAlerts[theGravity].Remove (anIt.Value()); + } +} + //======================================================================= //function : Dump //purpose : diff --git a/src/Message/Message_Report.hxx b/src/Message/Message_Report.hxx index d19c81aae8..cf30842e40 100644 --- a/src/Message/Message_Report.hxx +++ b/src/Message/Message_Report.hxx @@ -92,6 +92,9 @@ public: //! Clears collected alerts with specified type Standard_EXPORT void Clear (const Handle(Standard_Type)& theType); + //! Returns list of collected alerts with specified gravity + Standard_EXPORT void Delete (Message_Gravity theGravity, const Message_ListOfAlert& theAlerts); + //! Dumps all collected alerts to stream Standard_EXPORT void Dump (Standard_OStream& theOS); diff --git a/src/SelectMgr/SelectMgr.cxx b/src/SelectMgr/SelectMgr.cxx index 4e5c63bfa2..2c33d07efd 100644 --- a/src/SelectMgr/SelectMgr.cxx +++ b/src/SelectMgr/SelectMgr.cxx @@ -21,6 +21,11 @@ namespace { "FIRST_ACCEPTABLE", "ONLY_TOPMOST" }; + + static Standard_CString SelectMgr_Table_PrintBVHSubset[4] = + { + "3d", "3dPersistent", "2dPersistent", "Nb" + }; } //======================================================================= @@ -52,3 +57,33 @@ Standard_Boolean SelectMgr::PickingStrategyFromString (Standard_CString theTypeS } return Standard_False; } + +//======================================================================= +//function : BVHSubsetToString +//purpose : +//======================================================================= +Standard_CString SelectMgr::BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType) +{ + return SelectMgr_Table_PrintBVHSubset[theType]; +} + +//======================================================================= +//function : BVHSubsetFromString +//purpose : +//======================================================================= +Standard_Boolean SelectMgr::BVHSubsetFromString (Standard_CString theTypeString, + SelectMgr_SelectableObjectSet::BVHSubset& theType) +{ + TCollection_AsciiString aName (theTypeString); + aName.UpperCase(); + for (Standard_Integer aTypeIter = 0; aTypeIter <= SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aTypeIter) + { + Standard_CString aTypeName = SelectMgr_Table_PrintBVHSubset[aTypeIter]; + if (aName == aTypeName) + { + theType = SelectMgr_SelectableObjectSet::BVHSubset (aTypeIter); + return Standard_True; + } + } + return Standard_False; +} diff --git a/src/SelectMgr/SelectMgr.hxx b/src/SelectMgr/SelectMgr.hxx index 9b96b59a34..a8cdcb1178 100644 --- a/src/SelectMgr/SelectMgr.hxx +++ b/src/SelectMgr/SelectMgr.hxx @@ -15,6 +15,7 @@ #define _SelectMgr_HeaderFile #include +#include #include #include #include @@ -52,6 +53,30 @@ public: Standard_EXPORT static Standard_Boolean PickingStrategyFromString (const Standard_CString theTypeString, SelectMgr_PickingStrategy& theType); + + + //! Returns the string name for a given orientation type. + //! @param theType orientation type + //! @return string identifier from the list Xpos, Ypos, Zpos and others + Standard_EXPORT static Standard_CString BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType); + + //! Returns the orientation type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @return orientation type or BVHSubset_3d if string identifier is invalid + static SelectMgr_SelectableObjectSet::BVHSubset BVHSubsetFromString (Standard_CString theTypeString) + { + SelectMgr_SelectableObjectSet::BVHSubset aType = SelectMgr_SelectableObjectSet::BVHSubset_3d; + BVHSubsetFromString (theTypeString, aType); + return aType; + } + + //! Determines the shape type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @param theType detected shape type + //! @return TRUE if string identifier is known + Standard_EXPORT static Standard_Boolean BVHSubsetFromString (const Standard_CString theTypeString, + SelectMgr_SelectableObjectSet::BVHSubset& theType); + }; #endif // _SelectMgr_HeaderFile diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.cxx b/src/SelectMgr/SelectMgr_BaseFrustum.cxx index bf9f43a395..a78cceb3e6 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.cxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.cxx @@ -15,6 +15,9 @@ #include +#include +#include + IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) //======================================================================= @@ -251,3 +254,17 @@ Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHCl { return Standard_True; } + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= +void SelectMgr_BaseFrustum::Dump(Standard_OStream& OS)const +{ + DUMP_VALUES (OS, "SelectMgr_BaseFrustum", 2); + + DUMP_VALUES (OS, "myPixelTolerance", myPixelTolerance); + DUMP_VALUES (OS, "myIsOrthographic", myIsOrthographic); + DUMP_VALUES (OS, "myBuilder", Message::TransientToString (myBuilder)); + DUMP_VALUES (OS, "myCamera", Message::TransientToString (myCamera)); +} diff --git a/src/SelectMgr/SelectMgr_BaseFrustum.hxx b/src/SelectMgr/SelectMgr_BaseFrustum.hxx index 6e4852ce11..d402ac371b 100644 --- a/src/SelectMgr/SelectMgr_BaseFrustum.hxx +++ b/src/SelectMgr/SelectMgr_BaseFrustum.hxx @@ -35,6 +35,8 @@ #include +#include + //! This class is an interface for different types of selecting frustums, //! defining different selection types, like point, box or polyline //! selection. It contains signatures of functions for detection of @@ -186,6 +188,9 @@ public: return; } + //! Dumps the content of me on the stream . + Standard_EXPORT virtual void Dump (Standard_OStream& OS) const; + DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient) protected: diff --git a/src/SelectMgr/SelectMgr_Frustum.hxx b/src/SelectMgr/SelectMgr_Frustum.hxx index d758bb5e9f..54bb7c7da0 100644 --- a/src/SelectMgr/SelectMgr_Frustum.hxx +++ b/src/SelectMgr/SelectMgr_Frustum.hxx @@ -23,6 +23,7 @@ #include #include #include +#include //! This is an internal class containing representation of rectangular selecting frustum, created in case //! of point and box selection, and algorithms for overlap detection between selecting @@ -58,6 +59,9 @@ public: SelectMgr_Frustum() : SelectMgr_BaseFrustum() {}; + //! Dumps the content of me on the stream . + Standard_EXPORT virtual void Dump (Standard_OStream& OS) 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..9905d15c66 100644 --- a/src/SelectMgr/SelectMgr_Frustum.lxx +++ b/src/SelectMgr/SelectMgr_Frustum.lxx @@ -14,9 +14,13 @@ // commercial license or contractual agreement. #include + +#include #include #include +//IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Frustum, SelectMgr_BaseFrustum) + // ======================================================================= // function : isSeparated // purpose : Checks if AABB and frustum are separated along the given axis. @@ -461,3 +465,43 @@ Standard_Boolean SelectMgr_Frustum::hasOverlap (const gp_Pnt& thePnt1, return Standard_True; } + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= +template +void SelectMgr_Frustum::Dump(Standard_OStream& OS)const +{ + DUMP_VALUES (OS, "SelectMgr_Frustum", 2); + + DUMP_VALUES (OS, "myPlanes", N + 2); + for (int anIndex = 0; anIndex < N + 2; anIndex++) + DUMP_VALUES (OS, anIndex, myPlanes[anIndex].XYZ().ToString()); + + DUMP_VALUES (OS, "myVertices", N * 2); + for (int anIndex = 0; anIndex < N * 2; anIndex++) + DUMP_VALUES (OS, anIndex, myVertices[anIndex].XYZ().ToString()); + + DUMP_VALUES (OS, "myMaxVertsProjections", N + 2); + for (int anIndex = 0; anIndex < N + 2; anIndex++) + DUMP_VALUES (OS, anIndex, myMaxVertsProjections[anIndex]); + + DUMP_VALUES (OS, "myMinVertsProjections", N + 2); + for (int anIndex = 0; anIndex < N + 2; anIndex++) + DUMP_VALUES (OS, anIndex, myMinVertsProjections[anIndex]); + + DUMP_VALUES (OS, "myMaxOrthoVertsProjections", 3); + for (int anIndex = 0; anIndex < 3; anIndex++) + DUMP_VALUES (OS, anIndex, myMaxOrthoVertsProjections[anIndex]); + + DUMP_VALUES (OS, "myMinOrthoVertsProjections", 3); + for (int anIndex = 0; anIndex < 3; anIndex++) + DUMP_VALUES (OS, anIndex, myMinOrthoVertsProjections[anIndex]); + + DUMP_VALUES (OS, "myEdgeDirs", 6); + for (int anIndex = 0; anIndex < 6; anIndex++) + DUMP_VALUES (OS, anIndex, myEdgeDirs[anIndex].XYZ().ToString()); + + SelectMgr_BaseFrustum::Dump (OS); +} diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index d972e19f2d..81f939f7c1 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -15,9 +15,12 @@ #include #include - +#include +#include #include +IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_RectangularFrustum, SelectMgr_Frustum<4> ) + // ======================================================================= // function : segmentSegmentDistance // purpose : @@ -138,6 +141,8 @@ namespace const Handle(SelectMgr_FrustumBuilder)& theBuilder, gp_Pnt* theVertices, gp_Vec* theEdges) { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::computeFrustum", "", &aPerfMeter, NULL); // LeftTopNear theVertices[0] = theBuilder->ProjectPntOnViewPlane (theMinPnt.X(), theMaxPnt.Y(), @@ -272,6 +277,8 @@ void SelectMgr_RectangularFrustum::cacheVertexProjections (SelectMgr_Rectangular // ======================================================================= void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint) { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Build_1", "", &aPerfMeter, NULL); myNearPickedPnt = myBuilder->ProjectPntOnViewPlane (thePoint.X(), thePoint.Y(), 0.0); myFarPickedPnt = myBuilder->ProjectPntOnViewPlane (thePoint.X(), thePoint.Y(), 1.0); myViewRayDir = myFarPickedPnt.XYZ() - myNearPickedPnt.XYZ(); @@ -304,6 +311,8 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint) void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d& theMinPnt, const gp_Pnt2d& theMaxPnt) { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Build_2", "", &aPerfMeter, NULL); myNearPickedPnt = myBuilder->ProjectPntOnViewPlane ((theMinPnt.X() + theMaxPnt.X()) * 0.5, (theMinPnt.Y() + theMaxPnt.Y()) * 0.5, 0.0); @@ -431,6 +440,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t const SelectMgr_Vec3& theBoxMax, Standard_Boolean* theInside) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vvb", "", &aPerfMeter, NULL); return hasOverlap (theBoxMin, theBoxMax, theInside); } @@ -443,6 +454,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t const SelectMgr_Vec3& theBoxMax, SelectBasics_PickResult& thePickResult) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vv", "", &aPerfMeter, NULL); if (!hasOverlap (theBoxMin, theBoxMax)) return Standard_False; @@ -463,6 +476,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt, SelectBasics_PickResult& thePickResult) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_1p", "", &aPerfMeter, NULL); if (!hasOverlap (thePnt)) return Standard_False; @@ -482,6 +497,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt, // ======================================================================= Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_1", "", &aPerfMeter, NULL); return hasOverlap (thePnt); } @@ -493,6 +510,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2, SelectBasics_PickResult& thePickResult) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_2", "", &aPerfMeter, NULL); + if (!hasOverlap (thePnt1, thePnt2)) return Standard_False; @@ -512,6 +532,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn Select3D_TypeOfSensitivity theSensType, SelectBasics_PickResult& thePickResult) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_n", "", &aPerfMeter, NULL); if (theSensType == Select3D_TOS_BOUNDARY) { Standard_Integer aMatchingSegmentsNb = -1; @@ -562,6 +584,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1, Select3D_TypeOfSensitivity theSensType, SelectBasics_PickResult& thePickResult) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_3", "", &aPerfMeter, NULL); + if (theSensType == Select3D_TOS_BOUNDARY) { const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 }; @@ -651,6 +676,9 @@ Standard_Real SelectMgr_RectangularFrustum::DistToGeometryCenter (const gp_Pnt& // ======================================================================= gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::DetectedPoint", "", &aPerfMeter, NULL); + return myNearPickedPnt.XYZ() + myViewRayDir.Normalized().XYZ() * theDepth / myScale; } @@ -661,6 +689,9 @@ gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes, SelectMgr_ViewClipRange& theRange) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_RectangularFrustum::computeClippingRange", "", &aPerfMeter, NULL); + Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD; for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next()) { @@ -746,6 +777,9 @@ void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_Sequenc Standard_Boolean SelectMgr_RectangularFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, const Standard_Real theDepth) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("IsClipped", "", &aPerfMeter, NULL); + SelectMgr_ViewClipRange aRange; computeClippingRange (thePlanes, aRange); return aRange.IsClipped (theDepth); @@ -797,3 +831,23 @@ void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector thePlaneEquations.Append (anEquation); } } + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= +void SelectMgr_RectangularFrustum::Dump(Standard_OStream& OS)const +{ + DUMP_VALUES (OS, "SelectMgr_RectangularFrustum", 2); + DUMP_VALUES (OS, "myNearPickedPnt", myNearPickedPnt.XYZ().ToString()); + DUMP_VALUES (OS, "myFarPickedPnt", myFarPickedPnt.XYZ().ToString()); + DUMP_VALUES (OS, "myViewRayDir", myViewRayDir.XYZ().ToString()); + DUMP_VALUES (OS, "myMousePos", myMousePos.XY().ToString()); + DUMP_VALUES (OS, "myScale", myScale); + DUMP_VALUES (OS, "myIsViewClipEnabled", myIsViewClipEnabled); + + DUMP_VALUES (OS, "myViewClipRange", ""); + myViewClipRange.Dump (OS); + + SelectMgr_Frustum<4>::Dump (OS); +} diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx index 1fae9f4f0a..d48132d61c 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.hxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.hxx @@ -18,6 +18,7 @@ #include #include +#include //! This class contains representation of rectangular selecting frustum, created in case //! of point and box selection, and algorithms for overlap detection between selecting @@ -137,6 +138,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 on the stream . + Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE; + protected: Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1, @@ -164,6 +168,9 @@ private: RightTopNear, RightTopFar, RightBottomNear, RightBottomFar }; +public: + DEFINE_STANDARD_RTTIEXT(SelectMgr_RectangularFrustum, SelectMgr_Frustum<4>) + private: gp_Pnt myNearPickedPnt; //!< 3d projection of user-picked selection point onto near view plane diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx index 8fc2e17865..c75c8fe300 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx @@ -360,11 +360,17 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t const Standard_Integer theViewportWidth, const Standard_Integer theViewportHeight) { +#ifdef REPORT_SELECTION_BUILD + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("UpdateBVH", "", &aPerfMeter, NULL); +#endif + // ----------------------------------------- // check and update 3D BVH tree if necessary // ----------------------------------------- if (!IsEmpty (BVHSubset_3d) && myIsDirty[BVHSubset_3d]) { + MESSAGE_INFO ("Check and update 3D BVH", "", &aPerfMeter, NULL); // construct adaptor over private fields to provide direct access for the BVH builder BVHBuilderAdaptorRegular anAdaptor (myObjects[BVHSubset_3d], myDisabledZLayers); @@ -386,6 +392,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t if (!IsEmpty (BVHSubset_3dPersistent) && (myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged (theViewState) || isWindowSizeChanged)) { + MESSAGE_INFO ("Check and update 3D persistence BVH tree", "", &aPerfMeter, NULL); // construct adaptor over private fields to provide direct access for the BVH builder BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent], myDisabledZLayers, theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight); @@ -400,6 +407,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t if (!IsEmpty (BVHSubset_2dPersistent) && (myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged (theViewState) || isWindowSizeChanged)) { + MESSAGE_INFO ("Check and update 2D persistence BVH tree", "", &aPerfMeter, NULL); // construct adaptor over private fields to provide direct access for the BVH builder BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent], myDisabledZLayers, theCamera, theProjectionMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theViewportWidth, theViewportHeight); diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index 7073a002ba..8d923d0246 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -14,6 +14,8 @@ // commercial license or contractual agreement. #include +#include +#include //======================================================================= // function : SelectMgr_SelectingVolumeManager @@ -396,6 +398,9 @@ gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theD Standard_Boolean SelectMgr_SelectingVolumeManager::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, const Standard_Real& theDepth) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("SelectMgr_SelectingVolumeManager::IsClipped", "", &aPerfMeter, NULL); + if (myActiveSelectionType != Point) return Standard_False; diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index 92715faabe..3cb694e432 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -206,6 +206,19 @@ public: return mySelectingVolumes[myActiveSelectionType / 2]; } + //! Returns active selecting volume that was built during last + //! run of OCCT selection mechanism + Handle(SelectMgr_BaseFrustum) GetVolume (const SelectionType& theType) const + { + switch (theType) + { + case Point: + case Box: return mySelectingVolumes[Frustum]; + case Polyline: return mySelectingVolumes[FrustumSet]; + default: return NULL; + } + } + //! Stores plane equation coefficients (in the following form: //! Ax + By + Cz + D = 0) to the given vector virtual void GetPlanes (NCollection_Vector& thePlaneEquations) const Standard_OVERRIDE diff --git a/src/SelectMgr/SelectMgr_ViewClipRange.hxx b/src/SelectMgr/SelectMgr_ViewClipRange.hxx index 97deae09c9..ad5f893131 100644 --- a/src/SelectMgr/SelectMgr_ViewClipRange.hxx +++ b/src/SelectMgr/SelectMgr_ViewClipRange.hxx @@ -18,6 +18,7 @@ #include #include +#include //! Class for handling depth clipping range. //! It is used to perform checks in case if global (for the whole view) @@ -62,6 +63,16 @@ public: //! Adds a clipping sub-range (for clipping chains). void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); } + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS) const + { + DUMP_VALUES (OS, "SelectMgr_ViewClipRange", 2); + DUMP_VALUES (OS, "myUnclipRange", myUnclipRange.ToString()); + DUMP_VALUES (OS, "myClipRanges", myClipRanges.size()); + for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter) + DUMP_VALUES (OS, aRangeIter, myClipRanges[aRangeIter].ToString()); + } + private: std::vector myClipRanges; diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 8e1644e46d..38a446416c 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -564,6 +564,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives() Standard_Integer aWidth; Standard_Integer aHeight; mySelectingVolumeMgr.WindowSize (aWidth, aHeight); + MESSAGE_INFO ("UpdateBVH", "", &aPerfMeter, aParentAlert); mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(), mySelectingVolumeMgr.ProjectionMatrix(), mySelectingVolumeMgr.WorldViewMatrix(), @@ -583,14 +584,14 @@ void SelectMgr_ViewerSelector::TraverseSensitives() for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt) { + SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = + static_cast (aBVHSetIt); + #ifdef REPORT_SELECTION_BUILD - MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt") + aBVHSetIt, "", &aPerfMeter, aParentAlert); + MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt"), SelectMgr::BVHSubsetToString (aBVHSubset), &aPerfMeter, aParentAlert); Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert; #endif - SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = - static_cast (aBVHSetIt); - if (mySelectableObjects.IsEmpty (aBVHSubset)) { continue; @@ -702,6 +703,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives() } } + MESSAGE_INFO ("SortResult", "", &aPerfMeter, aParentAlert); SortResult(); #ifdef REPORT_SELECTION_BUILD Standard_SStream aStreamDone; diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 753d3f9e5a..7fc5d34690 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -205,6 +205,12 @@ public: //! Returns instance of selecting volume manager of the viewer selector SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; } + //! Returns container of selectable objects + const SelectMgr_SelectableObjectSet& GetSelectableObjects() const { return mySelectableObjects; } + + //! Returns container of sensitives + const SelectMgr_MapOfObjectSensitives& GetObjectSensitives() const { return myMapOfObjectSensitives; } + //! Marks all added sensitive entities of all objects as non-selectable Standard_EXPORT void ResetSelectionActivationStatus(); diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index a22fbf8962..ffa6f21abb 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -162,6 +162,15 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin, const Standard_Integer theYPMax, const Handle(V3d_View)& theView) { +#ifdef REPORT_SELECTION_BUILD + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("Pick", TCollection_AsciiString ("min/max: (") + + theXPMin + ", " + theYPMin + ") / (" + + theXPMax + ", " + theYPMax + ") " + , &aPerfMeter, NULL); + Handle(Message_Alert) aParentAlert = OCCT_Message_Alert; +#endif + updateZLayers (theView); mySelectingVolumeMgr.SetCamera (theView->Camera()); mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Box); diff --git a/src/TopoDS/TopoDS_AlertAttribute.hxx b/src/TopoDS/TopoDS_AlertAttribute.hxx index 115a9ec28e..f0708407cd 100644 --- a/src/TopoDS/TopoDS_AlertAttribute.hxx +++ b/src/TopoDS/TopoDS_AlertAttribute.hxx @@ -24,9 +24,10 @@ class TopoDS_AlertAttribute : public Message_Attribute { public: //! Constructor with shape argument - Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape, - const TCollection_AsciiString& theName = TCollection_AsciiString(), - const TCollection_AsciiString& theDescription = TCollection_AsciiString()); + TopoDS_AlertAttribute (const TopoDS_Shape& theShape, + const TCollection_AsciiString& theName = TCollection_AsciiString(), + const TCollection_AsciiString& theDescription = TCollection_AsciiString()) + : Message_Attribute (theName, theDescription), myShape (theShape) {} //! Returns contained shape const TopoDS_Shape& GetShape() const { return myShape; } diff --git a/src/gp/gp_XY.hxx b/src/gp/gp_XY.hxx index 70ffa21f58..cb451b135e 100644 --- a/src/gp/gp_XY.hxx +++ b/src/gp/gp_XY.hxx @@ -22,6 +22,9 @@ #include #include #include + +#include + class Standard_ConstructionError; class Standard_OutOfRange; class gp_Mat2d; @@ -269,6 +272,15 @@ public: } + //! Covers point into string in format: (X, Y) + //! \return the string value + Standard_EXPORT TCollection_AsciiString ToString() const; + + + //! Converts text value into parameters if possible, the string format is: (X, Y) + //! \return true if conversion is done + Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue); + protected: diff --git a/src/gp/gp_XY.lxx b/src/gp/gp_XY.lxx index ecd0605719..12fc78c19e 100644 --- a/src/gp/gp_XY.lxx +++ b/src/gp/gp_XY.lxx @@ -227,3 +227,37 @@ inline gp_XY operator* (const Standard_Real Scalar, return Coord1.Multiplied(Scalar); } +inline TCollection_AsciiString gp_XY::ToString() const +{ + return TCollection_AsciiString ("(") + x + ", " + y + ")"; +} + +inline Standard_Boolean gp_XY::FromString (const TCollection_AsciiString& theValue) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + Standard_Integer aPosition = aCurrentString.Search ("("); + if (aPosition != 1) + return Standard_False; + + aCurrentString = aCurrentString.Split (aPosition); + Standard_Real aX, anY; + // x value + aPosition = aCurrentString.Search (", "); + if (aPosition < 0) + return Standard_False; + aCurrentString = aValueString.Split (aPosition); + aX = aValueString.RealValue(); + aCurrentString = aCurrentString.Split (2); + + // y value + aPosition = aCurrentString.Search (")"); + if (aPosition < 0) + return Standard_False; + aCurrentString = aValueString.Split (aPosition); + anY = aValueString.RealValue(); + + x = aX; + y = anY; + return Standard_True; +} diff --git a/src/gp/gp_XYZ.hxx b/src/gp/gp_XYZ.hxx index ccb0373c09..34572eaa40 100644 --- a/src/gp/gp_XYZ.hxx +++ b/src/gp/gp_XYZ.hxx @@ -22,6 +22,9 @@ #include #include #include + +#include + class Standard_ConstructionError; class Standard_OutOfRange; class gp_Mat; @@ -324,6 +327,14 @@ public: void SetLinearForm (const gp_XYZ& XYZ1, const gp_XYZ& XYZ2); + //! Covers point into string in format: (X, Y, Z) + //! \return the string value + Standard_EXPORT TCollection_AsciiString ToString() const; + + + //! Converts text value into parameters if possible, the string format is: (X, Y, Z) + //! \return true if conversion is done + Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue); protected: diff --git a/src/gp/gp_XYZ.lxx b/src/gp/gp_XYZ.lxx index f97590738c..c4dde68a65 100644 --- a/src/gp/gp_XYZ.lxx +++ b/src/gp/gp_XYZ.lxx @@ -307,7 +307,50 @@ inline gp_XYZ operator* (const Standard_Real Scalar, const gp_XYZ& Coord1) { } +inline TCollection_AsciiString gp_XYZ::ToString() const +{ + return TCollection_AsciiString ("(") + x + ", " + y + ", " + z + ")"; +} - - +inline Standard_Boolean gp_XYZ::FromString (const TCollection_AsciiString& theValue) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + Standard_Integer aPosition = aCurrentString.Search ("("); + if (aPosition != 1) + return Standard_False; + + aCurrentString = aCurrentString.Split (aPosition); + Standard_Real aX, anY, aZ; + // x value + aPosition = aCurrentString.Search (", "); + if (aPosition < 0) + return Standard_False; + aValueString = aCurrentString; + aCurrentString = aValueString.Split (aPosition - 1); + aX = aValueString.RealValue(); + aCurrentString = aCurrentString.Split (2); + + // y value + aPosition = aCurrentString.Search (", "); + if (aPosition < 0) + return Standard_False; + aValueString = aCurrentString; + aCurrentString = aValueString.Split (aPosition - 1); + anY = aValueString.RealValue(); + aCurrentString = aCurrentString.Split (2); + + // z value + aPosition = aCurrentString.Search (")"); + if (aPosition < 0) + return Standard_False; + aValueString = aCurrentString; + aCurrentString = aValueString.Split (aPosition); + aZ = aValueString.RealValue(); + + x = aX; + y = anY; + z = aZ; + return Standard_True; +} diff --git a/tools/MessageModel/MessageModel_ActionType.hxx b/tools/MessageModel/MessageModel_ActionType.hxx index de036fefd4..5c03cff8eb 100644 --- a/tools/MessageModel/MessageModel_ActionType.hxx +++ b/tools/MessageModel/MessageModel_ActionType.hxx @@ -22,6 +22,7 @@ enum MessageModel_ActionType MessageModel_ActionType_Activate, //!< set Message_Report active MessageModel_ActionType_Deactivate, //!< set Message_Report not active MessageModel_ActionType_Clear, //!< clear Message_Report alerts + MessageModel_ActionType_Delete, //!< deletes Message_Report alerts MessageModel_ActionType_ExportToShapeView, //!< export TopoDS_Shape of selected item into TKShapeView plugin MessageModel_ActionType_Test //!< test alerts }; diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 4a587b5591..9dc2ac340e 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -59,6 +59,8 @@ MessageModel_Actions::MessageModel_Actions (QWidget* theParent, ViewControl_Tools::CreateAction ("Activate", SLOT (OnActivateReport()), parent(), this)); myActions.insert (MessageModel_ActionType_Clear, ViewControl_Tools::CreateAction ("Clear", SLOT (OnClearReport()), parent(), this)); + myActions.insert (MessageModel_ActionType_Delete, + ViewControl_Tools::CreateAction ("Delete", SLOT (OnDeleteAlerts()), parent(), this)); myActions.insert (MessageModel_ActionType_ExportToShapeView, ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this)); #ifdef DEBUG_ALERTS @@ -121,7 +123,10 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd #endif } else if (anAlertItem) + { theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]); + theMenu->addAction (myActions[MessageModel_ActionType_Delete]); + } theMenu->addSeparator(); } @@ -200,6 +205,42 @@ void MessageModel_Actions::OnClearReport() ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex); } +// ======================================================================= +// function : OnDeleteAlerts +// purpose : +// ======================================================================= +void MessageModel_Actions::OnDeleteAlerts() +{ + Handle(Message_Report) aReport; + Message_ListOfAlert anAlerts; + + QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes(); + QStringList anExportedPointers; + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + MessageModel_ItemAlertPtr anItem = itemDynamicCast (anItemBase); + if (!anItem) + break; + + if (aReport.IsNull()) + MessageModel_ItemReport::FindReport (anItem); + anAlerts.Append(anItem->GetAlert()); + } + + if (aReport.IsNull()) + return; + + aReport->Delete (Message_Info, anAlerts); +} + // ======================================================================= // function : OnExportToShapeView // purpose : diff --git a/tools/MessageModel/MessageModel_Actions.hxx b/tools/MessageModel/MessageModel_Actions.hxx index 71da2a0935..423989c534 100644 --- a/tools/MessageModel/MessageModel_Actions.hxx +++ b/tools/MessageModel/MessageModel_Actions.hxx @@ -79,6 +79,9 @@ public slots: //! Clears container of alerts of selected report void OnClearReport(); + //! Deletes container of alerts of selected reports + void OnDeleteAlerts(); + //! Exports the first selected shape into ShapeViewer plugin. void OnExportToShapeView(); diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx index bc4c4877e4..a2af8df74e 100644 --- a/tools/MessageModel/MessageModel_ItemReport.cxx +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -204,3 +204,24 @@ double MessageModel_ItemReport::AmountElapsedTime (const Handle(Message_Report)& } return anAmountTime; } + +// ======================================================================= +// function : FindReport +// purpose : +// ======================================================================= +Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_ItemBasePtr& theItem) +{ + Handle(Message_Report) aReport; + + MessageModel_ItemBasePtr anItem = theItem; + while (anItem) + { + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItem); + + if (aReportItem) + return aReportItem->GetReport(); + + anItem = itemDynamicCast(anItem->Parent()); + } + return NULL; +} diff --git a/tools/MessageModel/MessageModel_ItemReport.hxx b/tools/MessageModel/MessageModel_ItemReport.hxx index c6ce246fc2..d76b56b466 100644 --- a/tools/MessageModel/MessageModel_ItemReport.hxx +++ b/tools/MessageModel/MessageModel_ItemReport.hxx @@ -80,6 +80,9 @@ public: //! \return double value Standard_EXPORT static double AmountElapsedTime (const Handle(Message_Report)& theReport); + //! Returns report of the item + static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem); + protected: //! Initialize the current item. It is empty because Reset() is also empty. diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index c0c0aebf39..575ca8445d 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -32,9 +32,11 @@ #include #include +#include +#include #include - +#include #include #include @@ -294,6 +296,7 @@ void MessageView_Window::Init (NCollection_List& the NCollection_List aParameters; Handle(Message_ReportCallBack) aReportCallBack; + Handle(Graphic3d_Camera) aViewCamera; for (NCollection_List::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next()) @@ -305,24 +308,29 @@ void MessageView_Window::Init (NCollection_List& the aMessageReport->SetCallBack (myCallBack); addReport (aMessageReport); } - else + else if (!Handle(AIS_InteractiveContext)::DownCast (anObject).IsNull()) { aParameters.Append (anObject); if (aContext.IsNull()) aContext = Handle(AIS_InteractiveContext)::DownCast (anObject); } + else if (!Handle(Graphic3d_Camera)::DownCast (anObject).IsNull()) + { + aViewCamera = Handle(Graphic3d_Camera)::DownCast (anObject); + } } - QAbstractItemModel* aModel = myTreeView->model(); - if (!aModel) - return; - MessageModel_TreeModel* aTreeModel = dynamic_cast (aModel); + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); if (!aTreeModel) return; + aTreeModel->EmitLayoutChanged(); if (!aContext.IsNull()) myViewWindow->SetContext (View_ContextType_External, aContext); + if (!aViewCamera.IsNull()) + myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera); + theParameters = aParameters; } diff --git a/tools/TKTreeModel/EXTERNLIB b/tools/TKTreeModel/EXTERNLIB index 100866c7f3..37f0830243 100644 --- a/tools/TKTreeModel/EXTERNLIB +++ b/tools/TKTreeModel/EXTERNLIB @@ -1,3 +1,4 @@ TKernel TKMath +TKTopAlgo CSF_QT \ No newline at end of file diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 703414f403..3efee94260 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -65,6 +65,9 @@ void TreeModel_ItemBase::Reset() } m_bInitialized = false; myCachedValues.clear(); + + if (!GetProperties().IsNull()) + GetProperties()->Reset(); } // ======================================================================= diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index b7f3f7b634..45da4d7805 100644 --- a/tools/TreeModel/TreeModel_ItemBase.hxx +++ b/tools/TreeModel/TreeModel_ItemBase.hxx @@ -19,6 +19,8 @@ #include #include #include +#include + #include #include @@ -139,9 +141,13 @@ public: //! Returns item table properties builder Standard_EXPORT Handle(TreeModel_ItemProperties) GetProperties() const; + //! Dumps the content of me on the stream . + virtual Standard_Boolean Dump (Standard_OStream& OS) const { (void)OS; return Standard_False; } + //! Returns number of item rows only static Standard_EXPORT int RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem); + protected: //! \param theParent the parent item diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index d096f71394..a7a41282c6 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -48,6 +48,12 @@ public: //! Destructor ~TreeModel_ItemProperties() {} + //! If me has internal values, it should be initialized here. + virtual void Init() {} + + //! If the item has internal values, there should be reseted here. + Standard_EXPORT virtual void Reset() {} + //! Returns number of item children //! \return an integer value, ZERO by default virtual int ChildItemCount() const { return 0; } @@ -59,7 +65,7 @@ public: virtual TreeModel_ItemBasePtr CreateChildItem (int theRow, int theColumn) const { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); } - //! Returns number of table rows + //! Returns number of table columns. Default value is two columns: title to value //! \return an integer value virtual int GetTableColumnCount() const { return 2; } diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index b0e3e01520..0609ab6810 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -9,6 +9,13 @@ VInspector_ItemAspectWindow.cxx VInspector_ItemAspectWindow.hxx VInspector_ItemBase.cxx VInspector_ItemBase.hxx +VInspector_ItemBVHTree.cxx +VInspector_ItemBVHTree.hxx +VInspector_ItemBVHTreeNode.cxx +VInspector_ItemBVHTreeNode.hxx +VInspector_ItemContainer.cxx +VInspector_ItemContainer.hxx +VInspector_ItemContainerAPI.hxx VInspector_ItemContext.cxx VInspector_ItemContext.hxx VInspector_ItemFolderObject.cxx @@ -66,16 +73,22 @@ VInspector_ItemSelectMgrBaseFrustum.cxx VInspector_ItemSelectMgrBaseFrustum.hxx VInspector_ItemSelectMgrFilter.cxx VInspector_ItemSelectMgrFilter.hxx +VInspector_ItemSelectMgrSelectableObjectSet.cxx +VInspector_ItemSelectMgrSelectableObjectSet.hxx VInspector_ItemSelectMgrSelectingVolumeManager.cxx VInspector_ItemSelectMgrSelectingVolumeManager.hxx VInspector_ItemSelectMgrSelection.cxx VInspector_ItemSelectMgrSelection.hxx VInspector_ItemSelectMgrSensitiveEntity.cxx VInspector_ItemSelectMgrSensitiveEntity.hxx +VInspector_ItemSelectMgrSensitiveEntitySet.cxx +VInspector_ItemSelectMgrSensitiveEntitySet.hxx VInspector_ItemV3dView.cxx VInspector_ItemV3dView.hxx VInspector_ItemV3dViewer.cxx VInspector_ItemV3dViewer.hxx +VInspector_PropertiesCreator.cxx +VInspector_PropertiesCreator.hxx VInspector_PrsOpenGlElement.cxx VInspector_PrsOpenGlElement.hxx VInspector_SelectionType.hxx diff --git a/tools/VInspector/VInspector_ItemBVHTree.cxx b/tools/VInspector/VInspector_ItemBVHTree.cxx new file mode 100644 index 0000000000..5a13706816 --- /dev/null +++ b/tools/VInspector/VInspector_ItemBVHTree.cxx @@ -0,0 +1,259 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +VInspector_ItemBVHTree::VInspector_ItemBVHTree (TreeModel_ItemBasePtr theParent, + const int theRow, const int theColumn) +: VInspector_ItemBase(theParent, theRow, theColumn) +{ +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemBVHTree::initRowCount() const +{ + if (Column() != 0) + return 0; + + opencascade::handle > aTree = GetTree(); + if (aTree.IsNull()) + return 0; + + return aTree->Length(); +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemBVHTree::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 (GetTree().IsNull()) + return Column() == 0 ? "Empty BVH tree" : ""; + + switch (Column()) + { + case 0: + { + TCollection_AsciiString aName = TCollection_AsciiString (GetTree()->DynamicType()->Name()) + + TCollection_AsciiString (" (") + myName.ToCString() + ")"; + return aName.ToCString(); + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTree::Init() +{ + VInspector_ItemSelectMgrSelectableObjectSetPtr aParentItem = itemDynamicCast(Parent()); + + //! Returns child BVH tree of the row + setTree (aParentItem->GetBVHTree (Row(), myName)); + + //Handle(SelectMgr_ViewerSelector) aViewerSelector; + //if (aParentItem) + //{ + // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(aParentItem->Parent()); + // if (aParentContextItem) + // { + // Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext(); + // aViewerSelector = aContext->MainSelector(); + // } + //} + //setViewerSelector (aViewerSelector); + + //UpdatePresentationShape(); + TreeModel_ItemBase::Init(); // to use getIO() without circling initialization +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTree::Reset() +{ + VInspector_ItemBase::Reset(); + + setTree (NULL); + myName = TCollection_AsciiString(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTree::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemBVHTree::GetTableRowCount() const +{ + return 60; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemBVHTree::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + //if (theRole != Qt::DisplayRole) + // return QVariant(); + + //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + //if (aViewerSelector.IsNull()) + // return QVariant(); + + //bool isFirstColumn = theColumn == 0; + //switch (theRow) + //{ + // case 0: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aViewerSelector->Sensitivity()); + // case 1: return isFirstColumn ? QVariant ("IsPickClosest") : QVariant (aViewerSelector->IsPickClosest()); + // case 2: return isFirstColumn ? QVariant ("NbPicked") : QVariant (aViewerSelector->NbPicked()); + + // case 3: return ViewControl_Table::SeparatorData(); + // case 4: return isFirstColumn ? QVariant ("ClearPicked") : QVariant ("DO"); + + // case 5: return ViewControl_Table::SeparatorData(); + // case 6: return isFirstColumn ? QVariant ("X (pixel)") : QVariant (myXPix); + // case 7: return isFirstColumn ? QVariant ("Y (pixel)") : QVariant (myYPix); + // case 8: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO"); + + // case 9: return ViewControl_Table::SeparatorData(); + // case 10: return isFirstColumn ? QVariant ("X Min (pixel)") : QVariant (myXMinPix); + // case 11: return isFirstColumn ? QVariant ("Y Min (pixel)") : QVariant (myXMinPix); + // case 12: return isFirstColumn ? QVariant ("X Max (pixel)") : QVariant (myXMaxPix); + // case 13: return isFirstColumn ? QVariant ("Y Max (pixel)") : QVariant (myYMaxPix); + // case 14: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO"); + + // default: break; + //} + return QVariant(); +} + +// ======================================================================= +// function : GetTableEditType +// purpose : +// ======================================================================= +ViewControl_EditType VInspector_ItemBVHTree::GetTableEditType (const int theRow, const int) const +{ + switch (theRow) + { + //case 4: return ViewControl_EditType_DoAction; + //case 6: return ViewControl_EditType_Spin; + //case 7: return ViewControl_EditType_Spin; + //case 8: return ViewControl_EditType_DoAction; + //case 10: return ViewControl_EditType_Spin; + //case 11: return ViewControl_EditType_Spin; + //case 12: return ViewControl_EditType_Spin; + //case 13: return ViewControl_EditType_Spin; + //case 14: return ViewControl_EditType_DoAction; + default: return ViewControl_EditType_None; + } +} + +// ======================================================================= +// function : SetTableData +// purpose : +// ======================================================================= +bool VInspector_ItemBVHTree::SetTableData (const int theRow, const int, const QVariant& theValue) +{ + //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + //if (aViewerSelector.IsNull()) + // return Standard_False; + + //switch (theRow) + //{ + // case 4: aViewerSelector->ClearPicked(); break; + // case 6: myXPix = theValue.toInt(); + // case 7: myYPix = theValue.toInt(); + // case 8: + // { + // Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector); + // if (!aSelector3d.IsNull()) + // aSelector3d->Pick (myXPix, myYPix, View_Tools::FindActiveView (GetContext())); + // break; + // } + // case 10: myXMinPix = theValue.toInt(); + // case 11: myXMinPix = theValue.toInt(); + // case 12: myXMaxPix = theValue.toInt(); + // case 13: myYMaxPix = theValue.toInt(); + // case 14: + // { + // Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector); + // if (!aSelector3d.IsNull()) + // aSelector3d->Pick (myXMinPix, myYMinPix, myXMaxPix, myYMaxPix, View_Tools::FindActiveView (GetContext())); + // break; + // } + // default: break; + //} + return Standard_True; +} + +// ======================================================================= +// function : Dump +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const +{ + //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + //if (aViewerSelector.IsNull()) + // return Standard_False; + + //aViewerSelector->Dump (OS); + return Standard_True; +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn) +{ + return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn); +} diff --git a/tools/VInspector/VInspector_ItemBVHTree.hxx b/tools/VInspector/VInspector_ItemBVHTree.hxx new file mode 100644 index 0000000000..651145ee2b --- /dev/null +++ b/tools/VInspector/VInspector_ItemBVHTree.hxx @@ -0,0 +1,125 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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_ItemBVHTree_H +#define VInspector_ItemBVHTree_H + +#include +#include + +#include +#include +#include + +class VInspector_ItemBVHTree; +typedef QExplicitlySharedDataPointer VInspector_ItemBVHTreePtr; + +//! \class VInspector_ItemBVHTree +//! Parent item, that corresponds Folder under the AIS_InteractiveContext +//! Children of the item are: none +class VInspector_ItemBVHTree : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemBVHTreePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemBVHTreePtr (new VInspector_ItemBVHTree (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemBVHTree() 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 Handle(Standard_Transient) GetObject() const { initItem(); return myTree; } + + //! Returns current drawer, initialize the drawer if it was not initialized yet + Standard_EXPORT opencascade::handle > GetTree() const + { return opencascade::handle >::DownCast (GetObject()); } + + //! Returns the span from the 0 row to the first item corresponded to the picked item + //! the 0 item is SelectMgr_SelectingVolumeManager + Standard_Integer GetFirstChildOfPicked() const { return 1; } +protected: + //! Initialize 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 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; + + //! Returns type of edit control for the model index. By default, it is an empty control + //! \param theRow a model index row + //! \param theColumn a model index column + //! \return edit type + virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE; + + //! Sets the value into the table cell. Only 1st column value might be modified. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theValue a new cell value + virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE; + + //! Dumps the content of me on the stream . + virtual Standard_Boolean Dump (Standard_OStream& OS) const; + +protected: + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Set V3d viewer selector into the current field + //! \param theTree a viewer selector + void setTree (const opencascade::handle >& theTree) { myTree = theTree; } + +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_ItemBVHTree(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn); + +private: + + opencascade::handle > myTree; //!< the current tree + TCollection_AsciiString myName; //!< the name +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemBVHTreeNode.cxx b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx new file mode 100644 index 0000000000..99a45f590c --- /dev/null +++ b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx @@ -0,0 +1,96 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemBVHTreeNode::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 2; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemBVHTreeNode::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(); + + switch (Column()) + { + case 0: return QString ("TreeNode_" + Row()); break; + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTreeNode::Init() +{ + TreeModel_ItemBase::Init(); // to use getIO() without circling initialization +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTreeNode::Reset() +{ + VInspector_ItemBase::Reset(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= + +void VInspector_ItemBVHTreeNode::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int theRow, int theColumn) +{ + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemBVHTreeNode.hxx b/tools/VInspector/VInspector_ItemBVHTreeNode.hxx new file mode 100644 index 0000000000..ea09d07833 --- /dev/null +++ b/tools/VInspector/VInspector_ItemBVHTreeNode.hxx @@ -0,0 +1,86 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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_ItemBVHTreeNode_H +#define VInspector_ItemBVHTreeNode_H + +#include +#include + +//#include +//#include + +class SelectMgr_BaseFrustum; + +class VInspector_ItemBVHTreeNode; +typedef QExplicitlySharedDataPointer VInspector_ItemBVHTreeNodePtr; + +//! \class VInspector_ItemBVHTreeNode +//! Parent item, that corresponds Folder under the AIS_InteractiveContext +//! Children of the item are: none +class VInspector_ItemBVHTreeNode : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemBVHTreeNodePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemBVHTreeNodePtr (new VInspector_ItemBVHTreeNode (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemBVHTreeNode() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; } + +protected: + //! Initialize 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; + +protected: + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemBVHTreeNode(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemContainer.cxx b/tools/VInspector/VInspector_ItemContainer.cxx new file mode 100644 index 0000000000..a72c4741c6 --- /dev/null +++ b/tools/VInspector/VInspector_ItemContainer.cxx @@ -0,0 +1,96 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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 + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemContainer::initValue (int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)) + return QVariant(); + + VInspector_ItemContainerAPI* aContainerItem = dynamic_cast(Parent().data()); + + if (!aContainerItem) + return "Empty item container"; + + return aContainerItem->GetContainerValue (Row(), theItemRole); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemContainer::initRowCount() const +{ + VInspector_ItemContainerAPI* aContainerItem = dynamic_cast(Parent().data()); + + if (!aContainerItem) + return 0; + + return aContainerItem->GetContainerRowCount (Row()); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemContainer::createChild (int theRow, int theColumn) +{ + VInspector_ItemContainerAPI* aContainerItem = dynamic_cast(Parent().data()); + + if (!aContainerItem) + return TreeModel_ItemBasePtr(); + + return aContainerItem->CreateContainerChild (currentItem(), Row(), theRow, theColumn); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemContainer::Init() +{ + TreeModel_ItemBase::Init(); // to use getIO() without circling initialization +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemContainer::Reset() +{ + VInspector_ItemBase::Reset(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemContainer::initItem() const +{ + if (IsInitialized()) + return; + const_cast (this)->Init(); +} diff --git a/tools/VInspector/VInspector_ItemContainer.hxx b/tools/VInspector/VInspector_ItemContainer.hxx new file mode 100644 index 0000000000..f71949bc0c --- /dev/null +++ b/tools/VInspector/VInspector_ItemContainer.hxx @@ -0,0 +1,87 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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_ItemContainer_H +#define VInspector_ItemContainer_H + +#include +#include + +#include +#include +#include + +class Prs3d_Drawer; + +class QItemSelectionModel; + +class VInspector_ItemContainer; +typedef QExplicitlySharedDataPointer VInspector_ItemContainerPtr; + +//! \class VInspector_ItemContainer +//! Item presents additional level of information in the tree model. +//! Parent is item context, children are either folder item or Selection filter item. +class VInspector_ItemContainer : public VInspector_ItemBase +{ + +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemContainerPtr CreateItem (TreeModel_ItemBasePtr theParent, + const int theRow, const int theColumn) + { return VInspector_ItemContainerPtr (new VInspector_ItemContainer (theParent, theRow, theColumn)); } + //! Destructor + virtual ~VInspector_ItemContainer() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { return NULL; } + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of item selected + //! \return rows count + 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 + virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + VInspector_ItemContainer (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase (theParent, theRow, theColumn) {} + +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemContainerAPI.hxx b/tools/VInspector/VInspector_ItemContainerAPI.hxx new file mode 100644 index 0000000000..c986433e2b --- /dev/null +++ b/tools/VInspector/VInspector_ItemContainerAPI.hxx @@ -0,0 +1,50 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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_ItemContainerAPI_H +#define VInspector_ItemContainerAPI_H + +#include +#include + +//! \class VInspector_ItemContainerAPI +class VInspector_ItemContainerAPI +{ + +public: + //! Constructor + VInspector_ItemContainerAPI () {} + + //! Destructor + virtual ~VInspector_ItemContainerAPI() {}; + + //! Returns number of item selected + //! \return rows count + virtual int GetContainerRowCount (const int theContainerRow) const = 0; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const = 0; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) = 0; + +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx index e602f2b733..73e7dc02db 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx @@ -103,6 +103,21 @@ void VInspector_ItemSelectMgrBaseFrustum::initItem() const const_cast(this)->Init(); } +// ======================================================================= +// function : Dump +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemSelectMgrBaseFrustum::Dump (Standard_OStream& OS) const +{ + Handle(SelectMgr_BaseFrustum) aFrustum = GetFrustum(); + + if (aFrustum.IsNull()) + return Standard_False; + + aFrustum->Dump (OS); + return Standard_True; +} + // ======================================================================= // function : GetTableRowCount // purpose : diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx index 39079ddccf..37393debee 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx @@ -53,6 +53,9 @@ public: Standard_EXPORT Handle(SelectMgr_BaseFrustum) GetFrustum() const { return Handle(SelectMgr_BaseFrustum)::DownCast (GetObject()); } + //! Dumps the content of me on the stream . + virtual Standard_Boolean Dump (Standard_OStream& OS) const; + protected: //! Initialize the current item. It is empty because Reset() is also empty. virtual void initItem() const Standard_OVERRIDE; diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx new file mode 100644 index 0000000000..b2f61e37a4 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx @@ -0,0 +1,188 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 + +#include + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemSelectMgrSelectableObjectSet::initRowCount() const +{ + if (Column() != 0) + return 0; + + return SelectMgr_SelectableObjectSet::BVHSubsetNb; // VInspector_ItemBVHTree items +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemSelectMgrSelectableObjectSet::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(); + + SelectMgr_SelectableObjectSet aSet; + if (!GetSelectableObjectSet (aSet)) + return Column() == 0 ? "Empty selectable object set" : ""; + + switch (Column()) + { + case 0: return "SelectMgr_SelectableObjectSet"; + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void VInspector_ItemSelectMgrSelectableObjectSet::Init() +{ + //VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast(Parent()); + //Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr; + //if (aParentItem) + //{ + // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(aParentItem->Parent()); + // if (aParentContextItem) + // { + // Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext(); + // aVolumeMgr = aContext->MainSelector(); + // } + //} + //setViewerSelector (aVolumeMgr); + + //UpdatePresentationShape(); + TreeModel_ItemBase::Init(); // to use getIO() without circling initialization +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void VInspector_ItemSelectMgrSelectableObjectSet::Reset() +{ + VInspector_ItemBase::Reset(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= + +void VInspector_ItemSelectMgrSelectableObjectSet::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : GetSelectableObjectSet +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemSelectMgrSelectableObjectSet::GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const +{ + VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast(Parent()); + + if (!aParentItem || aParentItem->GetViewerSelector().IsNull()) + return Standard_False; + + theSet = aParentItem->GetViewerSelector()->GetSelectableObjects(); + return Standard_True; +} + +// ======================================================================= +// function : GetBVHTree +// purpose : +// ======================================================================= +opencascade::handle > VInspector_ItemSelectMgrSelectableObjectSet::GetBVHTree (const int theRow, + TCollection_AsciiString& theName) const +{ + SelectMgr_SelectableObjectSet aSet; + if (!GetSelectableObjectSet (aSet)) + return NULL; + + if (theRow >= SelectMgr_SelectableObjectSet::BVHSubsetNb) + return NULL; + + SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset)theRow; + theName = TCollection_AsciiString ("BVH_Tree_") + SelectMgr::BVHSubsetToString (aBVHSubset); + + return aSet.BVH (SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemSelectMgrSelectableObjectSet::GetTableRowCount() const +{ + return 60; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemSelectMgrSelectableObjectSet::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + //SelectMgr_SelectingVolumeManager aVolumeMgr; + //if (!GetViewerSelector (aVolumeMgr)) + // return QVariant(); + + //bool isFirstColumn = theColumn == 0; + //switch (theRow) + //{ + // case 0: return isFirstColumn ? QVariant ("GetActiveSelectionType") : QVariant (aVolumeMgr.GetActiveSelectionType()); + // case 1: return isFirstColumn ? QVariant ("IsOverlapAllowed()") : QVariant (aVolumeMgr.IsOverlapAllowed()); + // case 2: return isFirstColumn ? "GetNearPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetNearPickedPnt()).ToCString(); + // case 3: return isFirstColumn ? "GetFarPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetFarPickedPnt()).ToCString(); + // default: break; + //} + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectableObjectSet::createChild (int theRow, int theColumn) +{ + if (theRow == 0 || theRow == 1 || theRow == 2) + return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn); + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx new file mode 100644 index 0000000000..9a6a575d23 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx @@ -0,0 +1,102 @@ +// Created on: 2019-04-29 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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_ItemSelectMgrSelectableObjectSet_H +#define VInspector_ItemSelectMgrSelectableObjectSet_H + +#include + +#include +#include +#include +#include + +class SelectMgr_BaseFrustum; + +class VInspector_ItemSelectMgrSelectableObjectSet; +typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrSelectableObjectSetPtr; + +//! \class VInspector_ItemSelectMgrSelectableObjectSet +//! Parent item, that corresponds Folder under the AIS_InteractiveContext +//! Children of the item are: none +class VInspector_ItemSelectMgrSelectableObjectSet : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemSelectMgrSelectableObjectSetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemSelectMgrSelectableObjectSetPtr (new VInspector_ItemSelectMgrSelectableObjectSet (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemSelectMgrSelectableObjectSet() 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 Handle(Standard_Transient) GetObject() const { initItem(); return NULL; } + + //! Returns current drawer, initialize the drawer if it was not initialized yet + Standard_EXPORT Standard_Boolean GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const; + + //! Returns child BVH tree of the row + opencascade::handle > GetBVHTree (const int theRow, TCollection_AsciiString& theName) const; + +protected: + //! Initialize 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 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: + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) 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_ItemSelectMgrSelectableObjectSet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx index 8a08b48878..3f89dec684 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx @@ -29,7 +29,7 @@ int VInspector_ItemSelectMgrSelectingVolumeManager::initRowCount() const if (Column() != 0) return 0; - return 1; + return 2; } // ======================================================================= @@ -119,6 +119,24 @@ Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelect return Standard_True; } +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +Handle(SelectMgr_BaseFrustum) VInspector_ItemSelectMgrSelectingVolumeManager::GetFrustum (const int theRow) const +{ + SelectMgr_SelectingVolumeManager aVolumeManager; + if (!GetViewerSelector (aVolumeManager)) + return NULL; + + if (theRow == 0) + return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Box); + else if (theRow == 1) + return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Polyline); + + return NULL; +} + // ======================================================================= // function : GetTableRowCount // purpose : @@ -159,7 +177,7 @@ QVariant VInspector_ItemSelectMgrSelectingVolumeManager::GetTableData (const int // ======================================================================= TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectingVolumeManager::createChild (int theRow, int theColumn) { - if (theRow == 0) + if (theRow == 0 || theRow == 1) return VInspector_ItemSelectMgrBaseFrustum::CreateItem (currentItem(), theRow, theColumn); //else if (theRow == 1) // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn); diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx index b08765e477..b0f4a94b8a 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx @@ -22,6 +22,8 @@ #include #include +class SelectMgr_BaseFrustum; + class VInspector_ItemSelectMgrSelectingVolumeManager; typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrSelectingVolumeManagerPtr; @@ -52,6 +54,9 @@ public: //! Returns current drawer, initialize the drawer if it was not initialized yet Standard_EXPORT Standard_Boolean GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const; + //! Returns frustum Frustum for row = 0, FrustumSet for row = 1 + Handle(SelectMgr_BaseFrustum) GetFrustum (const int theRow) const; + protected: //! Initialize the current item. It is empty because Reset() is also empty. virtual void initItem() const Standard_OVERRIDE; diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx new file mode 100644 index 0000000000..e0b538927d --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx @@ -0,0 +1,137 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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 : initValue +// purpose : +// ======================================================================= +int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const +{ + Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet()); + if (!aSensitiveSet.IsNull()) + return aSensitiveSet->Size(); + + return 2; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (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(); + + Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet(); + const Handle(SelectMgr_SelectableObject)& aSelectableObject = GetSelectableObject(); + + if (anEntitySet.IsNull()) + return Column() == 0 ? "Empty sensitive entity set" : ""; + + if (aSelectableObject.IsNull()) + return Column() == 0 ? "Empty selectable object for sensitive entity set" : ""; + + switch (theItemRole) + { + case Qt::DisplayRole: + case Qt::EditRole: + case Qt::ToolTipRole: + { + switch (Column()) + { + case 0: return aSelectableObject->DynamicType()->Name(); + default: + break; + } + break; + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn) +{ + return VInspector_ItemSelect3DSensitiveSetItem::CreateItem (currentItem(), theRow, theColumn); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSensitiveEntitySet::Init() +{ + VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast(Parent()->Parent()); + + Handle(SelectMgr_SelectableObject) anObject; + Handle(SelectMgr_SensitiveEntitySet) anEntitySet = aParentItem->GetSensitiveEntitySet (Row(), anObject); + + myEntitySet = anEntitySet; + mySelectableObject = anObject; + + UpdatePresentationShape(); + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSensitiveEntitySet::Reset() +{ + // an empty method to don't clear the main label, otherwise the model will be empty + TreeModel_ItemBase::Reset(); + myEntitySet = NULL; + mySelectableObject = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSensitiveEntitySet::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : buildPresentationShape +// purpose : +// ======================================================================= +TopoDS_Shape VInspector_ItemSelectMgrSensitiveEntitySet::buildPresentationShape() +{ + //mySelectableObject + return TopoDS_Shape(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx new file mode 100644 index 0000000000..85ee1cdc08 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx @@ -0,0 +1,108 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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_ItemSelectMgrSensitiveEntitySet_H +#define VInspector_ItemSelectMgrSensitiveEntitySet_H + +#include +#include +#include +#include + +class SelectMgr_SelectableObject; + +class QItemSelectionModel; +class VInspector_ItemSelectMgrSensitiveEntitySet; + +typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrSensitiveEntitySetPtr; + +//! \class VInspector_ItemSelectMgrSensitiveEntitySet +class VInspector_ItemSelectMgrSensitiveEntitySet : public VInspector_ItemBase +{ + +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemSelectMgrSensitiveEntitySetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemSelectMgrSensitiveEntitySetPtr (new VInspector_ItemSelectMgrSensitiveEntitySet (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemSelectMgrSensitiveEntitySet() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myEntitySet; } + + //! \return the current sensitive entity + Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet() const + { return Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetObject()); } + + //! \return the current sensitive entity + Standard_EXPORT const Handle(SelectMgr_SelectableObject)& GetSelectableObject() const + { GetObject(); return mySelectableObject; } + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! \return number of children. + 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 + virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + + //! Returns table value for the row in form: depending on the aspect kind + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theEntityKind kind or kind of entity + QVariant getTableData (const int theRow, + const int theColumn, + const int theRole, + const TCollection_AsciiString& theEntityKind) const; + +protected: + //! Build presentation shape + //! \return generated shape of the item parameters + virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE; + + //! Constructor + //! param theParent a parent item + VInspector_ItemSelectMgrSensitiveEntitySet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +private: + + Handle(SelectMgr_SensitiveEntitySet) myEntitySet; //!< the current sensitive entity + Handle(SelectMgr_SelectableObject) mySelectableObject; //!< the current presentation +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx index 1f15cf506a..8c9687f555 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -15,7 +15,10 @@ #include +#include +#include #include +#include #include #include @@ -50,7 +53,8 @@ int VInspector_ItemSelectMgrViewerSelector::initRowCount() const if (Column() != 0) return 0; - Standard_Integer aNbRows = GetFirstChildOfPicked(); // SelectMgr_SelectingVolumeManager + // SelectMgr_SelectingVolumeManager, VInspector_ItemSelectMgrSelectableObjectSet, VInspector_ItemContainer + Standard_Integer aNbRows = GetFirstChildOfPicked(); Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector(); if (!aViewSelector.IsNull()) @@ -125,6 +129,80 @@ void VInspector_ItemSelectMgrViewerSelector::Reset() setViewerSelector (NULL); } +// ======================================================================= +// function : GetContainerRowCount +// purpose : +// ======================================================================= + +int VInspector_ItemSelectMgrViewerSelector::GetContainerRowCount (const int theContainerRow) const +{ + if (theContainerRow != 2) + return 0; + + Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector(); + if (aViewSelector.IsNull()) + return 0; + + return aViewSelector->GetObjectSensitives().Extent(); +} + +// ======================================================================= +// function : GetSensitiveEntitySet +// purpose : +// ======================================================================= +Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::GetSensitiveEntitySet (const int theRow, + Handle(SelectMgr_SelectableObject)& theObject) +{ + Standard_Integer anIndex = 0; + + Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector(); + if (!aViewSelector.IsNull()) + return NULL; + + for (SelectMgr_MapOfObjectSensitivesIterator anIterator (aViewSelector->GetObjectSensitives()); anIterator.More(); anIterator.Next(), anIndex++) + { + if (anIndex != theRow) + continue; + + theObject = anIterator.Key(); + return anIterator.Value(); + } + return NULL; +} + +// ======================================================================= +// function : GetContainerValue +// purpose : +// ======================================================================= + +QVariant VInspector_ItemSelectMgrViewerSelector::GetContainerValue (const int theContainerRow, const int theItemRole) const +{ + if (theContainerRow != 2) + return 0; + + if (theItemRole != Qt::DisplayRole) + return QVariant(); + + Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector(); + if (aViewSelector.IsNull()) + return QVariant(); + + return "SelectMgr_MapOfObjectSensitives"; +} + +// ======================================================================= +// function : CreateContainerChild +// purpose : +// ======================================================================= + +TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) +{ + if (theContainerRow != 2) + return TreeModel_ItemBasePtr(); + + return VInspector_ItemSelectMgrSensitiveEntitySet::CreateItem (theParent, theRow, theColumn); +} + // ======================================================================= // function : initItem // purpose : @@ -245,6 +323,20 @@ bool VInspector_ItemSelectMgrViewerSelector::SetTableData (const int theRow, con return Standard_True; } +// ======================================================================= +// function : Dump +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemSelectMgrViewerSelector::Dump (Standard_OStream& OS) const +{ + Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + if (aViewerSelector.IsNull()) + return Standard_False; + + aViewerSelector->Dump (OS); + return Standard_True; +} + // ======================================================================= // function : buildPresentationShape // purpose : @@ -272,12 +364,10 @@ TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::createChild (int t { if (theRow == 0) return VInspector_ItemSelectMgrSelectingVolumeManager::CreateItem (currentItem(), theRow, theColumn); + else if (theRow == 1) + return VInspector_ItemSelectMgrSelectableObjectSet::CreateItem (currentItem(), theRow, theColumn); + else if (theRow == 2) + return VInspector_ItemContainer::CreateItem (currentItem(), theRow, theColumn); else return VInspector_ItemSelectMgrViewerSelectorPicked::CreateItem (currentItem(), theRow, theColumn); - //else if (theRow == 1) - // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn); - //else if (theRow == 2) - // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn); - // - return TreeModel_ItemBasePtr(); } diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx index 978a70b34b..1367767873 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx @@ -18,9 +18,11 @@ #include #include +#include #include #include +#include class VInspector_ItemSelectMgrViewerSelector; typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrViewerSelectorPtr; @@ -28,7 +30,7 @@ typedef QExplicitlySharedDataPointer VIn //! \class VInspector_ItemSelectMgrViewerSelector //! Parent item, that corresponds Folder under the AIS_InteractiveContext //! Children of the item are: none -class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase +class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase, public VInspector_ItemContainerAPI { public: @@ -55,7 +57,31 @@ public: //! Returns the span from the 0 row to the first item corresponded to the picked item //! the 0 item is SelectMgr_SelectingVolumeManager - Standard_Integer GetFirstChildOfPicked() const { return 1; } + //! the 1 item is VInspector_ItemSelectMgrSelectableObjectSet + //! the 2 item is VInspector_ItemContainer for SelectMgr_MapOfObjectSensitives + Standard_Integer GetFirstChildOfPicked() const { return 3; } + + //! Returns entity set if possible from SelectMgr_MapOfObjectSensitives + //! \param theRow row index + //! \param theObject [out] object connected to the sensitive entity set + Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet (const int theRow, + Handle(SelectMgr_SelectableObject)& theObject); + + //! Returns number of item selected + //! \return rows count + virtual int GetContainerRowCount (const int theContainerRow) 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 + virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) Standard_OVERRIDE; + protected: //! Initialize the current item. It is empty because Reset() is also empty. virtual void initItem() const Standard_OVERRIDE; @@ -90,6 +116,9 @@ protected: //! \param theValue a new cell value virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE; + //! Dumps the content of me on the stream . + virtual Standard_Boolean Dump (Standard_OStream& OS) const; + protected: //! Build presentation shape diff --git a/tools/VInspector/VInspector_PropertiesCreator.cxx b/tools/VInspector/VInspector_PropertiesCreator.cxx new file mode 100644 index 0000000000..eb70a404ee --- /dev/null +++ b/tools/VInspector/VInspector_PropertiesCreator.cxx @@ -0,0 +1,40 @@ +// Created on: 2019-04-28 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 + +IMPLEMENT_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +// ======================================================================= +// function : GetProperties +// purpose : +// ======================================================================= +TreeModel_ItemProperties* VInspector_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem) +{ + Handle(Standard_Transient) anObject = theItem->GetObject(); + if (anObject.IsNull()) + return NULL; + + Standard_SStream aSStream; + if (theItem->Dump (aSStream)) + return new ViewControl_PropertiesStream (theItem); + + return NULL; +} + diff --git a/tools/VInspector/VInspector_PropertiesCreator.hxx b/tools/VInspector/VInspector_PropertiesCreator.hxx new file mode 100644 index 0000000000..b0673db741 --- /dev/null +++ b/tools/VInspector/VInspector_PropertiesCreator.hxx @@ -0,0 +1,47 @@ +// Created on: 2019-04-28 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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_PropertiesCreator_H +#define VInspector_PropertiesCreator_H + +#include +#include + +#include + +DEFINE_STANDARD_HANDLE (VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +//! \class VInspector_PropertiesCreator +//! \brief An interface to create custom panes by transient object name. +class VInspector_PropertiesCreator : public TreeModel_ItemPropertiesCreator +{ +public: + + //! Constructor + VInspector_PropertiesCreator() {} + + //! Destructor + virtual ~VInspector_PropertiesCreator() {} + + //! Returns pane for the name, creates a new pane if it does not exist and possible to create + //! \param theName type of the pane + //! \return a pane instance or NULL + virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +}; + +#endif diff --git a/tools/VInspector/VInspector_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index a44046decd..7f8bbb001c 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -600,6 +600,30 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_Box& theBoundingBox) return CreateBoxShape (aPntMin, aPntMax); } +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_OBB& theBoundingBox) +{ + if (theBoundingBox.IsVoid()) + return TopoDS_Shape(); + + TColgp_Array1OfPnt anArrPnts(0, 8); + theBoundingBox.GetVertex(&anArrPnts(0)); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(1)))); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(2)))); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(1)), gp_Pnt (anArrPnts.Value(3)))); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(2)), gp_Pnt (anArrPnts.Value(3)))); + + return aCompound; +} + //======================================================================= //function : CreateShape //purpose : diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index add7d38fdc..7b02cd9532 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -188,6 +189,11 @@ public: //! \return created shape Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_Box& theBoundingBox); + //! Creates box shape + //! \param theBoundingBox box shape parameters + //! \return created shape + Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox); + //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 6f42d6ca77..7fe674d6a5 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +128,7 @@ VInspector_Window::VInspector_Window() //((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_TREE_VIEW_WIDTH, // VINSPECTOR_DEFAULT_TREE_VIEW_HEIGHT)); VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView); + aTreeModel-> AddPropertiesCreator(new VInspector_PropertiesCreator()); myTreeView->setModel (aTreeModel); // hide Visibility column TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility); @@ -830,8 +832,6 @@ void VInspector_Window::onExportToShapeView() { const QModelIndexList anIndices; NCollection_List aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes()); - if (aSelectedShapes.Extent() <= 0) - return; TCollection_AsciiString aPluginName ("TKShapeView"); NCollection_List aParameters; @@ -843,20 +843,42 @@ void VInspector_Window::onExportToShapeView() anItemNames = myParameters->GetSelectedNames (aPluginName); QStringList anExportedPointers; - for (NCollection_List::Iterator anIOIt (aSelectedShapes); anIOIt.More(); anIOIt.Next()) + if (aSelectedShapes.Extent() > 0) { - const TopoDS_Shape& aShape = anIOIt.Value(); - if (aShape.IsNull()) + for (NCollection_List::Iterator anIOIt (aSelectedShapes); anIOIt.More(); anIOIt.Next()) + { + const TopoDS_Shape& aShape = anIOIt.Value(); + if (aShape.IsNull()) + continue; + aParameters.Append (aShape.TShape()); + anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape)); + anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()); + } + } + + // seach for objects to be exported + QList anItems = TreeModel_ModelBase::GetSelectedItems (myTreeView->selectionModel()->selectedIndexes()); + for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) + { + TreeModel_ItemBasePtr anItem = *anItemIt; + VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); + if (!aVItem) + continue; + + Handle(Standard_Transient) anObject = aVItem->GetObject(); + if (anObject.IsNull()) continue; - aParameters.Append (aShape.TShape()); - anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape)); - anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()); + + aParameters.Append (anObject); + anItemNames.Append (anObject->DynamicType()->Name()); + anExportedPointers.append (VInspector_Tools::GetPointerInfo (anObject, true).ToCString()); } - if (anExportedPointers.empty()) + + if (anExportedPointers.isEmpty()) return; TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length()); - QString aMessage = QString ("TShape %1 is sent to %2.") + QString aMessage = QString ("Objects %1 are sent to %2.") .arg (anExportedPointers.join(", ")) .arg (aPluginShortName.ToCString()); QString aQuestion = QString ("Would you like to activate %1 immediately?\n") diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx index a4f8e6e13e..76115eb042 100644 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx @@ -20,10 +20,6 @@ #include #include -#include - -#include -#include DEFINE_STANDARD_HANDLE (VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator) @@ -46,8 +42,6 @@ public: DEFINE_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator) -private: - NCollection_DataMap myPanes; //!< created panes }; #endif diff --git a/tools/View/View_Displayer.cxx b/tools/View/View_Displayer.cxx index 49fa790828..a74d190df1 100644 --- a/tools/View/View_Displayer.cxx +++ b/tools/View/View_Displayer.cxx @@ -313,7 +313,7 @@ Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shap { Handle(AIS_Shape) aShape = new AIS_Shape (theShape); - aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0)); + //aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0)); return aShape; } diff --git a/tools/View/View_Viewer.cxx b/tools/View/View_Viewer.cxx index ef24ca5231..03e8abe691 100644 --- a/tools/View/View_Viewer.cxx +++ b/tools/View/View_Viewer.cxx @@ -19,6 +19,13 @@ #include #include +#define USE_CLIPPLANE + +#ifdef USE_CLIPPLANE +#include +#include +#endif + // ======================================================================= // function : CreateView // purpose : @@ -26,7 +33,15 @@ void View_Viewer::CreateView() { if (myView.IsNull()) + { myView = myContext->CurrentViewer()->CreateView(); + +#ifdef USE_CLIPPLANE + gp_Pln aPln (gp_Pnt (50, 0, 0), gp_Dir (-1., 0., 0.)); + Handle(Graphic3d_ClipPlane) aClipPlane = new Graphic3d_ClipPlane(aPln); + myView->AddClipPlane (aClipPlane); +#endif + } } // ======================================================================= diff --git a/tools/ViewControl/FILES b/tools/ViewControl/FILES index ad85f4f68f..8c21c99ce9 100644 --- a/tools/ViewControl/FILES +++ b/tools/ViewControl/FILES @@ -8,6 +8,8 @@ ViewControl_Pane.hxx ViewControl_PaneCreator.cxx ViewControl_PaneCreator.hxx ViewControl_PaneItem.hxx +ViewControl_PropertiesStream.cxx +ViewControl_PropertiesStream.hxx ViewControl_PropertyView.cxx ViewControl_PropertyView.hxx ViewControl_Table.cxx diff --git a/tools/ViewControl/ViewControl_PropertiesStream.cxx b/tools/ViewControl/ViewControl_PropertiesStream.cxx new file mode 100644 index 0000000000..c37ee4260e --- /dev/null +++ b/tools/ViewControl/ViewControl_PropertiesStream.cxx @@ -0,0 +1,160 @@ +// Created on: 2019-04-28 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 + +IMPLEMENT_STANDARD_RTTIEXT(ViewControl_PropertiesStream, TreeModel_ItemProperties) + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void ViewControl_PropertiesStream::Init() +{ + if (!getItem() || !myValues.IsEmpty()) + return; + + Standard_SStream aSStream; + getItem()->Dump (aSStream); + + TCollection_AsciiString aStream (aSStream.str().c_str()); + Standard_Character aSeparator = Message::DumpSeparator(); + Standard_Integer aColumnCount = 0; + + TCollection_AsciiString aCurrentString = aStream; + Standard_Integer aPosition = aCurrentString.Search (aSeparator); + if (aPosition >= 1) + { + TCollection_AsciiString aTailString = aCurrentString.Split (aPosition); + Standard_Boolean aClassNameFound = Standard_False; + while (!aCurrentString.IsEmpty()) + { + TCollection_AsciiString aValueString = aCurrentString; + aPosition = aValueString.Search (aSeparator); + if (aPosition < 0 ) + break; + aCurrentString = aValueString.Split (aPosition - 1); + + if (!aColumnCount) + { + if (!aClassNameFound) + aClassNameFound = Standard_True; + else + { + if (!aValueString.IsIntegerValue()) + break; // not correct Dump, in correct the first value is number of property columns + aColumnCount = aValueString.IntegerValue(); + } + } + else + myValues.Append (aValueString); + + if (aTailString.IsEmpty()) + break; + aCurrentString = aTailString; + aPosition = aCurrentString.Search (aSeparator); + if (aPosition < 0 ) + { + aCurrentString = aTailString; + aTailString = TCollection_AsciiString(); + } + else + aTailString = aCurrentString.Split (aPosition); + } + } + myColumnCount = aColumnCount; +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void ViewControl_PropertiesStream::Reset() +{ + if (!getItem()) + return; + myValues.Clear(); + myColumnCount = 0; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= + +void ViewControl_PropertiesStream::initItem() const +{ + const_cast(this)->Init(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= + +int ViewControl_PropertiesStream::GetTableRowCount() const +{ + initItem(); + + return getValues().Length() / myColumnCount; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= + +QVariant ViewControl_PropertiesStream::GetTableData (const int theRow, const int theColumn, int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + initItem(); + + int anIndex = theRow * myColumnCount + theColumn; + if (theRole == Qt::DisplayRole && anIndex < getValues().Length()) + return getValues().Value(anIndex).ToCString(); + + return QVariant(); +} + +// ======================================================================= +// function : GetPresentations +// purpose : +// ======================================================================= + +void ViewControl_PropertiesStream::GetPresentations (const int theRow, + const int theColumn, + NCollection_List& thePresentations) +{ + if (theColumn == 0) + return; + + QVariant aValue = GetTableData (theRow, theColumn, Qt::DisplayRole); + TCollection_AsciiString aStrValue = aValue.toString().toStdString().c_str(); + + gp_XYZ aPoint; + if (!aPoint.FromString (aStrValue)) + return; + + thePresentations.Append (new ViewControl_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); +} diff --git a/tools/ViewControl/ViewControl_PropertiesStream.hxx b/tools/ViewControl/ViewControl_PropertiesStream.hxx new file mode 100644 index 0000000000..91730e8617 --- /dev/null +++ b/tools/ViewControl/ViewControl_PropertiesStream.hxx @@ -0,0 +1,90 @@ +// Created on: 2019-04-28 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 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 ViewControl_PropertiesStream_H +#define ViewControl_PropertiesStream_H + +#include +#include +#include + +#include +#include + +DEFINE_STANDARD_HANDLE (ViewControl_PropertiesStream, TreeModel_ItemProperties) + +//! \class ViewControl_PropertiesStream +//! \brief This is an interace for ViewControl_TableModel to give real values of the model +//! It should be filled or redefined. +class ViewControl_PropertiesStream : public TreeModel_ItemProperties +{ +public: + + //! Constructor + Standard_EXPORT ViewControl_PropertiesStream (const TreeModel_ItemBasePtr& theItem) + : TreeModel_ItemProperties (theItem) {} + + //! Destructor + virtual ~ViewControl_PropertiesStream() {} + + //! If me has internal values, it should be initialized here. + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! If the item has internal values, there should be reseted here. + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table columns + //! \return an integer value + virtual int GetTableColumnCount() const { initItem(); return myColumnCount; } + + //! Returns number of rows, depending on orientation: myColumnCount or size of values container + //! \param theParent an index of the parent item + //! \return an integer value + Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns content of the model index for the given role, it is obtained from internal container of values + //! It returns value only for DisplayRole. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theRole a view role + //! \return value intepreted depending on the given role + Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE; + + //! Returns presentation of the attribute to be visualized in the view + //! \param theRow a model index row + //! \param theColumn a model index column + //! \thePresentations [out] container of presentation handles to be visualized + Standard_EXPORT virtual void GetPresentations (const int theRow, const int theColumn, + NCollection_List& thePresentations) Standard_OVERRIDE; + +protected: + //! Returns values + //! @return values + const NCollection_Vector& getValues() const { return myValues; } + +protected: + + //! Initialize me. + Standard_EXPORT void initItem() const; + +public: + DEFINE_STANDARD_RTTIEXT (ViewControl_PropertiesStream, TreeModel_ItemProperties) + +protected: + NCollection_Vector myValues; //!< container of values + Standard_Integer myColumnCount; //!< value to present container of values into table +}; + +#endif -- 2.39.5