]> OCCT Git - occt-copy.git/commitdiff
0029451: Information Message Alert to debug an algorithm or object functionality
authornds <natalia.ermolaeva@opencascade.com>
Tue, 19 May 2020 16:53:20 +0000 (19:53 +0300)
committernds <natalia.ermolaeva@opencascade.com>
Tue, 26 May 2020 16:14:16 +0000 (19:14 +0300)
22 files changed:
src/Message/Message.cxx
src/Message/Message.hxx
src/Message/Message_AttributeMeter.cxx
src/Message/Message_AttributeMeter.hxx
src/Message/Message_Level.cxx
src/Message/Message_Level.hxx
src/Message/Message_Messenger.cxx
src/Message/Message_Messenger.hxx
src/Message/Message_Printer.cxx
src/Message/Message_PrinterToReport.cxx
src/Message/Message_PrinterToReport.hxx
src/Message/Message_Report.cxx
src/Message/Message_Report.hxx
tools/MessageModel/MessageModel_ActionType.hxx
tools/MessageModel/MessageModel_ItemAlert.cxx
tools/MessageModel/MessageModel_ItemReport.cxx
tools/MessageModel/MessageModel_TreeModel.cxx
tools/MessageView/MessageView_ActionsTest.cxx
tools/MessageView/MessageView_ActionsTest.hxx
tools/MessageView/MessageView_Window.cxx
tools/TreeModel/TreeModel_ColumnType.hxx
tools/TreeModel/TreeModel_ModelBase.cxx

index 505552b966b1b3ec236dcb2467fe058619ad8470..a6c63176e1f2c989cc37044dae7c77ef3ae5efda 100644 (file)
@@ -105,15 +105,15 @@ Standard_Boolean Message::ToOSDMetric (const Message_MetricType theMetric, OSD_M
 {
   switch (theMetric)
   {
-    case Message_MetricType_MemPrivate:        theMemInfo = OSD_MemInfo::MemPrivate; break;
-    case Message_MetricType_MemVirtual:        theMemInfo = OSD_MemInfo::MemVirtual; break;
-    case Message_MetricType_MemWorkingSet:     theMemInfo = OSD_MemInfo::MemWorkingSet; break;
-    case Message_MetricType_MemWorkingSetPeak: theMemInfo = OSD_MemInfo::MemWorkingSetPeak; break;
-    case Message_MetricType_MemSwapUsage:      theMemInfo = OSD_MemInfo::MemSwapUsage; break;
-    case Message_MetricType_MemSwapUsagePeak:  theMemInfo = OSD_MemInfo::MemSwapUsagePeak; break;
-    case Message_MetricType_MemHeapUsage:      theMemInfo = OSD_MemInfo::MemHeapUsage; break;
+    case Message_MetricType_MemPrivate:        theMemInfo = OSD_MemInfo::MemPrivate; return Standard_True;
+    case Message_MetricType_MemVirtual:        theMemInfo = OSD_MemInfo::MemVirtual; return Standard_True;
+    case Message_MetricType_MemWorkingSet:     theMemInfo = OSD_MemInfo::MemWorkingSet; return Standard_True;
+    case Message_MetricType_MemWorkingSetPeak: theMemInfo = OSD_MemInfo::MemWorkingSetPeak; return Standard_True;
+    case Message_MetricType_MemSwapUsage:      theMemInfo = OSD_MemInfo::MemSwapUsage; return Standard_True;
+    case Message_MetricType_MemSwapUsagePeak:  theMemInfo = OSD_MemInfo::MemSwapUsagePeak; return Standard_True;
+    case Message_MetricType_MemHeapUsage:      theMemInfo = OSD_MemInfo::MemHeapUsage; return Standard_True;
   }
-  return Standard_True;
+  return Standard_False;
 }
 
 // =======================================================================
index 601b0629abf0c8de7a75a322509759d517cef886..d93a903fd2f2ba66e4ae03c7ca7773d37b81b330 100644 (file)
@@ -136,13 +136,12 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 //! Append into messenger  result of DumpJson for the field
 //! It computes Dump of the fields. The expected field is a pointer.
 //! Use this macro for fields of the dumped class which has own DumpJson implementation.
-#define OCCT_SEND_DUMPJSON(theField) \
+#define OCCT_SEND_DUMPJSON(theField, theMessage) \
 { \
   if ((void*)(theField) != NULL) \
   { \
-    Standard_SStream aFieldStream; \
-    (theField)->DumpJson (aFieldStream, Message::DefaultMessenger()->TraceLevel()); \
-    Message::DefaultMessenger() << aFieldStream; \
+     Message::SendInfo() << theMessage; \
+     (theField)->DumpJson (Message::SendInfo()); \
   } \
 }
 
@@ -152,7 +151,17 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 //! Use this macro for fields of the dumped class which has own DumpJson implementation.
 #define OCCT_SEND_MESSAGE(theMessage) \
 { \
-  Message::DefaultMessenger() << theMessage << "" << std::endl; \
+  Message::SendInfo() << theMessage; \
+}
+
+//! @def OCCT_SEND_DUMPJSON
+//! Append into messenger  result of DumpJson for the field
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own DumpJson implementation.
+#define OCCT_SEND_STREAM(theStream, theMessage) \
+{ \
+   Message::SendInfo() << theMessage; \
+   Message::SendInfo() << theStream.str().c_str(); \
 }
 
 #endif // _Message_HeaderFile
index 227c4b5e61d579adef91073be94e6ef4c67c4cdc..f9571b9befed083cf62d66511316d32740efe1ac 100644 (file)
 // commercial license or contractual agreement.
 
 #include <Message_AttributeMeter.hxx>
+#include <Message_AlertExtended.hxx>
+#include <Message.hxx>
+#include <Message_Report.hxx>
+#include <OSD_Chronometer.hxx>
 
 #include <Precision.hxx>
 
@@ -63,6 +67,8 @@ Standard_Real Message_AttributeMeter::StartValue (const Message_MetricType& theM
 //=======================================================================
 void Message_AttributeMeter::SetStartValue (const Message_MetricType& theMetric, const Standard_Real theValue)
 {
+  //std::cout << GetName() << ": " << theValue << " (start)" << std::endl;
+
   if (!HasMetric (theMetric))
   {
     myMetrics.Bind (theMetric, std::make_pair (theValue, UndefinedMetricValue()));
@@ -88,6 +94,7 @@ Standard_Real Message_AttributeMeter::StopValue (const Message_MetricType& theMe
 //=======================================================================
 void Message_AttributeMeter::SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue)
 {
+  //std::cout << GetName() << ": " << theValue << " (stop)" << std::endl;
   if (!HasMetric (theMetric))
   {
     // start value should be already set
@@ -95,3 +102,74 @@ void Message_AttributeMeter::SetStopValue (const Message_MetricType& theMetric,
   }
   myMetrics.ChangeFind (theMetric).second = theValue;
 }
+
+//=======================================================================
+//function : SetAlertMetrics
+//purpose  :
+//=======================================================================
+void Message_AttributeMeter::SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
+                                              const Standard_Boolean theStartValue)
+{
+  if (theAlert.IsNull())
+    return;
+
+  Handle(Message_AttributeMeter) aMeterAttribute = Handle(Message_AttributeMeter)::DownCast (theAlert->Attribute());
+  if (aMeterAttribute.IsNull())
+    return;
+
+  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
+
+  // time metrics
+  if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU) ||
+      anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo))
+  {
+    Standard_Real aUserSeconds, aSystemSeconds;
+    OSD_Chronometer::GetProcessCPU (aUserSeconds, aSystemSeconds);
+
+    if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU))
+    {
+      if (theStartValue)
+        aMeterAttribute->SetStartValue (Message_MetricType_UserTimeCPU, aUserSeconds);
+      else
+        aMeterAttribute->SetStopValue (Message_MetricType_UserTimeCPU, aUserSeconds);
+    }
+    if (anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo))
+    {
+      if (theStartValue)
+        aMeterAttribute->SetStartValue (Message_MetricType_SystemTimeInfo, aSystemSeconds);
+      else
+        aMeterAttribute->SetStopValue (Message_MetricType_SystemTimeInfo, aSystemSeconds);
+    }
+  }
+  // memory metrics
+  OSD_MemInfo aMemInfo (Standard_False);
+  aMemInfo.SetActive (Standard_False);
+  NCollection_Map<OSD_MemInfo::Counter> aCounters;
+  Standard_Boolean isCounterFound = Standard_False;
+  for (NCollection_Map<Message_MetricType>::Iterator anIterator (anActiveMetrics); anIterator.More(); anIterator.Next())
+  {
+    OSD_MemInfo::Counter anInfoCounter;
+    if (!Message::ToOSDMetric (anIterator.Value(), anInfoCounter))
+      continue;
+
+    aCounters.Add (anInfoCounter);
+    aMemInfo.SetActive (anInfoCounter, Standard_True);
+    isCounterFound = Standard_True;
+  }
+  if (aCounters.IsEmpty())
+    return;
+
+  aMemInfo.Update();
+  Message_MetricType aMetricType;
+  for (NCollection_Map<OSD_MemInfo::Counter>::Iterator anIterator (aCounters); anIterator.More(); anIterator.Next())
+  {
+    if (!Message::ToMessageMetric (anIterator.Value(), aMetricType))
+      continue;
+
+    if (theStartValue)
+      aMeterAttribute->SetStartValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
+    else
+      aMeterAttribute->SetStopValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
+  }
+}
index f563c283778d0266c17d3236a3cc08cfc34cbb7f..72be3f6097eac8744566134b8b8162eb2d0c82ad 100644 (file)
@@ -20,6 +20,7 @@
 #include <NCollection_DataMap.hxx>
 
 class Message_Alert;
+class Message_AlertExtended;
 
 //! Alert object storing alert metrics values.
 //! Start and stop values for each metric.
@@ -64,6 +65,21 @@ public:
   //! @param theMetric [in] metric type
   Standard_EXPORT void SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue);
 
+  //! Sets start values of default report metrics into the alert
+  //! @param theAlert an alert  
+  static void StartAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_True); }
+
+  //! Sets stop values of default report metrics into the alert
+  //! @param theAlert an alert  
+  static void StopAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_False); }
+
+  //! Sets current values of default report metrics into the alert.
+  //! Processed oly alert with Message_AttributeMeter attribute
+  //! @param theAlert an alert  
+  //! @param theStartValue flag, if true, the start value is collected otherwise stop
+  static Standard_EXPORT void SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
+                                               const Standard_Boolean theStartValue);
+
   DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
 
 private:
index e0127236518cf64c1d03ec1ec6c03781018a4183..7db8bf562176161b7f33eb7c1d32250dff3a01ce 100644 (file)
 //function : Message_Level
 //purpose  :
 //=======================================================================
-Message_Level::Message_Level()
+Message_Level::Message_Level (const TCollection_AsciiString& theName)
 {
   const Handle(Message_Report)& aDefaultReport = Message::DefaultReport();
   if (!aDefaultReport.IsNull() && aDefaultReport->IsActiveInMessenger())
-    aDefaultReport->AddLevel (this);
+    aDefaultReport->AddLevel (this, theName);
 }
 
 //=======================================================================
@@ -40,17 +40,19 @@ Message_Level::Message_Level()
 //=======================================================================
 Message_Level::~Message_Level()
 {
-  Remove();
+  remove();
 }
 
 //=======================================================================
 //function : SetRootAlert
 //purpose  :
 //=======================================================================
-void Message_Level::SetRootAlert (const Handle(Message_AlertExtended)& theAlert)
+void Message_Level::SetRootAlert (const Handle(Message_AlertExtended)& theAlert,
+                                  const Standard_Boolean isRequiredToStart)
 {
   myRootAlert = theAlert;
-  startAlert (myRootAlert);
+  if (isRequiredToStart)
+    Message_AttributeMeter::StartAlert (myRootAlert);
 }
 
 //=======================================================================
@@ -64,39 +66,17 @@ Standard_Boolean Message_Level::AddAlert (const Message_Gravity theGravity,
   if (anAlertExtended.IsNull())
     return Standard_False;
 
-  if (myRootAlert.IsNull())
-    return Standard_False;
-
   // looking for the parent of the parameter alert to release the previous alert
   Handle(Message_AlertExtended) aRootAlert = myRootAlert;
   Handle(Message_CompositeAlerts) aCompositeAlert = aRootAlert->CompositeAlerts (Standard_True);
 
   // update metrics of the previous alert
-  stopAlert (myLastAlert);
+  Message_AttributeMeter::StopAlert (myLastAlert);
 
   myLastAlert = anAlertExtended;
-
   // set start metrics of the new alert
-  startAlert (myLastAlert);
-
-  // add child alert
-  aCompositeAlert->AddAlert (theGravity, theAlert);
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function : AddLevelAlert
-//purpose  :
-//=======================================================================
-Standard_Boolean Message_Level::AddLevelAlert (const Message_Gravity theGravity,
-                                               const Handle(Message_Alert)& theAlert)
-{
-  Handle(Message_AlertExtended) aRootAlert = /*!myLastAlert.IsNull() ? myLastAlert :*/ myRootAlert;
-  if (aRootAlert.IsNull())
-    return Standard_False;
+  Message_AttributeMeter::StartAlert (myLastAlert);
 
-  Handle(Message_CompositeAlerts) aCompositeAlert = aRootAlert->CompositeAlerts (Standard_True);
   // add child alert
   aCompositeAlert->AddAlert (theGravity, theAlert);
 
@@ -104,86 +84,17 @@ Standard_Boolean Message_Level::AddLevelAlert (const Message_Gravity theGravity,
 }
 
 //=======================================================================
-//function : Remove()
+//function : remove()
 //purpose  :
 //=======================================================================
-void Message_Level::Remove()
+void Message_Level::remove()
 {
   const Handle(Message_Report)& aDefaultReport = Message::DefaultReport();
   if (aDefaultReport.IsNull() || !aDefaultReport->IsActiveInMessenger())
     return;
 
-  stopAlert (myLastAlert);
-  stopAlert (myRootAlert);
+  Message_AttributeMeter::StopAlert (myLastAlert);
 
   if (!Message::DefaultReport().IsNull())
     Message::DefaultReport()->RemoveLevel (this);
 }
-
-//=======================================================================
-//function : setAlertMetrics
-//purpose  :
-//=======================================================================
-void Message_Level::setAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
-                                                 const Standard_Boolean theStartValue)
-{
-  if (theAlert.IsNull())
-    return;
-
-  Handle(Message_AttributeMeter) aMeterAttribute = Handle(Message_AttributeMeter)::DownCast (theAlert->Attribute());
-  if (aMeterAttribute.IsNull())
-    return;
-
-  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
-  const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
-
-  // time metrics
-  if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU) ||
-      anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo))
-  {
-    Standard_Real aUserSeconds, aSystemSeconds;
-    OSD_Chronometer::GetThreadCPU (aUserSeconds, aSystemSeconds);
-
-    if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU))
-    {
-      if (theStartValue)
-        aMeterAttribute->SetStartValue (Message_MetricType_UserTimeCPU, aUserSeconds);
-      else
-        aMeterAttribute->SetStopValue (Message_MetricType_UserTimeCPU, aUserSeconds);
-    }
-    if (anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo))
-    {
-      if (theStartValue)
-        aMeterAttribute->SetStartValue (Message_MetricType_SystemTimeInfo, aSystemSeconds);
-      else
-        aMeterAttribute->SetStopValue (Message_MetricType_SystemTimeInfo, aSystemSeconds);
-    }
-  }
-  // memory metrics
-  NCollection_Map<OSD_MemInfo::Counter> aCounters;
-  for (NCollection_Map<Message_MetricType>::Iterator anIterator (anActiveMetrics); anIterator.More(); anIterator.Next())
-  {
-    OSD_MemInfo::Counter aMemInfo;
-    if (!Message::ToOSDMetric (anIterator.Value(), aMemInfo))
-      continue;
-
-    aCounters.Add (aMemInfo);
-  }
-  if (aCounters.IsEmpty())
-    return;
-
-  OSD_MemInfo aMemInfo (Standard_False);
-  //aMemInfo.SetActiveCounters (aCounters);
-  aMemInfo.Update ();
-  Message_MetricType aMetricType;
-  for (NCollection_Map<OSD_MemInfo::Counter>::Iterator anIterator (aCounters); anIterator.More(); anIterator.Next())
-  {
-    if (!Message::ToMessageMetric (anIterator.Value(), aMetricType))
-      continue;
-
-    if (theStartValue)
-      aMeterAttribute->SetStartValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
-    else
-      aMeterAttribute->SetStopValue (aMetricType, (Standard_Real)aMemInfo.ValuePreciseMiB (anIterator.Value()));
-  }
-}
index de08c4c034be5a43dcf7fbba7930f64e9d3d9de3..423561e97b2760a980488476dc01136a69d922ff 100644 (file)
@@ -42,7 +42,7 @@ public:
   //! Constructor. Append
   //! One string key is used for all alert meters. The perf meter is not started automatically, it will be done in
   //! AddAlert method
-  Standard_EXPORT Message_Level();
+  Standard_EXPORT Message_Level (const TCollection_AsciiString& theName = TCollection_AsciiString());
 
   //! Assures stopping upon destruction
   Standard_EXPORT ~Message_Level();
@@ -53,7 +53,8 @@ public:
 
   //! Sets the root alert. Starts collects alert metrics if active.
   //! @param theAlert an alert  
-  Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert);
+  Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert,
+                                     const Standard_Boolean isRequiredToStart);
 
   //! Adds new alert on the level. Stops the last alert metric, appends the alert and starts the alert metrics collecting.
   //! Sets root alert beforehead this method using, if the root is NULL, it does nothing.
@@ -63,31 +64,9 @@ public:
   Standard_EXPORT Standard_Boolean AddAlert (const Message_Gravity theGravity,
                                              const Handle(Message_Alert)& theAlert);
 
-  //! Add new alert as a child of the last alert if exists or as a child of the root alert.
-  //! @param theGravity an alert gravity
-  //! @param theAlert an alert  
-  //! @return true if alert is added
-  Standard_EXPORT Standard_Boolean AddLevelAlert (const Message_Gravity theGravity,
-                                                  const Handle(Message_Alert)& theAlert);
-
-  //! Remove the current level from the report. It stops metric collecting for the last and the root alerts.
-  Standard_EXPORT void Remove();
-
 protected:
-  //! Sets start values of default report metrics into the alert
-  //! @param theAlert an alert  
-  void startAlert (const Handle(Message_AlertExtended)& theAlert) { setAlertMetrics (theAlert, Standard_True); }
-
-  //! Sets stop values of default report metrics into the alert
-  //! @param theAlert an alert  
-  void stopAlert (const Handle(Message_AlertExtended)& theAlert) { setAlertMetrics (theAlert, Standard_True); }
-
-  //! Sets current values of default report metrics into the alert.
-  //! Processed oly alert with Message_AttributeMeter attribute
-  //! @param theAlert an alert  
-  //! @param theStartValue flag, if true, the start value is collected otherwise stop
-  Standard_EXPORT void setAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
-                                        const Standard_Boolean theStartValue);
+  //! Remove the current level from the report. It stops metric collecting for the last and the root alerts.
+  Standard_EXPORT void remove();
 
 protected:
   Handle(Message_AlertExtended) myRootAlert; //!< root alert
@@ -97,7 +76,6 @@ protected:
 //! @def MESSAGE_NEW_LEVEL
 //! Creates a new level instance of Sentry. This row should be inserted before messages using in the method.
 #define OCCT_ADD_MESSAGE_LEVEL_SENTRY(theMessage) \
-  Message_Level aLevel; \
-  Message::SendInfo() << theMessage << std::endl;
+  Message_Level aLevel(theMessage);
 
 #endif // _Message_Level_HeaderFile
index cd6488431a322920859c5dcd4d3caf14dbd6a6b5..b57c3e075ebaea80dbe48a2a4b1b13fd6b200a10 100644 (file)
@@ -147,6 +147,28 @@ void Message_Messenger::Send (const Standard_CString theString,
   }
 }
 
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_Messenger::Send (const Standard_SStream& theStream,
+                              const Message_Gravity theGravity) const
+{
+  if (TraceLevel() == 0)
+    return;
+
+  for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More(); aPrinterIter.Next())
+  {
+    const Handle(Message_Printer)& aPrinter = aPrinterIter.Value();
+    if (!aPrinter.IsNull())
+    {
+      aPrinter->Send (theStream, theGravity);
+    }
+  }
+}
+
+
 //=======================================================================
 //function : Send
 //purpose  : 
index e5306bfa7628538305882ea1153c6300a4e750c3..8c63945840c5f6f46efc163da9e34f601c6080da 100644 (file)
@@ -77,7 +77,7 @@ public:
       {
         if (myMessenger)
         {
-          myMessenger->Send(myStream.str().c_str(), myGravity);
+          myMessenger->Send(myStream, myGravity);
         }
         myStream.str(std::string()); // empty the buffer for possible reuse
       }
@@ -191,6 +191,10 @@ public:
   Standard_EXPORT void Send (const Standard_CString theString,
                              const Message_Gravity theGravity = Message_Warning) const;
   
+  //! See above
+  Standard_EXPORT void Send (const Standard_SStream& theStream,
+                             const Message_Gravity theGravity = Message_Warning) const;
+  
   //! See above
   Standard_EXPORT void Send (const TCollection_AsciiString& theString,
                              const Message_Gravity theGravity = Message_Warning) const;
index 5356a862f67fc77a63146a3837febf0bc14cdab2..58d3da01596f274efea7abba03ee6c3287f5a3eb 100644 (file)
@@ -73,13 +73,12 @@ void Message_Printer::Send (const TCollection_AsciiString& theString,
 //function : Send
 //purpose  :
 //=======================================================================
-
 void Message_Printer::Send (const Standard_SStream& theStream,
                             const Message_Gravity   theGravity) const
 {
   if (theGravity >= myTraceLevel)
   {
-    Send (TCollection_ExtendedString (theStream.str().c_str()), theGravity);
+    Send (theStream.str().c_str(), theGravity);
   }
 }
 
index c66c83e8c6b0277035514875b63b2aa685a14cca..ca225ab0af9fa7a78a0b873fa43c04e826317778 100644 (file)
@@ -40,6 +40,36 @@ const Handle(Message_Report)& Message_PrinterToReport::Report() const
   return Message::DefaultReport (Standard_True);
 }
 
+//=======================================================================
+//function : Send
+//purpose  :
+//=======================================================================
+void Message_PrinterToReport::Send (const Standard_SStream& theStream,
+                                    const Message_Gravity   theGravity) const
+{
+  const Handle(Message_Report)& aReport = Report();
+  if (!aReport->ActiveMetrics().IsEmpty())
+  {
+    sendMetricAlert (theStream.str().c_str(), theGravity);
+    return;
+  }
+  if (Standard_Dump::HasChildKey(Standard_Dump::Text (theStream)))
+  {
+    Message_AlertExtended::AddAlert (aReport, new Message_AttributeStream (theStream, myName), theGravity);
+    myName.Clear();
+  }
+  else
+  {
+    if (!myName.IsEmpty())
+    {
+      TCollection_AsciiString aName = myName;
+      myName.Clear();
+      send (aName, theGravity);
+    }
+    myName = Standard_Dump::Text (theStream);
+  }
+}
+
 //=======================================================================
 //function : Send
 //purpose  : 
@@ -64,6 +94,12 @@ void Message_PrinterToReport::Send (const Handle(Standard_Transient)& /*theObjec
 void Message_PrinterToReport::send (const TCollection_AsciiString& theString,
                                     const Message_Gravity theGravity) const
 {
+  if (!myName.IsEmpty())
+  {
+    send (myName, theGravity);
+    myName.Clear();
+  }
+
   const Handle(Message_Report)& aReport = Report();
   if (!aReport->ActiveMetrics().IsEmpty())
   {
index bce9bdbb25ed07cabac94fbf6345d9a7cdfabd7a..f61a5be2b0493c199da67bfb74e0df46cf19d195 100644 (file)
@@ -44,12 +44,18 @@ public:
   //! @param theReport report for messages processing, if NULL, the default report is used
   Standard_EXPORT void SetReport (const Handle(Message_Report)& theReport) { myReport = theReport; }
 
+  //! Send a string message with specified trace level.
+  //! Stream is converted to string value.
+  //! Default implementation calls first method Send().
+  Standard_EXPORT virtual void Send (const Standard_SStream& theStream, const Message_Gravity theGravity) const;
+
   //! Send a string message with specified trace level.
   //! The object is converted to string in format: <object kind> : <object pointer>.
   //! The parameter theToPutEol specified whether end-of-line should be added to the end of the message.
   //! Default implementation calls first method Send().
   Standard_EXPORT virtual void Send (const Handle(Standard_Transient)& theObject,
                                      const Message_Gravity theGravity) const Standard_OVERRIDE;
+
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
@@ -65,6 +71,7 @@ protected:
                                         const Message_Gravity theGravity) const;
 
 private:
+  mutable TCollection_AsciiString myName;
   Handle(Message_Report) myReport; //!< the report for sending alerts
 };
 
index e094b172b2177afed04458046a9f738f4e942a78..28502401190d17417e38f34147ecdd91b8b7fafe 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <Message.hxx>
 #include <Message_AlertExtended.hxx>
+#include <Message_AttributeMeter.hxx>
+#include <Message_Attribute.hxx>
 #include <Message_CompositeAlerts.hxx>
 #include <Message_Msg.hxx>
 #include <Message_Messenger.hxx>
@@ -66,33 +68,9 @@ void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_
     return;
   }
 
-  // if there are some levels of alerts
-  // iterate by already recorded alerts and try to merge new one with one of those
-  Message_Level* aLevel = myAlertLevels.Last();
+  // if there are some levels of alerts, the new alert will be placed below the root
+  myAlertLevels.Last()->AddAlert (theGravity, theAlert);
 
-  // level has root alert, the new alert will be placed below the root
-  if (!aLevel->RootAlert().IsNull())
-  {
-    aLevel->AddAlert (theGravity, theAlert);
-    writeReport();
-    return;
-  }
-
-  Handle(Message_AlertExtended) anAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anAlert.IsNull())
-    return;
-  // place new alert as a root of the level, after place the level alert below the report or
-  // below the previous level
-  aLevel->SetRootAlert (anAlert);
-
-  if (myAlertLevels.Size() == 1) // this is the first level, so root alert should be pushed in the report composite of alerts
-    compositeAlerts (Standard_True)->AddAlert (theGravity, theAlert);
-  else
-  {
-    // root alert of next levels should be pushed under the previous level
-    Message_Level* aPrevLevel = myAlertLevels.Value (myAlertLevels.Size() - 1); // previous level
-    aPrevLevel->AddLevelAlert (theGravity, theAlert);
-  }
   writeReport();
 }
 
@@ -194,10 +172,32 @@ void Message_Report::ActivateInMessenger (const Standard_Boolean toActivate,
 //function : AddLevel
 //purpose  :
 //=======================================================================
-
-void Message_Report::AddLevel (Message_Level* theLevel)
+void Message_Report::AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName)
 {
   myAlertLevels.Append (theLevel);
+
+  Handle(Message_AlertExtended) aLevelRootAlert = new Message_AlertExtended();
+
+  Handle(Message_Attribute) anAttribute;
+  if (!ActiveMetrics().IsEmpty())
+  {
+    anAttribute =  new Message_AttributeMeter (theName);
+  }
+  else
+    anAttribute = new Message_Attribute (theName);
+  aLevelRootAlert->SetAttribute (anAttribute);
+  theLevel->SetRootAlert (aLevelRootAlert, myAlertLevels.Size() == 1);
+
+  if (myAlertLevels.Size() == 1) // this is the first level, so root alert should be pushed in the report composite of alerts
+  {
+    compositeAlerts (Standard_True)->AddAlert (Message_Info, theLevel->RootAlert());
+  }
+  if (myAlertLevels.Size() > 1) // this is the first level, so root alert should be pushed in the report composite of alerts
+  {
+    // root alert of next levels should be pushed under the previous level
+    Message_Level* aPrevLevel = myAlertLevels.Value (myAlertLevels.Size() - 1); // previous level
+    aPrevLevel->AddAlert (Message_Info, aLevelRootAlert);
+  }
 }
 
 //=======================================================================
@@ -210,6 +210,10 @@ void Message_Report::RemoveLevel (Message_Level* theLevel)
   for (int aLevelIndex = myAlertLevels.Size(); aLevelIndex >= 1; aLevelIndex--)
   {
     Message_Level* aLevel = myAlertLevels.Value (aLevelIndex);
+    if (myAlertLevels.Size() == 1) // the last level, the root item should be stopped
+    {
+      Message_AttributeMeter::StopAlert (aLevel->RootAlert());
+    }
     myAlertLevels.Remove (aLevelIndex);
 
     if (aLevel == theLevel)
index be35d38a9e32c6415a9a1dd3ce60bdd6cc4efad5..599b0fad7bcef6de241027244cb9325d8182fcc0 100644 (file)
@@ -86,7 +86,7 @@ public:
 
   //! Add new level of alerts
   //! @param theLevel a level 
-  Standard_EXPORT void AddLevel (Message_Level* theLevel);
+  Standard_EXPORT void AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName);
 
   //! Remove level of alerts
   Standard_EXPORT void RemoveLevel (Message_Level* theLevel);
index 7df28caaba5ce791a1a5434e8cd9731e8f2cb765..3415c9d0d214cd385ed0dd733481e742153f3f69 100644 (file)
@@ -26,7 +26,8 @@ enum MessageModel_ActionType
   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_TestReportTree, //!< test message view on hierarchical report
+  MessageModel_ActionType_TestReportTree2 //!< test message view on hierarchical report
 };
 
 #endif
index 31e34e0aab21901b49a434b194647f6c93d9a171..6aa1c7bb693d336ccf8259291077b56ba26cac8f 100644 (file)
@@ -116,21 +116,38 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
       return QVariant();
 
     Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anExtendedAlert->Attribute());
-    if (anAttribute.IsNull())
-      return QVariant();
-
-    Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType);
-    if (fabs (aCumulativeMetric) < Precision::Confusion())
+    if (anAttribute.IsNull() || !anAttribute->HasMetric (aMetricType))
       return QVariant();
 
-    if (aPosition == 0) return aCumulativeMetric;
-    else if (aPosition == 1)
+    if (aMetricType == Message_MetricType_UserTimeCPU ||
+        aMetricType == Message_MetricType_SystemTimeInfo)
     {
-      Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType);
-      if (fabs (aReportCumulativeMetric) > Precision::Confusion())
-        return 100. * aCumulativeMetric / aReportCumulativeMetric;
-      else
+      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();
index 575de32fe4c93c152689598c224424b4bb09afe9..32ef4ff4e1deb30248caf03b3e5472c5738b9af0 100644 (file)
@@ -66,7 +66,8 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const
 
   Message_MetricType aMetricType;
   int aPosition;
-  if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition))
+  if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition) &&
+      (aMetricType == Message_MetricType_UserTimeCPU || aMetricType == Message_MetricType_SystemTimeInfo))
   {
     if (aPosition == 0) return CumulativeMetric (aReport, aMetricType);
     else if (aPosition == 1) return "100";
@@ -202,26 +203,29 @@ Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Re
   for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
   {
     const Message_ListOfAlert& anAlerts = theReport->GetAlerts ((Message_Gravity)iGravity);
-    Handle(Message_AttributeMeter) aFirstAttribute, aLastAttribute;
+    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())
+      if (anAttribute.IsNull() || !anAttribute->HasMetric(theMetricType))
         continue;
-      if (aFirstAttribute.IsNull())
-        aFirstAttribute = anAttribute;
-      else
-        aLastAttribute = anAttribute;
+      //if (aFirstAttribute.IsNull())
+      //  aFirstAttribute = anAttribute;
+      //else
+      //{
+        //aLastAttribute = anAttribute;
+      //}
+      aMetric += anAttribute->StopValue (theMetricType) - anAttribute->StartValue (theMetricType);
     }
-    if (aFirstAttribute.IsNull())
-      continue;
-    if (aLastAttribute.IsNull())
-      aLastAttribute = aFirstAttribute;
+    //if (aFirstAttribute.IsNull())
+    //  continue;
+    //if (aLastAttribute.IsNull())
+    //  aLastAttribute = aFirstAttribute;
 
-    aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType);
+    //aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType);
   }
   return aMetric;
 }
index 85b539817bc93081ab41740b49f099bc941f4e1b..7806eb35f75b7fe17106ad9e2e9a535f27437c67 100644 (file)
 #include <inspector/MessageModel_ItemAlert.hxx>
 #include <inspector/MessageModel_ItemRoot.hxx>
 #include <inspector/MessageModel_ItemReport.hxx>
+#include <inspector/TreeModel_ColumnType.hxx>
 
 #include <Message.hxx>
 
+const int COLUMN_NAME_WIDTH = 460;
+const int COLUMN_SIZE_WIDTH = 30;
+
 const int COLUMN_REAL_VALUE_WIDTH = 115;
-const int COLUMN_PERCENT_VALUE_WIDTH = 40;
+const int COLUMN_PERCENT_VALUE_WIDTH = 50;
 
 // =======================================================================
 // function : Constructor
@@ -39,8 +43,10 @@ MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
 // =======================================================================
 void MessageModel_TreeModel::InitColumns()
 {
-  TreeModel_ModelBase::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++)
@@ -52,7 +58,7 @@ void MessageModel_TreeModel::InitColumns()
     SetHeaderItem (aNextIndex++,
       TreeModel_HeaderSection (QString("%1 [%2]").arg (Message::MetricToString (aMetricType)).arg(isMemInfo ? "Mb" : "s"),
       COLUMN_REAL_VALUE_WIDTH));
-    SetHeaderItem (aNextIndex++, TreeModel_HeaderSection ("%", COLUMN_PERCENT_VALUE_WIDTH));
+    SetHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
   }
 }
 
index 9d23b96da15d5c2f4615af5aee5b022e2cb75c05..439c595921ac820536f3010c285fb92b52d18b6d 100644 (file)
 #include <Message_Messenger.hxx>
 #include <Message_PrinterToReport.hxx>
 
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Ax3.hxx>
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <OSD_Chronometer.hxx>
 #include <Quantity_Color.hxx>
 #include <QWidget>
 #include <Standard_WarningsRestore.hxx>
 
-//#define DEBUG_ALERTS
+#define DEBUG_ALERTS
 
 #ifdef DEBUG_ALERTS
-#include <Message_Alerts.hxx>
 #include <Message_Level.hxx>
 #endif
 
@@ -71,6 +74,8 @@ MessageView_ActionsTest::MessageView_ActionsTest (QWidget* theParent,
                     ViewControl_Tools::CreateAction ("Test <Message_Messenger>", SLOT (OnTestMessenger()), parent(), this));
   myActions.insert (MessageModel_ActionType_TestReportTree,
                     ViewControl_Tools::CreateAction ("Test <Tree of messages>", SLOT (OnTestReportTree()), parent(), this));
+  myActions.insert (MessageModel_ActionType_TestReportTree2,
+                    ViewControl_Tools::CreateAction ("Test <Tree of messages> 2", SLOT (OnTestReportTree2()), parent(), this));
 }
 
 // =======================================================================
@@ -111,6 +116,7 @@ void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelected
     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();
 
@@ -118,6 +124,7 @@ void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelected
     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();
 }
@@ -174,7 +181,7 @@ void MessageView_ActionsTest::OnTestMetric()
   double* aMemValue;
   for (int aTopIt = 0; aTopIt < 4; aTopIt++)
   {
-    MESSAGE_INFO ("Calculate");
+    Message::SendInfo() << "Calculate";
     for (int j = 0; j < aCounter; j++)
     {
       for (int i = 0; i < aCounter; i++)
@@ -219,45 +226,32 @@ void MessageView_ActionsTest::OnTestPropertyPanel()
 
   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);
-    aCoords.DumpJson (sout);
-    //Standard_SStream aStream;
-    //aCoords.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_XYZ");
+    OCCT_SEND_DUMPJSON (&aCoords, "gp_XYZ")
   }
   // gp_Dir
   {
     gp_Dir aDir (0.3, 0.3, 0.4);
-    //Standard_SStream aStream;
-    aDir.DumpJson (sout);
-    //aDir.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_Dir");
+    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));
-    //Standard_SStream aStream;
-    aCoords.DumpJson (sout);
-    //aCoords.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_Ax1");
+    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));
-    //Standard_SStream aStream;
-    aCoords.DumpJson (sout);
-    //aCoords.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_Ax2");
+    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.));
-    //Standard_SStream aStream;
-    aPln.DumpJson (sout);
-    //aPln.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_Ax3");
+    OCCT_SEND_DUMPJSON (&aPln, "gp_Ax3")
   }
   // gp_Trsf
   {
@@ -266,43 +260,28 @@ void MessageView_ActionsTest::OnTestPropertyPanel()
     aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.));
     aTrsf.SetScaleFactor (3.);
 
-    aTrsf.DumpJson (sout);
-    //Standard_SStream aStream;
-    //aTrsf.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "gp_Trsf");
+    OCCT_SEND_DUMPJSON (&aTrsf, "gp_Trsf")
   }
   // Bnd_Box
   {
     Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.));
-    aBox.DumpJson (sout);
-    //Standard_SStream aStream;
-    //aBox.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "Bnd_Box");
+    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.);
-    aBox.DumpJson (sout);
-    //Standard_SStream aStream;
-    //anOBB.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "Bnd_OBB");
+    OCCT_SEND_DUMPJSON (&anOBB, "Bnd_OBB");
   }
   // Quantity_ColorRGBA
   {
     Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f);
-    aColor.DumpJson (sout);
-    //Standard_SStream aStream;
-    //aColor.DumpJson (aStream);
-    //MESSAGE_INFO_STREAM(aStream, "Quantity_ColorRGBA");
+    OCCT_SEND_DUMPJSON (&aColor, "Quantity_ColorRGBA");
   }
   // Quantity_Color
   {
     Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB);
-    aColor.DumpJson (sout);
-    //Standard_SStream aStream;
-    //aColor.DumpJson (aStream);
-    ///MESSAGE_INFO_STREAM(aStream, "Quantity_Color");
+    OCCT_SEND_DUMPJSON (&aColor, "Quantity_Color");
   }
 
   // stream of some table values
@@ -310,8 +289,7 @@ void MessageView_ActionsTest::OnTestPropertyPanel()
     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");
-
-    MESSAGE_INFO_STREAM(aStream, "Table: Name to value");
+    OCCT_SEND_STREAM (aStream, "Table: Name to value");
   }
 
   // SHAPE messages
@@ -429,13 +407,13 @@ void levelAlerts (const int theCurrentLevel, const int theTopLevel)
   OCCT_ADD_MESSAGE_LEVEL_SENTRY (TCollection_AsciiString ("Level: " ) + theCurrentLevel)
 
   Message_Messenger::StreamBuffer sout = Message::SendInfo();
-  sout << "Alert: " << 1 << ", " << 2 << std::endl;
-  sout << "Alert: " << 3 << ", " << 4 << std::endl;
+  sout << "Alert(" << theCurrentLevel << "): " << 1 << ", " << 2 << std::endl;
+  sout << "Alert(" << theCurrentLevel << "): " << 3 << ", " << 4 << std::endl;
 
-  for (int i = 0; i < 2; i++)
+  //for (int i = 0; i < 2; i++)
     levelAlerts (theCurrentLevel + 1, theTopLevel);
 
-  sout << "Alert: " << 4 << ", " << 5 << std::endl;
+  sout << "Alert(" << theCurrentLevel << "): " << 4 << ", " << 5 << std::endl;
 }
 
 // =======================================================================
@@ -452,12 +430,12 @@ void levelAlert (const int theCurrentLevel, const int theTopLevel)
   Message_Messenger::StreamBuffer sout = Message::SendInfo();
   sout << "Level: " << theCurrentLevel << "(Single, no alerts on the level)" << std::endl;
 
-  for (int i = 0; i < 2; i++)
+  //for (int i = 0; i < 2; i++)
     levelAlerts (theCurrentLevel + 1, theTopLevel);
 }
 
 // =======================================================================
-// function : OnTestMessenger
+// function : OnTestReportTree
 // purpose :
 // =======================================================================
 void MessageView_ActionsTest::OnTestReportTree()
@@ -481,3 +459,27 @@ void MessageView_ActionsTest::OnTestReportTree()
   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();
+}
index 54943819e64f68f30d02f6ba214b9c9d9e56db81..bf58b17ec9c8c5be9f275ed64e5bb15a75cf328f 100644 (file)
@@ -67,6 +67,9 @@ public slots:
   //! 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
index aaa2c61dd2e8b97ed7b56204720ebc416c71a6b3..7e9104db2eb78f4959e3b09b88a027bcd0f18240 100644 (file)
@@ -155,6 +155,7 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
   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);
@@ -267,12 +268,6 @@ void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIt
 // =======================================================================
 void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
 {
-  if (theItem.IsEmpty())
-  {
-    TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
-    return;
-  }
-
   for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
   {
     if (anItemIt.Key().IsEqual ("geometry"))
index 80cb3f97daa9f6b5d8fbed1743efbfd028d488c5..520cec6fdfd415f15590622da423b9dea3fb1650 100644 (file)
@@ -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
index 806684a4f119c277fb28b460f36c2cdc4f557aef..34214396596ca8058ecbcbfb7ff71020c1a89901 100644 (file)
@@ -47,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));
 }
 
 // =======================================================================