]> OCCT Git - occt-copy.git/commitdiff
0031362: Inspectors - MessageView plugin for message alerts
authornds <nds@opencascade.com>
Tue, 27 Oct 2020 16:24:59 +0000 (19:24 +0300)
committernds <nds@opencascade.com>
Tue, 17 Nov 2020 10:04:16 +0000 (13:04 +0300)
- OSD_Timer in message alert,
- DumpJson correction,
- Selection owner should be dumped in selector. Sensitive entities might be used in the same owner, that leads to lots of the same dump in the result stream.

(cherry picked from commit e8bde810616e61cbe925981176681f2840234fa4)

44 files changed:
src/Message/Message.cxx
src/Message/Message_Alert.cxx
src/Message/Message_Alert.hxx
src/Message/Message_AlertExtended.cxx
src/Message/Message_AlertExtended.hxx
src/Message/Message_Attribute.cxx
src/Message/Message_Attribute.hxx
src/Message/Message_AttributeMeter.cxx
src/Message/Message_AttributeMeter.hxx
src/Message/Message_AttributeObject.hxx
src/Message/Message_AttributeStream.cxx
src/Message/Message_AttributeStream.hxx
src/Message/Message_CompositeAlerts.cxx
src/Message/Message_CompositeAlerts.hxx
src/Message/Message_MetricType.hxx
src/Message/Message_PrinterToReport.cxx
src/Message/Message_PrinterToReport.hxx
src/Message/Message_Report.cxx
src/Message/Message_Report.hxx
src/OSD/OSD_Timer.hxx
src/Select3D/Select3D_SensitiveEntity.cxx
src/SelectMgr/SelectMgr_Selection.cxx
src/Standard/Standard_Dump.cxx
src/Standard/Standard_Dump.hxx
src/TopoDS/TopoDS_AlertAttribute.cxx
src/TopoDS/TopoDS_AlertAttribute.hxx
tools/DFBrowser/DFBrowser_TreeModel.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx
tools/MessageModel/MessageModel_Actions.cxx
tools/MessageModel/MessageModel_ItemAlert.cxx
tools/MessageModel/MessageModel_ItemReport.cxx
tools/MessageModel/MessageModel_TreeModel.cxx
tools/MessageView/MessageView_Window.cxx
tools/MessageView/MessageView_Window.hxx
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TreeModel/TreeModel_ContextMenu.cxx
tools/TreeModel/TreeModel_ItemBase.cxx
tools/TreeModel/TreeModel_ModelBase.cxx
tools/TreeModel/TreeModel_ModelBase.hxx
tools/TreeModel/TreeModel_Tools.cxx
tools/VInspector/VInspector_ItemBase.cxx
tools/VInspector/VInspector_ViewModel.cxx
tools/VInspector/VInspector_ViewModelHistory.cxx
tools/VInspector/VInspector_Window.cxx

index a6c63176e1f2c989cc37044dae7c77ef3ae5efda..8b888403bce1f3a726ec7cf43b8592540567d7bd 100644 (file)
@@ -27,9 +27,9 @@ static Handle(Message_Messenger) MyMessenger;
 
 namespace
 {
-  static Standard_CString Message_Table_PrintMetricTypeEnum[10] =
+  static Standard_CString Message_Table_PrintMetricTypeEnum[11] =
   {
-    "NONE", "UserTimeCPU", "SystemTimeInfo", "MemPrivate", "MemVirtual",
+    "NONE", "UserTimeCPU", "SystemTimeCPU", "WallClock", "MemPrivate", "MemVirtual",
     "MemWorkingSet", "MemWorkingSetPeak", "MemSwapUsage", "MemSwapUsagePeak", "MemHeapUsage"
   };
 }
index 5901a49a096237fc29cc2676ea2f6f4828196e0c..c9148aa9730752b9475b772b6fa0df2751444666 100644 (file)
@@ -14,6 +14,7 @@
 // commercial license or contractual agreement.
 
 #include <Message_Alert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_Alert,Standard_Transient)
 
@@ -48,3 +49,12 @@ Standard_Boolean Message_Alert::Merge (const Handle(Message_Alert)& /*theTarget*
   // by default, merge trivially
   return Standard_True;
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Alert::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+}
index a460787354e88bc6a9121068d88b299deb6fe689..8a624570623254781db429425afbf94e180f6cd5 100644 (file)
@@ -54,6 +54,9 @@ public:
   //! Base implementation always returns true.
   virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
   
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Alert,Standard_Transient)
 };
 
index 843c3b6d311ac96ffda58005d1b992b2b968b266..a203777eb7c3c64a7438605ac27289123327b7b1 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Precision.hxx>
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AlertExtended,Message_Alert)
 
@@ -89,3 +90,22 @@ Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Repo
 
   return anAlert;
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AlertExtended::DumpJson (Standard_OStream& theOStream,
+                                      Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  if (!myCompositAlerts.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCompositAlerts.get())
+  }
+  if (!myAttribute.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAttribute.get())
+  }
+}
index 8c0420836d7e9f9efc7e362ee16deb317ee88535..0487dd56eaf80757ce083ee699f6ed17521e1a1a 100644 (file)
@@ -78,6 +78,10 @@ public:
                                                          const Handle(Message_Attribute)& theAttribute,
                                                          const Message_Gravity theGravity);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
 
 protected:
index 6efcd0f7ba1801342130026e0f8bad334cad10fa..3f0fb284e723e0a7caab27645f2019afb7c48cf7 100644 (file)
@@ -14,6 +14,7 @@
 #include <Message_Attribute.hxx>
 
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
 
@@ -26,3 +27,13 @@ Standard_CString Message_Attribute::GetMessageKey () const
 {
   return !myName.IsEmpty() ? myName.ToCString() : "";
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Attribute::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName)
+}
index cce24fd803ef2ca706de2776e6089d75810cf87c..773bbf2937f83a256f43789f28089410c97cc084 100644 (file)
@@ -43,6 +43,9 @@ public:
   //! @param theName a name for the alert
   void SetName (const TCollection_AsciiString& theName) { myName = theName; }
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
 
 private:
index f9571b9befed083cf62d66511316d32740efe1ac..e89f11862a9efb579f90bb7a185fc84c87ce4d88 100644 (file)
 #include <Message.hxx>
 #include <Message_Report.hxx>
 #include <OSD_Chronometer.hxx>
+#include <OSD_Timer.hxx>
 
 #include <Precision.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
 
@@ -121,6 +123,16 @@ void Message_AttributeMeter::SetAlertMetrics (const Handle(Message_AlertExtended
   const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
 
   // time metrics
+  if (anActiveMetrics.Contains (Message_MetricType_WallClock))
+  {
+    OSD_Timer aTimer;
+    aTimer.Start();
+    Standard_Real aTime = aTimer.StartTime();
+    if (theStartValue)
+      aMeterAttribute->SetStartValue (Message_MetricType_WallClock, aTime);
+    else
+      aMeterAttribute->SetStopValue (Message_MetricType_WallClock, aTime);
+  }
   if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU) ||
       anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo))
   {
@@ -173,3 +185,21 @@ void Message_AttributeMeter::SetAlertMetrics (const Handle(Message_AlertExtended
       aMeterAttribute->SetStopValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AttributeMeter::DumpJson (Standard_OStream& theOStream,
+                                       Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  for (NCollection_DataMap<Message_MetricType, StartToStopValue>::Iterator anIterator (myMetrics);
+       anIterator.More(); anIterator.Next())
+  {
+    OCCT_DUMP_VECTOR_CLASS (theOStream, Message::MetricToString (anIterator.Key()),
+                            2, anIterator.Value().first, anIterator.Value().second)
+  }
+}
index 72be3f6097eac8744566134b8b8162eb2d0c82ad..d322385d2e4d174b6d34c07a4816b94c44c1f967 100644 (file)
@@ -80,6 +80,10 @@ public:
   static Standard_EXPORT void SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
                                                const Standard_Boolean theStartValue);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
 
 private:
index 3775685da1e3f0c1c902239bcf15f5f069dff618..c9f5d7c2f06a7a5ef95539bc3bdf4bbecb5e11a0 100644 (file)
@@ -15,6 +15,7 @@
 #define _Message_AttributeObject_HeaderFile
 
 #include <Message_Attribute.hxx>
+#include <Standard_Dump.hxx>
 
 class Standard_Transient;
 
@@ -35,6 +36,15 @@ public:
   //! @param theObject an instance
   void SetObject (const Handle(Standard_Transient)& theObject) { myObject = theObject; }
 
+  //! Dumps the content of me into the stream
+  virtual void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE
+  {
+    OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+    OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+    OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myObject.get())
+  }
+
   DEFINE_STANDARD_RTTI_INLINE(Message_AttributeObject, Message_Attribute)
 
 private:
index f0cf9314159b28f54a64dcdbd75715a63e189749..72abd8689074d5cca308b0baaceffd81e8534830 100644 (file)
@@ -12,6 +12,7 @@
 // commercial license or contractual agreement.
 
 #include <Message_AttributeStream.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
 
@@ -39,3 +40,15 @@ void Message_AttributeStream::SetStream (const Standard_SStream& theStream)
   myStream << aStreamStr;
 }
 
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_AttributeStream::DumpJson (Standard_OStream& theOStream,
+                                        Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  OCCT_DUMP_STREAM_VALUE_DUMPED (theOStream, myStream)
+}
index c4a73527fa1c9b1ca7bee289b7066ed05d159bf1..2f992dd486baceef180b13b0c24ad14df45224ca 100644 (file)
@@ -34,6 +34,10 @@ public:
   //! Sets stream value
   Standard_EXPORT void SetStream (const Standard_SStream& theStream);
 
+  //! Dumps the content of me into the stream
+  virtual Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                         Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   DEFINE_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
 
 private:
index 48d0e14be950c9d71c7f9282bb2ba42fb420613a..5d315f3e8cf9beed6403c62a4ca9cf6a07a6cf6a 100644 (file)
@@ -14,6 +14,7 @@
 #include <Message_CompositeAlerts.hxx>
 #include <Message_AlertExtended.hxx>
 #include <Standard_Assert.hxx>
+#include <Standard_Dump.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_CompositeAlerts, Standard_Transient)
 
@@ -153,3 +154,29 @@ void Message_CompositeAlerts::Clear (const Handle(Standard_Type)& theType)
     }
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_CompositeAlerts::DumpJson (Standard_OStream& theOStream,
+                                        Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
+  {
+    if (myAlerts[i].IsEmpty())
+      continue;
+
+    Message_Gravity aGravity = (Message_Gravity)i;
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aGravity)
+
+    Standard_Integer anInc = 1;
+    for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); anIt.Next(), anInc++)
+    {
+      const Handle(Message_Alert)& anAlert = anIt.Value();
+      OCCT_DUMP_FIELD_VALUES_DUMPED_INC (theOStream, theDepth, anAlert.get(), anInc)
+    }
+  }
+}
index 0864e05b6fc90d2cca9e529c91caf8fef668cfb8..937eda0137e462c433ca2358c6aa4453ae79541e 100644 (file)
@@ -66,6 +66,9 @@ public:
   //! @param theType an alert type
   Standard_EXPORT void Clear (const Handle(Standard_Type)& theType);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_CompositeAlerts,Standard_Transient)
 
 protected:
index a99db83399c90630eb53153da276e6ccded24b0e..62c55cff18b80aac12ee5c87733539b8f689b20a 100644 (file)
@@ -20,6 +20,7 @@ enum Message_MetricType
   Message_MetricType_None,              //!< no computation
   Message_MetricType_UserTimeCPU,       //!< the current CPU user time in seconds
   Message_MetricType_SystemTimeInfo,    //!< the current CPU system time in seconds
+  Message_MetricType_WallClock,         //!< OSD_Timer elapsed time
   Message_MetricType_MemPrivate,        //!< OSD_MemInfo::MemPrivate
   Message_MetricType_MemVirtual,        //!< OSD_MemInfo::MemVirtual
   Message_MetricType_MemWorkingSet,     //!< OSD_MemInfo::MemWorkingSet
index ca225ab0af9fa7a78a0b873fa43c04e826317778..609e10c9789b3152f3b418f90cf25e6e90f30e77 100644 (file)
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
 
+//=======================================================================
+//function : Destructor
+//purpose  : 
+//=======================================================================
+Message_PrinterToReport::~Message_PrinterToReport()
+{
+  if (!myReport.IsNull())
+  {
+    myReport->UpdateActiveInMessenger();
+  }
+}
+
 //=======================================================================
 //function : Report
 //purpose  : 
@@ -40,6 +52,16 @@ const Handle(Message_Report)& Message_PrinterToReport::Report() const
   return Message::DefaultReport (Standard_True);
 }
 
+//=======================================================================
+//function : Send
+//purpose  :
+//=======================================================================
+void Message_PrinterToReport::SetReport (const Handle(Message_Report)& theReport)
+{
+  myReport = theReport;
+  myReport->UpdateActiveInMessenger();
+}
+
 //=======================================================================
 //function : Send
 //purpose  :
index f61a5be2b0493c199da67bfb74e0df46cf19d195..faa95acf1ae5b972bdc7d72d0d60451ebabb9ceb 100644 (file)
@@ -35,14 +35,15 @@ public:
   //! Create printer for redirecting messages into report.
   Message_PrinterToReport() {}
 
-  ~Message_PrinterToReport() {}
+  //! Destructor
+  Standard_EXPORT ~Message_PrinterToReport();
 
   //! Returns the current or default report
   Standard_EXPORT const Handle(Message_Report)& Report() const;
 
   //! Sets the printer report
   //! @param theReport report for messages processing, if NULL, the default report is used
-  Standard_EXPORT void SetReport (const Handle(Message_Report)& theReport) { myReport = theReport; }
+  Standard_EXPORT void SetReport (const Handle(Message_Report)& theReport);
 
   //! Send a string message with specified trace level.
   //! Stream is converted to string value.
index 28502401190d17417e38f34147ecdd91b8b7fafe..19d9b7f1112484483e76937f783ccc182b798ad5 100644 (file)
@@ -37,7 +37,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
 //=======================================================================
 
 Message_Report::Message_Report ()
-: myLimit (-1), myWriteFileOnEachAlert (Standard_False)
+: myLimit (-1), myWriteFileOnEachAlert (Standard_False),
+  myIsActiveInMessenger (Standard_False)
 {
 }
 
@@ -121,16 +122,9 @@ Standard_Boolean Message_Report::HasAlert (const Handle(Standard_Type)& theType,
 //purpose  :
 //=======================================================================
 
-Standard_Boolean Message_Report::IsActiveInMessenger (const Handle(Message_Messenger)& theMessenger) const
+Standard_Boolean Message_Report::IsActiveInMessenger (const Handle(Message_Messenger)&) const
 {
-  Handle(Message_Messenger) aMessenger = theMessenger.IsNull() ? Message::DefaultMessenger() : theMessenger;
-  for (Message_SequenceOfPrinters::Iterator anIterator (aMessenger->Printers()); anIterator.More(); anIterator.Next())
-  {
-    if (anIterator.Value()->IsKind(STANDARD_TYPE (Message_PrinterToReport)) &&
-        Handle(Message_PrinterToReport)::DownCast (anIterator.Value())->Report() == this)
-      return Standard_True;
-  }
-  return Standard_False;
+  return myIsActiveInMessenger;
 }
 
 //=======================================================================
@@ -139,11 +133,12 @@ Standard_Boolean Message_Report::IsActiveInMessenger (const Handle(Message_Messe
 //=======================================================================
 
 void Message_Report::ActivateInMessenger (const Standard_Boolean toActivate,
-                                          const Handle(Message_Messenger)& theMessenger) const
+                                          const Handle(Message_Messenger)& theMessenger)
 {
   if (toActivate == IsActiveInMessenger())
     return;
 
+  myIsActiveInMessenger = toActivate;
   Handle(Message_Messenger) aMessenger = theMessenger.IsNull() ? Message::DefaultMessenger() : theMessenger;
   if (toActivate)
   {
@@ -168,6 +163,25 @@ void Message_Report::ActivateInMessenger (const Standard_Boolean toActivate,
   }
 }
 
+//=======================================================================
+//function : UpdateActiveInMessenger
+//purpose  :
+//=======================================================================
+void Message_Report::UpdateActiveInMessenger (const Handle(Message_Messenger)& theMessenger)
+{
+  Handle(Message_Messenger) aMessenger = theMessenger.IsNull() ? Message::DefaultMessenger() : theMessenger;
+  for (Message_SequenceOfPrinters::Iterator anIterator (aMessenger->Printers()); anIterator.More(); anIterator.Next())
+  {
+    if (anIterator.Value()->IsKind(STANDARD_TYPE (Message_PrinterToReport)) &&
+        Handle(Message_PrinterToReport)::DownCast (anIterator.Value())->Report() == this)
+    {
+      myIsActiveInMessenger = Standard_True;
+      return;
+    }
+  }
+  myIsActiveInMessenger = Standard_False;
+}
+
 //=======================================================================
 //function : AddLevel
 //purpose  :
@@ -447,3 +461,29 @@ void Message_Report::writeReport()
 
   myReportWriter->ExportReport (this);
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void Message_Report::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+  if (!myCompositAlerts.IsNull())
+  {
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCompositAlerts.get())
+  }
+
+  Standard_Integer anAlertLevels = myAlertLevels.Size();
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anAlertLevels)
+
+  for (NCollection_Map<Message_MetricType>::Iterator anIterator (myActiveMetrics); anIterator.More(); anIterator.Next())
+  {
+    Message_MetricType anActiveMetric = anIterator.Value();
+    OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, anActiveMetric)
+  }
+
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLimit)
+  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsActiveInMessenger)
+}
index 599b0fad7bcef6de241027244cb9325d8182fcc0..03ef68ffe3f293d4144c0d4a334ed7270016cb5d 100644 (file)
@@ -82,8 +82,13 @@ public:
   //! Creates an instance of Message_PrinterToReport with the current report and register it in messenger
   //! @param toActivate if true, activated else deactivated
   // @param theMessenger the messenger. If it's NULL, the default messenger is used
-  Standard_EXPORT void ActivateInMessenger (const Standard_Boolean toActivate, const Handle(Message_Messenger)& theMessenger = NULL) const;
+  Standard_EXPORT void ActivateInMessenger (const Standard_Boolean toActivate, const Handle(Message_Messenger)& theMessenger = NULL);
 
+  //! Updates internal flag IsActiveInMessenger.
+  //! It becomes true if messenger contains at least one instance of Message_PrinterToReport.
+  //! @param theMessenger the messenger. If it's NULL, the default messenger is used
+  Standard_EXPORT void UpdateActiveInMessenger (const Handle(Message_Messenger)& theMessenger = NULL);
+  
   //! Add new level of alerts
   //! @param theLevel a level 
   Standard_EXPORT void AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName);
@@ -153,6 +158,9 @@ public:
   //! Merges alerts with specified gravity from theOther report into this
   Standard_EXPORT void Merge (const Handle(Message_Report)& theOther, Message_Gravity theGravity);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
+
   DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
 
 protected:
@@ -183,6 +191,7 @@ protected:
 
   Standard_Integer myLimit; //! Maximum number of collected alerts on the top level
   Standard_Boolean myWriteFileOnEachAlert; //! State if output file should be written on each alert adding
+  Standard_Boolean myIsActiveInMessenger; //! state whether the report is activated in messenger
 };
 
 #endif // _Message_Report_HeaderFile
index 2b483283bfaca170f009b18c49b2800a4b07a145..897d3442c0b20cfa9b1510ae8ba1cf329f68d4c3 100644 (file)
@@ -79,6 +79,9 @@ public:
   //! the Timer.
   Standard_EXPORT virtual void Start() Standard_OVERRIDE;
   
+  //! Returns start time in seconds.
+  Standard_Real StartTime() const { return myTimeStart; }
+
   //! Returns elapsed time in seconds.
   Standard_EXPORT Standard_Real ElapsedTime() const;
 
index 95d94d6300fc78ef9d0df3ea9a11777a2f1a16ac..97bc6a36841e107efb6eead7f748fc05d9906f9a 100644 (file)
@@ -39,7 +39,7 @@ void Select3D_SensitiveEntity::DumpJson (Standard_OStream& theOStream, Standard_
 {
   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
 
-  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myOwnerId.get())
+  OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwnerId.get())
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySFactor)
 
   OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, NbSubElements());
index d31eeafd3bdd61bbc4a44b887fb3298886497d5c..34f60d1469dc78358ec72bd2893ebb128298461d 100644 (file)
@@ -124,6 +124,27 @@ void SelectMgr_Selection::DumpJson (Standard_OStream& theOStream, Standard_Integ
 {
   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
 
+  NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> anOwners;
+  for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
+  {
+    const Handle(SelectMgr_SensitiveEntity)& anEntity = anIterator.Value();
+    if (anEntity.IsNull() || anEntity->BaseSensitive().IsNull())
+    {
+      continue;
+    }
+    const Handle(SelectMgr_EntityOwner)& anOwner = anEntity->BaseSensitive()->OwnerId();
+    if (!anOwners.Contains (anOwner))
+    {
+      anOwners.Add (anOwner);
+    }
+  }
+
+  for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anIterator (anOwners); anIterator.More(); anIterator.Next())
+  {
+    const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
+    OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anOwner.get())
+  }
+
   for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
   {
     const Handle(SelectMgr_SensitiveEntity)& anEntity = anIterator.Value();
index 4f030678dc18ae99fa4bd5cf5d138888dc4cca5f..a56292f912f93f754d99d7a9d26f16b7d269d07d 100644 (file)
@@ -24,7 +24,7 @@ void Standard_Dump::AddValuesSeparator (Standard_OStream& theOStream)
   Standard_SStream aStream;
   aStream << theOStream.rdbuf();
   TCollection_AsciiString aStreamStr = Standard_Dump::Text (aStream);
-  if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{"))
+  if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{") && !aStreamStr.EndsWith (", "))
     theOStream << ", ";
 }
 
@@ -306,9 +306,15 @@ TCollection_AsciiString Standard_Dump::FormatJson (const Standard_SStream& theSt
 
   Standard_Integer anIndentCount = 0;
   Standard_Boolean isMassiveValues = Standard_False;
-  for (Standard_Integer anIndex = 1; anIndex < aStreamStr.Length(); anIndex++)
+  for (Standard_Integer anIndex = 1; anIndex <= aStreamStr.Length(); anIndex++)
   {
     Standard_Character aSymbol = aStreamStr.Value (anIndex);
+    if (anIndex == 1 && aText.IsEmpty() && aSymbol != '{')
+    {
+      // append opening brace for json start
+      aSymbol = '{';
+      anIndex--;
+    }
     if (aSymbol == '{')
     {
       anIndentCount++;
@@ -354,6 +360,18 @@ TCollection_AsciiString Standard_Dump::FormatJson (const Standard_SStream& theSt
     }
     else
       aText += aSymbol;
+  
+    if (anIndex == aStreamStr.Length() && aSymbol != '}')
+    {
+      // append closing brace for json end
+      aSymbol = '}';
+
+      anIndentCount--;
+      aText += '\n';
+      for (int anIndent = 0; anIndent < anIndentCount; anIndent++)
+        aText += anIndentStr;
+      aText += aSymbol;
+    }
   }
   return aText;
 }
index 846c9cb001ac2c752e41345f85fc92aac98ca479..e0333c03e457c76a47dc2d7de5e1af4d74bdecbf 100644 (file)
   } \
 }
 
+//! @def OCCT_DUMP_FIELD_VALUES_DUMPED
+//! Append into output value: "Name": { field dumped values }
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own Dump implementation.
+//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
+//! Depth = -1 is the default value, dump here is unlimited.
+#define OCCT_DUMP_FIELD_VALUES_DUMPED_INC(theOStream, theDepth, theField, theIncName) \
+{ \
+  if (theDepth != 0 && (void*)(theField) != NULL) \
+  { \
+    Standard_SStream aFieldStream; \
+    (theField)->DumpJson (aFieldStream, theDepth - 1); \
+    TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
+    Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
+  } \
+}
+
+//! @def OCCT_DUMP_FIELD_VALUES_DUMPED
+//! Append into output value: "Name": { field dumped values }
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own Dump implementation.
+//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
+//! Depth = -1 is the default value, dump here is unlimited.
+#define OCCT_DUMP_STREAM_VALUE_DUMPED(theOStream, theField) \
+{ \
+  TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
+  Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (theField)); \
+}
+
 //! @def OCCT_INIT_FIELD_VALUES_DUMPED
 //! Append into output value: "Name": { field dumped values }
 //! It computes Dump of the fields. The expected field is a pointer.
@@ -267,6 +296,7 @@ public:
   //! - for '{' append after '\n' and indent to the next value, increment current indent value
   //! - for '}' append '\n' and current indent before it, decrement indent value
   //! - for ',' append after '\n' and indent to the next value. If the current symbol is in massive container [], do nothing
+  //! Covers result with opened and closed brackets on the top level, if it has no symbols there.
   //! @param theStream source value
   //! @param theIndent count of ' ' symbols to apply hierarchical indent of the text values
   //! @return text presentation
index c4fc6127dd0c674dd5aef8fa70f69dd6d049e1e5..3f111589648f53b24ee3cc544532cf21991486ca 100644 (file)
@@ -53,3 +53,16 @@ void TopoDS_AlertAttribute::Send (const Handle(Message_Messenger)& theMessenger,
     //                                 Message_Info);
   }
 }
+
+//=======================================================================
+//function : DumpJson
+//purpose  :
+//=======================================================================
+void TopoDS_AlertAttribute::DumpJson (Standard_OStream& theOStream,
+                                      Standard_Integer theDepth) const
+{
+  OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+  OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
+
+  OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myShape)
+}
index b7e5e95e1cca5c2627e80dc5e8154ac7f92ab05b..deaa193dc4bf448675ca82d0289d2c6fb6b70362 100644 (file)
@@ -40,6 +40,10 @@ public:
   Standard_EXPORT static void Send (const Handle(Message_Messenger)& theMessenger,
                                     const TopoDS_Shape& theShape);
 
+  //! Dumps the content of me into the stream
+  Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
+                                 Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream)
 
index 23ab2c2aa837e07d1034ab245d8a4ae4f73aa5f5..70857bc046c8f010b358c1de83628e2ba8014c22 100644 (file)
@@ -49,7 +49,7 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent)
 // =======================================================================
 void DFBrowser_TreeModel::InitColumns()
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+  setHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
index 4f8a4847f0dabca1173e63ebad4041ef783c60a6..0d6b98f12fa9cb65aa094ea319b1c1256f3c7c47 100644 (file)
@@ -37,7 +37,7 @@ DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObjec
 // =======================================================================
 void DFBrowserPane_TDataStdTreeNodeModel::InitColumns()
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+  setHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
index 6308c66460b44770f301abb2ce3830f1a0b064da..8ca4217c74cb80f8607ed1cd8309824ce1caddba 100644 (file)
@@ -170,6 +170,7 @@ void MessageModel_Actions::OnActivateReport()
 
   Message::DefaultMessenger()->AddPrinter (MyPrinterToReport);
   Message::DefaultMessenger()->SetTraceLevel (1);
+  Message::DefaultReport()->UpdateActiveInMessenger();
 
   myTreeModel->UpdateTreeModel();
 }
index 6aa1c7bb693d336ccf8259291077b56ba26cac8f..a0904ec5c11d8f3a9892954f47d3439ae7d8f6d5 100644 (file)
@@ -119,8 +119,12 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
     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_SystemTimeInfo ||
+        aMetricType == Message_MetricType_WallClock)
     {
       Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType);
       if (fabs (aCumulativeMetric) < Precision::Confusion())
index 32ef4ff4e1deb30248caf03b3e5472c5738b9af0..bf4fc5a7f7541b134c2fb35160a957383f52f1f0 100644 (file)
@@ -67,7 +67,8 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const
   Message_MetricType aMetricType;
   int aPosition;
   if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition) &&
-      (aMetricType == Message_MetricType_UserTimeCPU || aMetricType == Message_MetricType_SystemTimeInfo))
+      (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";
@@ -210,8 +211,9 @@ Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Re
       if (anAlert.IsNull())
         continue;
       Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anAlert->Attribute());
-      if (anAttribute.IsNull() || !anAttribute->HasMetric(theMetricType))
+      if (anAttribute.IsNull() || !anAttribute->HasMetric (theMetricType) || !anAttribute->IsMetricValid (theMetricType))
         continue;
+
       //if (aFirstAttribute.IsNull())
       //  aFirstAttribute = anAttribute;
       //else
index 7806eb35f75b7fe17106ad9e2e9a535f27437c67..b5950bd8b5337706e73f83ddbb29e8ed3bd96001 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <Message.hxx>
 
-const int COLUMN_NAME_WIDTH = 460;
+const int COLUMN_NAME_WIDTH = 230;
 const int COLUMN_SIZE_WIDTH = 30;
 
 const int COLUMN_REAL_VALUE_WIDTH = 115;
@@ -44,9 +44,9 @@ MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
 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*/));
+  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++)
@@ -55,10 +55,10 @@ void MessageModel_TreeModel::InitColumns()
     OSD_MemInfo::Counter aMemInfo;
     bool isMemInfo = Message::ToOSDMetric (aMetricType, aMemInfo);
 
-    SetHeaderItem (aNextIndex++,
+    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));
+    setHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
   }
 }
 
index 7e9104db2eb78f4959e3b09b88a027bcd0f18240..a2270827d1cc2302f9bcf11006fcbd882fff879a 100644 (file)
@@ -80,7 +80,7 @@
 #include <QWidget>
 #include <QVBoxLayout>
 
-const int DEFAULT_TEXT_VIEW_WIDTH = 400;// 800;
+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;
@@ -149,6 +149,9 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
   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);
@@ -171,6 +174,9 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
           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);
 
@@ -251,15 +257,18 @@ void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIt
   theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
 
   QMap<QString, QString> anItems;
-  //TreeModel_Tools::SaveState (myTreeView, anItems);
-
-  anItems.clear();
-  View_Window::SaveState(myViewWindow, anItems);
+  TreeModel_Tools::SaveState (myTreeView, anItems);
   for (QMap<QString, QString>::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<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+  {
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+  }
 }
 
 // =======================================================================
@@ -272,8 +281,8 @@ void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
   {
     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 (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;
   }
@@ -305,7 +314,7 @@ void MessageView_Window::UpdateContent()
     myParameters->SetFileNames (aName, aNames);
     isUpdated = true;
   }
-  Handle(Message_Report) aDefaultReport = Message::DefaultReport (Standard_False);
+  Handle(Message_Report) aDefaultReport = Message::DefaultReport();
   MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   if (!aDefaultReport.IsNull() && !aViewModel->HasReport (aDefaultReport))
   {
@@ -315,6 +324,7 @@ void MessageView_Window::UpdateContent()
   //onReloadReport();
 
   updateTreeModel();
+  updateVisibleColumns();
 }
 
 // =======================================================================
@@ -372,7 +382,10 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
 // =======================================================================
 void MessageView_Window::openFile(const TCollection_AsciiString& theFileName)
 {
-  const Handle(Message_Report)& aReport = Message::DefaultReport();
+  if (theFileName.IsEmpty())
+    return;
+
+  const Handle(Message_Report)& aReport = Message::DefaultReport (Standard_True);
 
   //Handle(Message_Report) aReport = new Message_Report();
   if (aReport->MessageWriter().IsNull())
@@ -407,7 +420,7 @@ void MessageView_Window::addReport (const Handle(Message_Report)& theReport,
   MessageModel_TreeModel* aModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   aModel->AddReport (theReport, theReportDescription);
 
-  updateVisibleColumns();
+  //updateVisibleColumns();
 }
 
 // =======================================================================
@@ -466,7 +479,8 @@ void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePositi
   }
   if (aRootItem)
   {
-    aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Import Report"), SLOT (onImportReport()), myMainWindow, this));
+    aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Create Default Report"),
+                      SLOT (onCreateDefaultReport()), myMainWindow, this));
     // unite
     //MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
     //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsUniteAlerts() ? tr ("SetUniteAlerts - OFF") : tr ("SetUniteAlerts - ON"),
@@ -545,6 +559,18 @@ void MessageView_Window::onPropertyViewDataChanged()
   updatePreviewPresentation();
 }
 
+// =======================================================================
+// function : onHeaderResized
+// purpose :
+// =======================================================================
+void MessageView_Window::onHeaderResized (int theSectionId, int, int)
+{
+  TreeModel_ModelBase* aViewModel = dynamic_cast<TreeModel_ModelBase*> (myTreeView->model());
+
+  TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (theSectionId);
+  aSection->SetWidth (myTreeView->columnWidth (theSectionId));
+}
+
 // =======================================================================
 // function : onEraseAllPerformed
 // purpose :
@@ -576,32 +602,36 @@ void MessageView_Window::onExportReport()
   if (!aReportItem)
     return;
 
-  QString aFilter (tr ("Document file (*.xml *)"));
+  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();
-  if (aReport->MessageWriter().IsNull())
-    aReport->SetMessageWriter (new XmlDrivers_MessageReportStorage());
+  Standard_SStream aStream;
+  aReport->DumpJson(aStream);
 
-  aReport->MessageWriter()->SetFileName (TCollection_AsciiString (aFileName.toStdString().c_str()));
-  aReport->MessageWriter()->ExportReport (aReport);
+  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 : onImportReport
+// function : onCreateDefaultReport
 // purpose :
 // =======================================================================
-void MessageView_Window::onImportReport()
+void MessageView_Window::onCreateDefaultReport()
 {
-  QString aFilter (tr ("Document file (*.cbf *)"));
-  QString aSelectedFilter;
-
-  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
-  aSelectionModel->clear();
+  if (!Message::DefaultReport().IsNull())
+  {
+    return;
+  }
 
-  QString aFileName = QFileDialog::getOpenFileName (0, tr("Import report"), QString(), aSelectedFilter);
-  openFile (TCollection_AsciiString (aFileName.toStdString().c_str()));
+  addReport (Message::DefaultReport (Standard_True));
 }
 
 // =======================================================================
@@ -742,10 +772,13 @@ void MessageView_Window::onPreviewChildren()
 // =======================================================================
 void MessageView_Window::addActivateMetricActions (QMenu* theMenu)
 {
-  QMenu* aSubMenu = new QMenu ("Activate metric");
-
-  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  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;
@@ -773,7 +806,7 @@ void MessageView_Window::OnActivateMetric()
   if (!Message::MetricFromString (anAction->text().toStdString().c_str(), aMetricType))
     return;
 
-  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  Handle(Message_Report) aReport = Message::DefaultReport();
   const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
 
   aReport->SetActiveMetric (aMetricType, !anActiveMetrics.Contains (aMetricType));
@@ -901,9 +934,8 @@ void MessageView_Window::updateVisibleColumns()
     {
       int aColumnId = aMetricColumns[i];
       myTreeView->setColumnHidden (aColumnId, isColumnHidden);
-      TreeModel_HeaderSection aSection = aViewModel->GetHeaderItem (aColumnId);
-      aSection.SetIsHidden (isColumnHidden);
-      aViewModel->SetHeaderItem (aColumnId, aSection);
+      TreeModel_HeaderSection* aSection = aViewModel->ChangeHeaderItem (aColumnId);
+      aSection->SetIsHidden (isColumnHidden);
     }
   }
 }
index dbaf64c6af0b5caf348654dc1bdd04ef42a5993f..bae2ad6fa812efb3056cdc014896a9b8f9136fb4 100644 (file)
@@ -136,14 +136,17 @@ protected slots:
   //! 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();
 
-  //! Import report into document
-  void onImportReport();
+  //! Create default report into document
+  void onCreateDefaultReport();
 
   //! Unite alerts in view model
   //void onUniteAlerts();
index 2c1aac570a025e473e8e59ae5d6d1a8367336f51..f3b29732f20a7c707fa72bc5d003a03228bc85f7 100644 (file)
@@ -128,8 +128,8 @@ int main (int argc, char** argv)
     aPlugins.insert("TKShapeView");
     aPlugins.insert("TKVInspector");
 
-    Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
-    aReport->SetLimit (100);//30);
+    //Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+    //aReport->SetLimit (100);//30);
     aPlugins.insert("TKMessageView");
 
     //anActivatedPluginName = "TKVInspector";
index 9a60792c6098179c2a22a107cb7a7a67559563a7..9cd0d07ab6f9ee4db73fd73848b89a01dc43870d 100644 (file)
@@ -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));
index 1b23b909cbc3a923cd57195c77f98898d48bc6a7..359ed3901874e44db7e93d3ae6e1007d6e1c108b 100644 (file)
@@ -14,6 +14,8 @@
 // commercial license or contractual agreement. 
 
 #include <inspector/TreeModel_ItemBase.hxx>
+
+#include <inspector/TreeModel_ColumnType.hxx>
 #include <inspector/TreeModel_ItemProperties.hxx>
 #include <inspector/TreeModel_ItemRole.hxx>
 #include <inspector/TreeModel_ItemStream.hxx>
@@ -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();
index 34214396596ca8058ecbcbfb7ff71020c1a89901..5dd4055b7e027ed4f5dae409bc25710dc6509f04 100644 (file)
@@ -47,9 +47,9 @@ TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
 // =======================================================================
 void TreeModel_ModelBase::InitColumns()
 {
-  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));
+  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));
 }
 
 // =======================================================================
@@ -178,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();
 }
 
 // =======================================================================
@@ -232,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 :
@@ -339,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 :
index 20b17ae9b3627f7fa2183b83b54d9a63604ba2e7..f616846496b73805883e6973db6aaec092aec256 100644 (file)
@@ -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
@@ -191,6 +186,11 @@ protected:
   //! \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
index e3d8b2afa54f7d917b1ec5861f55a0e0751314c1..00bc92f59fb3c17048e82883da6d2a777361aa21 100644 (file)
@@ -89,6 +89,7 @@ void TreeModel_Tools::SaveState (QTreeView* theTreeView, QMap<QString, QString>&
   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<int> 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<int> 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<TreeModel_ModelBase*> (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);
 }
 
index 591ecb0661d4de1871ac655b98f15b45dc46a59d..3ac0a4e0223681da98223304c15c7874dd23e072 100644 (file)
@@ -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);
 }
 
 // =======================================================================
index 2ca792b334b158835662706cc562885cd7648344..894d0a3ba3087fa9c53402afa0fef4596cc05096 100644 (file)
@@ -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));
 }
 
 // =======================================================================
index 980dc1e865890ff6dbfa76424b1c9dcce94b68a1..0b50eca7d8834aadcee893bf1824a82dd31900e8 100644 (file)
@@ -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++)
   {
index 4e76e981135a6031ed7e12d28a1af54d23cfe5eb..163df690dd1c1d596f250aee31427b917fc17110 100644 (file)
@@ -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);