From dea3e24f6861feea88a76bbd6914a962d463ebdb Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 19 Nov 2020 18:43:44 +0300 Subject: [PATCH] 0031362: Inspectors - MessageView plugin for message alerts (cherry picked from commit 09254e6ab360b059762ac2d18f0a607ac14b8591) --- tools/Convert/Convert_Tools.cxx | 79 +- tools/Convert/Convert_Tools.hxx | 10 +- tools/DFBrowser/DFBrowser.qrc | 6 + tools/DFBrowser/DFBrowser_TreeModel.cxx | 2 +- .../icons/attribute.png | Bin .../icons/attribute_40x40.png | Bin .../icons/export_shape.png | Bin .../icons/folder_export.png | Bin .../icons/named_shape.png | Bin .../icons/named_shape_40x40.png | Bin tools/DFBrowserPane/DFBrowserPane.qrc | 13 - .../DFBrowserPane_TDataStdTreeNodeModel.cxx | 2 +- tools/DFBrowserPane/FILES | 1 - tools/DFBrowserPane/icons/imageres_4.ico | Bin 168098 -> 0 bytes tools/DFBrowserPane/icons/imageres_5.ico | Bin 168717 -> 0 bytes tools/DFBrowserPane/icons/label.png | Bin 370 -> 0 bytes .../icons/label_folder_16x16.png | Bin 181 -> 0 bytes .../icons/label_folder_20x20.png | Bin 185 -> 0 bytes .../icons/label_folder_40x40.png | Bin 386 -> 0 bytes .../icons/label_folder_expand_16x16.png | Bin 257 -> 0 bytes .../icons/label_folder_expand_20x20.png | Bin 300 -> 0 bytes .../icons/label_folder_expand_40x40.png | Bin 601 -> 0 bytes tools/MessageModel/FILES | 16 + tools/MessageModel/MessageModel.qrc | 6 + .../MessageModel/MessageModel_ActionType.hxx | 33 + tools/MessageModel/MessageModel_Actions.cxx | 269 +++++ tools/MessageModel/MessageModel_Actions.hxx | 98 ++ tools/MessageModel/MessageModel_ItemAlert.cxx | 352 +++++++ tools/MessageModel/MessageModel_ItemAlert.hxx | 137 +++ tools/MessageModel/MessageModel_ItemBase.cxx | 47 + tools/MessageModel/MessageModel_ItemBase.hxx | 56 ++ .../MessageModel/MessageModel_ItemReport.cxx | 233 +++++ .../MessageModel/MessageModel_ItemReport.hxx | 117 +++ tools/MessageModel/MessageModel_ItemRoot.cxx | 96 ++ tools/MessageModel/MessageModel_ItemRoot.hxx | 126 +++ tools/MessageModel/MessageModel_Tools.cxx | 59 ++ tools/MessageModel/MessageModel_Tools.hxx | 53 + tools/MessageModel/MessageModel_TreeModel.cxx | 213 ++++ tools/MessageModel/MessageModel_TreeModel.hxx | 105 ++ tools/MessageModel/icons/item_shape.png | Bin 0 -> 614 bytes tools/MessageModel/icons/item_shape.svg | 122 +++ .../MessageModel/icons/item_streamValues.png | Bin 0 -> 347 bytes .../MessageModel/icons/item_streamValues.svg | 103 ++ tools/MessageView/FILES | 8 + tools/MessageView/MessageView_ActionsTest.cxx | 485 +++++++++ tools/MessageView/MessageView_ActionsTest.hxx | 85 ++ .../MessageView/MessageView_Communicator.cxx | 26 + .../MessageView/MessageView_Communicator.hxx | 66 ++ .../MessageView_VisibilityState.cxx | 150 +++ .../MessageView_VisibilityState.hxx | 99 ++ tools/MessageView/MessageView_Window.cxx | 941 ++++++++++++++++++ tools/MessageView/MessageView_Window.hxx | 209 ++++ tools/ShapeView/ShapeView_Window.cxx | 137 ++- tools/ShapeView/ShapeView_Window.hxx | 9 + tools/TInspector/TInspector_Communicator.cxx | 53 +- tools/TInspector/TInspector_Communicator.hxx | 3 + tools/TInspectorEXE/TInspectorEXE.cxx | 20 +- tools/TKMessageModel/CMakeLists.txt | 5 + tools/TKMessageModel/EXTERNLIB | 10 + tools/TKMessageModel/FILES | 2 + tools/TKMessageModel/PACKAGES | 1 + tools/TKMessageView/CMakeLists.txt | 5 + tools/TKMessageView/EXTERNLIB | 13 + tools/TKMessageView/FILES | 2 + tools/TKMessageView/PACKAGES | 1 + tools/TKVInspector/EXTERNLIB | 1 + tools/TKView/EXTERNLIB | 1 + tools/ToolsDraw/ToolsDraw.cxx | 6 +- tools/TreeModel/TreeModel_ColumnType.hxx | 3 +- tools/TreeModel/TreeModel_ContextMenu.cxx | 2 +- tools/TreeModel/TreeModel_ItemBase.cxx | 4 +- tools/TreeModel/TreeModel_ItemBase.hxx | 5 +- tools/TreeModel/TreeModel_ItemProperties.cxx | 35 +- tools/TreeModel/TreeModel_ItemProperties.hxx | 13 +- tools/TreeModel/TreeModel_ModelBase.cxx | 77 +- tools/TreeModel/TreeModel_ModelBase.hxx | 24 +- tools/TreeModel/TreeModel_Tools.cxx | 37 +- tools/VInspector/FILES | 6 + tools/VInspector/VInspector_ItemBase.cxx | 2 +- tools/VInspector/VInspector_ItemBase.hxx | 5 - tools/VInspector/VInspector_ItemContext.cxx | 10 +- .../VInspector_ItemContextProperties.cxx | 68 ++ .../VInspector_ItemContextProperties.hxx | 70 ++ .../VInspector_ItemPresentableObject.hxx | 2 +- ...VInspector_ItemSelectMgrViewerSelector.cxx | 105 ++ ...VInspector_ItemSelectMgrViewerSelector.hxx | 85 ++ tools/VInspector/VInspector_ItemV3dViewer.cxx | 105 ++ tools/VInspector/VInspector_ItemV3dViewer.hxx | 85 ++ tools/VInspector/VInspector_ViewModel.cxx | 4 +- .../VInspector_ViewModelHistory.cxx | 14 +- tools/VInspector/VInspector_Window.cxx | 54 +- tools/View/View_Displayer.cxx | 23 +- tools/View/View_PreviewParameters.cxx | 2 +- tools/ViewControl/FILES | 2 + .../ViewControl_PropertiesDialog.cxx | 65 ++ .../ViewControl_PropertiesDialog.hxx | 54 + 96 files changed, 5473 insertions(+), 180 deletions(-) rename tools/{DFBrowserPane => DFBrowser}/icons/attribute.png (100%) rename tools/{DFBrowserPane => DFBrowser}/icons/attribute_40x40.png (100%) rename tools/{DFBrowserPane => DFBrowser}/icons/export_shape.png (100%) rename tools/{DFBrowserPane => DFBrowser}/icons/folder_export.png (100%) rename tools/{DFBrowserPane => DFBrowser}/icons/named_shape.png (100%) rename tools/{DFBrowserPane => DFBrowser}/icons/named_shape_40x40.png (100%) delete mode 100644 tools/DFBrowserPane/DFBrowserPane.qrc delete mode 100644 tools/DFBrowserPane/icons/imageres_4.ico delete mode 100644 tools/DFBrowserPane/icons/imageres_5.ico delete mode 100644 tools/DFBrowserPane/icons/label.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_16x16.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_20x20.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_40x40.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_expand_16x16.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_expand_20x20.png delete mode 100644 tools/DFBrowserPane/icons/label_folder_expand_40x40.png create mode 100644 tools/MessageModel/FILES create mode 100644 tools/MessageModel/MessageModel.qrc create mode 100644 tools/MessageModel/MessageModel_ActionType.hxx create mode 100644 tools/MessageModel/MessageModel_Actions.cxx create mode 100644 tools/MessageModel/MessageModel_Actions.hxx create mode 100644 tools/MessageModel/MessageModel_ItemAlert.cxx create mode 100644 tools/MessageModel/MessageModel_ItemAlert.hxx create mode 100644 tools/MessageModel/MessageModel_ItemBase.cxx create mode 100644 tools/MessageModel/MessageModel_ItemBase.hxx create mode 100644 tools/MessageModel/MessageModel_ItemReport.cxx create mode 100644 tools/MessageModel/MessageModel_ItemReport.hxx create mode 100644 tools/MessageModel/MessageModel_ItemRoot.cxx create mode 100644 tools/MessageModel/MessageModel_ItemRoot.hxx create mode 100644 tools/MessageModel/MessageModel_Tools.cxx create mode 100644 tools/MessageModel/MessageModel_Tools.hxx create mode 100644 tools/MessageModel/MessageModel_TreeModel.cxx create mode 100644 tools/MessageModel/MessageModel_TreeModel.hxx create mode 100644 tools/MessageModel/icons/item_shape.png create mode 100644 tools/MessageModel/icons/item_shape.svg create mode 100644 tools/MessageModel/icons/item_streamValues.png create mode 100644 tools/MessageModel/icons/item_streamValues.svg create mode 100644 tools/MessageView/FILES create mode 100644 tools/MessageView/MessageView_ActionsTest.cxx create mode 100644 tools/MessageView/MessageView_ActionsTest.hxx create mode 100644 tools/MessageView/MessageView_Communicator.cxx create mode 100644 tools/MessageView/MessageView_Communicator.hxx create mode 100644 tools/MessageView/MessageView_VisibilityState.cxx create mode 100644 tools/MessageView/MessageView_VisibilityState.hxx create mode 100644 tools/MessageView/MessageView_Window.cxx create mode 100644 tools/MessageView/MessageView_Window.hxx create mode 100644 tools/TKMessageModel/CMakeLists.txt create mode 100644 tools/TKMessageModel/EXTERNLIB create mode 100644 tools/TKMessageModel/FILES create mode 100644 tools/TKMessageModel/PACKAGES create mode 100644 tools/TKMessageView/CMakeLists.txt create mode 100644 tools/TKMessageView/EXTERNLIB create mode 100644 tools/TKMessageView/FILES create mode 100644 tools/TKMessageView/PACKAGES create mode 100644 tools/VInspector/VInspector_ItemContextProperties.cxx create mode 100644 tools/VInspector/VInspector_ItemContextProperties.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx create mode 100644 tools/VInspector/VInspector_ItemV3dViewer.cxx create mode 100644 tools/VInspector/VInspector_ItemV3dViewer.hxx create mode 100644 tools/ViewControl/ViewControl_PropertiesDialog.cxx create mode 100644 tools/ViewControl/ViewControl_PropertiesDialog.hxx diff --git a/tools/Convert/Convert_Tools.cxx b/tools/Convert/Convert_Tools.cxx index 411fb1fd40..67803f2494 100644 --- a/tools/Convert/Convert_Tools.cxx +++ b/tools/Convert/Convert_Tools.cxx @@ -1,6 +1,6 @@ -// Created on: 2020-01-25 +// Created on: 2017-06-16 // Created by: Natalia ERMOLAEVA -// Copyright (c) 2020 OPEN CASCADE SAS +// Copyright (c) 2017 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -18,17 +18,17 @@ #include #include -#include -#include -#include -#include -#include #include #include #include -#include #include +#include +#include +#include #include +#include +#include +#include // ======================================================================= // function : ReadShape @@ -44,7 +44,7 @@ TopoDS_Shape Convert_Tools::ReadShape (const TCollection_AsciiString& theFileNam } //======================================================================= -//function : ConvertStreamToPresentations +//function : CreateShape //purpose : //======================================================================= void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream& theSStream, @@ -202,11 +202,61 @@ Standard_Boolean Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox, Topo //======================================================================= Standard_Boolean Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax, TopoDS_Shape& theShape) { - BRepPreviewAPI_MakeBox aMakeBox; - aMakeBox.Init (thePntMin, thePntMax); - theShape = aMakeBox.Shape(); + 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(); - return Standard_True; + 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)); + theShape = aCompound; + return Standard_True; + } + + 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)); + + theShape = aCompound; + return Standard_True; + } + else + { + BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax); + theShape = aBoxBuilder.Shape(); + return Standard_True; + } } //======================================================================= @@ -218,6 +268,7 @@ void Convert_Tools::CreatePresentation (const Handle(Geom_Plane)& thePlane, { Handle(AIS_Plane) aPlanePrs = new AIS_Plane (thePlane); + // TODO - default fields to be defined in another place aPlanePrs->Attributes()->SetPlaneAspect (new Prs3d_PlaneAspect()); Handle (Prs3d_PlaneAspect) aPlaneAspect = aPlanePrs->Attributes()->PlaneAspect(); aPlaneAspect->SetPlaneLength (100, 100); @@ -248,11 +299,13 @@ void Convert_Tools::CreatePresentation (const gp_Trsf& theTrsf, return; Handle(AIS_Shape) aSourcePrs = new AIS_Shape (aBoxShape); + // TODO - default fields to be defined in another place aSourcePrs->SetColor (Quantity_NOC_WHITE); aSourcePrs->SetTransparency (0.5); thePresentations.Append (aSourcePrs); Handle(AIS_Shape) aTransformedPrs = new AIS_Shape (aBoxShape); + // TODO - default fields to be defined in another place aTransformedPrs->SetColor (Quantity_NOC_TOMATO); aTransformedPrs->SetTransparency (0.5); aTransformedPrs->SetLocalTransformation (theTrsf); diff --git a/tools/Convert/Convert_Tools.hxx b/tools/Convert/Convert_Tools.hxx index 728c096c74..bdcd05c09b 100644 --- a/tools/Convert/Convert_Tools.hxx +++ b/tools/Convert/Convert_Tools.hxx @@ -1,6 +1,6 @@ -// Created on: 2020-01-25 +// Created on: 2017-06-16 // Created by: Natalia ERMOLAEVA -// Copyright (c) 2020 OPEN CASCADE SAS +// Copyright (c) 2017 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -42,7 +42,7 @@ class Geom_Plane; class Geom_Transformation; //! \class Convert_Tools -//! \brief The tool that gives auxiliary methods for qt elements manipulation. +//! \brief The tool that gives auxiliary methods for qt elements manipulation class Convert_Tools { public: @@ -81,9 +81,7 @@ public: //! \param thePntMin minimum point on the bounding box //! \param thePntMax maximum point on the bounding box //! \return created shape - Standard_EXPORT static Standard_Boolean CreateBoxShape (const gp_Pnt& thePntMin, - const gp_Pnt& thePntMax, - TopoDS_Shape& theShape); + Standard_EXPORT static Standard_Boolean CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax, TopoDS_Shape& theShape); //! Creates presentation AIS_Plane //! \param thePlane source plane diff --git a/tools/DFBrowser/DFBrowser.qrc b/tools/DFBrowser/DFBrowser.qrc index 9670e6ac89..e1f167f061 100644 --- a/tools/DFBrowser/DFBrowser.qrc +++ b/tools/DFBrowser/DFBrowser.qrc @@ -1,8 +1,14 @@ + icons/attribute.png + icons/attribute_40x40.png + icons/export_shape.png + icons/folder_export.png icons/item_type_folder.png icons/item_type_folder_40x40.png icons/level_change.png + icons/named_shape.png + icons/named_shape_40x40.png icons/search.png icons/search_cancel.png icons/treeline_backward.png diff --git a/tools/DFBrowser/DFBrowser_TreeModel.cxx b/tools/DFBrowser/DFBrowser_TreeModel.cxx index 23ab2c2aa8..70857bc046 100644 --- a/tools/DFBrowser/DFBrowser_TreeModel.cxx +++ b/tools/DFBrowser/DFBrowser_TreeModel.cxx @@ -49,7 +49,7 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent) // ======================================================================= void DFBrowser_TreeModel::InitColumns() { - SetHeaderItem (0, TreeModel_HeaderSection ("Name")); + setHeaderItem (0, TreeModel_HeaderSection ("Name")); } // ======================================================================= diff --git a/tools/DFBrowserPane/icons/attribute.png b/tools/DFBrowser/icons/attribute.png similarity index 100% rename from tools/DFBrowserPane/icons/attribute.png rename to tools/DFBrowser/icons/attribute.png diff --git a/tools/DFBrowserPane/icons/attribute_40x40.png b/tools/DFBrowser/icons/attribute_40x40.png similarity index 100% rename from tools/DFBrowserPane/icons/attribute_40x40.png rename to tools/DFBrowser/icons/attribute_40x40.png diff --git a/tools/DFBrowserPane/icons/export_shape.png b/tools/DFBrowser/icons/export_shape.png similarity index 100% rename from tools/DFBrowserPane/icons/export_shape.png rename to tools/DFBrowser/icons/export_shape.png diff --git a/tools/DFBrowserPane/icons/folder_export.png b/tools/DFBrowser/icons/folder_export.png similarity index 100% rename from tools/DFBrowserPane/icons/folder_export.png rename to tools/DFBrowser/icons/folder_export.png diff --git a/tools/DFBrowserPane/icons/named_shape.png b/tools/DFBrowser/icons/named_shape.png similarity index 100% rename from tools/DFBrowserPane/icons/named_shape.png rename to tools/DFBrowser/icons/named_shape.png diff --git a/tools/DFBrowserPane/icons/named_shape_40x40.png b/tools/DFBrowser/icons/named_shape_40x40.png similarity index 100% rename from tools/DFBrowserPane/icons/named_shape_40x40.png rename to tools/DFBrowser/icons/named_shape_40x40.png diff --git a/tools/DFBrowserPane/DFBrowserPane.qrc b/tools/DFBrowserPane/DFBrowserPane.qrc deleted file mode 100644 index 16c14c514c..0000000000 --- a/tools/DFBrowserPane/DFBrowserPane.qrc +++ /dev/null @@ -1,13 +0,0 @@ - - - icons/attribute.png - icons/attribute_40x40.png - icons/export_shape.png - icons/folder_export.png - icons/label.png - icons/label_folder_16x16.png - icons/label_folder_40x40.png - icons/named_shape.png - icons/named_shape_40x40.png - - diff --git a/tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx b/tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx index 4f8a4847f0..0d6b98f12f 100644 --- a/tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx +++ b/tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx @@ -37,7 +37,7 @@ DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObjec // ======================================================================= void DFBrowserPane_TDataStdTreeNodeModel::InitColumns() { - SetHeaderItem (0, TreeModel_HeaderSection ("Name")); + setHeaderItem (0, TreeModel_HeaderSection ("Name")); } // ======================================================================= diff --git a/tools/DFBrowserPane/FILES b/tools/DFBrowserPane/FILES index de80d10eb0..1eac7a6433 100644 --- a/tools/DFBrowserPane/FILES +++ b/tools/DFBrowserPane/FILES @@ -1,4 +1,3 @@ -DFBrowserPane.qrc DFBrowserPane_AttributePane.cxx DFBrowserPane_AttributePane.hxx DFBrowserPane_AttributePaneAPI.hxx diff --git a/tools/DFBrowserPane/icons/imageres_4.ico b/tools/DFBrowserPane/icons/imageres_4.ico deleted file mode 100644 index 1c823b1e9e30916a6a087bf553b5fbbd11d841db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168098 zcmeI535-?M8OOi(W<@&-6$H^RuPy~siep_MrZOXuDyhZMwpLP%qsyZidq|IM5^_ndd` zS$_9B|8wq6l%V01P80j}H1-0bOAv8eyq*mV){eB2h--4u8-xPIoeed{9 zQmZd-&-FWN3FpT(PK#PIOVMs+X;(evKgWyTl%+dE!(JGmGv7K)o&U+urJKK|IXnBb zAK`%j2$Um%OeRx~%|e?%00aUONW`>wtxinE%bAXAH4=&17?uRecO|bT0RI@wuNL;_ z(fkPZ2m6bj0Qw*LpEm-~pXhsEEyh30KfQH7jQ=?Pi9vuc{(J0x=zr*c=zozDfc`*# zyb-|hN93K4GerOMW_^510>-}>46yL_$G4?;T4LG%ReV*+V+CR;zb2_%)bdt==*t(4 z_g;ah%hww3xdIWFpKZL?3Pf7IzVRL_5M}wfjrUf8D9cw$H2iZD0hAw|{2S0KLGX7b z0Q-aeMMVJp&rHC%_eDGZH<#`{4@Uow%KF7ouX(}#cP0S)gZ)KCz})+wf6l!R;}7&F zs@{k35Bg&!0R3?$0R4gfL`A^d`!N4;?tPg5K!2j@eWg18u~Lob;@taRbY)rP6DCQ)2Z6FA!0J?%?LwmpL%{01l)pIVdWU|5M2>eh#UOthFj_SDfRE!<1oSUQ zJhk8hKF$Q3e}(;kk23-1UtvGs<4nN$SJ)5uI1_OGwZ!eG#^qu2kjF=^PqT;0-^0`D zVe-#DlkD&~eDM7B4_w<95IFyA<(0D)wgm*v-*6Jd?kE!ZtDwNgAfvD!0}w+Hd<;Mg zLGUpEF$BTK0K^ak9|I6W5PS?k3_FM-JJP~4-HEbcAFI#D@s5ch}6eJbt+&#rgr*4uRJExL8S89kdG>uN740}gBk zQ7qy<Zzi~PLs1V3pxuou{inE?6+`iI#n>|Q7&tNpL7oByOS79%(7qeB^$G~1-FZR}9{ss0@YWAX^fcacE zG!?<3AuxEYReN2Y65(;ZS8YZYUq;Dbor-}&n{HpU=+>Kb>vg*IDy%C;Tu=_#PUx}U z>C%h)9NO8X*=6r@Xy$-i#0emI5(w{OlT_e?K*bPXxu}@7x;50##MLSHU z+Z*now-16}j^(HU*pI!z7=D5MzpJ` zZ9h0l8+RbKH>jLt5d0(o*iSA2^dHL(V~CX2WB&dh_!&@H24mzmn6;<1TRD6EmQ1SU;!*cWO_Nx{z&J(w?>tvTbPdtPJauG*M@`y?I zJe>G`$H}iAR=(YVXW=9)_#jYz1XwDHv{9}@y`kQTdgnz7o!kuRb9sSJE)Qb}e2heL z!~Xcx)fjJzckGX~;=cFXTgn~NtKyNffrs=tO+b3x{?)`-YNznQ2Yhnu!F9kkpIOmw zU$}Mka7o^WGwAmVE9dD^G5e&|kGj-)Qd{x*cAUj=s(g2gJWg$|)!Bp4WvR{DajG~z zo$`J^zA>r8gjEnIR|2ser#g&UIV=-(c8gRdH968rPT(R*+A~Y^R!(lpQr7L z-%>=rozPTYAhD1JzN9) zo_{|27w1^;Px3y^o{_isUD@T*c<{Sv|3%Bkx`XL@klYjgePzDD|M*qiZ2?>hZ_^aS z$#TU!WhA>+c5dT`gz1WnS#YxK{Z*KIP&QwFK#}k zb9N#xq5sY7Qtae7plCmbmBla)h;Q16bFboiHaMP&3ljGp<{4HG4zmpFjP2qQN!8XXxNlD4>zB< zt~qtq{3Xk49-wd4bTl+{e`CZs=Zzda^qVs`99rA+h!&L&8T|#n9LGte(KPu_udv!D{9{D-TGqN3AFg|OS3zdZdo>z zZr(P#^C_|Nmj~-s*PeOyz%hyRvX8c$vFfY6Z`4!&*3pmOe%X?)AJC>J=HAk<^XmT7 zlJssLZ~QZ{P4}OUol&*=ST3XYuG`ks4s<@C#6I@%-C~Pr2fr_JJ3WzZ#h(WPtFnD) z{?C86|G=@&9yx**>mPemd)&3_C!{aA=nn@G52`U)=C5tZ)zg&_LFmlU)0?G=Je`2udE+;)25N19=&Kt^TqVeztbD$5B=5R*ZzFR z;&FSv_%gHguS=i5>VJRhc}RSsaQQFZKdbZkhi|y&o;{~;xZ=acnY#`Qz5MU*E@}->T2LKU`T= zz30`@a^s<1uxCuRQvMO zBpt;2S5|FYJ^jl=^<7UN_w?>7+P-f)( z9>)7PfCU6V00ck)1V8`;K)@e?9zFtxi{|Dzf8^EF%%0B`SF}^?F9^FRwgG>&|3|?x zNFLx1{sq=Q=uctCAMgkNN}dD3{$c;H{~(jc2)4oe6Z22ZKXLvc0x1cU1@s5{1O0*i z1QL%3HiG^@f1p3mp9rKRP!`Z1=nwP<`V&YzBG?G}1O0*iKz|~Tl0aENf1p3mALvgY z@rYm}=nwP<`UCxmKuQ8-0sVpgK!2b=fy5(%ji5i!ALtMCCju!6lm+w$`UCx`SpAv4 z`D@kwdos%c=||X&Dp-H`U5%2x^z*+DDv-ah`Qd8^By*#m-+fSF{4H$W$X|r>w+||W zzl+TmZXZ+te~&g_n0-(I{FUb$xt)Rhu=5+Y?ZMx9zqs)W`#bo9f6T|ffpkaeRapCW z+aC50`-lCP_4yy@PZ7M|LF&0*-%Y>6{to?z{zLzv|8}|*R$tt|F*+0#$SxT7=L5a-eP#KBJ>~n5BNMa5C8!X009sH0T2KIK_C;=vPa`t#TjCqsGK+?bo*3TjNHG}rCV>) zt+(jbo3O5QjWXlFW)Q_Pmf3W$Th1;)DgIB?J4^BK4+KB}1V8`;@<*Ut&VyRDBOesG z+WljrzW+r}On4jl+N6I0sA2vt} z0w4eaAOHeB2@HN~ME}hqkL$f^VO<$ck9GcPPhmK;>B?=vZc?SXT_UXgFj$ zp~rrwOE13j)6Ooa#_KR?M21VL_Wvu7Ax%y$n0PQcz`Jd~4m$rfZAC3U*ANF5_ z=l{_EJ&b)q1H&%p|LFhd|3zm5&_C#(CmVqNha-UTujsTdd#+#1Z`@qCy_F(B*${d1pV$g#E<{jmEV+k*fIlr4emD+BCSl$JMX z14+5~by|C>G(RB+%JTE=_Nx{z-V-4{u-wT`z9%Am5(lt=Kt2c*!<;EhI}1ENR*r*E z|AHN#f`4J34+Vel5A*ym><9J(`w20D!2BoF+ynXp{ek|Jxc>BH#3__uOM&!r*7m;4 z$*&%k*EV*u4h3sN0qSq_+)uDJ6rlcf&+%zSF4w~C_H9H3sJ}(M2ixMe0jR(4`2+at zj12Yz`_XHu&NMu&!hT>supi$x5c-%!&s@LmsnhBbq5t~ccbGrGe$am{kH7riFR9nA zVp!LiHda9(Dgx^5Lh?H_gML33klhy9cOW$mT(<{H>LPLf8S@6 z;^AN11oEltLE4h1Ij}NsME!ivx8+<5{K9=l0sO$vQhuO+iYB3dpnsr$*xNuc_m5ET zFO6CMro7*uFzA>^Wr|1r% zu8@A0R(_l2w-k{tIZ0n!V@k1WXD6>SrJFf`#hE}H`XKW3x^P;jd03F&6wO2V-Uxs{ z>@VOP#;$Lo|3Uw}i4UiWSbuzi*Fk(bL9|W`Id8iw+f*A$n+olEsi%~f6fHZ z|0=%!S?UJcMI`ag)>m=AD(4IM-yWj20Ir3%X$sRfk4^6SYoTbiIxd(qwh`bHG_<>;GLhCb_u{0tCFfM3o&HJ2fS`!P8I2lzF)}dSX-MOzULsuE}O>K^yzx|{U*i^xR|ll zRwMuJj5XZKSaY+Hzk#s{4=^@voDm+(*gGp3Yl3pf|DHO=u6~}e(WCY7vjZ7B_%+5x zj?}|-5dQ2f#)b{k!`~mkSZ|JLm%^IZA_&iZj~V(lvF<9yc5LDLHnDqt%h>jRaebTE z`*Rq({R+j7d8sbE^z}o7lDW zjD7F2Dns8U_6X?v(KS_uzEHk~vAb>nexPv%wFWG)-rCiwd)j}9$29GFL}j&)s%+R} zD%%CoU?uR>#g5(hbgh06>psH%Q zs!nzK>2VL4Fp4e z(LgZe7YPJWelbAEmtS}gZ1M{Xf`j~mg5WH_a3HwJFBAwK@(Tijr~Cqd;3uDhfHOpt z%WZb|myaMsk*t@EB!4K$kBR`{?~H(y{geGgH9x-NX=?<+AI4YTD>D3qzs>UW2(mw4 zI51l`nxnvhw{ANLaov0!hn91-yD;;_`jgfh0dF0xr|P8BOg^_V12B zRO@qJe{%yQ`*TM>$@OQY;6I30)WuKQ{uCbt5|{6zK=Sgv6)1pwPX!7g-%Ejl$oEj7 zF!J3MD3JV+`#{m>KhD8r_(^>IOY(ID2!Ce;sQ)Fq{-XXz{SOgv?tSo+sD$@l$o|Ow z$o{DR(fH$xK=H@lAs!15K6*#@ookQtk5cQdL3FvCgPVLdz)J&OI=b&FpLuBzT`uR~ zA>Ts-UOKw(Dc@Ct=yEv+ANejC@Y2zJU-^z2M3>7sNXU24fR~Q$OUbus5M3_kASvIX z0WTfhmzJNWL3FvCLjd`L2E251KahM=gXnTOhk)`84S4D3eqi~!2GIo@974#CRfACS zW7L4lhj#!J_exvDrz~N`5@zlB5zJD6Ra??61sH40%fKuJ02oVpegR0Y6*C}^)^J*g zz;v+yhQ&Hz*u0>eNh3kwio+u#8UVC^))LNH!kw0ImnGb73HMsUc>tr`mUDW$MgO!V z+-M2o*df*zJE|DQu|y1G#}&iWLCYVHjM$*izBxQ?BWtHX4%psNdJAfiY5k3MK4kY2@0E!Uh_Dc7-`mf?5AU6Ik0^;NEEFebyjsoK3 z?<62r{_?vJg5?Dv?Y)@v7x5!}L^SL);bX@{j3InPH0(6tW5+~{A$&wM?6dp zVD_R?F?Rm&3z<3x2~ynbnH>1zIb*v7dr_$vNB&L{q`28Lx$w73uosnzapiB7AjQp| z$%B8s1bb1b7*GD91SxLzOg{YkB-o2e#rX2)5~R4K4xWcMFH;;fQlP=LEF*g8-n-9|PbqXr2k_ zMxy}I`jt|NMkL&E=sPwF5F4mzaA$Y`;Q6P=yl&6Ec z1DttIc~1!Ni_R%?B*-TODiQ%0Ix4c>C12^dPt3-B%s1|1y|{rL=P_PmLp-))yXFRa zOiG&kpx$vPDe{X0$$Wm%m9+7TsH6iwT}jznLdyu?%rC$R0OAMu+b`MXus$=R_Rz5; z{9F*A{$}rN5aWWDJ-XcRb2%huub4}WrM_;5;#^AGqb>a04#C+Ay2M!dxg2_PDQ%Co z@pIPDUeG1R&JQ%So1jZ+d$a>Tr&DtFf-W({4|aK|JzT8A9v!#6)HpDV(jJNf!$|xb z7)Ik~XBd&6jbT)N5{pW^VR*$@+L-i{UvFrz5`NYZ+RNJPX@p;8;b%V;W48&f7>m6) zoKf*AZBMiEx%F(N|J zagJW4?P*^8bdL5iUNPSMkYljRk6%!Z8b5q~s$b%33FYV=yeK?I>1yWzpv@B%K$|Bj zfHqH5Al+ybK$>Sln!g=Uqm4`&ZJhYfXifKOlxv_;DKtNGg7xJO!I6eP6BGVGT#L^N z@d?rj>R|9kWlXwVpwj}~*w5&kjx)o0aic_f|j>FC8P2_2=t9!I%VmDKBev7tqWS-`pSf$ z<*mQ>4_w~DAb9zF1|iCOje)-SV+OGeNq*iOMEFS{P*V1j|5QXm`+WPiJOv3}p6{*e zW)!Bp$RS+$J`Q2aa}MFl>l~t#M-Eb#Xnz)3iUXE0HrrjjPmGjK?ljN? zeqY&Xe59z;_+6#(lQ{kpxT5*SPAdOxCf|PLJ0L;*c4OxxZTO9bpDMVY(ON#G<_ur2 zXv(M{JaN%7fUji$U&{c#wx68Bed1B zU&^Qvb&BHu0YhaJTtf#cwc@Ew2liUNQKNPnR4pv*-17m`29WP?8D$K9D1DSeE^{`g zd=_*#ej_yKeDO;ueHksB^dN7;RJEDWGapNtP2!!8m3O|r-D&T7D9Ui&B)ml&ae+w6 z=Zp-;Wza|+LFZg1eymm*sFn14{Nwky$M5kD?p=C4X)*RT z9iFV{H8b}3oOXXd#+IXR;Kj5_ z#IlIMG^fcW)_8q-&zl^OzcH=b;@RLTJojLa*ENk4uS2QTIFFA$5j(_d6Ig8V_=%!? zx%vbNlb>U}!<2@|X_w_OBJL-!4sch1%b zksul8Gd_>q$me&|$YCC9SlP>PE)$=LO?t zL%?+&t7))T25y@NS!0#qg9j+$!*x?#XEzbqSwQY>+r z%Hy}~&2i0Rs(C6spz*A6xL zYXh9P1V@45avj#=48~ms<1V}#3m#ZmT^8c9z{cuw5Z49nm(x!;X6T?XsOZos$4)v) zA5>w)#p&^kAKx<@y!!dao^}BY_^Z$<&zyhHxuC-2DU*);_C>dSv_3uW+oz6xdgJ+H z|LfRem%e|;l+9l_cj&>Z2Hp0%bBCU$y!dZ-Zy)iUBahm1|KlcIb>+D~Jn71t+YaxY z`1v~*ym)EH;zI_!cj(rwd+k|2Ve)Q|&b@uc>nG0GKJ)FHnjc(!-rR;AJ!|g1xGr^0 z*Qb-%?q_#>dMukgyX(`bZ1&k**XQopUcGkq@_U!9fB3Q`f0_8xbGjehbkk3N{_)X^ zE_`zCB~>>+J9Cfr3%eg&dgi6G9^G{6@#(?;+K<&9a>=(2U?-m2_1DYU;lJ6q?0~Ay z)~nZysm~rUq~oyNGVs5qYW@`)7foUy&;_aL6+%So?9lq%L zmB+ERLl^xTz5N#5fZoVO3(>1thG}$J2lU8kk( zah;Y{JMHON`?Ht6yKLL3_3Y5sf80HzioF~MIQQSJyfJsnwCB@}uN*cwyLem2Om*ju z>rOfG^6yNmn*Vm!_!G}ue$k*wrytH1Jfp5&etdesyI&c@HeK_?LA%5M-h)QK|CZHz z!~e@xYw@eK_|+Ky)u|Z&qp2AGz*LOiHdTxN!dQ%-wyi$*;mYyXH$HvH=9Kbl@IIPV zJtjTmsg?D0rQhy$Ys|i~wB_N;lrt8r-KiWnp|SU`e@?%%_T>#*zndPgv_5;=(w4O^ z@0zvc{m+*_w4?LXE$gzU*0c?rb;hoq#vSAT^1)53&%1s6_Jbdp!tVa~{vWDO{N=?Z zAN+Imd5@p|!Fl&DWMiLwXwJD+ogmk#n zw~U8OKRN$nEPcc3J2$i~zjyuib!%op@Wv@=<-8=%*4FtyQ?uIM`o3B3* z#K1_LcV#E_Di`fJ`(I!C){KWRVantaCM`Xx?HBeT8CKFTvTH-~s+O~!hk(vHq-}=RuPTPFXjW>>}KXTNh z2S+OVOrG+ywR>-Up?kyUOaAo6ufBEhhJXK$Tc&;R+9NN2_mu@x=KS=;S04V`Nf&>x zebHSFCkH& zPL?PTy5`)@`q~v@ZR0%QaV@-*MQ72j6w;mbad%|ML!Z^^$w9UVqBwf3Dj# ze&(?|e|yTSYo2)uG|K(*?cSLerY7~?c*@R`HvQ+zhmK;)Fa7!J)wze)&G-tNw_vZ` zhi2Y>=Z}-Cat|-x@_l9g+qgktF6KZwvms9jH%;ASFn9;LqEF z`b2T@=j}j!B7t_0uzwMMPE((VsVzd{&)b3eM8tN80e{{W)F(o;MU43KcA!2HpdAvz zpSK0|37@t|7=PXl4t;{(YnP|*1FLj$0rBT;VeB=PC+>ikroS}6J{bxBaCYDWt8_Bq zPx$jbT~5BVf%{}6`zQM^C%fmm`k1wJGTA@bKewrJ@}&*jCnMQE*?&3NJ=fL8tfiC5 z{>lEiO_h@`ZQwo`$^Oay%gOG!u0CcholN#m_RnpqoP22m_sK~1PxfCC2$ zvVXFFZd2vtOB=XPMzVjh|8lZ>uB(q(OD6+A_|%wo_Me|mNZP0K4?^p#P&?pNXa#Kp z!e782$pW_l;cvmez->VIJK$fyHX!_6@Gnps5dI$c3vH0pI*9Q1!C!BK#MY#QKj9zQ z1|%SilqJD^iO6;5_n^h}BY`VXnDF=B7m|Q5QWnCW@Gs{0;wL+jaZ3~?`zQPNv%zAf zOPFw^EM)&=|HZU#f7u<8?Axy}*}u2_>+O?V8xa07_+y@A+JNwv#Xp%gApC>iAAcJV z{z37Nw+#sYF!;kqjbge8f5IPZpzQXlV={lNH$8t0(f)*gar+G6Pxu?}l6D)v%5F># zG7pjcll_zZNACr+{t4HQq9d+AK_2<)A}cRFQEB1TtAAA zyv~8}C;a1@6AQ_Q>_42{#??lIf4{+h;;TK{_wd~IF~i2w{-;DI!S8UcP&eRj z-QLHjyHTL41)7O;U#4zWYbJEFzDz);c>>U8CZH7|-pmB?EM+7htzRjXXhgythh76I z4Ly<0@BpBi73iEmcNT*NQ!wR%ftfUzg-L@Q_0jDDohDjqv$W7Lpr7$}#O{>k0iaC~ zfi`;*&}IRoc>$z(0i<~WqIAOr{jLLeCg zR;XKHy}uA#Q!)bjIafHF(Xg_YpDS1iIJWik8pm5bzz@$VoV;O|df*E^97nQAS(FX@ z_<4^xn|G=$YrDxNL*mDAB%723&|-fgew-$o^uSUAKaL~Wqyvrt@#9#MO&VB+#E;`x z@irL)ejLk+w8Mp>lESdx%6-}y-j!-~K!K@2Mfzl1QXDEtHrz2<}WLh~>6V10RmA+73d z!8FLrssB^|kHrRP{G;)&=r-Us&b!6a_#fN*af{yexNZn~ z#rS^PvaCPi6%z(!TmP6aDC_zQ7|7o5So4*A{dEjNuZ5`oWw`#qHW#l5>j7$iYX73! zfN0BMXtMwE9{*u27pB?GGUeX>cn=T-gZ@$f@EG);`iH}yf7L(C{cyRDfBDbP&4Epl zp!TQs5BWTx=xaZ)U7HS)W^ZOA`zQM+`wwLUw!Y`o9}694c5F$4`hTdl$GuQ$e~0;} z(DrVXCu#O(HnM-UU%d~;Y*r-vNh;tiJ_^lEZ-OXZZZ>9B%$LBcZchCpwKcZ*&@O-RLx4%hAaiwG5q1PkeM_4pyRRuT<_6TC*QFq9QPSUaznt)g)hO7mrz86z z`|-08uXM5>vL7$|@Jo}lpVQvm<%%<(Z>_%PxaX&rY`UEO9kq|Cfq&;#GWug3L;Oao zr1Tf+V6_vsaLMVf*Fm};kp4bvAME2nFDT_?yHI;6WnY3h&n zIC6C;UH#?8BGTXcepa{VaCu}p0pTAGTbXtt{PWfp1zA6c?Lzny{-Qkur6ui0_FQ9$ z+Q0PoA4^hy-bNDVD@$5`iF%ZU{vP!xEBzhnQI`5!>QT@-aM|GNr@!p}CM|)n9QPZM zfUx$hC-AkB=%@8~v|7hNfUaZ^(9bA!K!3yIaiw>`T4>a&UViVh0rZ>?Zdl1E3i{#x zBR(fN@P!@~pEnp|*L~ol85j35^b_|;C%@UPj(s{0(}kdGQ&ALk(2wid_TDb-H%Uc3 zgXW*6kI>-%mL0A6h%KlM{Z|se$n*Pbu{|{>1VEkwOc=g$M=$$OQ?N4P%IXHE7Ud6 zF8=qA#nX?^(HRf)a2za7{{^|GU3)1=`t{)?VkXjrpFc(-URIj$t7!cEo)Mbkl+|wH z3VYk1?=!%n>c@5Wc*a)}`g!PCQu;aQS(5r$^h{JoLl!=L!i6>WpE1H&?x%r(^ejG~ zLSHd_pc^q9v!65gbs9cCk3uW35AD;{rT;4hmvR2(_OyrK6aw=Q7>bkTC_QlPF%jOgKIw^ z`5|pyv_Uuf-N@ zUcTENRe|d7x(8Jd`P?oX_LvGP-$9R}$hYVbn+^tF*fr5E++TSTTs933-YS@7Eam5N zkO%fdL{|&pYCi`@Vyj^Qt_C61xKA+}Tr)VnPtjHnfnr>JXGL2R5f5XZ<*a80+OsJ( zS;pLj>*(e+d1p0Of}FOQ%Uf4=?=W%tD2yImacak~eL z34hmntXTMCeO&ILV&kvNu&t3QlE2$J-k~3d!bcxR?Dq=s^0(g$5dZvf!(p7Tu2Cbj zuM_^ZHE68-d3}U6W+MD8aze`hKCm=n3&C9uF4GPUeoW-%vXGWDT{X~(tLuWaUU0Y$ z8wn15z7D%_AOs3=#r^CB`mgXTc*C)a#E)ZXX_wIYl_Ec90%}uV_^Gp#t-d! zCEA@Z9?JIOd0_&eZc|P|_;b)g`&b6V+b1;mxyA%&7gD5TpcLlf%9FVfQEW~9M JXV(ew{|~C0W1#>5 diff --git a/tools/DFBrowserPane/icons/label.png b/tools/DFBrowserPane/icons/label.png deleted file mode 100644 index 863d663206484e134e6d18906cd786dd327bc6d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 370 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP}Mt6 z7sn6_|JF&}g3Sgz&XTQy5n9R{dZvHk=sCc#QaAdiz>cEj$LwwAY>QsI^`zYY4Fa5x zGoP)r^khD}s%!FB^PiX5DuULkH+^0?=jN;0`_6$rU1~??y$TFV>HNkexbysV6CNKzHfADMZp&R%4_?cCBKdk$9cJ`6FW2_BM zd}p5R6a4+W(uup_7gJ^K{qh-x=Ckg7VX2JyF#m*IbG;JBhOqUw`KRUd{F*-Vc_7f| N44$rjF6*2UngHwElmGw# diff --git a/tools/DFBrowserPane/icons/label_folder_16x16.png b/tools/DFBrowserPane/icons/label_folder_16x16.png deleted file mode 100644 index 02f9f2daa62c40ecda1811f2ddfcf7752e6c0485..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK`&1i#}EtuaMNS%G}c0*}aI1_r*vAk26?e?^&nzrJx ziq`_hOWi9QFVdQ&MBb@07{CW-v9sr diff --git a/tools/DFBrowserPane/icons/label_folder_expand_16x16.png b/tools/DFBrowserPane/icons/label_folder_expand_16x16.png deleted file mode 100644 index da0860c5efcc1e39d9d9490cce7d33b338d8da7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc!D*f@jv*HQ$qwxQ%Z*eRKGrJy^XG8h>c9}d zu&9vVI_&5TgAi?&29|$uX8-@cPPKvy)a^aVoLthn10vlvhw<~mC`ASpk1oc5Tmc4= z8T?&#UOYek{|;11WjkQPzlL%Dd-nhTtKEcGvz72%H5AV6akq^nKa(Rm*`cWbkzLb6Mw<&;$TQt5g^O diff --git a/tools/DFBrowserPane/icons/label_folder_expand_20x20.png b/tools/DFBrowserPane/icons/label_folder_expand_20x20.png deleted file mode 100644 index 1377b9d9b6152d331adc198404afad1ca37a0a64..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?mvsec>?$29FQ#CC~of|DOH-|F3HNtJP{GvUr#pSRC078th_o zf^ghRKbLh*2~7avR%dMh diff --git a/tools/DFBrowserPane/icons/label_folder_expand_40x40.png b/tools/DFBrowserPane/icons/label_folder_expand_40x40.png deleted file mode 100644 index e1f2bff8953d9e83cc572eb6b1d5d24820f26fc4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 601 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4evZ%977`9-_Ef0at;(}iBDHID-+vRR<`cI zxkK0V=FZ*0QvN__6HB(EhhhY$SXh%n1V>ZC{Qb{oTKMxF-&q;xFT~2ePpkNOor-H* zP_6pc%BzNQJymfZR;@qEx34>P&54UX6;E?EGRr3|zCCx>{~8T<CZpzdt>V4@4Uf*usH0jfkk31EBzeH^8e(nHt$79KWg)-W{PuTj| zgH8z_H(t=zCz>{m8K`g7ivPvSJl@*!d(P=S{F|;HgKuPsc1zX5P zN5{@7Bq + + icons/item_shape.png + icons/item_streamValues.png + + diff --git a/tools/MessageModel/MessageModel_ActionType.hxx b/tools/MessageModel/MessageModel_ActionType.hxx new file mode 100644 index 0000000000..3415c9d0d2 --- /dev/null +++ b/tools/MessageModel/MessageModel_ActionType.hxx @@ -0,0 +1,33 @@ +// 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_ActionType_H +#define MessageModel_ActionType_H + +//! Kind of action type for tree view context menu item +enum MessageModel_ActionType +{ + MessageModel_ActionType_Activate, //!< set Message_Report active + MessageModel_ActionType_Deactivate, //!< set Message_Report not active + MessageModel_ActionType_Clear, //!< clear Message_Report alerts + MessageModel_ActionType_ExportToShapeView, //!< export TopoDS_Shape of selected item into TKShapeView plugin + MessageModel_ActionType_TestMetric, //!< test alerts + MessageModel_ActionType_TestProperties, //!< test alerts + MessageModel_ActionType_TestMessenger, //!< test message view on messenger printer to report + MessageModel_ActionType_TestReportTree, //!< test message view on hierarchical report + MessageModel_ActionType_TestReportTree2 //!< test message view on hierarchical report +}; + +#endif diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx new file mode 100644 index 0000000000..8ca4217c74 --- /dev/null +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -0,0 +1,269 @@ +// 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 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +MessageModel_Actions::MessageModel_Actions (QWidget* theParent, + MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel) +: QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel) +{ + myActions.insert (MessageModel_ActionType_Activate, + ViewControl_Tools::CreateAction ("Activate", SLOT (OnActivateReport()), parent(), this)); + myActions.insert (MessageModel_ActionType_Deactivate, + ViewControl_Tools::CreateAction ("Deactivate", SLOT (OnDeactivateReport()), parent(), this)); + myActions.insert (MessageModel_ActionType_Clear, + ViewControl_Tools::CreateAction ("Clear", SLOT (OnClearReport()), parent(), this)); + myActions.insert (MessageModel_ActionType_ExportToShapeView, + ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this)); +} + +// ======================================================================= +// function : GetAction +// purpose : +// ======================================================================= +QAction* MessageModel_Actions::GetAction (const MessageModel_ActionType& theType) +{ + if (myActions.contains (theType)) + return myActions[theType]; + + return 0; +} + +// ======================================================================= +// function : AddMenuActions +// purpose : +// ======================================================================= +void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu) +{ + MessageModel_ItemRootPtr aRootItem; + MessageModel_ItemReportPtr aReportItem; + MessageModel_ItemAlertPtr anAlertItem; + for (QModelIndexList::const_iterator aSelIt = theSelectedIndices.begin(); aSelIt != theSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + aRootItem = itemDynamicCast (anItemBase); + if (aRootItem) + break; + + aReportItem = itemDynamicCast (anItemBase); + if (aReportItem) + break; + + anAlertItem = itemDynamicCast (anItemBase); + if (anAlertItem) + break; + } + + if (aReportItem && !aReportItem->GetReport().IsNull()) + { + theMenu->addAction (myActions[MessageModel_ActionType_Deactivate]); + theMenu->addAction (myActions[MessageModel_ActionType_Activate]); + theMenu->addAction (myActions[MessageModel_ActionType_Clear]); + } + else if (anAlertItem) + { + theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]); + } + + theMenu->addSeparator(); +} + +// ======================================================================= +// function : getSelectedReport +// purpose : +// ======================================================================= +Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& theReportIndex) const +{ + MessageModel_ItemReportPtr aReportItem; + QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes(); + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + aReportItem = itemDynamicCast (anItemBase); + theReportIndex = anIndex; + if (aReportItem) + break; + } + if (!aReportItem) + return NULL; + + return aReportItem->GetReport(); +} + +// ======================================================================= +// function : OnActivateReport +// purpose : +// ======================================================================= +static Handle(Message_PrinterToReport) MyPrinterToReport; +static Message_SequenceOfPrinters MyDeactivatedPrinters; + +void MessageModel_Actions::OnActivateReport() +{ + if (MyPrinterToReport.IsNull()) + MyPrinterToReport = new Message_PrinterToReport(); + + if (MyPrinterToReport->Report()->IsActiveInMessenger()) + return; + + MyDeactivatedPrinters = Message::DefaultMessenger()->Printers(); + Message::DefaultMessenger()->ChangePrinters().Clear(); + + Message::DefaultMessenger()->AddPrinter (MyPrinterToReport); + Message::DefaultMessenger()->SetTraceLevel (1); + Message::DefaultReport()->UpdateActiveInMessenger(); + + myTreeModel->UpdateTreeModel(); +} + +// ======================================================================= +// function : OnDeactivateReport +// purpose : +// ======================================================================= +void MessageModel_Actions::OnDeactivateReport() +{ + if (MyPrinterToReport.IsNull() || !MyPrinterToReport->Report()->IsActiveInMessenger()) + return; + + Message::DefaultMessenger()->RemovePrinter (MyPrinterToReport); + Message::DefaultMessenger()->ChangePrinters().Assign (MyDeactivatedPrinters); + + myTreeModel->UpdateTreeModel(); +} + +// ======================================================================= +// function : OnClearReport +// purpose : +// ======================================================================= +void MessageModel_Actions::OnClearReport() +{ + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + aReport->Clear(); + myTreeModel->UpdateTreeModel(); +} + +// ======================================================================= +// function : OnExportToShapeView +// purpose : +// ======================================================================= +void MessageModel_Actions::OnExportToShapeView() +{ + TCollection_AsciiString aPluginName ("TKShapeView"); + + NCollection_List aPluginParameters; + if (myParameters->FindParameters (aPluginName)) + aPluginParameters = myParameters->Parameters (aPluginName); + NCollection_List anItemNames; + if (myParameters->FindSelectedNames (aPluginName)) + anItemNames = myParameters->GetSelectedNames (aPluginName); + + QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes(); + QStringList anExportedPointers; + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast (anItemBase); + if (!anAlertItem) + continue; + + Handle(Message_Alert) anAlert = anAlertItem->GetAlert(); + if (anAlert.IsNull()) + continue; + + Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (anAlert); + if (anExtAlert.IsNull()) + continue; + + Handle(Message_Attribute) anAttribute = anExtAlert->Attribute(); + if (anAttribute.IsNull()) + continue; + + if (!anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) + continue; + + const TopoDS_Shape aShape = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape(); + if (aShape.IsNull()) + continue; + aPluginParameters.Append (aShape.TShape()); + anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString (aShape)); + + anExportedPointers.append (MessageModel_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()); + } + + if (anExportedPointers.empty()) + return; + myParameters->SetSelectedNames (aPluginName, anItemNames); + myParameters->SetParameters (aPluginName, aPluginParameters); + QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.") + .arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString()))); +} diff --git a/tools/MessageModel/MessageModel_Actions.hxx b/tools/MessageModel/MessageModel_Actions.hxx new file mode 100644 index 0000000000..39eab429e2 --- /dev/null +++ b/tools/MessageModel/MessageModel_Actions.hxx @@ -0,0 +1,98 @@ +// 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_Actions_H +#define MessageModel_Actions_H + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +class Message_Report; +class MessageModel_TreeModel; + +class QAction; +class QItemSelectionModel; +class QMenu; +class QWidget; + +//! \class MessageModel_Actions +//! \brief This is a listener of popup context menu items and selection change in message model +class MessageModel_Actions : public QObject +{ + Q_OBJECT + +public: + + //! Constructor + Standard_EXPORT MessageModel_Actions (QWidget* theParent, + MessageModel_TreeModel* theTreeModel, + QItemSelectionModel* theModel); + + //! Destructor + virtual ~MessageModel_Actions() Standard_OVERRIDE {} + + //! Returns action by the type + //! \param theType an action type + //! \return an action instance if it exists + Standard_EXPORT QAction* GetAction (const MessageModel_ActionType& theType); + + //! Fills popup menu with actions depending on the current selection + //! \param theSelectedIndices tree model selected indices + //! \param theMenu menu to be filled + Standard_EXPORT void AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu); + + //! Sets parameters container, it should be used when the plugin is initialized or in update content + //! \param theParameters a parameters container + void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) + { myParameters = theParameters; } + +public slots: + //! Set selected report active + void OnActivateReport(); + + //! Set selected report not active + void OnDeactivateReport(); + + //! Clears container of alerts of selected report + void OnClearReport(); + + //! Exports the first selected shape into ShapeViewer plugin. + void OnExportToShapeView(); + +protected: + //! Returns report of selected tree view item if a report item is selected + //! \param theReportIndex tree model index of the found report + //! \return report instance or NULL + Handle(Message_Report) getSelectedReport (QModelIndex& theReportIndex) const; + +protected: + MessageModel_TreeModel* myTreeModel; //< tree model + QItemSelectionModel* mySelectionModel; //< selection model + Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container + QMap myActions; //!< container of all actions +}; + +#endif diff --git a/tools/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx new file mode 100644 index 0000000000..a0904ec5c1 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -0,0 +1,352 @@ +// 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 +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant MessageModel_ItemAlert::initValue (const int theRole) const +{ + QVariant aParentValue = MessageModel_ItemBase::initValue (theRole); + if (aParentValue.isValid()) + return aParentValue; + + MessageModel_ItemReportPtr aReportItem = MessageModel_ItemReport::FindReportItem (Parent()); + if (!aReportItem) + return QVariant(); + + Handle(Message_Report) aReport = aReportItem->GetReport(); + if (aReport.IsNull()) + return QVariant(); + + if (theRole == Qt::ForegroundRole) + { + if (!aReport->IsActiveInMessenger()) + return QColor(Qt::darkGray); + + return QVariant(); + } + + Handle(Message_Alert) anAlert = getAlert(); + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert); + + // if the alert is composite, process the real alert + if (theRole == Qt::DecorationRole && Column() == 0) + { + if (anExtendedAlert.IsNull()) + return QVariant(); + + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (anAttribute.IsNull()) + return QVariant(); + + if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) + return QIcon (":/icons/item_shape.png"); + else if (!Handle(Message_AttributeStream)::DownCast (anAttribute).IsNull()) + return QIcon (":/icons/item_streamValues.png"); + else + return QVariant(); + } + + if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole) + return QVariant(); + + if (anAlert.IsNull()) + return QVariant(); + + if (Column() == 0) + { + if (theRole == Qt::DisplayRole) + { + TCollection_AsciiString aMessageKey = anAlert->GetMessageKey(); + if (aMessageKey.IsEmpty() && !Properties().IsNull()) + aMessageKey = Properties()->Key(); + return aMessageKey.ToCString(); + } + else + return anAlert->DynamicType()->Name(); + } + + Message_MetricType aMetricType; + int aPosition; + if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition)) + { + if (anExtendedAlert.IsNull()) + return QVariant(); + + Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anExtendedAlert->Attribute()); + if (anAttribute.IsNull() || !anAttribute->HasMetric (aMetricType)) + return QVariant(); + + if (!anAttribute->IsMetricValid (aMetricType)) + return QVariant ("in process"); + + if (aMetricType == Message_MetricType_UserTimeCPU || + aMetricType == Message_MetricType_SystemTimeInfo || + aMetricType == Message_MetricType_WallClock) + { + Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType); + if (fabs (aCumulativeMetric) < Precision::Confusion()) + return QVariant(); + + if (aPosition == 0) return aCumulativeMetric; + else if (aPosition == 1) + { + Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType); + if (fabs (aReportCumulativeMetric) > Precision::Confusion()) + return 100. * aCumulativeMetric / aReportCumulativeMetric; + else + return QVariant(); + } + } + else + { + if (aPosition == 0) return anAttribute->StopValue (aMetricType); + else if (aPosition == 1) + { + Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType); + if (fabs (aCumulativeMetric) < Precision::Confusion()) + return QVariant(); + else + return aCumulativeMetric; + } + + } + } + return QVariant(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int MessageModel_ItemAlert::initRowCount() const +{ + const Handle(Message_Alert)& anAlert = getAlert(); + if (anAlert.IsNull()) + return 0; + + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert); + if (anExtendedAlert.IsNull()) + return 0; + + Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->CompositeAlerts(); + if (aCompositeAlert.IsNull()) + return 0; + + MessageModel_ItemAlert* aCurrentItem = (MessageModel_ItemAlert*)this; + for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++) + { + const Message_ListOfAlert& anAlerts = aCompositeAlert->Alerts ((Message_Gravity)aGravityId); + { + for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next()) + { + Message_ListOfAlert aCurAlerts; + aCurAlerts.Append (anIt.Value()); + aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts); + } + } + } + + return aCurrentItem->myChildAlerts.Size(); +} + +// ======================================================================= +// function : initStream +// purpose : +// ======================================================================= +void MessageModel_ItemAlert::initStream (Standard_OStream& OS) const +{ + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert()); + if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull()) + return; + + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (anAttribute.IsNull()) + return; + + if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + return; + + Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + OS << anAttributeStream->Stream().str(); +} + +// ======================================================================= +// function : SetStream +// purpose : +// ======================================================================= +bool MessageModel_ItemAlert::SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const +{ + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert()); + if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull()) + return false; + + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (anAttribute.IsNull()) + return false; + + if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + return false; + + Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + TCollection_AsciiString aStreamValue = Standard_Dump::Text (anAttributeStream->Stream()); + + TCollection_AsciiString aNewValue = Standard_Dump::Text (theSStream); + + Standard_SStream aStream; + aStream << aStreamValue.SubString (1, theStartPos - 1); + aStream << aNewValue; + if (theLastPos + 1 <= aStreamValue.Length()) + aStream << aStreamValue.SubString (theLastPos + 1, aStreamValue.Length()); + + //TCollection_AsciiString aStreamValue_debug = Standard_Dump::Text (aStream); + + anAttributeStream->SetStream (aStream); + + return true; +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr MessageModel_ItemAlert::createChild (int theRow, int theColumn) +{ + return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void MessageModel_ItemAlert::Init() +{ + MessageModel_ItemReportPtr aReportItem = itemDynamicCast (Parent()); + MessageModel_ItemAlertPtr anAlertItem; + Handle(Message_Alert) anAlert; + if (aReportItem) + { + Message_ListOfAlert anAlerts; + if (aReportItem->GetChildAlerts (Row(), anAlerts)) + { + myAlert = anAlerts.First(); + } + } + else + { + anAlertItem = itemDynamicCast (Parent()); + if (anAlertItem) + { + Message_ListOfAlert anAlerts; + if (anAlertItem->GetChildAlerts (Row(), anAlerts)) + { + myAlert = anAlerts.First(); + } + } + } + + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(myAlert); + if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull()) + { + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (!anAttribute.IsNull()) + { + //if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + //{ + // if (GetProperties().IsNull()) + // { + // TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); + // SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem)); + // } + // Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + // Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties()); + // aProperties->Init (anAttributeStream->GetStream()); + //} + ////if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject))) + //// myPresentation = Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject(); + if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) + myPresentation = new Convert_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape()); + } + //TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription(); + //Bnd_Box aBox; + //if (aBox.Init (Standard_SStream (aDescription.ToCString()))) + // myPresentation =new Convert_TransientShape (Convert_Tools::CreateShape (aBox)); + } + MessageModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void MessageModel_ItemAlert::Reset() +{ + MessageModel_ItemBase::Reset(); + myAlert = Handle(Message_Alert)(); + myChildAlerts.Clear(); + myPresentation = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void MessageModel_ItemAlert::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : getAlert +// purpose : +// ======================================================================= +const Handle(Message_Alert)& MessageModel_ItemAlert::getAlert() const +{ + initItem(); + return myAlert; +} diff --git a/tools/MessageModel/MessageModel_ItemAlert.hxx b/tools/MessageModel/MessageModel_ItemAlert.hxx new file mode 100644 index 0000000000..c9b5d0b781 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemAlert.hxx @@ -0,0 +1,137 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef MessageModel_ItemAlert_H +#define MessageModel_ItemAlert_H + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +class QAbstractTableModel; + +class MessageModel_ItemAlert; +typedef QExplicitlySharedDataPointer MessageModel_ItemAlertPtr; + +//! \class MessageModel_ItemAlert +//! This item is connected to Message_Alert. +//! Parent is either MessageModel_ItemRoot or MessageModel_ItemAlert, children are MessageModel_ItemAlert or no children +class MessageModel_ItemAlert : public MessageModel_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + //! \return the pointer to the created item + static MessageModel_ItemAlertPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return MessageModel_ItemAlertPtr (new MessageModel_ItemAlert (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~MessageModel_ItemAlert() Standard_OVERRIDE {}; + + //! Returns the current shape + const Handle(Message_Alert)& GetAlert() const { return myAlert; } + + //! Returns alert of the report for the parameter row + Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); } + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Return data value for the role. + //! \param theRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE; + + //! \return number of children. + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const Standard_OVERRIDE; + + //! Sets some shape to present the item + //! \param theShape shape instance + void SetCustomShape (const TopoDS_Shape& theShape) { myCustomShape = theShape; } + + //! Returns custom shape to present the item + //! \return instance of the shape + const TopoDS_Shape& GetCustomShape() const { return myCustomShape; } + + //! Returns presentation of the attribute to be visualized in the view + //! \param theRow a model index row + //! \param theColumn a model index column + //! \thePresentations [out] container of presentation handles to be visualized + virtual void Presentations (NCollection_List& thePresentations) Standard_OVERRIDE + { TreeModel_ItemBase::Presentations (thePresentations); thePresentations.Append (myPresentation); } + + + ////! Returns summ of children alert elapsed times. The method is recusive. + ////! \param theAlert a message alert + ////! \return double value + //Standard_EXPORT static double CumulativeMetric (const Handle(Message_Alert)& theAlert); + +protected: + + //! Initialize the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void initStream (Standard_OStream& OS) const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + + //! Returns current alert, initialized item if it has not been initialized yet + //! \return alert value + const Handle(Message_Alert)& getAlert() const; + +private: + + //! Constructor + MessageModel_ItemAlert (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : MessageModel_ItemBase (theParent, theRow, theColumn) {} + +private: + Handle(Message_Alert) myAlert; + + NCollection_DataMap myChildAlerts; //!< container of child alerts + + TopoDS_Shape myCustomShape; + Handle(Standard_Transient) myPresentation; +}; + +#endif diff --git a/tools/MessageModel/MessageModel_ItemBase.cxx b/tools/MessageModel/MessageModel_ItemBase.cxx new file mode 100644 index 0000000000..de74f85a3c --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemBase.cxx @@ -0,0 +1,47 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + + +#include +#include + +// ======================================================================= +// function : isReversed +// purpose : +// ======================================================================= +Standard_Boolean MessageModel_ItemBase::isReversed() const +{ + TreeModel_ItemBasePtr aParentItem = GetRootItem(); + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (aParentItem); + return aRootItem ? aRootItem->IsReversed() : Standard_False; +} + +// ======================================================================= +// function : GetRootItem +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr MessageModel_ItemBase::GetRootItem() const +{ + TreeModel_ItemBasePtr anItem = Parent(); + while (anItem) + { + if (MessageModel_ItemRootPtr aThisRootItem = itemDynamicCast (anItem)) + { + return aThisRootItem; + } + anItem = anItem->Parent(); + } + return TreeModel_ItemBasePtr(); +} diff --git a/tools/MessageModel/MessageModel_ItemBase.hxx b/tools/MessageModel/MessageModel_ItemBase.hxx new file mode 100644 index 0000000000..dfd9e7fb61 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemBase.hxx @@ -0,0 +1,56 @@ +// 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_ItemBase_H +#define MessageModel_ItemBase_H + +#include +#include +#include + +class MessageModel_ItemBase; +typedef QExplicitlySharedDataPointer MessageModel_ItemBasePtr; + +//! \class MessageModel_ItemBase +// \brief Declaration of the tree model base item. +class MessageModel_ItemBase : public TreeModel_ItemBase +{ +public: + + //! Resets cached values + virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); } + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + virtual void initItem() const {}; + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + MessageModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : TreeModel_ItemBase (theParent, theRow, theColumn) {} + + //! Return whether the view is reversed or not + //! \return boolean value + Standard_Boolean isReversed() const; + + //! Return root item + //! \return an item instance + TreeModel_ItemBasePtr GetRootItem() const; +}; + +#endif \ No newline at end of file diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx new file mode 100644 index 0000000000..bf4fc5a7f7 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -0,0 +1,233 @@ +// 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 +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant MessageModel_ItemReport::initValue (const int theRole) const +{ + QVariant aParentValue = MessageModel_ItemBase::initValue (theRole); + if (aParentValue.isValid()) + return aParentValue; + + const Handle(Message_Report)& aReport = getReport(); + if (aReport.IsNull()) + return QVariant(); + + if (theRole == Qt::ForegroundRole) + { + if (!aReport->IsActiveInMessenger()) + return QColor(Qt::darkGray); + + return QVariant(); + } + if (theRole == Qt::ToolTipRole && !myDescription.IsEmpty() && Column() == 0) // display the exported file name in tool tip + { + OSD_Path aPath(myDescription); + return QString ("%1%2").arg (aPath.Name().ToCString()).arg (aPath.Extension().ToCString()); + } + + if (theRole != Qt::DisplayRole) + return QVariant(); + + if (Column() == 0) + return aReport->DynamicType()->Name(); + + Message_MetricType aMetricType; + int aPosition; + if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition) && + (aMetricType == Message_MetricType_UserTimeCPU || aMetricType == Message_MetricType_SystemTimeInfo || + aMetricType == Message_MetricType_WallClock)) + { + if (aPosition == 0) return CumulativeMetric (aReport, aMetricType); + else if (aPosition == 1) return "100"; + } + return QVariant(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int MessageModel_ItemReport::initRowCount() const +{ + const Handle(Message_Report)& aReport = getReport(); + if (aReport.IsNull()) + return 0; + + MessageModel_ItemReport* aCurrentItem = (MessageModel_ItemReport*)this; + for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++) + { + const Message_ListOfAlert& anAlerts = aReport->GetAlerts ((Message_Gravity)aGravityId); + for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next()) + { + Message_ListOfAlert aCurAlerts; + aCurAlerts.Append (anIt.Value()); + aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts); + } + } + return aCurrentItem->myChildAlerts.Size(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr MessageModel_ItemReport::createChild (int theRow, int theColumn) +{ + return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void MessageModel_ItemReport::Init() +{ + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (Parent()); + myReport = aRootItem ? aRootItem->GetReport (Row(), myDescription) : Handle(Message_Report)(); + + MessageModel_ItemBase::Init(); +} + +// ======================================================================= +// function : getReport +// purpose : +// ======================================================================= +const Handle(Message_Report)& MessageModel_ItemReport::getReport() const +{ + initItem(); + return myReport; +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void MessageModel_ItemReport::Reset() +{ + MessageModel_ItemBase::Reset(); + myReport = Handle(Message_Report)(); + myChildAlerts.Clear(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void MessageModel_ItemReport::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : FindReportItem +// purpose : +// ======================================================================= +MessageModel_ItemReportPtr MessageModel_ItemReport::FindReportItem (const TreeModel_ItemBasePtr& theItem) +{ + TreeModel_ItemBasePtr anItem = theItem; + while (anItem) + { + if (MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItem)) + return aReportItem; + + anItem = anItem->Parent(); + } + return MessageModel_ItemReportPtr(); +} + +// ======================================================================= +// function : FindReport +// purpose : +// ======================================================================= +Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_ItemBasePtr& theItem) +{ + Handle(Message_Report) aReport; + + MessageModel_ItemBasePtr anItem = theItem; + while (anItem) + { + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItem); + + if (aReportItem) + return aReportItem->GetReport(); + + anItem = itemDynamicCast(anItem->Parent()); + } + return NULL; +} + +// ======================================================================= +// function : CumulativeMetric +// purpose : +// ======================================================================= +Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType) +{ + if (!theReport->ActiveMetrics().Contains (theMetricType)) + return 0; + + Standard_Real aMetric = 0; + for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity) + { + const Message_ListOfAlert& anAlerts = theReport->GetAlerts ((Message_Gravity)iGravity); + Handle(Message_AttributeMeter) aFirstAttribute/*, aLastAttribute*/; + for (Message_ListOfAlert::Iterator anAlertsIterator (anAlerts); anAlertsIterator.More(); anAlertsIterator.Next()) + { + Handle(Message_AlertExtended) anAlert = Handle(Message_AlertExtended)::DownCast (anAlertsIterator.Value()); + if (anAlert.IsNull()) + continue; + Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anAlert->Attribute()); + if (anAttribute.IsNull() || !anAttribute->HasMetric (theMetricType) || !anAttribute->IsMetricValid (theMetricType)) + continue; + + //if (aFirstAttribute.IsNull()) + // aFirstAttribute = anAttribute; + //else + //{ + //aLastAttribute = anAttribute; + //} + aMetric += anAttribute->StopValue (theMetricType) - anAttribute->StartValue (theMetricType); + } + //if (aFirstAttribute.IsNull()) + // continue; + //if (aLastAttribute.IsNull()) + // aLastAttribute = aFirstAttribute; + + //aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType); + } + return aMetric; +} diff --git a/tools/MessageModel/MessageModel_ItemReport.hxx b/tools/MessageModel/MessageModel_ItemReport.hxx new file mode 100644 index 0000000000..f03d98e58d --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemReport.hxx @@ -0,0 +1,117 @@ +// 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_ItemReport_H +#define MessageModel_ItemReport_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class MessageModel_ItemReport; +typedef QExplicitlySharedDataPointer MessageModel_ItemReportPtr; + +//! \class MessageModel_ItemReport +//! This item is connected to Message_Alert. +//! Parent is MessageModel_ItemRoot, children are MessageModel_ItemAlert or no children +class MessageModel_ItemReport : public MessageModel_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + //! \return the pointer to the created item + static MessageModel_ItemReportPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return MessageModel_ItemReportPtr (new MessageModel_ItemReport (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~MessageModel_ItemReport() Standard_OVERRIDE {}; + + //! Returns the current shape + const Handle(Message_Report)& GetReport() const { return myReport; } + + //! Returns alert of the report for the parameter row + Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); } + + //! Returns the report description or NULL + const TCollection_AsciiString& GetDescription() const { return myDescription; } + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Return data value for the role. + //! \param theRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE; + + //! \return number of children. + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns report of the tree model item. Iterates up by parents intil the report item is found. + //! \return an item or NULL + Standard_EXPORT static MessageModel_ItemReportPtr FindReportItem (const TreeModel_ItemBasePtr& theItem); + + //! Returns report of the item + static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem); + + //! Returns report cumulative metric as stop time of the last alert minus start time of the first alert + Standard_EXPORT static Standard_Real CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType); + +protected: + + //! Initialize the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + + //! Returns number of child shapes. Init item if it is not initialized + //! \return integer value + int getRowCount() const; + + //! Returns current shape, initialized item if it has not been initialized yet + //! \return shape value + const Handle(Message_Report)& getReport() const; + +private: + + //! Constructor + MessageModel_ItemReport (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : MessageModel_ItemBase (theParent, theRow, theColumn) {} + +private: + + NCollection_DataMap myChildAlerts; //!< container of child alerts + + Handle(Message_Report) myReport; //!< current report + TCollection_AsciiString myDescription; //!< description +}; + +#endif diff --git a/tools/MessageModel/MessageModel_ItemRoot.cxx b/tools/MessageModel/MessageModel_ItemRoot.cxx new file mode 100644 index 0000000000..b42dcc8864 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemRoot.cxx @@ -0,0 +1,96 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + + +#include +#include + +// ======================================================================= +// function : SetReport +// purpose : +// ======================================================================= +void MessageModel_ItemRoot::SetReport (const int theRowId, const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription) +{ + NCollection_List::Iterator aReportsIt (myReports); + for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++) + { + if (aRowId == theRowId) + break; + } + aReportsIt.Value().myReport = theReport; + aReportsIt.Value().myDescription = theReportDescription; +} + +// ======================================================================= +// function : GetReport +// purpose : +// ======================================================================= +const Handle(Message_Report)& MessageModel_ItemRoot::GetReport (const int theRowId, + TCollection_AsciiString& theReportDescription) +{ + NCollection_List::Iterator aReportsIt (myReports); + for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++) + { + if (aRowId == theRowId) + break; + } + theReportDescription = aReportsIt.Value().myDescription; + return aReportsIt.Value().myReport; +} + +// ======================================================================= +// function : HasReport +// purpose : +// ======================================================================= +Standard_Boolean MessageModel_ItemRoot::HasReport (const Handle(Message_Report)& theReport) +{ + NCollection_List::Iterator aReportsIt (myReports); + for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++) + { + if (aReportsIt.Value().myReport == theReport) + return Standard_True; + } + return Standard_False; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant MessageModel_ItemRoot::initValue (const int theRole) const +{ + QVariant aParentValue = MessageModel_ItemBase::initValue (theRole); + if (aParentValue.isValid()) + return aParentValue; + + if (Column() != 0) + return QVariant(); + + if (theRole == Qt::DisplayRole) + return myName.IsEmpty() ? "Message_Reports" : myName.ToCString(); + + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr MessageModel_ItemRoot::createChild (int theRow, int theColumn) +{ + return MessageModel_ItemReport::CreateItem (currentItem(), theRow, theColumn); +} + diff --git a/tools/MessageModel/MessageModel_ItemRoot.hxx b/tools/MessageModel/MessageModel_ItemRoot.hxx new file mode 100644 index 0000000000..197bd1eb9a --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemRoot.hxx @@ -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. + +#ifndef MessageModel_ItemRoot_H +#define MessageModel_ItemRoot_H + +#include +#include +#include +#include +#include + +#include + +class MessageModel_ItemRoot; +typedef QExplicitlySharedDataPointer MessageModel_ItemRootPtr; + +//! \struct to extend report by description +struct MessageModel_ReportInformation +{ + //! Constructor + MessageModel_ReportInformation (Handle(Message_Report) theReport, const TCollection_AsciiString& theDescription) + : myReport (theReport), myDescription (theDescription) {} + + Handle(Message_Report) myReport; //! report + TCollection_AsciiString myDescription; //! report description +}; + +//! \class MessageModel_ItemRoot +//! Collects message reports that should be visualized in tree view. Reports are cached and if reports are not needed, +//! cache should be cleared using RemoveAllReports +//! Parent is NULL, children are MessageModel_ItemReport items. +class MessageModel_ItemRoot : public MessageModel_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static MessageModel_ItemRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return MessageModel_ItemRootPtr (new MessageModel_ItemRoot (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~MessageModel_ItemRoot() Standard_OVERRIDE {}; + + //! Appends new report + //! \param theReport a report instance + //! \param theReportDescription an additional report information + void AddReport (const Handle(Message_Report)& theReport, const TCollection_AsciiString& theReportDescription) + { myReports.Append (MessageModel_ReportInformation (theReport, theReportDescription)); } + + //! Set report, se it into the given row index + //! \param theRowId a report child row + //! \param theReport a report instance + //! \param theReportDescription an additional report information + Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription = ""); + + //! Returns true if report exists is in the list of the current reports + //! \param theReport a report instance + //! \return boolen value + Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport); + + //!< Returns processed reports + const NCollection_List& Reports() const { return myReports; } + + //! Clears internal container of added reports + void RemoveAllReports() { myReports.Clear(); } + + //! Returns report by the number + //! \param theRowId an index of the report in the internal container. + Standard_EXPORT const Handle(Message_Report)& GetReport (const int theRowId, TCollection_AsciiString& theReportDescription); + + //! Set the view reversed. If reversed, the last report alert is upper item in the tree view + //! \param theReversed boolean flag + void SetReversed (const Standard_Boolean& theReversed) { myIsReversed = theReversed; } + + //! Return whether the view is reversed or not + //! \return boolean value + Standard_Boolean IsReversed() const { return myIsReversed; }; + + //! Set the view reversed. If reversed, the last report alert is upper item in the tree view + //! \param theReversed boolean flag + void SetName (const TCollection_AsciiString& theName) { myName = theName; } + +protected: + + //! Return data value for the role. + //! \param theRole a value role + //! \return the value + virtual QVariant initValue (const int theRole) const Standard_OVERRIDE; + + //! \return number of children. + virtual int initRowCount() const Standard_OVERRIDE { return myReports.Size(); } + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + MessageModel_ItemRoot (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : MessageModel_ItemBase (theParent, theRow, theColumn), myIsReversed (Standard_False) {} + +private: + + NCollection_List myReports; //!< reports sent by algorithms + Standard_Boolean myIsReversed; //!< state if the model is reversed + TCollection_AsciiString myName; //!< DisplayRole data, if defined +}; + +#endif diff --git a/tools/MessageModel/MessageModel_Tools.cxx b/tools/MessageModel/MessageModel_Tools.cxx new file mode 100644 index 0000000000..5348d47ca8 --- /dev/null +++ b/tools/MessageModel/MessageModel_Tools.cxx @@ -0,0 +1,59 @@ +// 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 +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : GetPointerInfo +// purpose : +// ======================================================================= +TCollection_AsciiString MessageModel_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo) +{ + if (thePointer.IsNull()) + return TCollection_AsciiString(); + + std::ostringstream aPtrStr; + aPtrStr << thePointer.operator->(); + 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("0x"); + return anInfoPtr; + } + } + return aPtrStr.str().c_str(); +} diff --git a/tools/MessageModel/MessageModel_Tools.hxx b/tools/MessageModel/MessageModel_Tools.hxx new file mode 100644 index 0000000000..c83922aed6 --- /dev/null +++ b/tools/MessageModel/MessageModel_Tools.hxx @@ -0,0 +1,53 @@ +// 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_Tools_H +#define MessageModel_Tools_H + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +class Message_Alert; +class ViewControl_TableModelValues; + +class ViewControl_Table; + +//! \class MessageModel_Tools +//! It gives auxiliary methods for Message classes manipulation +class MessageModel_Tools +{ +public: + + //! 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 Handle(Standard_Transient)& thePointer, + const bool isShortInfo = true); +}; + +#endif diff --git a/tools/MessageModel/MessageModel_TreeModel.cxx b/tools/MessageModel/MessageModel_TreeModel.cxx new file mode 100644 index 0000000000..b5950bd8b5 --- /dev/null +++ b/tools/MessageModel/MessageModel_TreeModel.cxx @@ -0,0 +1,213 @@ +// 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 + +const int COLUMN_NAME_WIDTH = 230; +const int COLUMN_SIZE_WIDTH = 30; + +const int COLUMN_REAL_VALUE_WIDTH = 115; +const int COLUMN_PERCENT_VALUE_WIDTH = 50; + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent) +: TreeModel_ModelBase (theParent), myIsReversed (Standard_False) +{ +} + +// ======================================================================= +// function : InitColumns +// purpose : +// ======================================================================= +void MessageModel_TreeModel::InitColumns() +{ + // 0 - Name, 1 - visibility, 2 - Row + setHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); + setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); + setHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/)); + + int aNextIndex = 3; + for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) + { + Message_MetricType aMetricType = (Message_MetricType)aMetricId; + OSD_MemInfo::Counter aMemInfo; + bool isMemInfo = Message::ToOSDMetric (aMetricType, aMemInfo); + + setHeaderItem (aNextIndex++, + TreeModel_HeaderSection (QString("%1 [%2]").arg (Message::MetricToString (aMetricType)).arg(isMemInfo ? "Mb" : "s"), + COLUMN_REAL_VALUE_WIDTH)); + setHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH)); + } +} + +// ======================================================================= +// function : GetMetricColumns +// purpose : +// ======================================================================= +void MessageModel_TreeModel::GetMetricColumns (const Message_MetricType theMetricType, QList& theMetricColumns) +{ + theMetricColumns.clear(); + int aNextIndex = 3; // after default parent columns, see InitColumns + for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) + { + if (theMetricType != (Message_MetricType)aMetricId) + { + aNextIndex += 2; + continue; + } + theMetricColumns.append (aNextIndex++); + theMetricColumns.append (aNextIndex++); + } +} + +// ======================================================================= +// function : IsMetricColumn +// purpose : +// ======================================================================= +bool MessageModel_TreeModel::IsMetricColumn (const int theColumnId, Message_MetricType& theMetricType, int& thePosition) +{ + int aNextIndex = 3; // after default parent columns, see InitColumns + for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) + { + if (theColumnId == aNextIndex || theColumnId == aNextIndex + 1) + { + theMetricType = (Message_MetricType)aMetricId; + thePosition = theColumnId - aNextIndex; + return true; + } + aNextIndex += 2; + } + return false; +} + +// ======================================================================= +// function : createRootItem +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr MessageModel_TreeModel::createRootItem (const int theColumnId) +{ + return MessageModel_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId); +} + +// ======================================================================= +// function : HasShape +// purpose : +// ======================================================================= +Standard_Boolean MessageModel_TreeModel::HasReport (const Handle(Message_Report)& theReport) +{ + if (columnCount() == 0) + return Standard_False; + + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (0)); + return aRootItem && aRootItem->HasReport (theReport); +} + +// ======================================================================= +// function : AddShape +// purpose : +// ======================================================================= +void MessageModel_TreeModel::AddReport (const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription) +{ + for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++) + { + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (aColId)); + if (!aRootItem) + continue; + aRootItem->AddReport (theReport, theReportDescription); + aRootItem->SetReversed (myIsReversed); + } + + Reset(); + EmitLayoutChanged(); +} + +// ======================================================================= +// function : SetReport +// purpose : +// ======================================================================= +void MessageModel_TreeModel::SetReport (const int theRowId, const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription) +{ + for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++) + { + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (aColId)); + if (!aRootItem) + continue; + aRootItem->SetReport (theRowId, theReport, theReportDescription); + } + Reset(); + EmitLayoutChanged(); +} + +// ======================================================================= +// function : Reports +// purpose : +// ======================================================================= +const NCollection_List& MessageModel_TreeModel::Reports() const +{ + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (0)); + return aRootItem->Reports(); +} + +// ======================================================================= +// function : SetReversed +// purpose : +// ======================================================================= +void MessageModel_TreeModel::SetReversed (const Standard_Boolean& theReversed) +{ + myIsReversed = theReversed; + + for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++) + { + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (aColId)); + if (aRootItem) + aRootItem->SetReversed (myIsReversed); + } + + Reset(); + EmitLayoutChanged(); +} + +// ======================================================================= +// function : UpdateTreeModel +// purpose : +// ======================================================================= +void MessageModel_TreeModel::SetRootItemName (const TCollection_AsciiString& theName) +{ + MessageModel_ItemRootPtr aRootItem = itemDynamicCast (RootItem (0)); + if (aRootItem) + aRootItem->SetName (theName); +} + +// ======================================================================= +// function : UpdateTreeModel +// purpose : +// ======================================================================= +void MessageModel_TreeModel::UpdateTreeModel() +{ + Reset(); + EmitLayoutChanged(); +} diff --git a/tools/MessageModel/MessageModel_TreeModel.hxx b/tools/MessageModel/MessageModel_TreeModel.hxx new file mode 100644 index 0000000000..01eeba4144 --- /dev/null +++ b/tools/MessageModel/MessageModel_TreeModel.hxx @@ -0,0 +1,105 @@ +// 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_TreeModel_H +#define MessageModel_TreeModel_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class MessageModel_TreeModel; + +//! \class MessageModel_TreeModel +//! View model to visualize MessageReport/s content +class MessageModel_TreeModel : public TreeModel_ModelBase +{ +public: + + //! Constructor + Standard_EXPORT MessageModel_TreeModel (QObject* theParent); + + //! Destructor + virtual ~MessageModel_TreeModel() Standard_OVERRIDE {}; + + //! Creates model columns and root items. + Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE; + + //!< Returns columns of the model for the metric + //!< \param theMetricType metric + //!< \param theMetricColumns [out] container of metric columns + static Standard_EXPORT void GetMetricColumns (const Message_MetricType theMetricType, QList& theMetricColumns); + + //!< Returns metric type for the column + //!< \param theColumnId [in] index of the tree column + //!< \param theMetricType [out] metric type if found + //!< \param thePosition [out] index of the metric column, 0 - is metric, 1 - is delta + //!< \return true if the column has metric parameters + static Standard_EXPORT bool IsMetricColumn (const int theColumnId, Message_MetricType& theMetricType, int& thePosition); + + //! Returns true if parameter report was added into the model + //! \param theReport a report instance + //! \return boolen value + Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport); + + //! Add shape, append it to the model root item + //! \param theReport a report instance + //! \param theReportDescription an additional report information + Standard_EXPORT void AddReport (const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription = ""); + + //! Set report, se it into the given row index + //! \param theRowId a report child row + //! \param theReport a report instance + //! \param theReportDescription an additional report information + Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription = ""); + + //!< Returns processed reports + Standard_EXPORT const NCollection_List& Reports() const; + + //! Set the view reversed. If reversed, the last report alert is upper item in the tree view + //! \param theReversed boolean flag + Standard_EXPORT void SetReversed (const Standard_Boolean& theReversed); + + //! Return whether the view is reversed or not + //! \return boolean value + Standard_Boolean IsReversed() const { return myIsReversed; }; + + //! Sets the text value of the Root item, only "Name" column accepts the parameter value + //! \theName visulized text of root item + Standard_EXPORT void SetRootItemName (const TCollection_AsciiString& theName); + + //! Updates tree model + Standard_EXPORT void UpdateTreeModel(); + +protected: + //! Creates root item + //! \param theColumnId index of a column + virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE; + +private: + Standard_Boolean myIsReversed; //!< state if the model is reversed +}; + +#endif diff --git a/tools/MessageModel/icons/item_shape.png b/tools/MessageModel/icons/item_shape.png new file mode 100644 index 0000000000000000000000000000000000000000..a808bc55e505fa5e0dd00fc0df80eae5a9eac27c GIT binary patch literal 614 zcmV-s0-61ZP)b8c02hlmzzCYT+BYadXK|ku3NE#KtD1J<#s-Q>%sQ+!Pd3G zm6gg}U6+q^T}lH05CSkipMA8s`T6fXR$sZ?FF zZT+PvV&u1!A~?>>v-R~)PXS_v;(7bR$;s&(%Szt4ddE4y!ot0tvrgx{lgo*c5QVvJ z#rFN6W?9K}zYhLHk^}}2(Q=`%=V+RIXc&osvCHWJi^b}aZ5!_uMU>-;2>Ji|UbI{) zRoBMHlTQ%)?|O{a1y@&h%M%moYi2T28X^KAfB#At_CD5V zw4mAaLq(CA>9qOn0z5nOU$X2_AQBCryTFnpoQop$DJ92(fZqjyd_lwm z#^^`J@a^23(THuaP + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/tools/MessageModel/icons/item_streamValues.png b/tools/MessageModel/icons/item_streamValues.png new file mode 100644 index 0000000000000000000000000000000000000000..7181f9460e4986e85dba66ca426b4cb2797c5a5b GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0vp^!ayvgcyqV(DCY@~pSZg{#l zhFJ8zonn}G*nr2?K9tvFP1^Uws=fu+3m(U^PtcpV*TMhdX^YuetNWZc2Ai*TW#pIr z6mDnJbbwv6MS+2*tb?^-S*G0a!a3Oix3}dp%v+v$D*E%f*K$E#;oJQy;j9Uh_mVWFKf{g+P3I)AOy z*7$RGM@`;Y*CSmgE(%S2Hb?)kfsbh<$HQGZr={{$unc`-ETA4tmYw)LIL1oR_=r>mdKI;Vst0G)P;+W-In literal 0 HcmV?d00001 diff --git a/tools/MessageModel/icons/item_streamValues.svg b/tools/MessageModel/icons/item_streamValues.svg new file mode 100644 index 0000000000..38b1032701 --- /dev/null +++ b/tools/MessageModel/icons/item_streamValues.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/tools/MessageView/FILES b/tools/MessageView/FILES new file mode 100644 index 0000000000..5fe2f52661 --- /dev/null +++ b/tools/MessageView/FILES @@ -0,0 +1,8 @@ +MessageView_ActionsTest.cxx +MessageView_ActionsTest.hxx +MessageView_Communicator.cxx +MessageView_Communicator.hxx +MessageView_VisibilityState.cxx +MessageView_VisibilityState.hxx +MessageView_Window.cxx +MessageView_Window.hxx diff --git a/tools/MessageView/MessageView_ActionsTest.cxx b/tools/MessageView/MessageView_ActionsTest.cxx new file mode 100644 index 0000000000..743a4540c1 --- /dev/null +++ b/tools/MessageView/MessageView_ActionsTest.cxx @@ -0,0 +1,485 @@ +// 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 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//#define DEBUG_ALERTS + +#ifdef DEBUG_ALERTS +#include +#endif + +#include + + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +MessageView_ActionsTest::MessageView_ActionsTest (QWidget* theParent, + MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel) +: QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel) +{ + myActions.insert (MessageModel_ActionType_TestMetric, + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestMetric()), parent(), this)); + myActions.insert (MessageModel_ActionType_TestProperties, + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestPropertyPanel()), parent(), this)); + myActions.insert (MessageModel_ActionType_TestMessenger, + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestMessenger()), parent(), this)); + myActions.insert (MessageModel_ActionType_TestReportTree, + ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestReportTree()), parent(), this)); + myActions.insert (MessageModel_ActionType_TestReportTree2, + ViewControl_Tools::CreateAction ("Test 2", SLOT (OnTestReportTree2()), parent(), this)); +} + +// ======================================================================= +// function : AddMenuActions +// purpose : +// ======================================================================= +void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu) +{ + MessageModel_ItemRootPtr aRootItem; + MessageModel_ItemReportPtr aReportItem; + MessageModel_ItemAlertPtr anAlertItem; + for (QModelIndexList::const_iterator aSelIt = theSelectedIndices.begin(); aSelIt != theSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + aRootItem = itemDynamicCast (anItemBase); + if (aRootItem) + break; + + aReportItem = itemDynamicCast (anItemBase); + if (aReportItem) + break; + + anAlertItem = itemDynamicCast (anItemBase); + if (anAlertItem) + break; + } + + if (aReportItem && !aReportItem->GetReport().IsNull()) + { + theMenu->addAction (myActions[MessageModel_ActionType_TestMetric]); + theMenu->addAction (myActions[MessageModel_ActionType_TestProperties]); + theMenu->addAction (myActions[MessageModel_ActionType_TestMessenger]); + theMenu->addAction (myActions[MessageModel_ActionType_TestReportTree]); + theMenu->addAction (myActions[MessageModel_ActionType_TestReportTree2]); + + bool isReportEnabled = aReportItem->GetReport()->IsActiveInMessenger(); + + myActions[MessageModel_ActionType_TestMetric]->setEnabled (isReportEnabled); + myActions[MessageModel_ActionType_TestProperties]->setEnabled (isReportEnabled); + myActions[MessageModel_ActionType_TestMessenger]->setEnabled (isReportEnabled); + myActions[MessageModel_ActionType_TestReportTree]->setEnabled (isReportEnabled); + myActions[MessageModel_ActionType_TestReportTree2]->setEnabled (isReportEnabled); + } + theMenu->addSeparator(); +} + +// ======================================================================= +// function : getSelectedReport +// purpose : +// ======================================================================= +Handle(Message_Report) MessageView_ActionsTest::getSelectedReport (QModelIndex& theReportIndex) const +{ + MessageModel_ItemReportPtr aReportItem; + QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes(); + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + aReportItem = itemDynamicCast (anItemBase); + theReportIndex = anIndex; + if (aReportItem) + break; + } + if (!aReportItem) + return NULL; + + return aReportItem->GetReport(); +} + +// ======================================================================= +// function : OnTestMetric +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestMetric() +{ +#ifdef DEBUG_ALERTS + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestMetric()"); + unsigned int start_time = clock(); + //Standard_Real aSystemSeconds, aCurrentSeconds; + //OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds); + + Standard_Integer aCounter = 1500;//0; + Standard_Real aValue = 0., aValue2 = 0.1; + + double* aMemValue; + for (int aTopIt = 0; aTopIt < 4; aTopIt++) + { + Message::SendInfo() << "Calculate"; + for (int j = 0; j < aCounter; j++) + { + for (int i = 0; i < aCounter; i++) + { + aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5; + + Standard_Real aValue3 = aValue + aValue2 * 0.2; + (void)aValue3; + + aMemValue = new double; + } + } + } + + //((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged(); + + myTreeModel->UpdateTreeModel(); + + //Standard_Real aSystemSeconds1, aCurrentSeconds1; + //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1); + + //std::cout << aValue << std::endl; + //std::cout << "user time = " << aCurrentSeconds1 - aCurrentSeconds + // << ", system time = " << aSystemSeconds1 - aSystemSeconds << std::endl; + + unsigned int end_time = clock(); + std::cout << "clock() = " << end_time - start_time << std::endl; +#endif +} + +// ======================================================================= +// function : OnTestPropertyPanel +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestPropertyPanel() +{ +#ifdef DEBUG_ALERTS + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestPropertyPanel()"); + + OCCT_SEND_MESSAGE ("Values") + OCCT_SEND_MESSAGE ("Values2") + // gp_XYZ + { + gp_XYZ aCoords (1.3, 2.3, 3.4); + OCCT_SEND_DUMPJSON (&aCoords, "gp_XYZ") + } + // gp_Dir + { + gp_Dir aDir (0.3, 0.3, 0.4); + OCCT_SEND_DUMPJSON (&aDir, "gp_Dir") + } + // gp_Ax1 + { + gp_Ax1 aCoords (gp_Pnt (1.3, 2.3, 3.4), gp_Dir (0.3, 0.3, 0.4)); + OCCT_SEND_DUMPJSON (&aCoords, "gp_Ax1") + } + // gp_Ax2 + { + gp_Ax2 aCoords (gp_Pnt (10.3, 20.3, 30.4), gp_Dir (0.3, 0.3, 0.4)); + OCCT_SEND_DUMPJSON (&aCoords, "gp_Ax2") + } + // gp_Ax3 + { + gp_Ax3 aPln (gp_Pnt (10., 20., 15.), gp_Dir (0., 0., 1.), gp_Dir (1., 0., 0.)); + OCCT_SEND_DUMPJSON (&aPln, "gp_Ax3") + } + // gp_Trsf + { + gp_Trsf aTrsf; + aTrsf.SetRotation (gp::OZ(), 0.3); + aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.)); + aTrsf.SetScaleFactor (3.); + + OCCT_SEND_DUMPJSON (&aTrsf, "gp_Trsf") + } + // Bnd_Box + { + Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.)); + OCCT_SEND_DUMPJSON (&aBox, "Bnd_Box") + } + // 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.); + OCCT_SEND_DUMPJSON (&anOBB, "Bnd_OBB"); + } + // Quantity_ColorRGBA + { + Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f); + OCCT_SEND_DUMPJSON (&aColor, "Quantity_ColorRGBA"); + } + // Quantity_Color + { + Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB); + OCCT_SEND_DUMPJSON (&aColor, "Quantity_Color"); + } + + // stream of some table values + { + Standard_SStream aStream; + OCCT_DUMP_FIELD_VALUES_NUMERICAL (aStream, "value_1", 1, 100); + OCCT_DUMP_FIELD_VALUES_STRING (aStream, "value_2", 2, "value_1", "value_2"); + OCCT_SEND_STREAM (aStream, "Table: Name to value"); + } + + // SHAPE messages + { + BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); + TopoDS_Shape aShape = aBuilder.Shape(); + + MESSAGE_INFO_SHAPE (aShape, "Shape message edge"); + } + + myTreeModel->UpdateTreeModel(); +#endif +} + +// ======================================================================= +// function : createShapeOnLevel +// purpose : +// ======================================================================= +void createShapeOnLevel() +{ + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("createShapeOnLevel") + + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + + BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); + TopoDS_Shape aShape = aBuilder.Shape(); + + MESSAGE_INFO_SHAPE (aShape, "Shape message edge ON LEVEL"); + //sout << "Shape message edge" << aShape; +} + +// ======================================================================= +// function : createShape +// purpose : +// ======================================================================= +void createShape() +{ + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + + BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); + TopoDS_Shape aShape = aBuilder.Shape(); + + MESSAGE_INFO_SHAPE (aShape, "Shape message edge"); + //sout << "Shape message edge" << aShape; + + createShapeOnLevel(); +} + +// ======================================================================= +// function : OnTestMessenger +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestMessenger() +{ + // string messages + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + Standard_Integer aTraceLevel_prev = Message::DefaultMessenger()->TraceLevel(); + Message::DefaultMessenger()->SetTraceLevel (1); + + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestMessenger()") + + sout << "IGESBasic_Hierarchy" << std::endl; + sout << "Number of property valueaMessenger : " << 15 << std::endl; + sout << "Line Font : " << 1 << std::endl << "View Number : " << 3 << std::endl; + sout << "Entity level : " << 1 << std::endl; + sout << "Blank statuaMessenger : " << 0 << std::endl; + sout << "Line weight : " << 14 << std::endl; + sout << "Color number : " << 5 << std::endl; + + // stream messages + // gp_XYZ + { + gp_XYZ aCoords (1.3, 2.3, 3.4); + Standard_SStream aStream; + //aCoords.DumpJson (aStream); + //sout << "gp_XYZ" << aStream << std::endl; + aCoords.DumpJson (sout); + } + // Bnd_Box + { + Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.)); + Standard_SStream aStream; + //aBox.DumpJson (aStream); + //sout << "Bnd_Box" << aStream; + aBox.DumpJson (sout); + } + + // object messages + Handle(Standard_Transient) anObject = new Message_AlertExtended(); + //sout << "Message_AlertExtended" << anObject; + + // shape messages + { + BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); + TopoDS_Shape aShape = aBuilder.Shape(); + + MESSAGE_INFO_SHAPE (aShape, "Shape message edge"); + //sout << "Shape message edge" << aShape; + + createShape(); + } + myTreeModel->UpdateTreeModel(); + Message::DefaultMessenger()->SetTraceLevel (aTraceLevel_prev); +} + +// ======================================================================= +// function : levelAlerts +// purpose : +// ======================================================================= +void levelAlerts (const int theCurrentLevel, const int theTopLevel) +{ + if (theTopLevel - theCurrentLevel <= 0) + return; + + OCCT_ADD_MESSAGE_LEVEL_SENTRY (TCollection_AsciiString ("Level: " ) + theCurrentLevel) + + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "Alert(" << theCurrentLevel << "): " << 1 << ", " << 2 << std::endl; + sout << "Alert(" << theCurrentLevel << "): " << 3 << ", " << 4 << std::endl; + + //for (int i = 0; i < 2; i++) + levelAlerts (theCurrentLevel + 1, theTopLevel); + + sout << "Alert(" << theCurrentLevel << "): " << 4 << ", " << 5 << std::endl; +} + +// ======================================================================= +// function : levelAlert +// purpose : +// ======================================================================= +void levelAlert (const int theCurrentLevel, const int theTopLevel) +{ + if (theTopLevel - theCurrentLevel <= 0) + return; + + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("levelAlert") + + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "Level: " << theCurrentLevel << "(Single, no alerts on the level)" << std::endl; + + //for (int i = 0; i < 2; i++) + levelAlerts (theCurrentLevel + 1, theTopLevel); +} + +// ======================================================================= +// function : OnTestReportTree +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestReportTree() +{ + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestReportTree()") + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + + // string messages + //sout << "Alert: " << 1 << std::endl; + //sout << "Alert: " << 2 << std::endl; + + int aTopLevel = 3; + levelAlerts (1, aTopLevel); + + //sout << "Alert: " << 3 << std::endl; + //levelAlerts (1, aTopLevel); + + sout << "Alert: " << 4 << std::endl; + levelAlert (1, aTopLevel); + + myTreeModel->UpdateTreeModel(); +} + +// ======================================================================= +// function : OnTestReportTree2 +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestReportTree2() +{ + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestReportTree()") + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + + // string messages + //sout << "Alert: " << 1 << std::endl; + //sout << "Alert: " << 2 << std::endl; + + int aTopLevel = 3; + levelAlerts (1, aTopLevel); + + //sout << "Alert: " << 3 << std::endl; + //levelAlerts (1, aTopLevel); + + //sout << "Alert: " << 4 << std::endl; + //levelAlert (1, aTopLevel); + + myTreeModel->UpdateTreeModel(); +} diff --git a/tools/MessageView/MessageView_ActionsTest.hxx b/tools/MessageView/MessageView_ActionsTest.hxx new file mode 100644 index 0000000000..bf58b17ec9 --- /dev/null +++ b/tools/MessageView/MessageView_ActionsTest.hxx @@ -0,0 +1,85 @@ +// Copyright (c) 2020 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 MessageView_ActionsTest_H +#define MessageView_ActionsTest_H + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +class Message_Report; +class MessageModel_TreeModel; +class QItemSelectionModel; + +class QAction; +class QWidget; +class QMenu; + +//! \class MessageView_ActionsTest +//! Window that unites all MessageView controls. +class MessageView_ActionsTest : public QObject +{ + Q_OBJECT +public: + + //! Constructor + MessageView_ActionsTest (QWidget* theParent, MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel); + + //! Destructor + virtual ~MessageView_ActionsTest() {} + + //! Fills popup menu with actions depending on the current selection + //! \param theSelectedIndices tree model selected indices + //! \param theMenu menu to be filled + Standard_EXPORT void AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu); + +public slots: + //! Sending several alerts to check metric of message-alert-tool mechanizm + void OnTestMetric(); + + //! Sending several alerts to check property panel/presentations of message-alert-tool mechanizm + void OnTestPropertyPanel(); + + //! Sending several alerts to check property panel/presentations of messenger-alert-tool mechanizm + void OnTestMessenger(); + + //! Check tree of alerts + void OnTestReportTree(); + + //! Check tree of alerts + void OnTestReportTree2(); + +protected: + //! Returns report of selected tree view item if a report item is selected + //! \param theReportIndex tree model index of the found report + //! \return report instance or NULL + Handle(Message_Report) getSelectedReport (QModelIndex& theReportIndex) const; + +protected: + MessageModel_TreeModel* myTreeModel; //< tree model + QItemSelectionModel* mySelectionModel; //< selection model + QMap myActions; //!< container of all actions +}; + +#endif diff --git a/tools/MessageView/MessageView_Communicator.cxx b/tools/MessageView/MessageView_Communicator.cxx new file mode 100644 index 0000000000..10b95480f7 --- /dev/null +++ b/tools/MessageView/MessageView_Communicator.cxx @@ -0,0 +1,26 @@ +// 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 + + +// ======================================================================= +// function : CreateCommunicator +// purpose : Creates a communicator by the library loading +// ======================================================================= +Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator() +{ + return new MessageView_Communicator(); +} diff --git a/tools/MessageView/MessageView_Communicator.hxx b/tools/MessageView/MessageView_Communicator.hxx new file mode 100644 index 0000000000..7d93c21b55 --- /dev/null +++ b/tools/MessageView/MessageView_Communicator.hxx @@ -0,0 +1,66 @@ +// 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 MessageView_Communicator_H +#define MessageView_Communicator_H + +#include +#include + +//! \class MessageView_Communicator. +//! \brief This is a connector from TInspector application to MessageView window +class MessageView_Communicator : public TInspectorAPI_Communicator +{ +public: + + //! Constructor + MessageView_Communicator() : TInspectorAPI_Communicator(), myWindow (new MessageView_Window (0)) {} + + //! Destructor + virtual ~MessageView_Communicator() Standard_OVERRIDE {} + + //! Provides the container with a parent where this container should be inserted. + //! If Qt implementation, it should be QWidget with QLayout set inside + //! \param theParent a parent class + virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); } + + //! Sets parameters container, it should be used when the plugin is initialized or in update content + //! \param theParameters a parameters container + virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE + { myWindow->SetParameters (theParameters); } + + //! Provide container for actions available in inspector on general level + //! \param theMenu if Qt implementation, it is QMenu object + virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); } + + //! Returns plugin preferences, empty implementation by default + //! \param theItem container of preference elements + virtual void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE + { myWindow->GetPreferences (theItem); } + + //! Stores plugin preferences, empty implementation by default + //! \param theItem container of preference elements + virtual void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE + { myWindow->SetPreferences (theItem); } + + //! Calls update of the plugin's content + virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); } + +private: + + MessageView_Window* myWindow; //!< current window +}; + +#endif diff --git a/tools/MessageView/MessageView_VisibilityState.cxx b/tools/MessageView/MessageView_VisibilityState.cxx new file mode 100644 index 0000000000..9b7993528a --- /dev/null +++ b/tools/MessageView/MessageView_VisibilityState.cxx @@ -0,0 +1,150 @@ +// Created on: 2017-06-16 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +#include +#include + +#include + +// ======================================================================= +// function : CanBeVisible +// purpose : +// ======================================================================= +bool MessageView_VisibilityState::CanBeVisible (const QModelIndex& theIndex) const +{ + MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex); + if (anAlertItem) + { + NCollection_List aPresentations; + anAlertItem->Presentations (aPresentations); + if (!aPresentations.IsEmpty()) + return true; + } + + return !Shape (theIndex).IsNull();// || hasTableValues (theIndex); +} + +// ======================================================================= +// function : SetVisible +// purpose : +// ======================================================================= +bool MessageView_VisibilityState::SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged) +{ + TopoDS_Shape aShape = Shape (theIndex); + if (aShape.IsNull()) + return false; + + myDisplayer->SetVisible (aShape, theState, myPresentationType); + + if (!theState) { + MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex); + if (anAlertItem && !anAlertItem->GetCustomShape().IsNull()) + anAlertItem->SetCustomShape (TopoDS_Shape()); + } + + if (toEmitDataChanged) + { + QModelIndex anIndex = theIndex; + if (theIndex.column() != TreeModel_ColumnType_Visibility) + anIndex = theIndex.model()->index(theIndex.row(), TreeModel_ColumnType_Visibility, theIndex.parent()); + + getModel()->EmitDataChanged (anIndex, anIndex); + } + return true; +} + +// ======================================================================= +// function : IsVisible +// purpose : +// ======================================================================= +bool MessageView_VisibilityState::IsVisible (const QModelIndex& theIndex) const +{ + return myDisplayer->IsVisible (Shape (theIndex), myPresentationType); +} + +// ======================================================================= +// function : OnClicked +// purpose : +// ======================================================================= +void MessageView_VisibilityState::OnClicked (const QModelIndex& theIndex) +{ + processClicked (theIndex); + emit itemClicked (theIndex); +} + +// ======================================================================= +// function : getAlertItem +// purpose : +// ======================================================================= +MessageModel_ItemAlertPtr MessageView_VisibilityState::getAlertItem (const QModelIndex& theIndex) const +{ + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex); + if (!anItemBase) + return MessageModel_ItemAlertPtr(); + + MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); + return anAlertItem; +} + +// ======================================================================= +// function : Shape +// purpose : +// ======================================================================= +TopoDS_Shape MessageView_VisibilityState::Shape (const QModelIndex& theIndex) const +{ + MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex); + if (!anAlertItem) + return TopoDS_Shape(); + + /*if (!anAlertItem->GetCustomShape().IsNull()) + return anAlertItem->GetCustomShape(); + + Handle(Message_Alert) anAlert = anAlertItem->GetAlert(); + if (anAlert.IsNull()) + return TopoDS_Shape(); + + Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast(anAlert); + if (anAlertExtended.IsNull()) + return TopoDS_Shape(); + + Handle(TopoDS_AlertAttribute) aShapeAttribute = Handle(TopoDS_AlertAttribute)::DownCast (anAlertExtended->Attribute()); + if (!aShapeAttribute.IsNull()) + return aShapeAttribute->GetShape(); + */ + return TopoDS_Shape(); +} + +// ======================================================================= +// function : hasTableValues +// purpose : +// ======================================================================= +bool MessageView_VisibilityState::hasTableValues (const QModelIndex& theIndex) const +{ + MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex); + if (!anAlertItem) + return false; + + Handle(Message_Alert) anAlert = anAlertItem->GetAlert(); + if (anAlert.IsNull()) + return false; + + if (anAlert->IsKind (STANDARD_TYPE (Message_AttributeStream))) + return true; + + return false; +} \ No newline at end of file diff --git a/tools/MessageView/MessageView_VisibilityState.hxx b/tools/MessageView/MessageView_VisibilityState.hxx new file mode 100644 index 0000000000..b26e73f4ef --- /dev/null +++ b/tools/MessageView/MessageView_VisibilityState.hxx @@ -0,0 +1,99 @@ +// 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 MessageView_VisibilityState_H +#define MessageView_VisibilityState_H + +#include + +#include + +#include + +#include +#include +#include + +class TreeModel_ModelBase; + +//! \class MessageView_VisibilityState +//! \brief Class provides connection between model and visualization control +class MessageView_VisibilityState : public QObject, public TreeModel_VisibilityState +{ + Q_OBJECT +public: + //! Constructor + MessageView_VisibilityState (TreeModel_ModelBase* theModel) + : TreeModel_VisibilityState (theModel), myPresentationType (View_PresentationType_Main) {} + + //! Destructor + ~MessageView_VisibilityState() {} + + //! Sets current displayer + //! \theDisplayer class that provides connection to visualized objects + void SetDisplayer (View_Displayer* theDisplayer) { myDisplayer = theDisplayer; } + + //! Sets presentation type for displayer + //! \param theType type value + void SetPresentationType (const View_PresentationType theType) { myPresentationType = theType; } + + //! Returns true if visibility of the item can be changed + //! \param theIndex tree model index + //! \return boolean value + Standard_EXPORT virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE; + + //! Sets visibility state + //! \theIndex tree model index + //! \param theState visibility state + //! \param toEmitDataChanged boolean flag whether emit of the model should be done immediatelly + //! \return true if state is changed + Standard_EXPORT virtual bool SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged) Standard_OVERRIDE; + + //! Returns visibility state value + Standard_EXPORT virtual bool IsVisible (const QModelIndex& theIndex) const Standard_OVERRIDE; + +public slots: + //! Processes the mouse clicked on the index. + //! It changes the item visibility if model allows to change it. + //! \theIndex tree model index + void OnClicked (const QModelIndex& theIndex); + +signals: + //! Signal after OnClicked is performed + //! \theIndex tree model index + void itemClicked (const QModelIndex& theIndex); + +protected: + //! Gets the alert item + //! \theIndex tree model index + //! \return item or NULL + MessageModel_ItemAlertPtr getAlertItem (const QModelIndex& theIndex) const; + + //! Gets shape of the view model by the parameter index if it has a shape + //! \param theIndex tree model index + //! \return shape instance + TopoDS_Shape Shape (const QModelIndex& theIndex) const; + + //! Returns true if alert of the item has table values + //! \param theIndex tree model index + //! \return boolean result + bool hasTableValues (const QModelIndex& theIndex) const; + +private: + View_Displayer* myDisplayer; //! view displayer + View_PresentationType myPresentationType; //! presentation type +}; + +#endif diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx new file mode 100644 index 0000000000..a2270827d1 --- /dev/null +++ b/tools/MessageView/MessageView_Window.cxx @@ -0,0 +1,941 @@ +// 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 +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG_ALERTS + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const int DEFAULT_TEXT_VIEW_WIDTH = 800;// 800; +const int DEFAULT_TEXT_VIEW_HEIGHT = 700; +const int DEFAULT_TEXT_VIEW_POSITION_X = 430; +const int DEFAULT_TEXT_VIEW_POSITION_Y = 30; +const int DEFAULT_TEXT_VIEW_DELTA = 100; + +const int DEFAULT_SHAPE_VIEW_WIDTH = 400;// 900; +const int DEFAULT_SHAPE_VIEW_HEIGHT = 450; +const int DEFAULT_SHAPE_VIEW_POSITION_X = 60; +const int DEFAULT_SHAPE_VIEW_POSITION_Y = 60; + +const int DEFAULT_DETACH_POSITION_X = 5; +const int DEFAULT_DETACH_POSITION_Y = 450; + +const int MESSAGEVIEW_DEFAULT_TREE_VIEW_WIDTH = 950; //600 +const int MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500; + +const int MESSAGEVIEW_DEFAULT_VIEW_WIDTH = 200;// 400; +const int MESSAGEVIEW_DEFAULT_VIEW_HEIGHT = 300;// 1000; + +#include +#include +Handle(Prs3d_Drawer) GetPreviewAttributes (const Handle(AIS_InteractiveContext)& theContext) +{ + Handle(Prs3d_Drawer) myDrawer = new Prs3d_Drawer(); + myDrawer->Link (theContext->DefaultDrawer()); + + Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1)); + Standard_ShortReal aTransparency = 0.8; + + // point parameters + myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); + + // shading parameters + Graphic3d_MaterialAspect aShadingMaterial; + aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); + aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT); + + myDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID); + myDrawer->ShadingAspect()->SetColor (aColor); + myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial); + + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); + myDrawer->SetTransparency (aTransparency); + + // common parameters + myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); + + return myDrawer; +} + +// ======================================================================= +// function : Constructor +// purpose : +// ======================================================================= +MessageView_Window::MessageView_Window (QWidget* theParent) +: QObject (theParent) +{ + myMainWindow = new QMainWindow (theParent); + + myTreeView = new ViewControl_TreeView (myMainWindow); + ((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (MESSAGEVIEW_DEFAULT_TREE_VIEW_WIDTH, + MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT)); + MessageModel_TreeModel* aModel = new MessageModel_TreeModel (myTreeView); + aModel->InitColumns(); + //aModel->SetReversed (Standard_True); + + connect (myTreeView->header(), SIGNAL (sectionResized (int, int, int)), + this, SLOT(onHeaderResized (int, int, int))); + + myTreeView->setModel (aModel); + MessageView_VisibilityState* aVisibilityState = new MessageView_VisibilityState (aModel); + aModel->SetVisibilityState (aVisibilityState); + connect (aVisibilityState, SIGNAL (itemClicked (const QModelIndex&)), this, SLOT(onTreeViewVisibilityClicked(const QModelIndex&))); + + TreeModel_Tools::UseVisibilityColumn (myTreeView); + TreeModel_Tools::SetDefaultHeaderSections (myTreeView); + + QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel); + myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection); + myTreeView->setSelectionModel (aSelectionModel); + connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), + this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&))); + + myTreeViewActions = new MessageModel_Actions (myMainWindow, aModel, aSelectionModel); + myTestViewActions = new MessageView_ActionsTest (myMainWindow, aModel, aSelectionModel); + + myTreeView->setContextMenuPolicy (Qt::CustomContextMenu); + connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)), + this, SLOT (onTreeViewContextMenuRequested (const QPoint&))); + //new TreeModel_ContextMenu (myTreeView); + + connect (myTreeView->header(), SIGNAL (sectionResized (int, int, int)), + this, SLOT(onHeaderResized (int, int, int))); + + QModelIndex aParentIndex = myTreeView->model()->index (0, 0); + myTreeView->setExpanded (aParentIndex, true); + + myMainWindow->setCentralWidget (myTreeView); + + // property view + myPropertyView = new ViewControl_PropertyView (myMainWindow); + myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow); + myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle()); + myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow)); + myPropertyPanelWidget->setWidget (myPropertyView->GetControl()); + myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget); + connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool))); + connect (myPropertyView, SIGNAL (propertyViewDataChanged()), this, SLOT (onPropertyViewDataChanged())); + + + // view + myViewWindow = new View_Window (myMainWindow, false); + connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed())); + aVisibilityState->SetDisplayer (myViewWindow->Displayer()); + aVisibilityState->SetPresentationType (View_PresentationType_Main); + myViewWindow->ViewWidget()->SetPredefinedSize (MESSAGEVIEW_DEFAULT_VIEW_WIDTH, MESSAGEVIEW_DEFAULT_VIEW_HEIGHT); + + myViewDockWidget = new QDockWidget (tr ("View"), myMainWindow); + myViewDockWidget->setObjectName (myViewDockWidget->windowTitle()); + myViewDockWidget->setWidget (myViewWindow); + myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myViewDockWidget); + + myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT); + myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y); + + updateVisibleColumns(); +} + +// ======================================================================= +// function : SetParent +// purpose : +// ======================================================================= +void MessageView_Window::SetParent (void* theParent) +{ + QWidget* aParent = (QWidget*)theParent; + if (aParent) + { + QLayout* aLayout = aParent->layout(); + if (aLayout) + aLayout->addWidget (GetMainWindow()); + } + else + { + GetMainWindow()->setParent (0); + GetMainWindow()->setVisible (true); + } +} + +// ======================================================================= +// function : FillActionsMenu +// purpose : +// ======================================================================= +void MessageView_Window::FillActionsMenu (void* theMenu) +{ + QMenu* aMenu = (QMenu*)theMenu; + QList aDockwidgets = myMainWindow->findChildren(); + for (QList::iterator it = aDockwidgets.begin(); it != aDockwidgets.end(); ++it) + { + QDockWidget* aDockWidget = *it; + if (aDockWidget->parentWidget() == myMainWindow) + aMenu->addAction (aDockWidget->toggleViewAction()); + } +} + +// ======================================================================= +// function : GetPreferences +// purpose : +// ======================================================================= +void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem) +{ + theItem.Clear(); + theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str()); + + QMap anItems; + TreeModel_Tools::SaveState (myTreeView, anItems); + for (QMap::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++) + { + theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); + } + + anItems.clear(); + View_Window::SaveState(myViewWindow, anItems); + for (QMap::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++) + { + theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); + } +} + +// ======================================================================= +// function : SetPreferences +// purpose : +// ======================================================================= +void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) +{ + for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next()) + { + if (anItemIt.Key().IsEqual ("geometry")) + myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString())); + else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString())) + continue; + else if (myViewWindow && View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString())) + continue; + } +} + +// ======================================================================= +// function : UpdateContent +// purpose : +// ======================================================================= +void MessageView_Window::UpdateContent() +{ + bool isUpdated = false; + TCollection_AsciiString aName = "TKMessageView"; + if (myParameters->FindParameters (aName)) + { + NCollection_List aParameters = myParameters->Parameters (aName); + // Init will remove from parameters those, that are processed only one time (TShape) + Init (aParameters); + myParameters->SetParameters (aName, aParameters); + isUpdated = true; + } + if (myParameters->FindFileNames (aName)) + { + for (NCollection_List::Iterator aFilesIt (myParameters->FileNames (aName)); + aFilesIt.More(); aFilesIt.Next()) + openFile (aFilesIt.Value()); + + NCollection_List aNames; + myParameters->SetFileNames (aName, aNames); + isUpdated = true; + } + Handle(Message_Report) aDefaultReport = Message::DefaultReport(); + MessageModel_TreeModel* aViewModel = dynamic_cast (myTreeView->model()); + if (!aDefaultReport.IsNull() && !aViewModel->HasReport (aDefaultReport)) + { + addReport (aDefaultReport); + } + // reload report of selected item + //onReloadReport(); + + updateTreeModel(); + updateVisibleColumns(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void MessageView_Window::Init (NCollection_List& theParameters) +{ + Handle(AIS_InteractiveContext) aContext; + NCollection_List aParameters; + + Handle(Graphic3d_Camera) aViewCamera; + + for (NCollection_List::Iterator aParamsIt (theParameters); + aParamsIt.More(); aParamsIt.Next()) + { + Handle(Standard_Transient) anObject = aParamsIt.Value(); + Handle(Message_Report) aMessageReport = Handle(Message_Report)::DownCast (anObject); + if (!aMessageReport.IsNull()) + { + addReport (aMessageReport); + } + else if (!Handle(AIS_InteractiveContext)::DownCast (anObject).IsNull()) + { + aParameters.Append (anObject); + if (aContext.IsNull()) + aContext = Handle(AIS_InteractiveContext)::DownCast (anObject); + } + else if (!Handle(Graphic3d_Camera)::DownCast (anObject).IsNull()) + { + aViewCamera = Handle(Graphic3d_Camera)::DownCast (anObject); + } + } + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + if (!aTreeModel) + return; + + aTreeModel->EmitLayoutChanged(); + + if (!aContext.IsNull()) + { + myViewWindow->SetContext (View_ContextType_External, aContext); + //myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External); + } + + //if (!aViewCamera.IsNull()) + // myViewWindow->View()->Viewer()->View()->Camera()->Copy (aViewCamera); + + theParameters = aParameters; +} + +// ======================================================================= +// function : openFile +// purpose : +// ======================================================================= +void MessageView_Window::openFile(const TCollection_AsciiString& theFileName) +{ + if (theFileName.IsEmpty()) + return; + + const Handle(Message_Report)& aReport = Message::DefaultReport (Standard_True); + + //Handle(Message_Report) aReport = new Message_Report(); + if (aReport->MessageWriter().IsNull()) + aReport->SetMessageWriter (new XmlDrivers_MessageReportStorage()); + + aReport->MessageWriter()->SetFileName (TCollection_AsciiString (theFileName)); + aReport->MessageWriter()->ImportReport (aReport); + + addReport (aReport, theFileName); +} + +// ======================================================================= +// function : updateTreeModel +// purpose : +// ======================================================================= +void MessageView_Window::updateTreeModel() +{ + MessageModel_TreeModel* aViewModel = dynamic_cast (myTreeView->model()); + if (!aViewModel) + return; + + aViewModel->UpdateTreeModel(); +} + +// ======================================================================= +// function : addReport +// purpose : +// ======================================================================= +void MessageView_Window::addReport (const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription) +{ + MessageModel_TreeModel* aModel = dynamic_cast (myTreeView->model()); + aModel->AddReport (theReport, theReportDescription); + + //updateVisibleColumns(); +} + +// ======================================================================= +// function : onTreeViewVisibilityClicked +// purpose : +// ======================================================================= +void MessageView_Window::onTreeViewVisibilityClicked(const QModelIndex& theIndex) +{ + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + TreeModel_VisibilityState* aVisibilityState = aTreeModel->GetVisibilityState(); + if (!aVisibilityState->IsVisible (theIndex)) + myPropertyView->ClearActiveTablesSelection(); +} + +// ======================================================================= +// function : onTreeViewSelectionChanged +// purpose : +// ======================================================================= +void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&) +{ + if (!myPropertyPanelWidget->toggleViewAction()->isChecked()) + return; + + updatePropertyPanelBySelection(); + updatePreviewPresentation(); +} + +// ======================================================================= +// function : onTreeViewContextMenuRequested +// purpose : +// ======================================================================= +void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition) +{ + QMenu* aMenu = new QMenu (GetMainWindow()); + + MessageModel_ItemRootPtr aRootItem; + MessageModel_ItemReportPtr aReportItem; + QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); + + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + aRootItem = itemDynamicCast (anItemBase); + if (aRootItem) + break; + aReportItem = itemDynamicCast (anItemBase); + if (aReportItem) + break; + } + if (aRootItem) + { + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Create Default Report"), + SLOT (onCreateDefaultReport()), myMainWindow, this)); + // unite + //MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsUniteAlerts() ? tr ("SetUniteAlerts - OFF") : tr ("SetUniteAlerts - ON"), + // SLOT (onUniteAlerts()), myMainWindow, this)); + // reversed + //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsReversed() ? tr ("SetReversed - OFF") : tr ("SetReversed - ON"), + // SLOT (onSetReversedAlerts()), myMainWindow, this)); + } + else if (aReportItem) + { + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export Report"), SLOT (onExportReport()), myMainWindow, this)); + const TCollection_AsciiString& aDescription = aReportItem->GetDescription(); + if (!aDescription.IsEmpty()) + { + OSD_Path aPath(aDescription); + OSD_File aDescriptionFile (aPath); + if (aDescriptionFile.IsReadable()) + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Reload"), SLOT (onReloadReport()), myMainWindow, this)); + } + Handle(Message_Report) aReport = aReportItem->GetReport(); + QAction* anAction = ViewControl_Tools::CreateAction (tr ("Export by alert"), SLOT (onAutoExportActivate()), myMainWindow, this); + anAction->setCheckable (true); + anAction->setChecked (aReport->WriteFileOnEachAlert()); + aMenu->addAction (anAction); + + anAction = ViewControl_Tools::CreateAction (tr ("Export trace only"), SLOT (onExportTraceOnly()), myMainWindow, this); + anAction->setCheckable (true); + bool isTraceOnly = aReport->MessageWriter().IsNull() ? false : aReport->MessageWriter()->Gravity() == Message_Trace; + anAction->setChecked (isTraceOnly); + aMenu->addAction (anAction); + } + aMenu->addSeparator(); + + aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Preview children presentations"), SLOT (onPreviewChildren()), myMainWindow, this)); + aMenu->addSeparator(); + + myTreeViewActions->AddMenuActions (aSelectedIndices, aMenu); + addActivateMetricActions (aMenu); + +#ifdef DEBUG_ALERTS + aMenu->addSeparator(); + myTestViewActions->AddMenuActions (aSelectedIndices, aMenu); +#endif + + QPoint aPoint = myTreeView->mapToGlobal (thePosition); + aMenu->exec (aPoint); +} + +// ======================================================================= +// function : onPropertyPanelShown +// purpose : +// ======================================================================= +void MessageView_Window::onPropertyPanelShown (bool isToggled) +{ + if (!isToggled) + return; + + updatePropertyPanelBySelection(); +} + +// ======================================================================= +// function : onPropertyViewDataChanged +// purpose : +// ======================================================================= +void MessageView_Window::onPropertyViewDataChanged() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + + updatePropertyPanelBySelection(); + updatePreviewPresentation(); +} + +// ======================================================================= +// function : onHeaderResized +// purpose : +// ======================================================================= +void MessageView_Window::onHeaderResized (int theSectionId, int, int) +{ + TreeModel_ModelBase* aViewModel = dynamic_cast (myTreeView->model()); + + TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (theSectionId); + aSection->SetWidth (myTreeView->columnWidth (theSectionId)); +} + +// ======================================================================= +// function : onEraseAllPerformed +// purpose : +// ======================================================================= +void MessageView_Window::onEraseAllPerformed() +{ + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + + // TODO: provide update for only visibility state for better performance TopoDS_Shape myCustomShape; + + aTreeModel->Reset(); + aTreeModel->EmitLayoutChanged(); +} + +// ======================================================================= +// function : onExportReport +// purpose : +// ======================================================================= +void MessageView_Window::onExportReport() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItemBase); + if (!aReportItem) + return; + + QString aFilter (tr ("Document file (*.json *)")); + QString aSelectedFilter; + QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export report to file"), QString(), aFilter, &aSelectedFilter); + + Handle(Message_Report) aReport = aReportItem->GetReport(); + Standard_SStream aStream; + aReport->DumpJson(aStream); + + QFile aLogFile(aFileName); + if (!aLogFile.open(QFile::WriteOnly | QFile::Text)) + { + return; + } + QTextStream anOut( &aLogFile ); + anOut << Standard_Dump::FormatJson (aStream).ToCString();//aStream.str().c_str(); + aLogFile.close(); +} + +// ======================================================================= +// function : onCreateDefaultReport +// purpose : +// ======================================================================= +void MessageView_Window::onCreateDefaultReport() +{ + if (!Message::DefaultReport().IsNull()) + { + return; + } + + addReport (Message::DefaultReport (Standard_True)); +} + +// ======================================================================= +// function : onImportReport +// purpose : +// ======================================================================= +//void MessageView_Window::onUniteAlerts() +//{ + //MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + //Standard_Boolean isUniteAlerts = aTreeModel->IsUniteAlerts(); + + //aTreeModel->SetUniteAlerts (!isUniteAlerts); +//} + +// ======================================================================= +// function : onSetReversedAlerts +// purpose : +// ======================================================================= +void MessageView_Window::onSetReversedAlerts() +{ + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + Standard_Boolean isReversed = aTreeModel->IsReversed(); + + aTreeModel->SetReversed (!isReversed); +} + +// ======================================================================= +// function : onReloadReport +// purpose : +// ======================================================================= +void MessageView_Window::onReloadReport() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItemBase); + if (!aReportItem) + aReportItem = MessageModel_ItemReport::FindReportItem (anItemBase); + + if (!aReportItem) + return; + + const TCollection_AsciiString aDescription = aReportItem->GetDescription(); + if (aDescription.IsEmpty()) + return; + + Handle(Message_Report) aReport = aReportItem->GetReport(); + aReport->Clear(); + if (aReport->MessageWriter().IsNull()) + aReport->SetMessageWriter (new XmlDrivers_MessageReportStorage()); + + aReport->MessageWriter()->SetFileName (TCollection_AsciiString (aDescription)); + if (!aReport->MessageWriter()->ImportReport (aReport)) + return; + + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + aModel->clearSelection(); + aTreeModel->SetReport (aReportItem->Row(), aReport, aDescription); +} + +// ======================================================================= +// function : onAutoExportActivate +// purpose : +// ======================================================================= +void MessageView_Window::onAutoExportActivate() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItemBase); + if (!aReportItem) + aReportItem = MessageModel_ItemReport::FindReportItem (anItemBase); + + if (!aReportItem) + return; + + Handle(Message_Report) aReport = aReportItem->GetReport(); + QAction* anAction = (QAction*)(sender()); + aReport->SetWriteFileOnEachAlert (anAction->isChecked()); +} + +// ======================================================================= +// function : onExportTraceOnly +// purpose : +// ======================================================================= +void MessageView_Window::onExportTraceOnly() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(anItemBase); + if (!aReportItem) + aReportItem = MessageModel_ItemReport::FindReportItem (anItemBase); + + if (!aReportItem) + return; + + Handle(Message_Report) aReport = aReportItem->GetReport(); + if (aReport->MessageWriter().IsNull()) + return; + + QAction* anAction = (QAction*)(sender()); + aReport->MessageWriter()->SetGravity (anAction->isChecked() ? Message_Trace : Message_Info); +} + +// ======================================================================= +// function : onPreviewChildren +// purpose : +// ======================================================================= +void MessageView_Window::onPreviewChildren() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + + QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); + NCollection_List aPresentations; + TreeModel_ModelBase::SubItemsPresentations (aSelectedIndices, aPresentations); + + displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations); +} + +// ======================================================================= +// function : addActivateMetricActions +// purpose : +// ======================================================================= +void MessageView_Window::addActivateMetricActions (QMenu* theMenu) +{ + Handle(Message_Report) aReport = Message::DefaultReport(); + if (aReport.IsNull()) + { + return; + } + + QMenu* aSubMenu = new QMenu ("Activate metric"); + for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) + { + Message_MetricType aMetricType = (Message_MetricType)aMetricId; + QAction* anAction = ViewControl_Tools::CreateAction (Message::MetricToString (aMetricType), + SLOT (OnActivateMetric()), parent(), this); + anAction->setCheckable (true); + anAction->setChecked (aReport->ActiveMetrics().Contains (aMetricType)); + aSubMenu->addAction (anAction); + } + aSubMenu->addSeparator(); + aSubMenu->addAction (ViewControl_Tools::CreateAction ("Deactivate all", SLOT (OnDeactivateAllMetrics()), parent(), this)); + + theMenu->addMenu (aSubMenu); +} + +// ======================================================================= +// function : OnActivateMetric +// purpose : +// ======================================================================= +void MessageView_Window::OnActivateMetric() +{ + QAction* anAction = (QAction*)(sender()); + + Message_MetricType aMetricType; + if (!Message::MetricFromString (anAction->text().toStdString().c_str(), aMetricType)) + return; + + Handle(Message_Report) aReport = Message::DefaultReport(); + const NCollection_Map& anActiveMetrics = aReport->ActiveMetrics(); + + aReport->SetActiveMetric (aMetricType, !anActiveMetrics.Contains (aMetricType)); + + updateVisibleColumns(); +} + +// ======================================================================= +// function : OnDeactivateAllMetrics +// purpose : +// ======================================================================= +void MessageView_Window::OnDeactivateAllMetrics() +{ + Handle(Message_Report) aReport = Message::DefaultReport(); + if (aReport.IsNull()) + return; + aReport->ClearMetrics(); + + updateVisibleColumns(); +} + +// ======================================================================= +// function : displayer +// purpose : +// ======================================================================= +View_Displayer* MessageView_Window::displayer() +{ + return myViewWindow->Displayer(); +} + +// ======================================================================= +// function : updatePropertyPanelBySelection +// purpose : +// ======================================================================= +void MessageView_Window::updatePropertyPanelBySelection() +{ + /*QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + + QList aTableValues; + MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues); + + myPropertyView->Init (aTableValues);*/ + ViewControl_TableModelValues* aTableValues = 0; + + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (anItemBase) + { + Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties (); + if (!anItemProperties.IsNull()) + { + aTableValues = new ViewControl_TableModelValues(); + aTableValues->SetProperties (anItemProperties); + } + } + myPropertyView->Init (aTableValues); +} + +// ======================================================================= +// function : updatePreviewPresentation +// purpose : +// ======================================================================= +void MessageView_Window::updatePreviewPresentation() +{ + Handle(AIS_InteractiveContext) aContext = myViewWindow->ViewToolBar()->CurrentContext(); + if (aContext.IsNull()) + return; + + NCollection_List aPresentations; + QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) + { + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; + + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; + + anItemBase->Presentations (aPresentations); + } + + displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations); +} + +// ======================================================================= +// function : updateVisibleColumns +// purpose : +// ======================================================================= +void MessageView_Window::updateVisibleColumns() +{ + MessageModel_TreeModel* aViewModel = dynamic_cast (myTreeView->model()); + + NCollection_Map anActiveMetrics; + for (NCollection_List::Iterator anIterator (aViewModel->Reports()); anIterator.More(); anIterator.Next()) + { + Handle(Message_Report) aReport = anIterator.Value().myReport; + for (NCollection_Map::Iterator aMetricsIterator (aReport->ActiveMetrics()); aMetricsIterator.More(); aMetricsIterator.Next()) + { + if (anActiveMetrics.Contains (aMetricsIterator.Value())) + continue; + anActiveMetrics.Add (aMetricsIterator.Value()); + } + } + + for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) + { + Message_MetricType aMetricType = (Message_MetricType)aMetricId; + QList aMetricColumns; + aViewModel->GetMetricColumns (aMetricType, aMetricColumns); + bool isColumnHidden = !anActiveMetrics.Contains (aMetricType); + for (int i = 0; i < aMetricColumns.size(); i++) + { + int aColumnId = aMetricColumns[i]; + myTreeView->setColumnHidden (aColumnId, isColumnHidden); + TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (aColumnId); + aSection->SetIsHidden (isColumnHidden); + } + } +} diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx new file mode 100644 index 0000000000..bae2ad6fa8 --- /dev/null +++ b/tools/MessageView/MessageView_Window.hxx @@ -0,0 +1,209 @@ +// 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 MessageView_Window_H +#define MessageView_Window_H + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(disable : 4127) // conditional expression is constant +#endif +#include +#include +#include +#include +#include +#include +#include + +class View_Displayer; +class View_Window; + +class ViewControl_PropertyView; + +class MessageView_ActionsTest; + +class QDockWidget; +class QMainWindow; +class QMenu; +class QWidget; + +//! \class MessageView_Window +//! Window that unites all MessageView controls. +class MessageView_Window : public QObject +{ + Q_OBJECT +public: + + //! Constructor + Standard_EXPORT MessageView_Window (QWidget* theParent); + + //! Destructor + virtual ~MessageView_Window() {} + + //! Provides the container with a parent where this container should be inserted. + //! If Qt implementation, it should be QWidget with QLayout set inside + //! \param theParent a parent class + Standard_EXPORT void SetParent (void* theParent); + + //! Sets parameters container, it should be used when the plugin is initialized or in update content + //! \param theParameters a parameters container + void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) + { myParameters = theParameters; myTreeViewActions->SetParameters (theParameters); } + + //! Provide container for actions available in inspector on general level + //! \param theMenu if Qt implementation, it is QMenu object + Standard_EXPORT virtual void FillActionsMenu (void* theMenu); + + //! Returns plugin preferences: dock widgets state, tree view columns. + //! \param theItem container of preference elements + Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem); + + //! Applies plugin preferences + //! \param theItem container of preference elements + Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem); + + //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model + Standard_EXPORT void UpdateContent(); + + //! Returns main control + QMainWindow* GetMainWindow() const { return myMainWindow; } + + //! Returns current tree view + QTreeView* GetTreeView() const { return myTreeView; } + +protected: + //! Appends shape into tree view model + //! \param theShape a shape instance + //! \param theReportDescription an additional report information + void addReport (const Handle(Message_Report)& theReport, + const TCollection_AsciiString& theReportDescription = ""); + +private: + + //! Fills controls of the plugin by parameters: + //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context + //! \param theParameters a parameters container + void Init (NCollection_List& theParameters); + + //! Read Shape from the file name, add Shape into tree view + //! \param theFileName BREP file name + void openFile (const TCollection_AsciiString& theFileName); + + //! Updates tree model + void updateTreeModel(); + +protected slots: + //! Updates property view selection in table if the item is hidden + //! \param theIndex tree view model index + void onTreeViewVisibilityClicked(const QModelIndex& theIndex); + + //! Udpates all controls by changed selection in OCAF tree view + //! \param theSelected list of selected tree view items + //! \param theDeselected list of deselected tree view items + void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); + + //! Shows context menu for tree view selected item. It contains expand/collapse actions. + //! \param thePosition a clicked point + void onTreeViewContextMenuRequested (const QPoint& thePosition); + + //! Display content of selected tree view item if isToggled is true + //! \param isToggled true if the property dock widget is shown + void onPropertyPanelShown (bool isToggled); + + //! Update tree view item, preview presentation by item value change + void onPropertyViewDataChanged(); + + //! Update tree view header item width + void onHeaderResized (int theSectionId, int, int); + + //! Updates visibility states by erase all in context + void onEraseAllPerformed(); + + //! Export report into document + void onExportReport(); + + //! Create default report into document + void onCreateDefaultReport(); + + //! Unite alerts in view model + //void onUniteAlerts(); + + //! Sets report reversed + void onSetReversedAlerts(); + + //! Reads if possible report of a selected item and updates this report in tree view + void onReloadReport(); + + //! Sets report state to write it by each message alert + void onAutoExportActivate(); + + //! Sets report writer state to write only trace information of alerts + void onExportTraceOnly(); + + //! Iterates by children items of selected items and display its presentations if found + void onPreviewChildren(); + + //! Switch active state in report for clicked type of metric + void OnActivateMetric(); + + //! Deactivate all types of metrics for the current report + void OnDeactivateAllMetrics(); + +protected: + //! Appends items to activate report metrics + void addActivateMetricActions (QMenu* theMenu); + + //! Returns displayer where the presentations/preview should be shown/erased + //! If default view is created, it returns displayer of this view + Standard_EXPORT View_Displayer* displayer(); + + //! Updates property panel content by item selected in tree view. + void updatePropertyPanelBySelection(); + + //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes + void updatePreviewPresentation(); + + //!< Sets reports metric columns visible if used + void updateVisibleColumns(); + +private: + QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls + QDockWidget* myViewDockWidget; //!< view dock widget to hide/show + + QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget + ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist + + View_Window* myViewWindow; //!< OCC 3d view to visualize presentations + QTreeView* myTreeView; //!< tree view visualized shapes + MessageModel_Actions* myTreeViewActions; //!< processing history view actions + MessageView_ActionsTest* myTestViewActions; //!< check view actions + + Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container + + Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object +}; + +#endif diff --git a/tools/ShapeView/ShapeView_Window.cxx b/tools/ShapeView/ShapeView_Window.cxx index bfe8d34eca..7ae4fb55c4 100644 --- a/tools/ShapeView/ShapeView_Window.cxx +++ b/tools/ShapeView/ShapeView_Window.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -39,8 +40,15 @@ #include #include +#include +#include #include #include +#include +#include +#include +#include +#include #include #include @@ -107,6 +115,7 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent) aVisibilityState, SLOT (OnClicked(const QModelIndex&))); QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView); + myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection); myTreeView->setSelectionModel (aSelModel); connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&))); @@ -360,42 +369,47 @@ void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); - if (!anItemBase) - return; - QMenu* aMenu = new QMenu(myMainWindow); + ShapeView_ItemRootPtr aRootItem = itemDynamicCast (anItemBase); if (aRootItem) { aMenu->addAction (ViewControl_Tools::CreateAction ("Load BREP file", SLOT (onLoadFile()), myMainWindow, this)); aMenu->addAction (ViewControl_Tools::CreateAction ("Remove all shape items", SLOT (onClearView()), myMainWindow, this)); } - else { + else if (anItemBase) { // single selection aMenu->addAction (ViewControl_Tools::CreateAction ("Export to BREP", SLOT (onExportToBREP()), myMainWindow, this)); + ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(anItemBase); - const TopoDS_Shape& aShape = aShapeItem->GetItemShape(); - TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType(); - NCollection_List anExplodeTypes; - ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes); - if (anExplodeTypes.Size() > 0) + if (aShapeItem) { - QMenu* anExplodeMenu = aMenu->addMenu ("Explode"); - for (NCollection_List::Iterator anExpIterator (anExplodeTypes); anExpIterator.More(); - anExpIterator.Next()) + const TopoDS_Shape& aShape = aShapeItem->GetItemShape(); + TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType(); + NCollection_List anExplodeTypes; + ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes); + if (anExplodeTypes.Size() > 0) { - TopAbs_ShapeEnum aType = anExpIterator.Value(); - QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this); - anExplodeMenu->addAction (anAction); - if (anExplodeType == aType) + QMenu* anExplodeMenu = aMenu->addMenu ("Explode"); + for (NCollection_List::Iterator anExpIterator (anExplodeTypes); anExpIterator.More(); + anExpIterator.Next()) { - anAction->setCheckable (true); - anAction->setChecked (true); + TopAbs_ShapeEnum aType = anExpIterator.Value(); + QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this); + anExplodeMenu->addAction (anAction); + if (anExplodeType == aType) + { + anAction->setCheckable (true); + anAction->setChecked (true); + } } + QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this); + anExplodeMenu->addSeparator(); + anExplodeMenu->addAction (anAction); } - QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this); - anExplodeMenu->addSeparator(); - anExplodeMenu->addAction (anAction); } } + aMenu->addAction (ViewControl_Tools::CreateAction ("Create Face", SLOT (onCreateFace()), myMainWindow, this)); + aMenu->addAction (ViewControl_Tools::CreateAction ("Create Compound", SLOT (onCreateCompound()), myMainWindow, this)); + aMenu->addAction (ViewControl_Tools::CreateAction ("Algo: Incremental Mesh", SLOT (onIncrementalMesh()), myMainWindow, this)); QPoint aPoint = myTreeView->mapToGlobal (thePosition); aMenu->exec (aPoint); @@ -521,3 +535,84 @@ void ShapeView_Window::onExportToBREP() anItem->SetFileName (aFileNameIndiced.ToCString()); aFileName = aFileNameIndiced.ToCString(); } + +// ======================================================================= +// function : onCreateFace +// purpose : +// ======================================================================= +void ShapeView_Window::onCreateFace() +{ + /*QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QList anItems = TreeModel_ModelBase::SelectedItems (aModel->selectedIndexes()); + + QList aSelectedIds; // Remember of selected address in order to avoid duplicates + NCollection_List anItemPresentations; + + BRepBuilderAPI_MakeWire aWireBuilder; + for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt) + { + ShapeView_ItemShapePtr anItem = itemDynamicCast(*anItemIt); + if (!anItem) + continue; + + const TopoDS_Shape& aShape = anItem->GetItemShape(); + if (aShape.ShapeType() != TopAbs_EDGE) + continue; + + const TopoDS_Edge& aSourceEdge = TopoDS::Edge (aShape); + const TopoDS_Edge& anEdgeCopied = TopoDS::Edge (aSourceEdge.EmptyCopied()); + + aWireBuilder.Add (anEdgeCopied);//aSourceEdge); + } + if (!aWireBuilder.IsDone()) + return; + + BRepBuilderAPI_MakeFace aFaceBuilder; + + const TopoDS_Wire& aWire = aWireBuilder.Wire(); + const TopoDS_Wire& aWireCopied = TopoDS::Wire (aWire.EmptyCopied()); + + aFaceBuilder.Add (aWireCopied); + + addShape (aFaceBuilder.Face()); + */ +} + +// ======================================================================= +// function : onCreateCompound +// purpose : +// ======================================================================= +void ShapeView_Window::onCreateCompound() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QList anItems = TreeModel_ModelBase::SelectedItems (aModel->selectedIndexes()); + + QList aSelectedIds; // Remember of selected address in order to avoid duplicates + NCollection_List anItemPresentations; + + BRep_Builder aBB; + TopoDS_Compound aC; + aBB.MakeCompound(aC); + + for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt) + { + ShapeView_ItemShapePtr anItem = itemDynamicCast(*anItemIt); + if (!anItem) + return; + + aBB.Add(aC, anItem->GetItemShape()); + } + addShape (aC); +} + +// ======================================================================= +// function : onIncrementalMesh +// purpose : +// ======================================================================= +void ShapeView_Window::onIncrementalMesh() +{ +} diff --git a/tools/ShapeView/ShapeView_Window.hxx b/tools/ShapeView/ShapeView_Window.hxx index 950119326e..5119fd9039 100644 --- a/tools/ShapeView/ShapeView_Window.hxx +++ b/tools/ShapeView/ShapeView_Window.hxx @@ -129,6 +129,15 @@ protected slots: //! Views BREP files of selected items if exist void onExportToBREP(); + //! Create a wire of selected edges + void onCreateFace(); + + //! Create a compound of selected shapes + void onCreateCompound(); + + //! Perform BRepMesh_IncrementalMesh on the selected shape + void onIncrementalMesh(); + //! Convers file name to Ascii String and perform opeging file //! \param theFileName a file name to be opened void onOpenFile(const QString& theFileName) { OpenFile (TCollection_AsciiString (theFileName.toUtf8().data())); } diff --git a/tools/TInspector/TInspector_Communicator.cxx b/tools/TInspector/TInspector_Communicator.cxx index 8ec0c8cc2a..e06404ee8c 100644 --- a/tools/TInspector/TInspector_Communicator.cxx +++ b/tools/TInspector/TInspector_Communicator.cxx @@ -15,8 +15,10 @@ #include +#include #include #include + #include #include @@ -37,16 +39,59 @@ TInspector_Communicator::TInspector_Communicator() static int argc = 1; static char* argv[] = { (char*)"", 0 }; #if QT_VERSION > 0x050000 - OSD_Environment anEnvironment ("QTDIR"); - TCollection_AsciiString aPlugindsDirName = anEnvironment.Value(); - aPlugindsDirName += "/plugins"; - QApplication::addLibraryPath (aPlugindsDirName.ToCString()); + TCollection_AsciiString aPlugindsDirName; + if (TInspector_Communicator::PluginsDir (aPlugindsDirName)) + QApplication::addLibraryPath (aPlugindsDirName.ToCString()); #endif new QApplication (argc, argv); } myWindow = new TInspector_Window(); } +// ======================================================================= +// function : PluginsDir +// purpose : +// ======================================================================= +Standard_Boolean TInspector_Communicator::PluginsDir (TCollection_AsciiString& thePlugindsDirName) +{ + OSD_Environment anEnvironment ("QTDIR"); + TCollection_AsciiString aQtDirValue = anEnvironment.Value(); + if (!aQtDirValue.IsEmpty()) + { + thePlugindsDirName = aQtDirValue + "/plugins"; + return Standard_True; + } + anEnvironment = OSD_Environment ("PATH"); + TCollection_AsciiString aPathValue = anEnvironment.Value(); + TCollection_AsciiString aPathSep = +#ifdef _WIN32 + ';'; +#else + ':'; +#endif + for (int i = 1; !aPathValue.IsEmpty(); i++) + { + Standard_Integer aSepIndex = aPathValue.FirstLocationInSet (aPathSep, 1, aPathValue.Length()); + if (aSepIndex <= 1) + break; + + TCollection_AsciiString aCurPath = aPathValue.SubString (1, aSepIndex - 1); + aPathValue = aSepIndex < aPathValue.Length() ? aPathValue.SubString (aSepIndex + 1, aPathValue.Length()) : ""; + if (aCurPath.IsEmpty()) + continue; + + aCurPath += "/../plugins"; + OSD_Path aPath (aCurPath); + OSD_Directory aCurDir (aPath); + if (aCurDir.Exists()) + { + thePlugindsDirName = aCurPath; + return Standard_True; + } + } + return Standard_False; +} + // ======================================================================= // function : SetVisible // purpose : diff --git a/tools/TInspector/TInspector_Communicator.hxx b/tools/TInspector/TInspector_Communicator.hxx index f2d8633878..01d368b2dc 100644 --- a/tools/TInspector/TInspector_Communicator.hxx +++ b/tools/TInspector/TInspector_Communicator.hxx @@ -40,6 +40,9 @@ public: //! Destructor virtual ~TInspector_Communicator() {} + //! Returns directory of Qt plugins. Firstly it founds it in QTDIR, else if not defined in PATH + Standard_EXPORT static Standard_Boolean PluginsDir (TCollection_AsciiString& thePlugindsDirName); + //! Registers plugin into TInspector window //! \param thePluginName a name of the plugin void RegisterPlugin (const TCollection_AsciiString& thePluginName) { myWindow->RegisterPlugin (thePluginName); } diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx index 73ab696359..f3b29732f2 100644 --- a/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -19,6 +19,8 @@ #include +#include +#include #include #include @@ -87,9 +89,9 @@ void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspecto int main (int argc, char** argv) { #if QT_VERSION > 0x050000 - TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); - if (!aPlugindsDirName.IsEmpty()) - QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); + TCollection_AsciiString aPlugindsDirName; + if (TInspector_Communicator::PluginsDir (aPlugindsDirName)) + QApplication::addLibraryPath (aPlugindsDirName.ToCString()); #endif QApplication anApp (argc, argv); @@ -104,6 +106,9 @@ int main (int argc, char** argv) if (!strcmp (argv[anArgId], "vinspector")) aPlugins.insert ("TKVInspector"); + + if (!strcmp (argv[anArgId], "messageview")) + aPlugins.insert ("TKMessageView"); } NCollection_List aParameters; @@ -123,7 +128,14 @@ int main (int argc, char** argv) aPlugins.insert("TKShapeView"); aPlugins.insert("TKVInspector"); - anActivatedPluginName = "TKDFBrowser"; + //Handle(Message_Report) aReport = Message::DefaultReport (Standard_True); + //aReport->SetLimit (100);//30); + aPlugins.insert("TKMessageView"); + + //anActivatedPluginName = "TKVInspector"; + //anActivatedPluginName = "TKMessageView"; + //anActivatedPluginName = "TKDFBrowser"; + anActivatedPluginName = "TKShapeView"; } else anActivatedPluginName = *aPlugins.rbegin(); diff --git a/tools/TKMessageModel/CMakeLists.txt b/tools/TKMessageModel/CMakeLists.txt new file mode 100644 index 0000000000..911ffb1fbe --- /dev/null +++ b/tools/TKMessageModel/CMakeLists.txt @@ -0,0 +1,5 @@ +project(TKMessageModel) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKMessageModel/EXTERNLIB b/tools/TKMessageModel/EXTERNLIB new file mode 100644 index 0000000000..54b02742af --- /dev/null +++ b/tools/TKMessageModel/EXTERNLIB @@ -0,0 +1,10 @@ +TKMath +TKBin +TKBRep +TKGeomBase +TKG3d +TKTInspectorAPI +TKService +TKTopAlgo +TKTreeModel +CSF_QT diff --git a/tools/TKMessageModel/FILES b/tools/TKMessageModel/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/tools/TKMessageModel/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/tools/TKMessageModel/PACKAGES b/tools/TKMessageModel/PACKAGES new file mode 100644 index 0000000000..9021fbf297 --- /dev/null +++ b/tools/TKMessageModel/PACKAGES @@ -0,0 +1 @@ +MessageModel diff --git a/tools/TKMessageView/CMakeLists.txt b/tools/TKMessageView/CMakeLists.txt new file mode 100644 index 0000000000..9b3c1aaec7 --- /dev/null +++ b/tools/TKMessageView/CMakeLists.txt @@ -0,0 +1,5 @@ +project(TKMessageView) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKMessageView/EXTERNLIB b/tools/TKMessageView/EXTERNLIB new file mode 100644 index 0000000000..84e5b5d8b5 --- /dev/null +++ b/tools/TKMessageView/EXTERNLIB @@ -0,0 +1,13 @@ +TKTInspectorAPI +TKMath +TKMessageModel +TKBin +TKBRep +TKGeomBase +TKG3d +TKService +TKTopAlgo +TKTreeModel +TKView +TKXml +CSF_QT diff --git a/tools/TKMessageView/FILES b/tools/TKMessageView/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/tools/TKMessageView/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/tools/TKMessageView/PACKAGES b/tools/TKMessageView/PACKAGES new file mode 100644 index 0000000000..46a67b229d --- /dev/null +++ b/tools/TKMessageView/PACKAGES @@ -0,0 +1 @@ +MessageView diff --git a/tools/TKVInspector/EXTERNLIB b/tools/TKVInspector/EXTERNLIB index a54f90d251..8b42f7d545 100644 --- a/tools/TKVInspector/EXTERNLIB +++ b/tools/TKVInspector/EXTERNLIB @@ -6,6 +6,7 @@ TKMath TKV3d TKView TKService +TKTopAlgo TKTreeModel TKBO CSF_QT \ No newline at end of file diff --git a/tools/TKView/EXTERNLIB b/tools/TKView/EXTERNLIB index 72cf33304f..8cd89c728d 100644 --- a/tools/TKView/EXTERNLIB +++ b/tools/TKView/EXTERNLIB @@ -1,3 +1,4 @@ +TKBRep TKG3d TKernel TKMath diff --git a/tools/ToolsDraw/ToolsDraw.cxx b/tools/ToolsDraw/ToolsDraw.cxx index c0abd7766a..104bda3336 100644 --- a/tools/ToolsDraw/ToolsDraw.cxx +++ b/tools/ToolsDraw/ToolsDraw.cxx @@ -62,6 +62,7 @@ Standard_Boolean convertToPluginName (const TCollection_AsciiString& theArgument if (anArgument == "dfbrowser") { thePluginName = "TKDFBrowser"; return Standard_True; } else if (anArgument == "shapeview") { thePluginName = "TKShapeView"; return Standard_True; } else if (anArgument == "vinspector") { thePluginName = "TKVInspector"; return Standard_True; } + else if (anArgument == "messageview") { thePluginName = "TKMessageView"; return Standard_True; } return Standard_False; } @@ -305,6 +306,7 @@ static int tinspector (Draw_Interpretor& di, Standard_Integer theArgsNb, const c aPlugins.Append ("TKDFBrowser"); aPlugins.Append ("TKShapeView"); aPlugins.Append ("TKVInspector"); + aPlugins.Append ("TKMessageView"); } aPluginNameToActivate = !aPluginNameToActivate.IsEmpty() ? aPluginNameToActivate : aPlugins.First(); } @@ -391,10 +393,10 @@ void ToolsDraw::Commands(Draw_Interpretor& theCommands) "\n\t\t: Starts tool of inspection." "\n\t\t: Options:" "\n\t\t: -plugins enters plugins that should be added in the inspector." - "\n\t\t: Available names are: dfbrowser, vinspector and shapeview." + "\n\t\t: Available names are: dfbrowser, vinspector, shapeview and messageview." "\n\t\t: Plugins order will be the same as defined in arguments." "\n\t\t: 'all' adds all available plugins in the order:" - "\n\t\t: DFBrowser, VInspector and ShapeView." + "\n\t\t: DFBrowser, VInspector, ShapeView and MessageView." "\n\t\t: If at the first call this option is not used, 'all' option is applied;" "\n\t\t: -activate activates the plugin in the tool view." "\n\t\t: If at the first call this option is not used, the first plugin is activated;" diff --git a/tools/TreeModel/TreeModel_ColumnType.hxx b/tools/TreeModel/TreeModel_ColumnType.hxx index 80cb3f97da..520cec6fdf 100644 --- a/tools/TreeModel/TreeModel_ColumnType.hxx +++ b/tools/TreeModel/TreeModel_ColumnType.hxx @@ -24,7 +24,8 @@ enum TreeModel_ColumnType { TreeModel_ColumnType_Name = 0, //! name column - TreeModel_ColumnType_Visibility //! visibility state column + TreeModel_ColumnType_Visibility, //! visibility state column + TreeModel_ColumnType_Row //! row of the item column }; #endif diff --git a/tools/TreeModel/TreeModel_ContextMenu.cxx b/tools/TreeModel/TreeModel_ContextMenu.cxx index 9a60792c60..9cd0d07ab6 100644 --- a/tools/TreeModel/TreeModel_ContextMenu.cxx +++ b/tools/TreeModel/TreeModel_ContextMenu.cxx @@ -55,7 +55,7 @@ void TreeModel_ContextMenu::onTreeViewHeaderContextMenuRequested (const QPoint& int aNbSections = aModel->columnCount(); for (int aColumnId = 0; aColumnId < aNbSections; aColumnId++) { - QAction* anAction = ViewControl_Tools::CreateAction (aModel->GetHeaderItem (aColumnId).GetName(), + QAction* anAction = ViewControl_Tools::CreateAction (aModel->ChangeHeaderItem (aColumnId)->GetName(), SLOT (onColumnVisibilityChanged()), myTreeView, this); anAction->setCheckable (true); anAction->setChecked (!myTreeView->isColumnHidden (aColumnId)); diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 1b23b909cb..359ed39018 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -14,6 +14,8 @@ // commercial license or contractual agreement. #include + +#include #include #include #include @@ -195,7 +197,7 @@ QVariant TreeModel_ItemBase::initValue (const int theItemRole) const switch (Column()) { - case 1: { return Row(); } + case TreeModel_ColumnType_Row: { return Row(); } } return QVariant(); diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index 4c121f8213..8654b06876 100644 --- a/tools/TreeModel/TreeModel_ItemBase.hxx +++ b/tools/TreeModel/TreeModel_ItemBase.hxx @@ -16,12 +16,12 @@ #ifndef TreeModel_ItemBase_H #define TreeModel_ItemBase_H -#include #include #include #include #include #include +#include #include @@ -150,7 +150,10 @@ public: //! Returns the item properties const Handle(TreeModel_ItemProperties)& Properties() const { return myProperties; } + //! Returns presentation of the attribute to be visualized in the view + //! \thePresentations [out] container of presentation handles to be visualized Standard_EXPORT virtual void Presentations (NCollection_List& thePresentations); + protected: //! \param theParent the parent item diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index 3e6b4f5f83..8ea5ef2ce0 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -39,6 +39,15 @@ void TreeModel_ItemProperties::Init () const Standard_SStream& aStream = Item()->Stream(); + InitByStream (aStream); +} + +// ======================================================================= +// function : InitByStream +// purpose : +// ======================================================================= +void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream) +{ NCollection_IndexedDataMap aValues; TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream); Standard_Dump::SplitJson (aStreamText, aValues); @@ -48,8 +57,15 @@ void TreeModel_ItemProperties::Init () Standard_DumpValue aKeyValue; if (!aStreamParent) { - const Handle(Standard_Transient)& anItemObject = Item()->Object(); - aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name(); + if (!Item() || Item()->Object().IsNull()) + { + aKey = "Dump"; + } + else + { + const Handle(Standard_Transient)& anItemObject = Item()->Object(); + aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name(); + } aKeyValue = Standard_DumpValue (aStreamText, 1); myKey = aKey; @@ -95,6 +111,11 @@ void TreeModel_ItemProperties::Init () (int)(aGreen * aDelta), (int)(aBlue * aDelta))); } } + // in case if the stream alert has empty key avalue, use as the key the first row value + if ((myKey.IsEmpty() || myKey.IsEqual ("Dump")) && myRowValues.Size() > 0) + { + myKey = myRowValues.FindFromIndex (1).Value.toString().toStdString().c_str(); + } } // ======================================================================= @@ -172,10 +193,16 @@ ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int th // function : SetData // purpose : // ======================================================================= -bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColumn, const QVariant& /*theValue*/, int) +bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, const QVariant& theValue, int theRole) { if (theColumn == 0) return false; + + if (theRole == Qt::DisplayRole || theRole == Qt::EditRole) + { + myRowValues.ChangeFromIndex (theRow + 1).Value = theValue; + } + return false; } @@ -185,6 +212,8 @@ bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColum // ======================================================================= void TreeModel_ItemProperties::Presentations (NCollection_List& thePresentations) { + if (!Item()) + return; const Standard_SStream& aStream = Item()->Stream(); Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations); } diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index 7f498d70e4..a86ef9baec 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -73,6 +73,9 @@ public: //! Sets the current item void SetItem (const TreeModel_ItemBasePtr& theItem) { myItem = theItem; } + //! Fills properties with the stream value + Standard_EXPORT void InitByStream (const Standard_SStream& theStream); + //! Returns the current item TreeModel_ItemBasePtr Item() const { return myItem; } @@ -80,7 +83,7 @@ public: Standard_EXPORT void Init(); //! If the item has internal values, there should be reseted here. - Standard_EXPORT virtual void Reset(); + Standard_EXPORT void Reset(); //! Returns number of table rows //! \return an integer value @@ -108,18 +111,18 @@ public: //! \param theColumn a model index column //! \param theRole a view role //! \return true if the value is changed - Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue, - int theRole = Qt::DisplayRole); + Standard_EXPORT bool SetData (const int theRow, const int theColumn, const QVariant& theValue, + int theRole = Qt::DisplayRole); //! Returns presentation of the attribute to be visualized in the view //! \thePresentations [out] container of presentation handles to be visualized - Standard_EXPORT virtual void Presentations (NCollection_List& thePresentations); + Standard_EXPORT void Presentations (NCollection_List& thePresentations); //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable. //! Additional flag for the column 1 is Qt::ItemIsEditable. //! \param theIndex a model index //! \return flags - Standard_EXPORT virtual Qt::ItemFlags TableFlags (const int theRow, const int theColumn) const; + Standard_EXPORT Qt::ItemFlags TableFlags (const int theRow, const int theColumn) const; //! Returns stream value of the item to fulfill property panel. //! \return stream value or dummy diff --git a/tools/TreeModel/TreeModel_ModelBase.cxx b/tools/TreeModel/TreeModel_ModelBase.cxx index a87cbe662e..5dd4055b7e 100644 --- a/tools/TreeModel/TreeModel_ModelBase.cxx +++ b/tools/TreeModel/TreeModel_ModelBase.cxx @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -46,9 +47,9 @@ TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent) // ======================================================================= void TreeModel_ModelBase::InitColumns() { - SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); - SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); - SetHeaderItem (2, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH)); + setHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); + setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); + setHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH)); } // ======================================================================= @@ -177,7 +178,7 @@ QVariant TreeModel_ModelBase::headerData (int theSection, Qt::Orientation theOri if (IsUseVisibilityColumn() && theSection == TreeModel_ColumnType_Visibility) return QVariant(); - return GetHeaderItem (theSection).GetName(); + return myHeaderValues[theSection].GetName(); } // ======================================================================= @@ -231,23 +232,6 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const #endif } -// ======================================================================= -// function : SetHeaderItem -// purpose : -// ======================================================================= -void TreeModel_ModelBase::SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection) -{ - if (theSection.IsEmpty()) - { - // remove section - myHeaderValues.remove (theColumnId); - myRootItems.remove (theColumnId); - } - - myHeaderValues[theColumnId] = theSection; - createRoot (theColumnId); -} - // ======================================================================= // function : Selected // purpose : @@ -295,6 +279,40 @@ QList TreeModel_ModelBase::SelectedItems (const QModelInd return anItems; } +// ======================================================================= +// function : SubItemsPresentations +// purpose : +// ======================================================================= +void TreeModel_ModelBase::SubItemsPresentations (const QModelIndexList& theIndices, + NCollection_List& thePresentations) +{ + QList anItems; + + for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++) + { + TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt); + if (!anItem || anItems.contains (anItem)) + continue; + subItemsPresentations (anItem, thePresentations); + } +} + +// ======================================================================= +// function : subItemPresentations +// purpose : +// ======================================================================= +void TreeModel_ModelBase::subItemsPresentations (const TreeModel_ItemBasePtr& theItem, + NCollection_List& thePresentations) +{ + theItem->Presentations (thePresentations); + + QList anItems; + for (int aRowId = 0; aRowId < theItem->rowCount(); aRowId++) + { + subItemsPresentations (theItem->Child (aRowId, theItem->Column()), thePresentations); + } +} + // ======================================================================= // function : createRoot // purpose : @@ -304,6 +322,23 @@ void TreeModel_ModelBase::createRoot (const int theColumnId) myRootItems.insert (theColumnId, createRootItem (theColumnId)); } +// ======================================================================= +// function : setHeaderItem +// purpose : +// ======================================================================= +void TreeModel_ModelBase::setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection) +{ + if (theSection.IsEmpty()) + { + // remove section + myHeaderValues.remove (theColumnId); + myRootItems.remove (theColumnId); + } + + myHeaderValues[theColumnId] = theSection; + createRoot (theColumnId); +} + // ======================================================================= // function : getIndexValue // purpose : diff --git a/tools/TreeModel/TreeModel_ModelBase.hxx b/tools/TreeModel/TreeModel_ModelBase.hxx index b8a31e903e..f616846496 100644 --- a/tools/TreeModel/TreeModel_ModelBase.hxx +++ b/tools/TreeModel/TreeModel_ModelBase.hxx @@ -141,12 +141,7 @@ public: //! Returns whether the column is hidden by default //! \param theColumnId a column index //! \return header section values container - TreeModel_HeaderSection GetHeaderItem (const int theColumnId) const { return myHeaderValues[theColumnId]; } - - //! Sets header properties item. - //! \param theColumnId a column index - //! \param theSection a section value - Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection); + TreeModel_HeaderSection* ChangeHeaderItem (const int theColumnId) { return &myHeaderValues[theColumnId]; } //! Returns count of columns in the model //! \param theParent an index of the parent item @@ -180,16 +175,33 @@ public: //! \return model items from the list Standard_EXPORT static QList SelectedItems (const QModelIndexList& theIndices); + //! Returns presentations of sub items + //! \param theIndices a container of selected indices + //! \thePresentations [out] container of presentation handles to be visualized + Standard_EXPORT static void SubItemsPresentations (const QModelIndexList& theIndices, + NCollection_List& thePresentations); + protected: //! Creates root item //! \param theColumnId index of a column virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0; + //! Sets header properties item. + //! \param theColumnId a column index + //! \param theSection a section value + Standard_EXPORT void setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection); + //! Converts the item shared pointer to void* type //! \param theItem //! \return an item pointer Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem); + //! Returns presentations of sub items + //! \param theIndices a container of selected indices + //! \thePresentations [out] container of presentation handles to be visualized + static void subItemsPresentations (const TreeModel_ItemBasePtr& theItem, + NCollection_List& thePresentations); + private: //! Creates root item //! \param theColumnId index of a column diff --git a/tools/TreeModel/TreeModel_Tools.cxx b/tools/TreeModel/TreeModel_Tools.cxx index e3d8b2afa5..00bc92f59f 100644 --- a/tools/TreeModel/TreeModel_Tools.cxx +++ b/tools/TreeModel/TreeModel_Tools.cxx @@ -89,6 +89,7 @@ void TreeModel_Tools::SaveState (QTreeView* theTreeView, QMap& QStringList aColumnWidths, aHiddenColumns; for (int aColumnId = 0; aColumnId < theTreeView->model()->columnCount(); aColumnId++) { + int aWidth = theTreeView->columnWidth (aColumnId); if (theTreeView->isColumnHidden (aColumnId)) { aHiddenColumns.append (QString::number (aColumnId)); @@ -121,18 +122,18 @@ bool TreeModel_Tools::RestoreState (QTreeView* theTreeView, const QString& theKe } else if (theKey == thePrefix + "columns_hidden") { - int aColumnSize = theTreeView->model()->columnCount(); - QStringList aValues = theValue.split (",", QString::SkipEmptyParts); - QList aColumnIds; - for (int aValueId = 0; aValueId < aValues.size(); aValueId++) - { - if (aValueId < aColumnSize) - aColumnIds.append (aValues.at (aValueId).toInt()); - } - for (int aColumnId = 0; aColumnId < aColumnSize; aColumnId++) - { - theTreeView->setColumnHidden (aColumnId, aColumnIds.contains(aColumnId) == true); - } + //int aColumnSize = theTreeView->model()->columnCount(); + //QStringList aValues = theValue.split (",", QString::SkipEmptyParts); + //QList aColumnIds; + //for (int aValueId = 0; aValueId < aValues.size(); aValueId++) + //{ + // if (aValueId < aColumnSize) + // aColumnIds.append (aValues.at (aValueId).toInt()); + //} + //for (int aColumnId = 0; aColumnId < aColumnSize; aColumnId++) + //{ + // theTreeView->setColumnHidden (aColumnId, aColumnIds.contains(aColumnId) == true); + //} } else return false; @@ -149,9 +150,9 @@ void TreeModel_Tools::SetDefaultHeaderSections(QTreeView* theTreeView) for (int aColumnId = 0, aNbColumns = aTreeModel->columnCount(); aColumnId < aNbColumns; aColumnId++) { - TreeModel_HeaderSection aSection = aTreeModel->GetHeaderItem (aColumnId); - theTreeView->setColumnWidth (aColumnId, aSection.GetWidth()); - theTreeView->setColumnHidden (aColumnId, aSection.IsHidden()); + TreeModel_HeaderSection* aSection = aTreeModel->ChangeHeaderItem (aColumnId); + theTreeView->setColumnWidth (aColumnId, aSection->GetWidth()); + theTreeView->setColumnHidden (aColumnId, aSection->IsHidden()); } } @@ -170,8 +171,10 @@ void TreeModel_Tools::UseVisibilityColumn (QTreeView* theTreeView, const bool th aHeader->moveSection (TreeModel_ColumnType_Name, TreeModel_ColumnType_Visibility); TreeModel_ModelBase* aModel = dynamic_cast (theTreeView->model()); - aModel->SetHeaderItem (TreeModel_ColumnType_Visibility, - TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); + TreeModel_HeaderSection* anItem = aModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility); + anItem->SetIsHidden (theActive); + anItem->SetWidth (TreeModel_ModelBase::ColumnVisibilityWidth()); + aModel->SetUseVisibilityColumn (theActive); } diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index 0394262f8d..85d3755710 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -10,6 +10,8 @@ VInspector_ItemBase.cxx VInspector_ItemBase.hxx VInspector_ItemContext.cxx VInspector_ItemContext.hxx +VInspector_ItemContextProperties.cxx +VInspector_ItemContextProperties.hxx VInspector_ItemHistoryElement.cxx VInspector_ItemHistoryElement.hxx VInspector_ItemHistoryRoot.cxx @@ -19,6 +21,10 @@ VInspector_ItemHistoryType.hxx VInspector_ItemHistoryTypeInfo.hxx VInspector_ItemPresentableObject.cxx VInspector_ItemPresentableObject.hxx +VInspector_ItemSelectMgrViewerSelector.cxx +VInspector_ItemSelectMgrViewerSelector.hxx +VInspector_ItemV3dViewer.cxx +VInspector_ItemV3dViewer.hxx VInspector_ToolActionType.hxx VInspector_ToolBar.cxx VInspector_ToolBar.hxx diff --git a/tools/VInspector/VInspector_ItemBase.cxx b/tools/VInspector/VInspector_ItemBase.cxx index 591ecb0661..3ac0a4e022 100644 --- a/tools/VInspector/VInspector_ItemBase.cxx +++ b/tools/VInspector/VInspector_ItemBase.cxx @@ -43,7 +43,7 @@ QVariant VInspector_ItemBase::initValue (const int theItemRole) const case 3: return Standard_Dump::GetPointerInfo (Object(), true).ToCString(); } - return QVariant(); + return TreeModel_ItemBase::initValue (theItemRole); } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemBase.hxx b/tools/VInspector/VInspector_ItemBase.hxx index 4e35513625..cfe70758d8 100644 --- a/tools/VInspector/VInspector_ItemBase.hxx +++ b/tools/VInspector/VInspector_ItemBase.hxx @@ -51,11 +51,6 @@ public: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; - //! Returns presentation of the attribute to be visualized in the view - //! \thePresentations [out] container of presentation handles to be visualized - virtual void Presentations (NCollection_List& thePresentations) - { (void)thePresentations; } - //! Returns transform persistent of the item or NULL Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; } diff --git a/tools/VInspector/VInspector_ItemContext.cxx b/tools/VInspector/VInspector_ItemContext.cxx index 27400ac661..7725ff7313 100644 --- a/tools/VInspector/VInspector_ItemContext.cxx +++ b/tools/VInspector/VInspector_ItemContext.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,8 @@ int VInspector_ItemContext::initRowCount() const if (Column() != 0) return 0; + int aNbProperties = 1; // item to visualize Viewer information of context + Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (Object()); if (aContext.IsNull()) return 0; @@ -49,7 +52,7 @@ int VInspector_ItemContext::initRowCount() const aNbPresentations++; } - return aNbPresentations; + return aNbProperties + aNbPresentations; } // ======================================================================= @@ -124,7 +127,10 @@ void VInspector_ItemContext::initItem() const // ======================================================================= TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theColumn) { - return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn); + if (theRow == 0) + return VInspector_ItemContextProperties::CreateItem (currentItem(), theRow, theColumn); + else + return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn); } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemContextProperties.cxx b/tools/VInspector/VInspector_ItemContextProperties.cxx new file mode 100644 index 0000000000..020d02821c --- /dev/null +++ b/tools/VInspector/VInspector_ItemContextProperties.cxx @@ -0,0 +1,68 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemContextProperties::initValue (int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)) + return QVariant(); + + return "Properties"; +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemContextProperties::initRowCount() const +{ + return 2; // V3d_Viewer, SelectMgr_ViewerSelector +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemContextProperties::createChild (int theRow, int theColumn) +{ + if (theRow == 0) + return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn); + + return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemContextProperties::initItem() const +{ + if (IsInitialized()) + return; + const_cast (this)->Init(); +} diff --git a/tools/VInspector/VInspector_ItemContextProperties.hxx b/tools/VInspector/VInspector_ItemContextProperties.hxx new file mode 100644 index 0000000000..cb53b44855 --- /dev/null +++ b/tools/VInspector/VInspector_ItemContextProperties.hxx @@ -0,0 +1,70 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemContextProperties_H +#define VInspector_ItemContextProperties_H + +#include +#include + +#include +#include + +class VInspector_ItemContextProperties; +typedef QExplicitlySharedDataPointer VInspector_ItemContextPropertiesPtr; + +//! \class VInspector_ItemContextProperties +//! Item presents additional level of information in the tree model. +//! Parent is item context, child is v3d viewer item. +class VInspector_ItemContextProperties : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemContextPropertiesPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemContextPropertiesPtr (new VInspector_ItemContextProperties (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemContextProperties() Standard_OVERRIDE {}; + +protected: + //! Initializes the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of item selected + //! \return rows count + virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + VInspector_ItemContextProperties (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase (theParent, theRow, theColumn) {} + +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemPresentableObject.hxx b/tools/VInspector/VInspector_ItemPresentableObject.hxx index 28ea239953..31df492fc6 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.hxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.hxx @@ -61,7 +61,7 @@ public: //! Returns presentation of the attribute to be visualized in the view //! \thePresentations [out] container of presentation handles to be visualized - Standard_EXPORT virtual void Presentations (NCollection_List& thePresentations); + Standard_EXPORT virtual void Presentations (NCollection_List& thePresentations) Standard_OVERRIDE; protected: diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx new file mode 100644 index 0000000000..3846f94018 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -0,0 +1,105 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemSelectMgrViewerSelector::initRowCount() const +{ + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemSelectMgrViewerSelector::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + if (GetViewerSelector().IsNull()) + return Column() == 0 ? "Empty viewer selector" : ""; + + return Column() == 0 ? GetViewerSelector()->DynamicType()->Name() : QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::Init() +{ + VInspector_ItemContextPropertiesPtr aParentItem = itemDynamicCast(Parent()); + Handle(SelectMgr_ViewerSelector) aViewerSelector; + if (aParentItem) + { + VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(aParentItem->Parent()); + if (aParentContextItem) + { + Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext(); + aViewerSelector = aContext->MainSelector(); + } + } + myViewerSelector = aViewerSelector; + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::Reset() +{ + VInspector_ItemBase::Reset(); + + myViewerSelector = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initStream +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrViewerSelector::initStream (Standard_OStream& theOStream) const +{ + Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); + if (aViewerSelector.IsNull()) + return; + + aViewerSelector->DumpJson (theOStream); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx new file mode 100644 index 0000000000..aa2d4c7fb3 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx @@ -0,0 +1,85 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemSelectMgrViewerSelector_H +#define VInspector_ItemSelectMgrViewerSelector_H + +#include +#include + +#include + +class VInspector_ItemSelectMgrViewerSelector; +typedef QExplicitlySharedDataPointer VInspector_ItemSelectMgrViewerSelectorPtr; + +//! \class VInspector_ItemSelectMgrViewerSelector +//! Parent item is context properties, that corresponds to SelectMgr_ViewerSelector +class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemSelectMgrViewerSelectorPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemSelectMgrViewerSelectorPtr (new VInspector_ItemSelectMgrViewerSelector (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemSelectMgrViewerSelector() Standard_OVERRIDE {}; + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns data object of the item. + //! \return object + virtual const Handle(Standard_Transient)& Object() const { initItem(); return myViewerSelector; } + + //! Returns the current viewer, init item if it was not initialized yet + //! \return interactive object + Handle(SelectMgr_ViewerSelector) GetViewerSelector() const { return Handle(SelectMgr_ViewerSelector)::DownCast (Object()); } + +protected: + //! Initializes the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + VInspector_ItemSelectMgrViewerSelector (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +protected: + + Handle(SelectMgr_ViewerSelector) myViewerSelector; //!< the current viewer selector +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemV3dViewer.cxx b/tools/VInspector/VInspector_ItemV3dViewer.cxx new file mode 100644 index 0000000000..17edd0c174 --- /dev/null +++ b/tools/VInspector/VInspector_ItemV3dViewer.cxx @@ -0,0 +1,105 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemV3dViewer::initRowCount() const +{ + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + if (GetViewer().IsNull()) + return Column() == 0 ? "Empty viewer" : ""; + + return Column() == 0 ? GetViewer()->DynamicType()->Name() : QVariant(); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemV3dViewer::Init() +{ + VInspector_ItemContextPropertiesPtr aParentItem = itemDynamicCast(Parent()); + Handle(V3d_Viewer) aViewer; + if (aParentItem) + { + VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(aParentItem->Parent()); + if (aParentContextItem) + { + Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext(); + aViewer = aContext->CurrentViewer(); + } + } + myViewer = aViewer; + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemV3dViewer::Reset() +{ + VInspector_ItemBase::Reset(); + + myViewer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemV3dViewer::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initStream +// purpose : +// ======================================================================= +void VInspector_ItemV3dViewer::initStream (Standard_OStream& theOStream) const +{ + Handle(V3d_Viewer) aViewer = GetViewer(); + if (aViewer.IsNull()) + return; + + aViewer->DumpJson (theOStream); +} diff --git a/tools/VInspector/VInspector_ItemV3dViewer.hxx b/tools/VInspector/VInspector_ItemV3dViewer.hxx new file mode 100644 index 0000000000..b70c046e0c --- /dev/null +++ b/tools/VInspector/VInspector_ItemV3dViewer.hxx @@ -0,0 +1,85 @@ +// Created on: 2020-02-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemV3dViewer_H +#define VInspector_ItemV3dViewer_H + +#include +#include + +#include + +class VInspector_ItemV3dViewer; +typedef QExplicitlySharedDataPointer VInspector_ItemV3dViewerPtr; + +//! \class VInspector_ItemV3dViewer +//! Parent item is context properties, that corresponds to AIS_InteractiveContext +class VInspector_ItemV3dViewer : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemV3dViewerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemV3dViewerPtr (new VInspector_ItemV3dViewer (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemV3dViewer() Standard_OVERRIDE {}; + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns data object of the item. + //! \return object + virtual const Handle(Standard_Transient)& Object() const { initItem(); return myViewer; } + + //! Returns the current viewer, init item if it was not initialized yet + //! \return interactive object + Handle(V3d_Viewer) GetViewer() const { return Handle(V3d_Viewer)::DownCast (Object()); } + +protected: + //! Initializes the current item. It is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + VInspector_ItemV3dViewer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +protected: + + Handle(V3d_Viewer) myViewer; //!< the current viewer +}; + +#endif diff --git a/tools/VInspector/VInspector_ViewModel.cxx b/tools/VInspector/VInspector_ViewModel.cxx index 2ca792b334..894d0a3ba3 100644 --- a/tools/VInspector/VInspector_ViewModel.cxx +++ b/tools/VInspector/VInspector_ViewModel.cxx @@ -43,8 +43,8 @@ void VInspector_ViewModel::InitColumns() { TreeModel_ModelBase::InitColumns(); - SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH)); - SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); + setHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH)); + setHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); } // ======================================================================= diff --git a/tools/VInspector/VInspector_ViewModelHistory.cxx b/tools/VInspector/VInspector_ViewModelHistory.cxx index 980dc1e865..0b50eca7d8 100644 --- a/tools/VInspector/VInspector_ViewModelHistory.cxx +++ b/tools/VInspector/VInspector_ViewModelHistory.cxx @@ -54,13 +54,13 @@ void VInspector_ViewModelHistory::InitColumns() { TreeModel_ModelBase::InitColumns(); - SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); - SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item - SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH)); - SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH)); - SetHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH)); - SetHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH)); - SetHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1)); + setHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); + setHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item + setHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH)); + setHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH)); + setHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH)); + setHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH)); + setHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1)); for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++) { diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 1991dbe631..163df690dd 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -112,9 +112,8 @@ VInspector_Window::VInspector_Window() aTreeModel->InitColumns(); myTreeView->setModel (aTreeModel); // hide Visibility column - TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility); - anItem.SetIsHidden (true); - aTreeModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem); + TreeModel_HeaderSection* anItem = aTreeModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility); + anItem->SetIsHidden (true); connect (myTreeView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT (onTreeViewContextMenuRequested(const QPoint&))); @@ -157,12 +156,11 @@ VInspector_Window::VInspector_Window() connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&))); - anItem = aHistoryModel->GetHeaderItem (0); + anItem = aHistoryModel->ChangeHeaderItem (0); // hide Visibility column TreeModel_Tools::UseVisibilityColumn (myHistoryView, false); - anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility); - anItem.SetIsHidden (true); - aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem); + anItem = aHistoryModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility); + anItem->SetIsHidden (true); QModelIndex aParentIndex = myHistoryView->model()->index (0, 0); myHistoryView->setExpanded (aParentIndex, true); @@ -634,12 +632,12 @@ void VInspector_Window::onExportToShapeView() TCollection_AsciiString aPluginName ("TKShapeView"); NCollection_List aParameters; - if (myParameters->FindParameters (aPluginName)) - aParameters = myParameters->Parameters (aPluginName); + //if (myParameters->FindParameters (aPluginName)) + // aParameters = myParameters->Parameters (aPluginName); NCollection_List anItemNames; - if (myParameters->FindSelectedNames (aPluginName)) - anItemNames = myParameters->GetSelectedNames (aPluginName); + //if (myParameters->FindSelectedNames (aPluginName)) + // anItemNames = myParameters->GetSelectedNames (aPluginName); QStringList anExportedPointers; if (aSelectedShapes.Extent() > 0) @@ -659,23 +657,23 @@ void VInspector_Window::onExportToShapeView() } } - // search for objects to be exported - QList anItems = TreeModel_ModelBase::SelectedItems (myTreeView->selectionModel()->selectedIndexes()); - for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt) - { - TreeModel_ItemBasePtr anItem = *anItemIt; - VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (!aVItem) - continue; - - const Handle(Standard_Transient)& anObject = aVItem->Object(); - if (anObject.IsNull()) - continue; - - aParameters.Append (anObject); - anItemNames.Append (anObject->DynamicType()->Name()); - anExportedPointers.append (Standard_Dump::GetPointerInfo (anObject, true).ToCString()); - } + //// search for objects to be exported + //QList anItems = TreeModel_ModelBase::SelectedItems (myTreeView->selectionModel()->selectedIndexes()); + //for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); ++anItemIt) + //{ + // TreeModel_ItemBasePtr anItem = *anItemIt; + // VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); + // if (!aVItem) + // continue; + + // const Handle(Standard_Transient)& anObject = aVItem->Object(); + // if (anObject.IsNull()) + // continue; + + // aParameters.Append (anObject); + // anItemNames.Append (anObject->DynamicType()->Name()); + // anExportedPointers.append (Standard_Dump::GetPointerInfo (anObject, true).ToCString()); + //} if (anExportedPointers.isEmpty()) return; diff --git a/tools/View/View_Displayer.cxx b/tools/View/View_Displayer.cxx index fb868a9c2e..cf2db59296 100644 --- a/tools/View/View_Displayer.cxx +++ b/tools/View/View_Displayer.cxx @@ -310,18 +310,19 @@ void View_Displayer::DisplayedPresentations (NCollection_SharedCurrentViewer(); - if (!aViewer.IsNull()) - { - aViewer->InitActiveViews(); - if (aViewer->MoreActiveViews()) - aView = aViewer->ActiveView(); - } - return aView; + const Handle(V3d_Viewer)& aViewer = theContext->CurrentViewer(); + if (aViewer.IsNull()) + return NULL; + + aViewer->InitActiveViews(); + if (!aViewer->MoreActiveViews()) + return NULL; + + return aViewer->ActiveView(); } // ======================================================================= diff --git a/tools/View/View_PreviewParameters.cxx b/tools/View/View_PreviewParameters.cxx index 44e2968384..f6375e5658 100644 --- a/tools/View/View_PreviewParameters.cxx +++ b/tools/View/View_PreviewParameters.cxx @@ -28,7 +28,7 @@ View_PreviewParameters::View_PreviewParameters() myDrawer = new Prs3d_Drawer(); Quantity_Color aColor(Quantity_NOC_TOMATO); - Standard_ShortReal aTransparency = 0.8f; + Standard_ShortReal aTransparency = 0.8; // point parameters myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); diff --git a/tools/ViewControl/FILES b/tools/ViewControl/FILES index 9fda7a71be..3560ed5779 100644 --- a/tools/ViewControl/FILES +++ b/tools/ViewControl/FILES @@ -3,6 +3,8 @@ ViewControl_MessageDialog.cxx ViewControl_MessageDialog.hxx ViewControl_PropertyView.cxx ViewControl_PropertyView.hxx +ViewControl_PropertiesDialog.cxx +ViewControl_PropertiesDialog.hxx ViewControl_Table.cxx ViewControl_Table.hxx ViewControl_TableModel.cxx diff --git a/tools/ViewControl/ViewControl_PropertiesDialog.cxx b/tools/ViewControl/ViewControl_PropertiesDialog.cxx new file mode 100644 index 0000000000..c72627aa6e --- /dev/null +++ b/tools/ViewControl/ViewControl_PropertiesDialog.cxx @@ -0,0 +1,65 @@ +// Copyright (c) 2020 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 : Constructor +// purpose : +// ======================================================================= +ViewControl_PropertiesDialog::ViewControl_PropertiesDialog (QWidget* theParent) +: QDialog (theParent) +{ + setWindowTitle ("Properties"); + + QGridLayout* aLayout = new QGridLayout (this); + myTable = new ViewControl_Table (this); + ViewControl_TableModel* aModel = new ViewControl_TableModel (myTable->TableView()); + myTable->SetModel (aModel); + + aLayout->addWidget(myTable->TableView(), 0, 0, 1, 3); + + myOkButton = new QPushButton ("Ok", this); + myCancelButton = new QPushButton ("Cancel", this); + connect (myOkButton, SIGNAL (clicked()), this, SLOT (accept())); + connect (myCancelButton, SIGNAL (clicked()), this, SLOT (reject())); + aLayout->addWidget (myOkButton, 1, 1); + aLayout->addWidget (myCancelButton, 1, 2); + + aLayout->setColumnStretch (0, 1); + + myCancelButton->setDefault (true); + + setMinimumSize (200, 600); +} + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void ViewControl_PropertiesDialog::Init (const Handle(TreeModel_ItemProperties)& theProperties) +{ + ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues(); + aTableValues->SetProperties (theProperties); + + myTable->Init (aTableValues); +} diff --git a/tools/ViewControl/ViewControl_PropertiesDialog.hxx b/tools/ViewControl/ViewControl_PropertiesDialog.hxx new file mode 100644 index 0000000000..609bcb9226 --- /dev/null +++ b/tools/ViewControl/ViewControl_PropertiesDialog.hxx @@ -0,0 +1,54 @@ +// Copyright (c) 2020 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef ViewControl_PropertiesDialog_H +#define ViewControl_PropertiesDialog_H + +#include +#include + +#include + +#include +#include +#include + +class TreeModel_ItemProperties; + +class QWidget; +class QPushButton; + +//! \class ViewControl_PropertiesDialog +//! Dialog providing table of stream values +class ViewControl_PropertiesDialog : public QDialog +{ + Q_OBJECT +public: + + //! Constructor + Standard_EXPORT ViewControl_PropertiesDialog (QWidget* theParent); + + //! Destructor + virtual ~ViewControl_PropertiesDialog() {} + + Standard_EXPORT void Init (const Handle(TreeModel_ItemProperties)& theProperties); + +private: + ViewControl_Table* myTable; //!< table view + + QPushButton* myOkButton; //!< accept button + QPushButton* myCancelButton; //!< reject button +}; + + +#endif -- 2.39.5