From fb9df65ce306d727c2211d8e8248d38e19532379 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 6 Jun 2019 07:41:07 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin - display BVH information in VInspector --- src/BVH/BVH_Box.hxx | 13 + src/BVH/BVH_Tree.hxx | 41 ++++ src/BVH/BVH_Types.hxx | 28 +++ src/Bnd/Bnd_Box.cxx | 59 +++++ src/Bnd/Bnd_Box.hxx | 20 ++ src/Bnd/Bnd_OBB.cxx | 16 ++ src/Bnd/Bnd_OBB.hxx | 7 + src/Message/Message.cxx | 225 ++++++++++++++++++ src/Message/Message.hxx | 66 ++++- src/Message/Message_Alerts.hxx | 28 +++ .../Message_AttributeVectorOfValues.cxx | 1 - src/Quantity/Quantity_Color.cxx | 32 +++ src/Quantity/Quantity_Color.hxx | 9 + src/Quantity/Quantity_ColorRGBA.hxx | 36 +++ src/SelectBasics/SelectBasics_PickResult.hxx | 12 + .../SelectMgr_RectangularFrustum.cxx | 4 +- tools/MessageModel/MessageModel_ItemAlert.cxx | 23 ++ tools/MessageModel/MessageModel_ItemAlert.hxx | 10 + .../MessageView_VisibilityState.cxx | 9 + tools/MessageView/MessageView_Window.cxx | 130 ++++++++++ tools/MessageView/MessageView_Window.hxx | 13 +- tools/TInspectorEXE/TInspectorEXE.cxx | 6 +- tools/TKTreeModel/EXTERNLIB | 1 + tools/VInspector/FILES | 2 + tools/VInspector/VInspector_ItemBVHTree.cxx | 189 +++++---------- tools/VInspector/VInspector_ItemBVHTree.hxx | 34 +-- .../VInspector/VInspector_ItemBVHTreeNode.cxx | 82 ++++++- .../VInspector/VInspector_ItemBVHTreeNode.hxx | 10 + ...VInspector_ItemSelectBasicsEntityOwner.cxx | 5 +- ...ector_ItemSelectMgrSelectableObjectSet.cxx | 2 +- ...pector_ItemSelectMgrSensitiveEntitySet.cxx | 32 ++- ...pector_ItemSelectMgrSensitiveEntitySet.hxx | 4 + ...VInspector_ItemSelectMgrViewerSelector.cxx | 36 +-- .../VInspector_PreviewParameters.cxx | 120 ++++++++++ .../VInspector_PreviewParameters.hxx | 68 ++++++ .../VInspector_PropertiesCreator.cxx | 4 - tools/VInspector/VInspector_Tools.hxx | 10 +- tools/VInspector/VInspector_Window.cxx | 106 ++++++++- tools/VInspector/VInspector_Window.hxx | 11 +- tools/View/View_Viewer.cxx | 2 +- .../ViewControl_PropertiesStream.cxx | 47 +--- .../ViewControl_PropertiesStream.hxx | 1 + tools/ViewControl/ViewControl_Tools.cxx | 109 +++++++++ tools/ViewControl/ViewControl_Tools.hxx | 18 ++ 44 files changed, 1419 insertions(+), 262 deletions(-) create mode 100644 tools/VInspector/VInspector_PreviewParameters.cxx create mode 100644 tools/VInspector/VInspector_PreviewParameters.hxx diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 8210aa39ba..4e7dfc94e7 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -108,6 +109,18 @@ public: //! Returns center of bounding box along the given axis. T Center (const Standard_Integer theAxis) const; + //! Dumps the content of me on the stream . + void Dump (Standard_OStream& OS) const + { + DUMP_VALUES (OS, "BVH_Box", 2); + DUMP_VALUES (OS, "IsValid", IsValid()); + + DUMP_VALUES (OS, "Bnd_Box", BVH::ToBndBox (CornerMin(), CornerMax()).ToString()); + + //DUMP_VALUES (OS, "CornerMin", BVH::ToString (CornerMin())); + //DUMP_VALUES (OS, "CornerMin", BVH::ToString (CornerMax())); + } + protected: BVH_VecNt myMinPoint; //!< Minimum point of bounding box diff --git a/src/BVH/BVH_Tree.hxx b/src/BVH/BVH_Tree.hxx index a223d14b30..a46f717a50 100644 --- a/src/BVH/BVH_Tree.hxx +++ b/src/BVH/BVH_Tree.hxx @@ -18,6 +18,11 @@ #include +#include + +#include +#include + template class BVH_Builder; //! A non-template class for using as base for BVH_TreeBase @@ -27,6 +32,13 @@ class BVH_TreeBaseTransient : public Standard_Transient DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient) protected: BVH_TreeBaseTransient() {} + + //! Dumps the content of me on the stream . + virtual void Dump (Standard_OStream& OS) const { (void)OS; } + + //! Dumps the content of the given node on the stream . + virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const + { (void)theNodeIndex; (void)OS; } }; //! Stores parameters of bounding volume hierarchy (BVH). @@ -178,6 +190,35 @@ public: //! @name methods for accessing serialized tree data return myMaxPointBuffer; } + //! Dumps the content of me on the stream . + Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE + { + DUMP_VALUES (OS, "BVH_Tree", 2); + + DUMP_VALUES (OS, "Depth", Depth()); + DUMP_VALUES (OS, "Length", Length()); + + for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx) + { + DumpNode (aNodeIdx, OS); + } + } + + //! Dumps the content of the given node on the stream . + Standard_EXPORT virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const Standard_OVERRIDE + { + DUMP_VALUES (OS, "BVH_TreeNode", 2); + DUMP_VALUES (OS, "NodeIndex", theNodeIndex); + + DUMP_VALUES (OS, "MinPoint - MaxPoint", BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).ToString()); + + DUMP_VALUES (OS, "BegPrimitive", BegPrimitive (theNodeIndex)); + DUMP_VALUES (OS, "EndPrimitive", EndPrimitive (theNodeIndex)); + DUMP_VALUES (OS, "Level", Level (theNodeIndex)); + DUMP_VALUES (OS, "IsOuter", IsOuter (theNodeIndex)); + } + + public: //! @name protected fields //! Array of node data records. diff --git a/src/BVH/BVH_Types.hxx b/src/BVH/BVH_Types.hxx index 6cbf7ae916..fcbc66bca1 100644 --- a/src/BVH/BVH_Types.hxx +++ b/src/BVH/BVH_Types.hxx @@ -21,10 +21,12 @@ #include +#include #include #include #include #include +#include #include // GCC supports shrink function only in C++11 mode @@ -57,6 +59,32 @@ namespace BVH typedef NCollection_Vec3 Type; }; + template Bnd_Box ToBndBox (const T& theType1, const T& theType2) + { + return Bnd_Box (theType1, 0., 0., theType2, 0., 0.); + } + + template Bnd_Box ToBndBox (const NCollection_Vec2& theType1, + const NCollection_Vec2& theType2) + { + return Bnd_Box (theType1.x(), theType1.y(), 0., + theType2.x(), theType2.y(), 0.); + } + + template Bnd_Box ToBndBox (const NCollection_Vec3& theType1, + const NCollection_Vec3& theType2) + { + return Bnd_Box (theType1.x(), theType1.y(), theType1.z(), + theType2.x(), theType2.y(), theType2.z()); + } + + template Bnd_Box ToBndBox (const NCollection_Vec4& theType1, + const NCollection_Vec4& theType2) + { + return Bnd_Box (theType1.x(), theType1.y(), theType1.z(), + theType2.x(), theType2.y(), theType2.z()); + } + template struct VectorType { typedef NCollection_Vec4 Type; diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx index 3f9ea999ff..d7e67d141a 100644 --- a/src/Bnd/Bnd_Box.cxx +++ b/src/Bnd/Bnd_Box.cxx @@ -43,6 +43,19 @@ Bnd_Box::Bnd_Box() SetVoid(); } +//======================================================================= +//function : Bnd_Box +//purpose : +//======================================================================= + +Bnd_Box::Bnd_Box (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin, + const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax) +: Gap (0.0) +{ + SetVoid(); + Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax); +} + //======================================================================= //function : Set //purpose : @@ -957,3 +970,49 @@ void Bnd_Box::Dump () const cout << "\n Gap : " << Gap; cout << "\n"; } + +//======================================================================= +//function : PointsSeparator +//purpose : +//======================================================================= +TCollection_AsciiString PointsSeparator() +{ + return " - "; +} + +//======================================================================= +//function : ToString +//purpose : +//======================================================================= + +TCollection_AsciiString Bnd_Box::ToString() const +{ + return gp_XYZ (Xmin, Ymin, Zmin).ToString() + + PointsSeparator() + + gp_XYZ (Xmax, Ymax, Zmax).ToString(); +} + +//======================================================================= +//function : FromString +//purpose : +//======================================================================= + +Standard_Boolean Bnd_Box::FromString (const TCollection_AsciiString& theValue) +{ + TCollection_AsciiString aCurrentString = theValue; + Standard_Integer aPosition = aCurrentString.Search (PointsSeparator()); + if (aPosition < 0) + return Standard_False; + + TCollection_AsciiString aLeftString = aCurrentString; + TCollection_AsciiString aRightString = aLeftString.Split (aPosition - 1); + aCurrentString = aRightString; + aRightString = aCurrentString.Split (PointsSeparator().Length()); + + gp_XYZ aMinPoint, aMaxPoint; + if (!aMinPoint.FromString (aLeftString) || !aMaxPoint.FromString (aRightString)) + return Standard_False; + + Update (aMinPoint.X(), aMinPoint.Y(), aMinPoint.Z(), aMaxPoint.X(), aMaxPoint.Y(), aMaxPoint.Z()); + return Standard_True; +} diff --git a/src/Bnd/Bnd_Box.hxx b/src/Bnd/Bnd_Box.hxx index 301d9ad72c..268db71f36 100644 --- a/src/Bnd/Bnd_Box.hxx +++ b/src/Bnd/Bnd_Box.hxx @@ -24,6 +24,10 @@ #include #include #include + +#include +#include + class Standard_ConstructionError; class gp_Pnt; class gp_Dir; @@ -69,6 +73,14 @@ public: //! The constructed box is qualified Void. Its gap is null. Standard_EXPORT Bnd_Box(); + //! Creates a bounding box, it contains: + //! - interval [ aXmin,aXmax ] in the "X Direction", + //! - interval [ aYmin,aYmax ] in the "Y Direction", + //! - interval [ aZmin,aZmax ] in the "Z Direction"; + //! The constructed box is qualified Void. Its gap is null. + Standard_EXPORT Bnd_Box (const Standard_Real aXmin, const Standard_Real aYmin, const Standard_Real aZmin, + const Standard_Real aXmax, const Standard_Real aYmax, const Standard_Real aZmax); + //! Sets this bounding box so that it covers the whole of 3D space. //! It is infinitely long in all directions. void SetWhole() { Flags = WholeMask; } @@ -296,6 +308,14 @@ public: && Xmax >= Xmin; } + //! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax) + //! \return the string value + Standard_EXPORT TCollection_AsciiString ToString() const; + + //! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax) + //! \return true if conversion is done + Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue); + protected: //! Bit flags. diff --git a/src/Bnd/Bnd_OBB.cxx b/src/Bnd/Bnd_OBB.cxx index e9b7f36ea8..d0b4382f74 100644 --- a/src/Bnd/Bnd_OBB.cxx +++ b/src/Bnd/Bnd_OBB.cxx @@ -677,3 +677,19 @@ void Bnd_OBB::Add(const Bnd_OBB& theOther) ReBuild(TColgp_Array1OfPnt(aList[0], 0, 15)); } +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +Standard_Boolean Bnd_OBB::Init (const Standard_OStream& OS) +{ + return Standard_False; +} + +// ======================================================================= +// function : Dump +// purpose : +// ======================================================================= +void Bnd_OBB::Dump (Standard_OStream& OS) const +{ +} diff --git a/src/Bnd/Bnd_OBB.hxx b/src/Bnd/Bnd_OBB.hxx index d40d22ca93..065e67d959 100644 --- a/src/Bnd/Bnd_OBB.hxx +++ b/src/Bnd/Bnd_OBB.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -276,6 +277,12 @@ public: //! (which it was created from) and theP. Standard_EXPORT void Add(const gp_Pnt& theP); + //! Dumps the content of me on the stream . + Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS); + + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS) const; + protected: void ProcessOnePoint(const gp_Pnt& theP) diff --git a/src/Message/Message.cxx b/src/Message/Message.cxx index fe7d02c180..c04816e92c 100644 --- a/src/Message/Message.cxx +++ b/src/Message/Message.cxx @@ -125,3 +125,228 @@ TCollection_AsciiString Message::PointerToString (const void* thePointer, const } return aPtrStr.str().c_str(); } + +// ======================================================================= +// function : StrVectorToString +// purpose : +// ======================================================================= +TCollection_AsciiString Message::StrVectorToString + (const NCollection_Vector& theValues) +{ + TCollection_AsciiString aValue; + for (NCollection_Vector::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next()) + { + aValue += aValuesIt.Value(); + if (aValuesIt.More()) + aValue += VectorSeparator(); + } + return aValue; +} + +// ======================================================================= +// function : StrVectorFromString +// purpose : +// ======================================================================= +Standard_Boolean Message::StrVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + while (!aCurrentString.IsEmpty()) + { + Standard_Integer aPosition = aCurrentString.Search (", "); + aValueString = aCurrentString; + if (aPosition > 0) + aCurrentString = aValueString.Split (aPosition - 1); + theValues.Append (aValueString.RealValue()); + if (aPosition > 0) + aCurrentString = aCurrentString.Split (2); + } + return Standard_True; +} + +// ======================================================================= +// function : RealVectorToString +// purpose : +// ======================================================================= +TCollection_AsciiString Message::RealVectorToString + (const NCollection_Vector& theValues) +{ + TCollection_AsciiString aValue = ("("); + + for (NCollection_Vector::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next()) + { + aValue += aValuesIt.Value(); + if (aValuesIt.More()) + aValue += VectorSeparator(); + } + aValue += ")"; + + return aValue; +} + +// ======================================================================= +// function : RealVectorFromString +// purpose : +// ======================================================================= +Standard_Boolean Message::RealVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + Standard_Integer aPosition = aCurrentString.Search ("("); + if (aPosition != 1) + return Standard_False; + aCurrentString = aCurrentString.Split (aPosition); + + aPosition = aCurrentString.Search (")"); + if (aPosition != 1) + return Standard_False; + aValueString = aCurrentString.Split (aPosition); + + + while (!aCurrentString.IsEmpty()) + { + // x value + aPosition = aCurrentString.Search (", "); + aValueString = aCurrentString; + if (aPosition > 0) + aCurrentString = aValueString.Split (aPosition - 1); + theValues.Append (aValueString.RealValue()); + if (aPosition > 0) + aCurrentString = aCurrentString.Split (2); + } + return Standard_True; +} + +// ======================================================================= +// function : CoordVectorToString +// purpose : +// ======================================================================= +TCollection_AsciiString Message::CoordVectorToString + (const NCollection_Vector& theValues) +{ + TCollection_AsciiString aValue = ("("); + aValue += RealVectorToString (theValues); + aValue += ")"; + + return aValue; +} + +// ======================================================================= +// function : CoordVectorFromString +// purpose : +// ======================================================================= +Standard_Boolean Message::CoordVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + Standard_Integer aPosition = aCurrentString.Search ("("); + if (aPosition != 1) + return Standard_False; + aCurrentString = aCurrentString.Split (aPosition); + + aPosition = aCurrentString.Search (")"); + if (aPosition != 1) + return Standard_False; + aValueString = aCurrentString.Split (aPosition); + + return RealVectorFromString (aCurrentString, theValues); +} + +// ======================================================================= +// function : ColorVectorToString +// purpose : +// ======================================================================= +TCollection_AsciiString Message::ColorVectorToString + (const NCollection_Vector& theValues) +{ + TCollection_AsciiString aValue = ("["); + aValue += RealVectorToString (theValues); + aValue += "]"; + + return aValue; +} + +// ======================================================================= +// function : ColorVectorFromString +// purpose : +// ======================================================================= +Standard_Boolean Message::ColorVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aCurrentString = theValue, aValueString; + + Standard_Integer aPosition = aCurrentString.Search ("["); + if (aPosition != 1) + return Standard_False; + aCurrentString = aCurrentString.Split (aPosition); + + aPosition = aCurrentString.Search ("]"); + if (aPosition != 1) + return Standard_False; + aValueString = aCurrentString.Split (aPosition); + + return RealVectorFromString (aCurrentString, theValues); +} + +// ======================================================================= +// function : ConvertStream +// purpose : +// ======================================================================= +void Message::ConvertStream (const Standard_SStream& theStream, + Standard_Integer& theColumnCount, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aStream (theStream.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 + theValues.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); + } + } + theColumnCount = aColumnCount; +} diff --git a/src/Message/Message.hxx b/src/Message/Message.hxx index 96feb8de0d..7f9c44a5ab 100644 --- a/src/Message/Message.hxx +++ b/src/Message/Message.hxx @@ -18,6 +18,7 @@ #define _Message_HeaderFile #include +#include #include #include @@ -25,8 +26,9 @@ #include #include +#include + class Message_Messenger; -class TCollection_AsciiString; class Message_Msg; class Message_MsgFile; class Message_Messenger; @@ -86,6 +88,9 @@ public: //! Returns separator symbol of Dump information static Standard_Character DumpSeparator() { return '\\'; } + //! Returns separator symbol of values vector union + static TCollection_AsciiString VectorSeparator() { return " ,"; } + //! Convert handle pointer to string value //! \param thePointer a pointer //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped @@ -99,6 +104,65 @@ public: //! \return the string value Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer, const bool isShortInfo = true); + //! Convert vector of real values to string, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static TCollection_AsciiString StrVectorToString + (const NCollection_Vector& theValues); + + //! Convert string to vector of real values, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static Standard_Boolean StrVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues); + + //! Convert vector of real values to string, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static TCollection_AsciiString RealVectorToString + (const NCollection_Vector& theValues); + + //! Convert string to vector of real values, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static Standard_Boolean RealVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues); + + //! Convert vector of real values to string, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static TCollection_AsciiString CoordVectorToString + (const NCollection_Vector& theValues); + + //! Convert string to vector of real values, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static Standard_Boolean CoordVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues); + + //! Convert vector of real values to string, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static TCollection_AsciiString ColorVectorToString + (const NCollection_Vector& theValues); + + //! Convert string to vector of real values, separator is vector separator + //! \param thePointer a container of real values + //! \return the string value + Standard_EXPORT static Standard_Boolean ColorVectorFromString + (const TCollection_AsciiString& theValue, + NCollection_Vector& theValues); + + //! Converts stream to vector of values and column count + //! \param theStream stream value + //! \param theColumnCount [out] number of columns + //! \param theValues [out] container of split values + static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream, + Standard_Integer& theColumnCount, + NCollection_Vector& theValues); protected: diff --git a/src/Message/Message_Alerts.hxx b/src/Message/Message_Alerts.hxx index 267cc8c8e1..d1789025b2 100644 --- a/src/Message/Message_Alerts.hxx +++ b/src/Message/Message_Alerts.hxx @@ -23,6 +23,9 @@ #include #include +#include +#include + static Handle(Message_Alert) OCCT_Message_Alert; #define MESSAGE_INFO(Name, Description, PerfMeter, ParentAlert) \ @@ -70,5 +73,30 @@ static Handle(Message_Alert) OCCT_Message_Alert; OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \ } +#define DUMP_VEC_COLOR(Values, Value) \ + { \ + Value = Message::ColorVectorToString (aValues); \ + } + +#define DUMP_VEC_COLOR_SPLIT(Value, Values) \ + { \ + Message::ColorVectorFromString (Value, Values); \ + } + +#define DUMP_VEC_COORD(Values, Value) \ + { \ + Value = Message::CoordVectorToString (aValues); \ + } + +#define DUMP_VEC_COORD_SPLIT(Value, Values) \ + { \ + Message::CoordVectorFromString (Value, Values); \ + } + + +#define DUMP_VALUES_SPLIT(OS, ColumnCount, Values) \ + { \ + Message::ConvertStream (OS, aColumnCount, aValues); \ + } #endif // _Message_Alerts_HeaderFile diff --git a/src/Message/Message_AttributeVectorOfValues.cxx b/src/Message/Message_AttributeVectorOfValues.cxx index fcbb2fc9d2..3d389a1f45 100644 --- a/src/Message/Message_AttributeVectorOfValues.cxx +++ b/src/Message/Message_AttributeVectorOfValues.cxx @@ -40,7 +40,6 @@ Message_AttributeVectorOfValues::Message_AttributeVectorOfValues (const Standard if (aPosition >= 1) { TCollection_AsciiString aTailString = aCurrentString.Split (aPosition); - Standard_Integer aRow = 0; Standard_Boolean aClassNameFound = Standard_False; while (!aCurrentString.IsEmpty()) { diff --git a/src/Quantity/Quantity_Color.cxx b/src/Quantity/Quantity_Color.cxx index 3c056ff8eb..cd711d7954 100644 --- a/src/Quantity/Quantity_Color.cxx +++ b/src/Quantity/Quantity_Color.cxx @@ -15,6 +15,8 @@ #include +#include +#include #include #include #include @@ -3908,3 +3910,33 @@ void call_rgbhls (float r, float g, float b, float& h, float& l, float& s) if (h < 0.0) h += 360.0; } } + +TCollection_AsciiString Quantity_Color::ToString() const +{ + NCollection_Vector aValues; + aValues.Append (MyRed); + aValues.Append (MyGreen); + aValues.Append (MyBlue); + + Standard_SStream OS; + + TCollection_AsciiString aValue; + DUMP_VEC_COLOR(aValues, aValue) + + return aValue; +} + +Standard_Boolean Quantity_Color::FromString (const TCollection_AsciiString& theValue) +{ + NCollection_Vector aValues; + DUMP_VEC_COLOR_SPLIT (theValue, aValues) + + if (aValues.Size() != 3) + return Standard_False; + + MyRed = (Standard_ShortReal)aValues.Value (0); + MyGreen = (Standard_ShortReal)aValues.Value (1); + MyBlue = (Standard_ShortReal)aValues.Value (2); + + return Standard_True; +} diff --git a/src/Quantity/Quantity_Color.hxx b/src/Quantity/Quantity_Color.hxx index a31c38da5d..a32c04a111 100644 --- a/src/Quantity/Quantity_Color.hxx +++ b/src/Quantity/Quantity_Color.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -240,6 +241,14 @@ Standard_Boolean operator == (const Quantity_Color& Other) const //! Internal test Standard_EXPORT static void Test(); + //! 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); + private: //! Converts HLS components into RGB ones. diff --git a/src/Quantity/Quantity_ColorRGBA.hxx b/src/Quantity/Quantity_ColorRGBA.hxx index 8f91d9fea3..dddcaa9695 100644 --- a/src/Quantity/Quantity_ColorRGBA.hxx +++ b/src/Quantity/Quantity_ColorRGBA.hxx @@ -14,6 +14,8 @@ #ifndef _Quantity_ColorRGBA_HeaderFile #define _Quantity_ColorRGBA_HeaderFile +#include +#include #include #include @@ -91,6 +93,40 @@ public: //! Two colors are considered to be equal if their distance is no greater than Epsilon(). bool operator== (const Quantity_ColorRGBA& theOther) const { return IsEqual (theOther); } + + //! Covers point into string in format: (X, Y, Z) + //! \return the string value + Standard_EXPORT TCollection_AsciiString ToString() const + { + NCollection_Vector aValues; + aValues.Append (myRgb.Red()); + aValues.Append (myRgb.Green()); + aValues.Append (myRgb.Blue()); + aValues.Append (myAlpha); + + TCollection_AsciiString aValue; + DUMP_VEC_COORD (aValues, aValue); + return aValue; + } + + + //! 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) + { + NCollection_Vector aValues; + DUMP_VEC_COORD_SPLIT (theValue, aValues) + + if (aValues.Size() != 3) + return Standard_False; + + myRgb = Quantity_Color (aValues.Value (0), aValues.Value (1), aValues.Value (2), + Quantity_TOC_RGB); + myAlpha = (Standard_ShortReal)aValues.Value (3); + + return Standard_True; + } + private: static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); } diff --git a/src/SelectBasics/SelectBasics_PickResult.hxx b/src/SelectBasics/SelectBasics_PickResult.hxx index 03bcc16a49..4f45c8906d 100644 --- a/src/SelectBasics/SelectBasics_PickResult.hxx +++ b/src/SelectBasics/SelectBasics_PickResult.hxx @@ -17,6 +17,9 @@ #define _SelectBasics_PickResult_HeaderFile #include +#include + +#include #include //! This structure provides unified access to the results of Matches() method in all sensitive entities, @@ -80,6 +83,15 @@ public: //! Set distance to geometry center. void SetDistToGeomCenter (Standard_Real theDistToCenter) { myDistToCenter = theDistToCenter; } + //! Dumps the content of me on the stream . + void Dump (Standard_OStream& OS) const + { + DUMP_VALUES (OS, "SelectBasics_PickResult", 2); + DUMP_VALUES (OS, "myObjPickedPnt", myObjPickedPnt.XYZ().ToString()); + DUMP_VALUES (OS, "myDepth", myDepth); + DUMP_VALUES (OS, "myDistToCenter", myDistToCenter); + } + private: gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object Standard_Real myDepth; //!< Depth to detected point diff --git a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx index 81f939f7c1..7bcd7d8353 100644 --- a/src/SelectMgr/SelectMgr_RectangularFrustum.cxx +++ b/src/SelectMgr/SelectMgr_RectangularFrustum.cxx @@ -441,7 +441,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t Standard_Boolean* theInside) const { Message_PerfMeter aPerfMeter; - MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vvb", "", &aPerfMeter, NULL); + Bnd_Box aBox (theBoxMin.x(), theBoxMin.y(), theBoxMin.z(), + theBoxMax.x(), theBoxMax.y(), theBoxMax.z()); + MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vvb", aBox.ToString(), &aPerfMeter, NULL); return hasOverlap (theBoxMin, theBoxMax, theInside); } diff --git a/tools/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx index c05a71b800..b94e5ac006 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.cxx +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -18,12 +18,16 @@ #include #include #include +#include +#include #include #include +#include #include #include +#include #include #include @@ -32,6 +36,7 @@ #include #include + // ======================================================================= // function : initValue // purpose : @@ -208,6 +213,23 @@ void MessageModel_ItemAlert::Init() } } } + + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(myAlert); + if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull()) + { + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (!anAttribute.IsNull()) + { + if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject))) + myPresentations.Append (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject()); + if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) + myPresentations.Append (new ViewControl_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape())); + } + TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription(); + Bnd_Box aBox; + if (aBox.FromString (aDescription)) + myPresentations.Append (new ViewControl_TransientShape (ViewControl_Tools::CreateShape (aBox))); + } MessageModel_ItemBase::Init(); } @@ -221,6 +243,7 @@ void MessageModel_ItemAlert::Reset() myAlert = Handle(Message_Alert)(); myUnitedAlerts.Clear(); myChildAlerts.Clear(); + myPresentations.Clear(); } // ======================================================================= diff --git a/tools/MessageModel/MessageModel_ItemAlert.hxx b/tools/MessageModel/MessageModel_ItemAlert.hxx index f32df889d7..f139fb54c2 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.hxx +++ b/tools/MessageModel/MessageModel_ItemAlert.hxx @@ -29,6 +29,7 @@ #include #include +#include #include class QAbstractTableModel; @@ -84,6 +85,14 @@ public: //! \return instance of the shape const TopoDS_Shape& GetCustomShape() const { return myCustomShape; } + //! 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 + void GetPresentations (NCollection_List& thePresentations) + { thePresentations.Append (myPresentations); } + + //! Returns summ of children alert elapsed times. The method is recusive. //! \param theAlert a message alert //! \return double value @@ -126,6 +135,7 @@ private: NCollection_DataMap myChildAlerts; //!< container of child alerts TopoDS_Shape myCustomShape; + NCollection_List myPresentations; }; #endif diff --git a/tools/MessageView/MessageView_VisibilityState.cxx b/tools/MessageView/MessageView_VisibilityState.cxx index 8b4207b8fb..cec2d932df 100644 --- a/tools/MessageView/MessageView_VisibilityState.cxx +++ b/tools/MessageView/MessageView_VisibilityState.cxx @@ -27,6 +27,15 @@ // ======================================================================= bool MessageView_VisibilityState::CanBeVisible (const QModelIndex& theIndex) const { + MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex); + if (anAlertItem) + { + NCollection_List aPresentations; + anAlertItem->GetPresentations (aPresentations); + if (!aPresentations.IsEmpty()) + return true; + } + return !getShape (theIndex).IsNull();// || hasTableValues (theIndex); } diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index 575ca8445d..ad8895e831 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,39 @@ const int MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500; const int MESSAGEVIEW_DEFAULT_VIEW_WIDTH = 200;// 400; const int MESSAGEVIEW_DEFAULT_VIEW_HEIGHT = 300;// 1000; +#include +#include +Handle(Prs3d_Drawer) GetPreviewAttributes (const Handle(AIS_InteractiveContext)& theContext) +{ + Handle(Prs3d_Drawer) myDrawer = new Prs3d_Drawer(); + myDrawer->Link (theContext->DefaultDrawer()); + + Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1)); + Standard_ShortReal aTransparency = 0.8; + + // point parameters + myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); + + // shading parameters + Graphic3d_MaterialAspect aShadingMaterial; + aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); + aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT); + + myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID); + myDrawer->ShadingAspect()->SetColor (aColor); + myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial); + + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); + myDrawer->SetTransparency (aTransparency); + + // common parameters + myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); + + return myDrawer; +} + // ======================================================================= // function : Constructor // purpose : @@ -326,7 +360,10 @@ void MessageView_Window::Init (NCollection_List& the aTreeModel->EmitLayoutChanged(); if (!aContext.IsNull()) + { + myContext = aContext; myViewWindow->SetContext (View_ContextType_External, aContext); + } if (!aViewCamera.IsNull()) myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera); @@ -393,6 +430,26 @@ void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, cons return; updatePropertyPanelBySelection(); + + NCollection_List aPresentations; + MessageModel_ItemRootPtr aRootItem; + QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); + 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 anAlertItem = itemDynamicCast(anItemBase); + if (!anAlertItem) + continue; + anAlertItem->GetPresentations (aPresentations); + } + updatePreviewPresentation (aPresentations); } // ======================================================================= @@ -655,3 +712,76 @@ void MessageView_Window::updatePropertyPanelBySelection() myPropertyView->Init (aTableValues); } + +// ======================================================================= +// function : updatePreviewPresentation +// purpose : +// ======================================================================= +void MessageView_Window::updatePreviewPresentation (const NCollection_List& thePresentations) +{ + if (myContext.IsNull()) + return; + + Handle(AIS_InteractiveContext) aContext = myContext; + + if (!myPreviewPresentations.IsEmpty()) + { + for (NCollection_List::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next()) + { + Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value()); + if (!aPrs.IsNull()) + aContext->Remove (aPrs, Standard_True); + } + } + myPreviewPresentations.Clear(); + + myPreviewPresentations = thePresentations; + if (myPreviewPresentations.IsEmpty()) + return; + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + for (NCollection_List::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next()) + { + Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value()); + if (!aPrs.IsNull()) + { + aContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + } + else if (!Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull()) + { + Handle(ViewControl_TransientShape) aShapeObject = Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value()); + aBuilder.Add (aCompound, aShapeObject->GetShape()); + } + } + + if (aCompound.IsNull()) + { + if (!aContext.IsNull()) + aContext->Remove (myPreviewPresentation, Standard_True); + myPreviewPresentation = NULL; + return; + + } + else + { + if (myPreviewPresentation.IsNull()) + { + myPreviewPresentation = new AIS_Shape (aCompound); + myPreviewPresentation->SetAttributes (GetPreviewAttributes(myContext)); + //myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); + + //myPreviewPresentation->SetTransformPersistence(thePersistent); + if (!aContext.IsNull()) + aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + } + else + { + Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound); + //myPreviewPresentation->SetTransformPersistence(thePersistent); + if (!aContext.IsNull()) + aContext->Redisplay (myPreviewPresentation, Standard_True); + } + } +} diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx index 31d5b4ce7b..a4ace53694 100644 --- a/tools/MessageView/MessageView_Window.hxx +++ b/tools/MessageView/MessageView_Window.hxx @@ -21,9 +21,12 @@ #include #include - #include +#include +#include +#include + #ifdef _MSC_VER #pragma warning(disable : 4127) // conditional expression is constant #endif @@ -158,6 +161,10 @@ protected: //! Updates property panel content by item selected in tree view. void updatePropertyPanelBySelection(); + //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes + //!< \param theShape container of shapes + void updatePreviewPresentation (const NCollection_List& thePresentations); + private: QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls QDockWidget* myViewDockWidget; //!< view dock widget to hide/show @@ -171,6 +178,10 @@ private: Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container Handle(Message_ReportCallBack) myCallBack; //! < message call back to update content of the view + + Handle(AIS_InteractiveContext) myContext; //! current context + Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object + NCollection_List myPreviewPresentations; }; #endif diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx index 3d3fd45304..5743c1e0d1 100644 --- a/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -66,7 +66,7 @@ void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspecto aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep"); else if (theName.IsEqual ("TKVInspector")) { - aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"); + //aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"); anAdditionalFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep"); } aRecentlyOpenedFiles.append (aFileName.ToCString()); @@ -127,8 +127,8 @@ int main (int argc, char** argv) aPlugins.insert("TKVInspector"); Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True); - aReport->SetLimit(30); - aReport->SetActive (Standard_False); + aReport->SetLimit (100);//30); + aReport->SetActive (Standard_True);//Standard_False); aPlugins.insert("TKMessageView"); anActivatedPluginName = "TKVInspector"; diff --git a/tools/TKTreeModel/EXTERNLIB b/tools/TKTreeModel/EXTERNLIB index 37f0830243..faee5c912f 100644 --- a/tools/TKTreeModel/EXTERNLIB +++ b/tools/TKTreeModel/EXTERNLIB @@ -1,4 +1,5 @@ TKernel TKMath +TKPrim TKTopAlgo CSF_QT \ No newline at end of file diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index 0609ab6810..983606430e 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -87,6 +87,8 @@ VInspector_ItemV3dView.cxx VInspector_ItemV3dView.hxx VInspector_ItemV3dViewer.cxx VInspector_ItemV3dViewer.hxx +VInspector_PreviewParameters.cxx +VInspector_PreviewParameters.hxx VInspector_PropertiesCreator.cxx VInspector_PropertiesCreator.hxx VInspector_PrsOpenGlElement.cxx diff --git a/tools/VInspector/VInspector_ItemBVHTree.cxx b/tools/VInspector/VInspector_ItemBVHTree.cxx index 5a13706816..8bcd7e328e 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.cxx +++ b/tools/VInspector/VInspector_ItemBVHTree.cxx @@ -16,7 +16,14 @@ #include #include +#include #include +#include +#include + +#include +#include +#include // ======================================================================= // function : Constructor @@ -81,24 +88,22 @@ QVariant VInspector_ItemBVHTree::initValue (const int theItemRole) const void VInspector_ItemBVHTree::Init() { - VInspector_ItemSelectMgrSelectableObjectSetPtr aParentItem = itemDynamicCast(Parent()); - - //! Returns child BVH tree of the row - setTree (aParentItem->GetBVHTree (Row(), myName)); + VInspector_ItemSelectMgrSelectableObjectSetPtr anObjectParent = itemDynamicCast(Parent()); + opencascade::handle > aBVHTree; + if (anObjectParent) + { + aBVHTree = anObjectParent->GetBVHTree (Row(), myName); + } + else + { + VInspector_ItemSelectMgrSensitiveEntitySetPtr anEntityParent = itemDynamicCast(Parent()); + if (anEntityParent) + aBVHTree = anEntityParent->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); + setTree (aBVHTree); - //UpdatePresentationShape(); + UpdatePresentationShape(); TreeModel_ItemBase::Init(); // to use getIO() without circling initialization } @@ -128,132 +133,64 @@ void VInspector_ItemBVHTree::initItem() const } // ======================================================================= -// function : GetTableRowCount -// purpose : -// ======================================================================= -int VInspector_ItemBVHTree::GetTableRowCount() const -{ - return 60; -} - -// ======================================================================= -// function : GetTableData +// function : Dump // purpose : // ======================================================================= -QVariant VInspector_ItemBVHTree::GetTableData (const int theRow, const int theColumn, const int theRole) const +Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) 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"); + opencascade::handle > aBVHTree = GetTree(); + if (aBVHTree.IsNull()) + return Standard_False; - // 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; - } + aBVHTree->Dump (OS); + return Standard_True; } // ======================================================================= -// function : SetTableData +// function : createChild // purpose : // ======================================================================= -bool VInspector_ItemBVHTree::SetTableData (const int theRow, const int, const QVariant& theValue) +TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn) { - //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; + return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn); } // ======================================================================= -// function : Dump +// function : buildPresentationShape // purpose : // ======================================================================= -Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const +TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape() { - //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); - //if (aViewerSelector.IsNull()) - // return Standard_False; + opencascade::handle > aBVHTree = myTree; + if (aBVHTree.IsNull()) + return TopoDS_Shape(); + + Standard_SStream OS; + //aBVHTree->DumpNode (Row(), OS); + aBVHTree->Dump (OS); + + Standard_Integer aColumnCount; + NCollection_Vector aValues; + Message::ConvertStream (OS, aColumnCount, aValues); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + for (int aValueId = 0; aValueId < aValues.Size(); ) + { + for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++) + { + if (aColumnId != 1) + continue; - //aViewerSelector->Dump (OS); - return Standard_True; -} + TCollection_AsciiString aValue = aValues.Value (aValueId); + Bnd_Box aBox; + if (!aBox.FromString (aValue)) + continue; -// ======================================================================= -// function : createChild -// purpose : -// ======================================================================= -TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn) -{ - return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn); + TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox); + aBuilder.Add (aCompound, aShape); + } + } + return aCompound; } diff --git a/tools/VInspector/VInspector_ItemBVHTree.hxx b/tools/VInspector/VInspector_ItemBVHTree.hxx index 651145ee2b..a72ca7e2e7 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.hxx +++ b/tools/VInspector/VInspector_ItemBVHTree.hxx @@ -51,12 +51,12 @@ public: 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 + 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; } + //! 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; @@ -70,29 +70,9 @@ protected: //! \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; + //! Build presentation shape + //! \return generated shape of the item parameters + virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE; protected: diff --git a/tools/VInspector/VInspector_ItemBVHTreeNode.cxx b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx index 99a45f590c..061539e303 100644 --- a/tools/VInspector/VInspector_ItemBVHTreeNode.cxx +++ b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx @@ -15,10 +15,13 @@ #include -//#include +#include //#include // -//#include +#include + +#include +#include // ======================================================================= // function : initRowCount @@ -26,10 +29,7 @@ // ======================================================================= int VInspector_ItemBVHTreeNode::initRowCount() const { - if (Column() != 0) - return 0; - - return 2; + return 0; } // ======================================================================= @@ -47,7 +47,7 @@ QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const switch (Column()) { - case 0: return QString ("TreeNode_" + Row()); break; + case 0: return QString ("TreeNode_%1").arg (Row()); break; default: break; } @@ -61,6 +61,7 @@ QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const void VInspector_ItemBVHTreeNode::Init() { + UpdatePresentationShape(); TreeModel_ItemBase::Init(); // to use getIO() without circling initialization } @@ -74,6 +75,18 @@ void VInspector_ItemBVHTreeNode::Reset() VInspector_ItemBase::Reset(); } +// ======================================================================= +// function : GetTree +// purpose : +// ======================================================================= + +opencascade::handle > VInspector_ItemBVHTreeNode::GetTree() const +{ + VInspector_ItemBVHTreePtr anObjectParent = itemDynamicCast(Parent()); + + return anObjectParent->GetTree(); +} + // ======================================================================= // function : initItem // purpose : @@ -90,7 +103,60 @@ void VInspector_ItemBVHTreeNode::initItem() const // function : createChild // purpose : // ======================================================================= -TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int theRow, int theColumn) +TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int, int) { return TreeModel_ItemBasePtr(); } + +// ======================================================================= +// function : buildPresentationShape +// purpose : +// ======================================================================= +TopoDS_Shape VInspector_ItemBVHTreeNode::buildPresentationShape() +{ + opencascade::handle > aBVHTree = GetTree(); + if (aBVHTree.IsNull()) + return TopoDS_Shape(); + + Standard_SStream OS; + aBVHTree->DumpNode (Row(), OS); + + Standard_Integer aColumnCount; + NCollection_Vector aValues; + Message::ConvertStream (OS, aColumnCount, aValues); + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + for (int aValueId = 0; aValueId < aValues.Size(); ) + { + for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++) + { + if (aColumnId != 1) + continue; + + TCollection_AsciiString aValue = aValues.Value (aValueId); + Bnd_Box aBox; + if (!aBox.FromString (aValue)) + continue; + + TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox); + aBuilder.Add (aCompound, aShape); + } + } + return aCompound; +} + +// ======================================================================= +// function : Dump +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemBVHTreeNode::Dump (Standard_OStream& OS) const +{ + opencascade::handle > aBVHTree = GetTree(); + if (aBVHTree.IsNull()) + return Standard_False; + + aBVHTree->DumpNode (Row(), OS); + return Standard_True; +} diff --git a/tools/VInspector/VInspector_ItemBVHTreeNode.hxx b/tools/VInspector/VInspector_ItemBVHTreeNode.hxx index ea09d07833..d5aef7b4b9 100644 --- a/tools/VInspector/VInspector_ItemBVHTreeNode.hxx +++ b/tools/VInspector/VInspector_ItemBVHTreeNode.hxx @@ -51,6 +51,12 @@ public: //! \return object virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; } + //! Returns parent tree, the node information is obtained from the tree by the given index + Standard_EXPORT opencascade::handle > GetTree() const; + + //! 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; @@ -64,6 +70,10 @@ protected: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + //! Build presentation shape + //! \return generated shape of the item parameters + virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE; + protected: //! Creates a child item in the given position. diff --git a/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx b/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx index 312a658c8a..edcde81111 100644 --- a/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx +++ b/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx @@ -215,20 +215,23 @@ QVariant VInspector_ItemSelectBasicsEntityOwner::GetTableData(const int theRow, bool isFirstColumn = theColumn == 0; Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner(); + Handle(SelectMgr_EntityOwner) anEntityOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwner); switch (theRow) { case 0: return isFirstColumn ? QVariant ("Priority") : QVariant (anOwner->Priority()); case 1: return isFirstColumn ? QVariant ("HasLocation") : QVariant (anOwner->HasLocation()); case 2: return isFirstColumn ? QVariant ("Location") : (anOwner->HasLocation() ? QVariant (ViewControl_Tools::ToString (anOwner->Location()).ToCString()) : QVariant()); + case 3: return isFirstColumn ? QVariant ("IsSelected") : QVariant (!anEntityOwner.IsNull() ? anEntityOwner->IsSelected() : ""); default: break; } + Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner); if (aBROwner.IsNull()) return QVariant(); - int aBRepOwnerRow = theRow - 3; + int aBRepOwnerRow = theRow - 4; switch (aBRepOwnerRow) { case 0: return ViewControl_Table::SeparatorData(); diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx index b2f61e37a4..8f2051acb5 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx @@ -139,7 +139,7 @@ opencascade::handle > VInspector_ItemSelectMgrSelecta SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset)theRow; theName = TCollection_AsciiString ("BVH_Tree_") + SelectMgr::BVHSubsetToString (aBVHSubset); - return aSet.BVH (SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent); + return aSet.BVH (aBVHSubset); } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx index e0b538927d..672a946a53 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx @@ -16,7 +16,8 @@ #include #include -#include +#include +#include #include #include @@ -27,11 +28,11 @@ // ======================================================================= int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const { - Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet()); - if (!aSensitiveSet.IsNull()) - return aSensitiveSet->Size(); + //Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet()); + //if (!aSensitiveSet.IsNull()) + // return aSensitiveSet->Size(); - return 2; + return 1; // for BVH_Tree } // ======================================================================= @@ -40,6 +41,9 @@ int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const // ======================================================================= QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (int theItemRole) const { + if (theItemRole == Qt::DisplayRole && theItemRole == Qt::ToolTipRole && Column() == 2) + return ViewControl_Tools::GetPointerInfo (GetSelectableObject(), true).ToCString(); + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); if (aParentValue.isValid()) return aParentValue; @@ -82,7 +86,7 @@ QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (int theItemRole) // ======================================================================= TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn) { - return VInspector_ItemSelect3DSensitiveSetItem::CreateItem (currentItem(), theRow, theColumn); + return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn); } // ======================================================================= @@ -115,6 +119,21 @@ void VInspector_ItemSelectMgrSensitiveEntitySet::Reset() mySelectableObject = NULL; } +// ======================================================================= +// function : GetBVHTree +// purpose : +// ======================================================================= +opencascade::handle > VInspector_ItemSelectMgrSensitiveEntitySet::GetBVHTree (const int theRow, + TCollection_AsciiString& theName) const +{ + Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet(); + + if (anEntitySet.IsNull()) + return NULL; + + return anEntitySet->BVH(); +} + // ======================================================================= // function : initItem // purpose : @@ -123,6 +142,7 @@ void VInspector_ItemSelectMgrSensitiveEntitySet::initItem() const { if (IsInitialized()) return; + const_cast(this)->Init(); } diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx index 85ee1cdc08..305417778b 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx @@ -17,6 +17,7 @@ #define VInspector_ItemSelectMgrSensitiveEntitySet_H #include +#include #include #include #include @@ -59,6 +60,9 @@ public: //! Resets cached values Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + //! 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. diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx index 8c9687f555..bd590e5c41 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -129,23 +129,6 @@ 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 : @@ -156,7 +139,7 @@ Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::Get Standard_Integer anIndex = 0; Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector(); - if (!aViewSelector.IsNull()) + if (aViewSelector.IsNull()) return NULL; for (SelectMgr_MapOfObjectSensitivesIterator anIterator (aViewSelector->GetObjectSensitives()); anIterator.More(); anIterator.Next(), anIndex++) @@ -170,6 +153,23 @@ Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::Get return 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 : GetContainerValue // purpose : diff --git a/tools/VInspector/VInspector_PreviewParameters.cxx b/tools/VInspector/VInspector_PreviewParameters.cxx new file mode 100644 index 0000000000..7b3f80cea3 --- /dev/null +++ b/tools/VInspector/VInspector_PreviewParameters.cxx @@ -0,0 +1,120 @@ +// Created on: 2019-05-03 +// 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 : Constructor +// purpose : +// ======================================================================= +VInspector_PreviewParameters::VInspector_PreviewParameters() +{ + myDrawer = new Prs3d_Drawer(); + + Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1)); + Standard_ShortReal aTransparency = 0.8; + + // point parameters + myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); + + // shading parameters + Graphic3d_MaterialAspect aShadingMaterial; + aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); + aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT); + + myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID); + myDrawer->ShadingAspect()->SetColor (aColor); + myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial); + + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); + myDrawer->SetTransparency (aTransparency); + + // common parameters + myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); +} + +// ======================================================================= +// function : SaveState +// purpose : +// ======================================================================= +void VInspector_PreviewParameters::SaveState (VInspector_PreviewParameters* theParameters, + QMap& theItems, + const QString& thePrefix) +{ + Handle(Prs3d_Drawer) aDrawer = theParameters->GetDrawer(); + + //Quantity_Color aColor = aDrawer->Color(); + //Standard_ShortReal aTransparency = aDrawer->Transparency(); + + //// point parameters + //{ + // Standard_Boolean anOwnPointAspect = aDrawer->HasOwnPointAspect(); + // Standard_SStream OS; + // if (anOwnPointAspect) + // myDrawer->PointAspect()->Dump (OS); + // TCollection_AsciiString aStream (OS.str().c_str()); + // theItems[thePrefix + "has_point_aspect"] = anOwnPointAspect; + // theItems[thePrefix + "point_aspect"] = aStream.ToCString(); + //} + //// shading parameters + //{ + // Standard_Boolean anOwnShadingAspect = aDrawer->HasOwnShadingAspect(); + // Standard_SStream OS; + // if (anOwnShadingAspect) + // myDrawer->ShadingAspect()->Dump (OS); + // TCollection_AsciiString aStream (OS.str().c_str()); + // theItems[thePrefix + "has_shading_aspect"] = anOwnShadingAspect; + // theItems[thePrefix + "shading_aspect"] = aStream.ToCString(); + //} +} + +// ======================================================================= +// function : RestoreState +// purpose : +// ======================================================================= +bool VInspector_PreviewParameters::RestoreState (VInspector_PreviewParameters* theParameters, + const QString& theKey, const QString& theValue, + const QString& thePrefix) +{ + //if (theKey == thePrefix + "has_point_aspect") // point parameters + //{ + // myDrawer->SetOwnPointAspect (theValue.toBool()); + //} + //else if (theKey == thePrefix + "point_aspect") // point parameters + //{ + // Standard_SStream aStream; + // aStream << theValue.ToString().ToStdString(); + // myDrawer->PointAspect()->Init (aStream); + //} + //else if (theKey == thePrefix + "has_shading_aspect") // shading parameters + //{ + // myDrawer->SetOwnShadingAspect (theValue.toBool()); + //} + //else if (theKey == thePrefix + "shading_aspect") // shading parameters + //{ + // Standard_SStream aStream; + // aStream << theValue.ToString().ToStdString(); + // myDrawer->ShadingAspect()->Init (aStream); + //} + //else + // return false; + return true; +} diff --git a/tools/VInspector/VInspector_PreviewParameters.hxx b/tools/VInspector/VInspector_PreviewParameters.hxx new file mode 100644 index 0000000000..e98bea6260 --- /dev/null +++ b/tools/VInspector/VInspector_PreviewParameters.hxx @@ -0,0 +1,68 @@ +// Created on: 2019-05-03 +// 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_PreviewParameters_H +#define VInspector_PreviewParameters_H + +#include +#include + +#include + +#include +#include +#include +#include + +//! \class VInspector_PreviewParameters +//! Container of View tool bar actions +class VInspector_PreviewParameters +{ +public: + + //! Constructor + Standard_EXPORT VInspector_PreviewParameters (); + + //! Destructor + virtual ~VInspector_PreviewParameters() {} + + //! Returns main control + const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; } + + //! Save state of three view in a container in form: key, value. It saves: + //! - visibiblity of columns, + //! - columns width + //! \param theTreeView a view instance + //! \param theItems [out] properties + //! \param thePrefix peference item prefix + Standard_EXPORT static void SaveState (VInspector_PreviewParameters* theParameters, + QMap& theItems, + const QString& thePrefix = QString()); + //! Restore state of three view by a container + //! \param theTreeView a view instance + //! \param theKey property key + //! \param theValue property value + //! \param thePrefix peference item prefix + //! \return boolean value whether the property is applyed to the tree view + Standard_EXPORT static bool RestoreState (VInspector_PreviewParameters* theParameters, + const QString& theKey, const QString& theValue, + const QString& thePrefix = QString()); + +private: + + Handle(Prs3d_Drawer) myDrawer; +}; + +#endif diff --git a/tools/VInspector/VInspector_PropertiesCreator.cxx b/tools/VInspector/VInspector_PropertiesCreator.cxx index eb70a404ee..7d376c977e 100644 --- a/tools/VInspector/VInspector_PropertiesCreator.cxx +++ b/tools/VInspector/VInspector_PropertiesCreator.cxx @@ -27,10 +27,6 @@ IMPLEMENT_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertie // ======================================================================= 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); diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index 7b02cd9532..4ca765d517 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -194,17 +194,17 @@ public: //! \return created shape Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox); - //! Creates box shape - //! \param theBoundingBox box shape parameters - //! \return created shape - Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox); - //! Creates box shape //! \param thePntMin minimum point on the bounding box //! \param thePntMax maximum point on the bounding box //! \return created shape Standard_EXPORT static TopoDS_Shape CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax); + //! Creates box shape + //! \param theBoundingBox box shape parameters + //! \return created shape + Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox); + //! Build string presentation of Graphic3D index buffer //! \param theIndexBuffer index buffer //! \return string presentation diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 7fe674d6a5..f1f2e0a86d 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -19,8 +19,10 @@ #include #include #include +#include +#include +#include #include -#include #include #include @@ -45,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +110,8 @@ const int VINSPECTOR_DEFAULT_VIEW_POSITION_Y = 60; // TINSPECTOR_DEFAULT_POSITIO VInspector_Window::VInspector_Window() : myParent (0), myExportToShapeViewDialog (0), myViewWindow (0) { + myPreviewParameters = new VInspector_PreviewParameters(); + myMainWindow = new QMainWindow (0); QWidget* aCentralWidget = new QWidget (myMainWindow); @@ -249,9 +254,16 @@ void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIte } anItems.clear(); - TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_"); + VInspector_PreviewParameters::SaveState (myPreviewParameters, anItems, "preview_parameters_"); + for (QMap::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++) + theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); + + anItems.clear(); + TreeModel_Tools::SaveState (myTreeView, anItems); for (QMap::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++) + { theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); + } } // ======================================================================= @@ -276,6 +288,9 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(), "history_view_")) continue; + else if (VInspector_PreviewParameters::RestoreState (myPreviewParameters, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(), + "preview_parameters_")) + continue; } } @@ -382,7 +397,7 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode { TreeModel_ItemBasePtr anItem = *anItemIt; VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (!aVItem || aVItem->Row() == 0) + if (!aVItem /*|| aVItem->Row() == 0*/) continue; TopoDS_Shape aShape = aVItem->GetPresentationShape(); @@ -599,11 +614,18 @@ void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theCon return; VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); + bool isFirst = aViewModel->GetContext().IsNull(); + aViewModel->SetContext (theContext); myTreeView->setExpanded (aViewModel->index (0, 0), true); if (!myCallBack.IsNull()) myCallBack->SetContext (theContext); + + myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer()); + + if (isFirst) + onExportToMessageView(); } // ======================================================================= @@ -660,6 +682,20 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition { QMenu* aMenu = new QMenu (GetMainWindow()); aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this)); + aMenu->addSeparator(); + + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (anItemBase) + { + if (itemDynamicCast (anItemBase)) + { + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this)); + aMenu->addSeparator(); + + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Default preview"), SLOT (onDefaultPreview()), GetMainWindow(), this)); + } + } aMenu->addSeparator(); for (int aTypeId = (int)VInspector_DisplayActionType_DisplayId; aTypeId <= (int)VInspector_DisplayActionType_RemoveId; aTypeId++) @@ -824,6 +860,29 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the selectTreeViewItems (aPointers); } +// ======================================================================= +// function : onExportToShapeView +// purpose : +// ======================================================================= +void VInspector_Window::onExportToMessageView() +{ + VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); + if (!aViewModel) + return; + Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext(); + + TCollection_AsciiString aPluginName ("TKMessageView"); + NCollection_List aParameters; + if (myParameters->FindParameters (aPluginName)) + aParameters = myParameters->Parameters (aPluginName); + + QStringList anExportedPointers; + anExportedPointers.append (VInspector_Tools::GetPointerInfo (aContext, true).ToCString()); + aParameters.Append (aContext); + + myParameters->SetParameters (aPluginName, aParameters, false);//myExportToShapeViewDialog->IsAccepted()); +} + // ======================================================================= // function : onExportToShapeView // purpose : @@ -893,6 +952,36 @@ void VInspector_Window::onExportToShapeView() myParameters->SetParameters (aPluginName, aParameters, myExportToShapeViewDialog->IsAccepted()); } +// ======================================================================= +// function : onDefaultPreview +// purpose : +// ======================================================================= +void VInspector_Window::onDefaultPreview() +{ + VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); + if (!aViewModel) + return; + + Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext(); + if (aContext.IsNull()) + return; + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (gp_Pnt(25., 10., 0.))); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt(20., 20., 0.), gp_Pnt(30., 20., 10.))); + //aBuilder.Add (aCompound, BRepBuilderAPI_MakeFace (gp_Pln (gp_Pnt (20., 30., 0.), gp_Dir (1., 0., 0.))).Face()); + aBuilder.Add (aCompound, VInspector_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.))); + + Handle(AIS_Shape) aDefaultPreview = new AIS_Shape (aCompound); + aDefaultPreview->SetAttributes (myPreviewParameters->GetDrawer()); + if (!aContext.IsNull()) + aContext->Display (aDefaultPreview, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + + UpdateTreeModel(); +} + // ======================================================================= // function : onDisplayActionTypeClicked // purpose : @@ -1161,7 +1250,7 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView() aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); aContext->Display (aTrihedron, Standard_True); - myViewWindow = new View_Window (0, aContext); + myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true); myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT); myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y); myViewWindow->show(); @@ -1219,12 +1308,8 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_ListAttributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); - myPreviewPresentation->SetColor (aColor); - myPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost); + myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); myPreviewPresentation->SetTransformPersistence(thePersistent); if (!aContext.IsNull()) @@ -1262,10 +1347,9 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_ListSetAttributes (myPreviewParameters->GetDrawer()); myOpenGlPreviewPresentation->Set (theElements); - myOpenGlPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1)); - myOpenGlPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost); myOpenGlPreviewPresentation->SetTransformPersistence(thePersistent); if (!aContext.IsNull()) aContext->Display (myOpenGlPreviewPresentation, Standard_True); diff --git a/tools/VInspector/VInspector_Window.hxx b/tools/VInspector/VInspector_Window.hxx index b806e92518..0c774f8bb0 100644 --- a/tools/VInspector/VInspector_Window.hxx +++ b/tools/VInspector/VInspector_Window.hxx @@ -35,12 +35,14 @@ class OpenGl_Element; -class VInspector_PrsOpenGlElement; +class VInspector_PreviewParameters; class ViewControl_MessageDialog; class ViewControl_PropertyView; +class VInspector_PrsOpenGlElement; class VInspector_ToolBar; + class View_Window; class QAbstractItemModel; @@ -164,9 +166,15 @@ private slots: //! \param theDeselected a deselected items void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); + //! Exports the selected context into MessageView for have preview in the context. + void onExportToMessageView(); + //! Exports the first selected shape into ShapeViewer plugin. void onExportToShapeView(); + //! Displays default preview presentation + void onDefaultPreview(); + //! Apply activated display action void onDisplayActionTypeClicked(); @@ -259,6 +267,7 @@ private: View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container + VInspector_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object Handle(VInspector_PrsOpenGlElement) myOpenGlPreviewPresentation; //!< presentation of preview for OpenGl elements diff --git a/tools/View/View_Viewer.cxx b/tools/View/View_Viewer.cxx index 03e8abe691..04907e1479 100644 --- a/tools/View/View_Viewer.cxx +++ b/tools/View/View_Viewer.cxx @@ -19,7 +19,7 @@ #include #include -#define USE_CLIPPLANE +//#define USE_CLIPPLANE #ifdef USE_CLIPPLANE #include diff --git a/tools/ViewControl/ViewControl_PropertiesStream.cxx b/tools/ViewControl/ViewControl_PropertiesStream.cxx index c37ee4260e..fd5ac5a3f0 100644 --- a/tools/ViewControl/ViewControl_PropertiesStream.cxx +++ b/tools/ViewControl/ViewControl_PropertiesStream.cxx @@ -35,52 +35,7 @@ void ViewControl_PropertiesStream::Init() 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; + Message::ConvertStream (aSStream, myColumnCount, myValues); } // ======================================================================= diff --git a/tools/ViewControl/ViewControl_PropertiesStream.hxx b/tools/ViewControl/ViewControl_PropertiesStream.hxx index 91730e8617..c1317d4190 100644 --- a/tools/ViewControl/ViewControl_PropertiesStream.hxx +++ b/tools/ViewControl/ViewControl_PropertiesStream.hxx @@ -17,6 +17,7 @@ #define ViewControl_PropertiesStream_H #include +#include #include #include diff --git a/tools/ViewControl/ViewControl_Tools.cxx b/tools/ViewControl/ViewControl_Tools.cxx index 1bcf999a37..273f805a5c 100644 --- a/tools/ViewControl/ViewControl_Tools.cxx +++ b/tools/ViewControl/ViewControl_Tools.cxx @@ -18,6 +18,13 @@ #include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -260,3 +267,105 @@ TCollection_AsciiString ViewControl_Tools::ToString (const TopLoc_Location& theL { return ToString (theLocation.Transformation()); } + +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +TopoDS_Shape ViewControl_Tools::CreateShape (const Bnd_Box& theBoundingBox) +{ + if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole()) + return TopoDS_Shape(); + + Standard_Real aXmin, anYmin, aZmin, aXmax, anYmax, aZmax; + theBoundingBox.Get (aXmin, anYmin, aZmin, aXmax, anYmax, aZmax); + + gp_Pnt aPntMin = gp_Pnt (aXmin, anYmin, aZmin); + gp_Pnt aPntMax = gp_Pnt (aXmax, anYmax, aZmax); + + return CreateBoxShape (aPntMin, aPntMax); +} + +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +TopoDS_Shape ViewControl_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 : CreateBoxShape +//purpose : +//======================================================================= +TopoDS_Shape ViewControl_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax) +{ + Standard_Boolean aThinOnX = fabs (thePntMin.X() - thePntMax.X()) < Precision::Confusion(); + Standard_Boolean aThinOnY = fabs (thePntMin.Y() - thePntMax.Y()) < Precision::Confusion(); + Standard_Boolean aThinOnZ = fabs (thePntMin.Z() - thePntMax.Z()) < Precision::Confusion(); + + if (((int)aThinOnX + (int)aThinOnY + (int)aThinOnZ) > 1) // thin box in several directions is a point + { + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin)); + return aCompound; + } + + if (aThinOnX || aThinOnY || aThinOnZ) + { + gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ; + if (aThinOnX) + { + aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z()); + aPnt2 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z()); + aPnt3 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMax.Z()); + aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z()); + } + else if (aThinOnY) + { + aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z()); + aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z()); + aPnt3 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMax.Z()); + aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z()); + } + else if (aThinOnZ) + { + aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z()); + aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z()); + aPnt3 = gp_Pnt(thePntMax.X(), thePntMax.Y(), thePntMin.Z()); + aPnt4 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z()); + } + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt1, aPnt2)); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt2, aPnt3)); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt3, aPnt4)); + aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt4, aPnt1)); + + return aCompound; + } + else + { + BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax); + return aBoxBuilder.Shape(); + } +} diff --git a/tools/ViewControl/ViewControl_Tools.hxx b/tools/ViewControl/ViewControl_Tools.hxx index 7a9b90a3a4..a701d4df0a 100644 --- a/tools/ViewControl/ViewControl_Tools.hxx +++ b/tools/ViewControl/ViewControl_Tools.hxx @@ -21,11 +21,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include @@ -143,6 +145,22 @@ public: //! \return text value Standard_EXPORT static TCollection_AsciiString ToString (const TopLoc_Location& theLocation); + //! Creates box shape + //! \param theBoundingBox box shape parameters + //! \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 thePntMin minimum point on the bounding box + //! \param thePntMax maximum point on the bounding box + //! \return created shape + Standard_EXPORT static TopoDS_Shape CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax); + }; #endif -- 2.39.5