From 79db594820aeeafeac167908faf19ac9d5f56b10 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 17 Jul 2019 13:54:31 +0300 Subject: [PATCH] 0029451: Information Message Alert to debug an algorithm or object functionality Dump/Init implementation in OCCT object and parsing it in MessageView (VInspector later) --- src/BVH/BVH_Box.hxx | 8 +- src/BVH/BVH_Tree.hxx | 4 +- src/Bnd/Bnd_Box.cxx | 61 ++- src/Bnd/Bnd_Box.hxx | 11 +- src/Bnd/Bnd_OBB.cxx | 83 +++- src/Bnd/Bnd_OBB.hxx | 13 +- src/DRAWEXE/cmake_install.cmake | 54 +++ src/Message/FILES | 4 +- src/Message/Message_Alerts.hxx | 90 ++-- src/Message/Message_AttributeObject.cxx | 5 +- src/Message/Message_AttributeObject.hxx | 7 +- src/Message/Message_AttributeStream.cxx | 47 +++ src/Message/Message_AttributeStream.hxx | 50 +++ .../Message_AttributeVectorOfValues.cxx | 117 ------ .../Message_AttributeVectorOfValues.hxx | 68 --- src/Quantity/Quantity_Color.cxx | 68 +-- src/Quantity/Quantity_Color.hxx | 11 +- src/Quantity/Quantity_ColorRGBA.cxx | 22 + src/Quantity/Quantity_ColorRGBA.hxx | 3 + src/SelectMgr/SelectMgr_ViewerSelector.cxx | 10 +- src/Standard/FILES | 1 + src/Standard/Standard_DumpMask.hxx | 30 ++ src/TCollection/TCollection.cxx | 286 +++++++++++++ src/TCollection/TCollection.hxx | 94 ++++- src/TCollection/TCollection_AsciiString.hxx | 3 +- src/TopLoc/TopLoc_Datum3D.cxx | 19 + src/TopLoc/TopLoc_Datum3D.hxx | 3 + src/TopLoc/TopLoc_ItemLocation.cxx | 28 ++ src/TopLoc/TopLoc_ItemLocation.hxx | 5 + src/TopLoc/TopLoc_Location.cxx | 35 ++ src/TopLoc/TopLoc_Location.hxx | 5 + src/TopoDS/TopoDS_AlertAttribute.cxx | 17 + src/TopoDS/TopoDS_AlertAttribute.hxx | 13 +- src/TopoDS/TopoDS_Shape.cxx | 23 + src/TopoDS/TopoDS_Shape.hxx | 3 + src/XCAFPrs/XCAFPrs_Style.cxx | 30 ++ src/XCAFPrs/XCAFPrs_Style.hxx | 3 + .../XmlDrivers_MessageReportStorage.cxx | 36 +- src/gp/gp.cxx | 38 ++ src/gp/gp.hxx | 23 + src/gp/gp_Mat.cxx | 23 + src/gp/gp_Mat.hxx | 4 + src/gp/gp_Trsf.cxx | 28 ++ src/gp/gp_Trsf.hxx | 5 + src/gp/gp_XY.hxx | 11 - src/gp/gp_XY.lxx | 35 -- src/gp/gp_XYZ.cxx | 59 +++ src/gp/gp_XYZ.hxx | 14 +- src/gp/gp_XYZ.lxx | 47 --- tools/Convert/Convert_Tools.cxx | 126 ++++++ tools/Convert/Convert_Tools.hxx | 63 +++ .../Convert_TransientShape.cxx} | 4 +- .../Convert_TransientShape.hxx} | 16 +- tools/Convert/FILES | 4 + tools/MessageModel/FILES | 8 +- tools/MessageModel/MessageModel_Actions.cxx | 54 ++- tools/MessageModel/MessageModel_Actions.hxx | 7 +- tools/MessageModel/MessageModel_ItemAlert.cxx | 29 +- ...ageModel_ItemPropertiesAttributeStream.cxx | 126 ++++++ ...ageModel_ItemPropertiesAttributeStream.hxx | 100 +++++ ... => MessageModel_ItemPropertiesReport.cxx} | 14 +- ... => MessageModel_ItemPropertiesReport.hxx} | 12 +- .../MessageModel/MessageModel_ItemReport.cxx | 4 +- .../MessageModel_TableModelValues.cxx | 75 ---- .../MessageModel_TableModelValues.hxx | 57 --- tools/MessageModel/MessageModel_Tools.cxx | 57 ++- .../MessageView_VisibilityState.cxx | 4 +- tools/MessageView/MessageView_Window.cxx | 22 +- tools/MessageView/MessageView_Window.hxx | 1 - tools/TInspectorEXE/TInspectorEXE.cxx | 3 +- tools/TKTInspectorAPI/EXTERNLIB | 5 +- tools/TKTInspectorAPI/PACKAGES | 2 + tools/TKView/EXTERNLIB | 1 + tools/TreeModel/TreeModel_ItemBase.cxx | 4 +- tools/TreeModel/TreeModel_ItemProperties.cxx | 53 +++ tools/TreeModel/TreeModel_ItemProperties.hxx | 52 ++- tools/VInspector/FILES | 3 - tools/VInspector/VInspector_ItemBVHTree.cxx | 6 +- .../VInspector/VInspector_ItemBVHTreeNode.cxx | 6 +- .../VInspector_ItemPrs3dPresentation.cxx | 4 +- ...Inspector_ItemSelect3DSensitiveSetItem.cxx | 2 + ...Inspector_ItemSelect3DSensitiveSetItem.hxx | 2 +- ...pector_ItemSelectBasicsSensitiveEntity.cxx | 11 +- tools/VInspector/VInspector_Tools.cxx | 125 +----- tools/VInspector/VInspector_Tools.hxx | 26 +- tools/VInspector/VInspector_Window.cxx | 396 +++++++++++------- tools/VInspector/VInspector_Window.hxx | 22 +- .../VInspectorPaneAIS_Shape.cxx | 3 +- tools/View/FILES | 5 + .../View_DisplayActionType.hxx} | 18 +- tools/View/View_DisplayPreview.cxx | 127 ++++++ tools/View/View_DisplayPreview.hxx | 85 ++++ .../View_PreviewParameters.cxx} | 8 +- .../View_PreviewParameters.hxx} | 16 +- tools/View/View_Widget.cxx | 6 +- tools/ViewControl/FILES | 2 - .../ViewControl_PropertiesStream.cxx | 5 +- tools/ViewControl/ViewControl_Table.cxx | 64 ++- tools/ViewControl/ViewControl_Table.hxx | 14 +- .../ViewControl_TableModelValues.cxx | 6 +- tools/ViewControl/ViewControl_Tools.cxx | 112 +---- tools/ViewControl/ViewControl_Tools.hxx | 16 - 102 files changed, 2500 insertions(+), 1150 deletions(-) create mode 100644 src/DRAWEXE/cmake_install.cmake create mode 100644 src/Message/Message_AttributeStream.cxx create mode 100644 src/Message/Message_AttributeStream.hxx delete mode 100644 src/Message/Message_AttributeVectorOfValues.cxx delete mode 100644 src/Message/Message_AttributeVectorOfValues.hxx create mode 100644 src/Standard/Standard_DumpMask.hxx create mode 100644 tools/Convert/Convert_Tools.cxx create mode 100644 tools/Convert/Convert_Tools.hxx rename tools/{ViewControl/ViewControl_TransientShape.cxx => Convert/Convert_TransientShape.cxx} (84%) rename tools/{ViewControl/ViewControl_TransientShape.hxx => Convert/Convert_TransientShape.hxx} (73%) create mode 100644 tools/Convert/FILES create mode 100644 tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.cxx create mode 100644 tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.hxx rename tools/MessageModel/{MessageModel_ItemReportProperties.cxx => MessageModel_ItemPropertiesReport.cxx} (86%) rename tools/MessageModel/{MessageModel_ItemReportProperties.hxx => MessageModel_ItemPropertiesReport.hxx} (89%) delete mode 100644 tools/MessageModel/MessageModel_TableModelValues.cxx delete mode 100644 tools/MessageModel/MessageModel_TableModelValues.hxx rename tools/{VInspector/VInspector_DisplayActionType.hxx => View/View_DisplayActionType.hxx} (60%) create mode 100644 tools/View/View_DisplayPreview.cxx create mode 100644 tools/View/View_DisplayPreview.hxx rename tools/{VInspector/VInspector_PreviewParameters.cxx => View/View_PreviewParameters.cxx} (93%) rename tools/{VInspector/VInspector_PreviewParameters.hxx => View/View_PreviewParameters.hxx} (82%) diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 6bd67e4fe0..47efa7fdec 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -115,10 +116,9 @@ public: 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())); + OS << "Bnd_Box" << TCollection::DumpSeparator(); + BVH::ToBndBox (CornerMin(), CornerMax()).Dump (OS, Standard_DumpMask_SingleValue); + OS << TCollection::DumpSeparator(); } public: diff --git a/src/BVH/BVH_Tree.hxx b/src/BVH/BVH_Tree.hxx index 9209fbac8b..c17e3817f3 100644 --- a/src/BVH/BVH_Tree.hxx +++ b/src/BVH/BVH_Tree.hxx @@ -211,7 +211,9 @@ public: //! @name methods for accessing serialized tree data DUMP_VALUES (OS, "BVH_TreeNode", 2); DUMP_VALUES (OS, "NodeIndex", theNodeIndex); - DUMP_VALUES (OS, "MinPoint - MaxPoint", BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).ToString()); + OS << "Bnd_Box" << TCollection::DumpSeparator(); + BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).Dump (OS, Standard_DumpMask_SingleValue); + OS << TCollection::DumpSeparator(); DUMP_VALUES (OS, "BegPrimitive", BegPrimitive (theNodeIndex)); DUMP_VALUES (OS, "EndPrimitive", EndPrimitive (theNodeIndex)); diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx index d7e67d141a..cdd9dc9d73 100644 --- a/src/Bnd/Bnd_Box.cxx +++ b/src/Bnd/Bnd_Box.cxx @@ -20,7 +20,10 @@ #include #include #include +#include #include +#include +#include // set the flag to one #define ClearVoidFlag() ( Flags &= ~VoidMask ) @@ -980,39 +983,61 @@ TCollection_AsciiString PointsSeparator() return " - "; } + +const TCollection_AsciiString Bnd_Box_ClassName = "Bnd_Box"; + //======================================================================= -//function : ToString +//function : Dump //purpose : //======================================================================= -TCollection_AsciiString Bnd_Box::ToString() const +void Bnd_Box::Dump (Standard_OStream& OS, const Standard_Integer theMask) const { - return gp_XYZ (Xmin, Ymin, Zmin).ToString() - + PointsSeparator() - + gp_XYZ (Xmax, Ymax, Zmax).ToString(); + DUMP_START_KEY (OS, Bnd_Box_ClassName); + + DUMP_VALUES (OS, "Xmin", Xmin); + DUMP_VALUES (OS, "Ymin", Ymin); + DUMP_VALUES (OS, "Zmin", Zmin); + DUMP_VALUES (OS, "Xmax", Xmax); + DUMP_VALUES (OS, "Ymax", Ymax); + DUMP_VALUES (OS, "Zmax", Zmax); + DUMP_VALUES (OS, "Gap", Gap); + DUMP_VALUES (OS, "Flags", Flags); + + DUMP_STOP_KEY (OS, Bnd_Box_ClassName); } //======================================================================= -//function : FromString +//function : Init //purpose : //======================================================================= -Standard_Boolean Bnd_Box::FromString (const TCollection_AsciiString& theValue) +Standard_Boolean Bnd_Box::Init (const Standard_OStream& OS) { - TCollection_AsciiString aCurrentString = theValue; - Standard_Integer aPosition = aCurrentString.Search (PointsSeparator()); - if (aPosition < 0) - return Standard_False; + NCollection_IndexedDataMap aStreamValues; + Standard_SStream aSStream (OS); + TCollection::Split (aSStream, aStreamValues); + + TCollection_AsciiString anXYZValue; + if (aStreamValues.Size() == 1) + { + TCollection_AsciiString aValueStr = aStreamValues.FindFromIndex (1); + Standard_Integer aPosition = aValueStr.Search (Bnd_Box_ClassName + TCollection::ClassNameSeparator()); + if (aPosition < 1) + return Standard_False; + anXYZValue = aValueStr.Split (aPosition); + } - TCollection_AsciiString aLeftString = aCurrentString; - TCollection_AsciiString aRightString = aLeftString.Split (aPosition - 1); - aCurrentString = aRightString; - aRightString = aCurrentString.Split (PointsSeparator().Length()); + NCollection_Vector aValues; + if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues)) + return Standard_False; - gp_XYZ aMinPoint, aMaxPoint; - if (!aMinPoint.FromString (aLeftString) || !aMaxPoint.FromString (aRightString)) + if (aValues.Size() != 8) return Standard_False; - Update (aMinPoint.X(), aMinPoint.Y(), aMinPoint.Z(), aMaxPoint.X(), aMaxPoint.Y(), aMaxPoint.Z()); + Update (aValues.Value (1), aValues.Value (2), aValues.Value (3), aValues.Value (4), aValues.Value (5), aValues.Value (6)); + Gap = aValues.Value (7); + Flags = (Standard_Integer)aValues.Value (8); + return Standard_True; } diff --git a/src/Bnd/Bnd_Box.hxx b/src/Bnd/Bnd_Box.hxx index fcc9bbf082..30b41958e3 100644 --- a/src/Bnd/Bnd_Box.hxx +++ b/src/Bnd/Bnd_Box.hxx @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -308,13 +309,11 @@ 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; + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) 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); + //! Dumps the content of me on the stream . + Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS); protected: diff --git a/src/Bnd/Bnd_OBB.cxx b/src/Bnd/Bnd_OBB.cxx index a37586bef6..d59b0a058d 100644 --- a/src/Bnd/Bnd_OBB.cxx +++ b/src/Bnd/Bnd_OBB.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include class OBBTool @@ -677,19 +678,79 @@ 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&) +const TCollection_AsciiString Bnd_OBB_ClassName = "Bnd_OBB"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void Bnd_OBB::Dump (Standard_OStream& OS, const Standard_Integer /*theMask*/) const { - return Standard_False; + DUMP_START_KEY (OS, Bnd_OBB_ClassName); + { + Standard_SStream aTmpStream; + myCenter.Dump (aTmpStream); + DUMP_VALUES (OS, "Center", TCollection::ToDumpString (aTmpStream)); + } + { + Standard_SStream aTmpStream; + myAxes[0].Dump (aTmpStream); + DUMP_VALUES (OS, "XAxis", TCollection::ToDumpString (aTmpStream)); + } + { + Standard_SStream aTmpStream; + myAxes[1].Dump (aTmpStream); + DUMP_VALUES (OS, "YAxis", TCollection::ToDumpString (aTmpStream)); + } + { + Standard_SStream aTmpStream; + myAxes[2].Dump (aTmpStream); + DUMP_VALUES (OS, "ZAxis", TCollection::ToDumpString (aTmpStream)); + } + + DUMP_VALUES (OS, "XHSize", XHSize()); + DUMP_VALUES (OS, "YHSize", YHSize()); + DUMP_VALUES (OS, "ZHSize", ZHSize()); + DUMP_VALUES (OS, "IsAABox", myIsAABox); + + DUMP_STOP_KEY (OS, Bnd_OBB_ClassName); } -// ======================================================================= -// function : Dump -// purpose : -// ======================================================================= -void Bnd_OBB::Dump (Standard_OStream&) const +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +Standard_Boolean Bnd_OBB::Init (const Standard_OStream& /*OS*/) { + //NCollection_DataMap aStreamValues; + //Standard_SStream aSStream (OS); + //TCollection::Split (aSStream, aStreamValues); + + //TCollection_AsciiString anXYZValue; + //if (aStreamValues.Size() == 1) + //{ + // NCollection_DataMap::Iterator anIterator (aStreamValues); + // TCollection_AsciiString aValueStr = anIterator.Value(); + // Standard_Integer aPosition = aValueStr.Search (Bnd_Box_ClassName + TCollection::ClassNameSeparator()); + // if (aPosition < 1) + // return Standard_False; + // anXYZValue = aValueStr.Split (aPosition); + //} + + //NCollection_Vector aValues; + //if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues)) + // return Standard_False; + + //if (aValues.Size() != 8) + // return Standard_False; + + //Update (aValues.Value (1), aValues.Value (2), aValues.Value (3), aValues.Value (4), aValues.Value (5), aValues.Value (6)); + //Gap = aValues.Value (7); + //Flags = (Standard_Integer)aValues.Value (8); + + //return Standard_True; + + return Standard_False; } diff --git a/src/Bnd/Bnd_OBB.hxx b/src/Bnd/Bnd_OBB.hxx index 86da8d3bb1..0a3b2212cf 100644 --- a/src/Bnd/Bnd_OBB.hxx +++ b/src/Bnd/Bnd_OBB.hxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -277,6 +278,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 Standard_Integer = Standard_DumpMask_Whole) const; + protected: void ProcessOnePoint(const gp_Pnt& theP) @@ -289,12 +296,6 @@ protected: myCenter = theP.XYZ(); } - //! 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; - private: //! Center of the OBB diff --git a/src/DRAWEXE/cmake_install.cmake b/src/DRAWEXE/cmake_install.cmake new file mode 100644 index 0000000000..0a427f48c2 --- /dev/null +++ b/src/DRAWEXE/cmake_install.cmake @@ -0,0 +1,54 @@ +# Install script for directory: F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/src/DRAWEXE + +# Set the install prefix +if(NOT DEFINED CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "F:/Projects/DMUReviewer/Deps/3rd-parties_2019-06-18_Rina/occt-vc12-64") +endif() +string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + if(BUILD_TYPE) + string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + else() + set(CMAKE_INSTALL_CONFIG_NAME "Release") + endif() + message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +endif() + +# Set the component getting installed. +if(NOT CMAKE_INSTALL_COMPONENT) + if(COMPONENT) + message(STATUS "Install component: \"${COMPONENT}\"") + set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + else() + set(CMAKE_INSTALL_COMPONENT) + endif() +endif() + +# Is this installation the result of a crosscompile? +if(NOT DEFINED CMAKE_CROSSCOMPILING) + set(CMAKE_CROSSCOMPILING "FALSE") +endif() + +if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) + if ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") + set (OCCT_INSTALL_BIN_LETTER "") + elseif ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$") + set (OCCT_INSTALL_BIN_LETTER "i") + elseif ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") + set (OCCT_INSTALL_BIN_LETTER "d") + endif() +endif() + +if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) + if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$") + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bin/DRAWEXE.exe") + elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$") + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bind/DRAWEXE.exe") + elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$") + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bini/DRAWEXE.exe") + endif() +endif() + diff --git a/src/Message/FILES b/src/Message/FILES index e52f824502..9ec78694e2 100755 --- a/src/Message/FILES +++ b/src/Message/FILES @@ -12,8 +12,8 @@ Message_Attribute.cxx Message_Attribute.hxx Message_AttributeObject.cxx Message_AttributeObject.hxx -Message_AttributeVectorOfValues.cxx -Message_AttributeVectorOfValues.hxx +Message_AttributeStream.cxx +Message_AttributeStream.hxx Message_CompositeAlerts.cxx Message_CompositeAlerts.hxx Message_ExecStatus.hxx diff --git a/src/Message/Message_Alerts.hxx b/src/Message/Message_Alerts.hxx index d1789025b2..9f73a1f56c 100644 --- a/src/Message/Message_Alerts.hxx +++ b/src/Message/Message_Alerts.hxx @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -38,65 +38,65 @@ static Handle(Message_Alert) OCCT_Message_Alert; } \ } -#define MESSAGE_INFO_OBJECT(Object, Name, Description, PerfMeter, ParentAlert) \ +#define MESSAGE_INFO_OBJECT(Object, StreamValues, Name, Description, PerfMeter, ParentAlert) \ { \ if (!Message_Report::CurrentReport().IsNull() && \ Message_Report::CurrentReport()->IsActive (Message_Info)) \ { \ OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \ - new Message_AttributeObject (Object, Name, Description), PerfMeter, ParentAlert ); \ + new Message_AttributeObject (Object, StreamValues, Name, Description), PerfMeter, ParentAlert ); \ } \ } -#define MESSAGE_INFO_VALUES(StreamValues, Name, Description, PerfMeter, ParentAlert) \ +#define MESSAGE_INFO_STREAM(StreamValues, Name, Description, PerfMeter, ParentAlert) \ { \ if (!Message_Report::CurrentReport().IsNull() && \ Message_Report::CurrentReport()->IsActive (Message_Info)) \ { \ OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \ - new Message_AttributeVectorOfValues (StreamValues, Name, Description), PerfMeter, ParentAlert ); \ + new Message_AttributeStream (StreamValues, Name, Description), PerfMeter, ParentAlert ); \ } \ } -#define DUMP_VALUE(OS, Value) \ - { \ - OS << Value << Message::DumpSeparator(); \ - } - -#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \ - { \ - OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \ - } - -#define DUMP_VALUES(OS, Value1, Value2) \ - { \ - 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); \ - } +//#define DUMP_VALUE(OS, Value) \ +// { \ +// OS << Value << Message::DumpSeparator(); \ +// } +// +//#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \ +// { \ +// OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \ +// } +// +//#define DUMP_VALUES(OS, Value1, Value2) \ +// { \ +// 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_AttributeObject.cxx b/src/Message/Message_AttributeObject.cxx index 83788cacdb..b31ad97cd0 100644 --- a/src/Message/Message_AttributeObject.cxx +++ b/src/Message/Message_AttributeObject.cxx @@ -15,7 +15,7 @@ #include -IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute) +IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream) //======================================================================= //function : Message_AttributeObject @@ -23,9 +23,10 @@ IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute) //======================================================================= Message_AttributeObject::Message_AttributeObject (const Handle(Standard_Transient)& theObject, + const Standard_SStream& theStream, const TCollection_AsciiString& theName, const TCollection_AsciiString& theDescription) -: Message_Attribute (theName, theDescription) +: Message_AttributeStream (theStream, theName, theDescription) { myObject = theObject; } diff --git a/src/Message/Message_AttributeObject.hxx b/src/Message/Message_AttributeObject.hxx index bbf7afe727..29e45e98ca 100644 --- a/src/Message/Message_AttributeObject.hxx +++ b/src/Message/Message_AttributeObject.hxx @@ -16,15 +16,16 @@ #ifndef _Message_AttributeObject_HeaderFile #define _Message_AttributeObject_HeaderFile -#include +#include #include //! Alert object storing Transient object in its field -class Message_AttributeObject : public Message_Attribute +class Message_AttributeObject : public Message_AttributeStream { public: //! Constructor with string argument Standard_EXPORT Message_AttributeObject (const Handle(Standard_Transient)& theObject, + const Standard_SStream& theStream, const TCollection_AsciiString& theName = TCollection_AsciiString(), const TCollection_AsciiString& theDescription = TCollection_AsciiString()); @@ -36,7 +37,7 @@ public: Handle(Standard_Transient) GetObject() const { return myObject; } // OCCT RTTI - DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute) + DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream) private: Handle(Standard_Transient) myObject; diff --git a/src/Message/Message_AttributeStream.cxx b/src/Message/Message_AttributeStream.cxx new file mode 100644 index 0000000000..0e4ed5f0c0 --- /dev/null +++ b/src/Message/Message_AttributeStream.cxx @@ -0,0 +1,47 @@ +// Created on: 2018-06-10 +// Created by: Natalia Ermolaeva +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute) + +//======================================================================= +//function : SetValues +//purpose : +//======================================================================= +Message_AttributeStream::Message_AttributeStream (const Standard_SStream& theStream, + const TCollection_AsciiString& theName, + const TCollection_AsciiString& theDescription) +: Message_Attribute(theName, theDescription) +{ + SetStream (theStream); +} + +//======================================================================= +//function : SetStream +//purpose : +//======================================================================= + +void Message_AttributeStream::SetStream (const Standard_SStream& theStream) +{ + TCollection_AsciiString aStreamStr (theStream.str().c_str()); + myStream << aStreamStr; +} + diff --git a/src/Message/Message_AttributeStream.hxx b/src/Message/Message_AttributeStream.hxx new file mode 100644 index 0000000000..c0a3218726 --- /dev/null +++ b/src/Message/Message_AttributeStream.hxx @@ -0,0 +1,50 @@ +// Created on: 2018-06-10 +// Created by: Natalia Ermolaeva +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _Message_AttributeStream_HeaderFile +#define _Message_AttributeStream_HeaderFile + +#include +#include + +#include + +class Message_PerfMeter; +class Message_Report; + +//! Alert object storing container of Standard_Real values in its field +class Message_AttributeStream : public Message_Attribute +{ +public: + + //! Constructor with string argument + Standard_EXPORT Message_AttributeStream (const Standard_SStream& theStream, + const TCollection_AsciiString& theName = TCollection_AsciiString(), + const TCollection_AsciiString& theDescription = TCollection_AsciiString()); + + //! Sets stream value + Standard_EXPORT void SetStream (const Standard_SStream& theStream); + + //! Returns stream value + const Standard_SStream& GetStream() const { return myStream; } + + // OCCT RTTI + DEFINE_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute) + +private: + Standard_SStream myStream; //!< container of values +}; + +#endif // _Message_AttributeStream_HeaderFile diff --git a/src/Message/Message_AttributeVectorOfValues.cxx b/src/Message/Message_AttributeVectorOfValues.cxx deleted file mode 100644 index 3d389a1f45..0000000000 --- a/src/Message/Message_AttributeVectorOfValues.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// Created on: 2018-06-10 -// Created by: Natalia Ermolaeva -// Copyright (c) 2017 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeVectorOfValues, Message_Attribute) - -//======================================================================= -//function : SetValues -//purpose : -//======================================================================= -Message_AttributeVectorOfValues::Message_AttributeVectorOfValues (const Standard_SStream& theStream, - const TCollection_AsciiString& theName, - const TCollection_AsciiString& theDescription) -: Message_Attribute(theName, theDescription) -{ - 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 - myValues.Append (aValueString); - - if (aTailString.IsEmpty()) - break; - aCurrentString = aTailString; - aPosition = aCurrentString.Search (aSeparator); - if (aPosition < 0 ) - { - aCurrentString = aTailString; - aTailString = TCollection_AsciiString(); - } - else - aTailString = aCurrentString.Split (aPosition); - } - } - myColumnCount = aColumnCount; -} - -//======================================================================= -//function : SetValues -//purpose : -//======================================================================= - -void Message_AttributeVectorOfValues::SetValues (const NCollection_Vector& theValues) -{ - myValues = theValues; - - int aLength = (Standard_Integer)myValues.Length(); - if (aLength < 2) - return; - - if (myColumnCount <= 0) - myCachedValue = TCollection_AsciiString ("[") + aLength + "] : "; - else - myCachedValue = TCollection_AsciiString ("[") + (aLength / myColumnCount) + ", " + myColumnCount + "] : "; - - myCachedValue += myValues.First(); - myCachedValue += " ... "; - myCachedValue += myValues.Last(); -} - -//======================================================================= -//function : GetDescription -//purpose : -//======================================================================= - -const TCollection_AsciiString& Message_AttributeVectorOfValues::GetDescription() const -{ - if (!Message_Attribute::GetDescription().IsEmpty()) - return Message_Attribute::GetDescription(); - - return myCachedValue; -} - diff --git a/src/Message/Message_AttributeVectorOfValues.hxx b/src/Message/Message_AttributeVectorOfValues.hxx deleted file mode 100644 index 369991da6b..0000000000 --- a/src/Message/Message_AttributeVectorOfValues.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// Created on: 2018-06-10 -// Created by: Natalia Ermolaeva -// Copyright (c) 2017 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Message_AttributeVectorOfValues_HeaderFile -#define _Message_AttributeVectorOfValues_HeaderFile - -#include -#include - -#include - -class Message_PerfMeter; -class Message_Report; - -//! Alert object storing container of Standard_Real values in its field -class Message_AttributeVectorOfValues : public Message_Attribute -{ -public: - - //! Constructor with string argument - Standard_EXPORT Message_AttributeVectorOfValues (const Standard_SStream& theStream, - const TCollection_AsciiString& theName = TCollection_AsciiString(), - const TCollection_AsciiString& theDescription = TCollection_AsciiString()); - - //! Sets the values - //! @param theValues container of values - Standard_EXPORT void SetValues (const NCollection_Vector& theValues); - - //! Returns values - //! @return values - const NCollection_Vector& GetValues() const { return myValues; } - - //! Returns description of alert if it is set - //! @return alert description - virtual const TCollection_AsciiString& GetDescription() const; - - - //! Sets value to present values in a table view - //! \param theValue value of division the values on sub-containers - void SetColumnCount (const Standard_Integer& theValue) { myColumnCount = theValue; } - - //! Gets value to present values in a table view - //! \param theSubSize value of division the values on sub-containers - Standard_Integer GetColumnCount() const { return myColumnCount; } - - // OCCT RTTI - DEFINE_STANDARD_RTTIEXT(Message_AttributeVectorOfValues, Message_Attribute) - -private: - NCollection_Vector myValues; //!< container of values - Standard_Integer myColumnCount; //!< value to present container of values into table - - TCollection_AsciiString myCachedValue; //!< short description of the values in form: [size] : first ... last -}; - -#endif // _Message_AttributeVectorOfValues_HeaderFile diff --git a/src/Quantity/Quantity_Color.cxx b/src/Quantity/Quantity_Color.cxx index 16b70496f5..5ade8c2482 100644 --- a/src/Quantity/Quantity_Color.cxx +++ b/src/Quantity/Quantity_Color.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -3928,40 +3929,59 @@ void call_rgbhls (float r, float g, float b, float& h, float& l, float& s) } } + +const TCollection_AsciiString Quantity_Color_ClassName = "Quantity_Color"; + //======================================================================= -// function : ToString -// purpose : +//function : Dump +//purpose : //======================================================================= -TCollection_AsciiString Quantity_Color::ToString() const -{ - NCollection_Vector aValues; - aValues.Append (MyRed); - aValues.Append (MyGreen); - aValues.Append (MyBlue); - Standard_SStream OS; +void Quantity_Color::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, Quantity_Color_ClassName); - TCollection_AsciiString aValue; - DUMP_VEC_COLOR(aValues, aValue) + DUMP_VALUES (OS, "MyRed", MyRed); + DUMP_VALUES (OS, "MyGreen", MyGreen); + DUMP_VALUES (OS, "MyBlue", MyBlue); - return aValue; + DUMP_STOP_KEY (OS, Quantity_Color_ClassName); } //======================================================================= -// function : FromString -// purpose : +//function : Init +//purpose : //======================================================================= -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); +Standard_Boolean Quantity_Color::Init (const Standard_OStream& OS) +{ + //NCollection_IndexedDataMap aStreamValues; + //Standard_SStream aSStream (OS); + //TCollection::Split (aSStream, aStreamValues); + + //TCollection_AsciiString anXYZValue; + //if (!aStreamValues.FindFromKey (Quantity_Color_ClassName, anXYZValue)) + // anXYZValue = anXYZValue; + //else if (aStreamValues.Size() == 1) + //{ + // NCollection_IndexedDataMap::Iterator anIterator (aStreamValues); + // TCollection_AsciiString aValueStr = anIterator.Value(); + // Standard_Integer aPosition = aValueStr.Search (Quantity_Color_ClassName + TCollection::ClassNameSeparator()); + // if (aPosition < 1) + // return Standard_False; + // anXYZValue = aValueStr.Split (aPosition); + //} + + //NCollection_Vector aValues; + //if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues)) + // return Standard_False; + + //if (aValues.Size() != 3) + // return Standard_False; + + //MyRed = (Standard_ShortReal)aValues.Value (1); + //MyGreen = (Standard_ShortReal)aValues.Value (2); + //MyBlue = (Standard_ShortReal)aValues.Value (3); return Standard_True; } diff --git a/src/Quantity/Quantity_Color.hxx b/src/Quantity/Quantity_Color.hxx index 43de9e0864..f164e5a257 100644 --- a/src/Quantity/Quantity_Color.hxx +++ b/src/Quantity/Quantity_Color.hxx @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -265,13 +266,11 @@ 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; + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) 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); + //! Dumps the content of me on the stream . + Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS); private: diff --git a/src/Quantity/Quantity_ColorRGBA.cxx b/src/Quantity/Quantity_ColorRGBA.cxx index b7ade567a5..ddc623c572 100644 --- a/src/Quantity/Quantity_ColorRGBA.cxx +++ b/src/Quantity/Quantity_ColorRGBA.cxx @@ -16,6 +16,7 @@ #include #include +#include #include @@ -198,3 +199,24 @@ bool Quantity_ColorRGBA::ColorFromHex (const char* const theHexColorString, const ColorInteger aColorComponentBase = isShort ? THE_HEX_COLOR_COMPONENT_SHORT_BASE : THE_HEX_COLOR_COMPONENT_BASE; return convertIntegerToColorRGBA (aHexColorInteger, aColorComponentBase, hasAlphaComponent, theColor); } + +const TCollection_AsciiString Quantity_ColorRGBA_ClassName = "Quantity_ColorRGBA"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void Quantity_ColorRGBA::Dump (Standard_OStream& OS, const Standard_Integer /*theMask*/) const +{ + DUMP_START_KEY (OS, Quantity_ColorRGBA_ClassName); + + DUMP_VALUES (OS, "Alpha", Alpha()); + { + Standard_SStream aTmpStream; + myRgb.Dump (aTmpStream); + DUMP_VALUES (OS, "RGB", TCollection::ToDumpString (aTmpStream)); + } + + DUMP_STOP_KEY (OS, Quantity_ColorRGBA_ClassName); +} diff --git a/src/Quantity/Quantity_ColorRGBA.hxx b/src/Quantity/Quantity_ColorRGBA.hxx index c67cd52489..3dcc33b1cf 100644 --- a/src/Quantity/Quantity_ColorRGBA.hxx +++ b/src/Quantity/Quantity_ColorRGBA.hxx @@ -121,6 +121,9 @@ public: Quantity_ColorRGBA& theColor, const bool theAlphaComponentIsOff = false); + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + private: static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); } diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 8f88db8b5b..cc403b7632 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -219,7 +219,8 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(Select3D_SensitiveEnti { #ifdef REPORT_SELECTION_BUILD Message_PerfMeter aPerfMeter; - MESSAGE_INFO_OBJECT (theEntity, "checkOverlap", "", &aPerfMeter, NULL); + Standard_SStream aStream; + MESSAGE_INFO_OBJECT (theEntity, aStream, "checkOverlap", "", &aPerfMeter, NULL); Handle(Message_Alert) aParentAlert = OCCT_Message_Alert; #endif @@ -397,7 +398,8 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable #ifdef REPORT_SELECTION_BUILD Message_PerfMeter aPerfMeter; - MESSAGE_INFO_OBJECT (theObject, "traverseObject", "", &aPerfMeter, NULL); + Standard_SStream aStream; + MESSAGE_INFO_OBJECT (theObject, aStream, "traverseObject", "", &aPerfMeter, NULL); Handle(Message_Alert) aParentAlert = OCCT_Message_Alert; #endif @@ -616,7 +618,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives() Standard_SStream aStream; Dump (aStream); - MESSAGE_INFO_VALUES (aStream, "Parameters", "", &aPerfMeter, aParentAlert); + MESSAGE_INFO_STREAM (aStream, "Parameters", "", &aPerfMeter, aParentAlert); #endif mystored.Clear(); @@ -770,7 +772,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives() #ifdef REPORT_SELECTION_BUILD Standard_SStream aStreamDone; Dump (aStreamDone); - MESSAGE_INFO_VALUES (aStreamDone, "Parameters", "", &aPerfMeter, aParentAlert); + MESSAGE_INFO_STREAM (aStreamDone, "Parameters", "", &aPerfMeter, aParentAlert); #endif } diff --git a/src/Standard/FILES b/src/Standard/FILES index 1199f5f973..79bcc5a515 100755 --- a/src/Standard/FILES +++ b/src/Standard/FILES @@ -24,6 +24,7 @@ Standard_DimensionError.hxx Standard_DimensionMismatch.hxx Standard_DivideByZero.hxx Standard_DomainError.hxx +Standard_DumpMask.hxx Standard_ErrorHandler.cxx Standard_ErrorHandler.hxx Standard_ExtCharacter.hxx diff --git a/src/Standard/Standard_DumpMask.hxx b/src/Standard/Standard_DumpMask.hxx new file mode 100644 index 0000000000..5fe235580f --- /dev/null +++ b/src/Standard/Standard_DumpMask.hxx @@ -0,0 +1,30 @@ +// 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 _Standard_DumpMask_HeaderFile +#define _Standard_DumpMask_HeaderFile + + +//! Sets how much information should be dumped in Dump of the object +enum Standard_DumpMask +{ + Standard_DumpMask_Empty = 0x0000, //! empty output + Standard_DumpMask_Fields = 0x0001, //! only class fields value + Standard_DumpMask_Methods = 0x0002, //! only methods result + Standard_DumpMask_ClassName = 0x0004, //! the first row of Dump has class name + Standard_DumpMask_SingleValue = 0x0008, //! dump is combined in one value + Standard_DumpMask_Whole = Standard_DumpMask_Fields | Standard_DumpMask_Methods, + Standard_DumpMask_WholeAndClassName = Standard_DumpMask_Whole | Standard_DumpMask_ClassName +}; + +#endif // _Standard_DumpMask_HeaderFile diff --git a/src/TCollection/TCollection.cxx b/src/TCollection/TCollection.cxx index 667b058423..e07f8f7f4b 100644 --- a/src/TCollection/TCollection.cxx +++ b/src/TCollection/TCollection.cxx @@ -17,6 +17,7 @@ #include #include +#include // The array of prime numbers used as consequtive steps for // size of array of buckets in the map. @@ -72,3 +73,288 @@ Standard_Integer TCollection::NextPrimeForMap(const Standard_Integer N) } throw Standard_OutOfRange ("TCollection::NextPrimeForMap() - requested too big size"); } + +// ======================================================================= +// function : GetPointerInfo +// purpose : +// ======================================================================= + +TCollection_AsciiString TCollection::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo) +{ + if (thePointer.IsNull()) + return TCollection_AsciiString(); + + return GetPointerInfo(thePointer.operator->(), isShortInfo); +} + +// ======================================================================= +// function : GetPointerInfo +// purpose : +// ======================================================================= + +TCollection_AsciiString TCollection::GetPointerInfo (const void* thePointer, const bool isShortInfo) +{ + std::ostringstream aPtrStr; + aPtrStr << thePointer; + if (!isShortInfo) + return aPtrStr.str().c_str(); + + TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str()); + for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++) + { + if (anInfoPtr.Value(aSymbolId) != '0') + { + anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length()); + anInfoPtr.Prepend(GetPointerPrefix()); + return anInfoPtr; + } + } + return aPtrStr.str().c_str(); +} + +// ---------------------------------------------------------------------------- +// Join +// ---------------------------------------------------------------------------- + +TCollection_AsciiString TCollection::Join (const NCollection_List& theValues, + const TCollection_AsciiString& theSeparator) +{ + TCollection_AsciiString aValue; + for (NCollection_List::Iterator anIterator (theValues); anIterator.More(); anIterator.Next()) + { + if (!aValue.IsEmpty()) + aValue += theSeparator; + + aValue += anIterator.Value(); + } + + return aValue; +} + +// ---------------------------------------------------------------------------- +// Split +// ---------------------------------------------------------------------------- + +void TCollection::Split (const Standard_SStream& theStream, + NCollection_IndexedDataMap& theValues) +{ + TCollection_AsciiString aStreamStr (theStream.str().c_str()); + + NCollection_List aValues; + Split (aStreamStr, DumpSeparator(), aValues); + + for (NCollection_List::Iterator anIterator (aValues); anIterator.More(); anIterator.Next()) + { + TCollection_AsciiString aKey = anIterator.Value(); + anIterator.Next(); + if (!anIterator.More()) + break; + theValues.Add (aKey, anIterator.Value()); + } +} + + +// ---------------------------------------------------------------------------- +// Split +// ---------------------------------------------------------------------------- + +void TCollection::Split (const TCollection_AsciiString& theValue, + const TCollection_AsciiString& theSeparator, + NCollection_List& theValues) +{ + TCollection_AsciiString aCurrentString = theValue; + + TCollection_AsciiString aSplitValue, aTailValue, aKey; + while (!aCurrentString.IsEmpty()) + { + TCollection_AsciiString aValueString = aCurrentString; + if (SplitDumped (aValueString, aSplitValue, aTailValue, aKey)) + { + aValueString = aSplitValue; + aCurrentString = aTailValue; + } + else + { + Standard_Integer aPosition = aValueString.Search (theSeparator); + if (aPosition < 0 ) + break; + aCurrentString = aValueString.Split (aPosition - 1); + } + theValues.Append (aValueString); + if (aCurrentString.IsEmpty()) + break; + + aCurrentString = aCurrentString.Split (theSeparator.Length()); + } + + if (theValues.Size() == 1) + { + TCollection_AsciiString aKey, aValue; + if (!SplitKey (theValues.First(), aValue, aKey)) + return; + + theValues.Clear(); + Split (aValue, DumpSeparator(), theValues); + } +} + +// ---------------------------------------------------------------------------- +// SplitReal +// ---------------------------------------------------------------------------- + +Standard_Boolean TCollection::SplitReal (const TCollection_AsciiString& theValue, + const TCollection_AsciiString& theSeparator, + NCollection_Vector& theValues) +{ + TCollection_AsciiString aCurrentString = theValue; + + while (!aCurrentString.IsEmpty()) + { + TCollection_AsciiString aValueString = aCurrentString; + Standard_Integer aPosition = aValueString.Search (theSeparator); + if (aPosition < 0 ) + break; + + aCurrentString = aValueString.Split (aPosition); + if (!aValueString.IsRealValue()) + return Standard_False; + + theValues.Append (aValueString.RealValue()); + aCurrentString = aCurrentString.Split (theSeparator.Length() + 1); + } + + return !theValues.IsEmpty(); +} + +// ---------------------------------------------------------------------------- +// ToDumpString +// ---------------------------------------------------------------------------- + +TCollection_AsciiString TCollection::ToDumpString (const NCollection_List& theValues) +{ + return TCollection::Join (theValues, TCollection::VectorSeparator()); +} + +// ---------------------------------------------------------------------------- +// ToString +// ---------------------------------------------------------------------------- + +TCollection_AsciiString TCollection::ToDumpString (const Standard_SStream& theStream) +{ + return TCollection_AsciiString (theStream.str().c_str()); +} + +// ---------------------------------------------------------------------------- +// ConvertDumpToText +// ---------------------------------------------------------------------------- + +TCollection_AsciiString TCollection::ConvertDumpToText (const TCollection_AsciiString& theValue) +{ + TCollection_AsciiString aText = theValue; + + //TCollection_AsciiString aCurrentString = theValue; + //while (!aCurrentString.IsEmpty()) + //{ + // TCollection_AsciiString aValueString = aCurrentString; + // Standard_Integer aPosition = aValueString.Search (theSeparator); + // if (aPosition < 0 ) + // break; + + // aCurrentString = aValueString.Split (aPosition); + // theValues.Append (aValueString); + + // aCurrentString = aCurrentString.Split (theSeparator.Length() + 1); + //} + + //TCollection_AsciiString XMLBracketOpen() { return TCollection_AsciiString ("<"); } + //TCollection_AsciiString XMLBracketClose() { return TCollection_AsciiString (">"); } + //TCollection_AsciiString XMLFinishKey() { return TCollection_AsciiString ("\\"); } + + return aText; +} + +// ---------------------------------------------------------------------------- +// SplitDumped +// ---------------------------------------------------------------------------- + +Standard_Boolean TCollection::SplitDumped (const TCollection_AsciiString& theSourceValue, + TCollection_AsciiString& theSplitValue, + TCollection_AsciiString& theTailValue, + TCollection_AsciiString& theKey) +{ + Standard_Integer aBracketPosition = theSourceValue.Search (XMLBracketOpen()); + // the first symbol is bracket + if (aBracketPosition != 1 || aBracketPosition >= theSourceValue.Length()) + return Standard_False; + + TCollection_AsciiString aValue = theSourceValue.SubString (aBracketPosition + 1, theSourceValue.Length()); + + aBracketPosition = aValue.Search (XMLBracketClose()); + if (aBracketPosition <= 1 || aBracketPosition >= theSourceValue.Length()) + return Standard_False; + + theKey = aValue; + + TCollection_AsciiString aTailValue = theKey.Split (aBracketPosition - 1); + aTailValue = aTailValue.SubString (2, aTailValue.Length()); // remove close bracket + TCollection_AsciiString aStopKey = StopKey (theKey); + + aBracketPosition = theSourceValue.Search (aStopKey); + + Standard_Integer aStopKeyLastPosition = aBracketPosition + aStopKey.Length() - 1; + + //aBracketPosition = aTailValue.Search (aStopKey); + if (aBracketPosition <= 1 || aStopKeyLastPosition > theSourceValue.Length()) + return Standard_False; + + theSplitValue = theSourceValue; + theTailValue = theSplitValue.Split (aStopKeyLastPosition); + //theSplitValue = aTailValue; + //aTailValue = theSplitValue.Split (aBracketPosition - 1); + + //if (aTailValue.Length() < aStopKey.Length()) + // return Standard_False; + + //if (aTailValue.Length() == aStopKey.Length()) + //{ + // theTailValue = TCollection_AsciiString(); + // return Standard_True; + //} + + //theTailValue = aTailValue.Split (aStopKey.Length()); + return Standard_True; +} + +// ---------------------------------------------------------------------------- +// SplitKey +// ---------------------------------------------------------------------------- + +Standard_Boolean TCollection::SplitKey (const TCollection_AsciiString& theSourceValue, + TCollection_AsciiString& theSplitValue, + TCollection_AsciiString& theKey) +{ + Standard_Integer aBracketPosition = theSourceValue.Search (XMLBracketOpen()); + // the first symbol is bracket + if (aBracketPosition != 1 || aBracketPosition >= theSourceValue.Length()) + return Standard_False; + + TCollection_AsciiString aValue = theSourceValue.SubString (aBracketPosition + 1, theSourceValue.Length()); + + aBracketPosition = aValue.Search (XMLBracketClose()); + if (aBracketPosition <= 1 || aBracketPosition >= theSourceValue.Length()) + return Standard_False; + + theKey = aValue; + + TCollection_AsciiString aTailValue = theKey.Split (aBracketPosition - 1); + aTailValue = aTailValue.SubString (2, aTailValue.Length()); // remove close bracket + TCollection_AsciiString aStopKey = StopKey (theKey); + + aBracketPosition = theSourceValue.Search (aStopKey); + if (aBracketPosition <= 1 || aBracketPosition >= theSourceValue.Length()) + return Standard_False; + + theSplitValue = aTailValue; + aTailValue = theSplitValue.Split (aBracketPosition - 1); + return Standard_True; +} diff --git a/src/TCollection/TCollection.hxx b/src/TCollection/TCollection.hxx index 21fc27cd8c..33f57f9852 100644 --- a/src/TCollection/TCollection.hxx +++ b/src/TCollection/TCollection.hxx @@ -22,7 +22,12 @@ #include #include -class TCollection_AsciiString; +#include + +#include +#include +#include + class TCollection_ExtendedString; class TCollection_HAsciiString; class TCollection_HExtendedString; @@ -66,6 +71,23 @@ public: DEFINE_STANDARD_ALLOC + //! Returns default prefix added for each pointer info string + Standard_EXPORT static TCollection_AsciiString GetPointerPrefix() { return "0x"; } + + //! 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 + //! \return the string value + Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer, + const bool isShortInfo = true); + + //! Convert pointer to string value + //! \param thePointer a pointer + //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped + //! \return the string value + Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const void* thePointer, + const bool isShortInfo = true); + //! Returns a prime number greater than suitable //! to dimension a Map. When becomes great there //! is a limit on the result (today the limit is @@ -74,8 +96,69 @@ public: //! there will be more collisions in the map. Standard_EXPORT static Standard_Integer NextPrimeForMap (const Standard_Integer I); + //! Returns separator symbol of Dump information + static Standard_Character DumpSeparator() { return '\\'; } + + //! Returns separator symbol of values vector union + static Standard_CString VectorSeparator() { return " ,"; } + + //! Returns separator symbol of class name prefix + static inline Standard_CString ClassNameSeparator() { return " ,"; } + + //! Unites list of string into one string using the separator + Standard_EXPORT static TCollection_AsciiString Join (const NCollection_List& theValues, + const TCollection_AsciiString& theSeparator); + + //! Converts stream to map of values where the key is each odd, value is each even value + //! \param theStream stream value + //! \param theValues [out] container of split values + Standard_EXPORT static void Split (const Standard_SStream& theStream, + NCollection_IndexedDataMap& theValues); + + //! Unites list of string into one string using the separator + Standard_EXPORT static void Split (const TCollection_AsciiString& theValue, + const TCollection_AsciiString& theSeparator, + NCollection_List& theValues); + + //! Unites list of string into one string using the separator + Standard_EXPORT static Standard_Boolean SplitReal (const TCollection_AsciiString& theValue, + const TCollection_AsciiString& theSeparator, + NCollection_Vector& theValues); + + //! Unites vector to string value using VectorSeparator. + Standard_EXPORT static TCollection_AsciiString ToDumpString (const NCollection_List& theValues); + //! Converts stream value to string value + Standard_EXPORT static TCollection_AsciiString ToDumpString (const Standard_SStream& theStream); + + //! Converts stream value to string value + static TCollection_AsciiString StartKey (const TCollection_AsciiString& theValue) + { return XMLBracketOpen() + theValue + XMLBracketClose(); } + + //! Converts stream value to string value + static TCollection_AsciiString StopKey (const TCollection_AsciiString& theValue) + { return XMLBracketOpen() + XMLFinishKey() + theValue + XMLBracketClose(); } + + Standard_EXPORT static TCollection_AsciiString ConvertDumpToText (const TCollection_AsciiString& theValue); + + //! Splits a AsciiString into two sub-strings using Dump keys. + //! Example: + //! aString contains "abcdefg" + //! aString.SplitDumped() gives = "abc" and returns "defg" + Standard_EXPORT static Standard_Boolean SplitDumped (const TCollection_AsciiString& theSourceValue, + TCollection_AsciiString& theSplitValue, + TCollection_AsciiString& theTailValue, + TCollection_AsciiString& theKey); + + //! Splits value that contains a key in form: value. In this case the values are: + //! theSplitValue = value, theKey = key. + Standard_EXPORT static Standard_Boolean SplitKey (const TCollection_AsciiString& theSourceValue, + TCollection_AsciiString& theSplitValue, + TCollection_AsciiString& theKey); - +protected: + static TCollection_AsciiString XMLBracketOpen() { return TCollection_AsciiString ("<"); } + static TCollection_AsciiString XMLBracketClose() { return TCollection_AsciiString (">"); } + static TCollection_AsciiString XMLFinishKey() { return TCollection_AsciiString ("\\"); } protected: @@ -124,6 +207,13 @@ friend class TCollection_IndexedDataMapNode; }; +#define DUMP_VALUES(OS, Value1, Value2) \ +{ \ + OS << Value1 << TCollection::DumpSeparator() << Value2 << TCollection::DumpSeparator(); \ +} + +#define DUMP_START_KEY(OS, Value1) { OS << TCollection::StartKey (Value1); } +#define DUMP_STOP_KEY(OS, Value1) { OS << TCollection::StopKey (Value1); } diff --git a/src/TCollection/TCollection_AsciiString.hxx b/src/TCollection/TCollection_AsciiString.hxx index 4f7df1a6fe..82db097a70 100644 --- a/src/TCollection/TCollection_AsciiString.hxx +++ b/src/TCollection/TCollection_AsciiString.hxx @@ -17,6 +17,7 @@ #ifndef _TCollection_AsciiString_HeaderFile #define _TCollection_AsciiString_HeaderFile + #include #include #include @@ -624,7 +625,7 @@ friend Standard_EXPORT Standard_IStream& operator >> (Standard_IStream& astream, //! aString contains "abcdefg" //! aString.Split(3) gives = "abc" and returns "defg" Standard_EXPORT TCollection_AsciiString Split (const Standard_Integer where); - + //! Creation of a sub-string of the string . //! The sub-string starts to the index Fromindex and ends //! to the index ToIndex. diff --git a/src/TopLoc/TopLoc_Datum3D.cxx b/src/TopLoc/TopLoc_Datum3D.cxx index 50369d0d39..19ad955b37 100644 --- a/src/TopLoc/TopLoc_Datum3D.cxx +++ b/src/TopLoc/TopLoc_Datum3D.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include IMPLEMENT_STANDARD_RTTIEXT(TopLoc_Datum3D,Standard_Transient) @@ -41,6 +42,24 @@ TopLoc_Datum3D::TopLoc_Datum3D (const gp_Trsf& T) : { } +const TCollection_AsciiString TopLoc_Datum3D_ClassName = "TopLoc_Datum3D"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void TopLoc_Datum3D::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, TopLoc_Datum3D_ClassName); + + Standard_SStream aTmpStream; + myTrsf.Dump (aTmpStream); + DUMP_VALUES (OS, "Transformation", TCollection::ToDumpString (aTmpStream)); + + DUMP_START_KEY (OS, TopLoc_Datum3D_ClassName); +} + //======================================================================= //function : ShallowDump //purpose : diff --git a/src/TopLoc/TopLoc_Datum3D.hxx b/src/TopLoc/TopLoc_Datum3D.hxx index b1f589d201..72830e6ffb 100644 --- a/src/TopLoc/TopLoc_Datum3D.hxx +++ b/src/TopLoc/TopLoc_Datum3D.hxx @@ -53,6 +53,9 @@ public: const gp_Trsf& Transformation() const; + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + //! Writes the contents of this Datum3D to the stream S. Standard_EXPORT void ShallowDump (Standard_OStream& S) const; diff --git a/src/TopLoc/TopLoc_ItemLocation.cxx b/src/TopLoc/TopLoc_ItemLocation.cxx index c994bbd36a..86c35c0f19 100644 --- a/src/TopLoc/TopLoc_ItemLocation.cxx +++ b/src/TopLoc/TopLoc_ItemLocation.cxx @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -32,3 +33,30 @@ TopLoc_ItemLocation::TopLoc_ItemLocation myTrsf (D->Transformation().Powered (P)) { } + +const TCollection_AsciiString TopLoc_ItemLocation_ClassName = "TopLoc_ItemLocation"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void TopLoc_ItemLocation::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, TopLoc_ItemLocation_ClassName); + + DUMP_VALUES (OS, "Power", myPower); + { + Standard_SStream aTmpStream; + myTrsf.Dump (aTmpStream); + DUMP_VALUES (OS, "Trsf", TCollection::ToDumpString (aTmpStream)); + } + { + Standard_SStream aTmpStream; + if (!myDatum.IsNull()) + myDatum->Dump (aTmpStream); + DUMP_VALUES (OS, "Datum", TCollection::ToDumpString (aTmpStream)); + } + + DUMP_STOP_KEY (OS, TopLoc_ItemLocation_ClassName); +} diff --git a/src/TopLoc/TopLoc_ItemLocation.hxx b/src/TopLoc/TopLoc_ItemLocation.hxx index f2e117b390..e40fa8195e 100644 --- a/src/TopLoc/TopLoc_ItemLocation.hxx +++ b/src/TopLoc/TopLoc_ItemLocation.hxx @@ -19,9 +19,11 @@ #include #include +#include #include #include +#include #include class TopLoc_Datum3D; class TopLoc_Location; @@ -49,6 +51,9 @@ public: //! Sets the exponent to

Standard_EXPORT TopLoc_ItemLocation(const Handle(TopLoc_Datum3D)& D, const Standard_Integer P); + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + friend class TopLoc_Location; friend class TopLoc_SListOfItemLocation; diff --git a/src/TopLoc/TopLoc_Location.cxx b/src/TopLoc/TopLoc_Location.cxx index 7dbce0588b..00672c5b4d 100644 --- a/src/TopLoc/TopLoc_Location.cxx +++ b/src/TopLoc/TopLoc_Location.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -230,6 +231,40 @@ Standard_Boolean TopLoc_Location::IsDifferent return !IsEqual(Other); } +const TCollection_AsciiString TopLoc_Location_ClassName = "TopLoc_Location"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void TopLoc_Location::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, TopLoc_Location_ClassName); + + DUMP_VALUES (OS, "IsIdentity", IsIdentity()); + { + Standard_SStream aTmpStream; + Transformation().Dump (aTmpStream); + DUMP_VALUES (OS, "Transformation", TCollection::ToDumpString (aTmpStream)); + } + + TopLoc_SListOfItemLocation items = myItems; + if (!items.IsEmpty()) + { + DUMP_VALUES (OS, "Items", ""); + while (items.More()) + { + Standard_SStream aTmpStream; + items.Value().Dump (aTmpStream); + DUMP_VALUES (OS, "Item", TCollection::ToDumpString (aTmpStream)); + + items.Next(); + } + } + DUMP_STOP_KEY (OS, TopLoc_Location_ClassName); +} + //======================================================================= //function : ShallowDump //purpose : diff --git a/src/TopLoc/TopLoc_Location.hxx b/src/TopLoc/TopLoc_Location.hxx index 0eec93b46b..20cc078348 100644 --- a/src/TopLoc/TopLoc_Location.hxx +++ b/src/TopLoc/TopLoc_Location.hxx @@ -23,8 +23,10 @@ #include #include +#include #include #include + class Standard_NoSuchObject; class Standard_ConstructionError; class gp_Trsf; @@ -142,6 +144,9 @@ Standard_Boolean operator != (const TopLoc_Location& Other) const return IsDifferent(Other); } + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + //! Prints the contents of on the stream . Standard_EXPORT void ShallowDump (Standard_OStream& S) const; diff --git a/src/TopoDS/TopoDS_AlertAttribute.cxx b/src/TopoDS/TopoDS_AlertAttribute.cxx index 2a6f29f22d..c33a1aeaaa 100644 --- a/src/TopoDS/TopoDS_AlertAttribute.cxx +++ b/src/TopoDS/TopoDS_AlertAttribute.cxx @@ -18,3 +18,20 @@ #include IMPLEMENT_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute) + +//======================================================================= +//function : TopoDS_AlertAttribute +//purpose : +//======================================================================= + + +TopoDS_AlertAttribute::TopoDS_AlertAttribute (const TopoDS_Shape& theShape, + const TCollection_AsciiString& theName, + const TCollection_AsciiString& theDescription) +: Message_AttributeStream (Standard_SStream(), theName, theDescription), myShape (theShape) +{ + Standard_SStream aStream; + theShape.Dump (aStream); + + SetStream (aStream); +} diff --git a/src/TopoDS/TopoDS_AlertAttribute.hxx b/src/TopoDS/TopoDS_AlertAttribute.hxx index f0708407cd..ea347944e7 100644 --- a/src/TopoDS/TopoDS_AlertAttribute.hxx +++ b/src/TopoDS/TopoDS_AlertAttribute.hxx @@ -16,24 +16,23 @@ #ifndef _TopoDS_AlertAttribute_HeaderFile #define _TopoDS_AlertAttribute_HeaderFile -#include +#include #include //! Alert attributre object storing TopoDS shape in its field -class TopoDS_AlertAttribute : public Message_Attribute +class TopoDS_AlertAttribute : public Message_AttributeStream { public: //! Constructor with shape argument - TopoDS_AlertAttribute (const TopoDS_Shape& theShape, - const TCollection_AsciiString& theName = TCollection_AsciiString(), - const TCollection_AsciiString& theDescription = TCollection_AsciiString()) - : Message_Attribute (theName, theDescription), myShape (theShape) {} + Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape, + const TCollection_AsciiString& theName = TCollection_AsciiString(), + const TCollection_AsciiString& theDescription = TCollection_AsciiString()); //! Returns contained shape const TopoDS_Shape& GetShape() const { return myShape; } // OCCT RTTI - DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute) + DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream) private: TopoDS_Shape myShape; diff --git a/src/TopoDS/TopoDS_Shape.cxx b/src/TopoDS/TopoDS_Shape.cxx index 513703947c..b586afb525 100644 --- a/src/TopoDS/TopoDS_Shape.cxx +++ b/src/TopoDS/TopoDS_Shape.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -33,3 +34,25 @@ Standard_Integer TopoDS_Shape::HashCode (const Standard_Integer theUpperBound) c const Standard_Integer aHL = myLocation.HashCode (theUpperBound); return ::HashCode (aHS ^ aHL, theUpperBound); } + +const TCollection_AsciiString TopoDS_Shape_ClassName = "TopoDS_Shape"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void TopoDS_Shape::Dump (Standard_OStream& OS, const Standard_Integer /*theMask*/) const +{ + DUMP_START_KEY (OS, TopoDS_Shape_ClassName); + + DUMP_VALUES (OS, "TShape", TCollection::GetPointerInfo (myTShape)); + DUMP_VALUES (OS, "Orientation", TopAbs::ShapeOrientationToString (myOrient)); + { + Standard_SStream aTmpStream; + myLocation.Dump (aTmpStream); + DUMP_VALUES (OS, "Location", TCollection::ToDumpString (aTmpStream)); + } + + DUMP_STOP_KEY (OS, TopoDS_Shape_ClassName); +} diff --git a/src/TopoDS/TopoDS_Shape.hxx b/src/TopoDS/TopoDS_Shape.hxx index ea05cb600f..d3173651af 100644 --- a/src/TopoDS/TopoDS_Shape.hxx +++ b/src/TopoDS/TopoDS_Shape.hxx @@ -280,6 +280,9 @@ public: void TShape (const Handle(TopoDS_TShape)& theTShape) { myTShape = theTShape; } + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + private: Handle(TopoDS_TShape) myTShape; diff --git a/src/XCAFPrs/XCAFPrs_Style.cxx b/src/XCAFPrs/XCAFPrs_Style.cxx index 0a0c52f933..e643a81429 100644 --- a/src/XCAFPrs/XCAFPrs_Style.cxx +++ b/src/XCAFPrs/XCAFPrs_Style.cxx @@ -15,6 +15,8 @@ #include +#include + //======================================================================= //function : XCAFPrs_Style //purpose : @@ -67,3 +69,31 @@ void XCAFPrs_Style::UnSetColorCurv() myHasColorCurv = Standard_False; myColorCurv.SetValues (Quantity_NOC_YELLOW); } + +const TCollection_AsciiString XCAFPrs_Style_ClassName = "XCAFPrs_Style"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void XCAFPrs_Style::Dump (Standard_OStream& OS) const +{ + DUMP_START_KEY (OS, XCAFPrs_Style_ClassName); + + DUMP_VALUES (OS, "HasColorSurf", myHasColorSurf); + { + Standard_SStream aTmpStream; + myColorSurf.Dump (aTmpStream); + DUMP_VALUES (OS, "ColorSurf", TCollection::ToDumpString (aTmpStream)); + } + DUMP_VALUES (OS, "HasColorCurv", myHasColorCurv); + { + Standard_SStream aTmpStream; + myColorCurv.Dump (aTmpStream); + DUMP_VALUES (OS, "ColorCurv", TCollection::ToDumpString (aTmpStream)); + } + DUMP_VALUES (OS, "IsVisible", myIsVisible); + + DUMP_STOP_KEY (OS, XCAFPrs_Style_ClassName); +} diff --git a/src/XCAFPrs/XCAFPrs_Style.hxx b/src/XCAFPrs/XCAFPrs_Style.hxx index 214a0bdcfa..79a82cc655 100644 --- a/src/XCAFPrs/XCAFPrs_Style.hxx +++ b/src/XCAFPrs/XCAFPrs_Style.hxx @@ -121,6 +121,9 @@ public: return theS1.IsEqual (theS2); } + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS) const; + protected: Quantity_ColorRGBA myColorSurf; diff --git a/src/XmlDrivers/XmlDrivers_MessageReportStorage.cxx b/src/XmlDrivers/XmlDrivers_MessageReportStorage.cxx index 6ee08d2cbb..4bb6d0108b 100644 --- a/src/XmlDrivers/XmlDrivers_MessageReportStorage.cxx +++ b/src/XmlDrivers/XmlDrivers_MessageReportStorage.cxx @@ -17,10 +17,11 @@ #include #include -#include +#include #include #include +#include #include #include #include @@ -249,18 +250,22 @@ void XmlDrivers_MessageReportStorage::exportAlertParameters (const Handle(Messag TDataStd_Comment::Set (theAlertLabel, anAttribute->GetDescription()); Standard_CString aDynamicTypeName = anAttribute->DynamicType()->Name(); - if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeVectorOfValues)->Name()) + if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name()) { - Handle(Message_AttributeVectorOfValues) aValuesArrayAlert = Handle(Message_AttributeVectorOfValues)::DownCast (anAttribute); + Handle(Message_AttributeStream) aValuesArrayAlert = Handle(Message_AttributeStream)::DownCast (anAttribute); // store values - const NCollection_Vector& anArrayValues = aValuesArrayAlert->GetValues(); - // create real list attribute only if there are values in the attribute - if (anArrayValues.IsEmpty()) + NCollection_IndexedDataMap aValues; + TCollection::Split (aValuesArrayAlert->GetStream(), aValues); + if (aValues.IsEmpty()) return; - int anArraySize = anArrayValues.Length(); + int anArraySize = 2 * aValues.Size(); Handle(TDataStd_ExtStringArray) aListAttribute = TDataStd_ExtStringArray::Set (theAlertLabel, 0, anArraySize - 1); for (int aValueId = 0; aValueId < anArraySize; aValueId++) - aListAttribute->SetValue (aValueId, anArrayValues.Value (aValueId)); + { + TCollection_AsciiString aKey = aValues.FindKey (aValueId); + aListAttribute->SetValue (aValueId * 2, aKey); + aListAttribute->SetValue (aValueId * 2 + 1, aValues.FindFromKey (aKey)); + } } } @@ -291,7 +296,7 @@ Handle(Message_Alert) XmlDrivers_MessageReportStorage::importAlertParameters (co Handle(Message_Attribute) aMessageAttribute; if (aDynamicTypeName == STANDARD_TYPE (Message_Attribute)->Name()) aMessageAttribute = new Message_Attribute(); - else if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeVectorOfValues)->Name()) + else if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name()) { // values NCollection_Vector anArrayValues; @@ -302,12 +307,15 @@ Handle(Message_Alert) XmlDrivers_MessageReportStorage::importAlertParameters (co if (aValuesAttribute.IsNull()) return Handle(Message_Alert)(); - for (int aValueId = aValuesAttribute->Lower(); aValueId <= aValuesAttribute->Upper(); aValueId++) - anArrayValues.Append (aValuesAttribute->Value (aValueId)); - Standard_SStream aStream; - Handle(Message_AttributeVectorOfValues) anAlert = new Message_AttributeVectorOfValues (aStream); - anAlert->SetValues (anArrayValues); + for (int aValueId = aValuesAttribute->Lower(); aValueId <= aValuesAttribute->Upper(); aValueId++) + { + TCollection_AsciiString aKey = aValuesAttribute->Value (aValueId++); + if (aValueId > aValuesAttribute->Upper()) + break; + DUMP_VALUES (aStream, aKey, aValuesAttribute->Value (aValueId)); + } + Handle(Message_AttributeStream) anAlert = new Message_AttributeStream (aStream); aMessageAttribute = anAlert; } diff --git a/src/gp/gp.cxx b/src/gp/gp.cxx index e269c3bda7..c790860539 100644 --- a/src/gp/gp.cxx +++ b/src/gp/gp.cxx @@ -22,6 +22,15 @@ #include #include +namespace +{ + static Standard_CString gp_Table_PrintTrsfForm[9] = + { + "IDENTITY", "ROTATION", "TRANSLATION", "PNTMIRROR", "AX1MIRROR", "AX2MIRROR", + "SCALE", "COMPOUNDSTRSF", "OTHER2" + }; +} + //======================================================================= //function : Origin //purpose : @@ -186,3 +195,32 @@ const gp_Ax2d& gp::OY2d() return gp_OY2d; } +//======================================================================= +//function : TypeOfTrsfFormToString +//purpose : +//======================================================================= +Standard_CString gp::TrsfFormToString (gp_TrsfForm theType) +{ + return gp_Table_PrintTrsfForm[theType]; +} + +//======================================================================= +//function : TrsfFormFromString +//purpose : +//======================================================================= +Standard_Boolean gp::TrsfFormFromString (Standard_CString theTypeString, + gp_TrsfForm& theType) +{ + TCollection_AsciiString aName (theTypeString); + aName.UpperCase(); + for (Standard_Integer aTypeIter = gp_Identity; aTypeIter <= gp_Other; ++aTypeIter) + { + Standard_CString aTypeName = gp_Table_PrintTrsfForm[aTypeIter]; + if (aName == aTypeName) + { + theType = gp_TrsfForm (aTypeIter); + return Standard_True; + } + } + return Standard_False; +} diff --git a/src/gp/gp.hxx b/src/gp/gp.hxx index f6914eb82f..4b8bc4e4ea 100644 --- a/src/gp/gp.hxx +++ b/src/gp/gp.hxx @@ -17,6 +17,8 @@ #ifndef _gp_HeaderFile #define _gp_HeaderFile +#include + #include #include #include @@ -151,6 +153,27 @@ public: Standard_EXPORT static const gp_Ax2d& OY2d(); + //! Returns the string name for a given type. + //! @param theType an enumeration type + //! @return string identifier from the enumeration list + Standard_EXPORT static Standard_CString TrsfFormToString (gp_TrsfForm theType); + + //! Returns the orientation type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @return enumeration type or gp_Identity if string identifier is invalid + static gp_TrsfForm TrsfFormFromString (Standard_CString theTypeString) + { + gp_TrsfForm aType = gp_Identity; + TrsfFormFromString (theTypeString, aType); + return aType; + } + + //! Determines the type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @param theType detected type + //! @return TRUE if string identifier is known + Standard_EXPORT static Standard_Boolean TrsfFormFromString (const Standard_CString theTypeString, + gp_TrsfForm& theType); protected: diff --git a/src/gp/gp_Mat.cxx b/src/gp/gp_Mat.cxx index cb106686fc..fd2d13dd30 100644 --- a/src/gp/gp_Mat.cxx +++ b/src/gp/gp_Mat.cxx @@ -24,8 +24,11 @@ #include #include #include +#include #include #include +#include +#include #define M00 ((Standard_Real*)M)[0] #define M01 ((Standard_Real*)M)[1] @@ -268,3 +271,23 @@ void gp_Mat::Power (const Standard_Integer N) } } +const TCollection_AsciiString gp_Map_ClassName = "gp_Mat"; + +void gp_Mat::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, gp_Map_ClassName); + + DUMP_VALUES (OS, "Mat00", Mat00); + DUMP_VALUES (OS, "Mat01", Mat01); + DUMP_VALUES (OS, "Mat02", Mat02); + + DUMP_VALUES (OS, "Mat10", Mat10); + DUMP_VALUES (OS, "Mat11", Mat11); + DUMP_VALUES (OS, "Mat12", Mat12); + + DUMP_VALUES (OS, "Mat20", Mat20); + DUMP_VALUES (OS, "Mat21", Mat21); + DUMP_VALUES (OS, "Mat22", Mat22); + + DUMP_STOP_KEY (OS, gp_Map_ClassName); +} diff --git a/src/gp/gp_Mat.hxx b/src/gp/gp_Mat.hxx index 16fc2f2144..4a0e36a01e 100644 --- a/src/gp/gp_Mat.hxx +++ b/src/gp/gp_Mat.hxx @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -255,6 +256,9 @@ public: //! Transposes the matrix. A(j, i) -> A (i, j) Standard_NODISCARD gp_Mat Transposed() const; + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + friend class gp_XYZ; friend class gp_Trsf; diff --git a/src/gp/gp_Trsf.cxx b/src/gp/gp_Trsf.cxx index 6401493575..98a83731fd 100644 --- a/src/gp/gp_Trsf.cxx +++ b/src/gp/gp_Trsf.cxx @@ -34,6 +34,7 @@ #include #include #include +#include //======================================================================= //function : gp_Trsf @@ -849,3 +850,30 @@ void gp_Trsf::Orthogonalize() matrix = aTM; } + +const TCollection_AsciiString gp_Trsf_ClassName = "gp_Trsf"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void gp_Trsf::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, gp_Trsf_ClassName); + + DUMP_VALUES (OS, "Form", gp::TrsfFormToString (Form())); + { + Standard_SStream aTmpStream; + loc.Dump (aTmpStream); + DUMP_VALUES (OS, "TranslationPart", TCollection::ToDumpString (aTmpStream)); + } + DUMP_VALUES (OS, "ScaleFactor", ScaleFactor()); + { + Standard_SStream aTmpStream; + matrix.Dump (aTmpStream); + DUMP_VALUES (OS, "HVectorialPart", TCollection::ToDumpString (aTmpStream)); + } + + DUMP_STOP_KEY (OS, gp_Trsf_ClassName); +} diff --git a/src/gp/gp_Trsf.hxx b/src/gp/gp_Trsf.hxx index ebb05bfbd3..443eded074 100644 --- a/src/gp/gp_Trsf.hxx +++ b/src/gp/gp_Trsf.hxx @@ -22,8 +22,10 @@ #include #include #include +#include #include #include +#include #include class Standard_ConstructionError; @@ -349,6 +351,9 @@ void operator *= (const gp_Trsf& T) theMat.SetValue (3, 3, static_cast (1)); } + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) const; + friend class gp_GTrsf; protected: diff --git a/src/gp/gp_XY.hxx b/src/gp/gp_XY.hxx index ce9273a697..170374d4be 100644 --- a/src/gp/gp_XY.hxx +++ b/src/gp/gp_XY.hxx @@ -273,17 +273,6 @@ public: - //! Covers point into string in format: (X, Y) - //! \return the string value - Standard_EXPORT TCollection_AsciiString ToString() const; - - - //! Converts text value into parameters if possible, the string format is: (X, Y) - //! \return true if conversion is done - Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue); - - - protected: diff --git a/src/gp/gp_XY.lxx b/src/gp/gp_XY.lxx index 12fc78c19e..940b5b2af7 100644 --- a/src/gp/gp_XY.lxx +++ b/src/gp/gp_XY.lxx @@ -226,38 +226,3 @@ inline gp_XY operator* (const Standard_Real Scalar, const gp_XY& Coord1) { return Coord1.Multiplied(Scalar); } - -inline TCollection_AsciiString gp_XY::ToString() const -{ - return TCollection_AsciiString ("(") + x + ", " + y + ")"; -} - -inline Standard_Boolean gp_XY::FromString (const TCollection_AsciiString& theValue) -{ - TCollection_AsciiString aCurrentString = theValue, aValueString; - - Standard_Integer aPosition = aCurrentString.Search ("("); - if (aPosition != 1) - return Standard_False; - - aCurrentString = aCurrentString.Split (aPosition); - Standard_Real aX, anY; - // x value - aPosition = aCurrentString.Search (", "); - if (aPosition < 0) - return Standard_False; - aCurrentString = aValueString.Split (aPosition); - aX = aValueString.RealValue(); - aCurrentString = aCurrentString.Split (2); - - // y value - aPosition = aCurrentString.Search (")"); - if (aPosition < 0) - return Standard_False; - aCurrentString = aValueString.Split (aPosition); - anY = aValueString.RealValue(); - - x = aX; - y = anY; - return Standard_True; -} diff --git a/src/gp/gp_XYZ.cxx b/src/gp/gp_XYZ.cxx index 7bf550dcec..c6ea78353b 100644 --- a/src/gp/gp_XYZ.cxx +++ b/src/gp/gp_XYZ.cxx @@ -15,8 +15,13 @@ #include #include +#include #include #include +#include +#include + +#include Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other, const Standard_Real Tolerance) const { @@ -33,3 +38,57 @@ Standard_Boolean gp_XYZ::IsEqual (const gp_XYZ& Other, return Standard_True; } +const TCollection_AsciiString gp_XYZ_ClassName = "gp_XYZ"; + +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + +void gp_XYZ::Dump (Standard_OStream& OS, const Standard_Integer theMask) const +{ + DUMP_START_KEY (OS, gp_XYZ_ClassName); + + DUMP_VALUES (OS, "X", x); + DUMP_VALUES (OS, "Y", y); + DUMP_VALUES (OS, "Z", z); + + DUMP_STOP_KEY (OS, gp_XYZ_ClassName); +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +Standard_Boolean gp_XYZ::Init (const Standard_OStream& OS) +{ + /*NCollection_IndexedDataMap aStreamValues; + Standard_SStream aSStream (OS); + TCollection::Split (aSStream, aStreamValues); + + TCollection_AsciiString anXYZValue; + if (aStreamValues.FindFromKey (gp_XYZ_ClassName, anXYZValue)) + anXYZValue = anXYZValue; + else if (aStreamValues.Size() == 1) + { + TCollection_AsciiString aValueStr = aStreamValues.FindFromIndex (1); + Standard_Integer aPosition = aValueStr.Search (gp_XYZ_ClassName + TCollection::ClassNameSeparator()); + if (aPosition < 1) + return Standard_False; + anXYZValue = aValueStr.Split (aPosition); + } + + NCollection_Vector aValues; + if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues)) + return Standard_False; + + if (aValues.Size() != 3) + return Standard_False; + + x = aValues.Value (1); + y = aValues.Value (2); + z = aValues.Value (3); + */ + return Standard_True; +} diff --git a/src/gp/gp_XYZ.hxx b/src/gp/gp_XYZ.hxx index f551afd25e..b18e51cc40 100644 --- a/src/gp/gp_XYZ.hxx +++ b/src/gp/gp_XYZ.hxx @@ -23,7 +23,8 @@ #include #include -#include +#include +#include class Standard_ConstructionError; class Standard_OutOfRange; @@ -327,14 +328,11 @@ public: void SetLinearForm (const gp_XYZ& XYZ1, const gp_XYZ& XYZ2); - //! Covers point into string in format: (X, Y, Z) - //! \return the string value - Standard_EXPORT TCollection_AsciiString ToString() const; + //! Dumps the content of me on the stream . + Standard_EXPORT void Dump (Standard_OStream& OS, const Standard_Integer theMask = Standard_DumpMask_Whole) 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); + //! Dumps the content of me on the stream . + Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS); diff --git a/src/gp/gp_XYZ.lxx b/src/gp/gp_XYZ.lxx index e56f801ab2..5ba1431798 100644 --- a/src/gp/gp_XYZ.lxx +++ b/src/gp/gp_XYZ.lxx @@ -306,50 +306,3 @@ inline gp_XYZ operator* (const Standard_Real Scalar, const gp_XYZ& Coord1) { return Coord1.Multiplied (Scalar); } -inline TCollection_AsciiString gp_XYZ::ToString() const -{ - return TCollection_AsciiString ("(") + x + ", " + y + ", " + z + ")"; -} - -inline Standard_Boolean gp_XYZ::FromString (const TCollection_AsciiString& theValue) -{ - TCollection_AsciiString aCurrentString = theValue, aValueString; - - Standard_Integer aPosition = aCurrentString.Search ("("); - if (aPosition != 1) - return Standard_False; - - aCurrentString = aCurrentString.Split (aPosition); - Standard_Real aX, anY, aZ; - // x value - aPosition = aCurrentString.Search (", "); - if (aPosition < 0) - return Standard_False; - aValueString = aCurrentString; - aCurrentString = aValueString.Split (aPosition - 1); - aX = aValueString.RealValue(); - aCurrentString = aCurrentString.Split (2); - - // y value - aPosition = aCurrentString.Search (", "); - if (aPosition < 0) - return Standard_False; - aValueString = aCurrentString; - aCurrentString = aValueString.Split (aPosition - 1); - anY = aValueString.RealValue(); - aCurrentString = aCurrentString.Split (2); - - // z value - aPosition = aCurrentString.Search (")"); - if (aPosition < 0) - return Standard_False; - aValueString = aCurrentString; - aCurrentString = aValueString.Split (aPosition); - aZ = aValueString.RealValue(); - - x = aX; - y = anY; - z = aZ; - return Standard_True; -} - diff --git a/tools/Convert/Convert_Tools.cxx b/tools/Convert/Convert_Tools.cxx new file mode 100644 index 0000000000..178fdab180 --- /dev/null +++ b/tools/Convert/Convert_Tools.cxx @@ -0,0 +1,126 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +TopoDS_Shape Convert_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 Convert_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 Convert_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/Convert/Convert_Tools.hxx b/tools/Convert/Convert_Tools.hxx new file mode 100644 index 0000000000..146036c312 --- /dev/null +++ b/tools/Convert/Convert_Tools.hxx @@ -0,0 +1,63 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef Convert_Tools_H +#define Convert_Tools_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class Geom_Transformation; + +//! \class Convert_Tools +//! \brief The tool that gives auxiliary methods for qt elements manipulation +class Convert_Tools +{ +public: + //! 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 diff --git a/tools/ViewControl/ViewControl_TransientShape.cxx b/tools/Convert/Convert_TransientShape.cxx similarity index 84% rename from tools/ViewControl/ViewControl_TransientShape.cxx rename to tools/Convert/Convert_TransientShape.cxx index fc537b0d81..88b41fad41 100644 --- a/tools/ViewControl/ViewControl_TransientShape.cxx +++ b/tools/Convert/Convert_TransientShape.cxx @@ -13,6 +13,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include -IMPLEMENT_STANDARD_RTTIEXT(ViewControl_TransientShape, Standard_Transient) +IMPLEMENT_STANDARD_RTTIEXT(Convert_TransientShape, Standard_Transient) diff --git a/tools/ViewControl/ViewControl_TransientShape.hxx b/tools/Convert/Convert_TransientShape.hxx similarity index 73% rename from tools/ViewControl/ViewControl_TransientShape.hxx rename to tools/Convert/Convert_TransientShape.hxx index 5b28f7cc99..b9aaae1d7d 100644 --- a/tools/ViewControl/ViewControl_TransientShape.hxx +++ b/tools/Convert/Convert_TransientShape.hxx @@ -13,8 +13,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef ViewControl_TransientShape_H -#define ViewControl_TransientShape_H +#ifndef Convert_TransientShape_H +#define Convert_TransientShape_H #include #include @@ -24,19 +24,19 @@ #include -DEFINE_STANDARD_HANDLE (ViewControl_TransientShape, Standard_Transient) +DEFINE_STANDARD_HANDLE (Convert_TransientShape, Standard_Transient) -//! \class ViewControl_TransientShape +//! \class Convert_TransientShape //! \brief An interface to create custom panes by transient object name. -class ViewControl_TransientShape : public Standard_Transient +class Convert_TransientShape : public Standard_Transient { public: //! Constructor - ViewControl_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); } + Convert_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); } //! Destructor - virtual ~ViewControl_TransientShape() {} + virtual ~Convert_TransientShape() {} //! Fills current shape void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; } @@ -44,7 +44,7 @@ public: //! Returns current shape const TopoDS_Shape GetShape() const { return myShape; } - DEFINE_STANDARD_RTTIEXT (ViewControl_TransientShape, Standard_Transient) + DEFINE_STANDARD_RTTIEXT (Convert_TransientShape, Standard_Transient) private: TopoDS_Shape myShape; diff --git a/tools/Convert/FILES b/tools/Convert/FILES new file mode 100644 index 0000000000..bbcae4a01e --- /dev/null +++ b/tools/Convert/FILES @@ -0,0 +1,4 @@ +Convert_Tools.cxx +Convert_Tools.hxx +Convert_TransientShape.cxx +Convert_TransientShape.hxx diff --git a/tools/MessageModel/FILES b/tools/MessageModel/FILES index fb8efa0e50..3274a6ec51 100644 --- a/tools/MessageModel/FILES +++ b/tools/MessageModel/FILES @@ -6,16 +6,16 @@ MessageModel_ItemAlert.cxx MessageModel_ItemAlert.hxx MessageModel_ItemBase.cxx MessageModel_ItemBase.hxx +MessageModel_ItemPropertiesAttributeStream.cxx +MessageModel_ItemPropertiesAttributeStream.hxx +MessageModel_ItemPropertiesReport.cxx +MessageModel_ItemPropertiesReport.hxx MessageModel_ItemReport.cxx MessageModel_ItemReport.hxx -MessageModel_ItemReportProperties.cxx -MessageModel_ItemReportProperties.hxx MessageModel_ItemRoot.cxx MessageModel_ItemRoot.hxx MessageModel_ReportCallBack.cxx MessageModel_ReportCallBack.hxx -MessageModel_TableModelValues.cxx -MessageModel_TableModelValues.hxx MessageModel_Tools.cxx MessageModel_Tools.hxx MessageModel_TreeModel.cxx diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 140aaaf043..0914b8d004 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -63,7 +63,9 @@ MessageModel_Actions::MessageModel_Actions (QWidget* theParent, ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this)); #ifdef DEBUG_ALERTS myActions.insert (MessageModel_ActionType_Test, - ViewControl_Tools::CreateAction ("Test", SLOT (OnTestAlerts()), parent(), this)); + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestClock()), parent(), this)); + myActions.insert (MessageModel_ActionType_Test, + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestPropetyPanel()), parent(), this)); #endif } @@ -266,12 +268,12 @@ void MessageModel_Actions::OnExportToShapeView() } // ======================================================================= -// function : OnTestAlerts +// function : OnTestClock // purpose : // ======================================================================= #include #include -void MessageModel_Actions::OnTestAlerts() +void MessageModel_Actions::OnTestClock() { #ifdef DEBUG_ALERTS QModelIndex aReportIndex; @@ -294,11 +296,14 @@ void MessageModel_Actions::OnTestAlerts() aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5; Standard_Real aValue3 = aValue + aValue2 * 0.2; + (void)aValue3; //MESSAGE_INFO ("Calculate", aValue, &aPerfMeter, NULL); } } - ((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged(); + //((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged(); + + myTreeModel->UpdateTreeModel(); //Standard_Real aSystemSeconds1, aCurrentSeconds1; //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1); @@ -311,3 +316,44 @@ void MessageModel_Actions::OnTestAlerts() std::cout << "clock() = " << end_time - start_time << std::endl; #endif } + +// ======================================================================= +// function : OnTestClock +// purpose : +// ======================================================================= +void MessageModel_Actions::OnTestPropetyPanel() +{ +#ifdef DEBUG_ALERTS + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL); + + // gp_XYZ + { + gp_XYZ aCoords (1.3, 2.3, 3.4); + Standard_SStream aStream; + aCoords.Dump (aStream, Standard_DumpMask_SingleValue); + MESSAGE_INFO_STREAM(aStream, "gp_XYZ", "", &aPerfMeter, NULL); + } + // Bnd_Box + { + Bnd_Box aBox(20., 15., 10., 25., 20., 15.); + Standard_SStream aStream; + aBox.Dump (aStream, Standard_DumpMask_SingleValue); + MESSAGE_INFO_STREAM(aStream, "Bnd_Box", "", &aPerfMeter, NULL); + } + // Bnd_OBB + { + Bnd_OBB anOBB (gp_Pnt (-10., -15., -10.), gp_Dir (1., 0., 0.), gp_Dir (0., 1., 0.), gp_Dir (0., 0., 1.), + 5., 10., 5.); + Standard_SStream aStream; + anOBB.Dump (aStream, Standard_DumpMask_SingleValue); + MESSAGE_INFO_STREAM(aStream, "Bnd_OBB", "", &aPerfMeter, NULL); + } + myTreeModel->UpdateTreeModel(); +#endif +} diff --git a/tools/MessageModel/MessageModel_Actions.hxx b/tools/MessageModel/MessageModel_Actions.hxx index 71da2a0935..7dea43fa33 100644 --- a/tools/MessageModel/MessageModel_Actions.hxx +++ b/tools/MessageModel/MessageModel_Actions.hxx @@ -82,8 +82,11 @@ public slots: //! Exports the first selected shape into ShapeViewer plugin. void OnExportToShapeView(); - //! Sending several alerts to check message-alert-tool mechanizm - void OnTestAlerts(); + //! Sending several alerts to check time of message-alert-tool mechanizm + void OnTestClock(); + + //! Sending several alerts to check property panel/presentations of message-alert-tool mechanizm + void OnTestPropetyPanel(); protected: //! Returns report of selected tree view item if a report item is selected diff --git a/tools/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx index b94e5ac006..56c8d6f550 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.cxx +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -15,16 +15,17 @@ #include +#include #include #include #include #include -#include +#include #include #include #include -#include +#include #include #include @@ -76,7 +77,7 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) return QIcon (":/icons/item_shape.png"); - else if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeVectorOfValues))) + else if (!Handle(Message_AttributeStream)::DownCast (anAttribute).IsNull()) return QIcon (":/icons/item_vectorOfValues.png"); else return QVariant(); @@ -218,17 +219,23 @@ void MessageModel_ItemAlert::Init() 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())); + if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + { + TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); + SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem)); + } + //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 Convert_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))); + //TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription(); + //Bnd_Box aBox; + //if (aBox.Init (Standard_SStream (aDescription.ToCString()))) + // myPresentations.Append (new Convert_TransientShape (Convert_Tools::CreateShape (aBox))); } MessageModel_ItemBase::Init(); } diff --git a/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.cxx b/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.cxx new file mode 100644 index 0000000000..f0f24c957c --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.cxx @@ -0,0 +1,126 @@ +// Created on: 2019-02-25 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ItemPropertiesAttributeStream, TreeModel_ItemProperties) + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void MessageModel_ItemPropertiesAttributeStream::Init() +{ + MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(getItem()); + if (!anAlertItem) + return; + + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlertItem->GetAlert()); + if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull()) + return; + + Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + if (anAttributeStream.IsNull()) + return; + + TCollection::Split (anAttributeStream->GetStream(), myValues); + + TreeModel_ItemProperties::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void MessageModel_ItemPropertiesAttributeStream::Reset() +{ + myValues.Clear(); + + TreeModel_ItemProperties::Reset(); +} + +// ======================================================================= +// function : RowCount +// purpose : +// ======================================================================= + +int MessageModel_ItemPropertiesAttributeStream::GetTableRowCount() const +{ + const NCollection_IndexedDataMap& aValues = GetValues(); + return aValues.Size(); +} + +// ======================================================================= +// function : Data +// purpose : +// ======================================================================= + +QVariant MessageModel_ItemPropertiesAttributeStream::GetTableData (const int theRow, const int theColumn, int theRole) const +{ + const NCollection_IndexedDataMap& aValues = GetValues(); + + if (theRole == Qt::DisplayRole) + { + if (theColumn == 0) return aValues.FindKey (theRow + 1).ToCString(); + else if (theColumn == 1) return aValues.FindFromIndex (theRow + 1).ToCString(); + } + return QVariant(); +} + +// ======================================================================= +// function : GetTableEditType +// purpose : +// ======================================================================= +ViewControl_EditType MessageModel_ItemPropertiesAttributeStream::GetTableEditType (const int theRow, const int) const +{ + //switch (theRow) + //{ + // case 0: return ViewControl_EditType_Spin; + // default: return ViewControl_EditType_None; + //} + return ViewControl_EditType_None; +} + +// ======================================================================= +// function : SetTableData +// purpose : +// ======================================================================= +bool MessageModel_ItemPropertiesAttributeStream::SetTableData (const int theRow, const int theColumn, const QVariant& theValue) +{ + //Handle(Message_Report) aReport = getItemReport(); + //switch (theRow) + //{ + // case 0: aReport->SetLimit (theValue.toInt()); break; + // default: break; + //} + return true; +} diff --git a/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.hxx b/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.hxx new file mode 100644 index 0000000000..96a86f611c --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemPropertiesAttributeStream.hxx @@ -0,0 +1,100 @@ +// Created on: 2019-02-25 +// 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 MessageModel_ItemReportProperties_H +#define MessageModel_ItemReportProperties_H + +#include +#include +#include +#include + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +class QItemDelegate; + +DEFINE_STANDARD_HANDLE (MessageModel_ItemPropertiesAttributeStream, TreeModel_ItemProperties) + +//! \class MessageModel_ItemPropertiesAttributeStream +//! \brief This is an interace for ViewControl_TableModel to give real values of the model +//! It should be filled or redefined. +class MessageModel_ItemPropertiesAttributeStream : public TreeModel_ItemProperties +{ +public: + + //! Constructor + Standard_EXPORT MessageModel_ItemPropertiesAttributeStream (TreeModel_ItemBasePtr theItem) + : TreeModel_ItemProperties (theItem) {} + + //! Destructor + virtual ~MessageModel_ItemPropertiesAttributeStream() {} + + //! If me has internal values, it should be initialized here. + Standard_EXPORT virtual void Init(); + + //! If the item has internal values, there should be reseted here. + Standard_EXPORT virtual void Reset(); + + //! Returns number of rows, depending on orientation: myColumnCount or size of values container + //! \param theParent an index of the parent item + //! \return an integer value + Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns content of the model index for the given role, it is obtained from internal container of values + //! It returns value only for DisplayRole. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theRole a view role + //! \return value intepreted depending on the given role + Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE; + + //! Returns 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 + Standard_EXPORT 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 + Standard_EXPORT virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT (MessageModel_ItemPropertiesAttributeStream, TreeModel_ItemProperties) + +protected: + //! Returns attribute with stream value + const NCollection_IndexedDataMap& GetValues() const + { + if (!IsInitialized()) + const_cast(this)->Init(); + return myValues; + } + +protected: + NCollection_IndexedDataMap myValues; +}; + +#endif diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.cxx b/tools/MessageModel/MessageModel_ItemPropertiesReport.cxx similarity index 86% rename from tools/MessageModel/MessageModel_ItemReportProperties.cxx rename to tools/MessageModel/MessageModel_ItemPropertiesReport.cxx index 4538856399..5860f5e7d6 100644 --- a/tools/MessageModel/MessageModel_ItemReportProperties.cxx +++ b/tools/MessageModel/MessageModel_ItemPropertiesReport.cxx @@ -13,7 +13,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include #include #include @@ -27,14 +27,14 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ItemReportProperties, TreeModel_ItemProperties) +IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ItemPropertiesReport, TreeModel_ItemProperties) // ======================================================================= // function : RowCount // purpose : // ======================================================================= -int MessageModel_ItemReportProperties::GetTableRowCount() const +int MessageModel_ItemPropertiesReport::GetTableRowCount() const { return 1; } @@ -44,7 +44,7 @@ int MessageModel_ItemReportProperties::GetTableRowCount() const // purpose : // ======================================================================= -QVariant MessageModel_ItemReportProperties::GetTableData (const int theRow, const int theColumn, int theRole) const +QVariant MessageModel_ItemPropertiesReport::GetTableData (const int theRow, const int theColumn, int theRole) const { if (theRole != Qt::DisplayRole) return QVariant(); @@ -63,7 +63,7 @@ QVariant MessageModel_ItemReportProperties::GetTableData (const int theRow, cons // function : GetTableEditType // purpose : // ======================================================================= -ViewControl_EditType MessageModel_ItemReportProperties::GetTableEditType (const int theRow, const int) const +ViewControl_EditType MessageModel_ItemPropertiesReport::GetTableEditType (const int theRow, const int) const { switch (theRow) { @@ -76,7 +76,7 @@ ViewControl_EditType MessageModel_ItemReportProperties::GetTableEditType (const // function : SetTableData // purpose : // ======================================================================= -bool MessageModel_ItemReportProperties::SetTableData (const int theRow, const int theColumn, const QVariant& theValue) +bool MessageModel_ItemPropertiesReport::SetTableData (const int theRow, const int theColumn, const QVariant& theValue) { Handle(Message_Report) aReport = getItemReport(); switch (theRow) @@ -92,7 +92,7 @@ bool MessageModel_ItemReportProperties::SetTableData (const int theRow, const in // purpose : // ======================================================================= -Handle(Message_Report) MessageModel_ItemReportProperties::getItemReport() const +Handle(Message_Report) MessageModel_ItemPropertiesReport::getItemReport() const { MessageModel_ItemReportPtr aReportItem = itemDynamicCast(getItem()); if (!aReportItem) diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.hxx b/tools/MessageModel/MessageModel_ItemPropertiesReport.hxx similarity index 89% rename from tools/MessageModel/MessageModel_ItemReportProperties.hxx rename to tools/MessageModel/MessageModel_ItemPropertiesReport.hxx index 2970397b9f..ce1b324bcd 100644 --- a/tools/MessageModel/MessageModel_ItemReportProperties.hxx +++ b/tools/MessageModel/MessageModel_ItemPropertiesReport.hxx @@ -32,21 +32,21 @@ class QItemDelegate; -DEFINE_STANDARD_HANDLE (MessageModel_ItemReportProperties, TreeModel_ItemProperties) +DEFINE_STANDARD_HANDLE (MessageModel_ItemPropertiesReport, TreeModel_ItemProperties) -//! \class MessageModel_ItemReportProperties +//! \class MessageModel_ItemPropertiesReport //! \brief This is an interace for ViewControl_TableModel to give real values of the model //! It should be filled or redefined. -class MessageModel_ItemReportProperties : public TreeModel_ItemProperties +class MessageModel_ItemPropertiesReport : public TreeModel_ItemProperties { public: //! Constructor - Standard_EXPORT MessageModel_ItemReportProperties (TreeModel_ItemBasePtr theItem) + Standard_EXPORT MessageModel_ItemPropertiesReport (TreeModel_ItemBasePtr theItem) : TreeModel_ItemProperties (theItem) {} //! Destructor - virtual ~MessageModel_ItemReportProperties() {} + virtual ~MessageModel_ItemPropertiesReport() {} //! Returns number of rows, depending on orientation: myColumnCount or size of values container //! \param theParent an index of the parent item @@ -73,7 +73,7 @@ public: //! \param theValue a new cell value Standard_EXPORT virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE; - DEFINE_STANDARD_RTTIEXT (MessageModel_ItemReportProperties, TreeModel_ItemProperties) + DEFINE_STANDARD_RTTIEXT (MessageModel_ItemPropertiesReport, TreeModel_ItemProperties) protected: //! Returns report diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx index a2af8df74e..4f387e61c5 100644 --- a/tools/MessageModel/MessageModel_ItemReport.cxx +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -128,7 +128,7 @@ void MessageModel_ItemReport::Init() myReport = aRootItem ? aRootItem->GetReport (Row(), myDescription) : Handle(Message_Report)(); TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); - SetProperties (new MessageModel_ItemReportProperties(anItem)); + SetProperties (new MessageModel_ItemPropertiesReport (anItem)); MessageModel_ItemBase::Init(); } diff --git a/tools/MessageModel/MessageModel_TableModelValues.cxx b/tools/MessageModel/MessageModel_TableModelValues.cxx deleted file mode 100644 index 9b295cf8bd..0000000000 --- a/tools/MessageModel/MessageModel_TableModelValues.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// Created on: 2017-06-16 -// Created by: Natalia ERMOLAEVA -// Copyright (c) 2017 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include - -#include - -const int REAL_SIGNS = 16; - -// ======================================================================= -// function : Constructor -// purpose : -// ======================================================================= - -MessageModel_TableModelValues::MessageModel_TableModelValues (const Handle(Message_Attribute)& theAttribute, - const int theSectionWidth) - : myAttribute (Handle(Message_AttributeVectorOfValues)::DownCast (theAttribute)) -{ - SetDefaultSectionSize (Qt::Horizontal, theSectionWidth); -} - -// ======================================================================= -// function : ColumnCount -// purpose : -// ======================================================================= - -int MessageModel_TableModelValues::ColumnCount (const QModelIndex&) const -{ - return myAttribute->GetColumnCount(); -} - -// ======================================================================= -// function : RowCount -// purpose : -// ======================================================================= -int MessageModel_TableModelValues::RowCount (const QModelIndex& theParent) const -{ - int aColumnCount = ColumnCount (theParent); - if (!aColumnCount) - return 0; - - return myAttribute->GetValues().Length() / aColumnCount; -} - -// ======================================================================= -// function : Data -// purpose : -// ======================================================================= - -QVariant MessageModel_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const -{ - int aColumnCount = ColumnCount (QModelIndex()); - int anIndex = theRow * aColumnCount + theColumn; - - if (theRole == Qt::DisplayRole && anIndex < myAttribute->GetValues().Length()) - { - return myAttribute->GetValues().Value(anIndex).ToCString(); - } - - return QVariant(); -} diff --git a/tools/MessageModel/MessageModel_TableModelValues.hxx b/tools/MessageModel/MessageModel_TableModelValues.hxx deleted file mode 100644 index 85145e78f8..0000000000 --- a/tools/MessageModel/MessageModel_TableModelValues.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Created on: 2017-06-16 -// Created by: Natalia ERMOLAEVA -// Copyright (c) 2017 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef MessageModel_TableModelValues_H -#define MessageModel_TableModelValues_H - -#include - -#include -class Message_AttributeVectorOfValues; - -//! \class MessageModel_TableModelValues -//! \brief This is an implementation for ViewControl_TableModel to present Message_AttributeVectorOfValues object -class MessageModel_TableModelValues : public ViewControl_TableModelValues -{ -public: - - //! Constructor - Standard_EXPORT MessageModel_TableModelValues (const Handle(Message_Attribute)& theAttribute, const int theSectionWidth); - - //! Destructor - virtual ~MessageModel_TableModelValues() Standard_OVERRIDE {} - - //! Returns number of columns, size of header values - //! \param theParent an index of the parent item - //! \return an integer value - Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const; - - //! Returns number of rows, depending on orientation: myColumnCount or size of values container - //! \param theParent an index of the parent item - //! \return an integer value - Standard_EXPORT virtual int RowCount (const QModelIndex& theParent) const; - - //! Returns content of the model index for the given role, it is obtained from internal container of values - //! It returns value only for DisplayRole. - //! \param theIndex a model index - //! \param theRole a view role - //! \return value intepreted depending on the given role - Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const; - -private: - Handle(Message_AttributeVectorOfValues) myAttribute; //!< alert attribute, container of table values -}; - -#endif diff --git a/tools/MessageModel/MessageModel_Tools.cxx b/tools/MessageModel/MessageModel_Tools.cxx index 0adacedd37..892f165287 100644 --- a/tools/MessageModel/MessageModel_Tools.cxx +++ b/tools/MessageModel/MessageModel_Tools.cxx @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -27,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -163,36 +162,36 @@ void MessageModel_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& th if (anAttribute.IsNull()) return; - if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeVectorOfValues))) + //if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeStream))) + //{ + //int aSectionSize = 200; + //ViewControl_TableModelValues* aTableValues = new MessageModel_TableModelValues (anAttribute, aSectionSize); + //theTableValues.append (aTableValues); + //} + //else + //{ + if (!anAttribute->GetDescription().IsEmpty()) { - int aSectionSize = 200; - ViewControl_TableModelValues* aTableValues = new MessageModel_TableModelValues (anAttribute, aSectionSize); + ViewControl_TableModelValuesDefault* aTableValues = new ViewControl_TableModelValuesDefault(); + QList aHeaderValues; + QVector aValues; + aHeaderValues << TreeModel_HeaderSection ("Description", -2); + aValues << anAttribute->GetDescription().ToCString(); + aTableValues->SetHeaderValues (aHeaderValues, Qt::Horizontal); + + QString aValueStr = anAttribute->GetDescription().ToCString(); + QStringList aValueStrList = aValueStr.split ("\n"); + int aNbRows = aValueStrList.size(); + + QFontMetrics aFontMetrics (qApp->font()); + int aHeight = aFontMetrics.boundingRect(aValueStr).height(); + aHeight = (aHeight + TreeModel_Tools::HeaderSectionMargin()) * aNbRows; + aTableValues->SetValues (aValues); + aTableValues->SetDefaultSectionSize(Qt::Vertical, aHeight); + theTableValues.append (aTableValues); } - else - { - if (!anAttribute->GetDescription().IsEmpty()) - { - ViewControl_TableModelValuesDefault* aTableValues = new ViewControl_TableModelValuesDefault(); - QList aHeaderValues; - QVector aValues; - aHeaderValues << TreeModel_HeaderSection ("Description", -2); - aValues << anAttribute->GetDescription().ToCString(); - aTableValues->SetHeaderValues (aHeaderValues, Qt::Horizontal); - - QString aValueStr = anAttribute->GetDescription().ToCString(); - QStringList aValueStrList = aValueStr.split ("\n"); - int aNbRows = aValueStrList.size(); - - QFontMetrics aFontMetrics (qApp->font()); - int aHeight = aFontMetrics.boundingRect(aValueStr).height(); - aHeight = (aHeight + TreeModel_Tools::HeaderSectionMargin()) * aNbRows; - aTableValues->SetValues (aValues); - aTableValues->SetDefaultSectionSize(Qt::Vertical, aHeight); - - theTableValues.append (aTableValues); - } - } + //} } // ======================================================================= diff --git a/tools/MessageView/MessageView_VisibilityState.cxx b/tools/MessageView/MessageView_VisibilityState.cxx index cec2d932df..5b7e5d415f 100644 --- a/tools/MessageView/MessageView_VisibilityState.cxx +++ b/tools/MessageView/MessageView_VisibilityState.cxx @@ -17,7 +17,7 @@ #include #include -#include +#include #include @@ -133,7 +133,7 @@ bool MessageView_VisibilityState::hasTableValues (const QModelIndex& theIndex) c if (anAlert.IsNull()) return false; - if (anAlert->IsKind (STANDARD_TYPE (Message_AttributeVectorOfValues))) + if (anAlert->IsKind (STANDARD_TYPE (Message_AttributeStream))) return true; return false; diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index ad8895e831..72b06db0ad 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -361,7 +361,6 @@ void MessageView_Window::Init (NCollection_List& the if (!aContext.IsNull()) { - myContext = aContext; myViewWindow->SetContext (View_ContextType_External, aContext); } @@ -719,17 +718,16 @@ void MessageView_Window::updatePropertyPanelBySelection() // ======================================================================= void MessageView_Window::updatePreviewPresentation (const NCollection_List& thePresentations) { - if (myContext.IsNull()) + Handle(AIS_InteractiveContext) aContext = myViewWindow->GetViewToolBar()->GetCurrentContext(); + if (aContext.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()) + if (!aPrs.IsNull() && aPrs->GetContext() == aContext) aContext->Remove (aPrs, Standard_True); } } @@ -747,18 +745,20 @@ void MessageView_Window::updatePreviewPresentation (const NCollection_ListGetContext().IsNull()) + continue; // not possible to display one object in several contexts aContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); } - else if (!Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull()) + else if (!Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull()) { - Handle(ViewControl_TransientShape) aShapeObject = Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value()); + Handle(Convert_TransientShape) aShapeObject = Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()); aBuilder.Add (aCompound, aShapeObject->GetShape()); } } if (aCompound.IsNull()) { - if (!aContext.IsNull()) + if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext) aContext->Remove (myPreviewPresentation, Standard_True); myPreviewPresentation = NULL; return; @@ -769,7 +769,7 @@ void MessageView_Window::updatePreviewPresentation (const NCollection_ListSetAttributes (GetPreviewAttributes(myContext)); + myPreviewPresentation->SetAttributes (GetPreviewAttributes(aContext)); //myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); //myPreviewPresentation->SetTransformPersistence(thePersistent); @@ -780,7 +780,7 @@ void MessageView_Window::updatePreviewPresentation (const NCollection_ListSet (aCompound); //myPreviewPresentation->SetTransformPersistence(thePersistent); - if (!aContext.IsNull()) + if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext) aContext->Redisplay (myPreviewPresentation, Standard_True); } } diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx index a4ace53694..d90555ad40 100644 --- a/tools/MessageView/MessageView_Window.hxx +++ b/tools/MessageView/MessageView_Window.hxx @@ -179,7 +179,6 @@ 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; }; diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx index 5743c1e0d1..75ccf87870 100644 --- a/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -131,7 +131,8 @@ int main (int argc, char** argv) aReport->SetActive (Standard_True);//Standard_False); aPlugins.insert("TKMessageView"); - anActivatedPluginName = "TKVInspector"; + //anActivatedPluginName = "TKVInspector"; + anActivatedPluginName = "TKMessageView"; } else anActivatedPluginName = *aPlugins.rbegin(); diff --git a/tools/TKTInspectorAPI/EXTERNLIB b/tools/TKTInspectorAPI/EXTERNLIB index df0002f9af..fd85421be9 100644 --- a/tools/TKTInspectorAPI/EXTERNLIB +++ b/tools/TKTInspectorAPI/EXTERNLIB @@ -1,4 +1,7 @@ TKG3d TKernel TKLCAF -TKMath \ No newline at end of file +TKMath +TKBRep +TKTopAlgo +TKPrim diff --git a/tools/TKTInspectorAPI/PACKAGES b/tools/TKTInspectorAPI/PACKAGES index 7cb3cd210e..72bf985bde 100644 --- a/tools/TKTInspectorAPI/PACKAGES +++ b/tools/TKTInspectorAPI/PACKAGES @@ -1 +1,3 @@ +Convert TInspectorAPI + diff --git a/tools/TKView/EXTERNLIB b/tools/TKView/EXTERNLIB index b5f64414c0..72cf33304f 100644 --- a/tools/TKView/EXTERNLIB +++ b/tools/TKView/EXTERNLIB @@ -4,4 +4,5 @@ TKMath TKService TKOpenGl TKV3d +TKTInspectorAPI CSF_QT \ No newline at end of file diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 3efee94260..af8dc1f860 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -52,7 +52,7 @@ Handle(TreeModel_ItemProperties) TreeModel_ItemBase::GetProperties() const } // ======================================================================= -// function : reset +// function : Reset // purpose : // ======================================================================= void TreeModel_ItemBase::Reset() @@ -76,7 +76,7 @@ void TreeModel_ItemBase::Reset() // ======================================================================= void TreeModel_ItemBase::Reset (int theRole) { - if (!myCachedValues.contains (theRole)) + if (!myCachedValues.contains (theRole)) return; myCachedValues.remove (theRole); diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index a16e3a2ca5..fb7086f254 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -17,6 +17,16 @@ IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient) +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void TreeModel_ItemProperties::Reset() +{ + m_bInitialized = false; + myCachedValues.clear(); +} + // ======================================================================= // function : GetTableFlags // purpose : @@ -31,3 +41,46 @@ Qt::ItemFlags TreeModel_ItemProperties::GetTableFlags (const int, const int theC return aFlags; } + +// ======================================================================= +// function : cachedValueRowCount +// purpose : +// ======================================================================= + +int TreeModel_ItemProperties::cachedDimValue (const TreeModel_DimType theDimType) const +{ + if (myCachedDimValues.contains (theDimType)) + return myCachedDimValues[theDimType].toInt(); + + QVariant aValueToCache; + switch (theDimType) + { + case TreeModel_DimType_Rows: aValueToCache = GetTableRowCount(); break; + case TreeModel_DimType_Columns: aValueToCache = GetTableColumnCount(); break; + } + + const_cast(this)->myCachedDimValues.insert (theDimType, aValueToCache); + return myCachedDimValues.contains (theDimType) ? myCachedDimValues[theDimType].toInt() : 0; +} + +// ======================================================================= +// function : cachedValue +// purpose : +// ======================================================================= + +QVariant TreeModel_ItemProperties::cachedValue (const int theRow, const int theColumn, int theRole) const +{ + QPair aPos = qMakePair (theRow, theColumn); + if (myCachedValues.contains (aPos) && myCachedValues[aPos].contains (theRole)) + return myCachedValues[aPos][theRole]; + + QVariant aValueToCache = GetTableData (theRow, theColumn, theRole); + + QMap aValuesToCache; + if (myCachedValues.contains(aPos)) + aValuesToCache = myCachedValues[aPos]; + aValuesToCache.insert (theRole, aValueToCache); + + const_cast(this)->myCachedValues.insert (aPos, aValuesToCache); + return aValueToCache; +} diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index a7a41282c6..8310cd3a61 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -41,6 +41,13 @@ DEFINE_STANDARD_HANDLE (TreeModel_ItemProperties, Standard_Transient) //! Class to manipulate properties of tree item. The properties are organized in table structure class TreeModel_ItemProperties : public Standard_Transient { + //! enum defined the dimension type + enum TreeModel_DimType + { + TreeModel_DimType_Rows, //! defines number of rows + TreeModel_DimType_Columns //! defines number of columns + }; + public: //! Constructor TreeModel_ItemProperties (const TreeModel_ItemBasePtr& theItem) : myItem (theItem) {} @@ -48,11 +55,33 @@ public: //! Destructor ~TreeModel_ItemProperties() {} + //! Returns number of table rows. It uses cached value of GetTableRowCount(), Reset() to reinit it. + //! \return an integer value + int RowCount() const { return cachedDimValue (TreeModel_DimType_Rows); } + + //! Returns number of table columns. It uses cached value of GetTableColumnCount(), Reset() to reinit it. + //! \return an integer value + int ColumnCount() const { return cachedDimValue (TreeModel_DimType_Columns); } + + //! Returns content of the model index for the given role, it is obtained from internal container of values + //! It uses cached value of GetTableData(), Reset() to reinit it. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theRole a view role + //! \return value intepreted depending on the given role + QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const + { return cachedValue (theRow, theColumn, theRole); } + + //! Gets whether the item is already initialized.The initialized state is thrown down + //! by the reset method and get back after the method Init(). + //! \return if the item is initialized + bool IsInitialized() const { return m_bInitialized; } + //! If me has internal values, it should be initialized here. - virtual void Init() {} + virtual void Init() { m_bInitialized = true; } //! If the item has internal values, there should be reseted here. - Standard_EXPORT virtual void Reset() {} + Standard_EXPORT virtual void Reset(); //! Returns number of item children //! \return an integer value, ZERO by default @@ -114,15 +143,32 @@ public: //! \return flags Standard_EXPORT virtual Qt::ItemFlags GetTableFlags (const int theRow, const int theColumn) const; - DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient) protected: //! Returns current item TreeModel_ItemBasePtr getItem() const { return myItem; } +private: + //! Returns the cached value for number of rows. Init the value if it is requested the first time. + //! \param theDimType dimension type + //! \return the value + Standard_EXPORT int cachedDimValue (const TreeModel_DimType theDimType) const; + + //! Returns the cached value for the role. Init the value if it is requested the first time + //! By default, it calls initRowCount(TreeModel_ItemRole_RowCountRole) or initValue for the item role + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT QVariant cachedValue (const int theRow, const int theColumn, int theRole) const; + private: TreeModel_ItemBasePtr myItem; //! current item + + QMap myCachedDimValues; //!< cached values, should be cleared by reset + QMap, QMap > myCachedValues; //!< cached values, should be cleared by reset + QMap, NCollection_List > myCachedPresentations; //!< cached values, should be cleared by reset + + bool m_bInitialized; //!< the state whether the item content is already initialized }; #endif \ No newline at end of file diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index 8768383993..92141ceaf4 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -4,7 +4,6 @@ VInspector_CallBack.hxx VInspector_CallBackMode.hxx VInspector_Communicator.cxx VInspector_Communicator.hxx -VInspector_DisplayActionType.hxx VInspector_ItemAspectWindow.cxx VInspector_ItemAspectWindow.hxx VInspector_ItemBase.cxx @@ -85,8 +84,6 @@ 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_SelectionType.hxx diff --git a/tools/VInspector/VInspector_ItemBVHTree.cxx b/tools/VInspector/VInspector_ItemBVHTree.cxx index 8bcd7e328e..01c8744aa2 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.cxx +++ b/tools/VInspector/VInspector_ItemBVHTree.cxx @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -185,10 +187,10 @@ TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape() TCollection_AsciiString aValue = aValues.Value (aValueId); Bnd_Box aBox; - if (!aBox.FromString (aValue)) + if (!aBox.Init (Standard_SStream (aValue.ToCString()))) continue; - TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox); + TopoDS_Shape aShape = Convert_Tools::CreateShape (aBox); aBuilder.Add (aCompound, aShape); } } diff --git a/tools/VInspector/VInspector_ItemBVHTreeNode.cxx b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx index 061539e303..d171da21b3 100644 --- a/tools/VInspector/VInspector_ItemBVHTreeNode.cxx +++ b/tools/VInspector/VInspector_ItemBVHTreeNode.cxx @@ -20,6 +20,8 @@ // #include +#include + #include #include @@ -137,10 +139,10 @@ TopoDS_Shape VInspector_ItemBVHTreeNode::buildPresentationShape() TCollection_AsciiString aValue = aValues.Value (aValueId); Bnd_Box aBox; - if (!aBox.FromString (aValue)) + if (!aBox.Init (Standard_SStream (aValue.ToCString()))) continue; - TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox); + TopoDS_Shape aShape = Convert_Tools::CreateShape (aBox); aBuilder.Add (aCompound, aShape); } } diff --git a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx index 0fbeac1940..a6c26dc844 100644 --- a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx @@ -21,6 +21,8 @@ #include #include +#include + #include // ======================================================================= @@ -223,7 +225,7 @@ bool VInspector_ItemPrs3dPresentation::SetTableData (const int theRow, const int TopoDS_Shape VInspector_ItemPrs3dPresentation::buildPresentationShape() { if (!myPresentation.IsNull()) - myPresentationShape = VInspector_Tools::CreateShape (myPresentation->MinMaxValues()); + myPresentationShape = Convert_Tools::CreateShape (myPresentation->MinMaxValues()); return TopoDS_Shape(); } diff --git a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx index c865b83c04..e4a7d8b691 100644 --- a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx +++ b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx @@ -54,6 +54,8 @@ //#include //#include // + +#include #include //#include #include diff --git a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.hxx b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.hxx index 8b164ed38d..9416896f41 100644 --- a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.hxx +++ b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.hxx @@ -101,7 +101,7 @@ protected: //! \param theColumn the child column position //! \return the created item virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE - { return TreeModel_ItemBasePtr(); } + { (void)theRow, (void)theColumn; return TreeModel_ItemBasePtr(); } //! Returns owner of the current sensitive entity //! \return owner diff --git a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx index af955e3a98..b65f2d28ae 100644 --- a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx @@ -48,6 +48,8 @@ #include #include +#include + #include #include #include @@ -205,7 +207,7 @@ void VInspector_ItemSelectBasicsSensitiveEntity::GetPresentations(NCollection_Li if (!myPresentation.IsNull()) return; - Handle(Select3D_SensitiveEntity) aBaseEntity = Handle(Select3D_SensitiveEntity)::DownCast (GetSensitiveEntity()); + Handle(Select3D_SensitiveEntity) aBaseEntity = GetSensitiveEntity(); if (aBaseEntity.IsNull()) return; @@ -276,7 +278,6 @@ QVariant VInspector_ItemSelectBasicsSensitiveEntity::GetTableData (const int the case 10: return ViewControl_Table::SeparatorData(); default: return getTableData (theRow, theColumn, theRole, anEntity->DynamicType()->Name()); } - return QVariant(); } // ======================================================================= @@ -308,7 +309,7 @@ QVariant VInspector_ItemSelectBasicsSensitiveEntity::getTableData (const int the const int, const TCollection_AsciiString& theEntityKind) const { - Handle(Select3D_SensitiveEntity) aBaseEntity = Handle(Select3D_SensitiveEntity)::DownCast (GetSensitiveEntity()); + Handle(Select3D_SensitiveEntity) aBaseEntity = GetSensitiveEntity(); if (aBaseEntity.IsNull()) return QVariant(); @@ -428,7 +429,7 @@ QVariant VInspector_ItemSelectBasicsSensitiveEntity::getTableData (const int the TopoDS_Shape VInspector_ItemSelectBasicsSensitiveEntity::buildPresentationShape (const Handle(SelectBasics_SensitiveEntity)& theEntity) { - Handle(Select3D_SensitiveEntity) aBaseEntity = Handle(Select3D_SensitiveEntity)::DownCast (theEntity); + Handle(Select3D_SensitiveEntity) aBaseEntity = theEntity; if (aBaseEntity.IsNull()) return TopoDS_Shape(); @@ -446,7 +447,7 @@ TopoDS_Shape VInspector_ItemSelectBasicsSensitiveEntity::buildPresentationShape if (aTypeName == STANDARD_TYPE (Select3D_SensitiveBox)->Name()) { Handle(Select3D_SensitiveBox) anEntity = Handle(Select3D_SensitiveBox)::DownCast (aBaseEntity); - TopoDS_Shape aShape = VInspector_Tools::CreateShape(anEntity->Box()); + TopoDS_Shape aShape = Convert_Tools::CreateShape(anEntity->Box()); aBuilder.Add (aCompound, aShape); } else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveFace)->Name()) diff --git a/tools/VInspector/VInspector_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index d443f150bb..9f28385816 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -16,9 +16,12 @@ #include #include +#include #include #include +#include + #include #include #include @@ -138,9 +141,8 @@ bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& th const Handle(SelectBasics_EntityOwner)& theOwner) { bool anIsSelected = false; - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (theOwner); for (theContext->InitSelected(); theContext->MoreSelected() && !anIsSelected; theContext->NextSelected()) - anIsSelected = theContext->SelectedOwner() == anOwner; + anIsSelected = theContext->SelectedOwner() == theOwner; return anIsSelected; } @@ -223,7 +225,7 @@ NCollection_List VInspector_Tools::ActiveOwner for (NCollection_List::Iterator anOwnersIt (anActiveOwners); anOwnersIt.More(); anOwnersIt.Next()) { - anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value()); + anOwner = anOwnersIt.Value(); if (anOwner.IsNull()) continue; @@ -264,7 +266,7 @@ void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveCo for (NCollection_List::Iterator anOwnersIt(theOwners); anOwnersIt.More(); anOwnersIt.Next()) { - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value()); + Handle(SelectMgr_EntityOwner) anOwner = anOwnersIt.Value(); #if OCC_VERSION_HEX > 0x060901 theContext->AddOrRemoveSelected (anOwner, Standard_False); #else @@ -546,7 +548,7 @@ namespace //function : DisplayActionTypeToString //purpose : //======================================================================= -Standard_CString VInspector_Tools::DisplayActionTypeToString (VInspector_DisplayActionType theType) +Standard_CString VInspector_Tools::DisplayActionTypeToString (View_DisplayActionType theType) { return VInspector_Table_PrintDisplayActionType[theType]; } @@ -556,15 +558,15 @@ Standard_CString VInspector_Tools::DisplayActionTypeToString (VInspector_Display //purpose : //======================================================================= Standard_Boolean VInspector_Tools::DisplayActionTypeFromString (Standard_CString theTypeString, - VInspector_DisplayActionType& theType) + View_DisplayActionType& theType) { TCollection_AsciiString aName (theTypeString); - for (Standard_Integer aTypeIter = 0; aTypeIter <= VInspector_DisplayActionType_RemoveId; ++aTypeIter) + for (Standard_Integer aTypeIter = 0; aTypeIter <= View_DisplayActionType_RemoveId; ++aTypeIter) { Standard_CString aTypeName = VInspector_Table_PrintDisplayActionType[aTypeIter]; if (aName == aTypeName) { - theType = VInspector_DisplayActionType (aTypeIter); + theType = View_DisplayActionType (aTypeIter); return Standard_True; } } @@ -582,48 +584,6 @@ QVariant VInspector_Tools::ToVariant (const Select3D_BndBox3d& theBoundingBox) .arg (theBoundingBox.CornerMax().x()).arg (theBoundingBox.CornerMax().y()).arg (theBoundingBox.CornerMax().z()); } -//======================================================================= -//function : CreateShape -//purpose : -//======================================================================= -TopoDS_Shape VInspector_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 VInspector_Tools::CreateShape (const Bnd_OBB& theBoundingBox) -{ - if (theBoundingBox.IsVoid()) - return TopoDS_Shape(); - - TColgp_Array1OfPnt anArrPnts(0, 8); - theBoundingBox.GetVertex(&anArrPnts(0)); - - BRep_Builder aBuilder; - TopoDS_Compound aCompound; - aBuilder.MakeCompound (aCompound); - - aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(1)))); - aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(2)))); - aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(1)), gp_Pnt (anArrPnts.Value(3)))); - aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(2)), gp_Pnt (anArrPnts.Value(3)))); - - return aCompound; -} - //======================================================================= //function : CreateShape //purpose : @@ -636,70 +596,9 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding gp_Pnt aPntMin = gp_Pnt (theBoundingBox.CornerMin().x(), theBoundingBox.CornerMin().y(), theBoundingBox.CornerMin().z()); gp_Pnt aPntMax = gp_Pnt (theBoundingBox.CornerMax().x(), theBoundingBox.CornerMax().y(), theBoundingBox.CornerMax().z()); - return CreateBoxShape (aPntMin, aPntMax); + return Convert_Tools::CreateBoxShape (aPntMin, aPntMax); } -//======================================================================= -//function : CreateBoxShape -//purpose : -//======================================================================= -TopoDS_Shape VInspector_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(); - } -} - - //======================================================================= //function : ToVariant //purpose : @@ -736,7 +635,7 @@ QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_Buffer)& theBuffer) //function : ToVariant //purpose : //======================================================================= -QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_BoundBuffer)& theBoundBuffer) +QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_BoundBuffer)& /*theBoundBuffer*/) { //const Handle(Graphic3d_Buffer)& aBuffer = theBoundBuffer; //Handle(Graphic3d_Buffer) aBuffer = Handle(Graphic3d_Buffer)::DownCast (theBoundBuffer); diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index 4ca765d517..6911834d27 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -160,14 +160,14 @@ public: //! Returns the string name for a given type. //! @param theType action type //! @return string identifier from the display action type - Standard_EXPORT static Standard_CString DisplayActionTypeToString (VInspector_DisplayActionType theType); + Standard_EXPORT static Standard_CString DisplayActionTypeToString (View_DisplayActionType theType); //! Returns the enumeration type from the given string identifier (using case-insensitive comparison). //! @param theTypeString string identifier //! @return string identifier from the display action type - static VInspector_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString) + static View_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString) { - VInspector_DisplayActionType aType = VInspector_DisplayActionType_NoneId; + View_DisplayActionType aType = View_DisplayActionType_NoneId; DisplayActionTypeFromString (theTypeString, aType); return aType; } @@ -177,29 +177,13 @@ public: //! @param theType detected action type //! @return TRUE if string identifier is known Standard_EXPORT static Standard_Boolean DisplayActionTypeFromString (const Standard_CString theTypeString, - VInspector_DisplayActionType& theType); + View_DisplayActionType& theType); //! Build string presentation of bounding box information in form: (xmin, ymin, zmin), (xmax, ymax, zmax) //! \param theBoundingBox bounding box //! \return string presentation Standard_EXPORT static QVariant ToVariant (const Select3D_BndBox3d& theBoundingBox); - //! 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); - //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index cb0f36a9ed..cab89e4ec7 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -18,15 +18,17 @@ #include #include #include -#include -#include -#include -#include +//#include +//#include +//#include +//#include #include -#include +//#include #include +#include + #include #include #include @@ -35,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -46,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -61,6 +62,8 @@ #include #include +#include +#include #include #include @@ -108,7 +111,7 @@ 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(); + myDisplayPreview = new View_DisplayPreview(); myMainWindow = new QMainWindow (0); @@ -251,8 +254,9 @@ void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIte theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); } + anItems.clear(); - VInspector_PreviewParameters::SaveState (myPreviewParameters, anItems, "preview_parameters_"); + View_PreviewParameters::SaveState (myDisplayPreview->GetPreviewParameters(), 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()); @@ -286,8 +290,8 @@ 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_")) + else if (View_PreviewParameters::RestoreState (myDisplayPreview->GetPreviewParameters(), anItemIt.Key().ToCString(), + anItemIt.Value().ToCString(), "preview_parameters_")) continue; } } @@ -382,6 +386,31 @@ NCollection_List VInspector_Window::GetSelectedPr return aSelectedPresentations; } +// ======================================================================= +// function : GetSelectedShapes +// purpose : +// ======================================================================= + +void VInspector_Window::GetSelectedShapes (NCollection_List& theSelPresentations) +{ + QModelIndexList theIndices = myTreeView->selectionModel()->selectedIndexes(); + + QList anItems = TreeModel_ModelBase::GetSelectedItems (theIndices); + for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) + { + TreeModel_ItemBasePtr anItem = *anItemIt; + VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); + if (!aVItem /*|| aVItem->Row() == 0*/) + continue; + + TopoDS_Shape aShape = aVItem->GetPresentationShape(); + if (aShape.IsNull()) + continue; + + theSelPresentations.Append (new Convert_TransientShape (aShape)); + } +} + // ======================================================================= // function : GetSelectedShapes // purpose : @@ -407,18 +436,20 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode // obtain selection from the property panel { - QList aPropertyTables; - myPropertyView->GetActiveTables (aPropertyTables); - if (!aPropertyTables.isEmpty()) - { - ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables + //QList aPropertyTables; + //myPropertyView->GetActiveTables (aPropertyTables); + //if (!aPropertyTables.isEmpty()) + //{ + // ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables - Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); - QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes(); - GetSelectedPropertyPanelShapes(aTreeViewSelected, - aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), - aSelectedShapes); - } + // Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); + + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0); + TreeModel_ItemBasePtr aTreeItem = TreeModel_ModelBase::GetItemByIndex (anIndex); + + //QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes(); + GetSelectedPropertyPanelShapes(aTreeItem, aSelectedShapes); + //} } return aSelectedShapes; @@ -428,55 +459,75 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode // function : GetSelectedPropertyPanelShapes // purpose : // ======================================================================= -void VInspector_Window::GetSelectedPropertyPanelShapes (const QModelIndexList& theTreeViewIndices, - const QModelIndexList& thePropertyPanelIndices, +void VInspector_Window::GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem, NCollection_List& theShapes) { - QList anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices); - NCollection_List aPropertyPresentations; - for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) - { - TreeModel_ItemBasePtr anItem = *anItemIt; - if (!anItem || anItem->Column() != 0) - continue; - - QList aTableValues; - VInspector_Tools::GetPropertyTableValues (anItem, myPaneCreators, aTableValues); - if (aTableValues.isEmpty()) - continue; - - Handle(TreeModel_ItemProperties) anItemProperties = anItem->GetProperties(); - for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++) - { - VInspector_TableModelValues* aTableVals = dynamic_cast(aTableValues[aTableIt]); - if (!aTableVals) - continue; - - // default shape by NULL selection - aTableVals->GetPaneShapes (-1, -1, theShapes); + QList aPropertyTables; + myPropertyView->GetActiveTables (aPropertyTables); + if (aPropertyTables.isEmpty()) + return; - for (QModelIndexList::const_iterator anIndicesIt = thePropertyPanelIndices.begin(); anIndicesIt != thePropertyPanelIndices.end(); anIndicesIt++) - { - QModelIndex anIndex = *anIndicesIt; - aTableVals->GetPaneShapes (anIndex.row(), anIndex.column(), theShapes); + ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables + if (!aFirstTable) + return; - if (!anItemProperties.IsNull()) - { - anItemProperties->GetPresentations (anIndex.row(), anIndex.column(), aPropertyPresentations); - } - } - } - } + NCollection_List theSelPresentations; + aFirstTable->GetSelectedPresentations (theTreeItem, theSelPresentations); - if (!aPropertyPresentations.IsEmpty()) + for (NCollection_List::Iterator anIterator (theSelPresentations); anIterator.More(); anIterator.Next()) { - for (NCollection_List::Iterator aPrsIterator (aPropertyPresentations); aPrsIterator.More(); aPrsIterator.Next()) - { - Handle(ViewControl_TransientShape) aShapePrs = Handle(ViewControl_TransientShape)::DownCast (aPrsIterator.Value()); - if (!aShapePrs.IsNull()) - theShapes.Append (aShapePrs->GetShape()); - } + Handle(Convert_TransientShape) aShapePrs = Handle(Convert_TransientShape)::DownCast (anIterator.Value()); + if (!aShapePrs.IsNull()) + theShapes.Append (aShapePrs->GetShape()); } + + //QModelIndexList& thePropertyPanelIndices = aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), + + //QList anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices); + //NCollection_List aPropertyPresentations; + //for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) + //{ + // TreeModel_ItemBasePtr anItem = *anItemIt; + // if (!anItem || anItem->Column() != 0) + // continue; + + // QList aTableValues; + // VInspector_Tools::GetPropertyTableValues (anItem, myPaneCreators, aTableValues); + // if (aTableValues.isEmpty()) + // continue; + + // Handle(TreeModel_ItemProperties) anItemProperties = anItem->GetProperties(); + // for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++) + // { + // VInspector_TableModelValues* aTableVals = dynamic_cast(aTableValues[aTableIt]); + // if (!aTableVals) + // continue; + + // // default shape by NULL selection + // aTableVals->GetPaneShapes (-1, -1, theShapes); + + // for (QModelIndexList::const_iterator anIndicesIt = thePropertyPanelIndices.begin(); anIndicesIt != thePropertyPanelIndices.end(); anIndicesIt++) + // { + // QModelIndex anIndex = *anIndicesIt; + // aTableVals->GetPaneShapes (anIndex.row(), anIndex.column(), theShapes); + + // if (!anItemProperties.IsNull()) + // { + // anItemProperties->GetPresentations (anIndex.row(), anIndex.column(), aPropertyPresentations); + // } + // } + // } + //} + + //if (!aPropertyPresentations.IsEmpty()) + //{ + // for (NCollection_List::Iterator aPrsIterator (aPropertyPresentations); aPrsIterator.More(); aPrsIterator.Next()) + // { + // Handle(Convert_TransientShape) aShapePrs = Handle(Convert_TransientShape)::DownCast (aPrsIterator.Value()); + // if (!aShapePrs.IsNull()) + // theShapes.Append (aShapePrs->GetShape()); + // } + //} } // ======================================================================= @@ -581,7 +632,7 @@ void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theCon if (!myCallBack.IsNull()) myCallBack->SetContext (theContext); - myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer()); + myDisplayPreview->SetContext (theContext); if (isFirst) onExportToMessageView(); @@ -657,8 +708,8 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition } aMenu->addSeparator(); - for (int aTypeId = (int)VInspector_DisplayActionType_DisplayId; aTypeId <= (int)VInspector_DisplayActionType_RemoveId; aTypeId++) - aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((VInspector_DisplayActionType) aTypeId), + for (int aTypeId = (int)View_DisplayActionType_DisplayId; aTypeId <= (int)View_DisplayActionType_RemoveId; aTypeId++) + aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((View_DisplayActionType) aTypeId), SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this)); aMenu->addSeparator(); @@ -730,21 +781,34 @@ void VInspector_Window::onPropertyPanelShown (bool isToggled) // ======================================================================= void VInspector_Window::onPropertyViewSelectionChanged() { + QModelIndex aTreeItemIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0); + TreeModel_ItemBasePtr aTreeItemSelected = TreeModel_ModelBase::GetItemByIndex (aTreeItemIndex); + if (!aTreeItemSelected) + return; + QList aPropertyTables; myPropertyView->GetActiveTables (aPropertyTables); if (aPropertyTables.isEmpty()) return; ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables + NCollection_List aSelPresentations; + aFirstTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations); - QMap> aSelectedIndices; - aFirstTable->GetSelectedIndices (aSelectedIndices); + //Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties(); - ViewControl_TableModel* aTableModel = dynamic_cast(aFirstTable->GetTableView()->model()); - ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues(); + + //QMap> aSelectedIndices; + //aFirstTable->GetSelectedIndices (aSelectedIndices); + + //ViewControl_TableModel* aTableModel = dynamic_cast(aFirstTable->GetTableView()->model()); + //ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues(); QStringList aPointers; - for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + aFirstTable->GetSelectedPointers (aPointers); + + //NCollection_List aSelPresentations; + /*for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) { int aRowId = aSelIt.key(); QList aColIds = aSelIt.value(); @@ -757,19 +821,23 @@ void VInspector_Window::onPropertyViewSelectionChanged() QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString(); if (aData.contains (ViewControl_Tools::GetPointerPrefix().ToCString())) aPointers.append (aData); + + if (anItemProperties) + anItemProperties->GetPresentations (aRowId, aColId, aSelPresentations); } - } + }*/ highlightTreeViewItems (aPointers); - Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); - QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes(); - NCollection_List aSelectedShapes = GetSelectedShapes (aTreeViewSelected); + //Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); + //QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes(); + //NCollection_List aSelectedShapes = GetSelectedShapes (aTreeViewSelected); - GetSelectedPropertyPanelShapes(aTreeViewSelected, - aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), - aSelectedShapes); + //GetSelectedPropertyPanelShapes(aTreeViewSelected, + // aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), + // aSelectedShapes); + //updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); - updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); + myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations); } // ======================================================================= @@ -789,10 +857,24 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&, if (myPropertyPanelWidget->toggleViewAction()->isChecked()) updatePropertyPanelBySelection(); - Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); + QModelIndex aTreeItemIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0); + TreeModel_ItemBasePtr aTreeItemSelected = TreeModel_ModelBase::GetItemByIndex (aTreeItemIndex); + if (!aTreeItemSelected) + return; + + Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties(); + NCollection_List aSelPresentations; + if (anItemProperties) + anItemProperties->GetPresentations (-1, -1, aSelPresentations); + else + GetSelectedShapes (aSelPresentations); + myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations); - NCollection_List aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes()); - updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); + //Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); + + //NCollection_List aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes()); + + //updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); QApplication::restoreOverrideCursor(); } @@ -914,26 +996,7 @@ void VInspector_Window::onExportToShapeView() // ======================================================================= 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); + myDisplayPreview->DisplayDefaultPreview(); UpdateTreeModel(); } @@ -1085,7 +1148,7 @@ void VInspector_Window::updatePropertyPanelBySelection() // purpose : // ======================================================================= -void VInspector_Window::displaySelectedPresentations (const VInspector_DisplayActionType theType) +void VInspector_Window::displaySelectedPresentations (const View_DisplayActionType theType) { VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); if (!aViewModel) @@ -1102,24 +1165,35 @@ void VInspector_Window::displaySelectedPresentations (const VInspector_DisplayAc NCollection_List aSelectedPresentations = GetSelectedPresentations (aSelectionModel); const QModelIndexList& aSelectedIndices = aSelectionModel->selectedIndexes(); - bool aPreviewPresentationShown = !myPreviewPresentation.IsNull(); + bool aPreviewPresentationShown = myDisplayPreview->HasPreview(); // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from // Erased to Displayed container or back aSelectionModel->clear(); // redisplay preview presentation if exists - if (aPreviewPresentationShown && theType == VInspector_DisplayActionType_RedisplayId) + if (aPreviewPresentationShown && theType == View_DisplayActionType_RedisplayId) { - QList anItems = TreeModel_ModelBase::GetSelectedItems (aSelectedIndices); - for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) - { - TreeModel_ItemBasePtr anItem = *anItemIt; - VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (aVItem) - aVItem->UpdatePresentationShape(); - } - NCollection_List aSelectedShapes = GetSelectedShapes (aSelectedIndices); - updatePreviewPresentation(aSelectedShapes, GetSelectedTransformPers()); + // REDISPLAY preview ! + + //QList anItems = TreeModel_ModelBase::GetSelectedItems (aSelectedIndices); + //NCollection_List aSelPresentations; + + //for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) + //{ + // TreeModel_ItemBasePtr anItem = *anItemIt; + // VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); + // if (!aVItem) + // continue; + // aVItem->UpdatePresentationShape(); + + // Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties(); + // if (anItemProperties) + // anItemProperties->GetPresentations (aRowId, aColId, aSelPresentations); + //} + //myDisplayPreview->UpdatePreview (theType, aSelPresentations); + + //NCollection_List aSelectedShapes = GetSelectedShapes (aSelectedIndices); + //updatePreviewPresentation(aSelectedShapes, GetSelectedTransformPers()); } if (aSelectedPresentations.Extent() == 0) @@ -1130,16 +1204,16 @@ void VInspector_Window::displaySelectedPresentations (const VInspector_DisplayAc Handle(AIS_InteractiveObject) aPresentation = anIOIt.Value(); switch (theType) { - case VInspector_DisplayActionType_DisplayId: + case View_DisplayActionType_DisplayId: { aContext->Display(aPresentation, false); aContext->Load(aPresentation, -1); } break; - case VInspector_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break; - case VInspector_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break; - case VInspector_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break; + case View_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break; + case View_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break; + case View_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break; default: break; } } @@ -1238,44 +1312,44 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView() // function : updatePreviewPresentation // purpose : // ======================================================================= -void VInspector_Window::updatePreviewPresentation (const NCollection_List& theShapes, - const Handle(Graphic3d_TransformPers)& thePersistent) -{ - Handle(AIS_InteractiveContext) aContext; - VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); - if (aViewModel) - aContext = aViewModel->GetContext(); - - if (theShapes.IsEmpty()) - { - if (!aContext.IsNull()) - aContext->Remove (myPreviewPresentation, Standard_True); - myPreviewPresentation = NULL; - return; - } - - BRep_Builder aBuilder; - TopoDS_Compound aCompound; - aBuilder.MakeCompound (aCompound); - for (NCollection_List::Iterator anIterator (theShapes); anIterator.More(); anIterator.Next()) - { - aBuilder.Add (aCompound, anIterator.Value()); - } - - if (myPreviewPresentation.IsNull()) - { - myPreviewPresentation = new AIS_Shape (aCompound); - 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); - } -} +//void VInspector_Window::updatePreviewPresentation (const NCollection_List& theShapes, +// const Handle(Graphic3d_TransformPers)& thePersistent) +//{ +// Handle(AIS_InteractiveContext) aContext; +// VInspector_ViewModel* aViewModel = dynamic_cast (myTreeView->model()); +// if (aViewModel) +// aContext = aViewModel->GetContext(); +// +// if (theShapes.IsEmpty()) +// { +// if (!aContext.IsNull()) +// aContext->Remove (myPreviewPresentation, Standard_True); +// myPreviewPresentation = NULL; +// return; +// } +// +// BRep_Builder aBuilder; +// TopoDS_Compound aCompound; +// aBuilder.MakeCompound (aCompound); +// for (NCollection_List::Iterator anIterator (theShapes); anIterator.More(); anIterator.Next()) +// { +// aBuilder.Add (aCompound, anIterator.Value()); +// } +// +// if (myPreviewPresentation.IsNull()) +// { +// myPreviewPresentation = new AIS_Shape (aCompound); +// 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/VInspector/VInspector_Window.hxx b/tools/VInspector/VInspector_Window.hxx index 94c4a2e03d..74dfea9fb1 100644 --- a/tools/VInspector/VInspector_Window.hxx +++ b/tools/VInspector/VInspector_Window.hxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include @@ -33,13 +33,12 @@ #include #include -class VInspector_PreviewParameters; - class ViewControl_MessageDialog; class ViewControl_PropertyView; class VInspector_ToolBar; +class View_DisplayPreview; class View_Window; class QAbstractItemModel; @@ -101,6 +100,8 @@ public: //! \return container of presentations NCollection_List GetSelectedPresentations (QItemSelectionModel* theModel); + void GetSelectedShapes (NCollection_List& theSelPresentations); + //! Returns selected shapes //! \param theModel selection model //! \return container of shapes @@ -109,8 +110,7 @@ public: //! Returns selected shapes //! \param theModel selection model //! \return container of shapes - void GetSelectedPropertyPanelShapes (const QModelIndexList& theTreeViewIndices, - const QModelIndexList& thePropertyPanelIndices, + void GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem, NCollection_List& theShapes); //! Returns the first not zero transform persistent of selected elements @@ -214,7 +214,7 @@ private: //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations //! still belongs to the current context until Remove is called. //! \param theType display action type - void displaySelectedPresentations (const VInspector_DisplayActionType theType); + void displaySelectedPresentations (const View_DisplayActionType theType); //! Set items of the pointers highlighted in tree view //! \param theType display action type @@ -228,12 +228,6 @@ private: //! \return a context of created view. Handle(AIS_InteractiveContext) createView(); - //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes - //!< \param theShape container of shapes - //!< \param thePersistent transform persistent to be used in preview presentation - void updatePreviewPresentation (const NCollection_List& theShapes, - const Handle(Graphic3d_TransformPers)& thePersistent); - private: QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title @@ -254,8 +248,8 @@ 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 + + View_DisplayPreview* myDisplayPreview; //!< class for preview display #ifdef DEBUG_TWO_VIEWS Handle(View_CameraPositionPrs) myCameraPrs; diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx index f4378b68d8..52a32aa45a 100644 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx @@ -71,7 +71,6 @@ QVariant VInspectorPaneAIS_Shape::GetTableData (const Handle(Standard_Transient) default: return QVariant(); } - return QVariant(); } // ======================================================================= @@ -79,7 +78,7 @@ QVariant VInspectorPaneAIS_Shape::GetTableData (const Handle(Standard_Transient) // purpose : // ======================================================================= ViewControl_PaneItem* VInspectorPaneAIS_Shape::GetSelected (const Handle(Standard_Transient)& theObject, - const int theRow, const int theColumn) + const int /*theRow*/, const int /*theColumn*/) { Handle(AIS_Shape) aPrs = GetPresentation (theObject); if (aPrs.IsNull()) diff --git a/tools/View/FILES b/tools/View/FILES index 0d5ff838ac..cb2e073552 100644 --- a/tools/View/FILES +++ b/tools/View/FILES @@ -2,9 +2,14 @@ View.qrc View_CameraPositionPrs.cxx View_CameraPositionPrs.hxx View_ContextType.hxx +View_DisplayActionType.hxx View_Displayer.cxx View_Displayer.hxx +View_DisplayPreview.cxx +View_DisplayPreview.hxx View_PresentationType.hxx +View_PreviewParameters.cxx +View_PreviewParameters.hxx View_ToolActionType.hxx View_ToolBar.cxx View_ToolBar.hxx diff --git a/tools/VInspector/VInspector_DisplayActionType.hxx b/tools/View/View_DisplayActionType.hxx similarity index 60% rename from tools/VInspector/VInspector_DisplayActionType.hxx rename to tools/View/View_DisplayActionType.hxx index 0e39185812..7211c1819a 100644 --- a/tools/VInspector/VInspector_DisplayActionType.hxx +++ b/tools/View/View_DisplayActionType.hxx @@ -13,17 +13,17 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef VInspector_DisplayActionType_H -#define VInspector_DisplayActionType_H +#ifndef View_DisplayActionType_H +#define View_DisplayActionType_H -//! \enum VInspector_DisplayActionType -enum VInspector_DisplayActionType +//! \enum View_DisplayActionType +enum View_DisplayActionType { - VInspector_DisplayActionType_NoneId, //!< No action activated - VInspector_DisplayActionType_DisplayId, //!< Display action - VInspector_DisplayActionType_RedisplayId, //!< Redisplay action - VInspector_DisplayActionType_EraseId, //!< Erase action - VInspector_DisplayActionType_RemoveId //!< Remove action + View_DisplayActionType_NoneId, //!< No action activated + View_DisplayActionType_DisplayId, //!< Display action + View_DisplayActionType_RedisplayId, //!< Redisplay action + View_DisplayActionType_EraseId, //!< Erase action + View_DisplayActionType_RemoveId //!< Remove action }; #endif diff --git a/tools/View/View_DisplayPreview.cxx b/tools/View/View_DisplayPreview.cxx new file mode 100644 index 0000000000..5537faaeea --- /dev/null +++ b/tools/View/View_DisplayPreview.cxx @@ -0,0 +1,127 @@ +// Created on: 2019-07-14 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +View_DisplayPreview::View_DisplayPreview() +{ + myPreviewParameters = new View_PreviewParameters(); +} + +// ======================================================================= +// function : SetContext +// purpose : +// ======================================================================= +void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theContext) +{ + if (myContext == theContext) + return; + + // remove all preview presentations from the previous context, display it in the new + + myContext = theContext; + myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer()); +} + +// ======================================================================= +// function : UpdatePreview +// purpose : +// ======================================================================= +void View_DisplayPreview::UpdatePreview (const View_DisplayActionType theType, + const NCollection_List& thePresentations) +{ + if (myContext.IsNull()) + return; + + if (thePresentations.IsEmpty()) + { + myContext->Remove (myPreviewPresentation, Standard_True); + myPreviewPresentation = NULL; + return; + } + + BRep_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound (aCompound); + for (NCollection_List::Iterator anIterator (thePresentations); anIterator.More(); anIterator.Next()) + { + Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (anIterator.Value()); + if (aShapePtr.IsNull()) + continue; + + aBuilder.Add (aCompound, aShapePtr->GetShape()); + } + + if (myPreviewPresentation.IsNull()) + { + myPreviewPresentation = new AIS_Shape (aCompound); + myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); + + //myPreviewPresentation->SetTransformPersistence(thePersistent); + myContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + } + else + { + Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound); + //myPreviewPresentation->SetTransformPersistence(thePersistent); + myContext->Redisplay (myPreviewPresentation, Standard_True); + } +} + +// ======================================================================= +// function : DisplayDefaultPreview +// purpose : +// ======================================================================= + +void View_DisplayPreview::DisplayDefaultPreview() +{ + if (myContext.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, Convert_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.))); + + Handle(AIS_Shape) aDefaultPreview = new AIS_Shape (aCompound); + aDefaultPreview->SetAttributes (myPreviewParameters->GetDrawer()); + myContext->Display (aDefaultPreview, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); +} diff --git a/tools/View/View_DisplayPreview.hxx b/tools/View/View_DisplayPreview.hxx new file mode 100644 index 0000000000..2d2d6bbf49 --- /dev/null +++ b/tools/View/View_DisplayPreview.hxx @@ -0,0 +1,85 @@ +// Created on: 2019-07-14 +// 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 View_DisplayPreview_H +#define View_DisplayPreview_H + +#include + +#include +#include +#include +#include + +class AIS_InteractiveObject; +class View_PreviewParameters; + +//! \class View_DisplayPreview +//! \brief It is responsible for communication with AIS Interactive Context to: +//! - display/erase presentations; +//! - change display mode of visualized presentations (Shaded or WireFrame mode) +//! +//! It contains containers of visualized presentations to obtain presentations relating only to this displayer. +//! Displayer is connected to AIS Interactive Context +class View_DisplayPreview +{ +public: + + //! Constructor + Standard_EXPORT View_DisplayPreview(); + + //! Destructor + virtual ~View_DisplayPreview() {} + + //! Stores the current context where the presentations will be displayed/erased. + //! Erases previuously displayd presentations if there were some displayed + //! \param theContext a context instance + Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext); + + //!< Returns preview parameters + View_PreviewParameters* GetPreviewParameters() const { return myPreviewParameters; } + + //!< Updates visibility of the presentations for the display type + Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType, + const NCollection_List& thePresentations); + + //!< Returns true if preview presentation is shown + Standard_EXPORT Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); } + + //!< Displays default preview to set visualization properties + Standard_EXPORT void DisplayDefaultPreview(); + +protected: + + //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes + //!< \param theShape container of shapes + //!< \param thePersistent transform persistent to be used in preview presentation + //void updatePreviewPresentation (const NCollection_List& theShapes, + // const Handle(Graphic3d_TransformPers)& thePersistent); + +private: + + //! Returns the current context + const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; } + +private: + + Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works + + View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation + Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object +}; + +#endif diff --git a/tools/VInspector/VInspector_PreviewParameters.cxx b/tools/View/View_PreviewParameters.cxx similarity index 93% rename from tools/VInspector/VInspector_PreviewParameters.cxx rename to tools/View/View_PreviewParameters.cxx index 7b3f80cea3..30d0b4766a 100644 --- a/tools/VInspector/VInspector_PreviewParameters.cxx +++ b/tools/View/View_PreviewParameters.cxx @@ -13,7 +13,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include #include @@ -23,7 +23,7 @@ // function : Constructor // purpose : // ======================================================================= -VInspector_PreviewParameters::VInspector_PreviewParameters() +View_PreviewParameters::View_PreviewParameters() { myDrawer = new Prs3d_Drawer(); @@ -55,7 +55,7 @@ VInspector_PreviewParameters::VInspector_PreviewParameters() // function : SaveState // purpose : // ======================================================================= -void VInspector_PreviewParameters::SaveState (VInspector_PreviewParameters* theParameters, +void View_PreviewParameters::SaveState (View_PreviewParameters* theParameters, QMap& theItems, const QString& thePrefix) { @@ -90,7 +90,7 @@ void VInspector_PreviewParameters::SaveState (VInspector_PreviewParameters* theP // function : RestoreState // purpose : // ======================================================================= -bool VInspector_PreviewParameters::RestoreState (VInspector_PreviewParameters* theParameters, +bool View_PreviewParameters::RestoreState (View_PreviewParameters* theParameters, const QString& theKey, const QString& theValue, const QString& thePrefix) { diff --git a/tools/VInspector/VInspector_PreviewParameters.hxx b/tools/View/View_PreviewParameters.hxx similarity index 82% rename from tools/VInspector/VInspector_PreviewParameters.hxx rename to tools/View/View_PreviewParameters.hxx index e98bea6260..c5931bf666 100644 --- a/tools/VInspector/VInspector_PreviewParameters.hxx +++ b/tools/View/View_PreviewParameters.hxx @@ -13,8 +13,8 @@ // 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 +#ifndef View_PreviewParameters_H +#define View_PreviewParameters_H #include #include @@ -26,17 +26,17 @@ #include #include -//! \class VInspector_PreviewParameters +//! \class View_PreviewParameters //! Container of View tool bar actions -class VInspector_PreviewParameters +class View_PreviewParameters { public: //! Constructor - Standard_EXPORT VInspector_PreviewParameters (); + Standard_EXPORT View_PreviewParameters (); //! Destructor - virtual ~VInspector_PreviewParameters() {} + virtual ~View_PreviewParameters() {} //! Returns main control const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; } @@ -47,7 +47,7 @@ public: //! \param theTreeView a view instance //! \param theItems [out] properties //! \param thePrefix peference item prefix - Standard_EXPORT static void SaveState (VInspector_PreviewParameters* theParameters, + Standard_EXPORT static void SaveState (View_PreviewParameters* theParameters, QMap& theItems, const QString& thePrefix = QString()); //! Restore state of three view by a container @@ -56,7 +56,7 @@ public: //! \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, + Standard_EXPORT static bool RestoreState (View_PreviewParameters* theParameters, const QString& theKey, const QString& theValue, const QString& thePrefix = QString()); diff --git a/tools/View/View_Widget.cxx b/tools/View/View_Widget.cxx index 3662857967..26a4f65577 100644 --- a/tools/View/View_Widget.cxx +++ b/tools/View/View_Widget.cxx @@ -78,9 +78,9 @@ View_Widget::View_Widget (QWidget* theParent, { myViewer->InitViewer (myViewer->CreateStandardViewer()); - Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())); - aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); - myViewer->GetContext()->Display (aTrihedron, Standard_True); + //Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())); + //aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); + //myViewer->GetContext()->Display (aTrihedron, Standard_True); } setAttribute (Qt::WA_PaintOnScreen); diff --git a/tools/ViewControl/FILES b/tools/ViewControl/FILES index 8c21c99ce9..eee2dd0d17 100644 --- a/tools/ViewControl/FILES +++ b/tools/ViewControl/FILES @@ -26,6 +26,4 @@ ViewControl_TableModelValuesDefault.cxx ViewControl_TableModelValuesDefault.hxx ViewControl_Tools.cxx ViewControl_Tools.hxx -ViewControl_TransientShape.cxx -ViewControl_TransientShape.hxx ViewControl_TreeView.hxx diff --git a/tools/ViewControl/ViewControl_PropertiesStream.cxx b/tools/ViewControl/ViewControl_PropertiesStream.cxx index fd5ac5a3f0..a07c7ffe27 100644 --- a/tools/ViewControl/ViewControl_PropertiesStream.cxx +++ b/tools/ViewControl/ViewControl_PropertiesStream.cxx @@ -14,7 +14,6 @@ // commercial license or contractual agreement. #include -#include #include @@ -108,8 +107,8 @@ void ViewControl_PropertiesStream::GetPresentations (const int theRow, TCollection_AsciiString aStrValue = aValue.toString().toStdString().c_str(); gp_XYZ aPoint; - if (!aPoint.FromString (aStrValue)) + if (!aPoint.Init (Standard_SStream (aStrValue.ToCString()))) return; - thePresentations.Append (new ViewControl_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); + //thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); } diff --git a/tools/ViewControl/ViewControl_Table.cxx b/tools/ViewControl/ViewControl_Table.cxx index fee84d2c06..673d9f9de6 100644 --- a/tools/ViewControl/ViewControl_Table.cxx +++ b/tools/ViewControl/ViewControl_Table.cxx @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -106,7 +107,7 @@ void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues) // purpose : // ======================================================================= -void ViewControl_Table::GetSelectedIndices (QMap>& theSelectedIndices) +void ViewControl_Table::GetSelectedIndices (QMap>& theSelectedIndices) const { QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes(); @@ -131,3 +132,64 @@ QString ViewControl_Table::SeparatorData() { return ViewControl_Tools::TableSeparator(); } + +// ======================================================================= +// function : GetSelectedPresentations +// purpose : +// ======================================================================= + +void ViewControl_Table::GetSelectedPresentations (const TreeModel_ItemBasePtr& theTreeItem, + NCollection_List& theSelPresentations) const +{ + Handle(TreeModel_ItemProperties) anItemProperties = theTreeItem->GetProperties(); + if (anItemProperties.IsNull()) + return; + + QMap> aSelectedIndices; + GetSelectedIndices (aSelectedIndices); + + for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + int aRowId = aSelIt.key(); + QList aColIds = aSelIt.value(); + for (int aColId = 0; aColId < aColIds.size(); aColId++) + { + int aSelectedColId = aColIds[aColId]; + if (aSelectedColId != 1) + continue; + + if (anItemProperties) + anItemProperties->GetPresentations (aRowId, aSelectedColId, theSelPresentations); + } + } +} + +// ======================================================================= +// function : GetSelectedPointers +// purpose : +// ======================================================================= + +void ViewControl_Table::GetSelectedPointers (QStringList& thePointers) const +{ + QMap> aSelectedIndices; + GetSelectedIndices (aSelectedIndices); + + ViewControl_TableModel* aTableModel = dynamic_cast(GetTableView()->model()); + ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues(); + + for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + int aRowId = aSelIt.key(); + QList aColIds = aSelIt.value(); + for (int aColId = 0; aColId < aColIds.size(); aColId++) + { + int aSelectedColId = aColIds[aColId]; + if (aSelectedColId != 1) + continue; + + QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString(); + if (aData.contains (ViewControl_Tools::GetPointerPrefix().ToCString())) + thePointers.append (aData); + } + } +} \ No newline at end of file diff --git a/tools/ViewControl/ViewControl_Table.hxx b/tools/ViewControl/ViewControl_Table.hxx index 336f277441..3c7611ea51 100644 --- a/tools/ViewControl/ViewControl_Table.hxx +++ b/tools/ViewControl/ViewControl_Table.hxx @@ -16,8 +16,13 @@ #ifndef ViewControl_Table_H #define ViewControl_Table_H +#include + #include #include +#include + +#include #include #include @@ -68,7 +73,14 @@ public: //! Retuns model indices of the selected cells in table view //! \param theSelectedIndices [out] a container of indices: row to list of columns - Standard_EXPORT void GetSelectedIndices (QMap>& aSelectedIndices); + Standard_EXPORT void GetSelectedIndices (QMap>& aSelectedIndices) const; + + //! Returns presentations by the property item of tree item for the selected cells + Standard_EXPORT void GetSelectedPresentations (const TreeModel_ItemBasePtr& theTreeItem, + NCollection_List& theSelPresentations) const; + + //! Returns pointers from selected cells + Standard_EXPORT void GetSelectedPointers (QStringList& thePointers) const; //! Returns text of separation row in table //! \return string value diff --git a/tools/ViewControl/ViewControl_TableModelValues.cxx b/tools/ViewControl/ViewControl_TableModelValues.cxx index bccb3d24ec..166aedc51b 100644 --- a/tools/ViewControl/ViewControl_TableModelValues.cxx +++ b/tools/ViewControl/ViewControl_TableModelValues.cxx @@ -28,7 +28,7 @@ int ViewControl_TableModelValues::ColumnCount (const QModelIndex&) const { if (!GetProperties().IsNull()) - return GetProperties()->GetTableColumnCount(); + return GetProperties()->ColumnCount(); return 0; } @@ -42,7 +42,7 @@ int ViewControl_TableModelValues::ColumnCount (const QModelIndex&) const int ViewControl_TableModelValues::RowCount (const QModelIndex&) const { if (!GetProperties().IsNull()) - return GetProperties()->GetTableRowCount(); + return GetProperties()->RowCount(); return 0; } @@ -56,7 +56,7 @@ QVariant ViewControl_TableModelValues::Data (const int theRow, const int theColu { if (!GetProperties().IsNull()) { - QVariant aValue = GetProperties()->GetTableData (theRow, theColumn, theRole); + QVariant aValue = GetProperties()->Data (theRow, theColumn, theRole); if (aValue.isValid()) return aValue; } diff --git a/tools/ViewControl/ViewControl_Tools.cxx b/tools/ViewControl/ViewControl_Tools.cxx index 273f805a5c..3d15c483ae 100644 --- a/tools/ViewControl/ViewControl_Tools.cxx +++ b/tools/ViewControl/ViewControl_Tools.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -100,10 +101,11 @@ void ViewControl_Tools::SetDefaultHeaderSections(QTableView* theTableView, const // ======================================================================= TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo) { - if (thePointer.IsNull()) + return TCollection::GetPointerInfo (thePointer); + /*if (thePointer.IsNull()) return TCollection_AsciiString(); - return GetPointerInfo(thePointer.operator->(), isShortInfo); + return GetPointerInfo(thePointer.operator->(), isShortInfo);*/ } // ======================================================================= @@ -112,6 +114,8 @@ TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const Handle(Standard // ======================================================================= TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const void* thePointer, const bool isShortInfo) { + return TCollection::GetPointerInfo (thePointer); + /* std::ostringstream aPtrStr; aPtrStr << thePointer; if (!isShortInfo) @@ -127,7 +131,7 @@ TCollection_AsciiString ViewControl_Tools::GetPointerInfo (const void* thePointe return anInfoPtr; } } - return aPtrStr.str().c_str(); + return aPtrStr.str().c_str();*/ } // ======================================================================= @@ -267,105 +271,3 @@ 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 a701d4df0a..8af7a1dd8f 100644 --- a/tools/ViewControl/ViewControl_Tools.hxx +++ b/tools/ViewControl/ViewControl_Tools.hxx @@ -145,22 +145,6 @@ 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