]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin
authornds <nds@opencascade.com>
Wed, 22 Jan 2020 17:15:04 +0000 (20:15 +0300)
committernds <nds@opencascade.com>
Wed, 22 Jan 2020 17:15:04 +0000 (20:15 +0300)
# Messages are simplified, redirecting Message_Messenger into Message_Report
# STEP reading trace level setting to get Message_Report
# tools: TreeModel: moving container of parents on the base levelAlert
# tools: MessageView is extended to select list of report metrics to collect

108 files changed:
src/DDocStd/DDocStd_ToolsCommands.cxx
src/Draw/Draw_BasicCommands.cxx
src/Message/FILES
src/Message/Message.cxx
src/Message/Message.hxx
src/Message/Message_AlertExtended.cxx
src/Message/Message_AlertExtended.hxx
src/Message/Message_Alerts.hxx
src/Message/Message_Attribute.hxx
src/Message/Message_AttributeMeter.cxx [new file with mode: 0644]
src/Message/Message_AttributeMeter.hxx [new file with mode: 0644]
src/Message/Message_AttributeObject.cxx
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_Level.cxx [new file with mode: 0644]
src/Message/Message_Level.hxx [new file with mode: 0644]
src/Message/Message_Messenger.cxx
src/Message/Message_Messenger.hxx
src/Message/Message_MetricType.hxx [new file with mode: 0644]
src/Message/Message_PerfMeter.cxx [deleted file]
src/Message/Message_PerfMeter.hxx [deleted file]
src/Message/Message_PerfMeterMode.hxx [deleted file]
src/Message/Message_Printer.cxx
src/Message/Message_Printer.hxx
src/Message/Message_PrinterToReport.cxx [new file with mode: 0644]
src/Message/Message_PrinterToReport.hxx [new file with mode: 0644]
src/Message/Message_Report.cxx
src/Message/Message_Report.hxx
src/Message/Message_ReportCallBack.cxx [deleted file]
src/Message/Message_ReportCallBack.hxx [deleted file]
src/OSD/OSD_MemInfo.cxx
src/OSD/OSD_MemInfo.hxx
src/OpenGl/OpenGl_CappingAlgo.cxx
src/OpenGl/OpenGl_Group.cxx
src/OpenGl/OpenGl_LayerList.cxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_Structure.cxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_View_Redraw.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/PrsMgr/PrsMgr_PresentableObject.cxx
src/STEPControl/STEPControl_ActorRead.cxx
src/TopoDS/TopoDS_AlertAttribute.cxx
src/TopoDS/TopoDS_AlertAttribute.hxx
src/Transfer/Transfer_TransferProcess.gxx
src/XDEDRAW/XDEDRAW_Common.cxx
src/XmlDrivers/XmlDrivers_MessageReportStorage.cxx
src/XmlDrivers/XmlDrivers_MessageReportStorage.hxx
tests/de/step_5/B8 [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Module.cxx
tools/DFBrowser/DFBrowser_TreeModel.cxx
tools/DFBrowser/DFBrowser_TreeModel.hxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.hxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.hxx
tools/MessageModel/FILES
tools/MessageModel/MessageModel.qrc
tools/MessageModel/MessageModel_ActionType.hxx
tools/MessageModel/MessageModel_Actions.cxx
tools/MessageModel/MessageModel_Actions.hxx
tools/MessageModel/MessageModel_ItemAlert.cxx
tools/MessageModel/MessageModel_ItemReport.cxx
tools/MessageModel/MessageModel_ItemReport.hxx
tools/MessageModel/MessageModel_ItemRoot.hxx
tools/MessageModel/MessageModel_ReportCallBack.cxx [deleted file]
tools/MessageModel/MessageModel_ReportCallBack.hxx [deleted file]
tools/MessageModel/MessageModel_Tools.cxx
tools/MessageModel/MessageModel_Tools.hxx
tools/MessageModel/MessageModel_TreeModel.cxx
tools/MessageModel/MessageModel_TreeModel.hxx
tools/MessageModel/icons/item_streamValues.png [new file with mode: 0644]
tools/MessageModel/icons/item_streamValues.svg [new file with mode: 0644]
tools/MessageModel/icons/item_vectorOfReal.png [deleted file]
tools/MessageModel/icons/item_vectorOfReal.svg [deleted file]
tools/MessageModel/icons/item_vectorOfRealVec3.png [deleted file]
tools/MessageModel/icons/item_vectorOfRealVec3.svg [deleted file]
tools/MessageModel/icons/item_vectorOfValues.png [deleted file]
tools/MessageModel/icons/item_vectorOfValues.svg [deleted file]
tools/MessageView/FILES
tools/MessageView/MessageView_ActionsTest.cxx [new file with mode: 0644]
tools/MessageView/MessageView_ActionsTest.hxx [new file with mode: 0644]
tools/MessageView/MessageView_Communicator.hxx
tools/MessageView/MessageView_Window.cxx
tools/MessageView/MessageView_Window.hxx
tools/ShapeView/ShapeView_ItemBase.cxx
tools/ShapeView/ShapeView_ItemBase.hxx
tools/ShapeView/ShapeView_ItemShape.cxx
tools/ShapeView/ShapeView_ItemShape.hxx
tools/ShapeView/ShapeView_TreeModel.cxx
tools/ShapeView/ShapeView_TreeModel.hxx
tools/ShapeView/ShapeView_Window.cxx
tools/ShapeView/ShapeView_Window.hxx
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TreeModel/TreeModel_ItemBase.cxx
tools/TreeModel/TreeModel_ModelBase.cxx
tools/TreeModel/TreeModel_ModelBase.hxx
tools/VInspector/VInspector_ItemBase.cxx
tools/VInspector/VInspector_ItemContext.cxx
tools/VInspector/VInspector_ViewModel.cxx
tools/VInspector/VInspector_ViewModel.hxx
tools/VInspector/VInspector_ViewModelHistory.cxx
tools/VInspector/VInspector_ViewModelHistory.hxx
tools/VInspector/VInspector_Window.cxx
tools/VInspector/VInspector_Window.hxx

index 9d925859c9332d5095c8eb8f1827b88de5b9d43d..9507d731e8074ef4b850747c4be1047cf678a47b 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <Draw.hxx>
 #include <Draw_Interpretor.hxx>
+#include <Message.hxx>
 #include <TDocStd_Document.hxx>
 #include <TDF_Label.hxx>
 #include <TCollection_AsciiString.hxx>
@@ -34,6 +35,7 @@
 #include <TDF_ListIteratorOfAttributeDeltaList.hxx> 
 #include <Standard_DomainError.hxx>
 
+#include <XmlDrivers_MessageReportStorage.hxx>
 
 
 //=======================================================================
@@ -151,7 +153,23 @@ static Standard_Integer DDocStd_DumpCommand (Draw_Interpretor& di,
   return 1;
 }
 
+//=======================================================================
+//function : DDocStd_WriteReport 
+//=======================================================================
+
+static Standard_Integer DDocStd_WriteReport(Draw_Interpretor& di,Standard_Integer n, const char** a)
+{
+  if (n < 2)
+  {
+    di << "DDocStd_WriteReport : Error not enough argument\n";
+    return 1;
+  }
 
+  TCollection_ExtendedString path (a[1]); 
+  MESSAGE_STORE_XML_REPORT (path);
+
+  return 0;
+}
 
 //=======================================================================
 //function : ModificationCommands
@@ -174,5 +192,9 @@ void DDocStd::ToolsCommands(Draw_Interpretor& theCommands)
                    "DumpCommand (DOC)",
                   __FILE__, DDocStd_DumpCommand, g);   
 
+  theCommands.Add ("WriteReport", 
+                   "WriteReport path",
+                  __FILE__, DDocStd_WriteReport, g);   
+
 }
 
index 8c57448a03803b61a155102f5227d8247972cab5..5fa9608390869653ff35dd029f84db4e59909dda 100644 (file)
@@ -23,6 +23,8 @@
 #include <Draw_ProgressIndicator.hxx>
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
+#include <Message_PrinterToReport.hxx>
+#include <Message_Report.hxx>
 #include <OSD.hxx>
 #include <OSD_Chronometer.hxx>
 #include <OSD_Environment.hxx>
@@ -931,6 +933,91 @@ static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const
   return 0;
 }
 
+//==============================================================================
+//function : dsetreportprinter
+//purpose  :
+//==============================================================================
+static Handle(Message_PrinterToReport) MyPrinterToReport;
+static Message_SequenceOfPrinters MyDeactivatedPrinters;
+
+static Standard_Integer dsetreportprinter(Draw_Interpretor&, Standard_Integer n, const char** a)
+{
+  if (n != 2)
+  {
+    std::cout << "Enable or disable report printer: " << a[0] << " {on|off}" << std::endl;
+    return 1;
+  }
+
+  const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+  if (aMsgMgr.IsNull())
+    return 1;
+
+  if (! strcmp (a[1], "on") && n == 2)
+  {
+    if (MyPrinterToReport.IsNull())
+      MyPrinterToReport = new Message_PrinterToReport;
+
+    if (MyPrinterToReport->Report()->IsActiveInMessenger())
+    {
+      std::cout << "Report printer has been already activated." << std::endl;
+      return 1;
+    }
+
+    MyDeactivatedPrinters = Message::DefaultMessenger()->Printers();
+    Message::DefaultMessenger()->ChangePrinters().Clear();
+    aMsgMgr->AddPrinter (MyPrinterToReport);
+
+  }
+  else if (! strcmp (a[1], "off") && n == 2)
+  {
+    if (MyPrinterToReport.IsNull() || !MyPrinterToReport->Report()->IsActiveInMessenger())
+    {
+      std::cout << "Report printer was not activated." << std::endl;
+      return 1;
+    }
+
+    Message::DefaultMessenger()->ChangePrinters().Assign (MyDeactivatedPrinters);
+  }
+  else {
+    std::cout << "Unrecognized option(s): " << a[1] << std::endl;
+    return 1;
+  }
+  return 0;
+}
+
+//==============================================================================
+//function : dsetreportmetric
+//purpose  :
+//==============================================================================
+static Standard_Integer dsetreportmetric(Draw_Interpretor&, Standard_Integer n, const char** a)
+{
+  if (n < 1)
+  {
+    std::cout << "Report metric activation: " << a[0] << " [metric_1 metric_2 ...]" << std::endl;
+    return 1;
+  }
+
+  const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+  const Handle(Message_Report)& aDefReport = Message::DefaultReport();
+
+  if (aMsgMgr.IsNull() || aDefReport.IsNull())
+    return 1;
+
+  aDefReport->ClearMetrics();
+  for (int i = 1; i < n; i++)
+  {
+    Standard_Integer aMetricId = atoi (a [i]);
+    if (aMetricId < Message_MetricType_UserTimeCPU || aMetricId > Message_MetricType_MemHeapUsage)
+    {
+      std::cout << "Unrecognized message metric: " << aMetricId << std::endl;
+      return 1;
+    }
+    aDefReport->SetActiveMetric ((Message_MetricType)aMetricId, Standard_True);
+  }
+   
+  return 0;
+}
+
 //==============================================================================
 //function : dtracelevel
 //purpose  :
@@ -1059,6 +1146,10 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands)
                  __FILE__,dperf,g);
   theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given",
                  __FILE__,dsetsignal,g);
+  theCommands.Add("dsetreportprinter", "manage logging of messenger into current report",
+                 __FILE__,dsetreportprinter,g);
+  theCommands.Add("dsetreportmetric", "manage logging of messenger into current report",
+                 __FILE__,dsetreportmetric,g);
 
   theCommands.Add("dparallel",
     "dparallel [-occt {0|1}] [-nbThreads Count] [-nbDefThreads Count]"
index 9a4bf4a9826cad3ca423c82d4aef91dd34d2a155..e332c94b4647a0873b5a22a93844bce7c775e67e 100755 (executable)
@@ -10,6 +10,8 @@ Message_Algorithm.hxx
 Message_Algorithm.lxx
 Message_Attribute.cxx
 Message_Attribute.hxx
+Message_AttributeMeter.cxx
+Message_AttributeMeter.hxx
 Message_AttributeObject.cxx
 Message_AttributeObject.hxx
 Message_AttributeStream.cxx
@@ -19,22 +21,24 @@ Message_CompositeAlerts.hxx
 Message_ExecStatus.hxx
 Message_Gravity.hxx
 Message_HArrayOfMsg.hxx
+Message_Level.cxx
+Message_Level.hxx
 Message_ListIteratorOfListOfMsg.hxx
 Message_ListOfMsg.hxx
 Message_Messenger.cxx
 Message_Messenger.hxx
+Message_MetricType.hxx
 Message_Msg.cxx
 Message_Msg.hxx
 Message_Msg.lxx
 Message_MsgFile.cxx
 Message_MsgFile.hxx
-Message_PerfMeter.cxx
-Message_PerfMeter.hxx
-Message_PerfMeterMode.hxx
 Message_Printer.cxx
 Message_Printer.hxx
 Message_PrinterOStream.cxx
 Message_PrinterOStream.hxx
+Message_PrinterToReport.cxx
+Message_PrinterToReport.hxx
 Message_ProgressIndicator.cxx
 Message_ProgressIndicator.hxx
 Message_ProgressIndicator.lxx
@@ -51,5 +55,3 @@ Message_StatusType.hxx
 Message_ListOfAlert.hxx
 Message_Report.cxx
 Message_Report.hxx
-Message_ReportCallBack.cxx
-Message_ReportCallBack.hxx
index 3aea6317a4a52ccda50642af82b1de6e5727f611..4c412893cf1d321f7f1a8763ce52177c37513ec2 100644 (file)
 
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
+#include <Message_Report.hxx>
 #include <TCollection_AsciiString.hxx>
 
 #include <stdio.h>
 #include <string.h>
+
 //=======================================================================
 //function : DefaultMessenger
 //purpose  : 
@@ -31,6 +33,21 @@ const Handle(Message_Messenger)& Message::DefaultMessenger ()
   return aMessenger;
 }
 
+//=======================================================================
+//function : DefaultReport
+//purpose  :
+//=======================================================================
+
+const Handle(Message_Report)& Message::DefaultReport(const Standard_Boolean theToCreate)
+{
+  static Handle(Message_Report) MyReport;
+
+  if (MyReport.IsNull() && theToCreate)
+    MyReport = new Message_Report();
+
+  return MyReport;
+}
+
 //=======================================================================
 //function : FillTime
 //purpose  : 
@@ -52,76 +69,38 @@ TCollection_AsciiString Message::FillTime (const Standard_Integer hour,
 
 namespace
 {
-  static Standard_CString Message_Table_PrintGravityEnum[5] =
+  static Standard_CString Message_Table_PrintMetricTypeEnum[10] =
   {
-    "TRACE", "INFO", "WARNING", "ALARM", "FAIL"
+    "NONE", "UserTimeCPU", "SystemTimeInfo", "MemPrivate", "MemVirtual",
+    "MemWorkingSet", "MemWorkingSetPeak", "MemSwapUsage", "MemSwapUsagePeak", "MemHeapUsage"
   };
-
-  static Standard_CString Message_Table_PrintPerfMeterModeEnum[10] =
-  {
-    "NONE", "USER_TIME_CPU", "SYSTEM_TIME_CPU", "MEM_PRIVATE", "MEM_VIRTUAL",
-    "MEM_WORKING_SET", "MEM_WORKING_SET_PEAK", "MEM_SWAP_USAGE", "MEM_SWAP_USAGE_PEAK", "MEM_HEAP_USAGE"
-  };
-}
-
-//=======================================================================
-//function : GravityToString
-//purpose  :
-//=======================================================================
-
-Standard_CString Message::GravityToString (const Message_Gravity theGravity)
-{
-  return Message_Table_PrintGravityEnum[theGravity];
-}
-
-//=======================================================================
-//function : GravityFromString
-//purpose  :
-//=======================================================================
-
-Standard_Boolean Message::GravityFromString (const Standard_CString theGravityString,
-                                             Message_Gravity& theGravity)
-{
-  TCollection_AsciiString aName (theGravityString);
-  aName.UpperCase();
-  for (Standard_Integer aGravityIter = 0; aGravityIter <= Message_Fail; ++aGravityIter)
-  {
-    Standard_CString aGravityName = Message_Table_PrintGravityEnum[aGravityIter];
-    if (aName == aGravityName)
-    {
-      theGravity = Message_Gravity (aGravityIter);
-      return Standard_True;
-    }
-  }
-  return Standard_False;
 }
 
 //=======================================================================
-//function : PerfMeterModeToString
+//function : MetricToString
 //purpose  :
 //=======================================================================
 
-Standard_CString Message::PerfMeterModeToString (const Message_PerfMeterMode theValue)
+Standard_CString Message::MetricToString (const Message_MetricType theType)
 {
-  return Message_Table_PrintPerfMeterModeEnum[theValue];
+  return Message_Table_PrintMetricTypeEnum[theType];
 }
 
 //=======================================================================
-//function : PerfMeterModeFromString
+//function : MetricFromString
 //purpose  :
 //=======================================================================
 
-Standard_Boolean Message::PerfMeterModeFromString (const Standard_CString theString,
-                                                   Message_PerfMeterMode& theValue)
+Standard_Boolean Message::MetricFromString (const Standard_CString theString,
+                                            Message_MetricType& theGravity)
 {
   TCollection_AsciiString aName (theString);
-  aName.UpperCase();
-  for (Standard_Integer aModeIter = 0; aModeIter <= Message_PerfMeterMode_MemHeapUsage; ++aModeIter)
+  for (Standard_Integer aMetricIter = 0; aMetricIter <= Message_MetricType_MemHeapUsage; ++aMetricIter)
   {
-    Standard_CString aModeName = Message_Table_PrintPerfMeterModeEnum[aModeIter];
-    if (aName == aModeName)
+    Standard_CString aMetricName = Message_Table_PrintMetricTypeEnum[aMetricIter];
+    if (aName == aMetricName)
     {
-      theValue = Message_PerfMeterMode (aModeIter);
+      theGravity = Message_MetricType (aMetricIter);
       return Standard_True;
     }
   }
@@ -129,262 +108,41 @@ Standard_Boolean Message::PerfMeterModeFromString (const Standard_CString theStr
 }
 
 // =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::TransientToString (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
-  if (thePointer.IsNull())
-    return TCollection_AsciiString();
-
-  return PointerToString(thePointer.operator->(), isShortInfo);
-}
-
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::PointerToString (const void* thePointer, const bool isShortInfo)
-{
-  std::ostringstream aPtrStr;
-  aPtrStr << thePointer;
-  if (!isShortInfo)
-    return aPtrStr.str().c_str();
-
-  TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
-  for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
-  {
-    if (anInfoPtr.Value(aSymbolId) != '0')
-    {
-      anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
-      anInfoPtr.Prepend("0x");
-      return anInfoPtr;
-    }
-  }
-  return aPtrStr.str().c_str();
-}
-
-// =======================================================================
-// function : StrVectorToString
+// function : ToOSDMetric
 // purpose :
 // =======================================================================
-TCollection_AsciiString Message::StrVectorToString
-    (const NCollection_Vector<TCollection_AsciiString>& theValues)
+Standard_Boolean Message::ToOSDMetric (const Message_MetricType theMetric, OSD_MemInfo::Counter& theMemInfo)
 {
-  TCollection_AsciiString aValue;
-  for (NCollection_Vector<TCollection_AsciiString>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
-  {
-    aValue += aValuesIt.Value();
-    if (aValuesIt.More())
-      aValue += VectorSeparator();
-  }
-  return aValue;
-}
-
-// =======================================================================
-// function : StrVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::StrVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<TCollection_AsciiString>& theValues)
-{
-  TCollection_AsciiString aCurrentString = theValue, aValueString;
-
-  while (!aCurrentString.IsEmpty())
+  switch (theMetric)
   {
-    Standard_Integer aPosition = aCurrentString.Search (", ");
-    aValueString = aCurrentString;
-    if (aPosition > 0)
-      aCurrentString = aValueString.Split (aPosition - 1);
-    theValues.Append (aValueString.RealValue());
-    if (aPosition > 0)
-      aCurrentString = aCurrentString.Split (2);
+    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;
+    default: return Standard_False;
   }
   return Standard_True;
 }
 
 // =======================================================================
-// function : RealVectorToString
+// function : ToMessageMetric
 // purpose :
 // =======================================================================
-TCollection_AsciiString Message::RealVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues)
+Standard_Boolean Message::ToMessageMetric (const OSD_MemInfo::Counter theMemInfo, Message_MetricType& theMetric)
 {
-  TCollection_AsciiString aValue = ("(");
-
-  for (NCollection_Vector<Standard_Real>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
+  switch (theMemInfo)
   {
-    aValue += aValuesIt.Value();
-    if (aValuesIt.More())
-      aValue += VectorSeparator();
-  }
-  aValue += ")";
-
-  return aValue;
-}
-
-// =======================================================================
-// function : RealVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::RealVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues)
-{
-  TCollection_AsciiString aCurrentString = theValue, aValueString;
-
-  Standard_Integer aPosition = aCurrentString.Search ("(");
-  if (aPosition != 1)
-    return Standard_False;
-  aCurrentString = aCurrentString.Split (aPosition);
-
-  aPosition = aCurrentString.Search (")");
-  if (aPosition != 1)
-    return Standard_False;
-  aValueString = aCurrentString.Split (aPosition);
-
-
-  while (!aCurrentString.IsEmpty())
-  {
-    // x value
-    aPosition = aCurrentString.Search (", ");
-    aValueString = aCurrentString;
-    if (aPosition > 0)
-      aCurrentString = aValueString.Split (aPosition - 1);
-    theValues.Append (aValueString.RealValue());
-    if (aPosition > 0)
-      aCurrentString = aCurrentString.Split (2);
+    case OSD_MemInfo::MemPrivate:        theMetric = Message_MetricType_MemPrivate;        break;
+    case OSD_MemInfo::MemVirtual:        theMetric = Message_MetricType_MemVirtual;        break;
+    case OSD_MemInfo::MemWorkingSet:     theMetric = Message_MetricType_MemWorkingSet;     break;
+    case OSD_MemInfo::MemWorkingSetPeak: theMetric = Message_MetricType_MemWorkingSetPeak; break;
+    case OSD_MemInfo::MemSwapUsage:      theMetric = Message_MetricType_MemSwapUsage;      break;
+    case OSD_MemInfo::MemSwapUsagePeak:  theMetric = Message_MetricType_MemSwapUsagePeak;  break;
+    case OSD_MemInfo::MemHeapUsage:      theMetric = Message_MetricType_MemHeapUsage;      break;
+    default: return Standard_False;
   }
   return Standard_True;
 }
-
-// =======================================================================
-// function : CoordVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::CoordVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues)
-{
-  TCollection_AsciiString aValue = ("(");
-  aValue += RealVectorToString (theValues);
-  aValue += ")";
-
-  return aValue;
-}
-
-// =======================================================================
-// function : CoordVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::CoordVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues)
-{
-  TCollection_AsciiString aCurrentString = theValue, aValueString;
-
-  Standard_Integer aPosition = aCurrentString.Search ("(");
-  if (aPosition != 1)
-    return Standard_False;
-  aCurrentString = aCurrentString.Split (aPosition);
-
-  aPosition = aCurrentString.Search (")");
-  if (aPosition != 1)
-    return Standard_False;
-  aValueString = aCurrentString.Split (aPosition);
-
-  return RealVectorFromString (aCurrentString, theValues); 
-}
-
-// =======================================================================
-// function : ColorVectorToString
-// purpose :
-// =======================================================================
-TCollection_AsciiString Message::ColorVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues)
-{
-  TCollection_AsciiString aValue = ("[");
-  aValue += RealVectorToString (theValues);
-  aValue += "]";
-
-  return aValue;
-}
-
-// =======================================================================
-// function : ColorVectorFromString
-// purpose :
-// =======================================================================
-Standard_Boolean Message::ColorVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues)
-{
-  TCollection_AsciiString aCurrentString = theValue, aValueString;
-
-  Standard_Integer aPosition = aCurrentString.Search ("[");
-  if (aPosition != 1)
-    return Standard_False;
-  aCurrentString = aCurrentString.Split (aPosition);
-
-  aPosition = aCurrentString.Search ("]");
-  if (aPosition != 1)
-    return Standard_False;
-  aValueString = aCurrentString.Split (aPosition);
-
-  return RealVectorFromString (aCurrentString, theValues); 
-}
-
-// =======================================================================
-// function : ConvertStream
-// purpose :
-// =======================================================================
-void Message::ConvertStream (const Standard_SStream& theStream,
-  Standard_Integer& theColumnCount,
-  NCollection_Vector<TCollection_AsciiString>& theValues)
-{
-  TCollection_AsciiString aStream (theStream.str().c_str());
-  Standard_Character aSeparator = Message::DumpSeparator();
-  Standard_Integer aColumnCount = 0;
-
-  TCollection_AsciiString aCurrentString = aStream;
-  Standard_Integer aPosition = aCurrentString.Search (aSeparator);
-  if (aPosition >= 1)
-  {
-    TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
-    Standard_Boolean aClassNameFound = Standard_False;
-    while (!aCurrentString.IsEmpty())
-    {
-      TCollection_AsciiString aValueString = aCurrentString;
-      aPosition = aValueString.Search (aSeparator);
-      if (aPosition < 0 )
-        break;
-      aCurrentString = aValueString.Split (aPosition - 1);
-
-      if (!aColumnCount)
-      {
-        if (!aClassNameFound)
-          aClassNameFound = Standard_True;
-        else
-        {
-          if (!aValueString.IsIntegerValue())
-            break; // not correct Dump, in correct the first value is number of property columns
-          aColumnCount = aValueString.IntegerValue();
-        }
-      }
-      else
-        theValues.Append (aValueString);
-
-      if (aTailString.IsEmpty())
-        break;
-      aCurrentString = aTailString;
-      aPosition = aCurrentString.Search (aSeparator);
-      if (aPosition < 0 )
-      {
-        aCurrentString = aTailString;
-        aTailString = TCollection_AsciiString();
-      }
-      else
-        aTailString = aCurrentString.Split (aPosition);
-    }
-  }
-  theColumnCount = aColumnCount;
-}
index 6c440bad812e517d388bfd8ac87358179c799066..2df8154bce8ccffe2e52828792f6e0899a59b60c 100644 (file)
@@ -18,8 +18,9 @@
 #define _Message_HeaderFile
 
 #include <Message_Gravity.hxx>
-#include <Message_PerfMeterMode.hxx>
+#include <Message_MetricType.hxx>
 #include <NCollection_Vector.hxx>
+#include <OSD_MemInfo.hxx>
 
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
@@ -39,6 +40,7 @@ class Message_PrinterOStream;
 class Message_ProgressIndicator;
 class Message_ProgressScale;
 class Message_ProgressSentry;
+class Message_Report;
 
 
 //! Defines
@@ -56,7 +58,12 @@ public:
   //! By default, it contains single printer directed to std::cout.
   //! It can be customized according to the application needs.
   Standard_EXPORT static const Handle(Message_Messenger)& DefaultMessenger();
-  
+
+  //! returns the only one instance of Report
+  //! When theToCreate is true - automatically creates message report when not exist.
+  //! that has been created.
+  Standard_EXPORT static const Handle(Message_Report)& DefaultReport (const Standard_Boolean theToCreate = Standard_False);
+
   //! Returns the string filled with values of hours, minutes and seconds.
   //! Example:
   //! 1. (5, 12, 26.3345) returns "05h:12m:26.33s",
@@ -64,132 +71,41 @@ public:
   //! 3. (0,  0,  4.5   ) returns "4.50s"
   Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
 
-  //! Returns the string name for a given gravity.
-  //! @param Gravity gravity type
-  //! @return string identifier from the list Message_Trace, Message_Info, Message_Warning, Message_Alarm and Message_Fail
-  Standard_EXPORT static Standard_CString GravityToString (const Message_Gravity theGravity);
-
-  //! Returns the gravity type from the given string identifier (using case-insensitive comparison).
-  //! @param theGravityString string identifier
-  //! @return gravity or Message_Trace if string identifier is invalid
-  static Message_Gravity GravityFromString (const Standard_CString theGravityString)
-  {
-    Message_Gravity aGravity = Message_Trace;
-    GravityFromString (theGravityString, aGravity);
-    return aGravity;
-  }
-
-  //! Determines the gravity from the given string identifier (using case-insensitive comparison).
-  //! @param theGravityString string identifier
-  //! @param theGravity detected shape type
+  //! Determines the metric from the given string identifier.
+  //! @param theString string identifier
+  //! @param theType detected type of metric
   //! @return TRUE if string identifier is known
-  Standard_EXPORT static Standard_Boolean GravityFromString (const Standard_CString theGravityString,
-                                                             Message_Gravity& theGravity);
+  Standard_EXPORT static Standard_Boolean MetricFromString (const Standard_CString theString,
+                                                            Message_MetricType& theType);
 
-  //! Returns the string name for a perf meter mode.
-  //! @param theValue mode
-  //! @return string identifier
-  Standard_EXPORT static Standard_CString PerfMeterModeToString (const Message_PerfMeterMode theValue);
+  //! Returns the string name for a given metric type.
+  //! @param theType metric type
+  //! @return string identifier from the list of Message_MetricType
+  Standard_EXPORT static Standard_CString MetricToString (const Message_MetricType theType);
 
-  //! Returns the enum value from the given string identifier (using case-insensitive comparison).
+  //! Returns the metric type from the given string identifier.
   //! @param theString string identifier
-  //! @return enum or Message_PerfMeterMode_None if string identifier is invalid
-  static Message_PerfMeterMode PerfMeterModeFromString (const Standard_CString theString)
+  //! @return metric type or Message_MetricType_None if string identifier is invalid
+  static Message_MetricType MetricFromString (const Standard_CString theString)
   {
-    Message_PerfMeterMode aValue = Message_PerfMeterMode_None;
-    PerfMeterModeFromString (theString, aValue);
-    return aValue;
+    Message_MetricType aMetric = Message_MetricType_None;
+    MetricFromString (theString, aMetric);
+    return aMetric;
   }
 
-  //! Returns the enum value from the given string identifier (using case-insensitive comparison).
-  //! @param theString string identifier
-  //! @return enum or Message_PerfMeterMode_None if string identifier is invalid
-  //! @return TRUE if string identifier is known
-  Standard_EXPORT static Standard_Boolean PerfMeterModeFromString (const Standard_CString theString,
-                                                                   Message_PerfMeterMode& theValue);
-
-
-  //! Returns separator symbol of Dump information
-  static Standard_Character DumpSeparator() { return '\\'; }
-
-  //! Returns separator symbol of values vector union
-  static TCollection_AsciiString VectorSeparator() { return " ,"; }
-
-  //! Convert handle pointer to string value
-  //! \param thePointer a pointer
-  //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString TransientToString (const Handle(Standard_Transient)& thePointer,
-                                                                    const bool isShortInfo = true);
-
-  //! Convert pointer to string value
-  //! \param thePointer a pointer
-  //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer,
-                                                                  const bool isShortInfo = true);
-  //! Convert vector of real values to string, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString StrVectorToString
-    (const NCollection_Vector<TCollection_AsciiString>& theValues);
-
-  //! Convert string to vector of real values, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static Standard_Boolean StrVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<TCollection_AsciiString>& theValues);
-
-  //! Convert vector of real values to string, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString RealVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues);
-
-  //! Convert string to vector of real values, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static Standard_Boolean RealVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues);
-
-  //! Convert vector of real values to string, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString CoordVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues);
-
-  //! Convert string to vector of real values, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static Standard_Boolean CoordVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues);
-
-  //! Convert vector of real values to string, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString ColorVectorToString
-    (const NCollection_Vector<Standard_Real>& theValues);
-
-  //! Convert string to vector of real values, separator is vector separator
-  //! \param thePointer a container of real values
-  //! \return the string value
-  Standard_EXPORT static Standard_Boolean ColorVectorFromString
-    (const TCollection_AsciiString& theValue,
-     NCollection_Vector<Standard_Real>& theValues);
-
-  //! Converts stream to vector of values and column count
-  //! \param theStream stream value
-  //! \param theColumnCount [out] number of columns
-  //! \param theValues [out] container of split values
-  static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream,
-    Standard_Integer& theColumnCount,
-    NCollection_Vector<TCollection_AsciiString>& theValues);
+  //! Converts message metric to OSD memory info type.
+  //! \param theMetric [in] message metric
+  //! \param theMemInfo [out] filled memory info type
+  //! \return true if converted
+  static Standard_EXPORT Standard_Boolean ToOSDMetric (const Message_MetricType theMetric, OSD_MemInfo::Counter& theMemInfo);
 
-protected:
+  //! Converts OSD memory info type to message metric.
+  //! \param theMemInfo [int] memory info type
+  //! \param theMetric [out] filled message metric
+  //! \return true if converted
+  static Standard_EXPORT Standard_Boolean ToMessageMetric (const OSD_MemInfo::Counter theMemInfo, Message_MetricType& theMetric);
 
+protected:
 
 
 
index 44555fccf28e0e56e546cbd7fb1c6e231fd023ac..2e7815feae69a9865021621955e612d18be3cbb6 100644 (file)
@@ -40,7 +40,6 @@ Standard_CString Message_AlertExtended::GetMessageKey () const
 //function : GetCompositeAlerts
 //purpose  : 
 //=======================================================================
-
 Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (const Standard_Boolean isCreate)
 {
   if (myCompositAlerts.IsNull() && isCreate)
@@ -50,32 +49,45 @@ Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (cons
 }
 
 //=======================================================================
-//function : IsMetricValid
+//function : SupportsMerge
 //purpose  : 
 //=======================================================================
+Standard_Boolean Message_AlertExtended::SupportsMerge () const
+{
+  if (myCompositAlerts.IsNull())
+    return Standard_True;
+
+  // hierarchical alerts can not be merged
+  for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
+  {
+    if (!myCompositAlerts->GetAlerts ((Message_Gravity)iGravity).IsEmpty())
+      return Standard_False;
+  }
+
+  return Standard_True;
+}
 
-Standard_Boolean Message_AlertExtended::IsMetricValid() const
+//=======================================================================
+//function : Merge
+//purpose  : 
+//=======================================================================
+Standard_Boolean Message_AlertExtended::Merge (const Handle(Message_Alert)& /*theTarget*/)
 {
-  return fabs (myMetricStart - GetUndefinedMetric()) > Precision::Confusion() &&
-         fabs (myMetricStop  - GetUndefinedMetric()) > Precision::Confusion();
+  // by default, merge trivially
+  return Standard_False;
 }
 
 //=======================================================================
 //function : AddAlert
 //purpose  : 
 //=======================================================================
-
 Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Report)& theReport,
                                                        const Handle(Message_Attribute)& theAttribute,
-                                                       Message_PerfMeter* thePerfMeter,
-                                                       const Handle(Message_Alert)& theParentAlert)
+                                                       const Message_Gravity theGravity)
 {
-  if (!theReport->IsActive (Message_Info))
-    return Handle(Message_Alert)();
-
   Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
   anAlert->SetAttribute (theAttribute);
-  theReport->AddAlert (Message_Info, anAlert, thePerfMeter, theParentAlert);
+  theReport->AddAlert (theGravity, anAlert);
 
   return anAlert;
 }
index bac7047cd953691a56d757ca25fe3611b04c6d1c..c5d81355e58a2921c3aea7629f7e25b4ab9678b8 100644 (file)
 #define _Message_AlertExtended_HeaderFile
 
 #include <Message_Alert.hxx>
+#include <Message_Gravity.hxx>
 #include <TCollection_AsciiString.hxx>
 
 class Message_Attribute;
-class Message_PerfMeter;
 class Message_Report;
 
 DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
@@ -29,8 +29,7 @@ class Message_CompositeAlerts;
 
 //! Inherited class of Message_Alert with some additional information.
 //!
-//! It has Message_Attributes to provide the alert name, description and
-//! other custom information
+//! It has Message_Attributes to provide the alert name, and other custom information
 //!
 //! It is possible to set performance meter into alert to store time/memory metric information
 //! spent between the next alert adding. Also time of child alerts are collected
@@ -43,8 +42,7 @@ class Message_AlertExtended : public Message_Alert
 {
 public:
   //! Empty constructor
-  Standard_EXPORT Message_AlertExtended()
-    : Message_Alert(), myMetricStart (GetUndefinedMetric()), myMetricStop (GetUndefinedMetric()) {}
+  Standard_EXPORT Message_AlertExtended() : Message_Alert() {}
 
   //! Return a C string to be used as a key for generating text user 
   //! messages describing this alert.
@@ -59,75 +57,41 @@ public:
 
   //! Returns container of the alert attributes
   //! \param theAttributes an attribute values
-  const Handle(Message_Attribute)& Attribute () const { return myAttribute; }
+  const Handle(Message_Attribute)& Attribute() const { return myAttribute; }
 
   //! Returns class provided hierarchy of alerts if created or create if the parameter is true
   //! \param isCreate if composite alert has not been created for this alert, it should be created
   //! \return instance or NULL
   Standard_EXPORT Handle (Message_CompositeAlerts) GetCompositeAlerts (const Standard_Boolean isCreate = Standard_False);
 
-  //! Returns performance meter
-  //! \return instance or NULL
-  Message_PerfMeter* GetPerfMeter() { return myPerfMeter; }
-
-  //! Returns true if metric is computed
-  //! @return value
-  Standard_EXPORT Standard_Boolean IsMetricValid() const;
-
-  //! Returns the alert cumulative metric. It includes time/mem of sub alerts
-  //! @return value
-  Standard_Real MetricStart() const { return myMetricStart; }
-
-  //! Returns the alert cumulative metric. It includes time/mem of sub alerts
-  //! @return value
-  Standard_Real MetricStop() const { return myMetricStop; }
-
-  //! Sets cumulative time/mem of alert
-  //! \param theCumulativeMetric time/mem of the alert
-  void SetMetricValues (const Standard_Real theStartValue, const Standard_Real theStopValue)
-    { myMetricStart = theStartValue; myMetricStop = theStopValue; }
-
   //! Return true if this type of alert can be merged with other
   //! of the same type to avoid duplication.
+  //! Hierarchical alerts can not be merged
   //! Basis implementation returns true.
-  virtual Standard_EXPORT Standard_Boolean SupportsMerge () const { return Standard_False; }
+  virtual Standard_EXPORT Standard_Boolean SupportsMerge() const;
 
-  //! Returns default value of the time/mem when it is not defined
-  //! \return integer value
-  static Standard_Real GetUndefinedMetric() { return -1.0; }
+  //! If possible, merge data contained in this alert to theTarget.
+  //! @return True if merged.
+  //! Base implementation always returns false.
+  virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
 
   //! Creates new instance of the alert and put it into report with Message_Info gravity.
   //! It does nothing if such kind of gravity is not active in the report
   //! @param theReport the message report where new alert is placed
   //! @param theAttribute container of additional values of the alert
-  //! @param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
-  //! @param theParentAlert parent for the new alert, or alert is placed under the report
   //! @return created alert or NULL if Message_Info is not active in report
   static Standard_EXPORT Handle(Message_Alert) AddAlert (const Handle(Message_Report)& theReport,
                                                          const Handle(Message_Attribute)& theAttribute,
-                                                         Message_PerfMeter* thePerfMeter,
-                                                         const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
+                                                         const Message_Gravity theGravity);
 
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
 
-protected:
-  //! Sets performance meter
-  //! \param theMeter instance pointer or NULL
-  void SetPerfMeter (Message_PerfMeter* theMeter) { myPerfMeter = theMeter; }
-
 protected:
 
   Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
   //!< It should be created by an attempt of a child alert creation
-
   Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
-
-  Message_PerfMeter* myPerfMeter; //!< performance meter
-  Standard_Real myMetricStart; //!< value on start metric computation
-  Standard_Real myMetricStop; //!< value on stop metric computation
-
-  friend Message_PerfMeter;
 };
 
 #endif // _Message_Alert_HeaderFile
index 9f73a1f56c15921458861865163f915f55a79584..3aed324b89d4718eede2282771b42008736e04c1 100644 (file)
 #include <Message_AttributeObject.hxx>
 #include <Message_AttributeStream.hxx>
 #include <Message_Gravity.hxx>
+#include <Message_Messenger.hxx>
 #include <Message_Report.hxx>
 
 #include <NCollection_Vector.hxx>
 #include <TCollection_AsciiString.hxx>
 
-static Handle(Message_Alert) OCCT_Message_Alert;
-
-#define MESSAGE_INFO(Name, Description, PerfMeter, ParentAlert) \
+#define MESSAGE_INFO(Name) \
   { \
-    if (!Message_Report::CurrentReport().IsNull() && \
-         Message_Report::CurrentReport()->IsActive (Message_Info)) \
+    if (!Message::DefaultReport().IsNull()) \
     { \
-      OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
-        new Message_Attribute (Name, Description), PerfMeter, ParentAlert); \
+     if (Message::DefaultReport()->IsActiveInMessenger())\
+     { Message::DefaultMessenger() << Name << Message_EndLine; } \
+     else \
+      Message_AlertExtended::AddAlert (Message::DefaultReport(), \
+        new Message_Attribute (Name), Message_Info); \
     } \
   }
 
-#define MESSAGE_INFO_OBJECT(Object, StreamValues, Name, Description, PerfMeter, ParentAlert) \
+#define MESSAGE_INFO_OBJECT(Object, Name) \
   { \
-    if (!Message_Report::CurrentReport().IsNull() && \
-         Message_Report::CurrentReport()->IsActive (Message_Info)) \
+    if (!Message::DefaultReport().IsNull()) \
     { \
-      OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
-        new Message_AttributeObject (Object, StreamValues, Name, Description), PerfMeter, ParentAlert ); \
+     if (Message::DefaultReport()->IsActiveInMessenger())\
+     { Message::DefaultMessenger() << Name << Object << Message_EndLine; } \
+     else \
+      Message_AlertExtended::AddAlert (Message::DefaultReport(), \
+        new Message_AttributeObject (Object, Name), Message_Info); \
     } \
   }
 
-#define MESSAGE_INFO_STREAM(StreamValues, Name, Description, PerfMeter, ParentAlert) \
+#define MESSAGE_INFO_STREAM(StreamValues, Name) \
   { \
-    if (!Message_Report::CurrentReport().IsNull() && \
-         Message_Report::CurrentReport()->IsActive (Message_Info)) \
+    if (!Message::DefaultReport().IsNull()) \
     { \
-      OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
-        new Message_AttributeStream (StreamValues, Name, Description), PerfMeter, ParentAlert ); \
+     if (Message::DefaultReport()->IsActiveInMessenger())\
+     { Message::DefaultMessenger() << Name << StreamValues << Message_EndLine; } \
+     else \
+      Message_AlertExtended::AddAlert (Message::DefaultReport(), \
+        new Message_AttributeStream (StreamValues, Name), Message_Info); \
     } \
   }
 
-//#define DUMP_VALUE(OS, Value) \
-//  { \
-//    OS << Value << Message::DumpSeparator(); \
-//  }
-//
-//#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \
-//  { \
-//    OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \
-//  }
-//
-//#define DUMP_VALUES(OS, Value1, Value2) \
-//  { \
-//    OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \
-//  }
-//
-//#define DUMP_VEC_COLOR(Values, Value) \
-//  { \
-//    Value = Message::ColorVectorToString (aValues); \
-//  }
-//
-//#define DUMP_VEC_COLOR_SPLIT(Value, Values) \
-//  { \
-//    Message::ColorVectorFromString (Value, Values); \
-//  }
-//
-//#define DUMP_VEC_COORD(Values, Value) \
-//  { \
-//    Value = Message::CoordVectorToString (aValues); \
-//  }
-//
-//#define DUMP_VEC_COORD_SPLIT(Value, Values) \
-//  { \
-//    Message::CoordVectorFromString (Value, Values); \
-//  }
-//
-//
-//#define DUMP_VALUES_SPLIT(OS, ColumnCount, Values) \
-//  { \
-//    Message::ConvertStream (OS, aColumnCount, aValues); \
-//  }
-
 #endif // _Message_Alerts_HeaderFile
index f27b332266bb6943123e1026272964d9514b21f4..61198d28d0b7d9ccb9970f65f27745556b38a795 100644 (file)
@@ -27,9 +27,8 @@ class Message_Attribute : public Standard_Transient
 {
 public:
   //! Empty constructor
-  Standard_EXPORT Message_Attribute (const TCollection_AsciiString& theName = TCollection_AsciiString(),
-                                     const TCollection_AsciiString& theDescription = TCollection_AsciiString())
-    : myName (theName), myDescription (theDescription) {}
+  Standard_EXPORT Message_Attribute (const TCollection_AsciiString& theName = TCollection_AsciiString())
+    : myName (theName) {}
 
   //! Return a C string to be used as a key for generating text user 
   //! messages describing this alert.
@@ -46,21 +45,12 @@ public:
   //! @param theName a name for the alert
   void SetName (const TCollection_AsciiString& theName) { myName = theName; }
 
-  //! Sets desription of alert
-  //! @param theName a name for the alert
-  void SetDescription (const TCollection_AsciiString& theDescription) { myDescription = theDescription; }
-
-  //! Returns description of alert if it is set
-  //! @return alert description
-  virtual const TCollection_AsciiString& GetDescription() const { return myDescription; }
-
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
 
 private:
 
   TCollection_AsciiString myName; //!< alert name, if defined is used in GetMessageKey
-  TCollection_AsciiString myDescription; //!< alert description if defined
 
 };
 
diff --git a/src/Message/Message_AttributeMeter.cxx b/src/Message/Message_AttributeMeter.cxx
new file mode 100644 (file)
index 0000000..3ffc22c
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Message_AttributeMeter.hxx>
+
+#include <Precision.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
+
+//=======================================================================
+//function : SetValues
+//purpose  : 
+//=======================================================================
+Message_AttributeMeter::Message_AttributeMeter (const TCollection_AsciiString& theName)
+: Message_Attribute(theName)
+{
+}
+
+//=======================================================================
+//function : HasMetric
+//purpose  : 
+//=======================================================================
+Standard_Boolean Message_AttributeMeter::HasMetric (const Message_MetricType& theMetric) const
+{
+  return myMetrics.IsBound (theMetric);
+}
+
+//=======================================================================
+//function : IsMetricValid
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean Message_AttributeMeter::IsMetricValid (const Message_MetricType& theMetric) const
+{
+  return fabs (StartValue (theMetric) - GetUndefinedMetric()) > Precision::Confusion() &&
+         fabs (StopValue (theMetric) - GetUndefinedMetric()) > Precision::Confusion();
+}
+
+//=======================================================================
+//function : StartValue
+//purpose  : 
+//=======================================================================
+Standard_Real Message_AttributeMeter::StartValue (const Message_MetricType& theMetric) const
+{
+  if (!HasMetric (theMetric))
+    return GetUndefinedMetric();
+
+  return myMetrics.Find (theMetric).first;
+}
+
+//=======================================================================
+//function : SetStartValue
+//purpose  : 
+//=======================================================================
+void Message_AttributeMeter::SetStartValue (const Message_MetricType& theMetric, const Standard_Real theValue)
+{
+  if (!HasMetric (theMetric))
+  {
+    myMetrics.Bind (theMetric, std::make_pair (theValue, GetUndefinedMetric()));
+  }
+  myMetrics.ChangeFind (theMetric).first = theValue;
+}
+
+//=======================================================================
+//function : StopValue
+//purpose  : 
+//=======================================================================
+Standard_Real Message_AttributeMeter::StopValue (const Message_MetricType& theMetric) const
+{
+  if (!HasMetric (theMetric))
+    return GetUndefinedMetric();
+
+  return myMetrics.Find (theMetric).second;
+}
+
+//=======================================================================
+//function : SetStopValue
+//purpose  : 
+//=======================================================================
+void Message_AttributeMeter::SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue)
+{
+  if (!HasMetric (theMetric))
+  {
+    // start value should be already set
+    return;
+  }
+  myMetrics.ChangeFind (theMetric).second = theValue;
+}
diff --git a/src/Message/Message_AttributeMeter.hxx b/src/Message/Message_AttributeMeter.hxx
new file mode 100644 (file)
index 0000000..a9f98d4
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Message_AttributeMeter_HeaderFile
+#define _Message_AttributeMeter_HeaderFile
+
+#include <Message_Attribute.hxx>
+#include <Message_MetricType.hxx>
+
+#include <NCollection_DataMap.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+class Message_Alert;
+
+//! Alert object storing container metrics values
+class Message_AttributeMeter : public Message_Attribute
+{
+public:
+
+  //! Constructor with string argument
+  Standard_EXPORT Message_AttributeMeter (const TCollection_AsciiString& theName = TCollection_AsciiString());
+
+  //! Checks whether the attribute has values for the metric
+  //! \param theMetric [in] metric type
+  //! \return true if the metric values exist
+  Standard_EXPORT Standard_Boolean HasMetric (const Message_MetricType& theMetric) const;
+
+  //! Returns true if metric is computed
+  //! @return value
+  Standard_EXPORT Standard_Boolean IsMetricValid (const Message_MetricType& theMetric) const;
+
+  //! Returns start value for the metric
+  //! \param theMetric [in] metric type
+  Standard_EXPORT Standard_Real StartValue (const Message_MetricType& theMetric) const;
+
+  //! Sets start values for the metric
+  //! \param theMetric [in] metric type
+  Standard_EXPORT void SetStartValue (const Message_MetricType& theMetric, const Standard_Real theValue);
+
+  //! Returns stop value for the metric
+  //! \param theMetric [in] metric type
+  Standard_EXPORT Standard_Real StopValue (const Message_MetricType& theMetric) const;
+
+  //! Sets stop values for the metric
+  //! \param theMetric [in] metric type
+  Standard_EXPORT void SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue);
+
+  //! Returns default value of the time/mem when it is not defined
+  //! \return integer value
+  static Standard_Real GetUndefinedMetric() { return -1.0; }
+
+  // OCCT RTTI
+  DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute)
+
+private:
+
+  typedef std::pair<Standard_Real, Standard_Real> MinToMaxValue;
+  NCollection_DataMap<Message_MetricType, MinToMaxValue> myMetrics; //!< computed metrics
+};
+
+#endif // _Message_AttributeMeter_HeaderFile
index b31ad97cd0f3fd53781d33ec7bfb1369726062e8..67ac1f6aff783e262bdb42a3642a41701d1e061b 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <Message_AttributeObject.hxx>
 
-IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
+IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute)
 
 //=======================================================================
 //function : Message_AttributeObject
@@ -23,10 +23,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
 //=======================================================================
 
 Message_AttributeObject::Message_AttributeObject (const Handle(Standard_Transient)& theObject,
-                                                  const Standard_SStream& theStream,
-                                                  const TCollection_AsciiString& theName,
-                                                  const TCollection_AsciiString& theDescription)
-: Message_AttributeStream (theStream, theName, theDescription)
+                                                  const TCollection_AsciiString& theName)
+: Message_Attribute (theName)
 {
   myObject = theObject;
 }
index 29e45e98ca0fb9d78efe47f9b7cd1c082711cd96..75321a100809964bb874a87b126af069df2216b0 100644 (file)
 #ifndef _Message_AttributeObject_HeaderFile
 #define _Message_AttributeObject_HeaderFile
 
-#include <Message_AttributeStream.hxx>
+#include <Message_Attribute.hxx>
 #include <TCollection_AsciiString.hxx>
 
 //! Alert object storing Transient object in its field
-class Message_AttributeObject : public Message_AttributeStream
+class Message_AttributeObject : public Message_Attribute
 {
 public:
   //! Constructor with string argument
   Standard_EXPORT Message_AttributeObject (const Handle(Standard_Transient)& theObject,
-    const Standard_SStream& theStream,
-    const TCollection_AsciiString& theName = TCollection_AsciiString(),
-    const TCollection_AsciiString& theDescription = TCollection_AsciiString());
+    const TCollection_AsciiString& theName = TCollection_AsciiString());
 
   //! Sets the object
   //! @param theObject an instance
@@ -37,7 +35,7 @@ public:
   Handle(Standard_Transient) GetObject() const { return myObject; }
 
   // OCCT RTTI
-  DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
+  DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute)
 
 private:
   Handle(Standard_Transient) myObject;
index 20c38b79b14aaecdbaf2c58832f1440f5e5eeac4..19c5c8323aaef53fdf1bf583042d532ab291635e 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <Message.hxx>
 #include <Message_Msg.hxx>
-#include <Message_PerfMeter.hxx>
 #include <Message_Report.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
@@ -27,9 +26,8 @@ IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
 //purpose  : 
 //=======================================================================
 Message_AttributeStream::Message_AttributeStream (const Standard_SStream& theStream,
-                                                  const TCollection_AsciiString& theName,
-                                                  const TCollection_AsciiString& theDescription)
-: Message_Attribute(theName, theDescription)
+                                                  const TCollection_AsciiString& theName)
+: Message_Attribute(theName)
 {
   SetStream (theStream);
 }
index c0a32187268ad60565875021c5fa85d8a03eee7d..2520670cfc2f2bb2a3e670d75748a4a3c3fa78c3 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <NCollection_Vector.hxx>
 
-class Message_PerfMeter;
 class Message_Report;
 
 //! Alert object storing container of Standard_Real values in its field
@@ -31,8 +30,7 @@ public:
 
   //! Constructor with string argument
   Standard_EXPORT Message_AttributeStream (const Standard_SStream& theStream,
-                                           const TCollection_AsciiString& theName = TCollection_AsciiString(),
-                                           const TCollection_AsciiString& theDescription = TCollection_AsciiString());
+                                           const TCollection_AsciiString& theName = TCollection_AsciiString());
 
   //! Sets stream value
   Standard_EXPORT void SetStream (const Standard_SStream& theStream);
index bf390d424a395f9c92f999b7f2c90543d61c1c30..79ed72e80dd51e56a1f914e1a3135b9fbc9bc52e 100644 (file)
 IMPLEMENT_STANDARD_RTTIEXT(Message_CompositeAlerts, Standard_Transient)
 
 //=======================================================================
-//function : Merge
-//purpose  : 
+//function : AddAlert
+//purpose  :
 //=======================================================================
 
-Standard_Boolean Message_CompositeAlerts::Merge (const Handle(Message_Alert)& theTarget)
+Standard_Boolean Message_CompositeAlerts::AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert)
 {
-  Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theTarget);
-  if (!anExtAlert.IsNull() && !anExtAlert->GetCompositeAlerts().IsNull())
+  Standard_ASSERT_RETURN (! theAlert.IsNull(), "Attempt to add null alert", Standard_False);
+  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+                          "Adding alert with gravity not in valid range", Standard_False);
+
+  Message_ListOfAlert& aList = myAlerts[theGravity];
+  if (theAlert->SupportsMerge() && ! aList.IsEmpty())
   {
-    Handle(Message_CompositeAlerts) anExtCompositeAlert = anExtAlert->GetCompositeAlerts();
-    // hierarchical alerts can not be merged
-    for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
+    // merge is performed only for alerts of exactly same type
+    const Handle(Standard_Type)& aType = theAlert->DynamicType();
+    for (Message_ListOfAlert::Iterator anIt(aList); anIt.More(); anIt.Next())
     {
-      if (!GetAlerts ((Message_Gravity)iGravity).IsEmpty() ||
-          !anExtCompositeAlert->GetAlerts ((Message_Gravity)iGravity).IsEmpty())
+      // if merged successfully, just return
+      if (aType == anIt.Value()->DynamicType() && theAlert->Merge (anIt.Value()))
         return Standard_False;
     }
   }
-  // by default, merge trivially
+
+  // if not merged, just add to the list
+  aList.Append (theAlert);
+  return Standard_True;
+}
+
+//=======================================================================
+//function : Merge
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean Message_CompositeAlerts::RemoveAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert)
+{
+  Standard_ASSERT_RETURN (! theAlert.IsNull(), "Attempt to add null alert", Standard_False);
+  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+                          "Adding alert with gravity not in valid range", Standard_False);
+
+  Message_ListOfAlert& anAlerts = myAlerts[theGravity];
+  if (!anAlerts.Contains (theAlert))
+      return Standard_False;
+
+  anAlerts.Remove (theAlert);
   return Standard_True;
 }
 
@@ -47,9 +72,13 @@ Standard_Boolean Message_CompositeAlerts::Merge (const Handle(Message_Alert)& th
 //purpose  :
 //=======================================================================
 
-Message_ListOfAlert& Message_CompositeAlerts::GetAlerts (const Message_Gravity theGravity)
+const Message_ListOfAlert& Message_CompositeAlerts::GetAlerts (const Message_Gravity theGravity) const
 {
-  return myChildAlerts[theGravity];
+  static const Message_ListOfAlert anEmptyList;
+  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+                          "Requesting alerts for gravity not in valid range", anEmptyList);
+
+  return myAlerts[theGravity];
 }
 
 //=======================================================================
@@ -61,9 +90,75 @@ Standard_Boolean Message_CompositeAlerts::HasAlert (const Handle(Message_Alert)&
 {
   for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
   {
-    Message_ListOfAlert& anAlerts = GetAlerts ((Message_Gravity)iGravity);
+    const Message_ListOfAlert& anAlerts = GetAlerts ((Message_Gravity)iGravity);
     if (anAlerts.Contains (theAlert))
       return Standard_True;
   }
   return Standard_False;
 }
+
+//=======================================================================
+//function : HasAlerts
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_CompositeAlerts::HasAlert (const Handle(Standard_Type)& theType, Message_Gravity theGravity)
+{
+  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+                          "Requesting alerts for gravity not in valid range", Standard_False);
+
+  for (Message_ListOfAlert::Iterator anIt (myAlerts[theGravity]); anIt.More(); anIt.Next())
+  {
+    if (anIt.Value()->IsInstance(theType))
+      return Standard_True;
+  }
+  return Standard_False;
+}
+
+//=======================================================================
+//function : Clear
+//purpose  :
+//=======================================================================
+
+void Message_CompositeAlerts::Clear ()
+{
+  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
+  {
+    myAlerts[i].Clear();
+  }
+}
+
+//=======================================================================
+//function : Clear
+//purpose  :
+//=======================================================================
+
+void Message_CompositeAlerts::Clear (Message_Gravity theGravity)
+{
+  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+                          "Requesting alerts for gravity not in valid range", );
+  myAlerts[theGravity].Clear();
+}
+
+//=======================================================================
+//function : Clear
+//purpose  :
+//=======================================================================
+
+void Message_CompositeAlerts::Clear (const Handle(Standard_Type)& theType)
+{
+  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
+  {
+    for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); )
+    {
+      if (anIt.Value().IsNull() || anIt.Value()->IsInstance (theType))
+      {
+        myAlerts[i].Remove (anIt);
+      }
+      else
+      {
+        anIt.More();
+      }
+    }
+  }
+}
index f069d45836d6c0c5950ddccdcc52e39397908727..aeb53d972f0ad46cc32516f0273b7d02c60f4773 100644 (file)
@@ -42,26 +42,39 @@ public:
   //! Empty constructor
   Standard_EXPORT Message_CompositeAlerts () {}
 
-  //! If possible, merge data contained in this alert to theTarget.
-  //! @return True if merged.
-  //! Base implementation always returns true.
-  virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
-  
+  //! Add alert with specified gravity.
+  Standard_EXPORT Standard_Boolean AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert);
+
+  //! Removes alert with specified gravity.
+  Standard_EXPORT Standard_Boolean RemoveAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert);
+
   //! Returns list of collected alerts with specified gravity
-  Standard_EXPORT Message_ListOfAlert& GetAlerts (const Message_Gravity theGravity);
+  Standard_EXPORT const Message_ListOfAlert& GetAlerts (const Message_Gravity theGravity) const;
 
   //! Returns true if the alert belong the list of the child alerts.
   //! \param theAlert an alert to be checked as a child alert
   //! \return true if the alert is found in a container of children
   Standard_EXPORT Standard_Boolean HasAlert (const Handle(Message_Alert)& theAlert);
 
+  //! Returns true if specific type of alert is recorded with specified gravity
+  Standard_EXPORT Standard_Boolean HasAlert (const Handle(Standard_Type)& theType, Message_Gravity theGravity);
+
+  //! Clears all collected alerts
+  Standard_EXPORT void Clear ();
+
+  //! Clears collected alerts with specified gravity
+  Standard_EXPORT void Clear (Message_Gravity theGravity);
+
+  //! Clears collected alerts with specified type
+  Standard_EXPORT void Clear (const Handle(Standard_Type)& theType);
+
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(Message_CompositeAlerts,Standard_Transient)
 
 protected:
   // store messages in a lists sorted by gravity;
   // here we rely on knowledge that Message_Fail is the last element of the enum
-  Message_ListOfAlert myChildAlerts[Message_Fail + 1];
+  Message_ListOfAlert myAlerts[Message_Fail + 1];
 };
 
 #endif // _Message_CompositeAlerts_HeaderFile
diff --git a/src/Message/Message_Level.cxx b/src/Message/Message_Level.cxx
new file mode 100644 (file)
index 0000000..2542a6d
--- /dev/null
@@ -0,0 +1,211 @@
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Message_Level.hxx>
+
+#include <Message.hxx>
+#include <Message_AlertExtended.hxx>
+#include <Message_CompositeAlerts.hxx>
+#include <Message_AttributeMeter.hxx>
+#include <Message_Report.hxx>
+
+#include <OSD_Chronometer.hxx>
+#include <OSD_MemInfo.hxx>
+
+//=======================================================================
+//function : Destructor
+//purpose  :
+//=======================================================================
+Message_Level::Message_Level()
+{
+  const Handle(Message_Report)& aDefaultReport = Message::DefaultReport();
+  if (!aDefaultReport.IsNull() && aDefaultReport->IsActiveInMessenger())
+    aDefaultReport->AddLevel (this);
+}
+
+//=======================================================================
+//function : Destructor
+//purpose  :
+//=======================================================================
+
+Message_Level::~Message_Level()
+{
+  Remove();
+}
+
+//=======================================================================
+//function : SetRootAlert
+//purpose  :
+//=======================================================================
+
+void Message_Level::SetRootAlert (const Handle(Message_AlertExtended)& theAlert)
+{
+  myRootAlert = theAlert;
+  startAlert (myRootAlert);
+}
+
+//=======================================================================
+//function : AddAlert
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_Level::AddAlert (const Message_Gravity theGravity,
+                                          const Handle(Message_Alert)& theAlert)
+{
+  Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
+  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->GetCompositeAlerts (Standard_True);
+
+  // update metrics of the previous alert
+  stopAlert (myLastAlert);
+
+  // set start metrics of the new alert
+  myLastAlert = anAlertExtended;
+  startAlert (myLastAlert);
+
+  // add child alert
+  aCompositeAlert->AddAlert (theGravity, theAlert);
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : AddAlert
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_Level::AddLevelAlert (const Message_Gravity theGravity,
+                                               const Handle(Message_Alert)& theAlert)
+{
+  Handle(Message_AlertExtended) aRootAlert = !myLastAlert.IsNull() ? myLastAlert : myRootAlert;
+
+  Handle(Message_CompositeAlerts) aCompositeAlert = aRootAlert->GetCompositeAlerts (Standard_True);
+  // add child alert
+  aCompositeAlert->AddAlert (theGravity, theAlert);
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : Remove()
+//purpose  :
+//=======================================================================
+
+void Message_Level::Remove()
+{
+  const Handle(Message_Report)& aDefaultReport = Message::DefaultReport();
+  if (aDefaultReport.IsNull() || !aDefaultReport->IsActiveInMessenger())
+    return;
+
+  stopAlert (myLastAlert);
+  stopAlert (myRootAlert);
+
+  if (!Message::DefaultReport().IsNull())
+    Message::DefaultReport()->RemoveLevel (this);
+}
+
+//=======================================================================
+//function : startAlert
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_Level::startAlert (const Handle(Message_AlertExtended)& theAlert)
+{
+  return setAlertMetrics (theAlert, Standard_True);
+}
+
+//=======================================================================
+//function : stopAlert
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_Level::stopAlert (const Handle(Message_AlertExtended)& theAlert)
+{
+  return setAlertMetrics (theAlert, Standard_False);
+}
+
+//=======================================================================
+//function : setAlertMetrics
+//purpose  :
+//=======================================================================
+
+Standard_Boolean Message_Level::setAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
+                                                 const Standard_Boolean theStartValue)
+{
+  if (theAlert.IsNull())
+    return Standard_False;
+
+  Handle(Message_AttributeMeter) aMeterAttribute = Handle(Message_AttributeMeter)::DownCast (theAlert->Attribute());
+  if (aMeterAttribute.IsNull())
+    return Standard_False;
+
+  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 Standard_True;
+
+  OSD_MemInfo aMemInfo (Standard_False);
+  aMemInfo.Update (aCounters);
+  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()));
+  }
+  return Standard_True;
+}
diff --git a/src/Message/Message_Level.hxx b/src/Message/Message_Level.hxx
new file mode 100644 (file)
index 0000000..35de389
--- /dev/null
@@ -0,0 +1,93 @@
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Message_Level_HeaderFile
+#define _Message_Level_HeaderFile
+
+#include <Message_AlertExtended.hxx>
+#include <Message_Gravity.hxx>
+#include <Message_MetricType.hxx>
+
+#include <NCollection_DataMap.hxx>
+#include <Standard.hxx>
+
+//! This class defines level of alerts in the current report.
+//! The first added alert is the root alert, next alerts are children of the root alert.
+class Message_Level
+{
+
+public:
+  //! Constructs and starts (if autoStart is true) the named meter
+  //! 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();
+
+  //! Assures stopping upon destruction
+  Standard_EXPORT ~Message_Level();
+
+  //! Returns message alert on the level, by default the upper alert is returned
+  //! \param theLevelId a level of child position inside the upper alert of performance meter
+  //! \return alert instance or NULL
+  Handle(Message_AlertExtended) RootAlert() const { return myRootAlert; }
+
+  //! Returns message alert on the level, by default the upper alert is returned
+  //! \param theLevelId a level of child position inside the upper alert of performance meter
+  //! \return alert instance or NULL
+  Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert);
+
+  //! Processes the parameter alert. There are some variants:
+  //! - current alert is NULL, the alert becomes the current one and perf meter is started
+  //! - last alert of the current alert is stopped (perf meter becomes NULL, time is calculated),
+  //! the parameter alert is started (perf meter becomes the current one)
+  Standard_EXPORT Standard_Boolean AddAlert (const Message_Gravity theGravity,
+                                             const Handle(Message_Alert)& theAlert);
+
+  //! Add level alert, that is placed under the previous last alert if exists or under the root alert
+  Standard_EXPORT Standard_Boolean AddLevelAlert (const Message_Gravity theGravity,
+                                                  const Handle(Message_Alert)& theAlert);
+
+  //! Remove the current level from the report
+  Standard_EXPORT void Remove();
+
+protected:
+  //! Sets stop time into the alert
+  //! \param theAlert a level of child position inside the upper alert of performance meter
+  Standard_Boolean startAlert (const Handle(Message_AlertExtended)& theAlert);
+
+  //! Sets start time into the alert
+  //! \param theAlert a level of child position inside the upper alert of performance meter
+  Standard_Boolean stopAlert (const Handle(Message_AlertExtended)& theAlert);
+
+  //! Fills the alert with metric values
+  //! \param theAlert a level of child position inside the upper alert of performance meter
+  //! \param theStartValue flag whether the computed value is the start value, if false, stop value is filled
+  //! \return true if the alert is filled
+  Standard_Boolean setAlertMetrics (const Handle(Message_AlertExtended)& theAlert,
+                                    const Standard_Boolean theStartValue);
+
+protected:
+  Handle(Message_AlertExtended) myRootAlert; //!< root alerts
+  Handle(Message_AlertExtended) myLastAlert; //!< last added alert
+};
+
+//! @def MESSAGE_NEW_LEVEL
+//! Creates a new level instance of Sentry. This row should be inserted before messages using in the method.
+#define MESSAGE_ADD_LEVEL_SENTRY Message_Level aLevel;
+
+//! @def MESSAGE_NEW_LEVEL
+//! Removed the current level from report. It is not necessary to call it as the level will be removed at the method end.
+//! This macro might be useful for creation several levels in one method to remove previous and add new one.
+#define MESSAGE_REMOVE_LEVEL_SENTRY() aLevel.Remove();
+
+
+#endif // _Message_Level_HeaderFile
index 1e44c8b22088a0df17d6cb11cda947fa5e0a4451..c2e2c71799d579279fda8b135968e49a8b2fd4dc 100644 (file)
@@ -25,6 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Message_Messenger,Standard_Transient)
 //purpose  : 
 //=======================================================================
 Message_Messenger::Message_Messenger ()
+: myOutputGravity (Message_Info)
 {
   AddPrinter ( new Message_PrinterOStream );
 }
@@ -35,6 +36,7 @@ Message_Messenger::Message_Messenger ()
 //=======================================================================
 
 Message_Messenger::Message_Messenger (const Handle(Message_Printer)& thePrinter)
+: myOutputGravity (Message_Info)
 {
   AddPrinter (thePrinter);
 }
@@ -161,3 +163,41 @@ void Message_Messenger::Send (const TCollection_ExtendedString& theString,
     }
   }
 }
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_Messenger::Send (const Standard_SStream& theStream,
+                              const Message_Gravity theGravity,
+                              const Standard_Boolean putEndl) const
+{
+  for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More(); aPrinterIter.Next())
+  {
+    const Handle(Message_Printer)& aPrinter = aPrinterIter.Value();
+    if (!aPrinter.IsNull())
+    {
+      aPrinter->Send (theStream, theGravity, putEndl);
+    }
+  }
+}
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_Messenger::Send (const Handle(Standard_Transient)& theObject,
+                              const Message_Gravity theGravity,
+                              const Standard_Boolean putEndl) const
+{
+  for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More(); aPrinterIter.Next())
+  {
+    const Handle(Message_Printer)& aPrinter = aPrinterIter.Value();
+    if (!aPrinter.IsNull())
+    {
+      aPrinter->Send (theObject, theGravity, putEndl);
+    }
+  }
+}
index 675fba34360e9ebac56b817193ccafb769e5f1ba..951eac85f4d3797b3133e483e89a3487be2fdfaa 100644 (file)
@@ -84,6 +84,12 @@ public:
   //! The sequence can be modified.
   Message_SequenceOfPrinters& ChangePrinters() { return myPrinters; }
 
+  //! Returns the output gavity used in operator <<
+  Message_Gravity OuputGravity() const { return myOutputGravity; }
+
+  //! Sets the output gavity used in operator <<
+  void SetOuputGravity (const Message_Gravity theValue) { myOutputGravity = theValue; }
+
   //! Dispatch a message to all the printers in the list.
   //! Three versions of string representations are accepted for
   //! convenience, by default all are converted to ExtendedString.
@@ -98,17 +104,23 @@ public:
   //! See above
   Standard_EXPORT void Send (const TCollection_ExtendedString& theString, const Message_Gravity theGravity = Message_Warning, const Standard_Boolean putEndl = Standard_True) const;
 
+  //! See above
+  Standard_EXPORT void Send (const Standard_SStream& theStream, const Message_Gravity theGravity = Message_Warning, const Standard_Boolean putEndl = Standard_True) const;
+
+  //! See above
+  Standard_EXPORT void Send (const Handle(Standard_Transient)& theObject, const Message_Gravity theGravity = Message_Warning, const Standard_Boolean putEndl = Standard_True) const;
+
 private:
 
   Message_SequenceOfPrinters myPrinters;
-
+  Message_Gravity myOutputGravity; //!< gavity used in operator <<
 };
 
 // CString
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const Standard_CString theStr)
 {
-  theMessenger->Send (theStr, Message_Info, Standard_False);
+  theMessenger->Send (theStr, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -116,7 +128,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const TCollection_AsciiString& theStr)
 {
-  theMessenger->Send (theStr, Message_Info, Standard_False);
+  theMessenger->Send (theStr, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -124,7 +136,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const Handle(TCollection_HAsciiString)& theStr)
 {
-  theMessenger->Send (theStr->String(), Message_Info, Standard_False);
+  theMessenger->Send (theStr->String(), theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -132,7 +144,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const TCollection_ExtendedString& theStr)
 {
-  theMessenger->Send (theStr, Message_Info, Standard_False);
+  theMessenger->Send (theStr, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -140,7 +152,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const Handle(TCollection_HExtendedString)& theStr)
 {
-  theMessenger->Send (theStr->String(), Message_Info, Standard_False);
+  theMessenger->Send (theStr->String(), theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -149,7 +161,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
                                                     const Standard_Integer theVal)
 {
   TCollection_AsciiString aStr (theVal);
-  theMessenger->Send (aStr, Message_Info, Standard_False);
+  theMessenger->Send (aStr, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -158,7 +170,7 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
                                                     const Standard_Real theVal)
 {
   TCollection_AsciiString aStr (theVal);
-  theMessenger->Send (aStr, Message_Info, Standard_False);
+  theMessenger->Send (aStr, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -166,7 +178,15 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng
 inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
                                                     const Standard_SStream& theStream)
 {
-  theMessenger->Send (theStream.str().c_str(), Message_Info, Standard_False);
+  theMessenger->Send (theStream, theMessenger->OuputGravity(), Standard_False);
+  return theMessenger;
+}
+
+// AsciiString
+inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
+                                                    const Handle(Standard_Transient)& theObject)
+{
+  theMessenger->Send (theObject, theMessenger->OuputGravity(), Standard_False);
   return theMessenger;
 }
 
@@ -181,7 +201,7 @@ inline const Handle(Message_Messenger)&
 // Message_EndLine
 inline const Handle(Message_Messenger)& Message_EndLine (const Handle(Message_Messenger)& theMessenger)
 {
-  theMessenger->Send ("", Message_Info, Standard_True);
+  theMessenger->Send ("", theMessenger->OuputGravity(), Standard_True);
   return theMessenger;
 }
 
diff --git a/src/Message/Message_MetricType.hxx b/src/Message/Message_MetricType.hxx
new file mode 100644 (file)
index 0000000..1529306
--- /dev/null
@@ -0,0 +1,34 @@
+// Created on: 2019-08-13
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Message_MetricType_HeaderFile
+#define _Message_MetricType_HeaderFile
+
+//! Specifies kind of report information to collect
+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_MemPrivate,        //!< OSD_MemInfo::MemPrivate
+  Message_MetricType_MemVirtual,        //!< OSD_MemInfo::MemVirtual
+  Message_MetricType_MemWorkingSet,     //!< OSD_MemInfo::MemWorkingSet
+  Message_MetricType_MemWorkingSetPeak, //!< OSD_MemInfo::MemWorkingSetPeak
+  Message_MetricType_MemSwapUsage,      //!< OSD_MemInfo::MemSwapUsage
+  Message_MetricType_MemSwapUsagePeak,  //!< OSD_MemInfo::MemSwapUsagePeak
+  Message_MetricType_MemHeapUsage       //!< OSD_MemInfo::MemHeapUsage
+};
+
+#endif // _Message_MetricType_HeaderFile
diff --git a/src/Message/Message_PerfMeter.cxx b/src/Message/Message_PerfMeter.cxx
deleted file mode 100644 (file)
index d602574..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-// Created on: 2018-06-10
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <Message_PerfMeter.hxx>
-
-#include <Message_AlertExtended.hxx>
-#include <Message_CompositeAlerts.hxx>
-
-#include <OSD_Chronometer.hxx>
-#include <OSD_MemInfo.hxx>
-
-//=======================================================================
-//function : Destructor
-//purpose  :
-//=======================================================================
-
-Message_PerfMeter::~Message_PerfMeter()
-{
-  releaseAlert (0);
-}
-
-//=======================================================================
-//function : GetAlert
-//purpose  :
-//=======================================================================
-
-Handle(Message_AlertExtended) Message_PerfMeter::GetAlert (const Standard_Integer theLevelId) const
-{
-  if (!myActiveAlerts.IsBound (theLevelId))
-    return Handle(Message_AlertExtended)();
-
-  return myActiveAlerts.Find (theLevelId).myAlert;
-}
-
-//=======================================================================
-//function : AddAlert
-//purpose  :
-//=======================================================================
-
-void Message_PerfMeter::AddAlert (const Handle(Message_Alert)& theAlert,
-                                  const Message_PerfMeterMode theMode)
-{
-  Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anExtendedAlert.IsNull())
-    return;
-
-  if (myActiveAlerts.IsEmpty())
-  {
-    setAlert (0, theAlert, theMode);
-    return;
-  }
-
-  Standard_Integer aSize = myActiveAlerts.Size();
-  // looking for the parent of the parameter alert to release the previous alert
-  for (Standard_Integer aLevelId = 0; aLevelId < aSize; aLevelId++)
-  {
-    Handle(Message_AlertExtended) anAlert = GetAlert (aLevelId);
-    Handle(Message_CompositeAlerts) aCompositeAlert = anAlert->GetCompositeAlerts();
-    Standard_ASSERT_RETURN (! aCompositeAlert.IsNull(), "Any alert of the performance meter has composite and children",);
-    if (!aCompositeAlert->HasAlert (theAlert))
-      continue;
-    // parent alert is found
-    if (myActiveAlerts.IsBound (aLevelId + 1))
-      releaseAlert (aLevelId + 1);
-
-    setAlert (aLevelId + 1, theAlert, theMode);
-    return;
-  }
-  Standard_Boolean isDone = Standard_True;
-  Standard_ASSERT_RETURN (!isDone, "Alert should be processed above",);
-}
-
-//=======================================================================
-//function : setAlert
-//purpose  :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::setAlert (const Standard_Integer theLevelId,
-                                              const Handle(Message_Alert)& theAlert,
-                                              const Message_PerfMeterMode theMode)
-{
-  if (!GetAlert (theLevelId).IsNull())
-    return Standard_False;
-
-  Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anAlertExtended.IsNull())
-    return Standard_False;
-
-  myActiveAlerts.Bind (theLevelId, AlertInfo (anAlertExtended, getCurrentInfo (theMode)));
-  anAlertExtended->SetPerfMeter (this);
-  myMode = theMode;
-  return Standard_True;
-}
-
-//=======================================================================
-//function : releaseAlert
-//purpose  :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::releaseAlert (const Standard_Integer theLevelId)
-{
-  // release alerts from the tail till the given alert
-  for (Standard_Integer aLevelId = myActiveAlerts.Extent() - 1; aLevelId >= theLevelId; aLevelId--)
-  {
-    if (!myActiveAlerts.IsBound (aLevelId))
-      continue;
-    stopAlert (aLevelId);
-  }
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function : stopAlert
-//purpose  :
-//=======================================================================
-
-Standard_Boolean Message_PerfMeter::stopAlert (const Standard_Integer theLevelId)
-{
-  if (!myActiveAlerts.IsBound (theLevelId))
-    return Standard_False;
-
-  AlertInfo anAlertInfo = myActiveAlerts.Find (theLevelId);
-  Handle(Message_AlertExtended) anExtendedAlert = anAlertInfo.myAlert;
-
-  anExtendedAlert->SetMetricValues (anAlertInfo.myStartValue, getCurrentInfo(myMode));
-  anExtendedAlert->SetPerfMeter (0);
-  myActiveAlerts.UnBind (theLevelId);
-
-  return Standard_True;
-}
-
-//=======================================================================
-//function : getLevel
-//purpose  :
-//=======================================================================
-
-Standard_Integer Message_PerfMeter::getLevel (const Handle(Message_Alert)& theAlert)
-{
-  for (NCollection_DataMap<Standard_Integer, AlertInfo>::Iterator anIterator (myActiveAlerts);
-    anIterator.More(); anIterator.Next())
-  {
-    if (anIterator.Value().myAlert == theAlert)
-      return anIterator.Key();
-  }
-  return -1;
-}
-
-//=======================================================================
-//function : getCurrentInfo
-//purpose  :
-//=======================================================================
-
-Standard_Real Message_PerfMeter::getCurrentInfo (const Message_PerfMeterMode theMode)
-{
-  if (theMode == Message_PerfMeterMode_UserTimeCPU ||
-      theMode == Message_PerfMeterMode_SystemTimeInfo)
-  {
-    Standard_Real aUserSeconds, aSystemSeconds;
-    OSD_Chronometer::GetThreadCPU (aUserSeconds, aSystemSeconds);
-    return theMode == Message_PerfMeterMode_UserTimeCPU ? aUserSeconds : aSystemSeconds;
-  }
-
-  OSD_MemInfo::Counter aType;
-  switch (theMode)
-  {
-    case Message_PerfMeterMode_MemPrivate:        aType = OSD_MemInfo::MemPrivate; break;
-    case Message_PerfMeterMode_MemVirtual:        aType = OSD_MemInfo::MemVirtual; break;
-    case Message_PerfMeterMode_MemWorkingSet:     aType = OSD_MemInfo::MemWorkingSet; break;
-    case Message_PerfMeterMode_MemWorkingSetPeak: aType = OSD_MemInfo::MemWorkingSetPeak; break;
-    case Message_PerfMeterMode_MemSwapUsage:      aType = OSD_MemInfo::MemSwapUsage; break;
-    case Message_PerfMeterMode_MemSwapUsagePeak:  aType = OSD_MemInfo::MemSwapUsagePeak; break;
-    case Message_PerfMeterMode_MemHeapUsage:      aType = OSD_MemInfo::MemHeapUsage; break;
-    default: return Message_AlertExtended::GetUndefinedMetric(); break;
-  }
-
-  OSD_MemInfo aMemInfo (Standard_False);
-  aMemInfo.Update (aType);
-  return (Standard_Real)aMemInfo.ValuePreciseMiB (aType);
-}
diff --git a/src/Message/Message_PerfMeter.hxx b/src/Message/Message_PerfMeter.hxx
deleted file mode 100644 (file)
index d9f85bd..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-// Created on: 2018-06-10
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Message_PerfMeter_HeaderFile
-#define _Message_PerfMeter_HeaderFile
-
-#include <Message_AlertExtended.hxx>
-#include <Message_Gravity.hxx>
-#include <Message_PerfMeterMode.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <Standard.hxx>
-
-//! This class is performance meter for message alerts. The usage is create the simple instance of it (not a pointer)
-//! in a method. Finalizing of the method will call destructor of the meter and store time into alert.
-class Message_PerfMeter
-{
-
-public:
-  //! Constructs and starts (if autoStart is true) the named meter
-  //! One string key is used for all alert meters. The perf meter is not started automatically, it will be done in
-  //! AddAlert method
-  Message_PerfMeter() : myGravity (Message_Info), myMode (Message_PerfMeterMode_None) {}
-
-  //! Assures stopping upon destruction
-  Standard_EXPORT ~Message_PerfMeter();
-
-  //! Returns message alert on the level, by default the upper alert is returned
-  //! \param theLevelId a level of child position inside the upper alert of performance meter
-  //! \return alert instance or NULL
-  Handle(Message_AlertExtended) GetAlert (const Standard_Integer theLevelId = 0) const;
-
-  //! Processes the parameter alert. There are some variants:
-  //! - current alert is NULL, the alert becomes the current one and perf meter is started
-  //! - last alert of the current alert is stopped (perf meter becomes NULL, time is calculated),
-  //! the parameter alert is started (perf meter becomes the current one)
-  Standard_EXPORT void AddAlert (const Handle(Message_Alert)& theAlert,
-                                 const Message_PerfMeterMode theMode);
-
-protected:
-
-  //! Sets message alert on the level
-  //! \param theLevelId a level of child position inside the upper alert of performance meter
-  //! \param theAlert an alert to be stored
-  //! \return true if succeeded, false if there is stored alert on the given level
-  Standard_Boolean setAlert (const Standard_Integer theLevelId,
-                             const Handle(Message_Alert)& theAlert,
-                             const Message_PerfMeterMode theMode);
-
-  //! Stop alert, store time into the alert and last child alert
-  //! \param theLevelId a level of child position inside the upper alert of performance meter
-  Standard_Boolean releaseAlert (const Standard_Integer theLevelId);
-
-  //! Sets NULL perf meter and parameter time into the alert
-  //! \param theLevelId a level of child position inside the upper alert of performance meter
-  Standard_Boolean stopAlert (const Standard_Integer theLevelId);
-
-  //! Returns level of given alert if it participates in the performance meter
-  //! \param theAlert modified alert
-  //! \return level value or -1
-  Standard_Integer getLevel (const Handle(Message_Alert)& theAlert);
-
-  //! Returns cumulative info of the performance meter
-  //! \param theMeterId a performance meter index
-  //! \return time value
-  static Standard_Real getCurrentInfo (const Message_PerfMeterMode theMode);
-
-protected:
-  //! Struct to store start time for the alert
-  struct AlertInfo
-  {
-    AlertInfo (const Handle(Message_AlertExtended)& theAlert, Standard_Real theStartValue)
-      : myAlert (theAlert), myStartValue (theStartValue) {}
-
-    Handle(Message_AlertExtended) myAlert; //!< an alert
-    Standard_Real myStartValue; //!< start alert information
-  };
-
-  NCollection_DataMap<Standard_Integer, AlertInfo> myActiveAlerts; //!< container of current alerts
-  Message_Gravity myGravity; //!< perf meter alert gravity
-  Message_PerfMeterMode myMode; //!< mode to define which information to collect
-};
-
-
-#endif // _Message_PerfMeter_HeaderFile
diff --git a/src/Message/Message_PerfMeterMode.hxx b/src/Message/Message_PerfMeterMode.hxx
deleted file mode 100644 (file)
index d03d5d4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// Created on: 2019-08-13
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2019 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Message_PerfMeterMode_HeaderFile
-#define _Message_PerfMeterMode_HeaderFile
-
-//! Specifies kind of report information to collect
-enum Message_PerfMeterMode
-{
-  Message_PerfMeterMode_None,           //!< no computation
-  Message_PerfMeterMode_UserTimeCPU,    //!< the current CPU user time in seconds
-  Message_PerfMeterMode_SystemTimeInfo, //!< the current CPU system time in seconds
-  Message_PerfMeterMode_MemPrivate,     //!< OSD_MemInfo::MemPrivate
-  Message_PerfMeterMode_MemVirtual,     //!< OSD_MemInfo::MemVirtual
-  Message_PerfMeterMode_MemWorkingSet,   //!< OSD_MemInfo::MemWorkingSet
-  Message_PerfMeterMode_MemWorkingSetPeak, //!< OSD_MemInfo::MemWorkingSetPeak
-  Message_PerfMeterMode_MemSwapUsage,     //!< OSD_MemInfo::MemSwapUsage
-  Message_PerfMeterMode_MemSwapUsagePeak, //!< OSD_MemInfo::MemSwapUsagePeak
-  Message_PerfMeterMode_MemHeapUsage      //!< OSD_MemInfo::MemHeapUsage
-};
-
-#endif // _Message_PerfMeterKind_HeaderFile
index 8ed2b87e6a5a52d142bfa885557c8b9e90e4a259..cc1c09878d8beb2b94f0270446f4daad9be5de0a 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <Message_Printer.hxx>
 
+#include <Standard_Dump.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 
@@ -58,3 +59,37 @@ void Message_Printer::Send (const TCollection_AsciiString& theString,
     Send (TCollection_ExtendedString (theString), theGravity, theToOutEol);
   }
 }
+
+//=======================================================================
+//function : Send
+//purpose  :
+//=======================================================================
+
+void Message_Printer::Send (const Standard_SStream& theStream,
+                            const Message_Gravity   theGravity,
+                            const Standard_Boolean  theToOutEol) const
+{
+  if (theGravity >= myTraceLevel)
+  {
+    Send (TCollection_ExtendedString (theStream.str().c_str()), theGravity, theToOutEol);
+  }
+}
+
+//=======================================================================
+//function : Send
+//purpose  :
+//=======================================================================
+void Message_Printer::Send (const Handle(Standard_Transient)& theObject,
+                            const Message_Gravity          theGravity,
+                            const Standard_Boolean         theToOutEol) const
+{
+  if (theObject.IsNull())
+    return;
+
+  if (theGravity >= myTraceLevel)
+  {
+    TCollection_ExtendedString aString = TCollection_ExtendedString (theObject->DynamicType()->Name())
+      + ": " + Standard_Dump::GetPointerInfo (theObject);
+    Send (aString, theGravity, theToOutEol);
+  }
+}
index e7e70ddfbd8694b548ab749a00cc2570236cc3cb..ae877c7081efcf803b460640225c2e8ac6321626 100644 (file)
@@ -23,6 +23,8 @@
 #include <Standard_Transient.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_CString.hxx>
+#include <Standard_SStream.hxx>
+
 class TCollection_ExtendedString;
 class TCollection_AsciiString;
 
@@ -62,6 +64,18 @@ public:
   //! Default implementation calls first method Send().
   Standard_EXPORT virtual void Send (const TCollection_AsciiString& theString, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) const;
 
+  //! Send a string message with specified trace level.
+  //! Stream is converted to string value.
+  //! 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 Standard_SStream& theStream, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) 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_Boolean theToPutEol) const;
+
 protected:
 
   //! Empty constructor with Message_Info trace level
diff --git a/src/Message/Message_PrinterToReport.cxx b/src/Message/Message_PrinterToReport.cxx
new file mode 100644 (file)
index 0000000..99ce957
--- /dev/null
@@ -0,0 +1,137 @@
+// Created on: 2001-01-06
+// Created by: OCC Team
+// Copyright (c) 2001-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Message_PrinterToReport.hxx>
+
+#include <Message.hxx>
+#include <Message_AlertExtended.hxx>
+#include <Message_Attribute.hxx>
+#include <Message_AttributeMeter.hxx>
+#include <Message_AttributeObject.hxx>
+#include <Message_AttributeStream.hxx>
+#include <Message_Report.hxx>
+
+#include <Standard_Dump.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
+
+//=======================================================================
+//function : Report
+//purpose  : 
+//=======================================================================
+
+const Handle(Message_Report)& Message_PrinterToReport::Report() const
+{
+  if (!myReport.IsNull())
+    return myReport;
+
+  return Message::DefaultReport (Standard_True);
+}
+
+//=======================================================================
+//function : Clear
+//purpose  :
+//=======================================================================
+void Message_PrinterToReport::Clear()
+{
+  myKey.Clear();
+}
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_PrinterToReport::Send (const TCollection_ExtendedString& theString,
+                                    const Message_Gravity theGravity,
+                                    const Standard_Boolean putEndl) const
+{
+  TCollection_AsciiString aString (theString/*, myUseUtf8 ? Standard_Character(0) : '?'*/);
+
+  Message_PrinterToReport* aThis = (Message_PrinterToReport*)this; // TODO!
+  if (putEndl)
+  {
+    if (myKey.IsEmpty())
+      return;
+
+    const Handle(Message_Report)& aReport = Report();
+    if (!aReport->ActiveMetrics().IsEmpty())
+    {
+      sendMetricAlert (aString, theGravity);
+      return;
+    }
+    Message_AlertExtended::AddAlert (aReport, new Message_Attribute (myKey), theGravity);
+    aThis->Clear();
+    return;
+  }
+  aThis->myKey += aString;
+}
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_PrinterToReport::Send (const Standard_SStream& theStream,
+                                    const Message_Gravity theGravity,
+                                    const Standard_Boolean /*putEndl*/) const
+{
+  const Handle(Message_Report)& aReport = Report();
+  if (!aReport->ActiveMetrics().IsEmpty())
+  {
+    sendMetricAlert (myKey, theGravity);
+    return;
+  }
+  Message_AlertExtended::AddAlert (aReport, new Message_AttributeStream (theStream, myKey), theGravity);
+  Message_PrinterToReport* aThis = (Message_PrinterToReport*)this; // TODO!
+  aThis->Clear();
+
+  return;
+}
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+
+void Message_PrinterToReport::Send (const Handle(Standard_Transient)& theObject,
+                                    const Message_Gravity theGravity,
+                                    const Standard_Boolean /*putEndl*/) const
+{
+  const Handle(Message_Report)& aReport = Report();
+  if (!aReport->ActiveMetrics().IsEmpty())
+  {
+    sendMetricAlert (myKey, theGravity);
+    return;
+  }
+
+  Message_AlertExtended::AddAlert (aReport, new Message_AttributeObject (theObject, myKey), theGravity);
+  Message_PrinterToReport* aThis = (Message_PrinterToReport*)this; // TODO!
+  aThis->Clear();
+}
+
+//=======================================================================
+//function : sendMetricAlert
+//purpose  : 
+//=======================================================================
+
+void Message_PrinterToReport::sendMetricAlert (const TCollection_AsciiString theValue,
+                                               const Message_Gravity theGravity) const
+{
+  Message_AlertExtended::AddAlert (Report(), new Message_AttributeMeter (myKey), theGravity);
+  Message_PrinterToReport* aThis = (Message_PrinterToReport*)this; // TODO!
+  aThis->Clear();
+}
diff --git a/src/Message/Message_PrinterToReport.hxx b/src/Message/Message_PrinterToReport.hxx
new file mode 100644 (file)
index 0000000..37d61ca
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Message_PrinterToReport_HeaderFile
+#define _Message_PrinterToReport_HeaderFile
+
+#include <Message_Printer.hxx>
+#include <Standard_Address.hxx>
+#include <Standard_OStream.hxx>
+#include <TCollection_AsciiString.hxx>
+
+class Message_Report;
+
+class Message_PrinterToReport;
+DEFINE_STANDARD_HANDLE(Message_PrinterToReport, Message_Printer)
+
+//! Implementation of a message printer associated with Message_Report
+//! Send will create a new alert of the report.
+//! The alerts are sent into set report or default report of Message.
+class Message_PrinterToReport : public Message_Printer
+{
+  DEFINE_STANDARD_RTTIEXT(Message_PrinterToReport, Message_Printer)
+
+public:
+  //! Create printer for redirecting messages into report.
+  Standard_EXPORT Message_PrinterToReport () {}
+
+  ~Message_PrinterToReport() {}
+
+  //! Returns the current or default report
+  Standard_EXPORT const Handle(Message_Report)& Report() const;
+
+  //!< Returns the first sent value
+  TCollection_AsciiString Key() const { return myKey; }
+
+  //! Clears current values
+  Standard_EXPORT void Clear();
+
+  //! Sets the printer report
+  //! @param theReport report for messages processing, if NULL, the default report is used
+  void SetReport (const Handle(Message_Report)& theReport);
+
+  //! Appends a new alert into message report
+  Standard_EXPORT virtual void Send (const TCollection_ExtendedString& theString,
+                                     const Message_Gravity theGravity,
+                                     const Standard_Boolean putEndl = Standard_True) const Standard_OVERRIDE;
+
+  //! Send a string message with specified trace level.
+  //! Stream is converted to string value.
+  //! 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 Standard_SStream& theStream,
+                                     const Message_Gravity theGravity,
+                                     const Standard_Boolean theToPutEol) const Standard_OVERRIDE;
+
+  //! 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_Boolean theToPutEol) const Standard_OVERRIDE;
+protected:
+
+  //! Send an alert with metrics active in the current report
+  Standard_EXPORT void sendMetricAlert (const TCollection_AsciiString theValue,
+                                        const Message_Gravity theGravity) const;
+
+private:
+  Handle(Message_Report) myReport; //!< the report for sending alerts
+  TCollection_AsciiString myKey; //!< the sent string value
+};
+
+#endif // _Message_PrinterToReport_HeaderFile
index fc57f328e32a8a57a93ee1beb539afd43ec062f0..f225f004e01cbfc1dc86b6af7665d2da4dab9b70 100644 (file)
 
 #include <Message_Report.hxx>
 
+#include <Message.hxx>
 #include <Message_AlertExtended.hxx>
 #include <Message_CompositeAlerts.hxx>
 #include <Message_Msg.hxx>
 #include <Message_Messenger.hxx>
-#include <Message_PerfMeter.hxx>
-#include <Message_ReportCallBack.hxx>
+#include <Message_PrinterToReport.hxx>
 
 #include <NCollection_Map.hxx>
 #include <Precision.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
 
-static Handle(Message_Report) MyReport;
-
 //=======================================================================
 //function : Message_Report
 //purpose  :
 //=======================================================================
 
 Message_Report::Message_Report ()
-: myPerfMeterMode (Message_PerfMeterMode_None), myLimit (-1)
+: myLimit (-1)
 {
-  SetActive (Standard_True);
 }
 
 //=======================================================================
-//function : CurrentReport
+//function : IsActiveInMessenger
 //purpose  :
 //=======================================================================
-Handle(Message_Report) Message_Report::CurrentReport(const Standard_Boolean theToCreate)
+Standard_Boolean Message_Report::IsActiveInMessenger() const
 {
-  if (MyReport.IsNull() && theToCreate)
-    MyReport = new Message_Report();
-
-  return MyReport;
+  const Handle(Message_Messenger)& aMessenger = Message::DefaultMessenger();
+  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;
 }
 
 //=======================================================================
-//function : AddAlert
+//function : AddLevel
 //purpose  :
 //=======================================================================
-
-void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert)
+void Message_Report::AddLevel (Message_Level* theLevel)
 {
-  if (!IsActive (theGravity))
-    return;
-
-  Standard_ASSERT_RETURN (! theAlert.IsNull(), "Attempt to add null alert",);
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Adding alert with gravity not in valid range",);
-
-  Standard_Mutex::Sentry aSentry (myMutex);
+  myAlertLevels.Append (theLevel);
+}
 
-  // iterate by already recorded alerts and try to merge new one with one of those
-  Message_ListOfAlert &aList = myAlerts[theGravity];
-  if (theAlert->SupportsMerge() && ! aList.IsEmpty())
+//=======================================================================
+//function : RemoveLevel
+//purpose  :
+//=======================================================================
+void Message_Report::RemoveLevel (Message_Level* theLevel)
+{
+  for (int aLevelIndex = myAlertLevels.Size(); aLevelIndex >= 1; aLevelIndex--)
   {
-    // merge is performed only for alerts of exactly same type
-    const Handle(Standard_Type)& aType = theAlert->DynamicType();
-    for (Message_ListOfAlert::Iterator anIt(aList); anIt.More(); anIt.Next())
-    {
-      // if merged successfully, just return
-      if (aType == anIt.Value()->DynamicType() && theAlert->Merge (anIt.Value()))
-        return;
-    }
-  }
+    Message_Level* aLevel = myAlertLevels.Value (aLevelIndex);
+    myAlertLevels.Remove (aLevelIndex);
 
-  // if not merged, just add to the list
-  aList.Append (theAlert);
-
-  if (!myCallBack.IsNull())
-    myCallBack->Update (theAlert);
+    if (aLevel == theLevel)
+      return;
+  }
 }
 
 //=======================================================================
@@ -95,216 +84,84 @@ void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_
 //purpose  :
 //=======================================================================
 
-void Message_Report::AddAlert (const Message_Gravity theGravity, const Handle(Message_Alert)& theAlert,
-                               Message_PerfMeter* thePerfMeter, const Handle(Message_Alert)& theParentAlert)
+void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert)
 {
-  if (!IsActive (theGravity))
-    return;
-
-  Standard_ASSERT_RETURN (!theAlert.IsNull(), "Attempt to add null alert",);
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Adding alert with gravity not in valid range",);
-
   Standard_Mutex::Sentry aSentry (myMutex);
 
-  // iterate by already recorded alerts and try to merge new one with one of those
-  Handle(Message_Alert) aParentAlert = theParentAlert;
-  if (aParentAlert.IsNull() && thePerfMeter)
-    aParentAlert = thePerfMeter->GetAlert();
-  if (aParentAlert.IsNull())
-    aParentAlert = getLastAlertInPerfMeter(theGravity);
-
-  Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(aParentAlert);
-  Handle(Message_CompositeAlerts) aCompositeAlert = !anExtendedAlert.IsNull() ? anExtendedAlert->GetCompositeAlerts (Standard_True)
-    : Handle(Message_CompositeAlerts)();
-  Message_ListOfAlert& aList = !aCompositeAlert.IsNull() ? aCompositeAlert->GetAlerts (theGravity) : myAlerts[theGravity];
-
-  if (theAlert->SupportsMerge() && !aList.IsEmpty())
+   // alerts of the top level
+  if (myAlertLevels.IsEmpty())
   {
-    // merge is performed only for alerts of exactly same type and same name
-    const Handle(Standard_Type)& aType = theAlert->DynamicType();
-    for (Message_ListOfAlert::Iterator anIt(aList); anIt.More(); anIt.Next())
+    Handle (Message_CompositeAlerts) aCompositeAlert = compositeAlerts (Standard_True);
+    if (aCompositeAlert->AddAlert (theGravity, theAlert))
+      return;
+
+    // remove alerts under the report only
+    const Message_ListOfAlert& anAlerts = aCompositeAlert->GetAlerts (theGravity);
+    if (anAlerts.Extent() > myLimit)
     {
-      // if merged successfully, just return
-      if (aType == anIt.Value()->DynamicType() && theAlert->Merge (anIt.Value()))
-        return;
+      aCompositeAlert->RemoveAlert (theGravity, anAlerts.First());
     }
+    return;
   }
 
-  // if not merged, just add to the list
-  aList.Append (theAlert);
-  // remove alerts under the report only
-  if (theParentAlert.IsNull() && aParentAlert.IsNull() && myLimit > 0 && aList.Extent() > myLimit)
-    aList.RemoveFirst();
-
-  if (thePerfMeter)
-    thePerfMeter->AddAlert (theAlert, PerfMeterMode());
-
-  if (!myCallBack.IsNull())
-    myCallBack->Update(theAlert);
-}
-
-//=======================================================================
-//function : GetAlerts
-//purpose  :
-//=======================================================================
+  // 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 (!aLevel)
+    return;
 
-const Message_ListOfAlert& Message_Report::GetAlerts (Message_Gravity theGravity) const
-{
-  static const Message_ListOfAlert anEmptyList;
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Requesting alerts for gravity not in valid range", anEmptyList);
-  return myAlerts[theGravity];
-}
+  // alert is placed below the level
+  if (!aLevel->RootAlert().IsNull())
+  {
+    aLevel->AddAlert (theGravity, theAlert);
+    return;
+  }
 
-//=======================================================================
-//function : CumulativeMetric
-//purpose  :
-//=======================================================================
+  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);
 
-Standard_Real Message_Report::CumulativeMetric (const Message_Gravity theGravity) const
-{
-  switch (myPerfMeterMode)
+  if (myAlertLevels.Size() == 1)
+    compositeAlerts (Standard_True)->AddAlert (theGravity, theAlert);
+  else
   {
-    case Message_PerfMeterMode_None: return 0.0;
-    case Message_PerfMeterMode_UserTimeCPU:
-    case Message_PerfMeterMode_SystemTimeInfo:
-    {
-      Standard_Real aStartTime = Message_AlertExtended::GetUndefinedMetric();
-      Standard_Boolean isFound = Standard_False;
-      for (Message_ListOfAlert::Iterator anAlertsIt (GetAlerts (theGravity)); anAlertsIt.More(); anAlertsIt.Next())
-      {
-        Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlertsIt.Value());
-        if (anExtendedAlert.IsNull() && anExtendedAlert->IsMetricValid())
-        {
-          aStartTime = anExtendedAlert->MetricStart();
-          isFound = Standard_True;
-          break;
-        }
-      }
-      if (!isFound)
-        return 0.0;
-
-      Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(getLastAlert (theGravity));
-      if (anExtendedAlert.IsNull() || !anExtendedAlert->IsMetricValid())
-        return 0.0;
-
-      return anExtendedAlert->MetricStop() - aStartTime;
-    }
-    case Message_PerfMeterMode_MemPrivate:
-    case Message_PerfMeterMode_MemVirtual:
-    case Message_PerfMeterMode_MemWorkingSet:
-    {
-      Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(getLastAlert (theGravity));
-      if (!anExtendedAlert.IsNull())
-        return anExtendedAlert->MetricStop();
-    }
+    Message_Level* aPrevLevel = myAlertLevels.Value (myAlertLevels.Size() - 1); // previous level
+    aPrevLevel->AddLevelAlert (theGravity, theAlert);
   }
-  return 0.0;
 }
 
 //=======================================================================
-//function : getLastAlert
+//function : GetAlerts
 //purpose  :
 //=======================================================================
 
-Handle(Message_Alert) Message_Report::getLastAlert (const Message_Gravity theGravity) const
+const Message_ListOfAlert& Message_Report::GetAlerts (Message_Gravity theGravity) const
 {
-  if (!IsActive (theGravity))
-    return Handle(Message_Alert)();
-
-  const Message_ListOfAlert& anAlerts = GetAlerts (theGravity);
-  if (anAlerts.IsEmpty())
-    return Handle(Message_Alert)();
-
-  Handle(Message_Alert) aLastAlert = anAlerts.Last();
-
-  Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
-  if (anExtendedAlert.IsNull())
-    return aLastAlert;
-  Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->GetCompositeAlerts (Standard_True);
-  if (aCompositeAlert.IsNull())
-    return aLastAlert;
-
-  while (!aCompositeAlert.IsNull() && !aCompositeAlert->GetAlerts (theGravity).IsEmpty())
-  {
-    Handle(Message_Alert) anAlert = aCompositeAlert->GetAlerts (theGravity).Last();
-
-    Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
-    if (anExtendedAlert.IsNull())
-    {
-      aLastAlert = anAlert;
-      break;
-    }
-
-    aLastAlert = anExtendedAlert;
-    aCompositeAlert = anExtendedAlert->GetCompositeAlerts();
-  }
-
-  // if alert has perf meter, use as the last alert, an alert of the perf meter
-  anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
-  if (anExtendedAlert.IsNull())
-    return aLastAlert;
+  static const Message_ListOfAlert anEmptyList;
+  if (myCompositAlerts.IsNull())
+    return anEmptyList;
 
-  return aLastAlert;
+  return myCompositAlerts->GetAlerts (theGravity);
 }
 
 //=======================================================================
-//function : getLastAlertInPerfMeter
+//function : SetActiveMetric
 //purpose  :
 //=======================================================================
 
-Handle(Message_Alert) Message_Report::getLastAlertInPerfMeter (const Message_Gravity theGravity) const
+void Message_Report::SetActiveMetric (const Message_MetricType theMetricType,
+                                      const Standard_Boolean theActivate)
 {
-  if (!IsActive (theGravity))
-    return Handle(Message_Alert)();
-
-  const Message_ListOfAlert& anAlerts = GetAlerts (theGravity);
-  if (anAlerts.IsEmpty())
-    return Handle(Message_Alert)();
-
-  Handle(Message_Alert) aLastAlert = anAlerts.Last();
-
-  Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
-  if (anExtendedAlert.IsNull())
-    return aLastAlert;
-  Handle(Message_CompositeAlerts) aCompositeAlert = anExtendedAlert->GetCompositeAlerts (Standard_True);
-  if (aCompositeAlert.IsNull())
-    return aLastAlert;
-
-  Standard_Boolean aHasPerfMeter = anExtendedAlert->GetPerfMeter() != NULL;
-  if (!aHasPerfMeter) // the alert has finished and is not the last alert anymore
-    return Handle(Message_Alert)();
-
-  while (!aCompositeAlert.IsNull() && !aCompositeAlert->GetAlerts (theGravity).IsEmpty())
-  {
-    Handle(Message_Alert) anAlert = aCompositeAlert->GetAlerts (theGravity).Last();
-
-    Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
-    if (anExtendedAlert.IsNull())
-    {
-      if (!aHasPerfMeter) // if there is a perf meter, use alert of it
-        aLastAlert = anAlert;
-      break;
-    }
-
-    if (!aHasPerfMeter)
-      aHasPerfMeter = anExtendedAlert->GetPerfMeter() != NULL;
-    else if (!anExtendedAlert->GetPerfMeter())
-      break; // last alert is the previous alert where perf meter is not NULL
-
-    aLastAlert = anExtendedAlert;
-    aCompositeAlert = anExtendedAlert->GetCompositeAlerts();
-  }
-
-  // if alert has perf meter, use as the last alert, an alert of the perf meter
-  anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert);
-  if (anExtendedAlert.IsNull())
-    return aLastAlert;
-  //if (anExtendedAlert->GetPerfMeter())
-  //  aLastAlert = anExtendedAlert->GetPerfMeter()->GetAlert();
+  if (theActivate == myActiveMetrics.Contains (theMetricType))
+    return;
 
-  return aLastAlert;
+  if (theActivate)
+    myActiveMetrics.Add (theMetricType);
+  else
+    myActiveMetrics.Remove (theMetricType);
 }
 
 //=======================================================================
@@ -329,14 +186,17 @@ Standard_Boolean Message_Report::HasAlert (const Handle(Standard_Type)& theType)
 
 Standard_Boolean Message_Report::HasAlert (const Handle(Standard_Type)& theType, Message_Gravity theGravity)
 {
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Requesting alerts for gravity not in valid range", Standard_False);
-  for (Message_ListOfAlert::Iterator anIt (myAlerts[theGravity]); anIt.More(); anIt.Next())
-  {
-    if (anIt.Value()->IsInstance(theType))
-      return Standard_True;
-  }
-  return Standard_False;
+  //Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+  //                        "Requesting alerts for gravity not in valid range", Standard_False);
+  //for (Message_ListOfAlert::Iterator anIt (myAlerts[theGravity]); anIt.More(); anIt.Next())
+  //{
+  //  if (anIt.Value()->IsInstance(theType))
+  //    return Standard_True;
+  //}
+  if (compositeAlerts().IsNull())
+    return Standard_False;
+
+  return compositeAlerts()->HasAlert (theType, theGravity);
 }
 
 //=======================================================================
@@ -344,12 +204,13 @@ Standard_Boolean Message_Report::HasAlert (const Handle(Standard_Type)& theType,
 //purpose  :
 //=======================================================================
 
-void Message_Report::Clear ()
+void Message_Report::Clear()
 {
-  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
-  {
-    myAlerts[i].Clear();
-  }
+  if (compositeAlerts().IsNull())
+    return;
+
+  compositeAlerts()->Clear();
+  myAlertLevels.Clear();
 }
 
 //=======================================================================
@@ -359,9 +220,11 @@ void Message_Report::Clear ()
 
 void Message_Report::Clear (Message_Gravity theGravity)
 {
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Requesting alerts for gravity not in valid range", );
-  myAlerts[theGravity].Clear();
+  if (compositeAlerts().IsNull())
+    return;
+
+  compositeAlerts()->Clear (theGravity);
+  myAlertLevels.Clear();
 }
 
 //=======================================================================
@@ -371,20 +234,26 @@ void Message_Report::Clear (Message_Gravity theGravity)
 
 void Message_Report::Clear (const Handle(Standard_Type)& theType)
 {
-  for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
-  {
-    for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); )
-    {
-      if (anIt.Value().IsNull() || anIt.Value()->IsInstance (theType))
-      {
-        myAlerts[i].Remove (anIt);
-      }
-      else
-      {
-        anIt.More();
-      }
-    }
-  }
+  if (compositeAlerts().IsNull())
+    return;
+
+  compositeAlerts()->Clear (theType);
+  myAlertLevels.Clear();
+
+  //for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
+  //{
+  //  for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); )
+  //  {
+  //    if (anIt.Value().IsNull() || anIt.Value()->IsInstance (theType))
+  //    {
+  //      myAlerts[i].Remove (anIt);
+  //    }
+  //    else
+  //    {
+  //      anIt.More();
+  //    }
+  //  }
+  //}
 }
 
 //=======================================================================
@@ -407,12 +276,13 @@ void Message_Report::Dump (Standard_OStream& theOS)
 
 void Message_Report::Dump (Standard_OStream& theOS, Message_Gravity theGravity)
 {
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Requesting alerts for gravity not in valid range", );
+  if (compositeAlerts().IsNull())
+    return;
+  const Message_ListOfAlert& anAlerts = compositeAlerts()->GetAlerts (theGravity);
 
   // report each type of warning only once
   NCollection_Map<Handle(Standard_Type)> aPassedAlerts;
-  for (Message_ListOfAlert::Iterator anIt (myAlerts[theGravity]); anIt.More(); anIt.Next())
+  for (Message_ListOfAlert::Iterator anIt (anAlerts); anIt.More(); anIt.Next())
   {
     if (aPassedAlerts.Add (anIt.Value()->DynamicType()))
     {
@@ -442,12 +312,15 @@ void Message_Report::SendMessages (const Handle(Message_Messenger)& theMessenger
 
 void Message_Report::SendMessages (const Handle(Message_Messenger)& theMessenger, Message_Gravity theGravity)
 {
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
-                          "Requesting alerts for gravity not in valid range", );
+  if (compositeAlerts().IsNull())
+    return;
+  const Message_ListOfAlert& anAlerts = compositeAlerts()->GetAlerts (theGravity);
+  //Standard_ASSERT_RETURN (theGravity >= 0 && size_t(theGravity) < sizeof(myAlerts)/sizeof(myAlerts[0]), 
+  //                        "Requesting alerts for gravity not in valid range", );
 
   // report each type of warning only once
   NCollection_Map<Handle(Standard_Type)> aPassedAlerts;
-  for (Message_ListOfAlert::Iterator anIt (myAlerts[theGravity]); anIt.More(); anIt.Next())
+  for (Message_ListOfAlert::Iterator anIt (anAlerts); anIt.More(); anIt.Next())
   {
     if (aPassedAlerts.Add (anIt.Value()->DynamicType()))
     {
@@ -484,48 +357,13 @@ void Message_Report::Merge (const Handle(Message_Report)& theOther, Message_Grav
 }
 
 //=======================================================================
-//function : SetActive
-//purpose  :
-//=======================================================================
-
-void Message_Report::SetActive (const Standard_Boolean theActive, const Standard_Integer theGravity)
-{
-  if (theGravity < 0)
-  {
-    for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
-      SetActive (theActive, iGravity);
-    return;
-  }
-
-  Standard_ASSERT_RETURN (theGravity >= 0 && size_t (theGravity) < sizeof (myAlerts) / sizeof (myAlerts[0]), 
-                          "Set active report with gravity not in valid range", );
-  myIsActive[theGravity] = theActive;
-}
-
-//=======================================================================
-//function : DumpJson
+//function : Ã±ompositeAlerts
 //purpose  : 
 //=======================================================================
-void Message_Report::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
+Handle (Message_CompositeAlerts) Message_Report::compositeAlerts (const Standard_Boolean isCreate)
 {
-  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPerfMeterMode);
-  OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLimit);
-}
-
-//=======================================================================
-//function : InitJson
-//purpose  : 
-//=======================================================================
-Standard_Boolean Message_Report::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
-{
-  Standard_Integer aPos = theStreamPos;
-
-  Standard_Real PerfMeterMode;
-  OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, PerfMeterMode);
-  myPerfMeterMode = (Message_PerfMeterMode)((Standard_Integer)PerfMeterMode);
-
-  OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, myLimit);
+  if (myCompositAlerts.IsNull() && isCreate)
+    myCompositAlerts = new Message_CompositeAlerts();
 
-  theStreamPos = aPos;
-  return Standard_True;
+  return myCompositAlerts;
 }
index 9fc0708cf3157b7d2391286c5cf75e7b53428a41..81d20febc57919f305a6c058330b7b7afec01d12 100644 (file)
 #define _Message_Report_HeaderFile
 
 #include <Message_Gravity.hxx>
+#include <Message_Level.hxx>
 #include <Message_ListOfAlert.hxx>
-#include <Message_PerfMeterMode.hxx>
+#include <Message_MetricType.hxx>
+#include <NCollection_Map.hxx>
+#include <NCollection_Sequence.hxx>
 #include <Standard_Mutex.hxx>
 
+class Message_CompositeAlerts;
 class Message_Messenger;
-class Message_PerfMeter;
 class Message_Report;
-class Message_ReportCallBack;
 
 DEFINE_STANDARD_HANDLE(Message_Report, Standard_Transient)
 
@@ -57,24 +59,19 @@ public:
   //! Empty constructor
   Standard_EXPORT Message_Report ();
   
-  //! returns the only one instance of Report
-  //! When theToCreate is true - automatically creates message report when not exist.
-  //! that has been created.
-  Standard_EXPORT static Handle(Message_Report) CurrentReport (const Standard_Boolean theToCreate = Standard_False);
+  //! Returns true if report printer is registered in the messenger
+  Standard_EXPORT Standard_Boolean IsActiveInMessenger() const;
+
+  //! Add new level of alerts
+  Standard_EXPORT void AddLevel (Message_Level* theLevel);
+
+  //! Remove level of alerts
+  Standard_EXPORT void RemoveLevel (Message_Level* theLevel);
 
   //! Add alert with specified gravity.
   //! This method is thread-safe, i.e. alerts can be added from parallel threads safely.
   Standard_EXPORT void AddAlert (Message_Gravity theGravity, const Handle(Message_Alert)& theAlert);
 
-  //! Add alert with specified gravity. The alert is a sub-alert of report or another alert
-  //! The parent alert is the parameter alert or the last alert if found else report.
-  //! \param theGravity a message gravity
-  //! \param theAlert a new alert to be added
-  //! \param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
-  //! \param theParentAlert if not NULL specifies parent alert where the alert should be placed, if the parent is an extednded alert
-  Standard_EXPORT void AddAlert (const Message_Gravity theGravity, const Handle(Message_Alert)& theAlert,
-                                 Message_PerfMeter* thePerfMeter, const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
-
   //! Returns list of collected alerts with specified gravity
   Standard_EXPORT const Message_ListOfAlert& GetAlerts (Message_Gravity theGravity) const;
 
@@ -111,24 +108,15 @@ public:
   //! Merges alerts with specified gravity from theOther report into this
   Standard_EXPORT void Merge (const Handle(Message_Report)& theOther, Message_Gravity theGravity);
 
-  //! Returns a state whether the report is active
-  //! \return the state
-  Standard_Boolean IsActive (const Message_Gravity theGravity) const { return myIsActive[theGravity]; }
+  //! Sets metrics to compute when alerts are performed
+  //! \param theMetrics container of metrics
+  Standard_EXPORT void SetActiveMetric (const Message_MetricType theMetricType, const Standard_Boolean theActivate);
 
-  //! Starts a timer to compute time between messages. If a timer has already been started, it will be stopped
-  //! \param theActive new state of report active
-  //! \param theGravity gravity type, if '-1', apply value for all gravity kinds
-  Standard_EXPORT void SetActive (const Standard_Boolean theActive, const Standard_Integer theGravity = -1);
+  //! Returns computed metrics when alerts are performed
+  const NCollection_Map<Message_MetricType>& ActiveMetrics() const { return myActiveMetrics; }
 
-  //! Sets a perf meter mode
-  //! \param theMode new mode
-  Standard_EXPORT void SetPerfMeterMode (const Message_PerfMeterMode theMode)
-  { myPerfMeterMode = theMode; }
-
-  //! Returns mode of perf meter
-  //! \return the state
-  Standard_EXPORT Message_PerfMeterMode PerfMeterMode() const
-  { return myPerfMeterMode; }
+  //! Removes all activated metrics
+  void ClearMetrics() { myActiveMetrics.Clear(); }
 
   //! Returns maximum number of collecting alerts. If the limit is achieved,
   //! adding of a new alert after removing the first cached alert.
@@ -139,48 +127,29 @@ public:
   //! \return theLimit limit value
   Standard_EXPORT void SetLimit(const Standard_Integer theLimit) { myLimit = theLimit; }
 
-  //! Returns the report cumulative metric. It includes time/mem of sub alerts depending on PerfMeter mode
-  //! @return value
-  Standard_EXPORT Standard_Real CumulativeMetric (const Message_Gravity theGravity) const;
-
-  //! Sets a listener for the report events
-  void SetCallBack(const Handle(Message_ReportCallBack)& theCallBack) { myCallBack = theCallBack; }
-
-  //! Returns listener of the reports events
-  const Handle(Message_ReportCallBack)& GetCallBack() const { return myCallBack; }
-
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
 
-  //! Inits the content of me into the stream
-  Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
-
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
 
 protected:
-  //! Returns last alert in list of report alerts or last alert in hierarchical tree of alerts provided by
-  //! the last alert
-  //! \parm theGravity a message gravity
-  Standard_EXPORT Handle(Message_Alert) getLastAlert (const Message_Gravity theGravity) const;
-
-  //! Returns last alert in list of report alerts or last alert in hierarchical tree of alerts provided by
-  //! the last alert
-  //! \parm theGravity a message gravity
-  Standard_EXPORT Handle(Message_Alert) getLastAlertInPerfMeter (const Message_Gravity theGravity) const;
+  //! Returns class provided hierarchy of alerts if created or create if the parameter is true
+  //! \param isCreate if composite alert has not been created for this alert, it should be created
+  //! \return instance or NULL
+  Standard_EXPORT Handle (Message_CompositeAlerts) compositeAlerts (const Standard_Boolean isCreate = Standard_False);
 
 protected:
   Standard_Mutex myMutex;
 
   // store messages in a lists sorted by gravity;
   // here we rely on knowledge that Message_Fail is the last element of the enum
-  Message_ListOfAlert myAlerts[Message_Fail + 1];
+  Handle(Message_CompositeAlerts) myCompositAlerts;
 
-  Standard_Boolean myIsActive[Message_Fail + 1];
-  Message_PerfMeterMode myPerfMeterMode; //! If true, each alert will store the mode information
   Standard_Integer myLimit; //! Maximum number of collected alerts
 
-  Handle(Message_ReportCallBack) myCallBack; //! signal about performed modifications
+  NCollection_Sequence <Message_Level*> myAlertLevels; //! container of alerts, new alerts are added below the latest level
+  NCollection_Map<Message_MetricType> myActiveMetrics; //! metrics to compute on alerts
 };
 
 #endif // _Message_Report_HeaderFile
diff --git a/src/Message/Message_ReportCallBack.cxx b/src/Message/Message_ReportCallBack.cxx
deleted file mode 100644 (file)
index 5f0ce64..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Created on: 2017-12-01
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include "Message_ReportCallBack.hxx"
-
-IMPLEMENT_STANDARD_RTTIEXT(Message_ReportCallBack, Standard_Transient)
-
-Message_ReportCallBack::Message_ReportCallBack ()
-{
-}
diff --git a/src/Message/Message_ReportCallBack.hxx b/src/Message/Message_ReportCallBack.hxx
deleted file mode 100644 (file)
index 884b64d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// Created on: 2017-12-01
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Message_ReportCallBack_HeaderFile
-#define _Message_ReportCallBack_HeaderFile
-
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Type.hxx>
-
-class Message_Alert;
-class Message_ReportCallBack;
-DEFINE_STANDARD_HANDLE(Message_ReportCallBack, Standard_Transient)
-
-//! Interface to have possibility of processing message report events.
-class Message_ReportCallBack : public Standard_Transient
-{
-public:
-
-  //! Empty constructor
-  Standard_EXPORT Message_ReportCallBack ();
-  ~Message_ReportCallBack () {}
-
-  //! Interface to be implemented in the child to process the message report event
-  //! \param theAlert created or modified message alert
-  virtual void Update(const Handle(Message_Alert)& theAlert) = 0;
-
-  //! OCCT RTTI
-  DEFINE_STANDARD_RTTIEXT(Message_ReportCallBack, Standard_Transient)
-};
-
-#endif // _Message_ReportCallBack_HeaderFile
index 6651c8f2b1c8e5c66e6c839bc03f02a944fee68d..8723021376e1aceda1932baafaec01a6b45d07b2 100644 (file)
@@ -190,12 +190,12 @@ void OSD_MemInfo::Update()
 // function : Update
 // purpose  :
 // =======================================================================
-void OSD_MemInfo::Update (const OSD_MemInfo::Counter theCounter)
+void OSD_MemInfo::Update (const NCollection_Map<OSD_MemInfo::Counter> theCounters)
 {
 #ifndef OCCT_UWP
 #if defined(_WIN32)
 
-  if (theCounter == MemVirtual)
+  if (theCounters.Contains (MemVirtual))
   {
   #if (_WIN32_WINNT >= 0x0500)
     MEMORYSTATUSEX aStatEx;
@@ -212,11 +212,11 @@ void OSD_MemInfo::Update (const OSD_MemInfo::Counter theCounter)
     return;
   }
 
-  if (theCounter == MemPrivate ||
-      theCounter == MemWorkingSet ||
-      theCounter == MemWorkingSetPeak ||
-      theCounter == MemSwapUsage ||
-      theCounter == MemSwapUsagePeak)
+  if (theCounters.Contains (MemPrivate) ||
+      theCounters.Contains (MemWorkingSet) ||
+      theCounters.Contains (MemWorkingSetPeak) ||
+      theCounters.Contains (MemSwapUsage) ||
+      theCounters.Contains (MemSwapUsagePeak))
   {
     // use Psapi library
     HANDLE aProcess = GetCurrentProcess();
@@ -238,7 +238,7 @@ void OSD_MemInfo::Update (const OSD_MemInfo::Counter theCounter)
     return;
   }
 
-  if (theCounter == MemHeapUsage)
+  if (theCounters.Contains (MemHeapUsage))
   {
     _HEAPINFO hinfo;
     int heapstatus;
index 71c0c9a1eacf174704f27da04dbd7cf301c7081a..84d4fda7ec44e130695380711b702d8fb1e2955a 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef _OSD_MemInfo_H__
 #define _OSD_MemInfo_H__
 
+#include <NCollection_Map.hxx>
 #include <TCollection_AsciiString.hxx>
 
 //! This class provide information about memory utilized by current process.
@@ -75,7 +76,7 @@ public:
   Standard_EXPORT void Update();
 
   //! Update counter of specified counter
-  Standard_EXPORT void Update (const OSD_MemInfo::Counter theCounter);
+  Standard_EXPORT void Update (const NCollection_Map<OSD_MemInfo::Counter> theCounters);
 
   //! Return the string representation for all available counter.
   Standard_EXPORT TCollection_AsciiString ToString() const;
index 377f87023507ee8394e4d2c5039068b633124fe5..a57be8b7d1d3caf1405d3542880e484e399f8791 100755 (executable)
 #include <OpenGl_Structure.hxx>
 #include <OpenGl_ShaderManager.hxx>
 
+//#define DEBUG_INFO
+#ifdef DEBUG_INFO
+#include <Message_Alerts.hxx>
+#include <Message_Level.hxx>
+#endif // DEBUG_INFO
+
 namespace
 {
   static const OpenGl_CappingPlaneResource* THE_DEFAULT_ASPECT = new OpenGl_CappingPlaneResource (new Graphic3d_AspectFillCapping);
@@ -341,13 +347,13 @@ namespace
 // function : RenderCapping
 // purpose  :
 // =======================================================================
-#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
 void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorkspace,
                                         const OpenGl_Structure&         theStructure)
 {
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO ("RenderCapping", "", &aPerfMeter, NULL);
+#ifdef DEBUG_INFO
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO ("RenderCapping");
+#endif
 
   const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
   if (!aContext->Clipping().IsCappingOn())
@@ -394,8 +400,9 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
 
     Standard_SStream aStream;
     aClipChain->DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "ClipChain", "", &aPerfMeter, NULL);
-
+#ifdef DEBUG_INFO
+    MESSAGE_INFO_STREAM(aStream, "ClipChain");
+#endif
     Standard_Integer aSubPlaneIndex = 1;
     for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex)
     {
index 8c6f0ff4d02676ed7ed72a055dd7fb379c0774df..882eb66980ea2c6fc6a421f82594c3b38b42a8de 100644 (file)
@@ -31,7 +31,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif // DEBUG_INFO
 
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
@@ -306,16 +306,16 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO_OBJECT(this, "OpenGl_Group::Render")
+
   Standard_SStream aGroupStream;
   DumpJson (aGroupStream);
-  MESSAGE_INFO_OBJECT(this, aGroupStream, "OpenGl_Group::Render", "", &aPerfMeter, NULL)
-  Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+  MESSAGE_INFO_STREAM(aGroupStream, "group")
 
   Standard_SStream aContextStream;
   theWorkspace->GetGlContext()->DumpJson (aContextStream);
-  MESSAGE_INFO_OBJECT(this, aContextStream, "Context", "", &aPerfMeter, aParentAlert)
+  MESSAGE_INFO_STREAM(aContextStream, "context")
 #endif
 
   // Setup aspects
index 3b8d2c3021f08d500f7955d9f898e5875cb96b4c..ca1084f89179e9bcbabe226717b86d37618d372f 100644 (file)
@@ -29,7 +29,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif
 
 namespace
@@ -587,8 +587,8 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace
                                     const Graphic3d_Layer& theLayer) const
 {
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_LayerList::renderLayer", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_LayerList::renderLayer")
 #endif
 
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
@@ -900,8 +900,8 @@ void OpenGl_LayerList::renderTransparent (const Handle(OpenGl_Workspace)&   theW
   }
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_LayerList::renderTransparent", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_LayerList::renderTransparent")
 #endif
 
   const Handle(OpenGl_Context) aCtx            = theWorkspace->GetGlContext();
index b71dd848f38a83d1197ee0d93fe64dd3282872a5..e4941d9bd78856d3d9731615a37fad770899e736 100644 (file)
@@ -32,7 +32,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif // DEBUG_INFO
 
 namespace
@@ -776,10 +776,12 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
   }
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
+  MESSAGE_ADD_LEVEL_SENTRY
+
+  MESSAGE_INFO_OBJECT(this, "OpenGl_PrimitiveArray::Render")
   Standard_SStream aGroupStream;
   DumpJson (aGroupStream);
-  MESSAGE_INFO_STREAM(aGroupStream, "OpenGl_PrimitiveArray::Render", Standard_Dump::GetPointerInfo(this), &aPerfMeter, NULL)
+  MESSAGE_INFO_STREAM(aGroupStream, "parameters")
 #endif
 
   const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects();
index a552a33ff2b7547055fe2a8308314c53aa522e6b..1fa6d8d8610ea7808c08de1974281163ec5da565 100644 (file)
@@ -28,7 +28,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif
 
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure)
@@ -390,8 +390,8 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp
                                        bool&                           theHasClosed) const
 {
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_Structure::renderGeometry", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_Structure::renderGeometry")
 #endif
 
   if (myInstancedStructure != NULL)
index 2fe1563ea0d4b1ed40e9950f58c5a140f7d459f0..06b57bcffb8e1f12cd4c5e979fc3a161248e9055 100644 (file)
@@ -33,7 +33,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif
 
 namespace
@@ -286,23 +286,22 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
 void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
+  MESSAGE_ADD_LEVEL_SENTRY
 
   Standard_SStream aGroupStream;
   DumpJson (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "OpenGl_Text::Render", "", &aPerfMeter, NULL)
-  Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+  MESSAGE_INFO_STREAM (aGroupStream, "OpenGl_Text::Render")
 #endif
   const OpenGl_Aspects* aTextAspect = theWorkspace->ApplyAspects();
 
 #ifdef DEBUG_INFO
   aGroupStream.str("");
   aTextAspect->DumpJson (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "aTextAspect", "", &aPerfMeter, aParentAlert)
+  MESSAGE_INFO_STREAM (aGroupStream, "aTextAspect")
 
   aGroupStream.str("");
   OpenGl_Context::DumpJsonOpenGl (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters1", "", &aPerfMeter, aParentAlert)
+  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters1")
 #endif
 
   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
@@ -344,7 +343,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
 #ifdef DEBUG_INFO
   aGroupStream.str("");
   OpenGl_Context::DumpJsonOpenGl (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters2", "", &aPerfMeter, aParentAlert)
+  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters2")
 #endif
 }
 
@@ -645,11 +644,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   }
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
+  MESSAGE_ADD_LEVEL_SENTRY
 
   Standard_SStream aGroupStream;
   OpenGl_Context::DumpJsonOpenGl (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters3", "", &aPerfMeter, NULL)
+  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters3")
 #endif
 
   // Note that using difference resolution in different Views in same Viewer
@@ -823,7 +822,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
 #ifdef DEBUG_INFO
   aGroupStream.str("");
   OpenGl_Context::DumpJsonOpenGl (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters4", "", &aPerfMeter, NULL)
+  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters4")
 #endif
 
   // main draw call
@@ -840,7 +839,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
 #ifdef DEBUG_INFO
   aGroupStream.str("");
   OpenGl_Context::DumpJsonOpenGl (aGroupStream);
-  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters5", "", &aPerfMeter, NULL)
+  MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters5")
 #endif
 
 #if !defined(GL_ES_VERSION_2_0)
index 1fd9aab95af2a165b9ed4f8212fea8964f33c060..0d5444e2156b624e22bb1e7180635ef3cbad0e1d 100644 (file)
@@ -42,7 +42,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif
 
 namespace
@@ -182,8 +182,8 @@ void OpenGl_View::Redraw()
   }
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::Redraw", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::Redraw")
 #endif
 
   myWindow->SetSwapInterval();
@@ -626,8 +626,8 @@ void OpenGl_View::RedrawImmediate()
   }
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::RedrawImmediate", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::RedrawImmediate")
 #endif
 
   const Graphic3d_StereoMode   aStereoMode  = myRenderParams.StereoMode;
@@ -789,8 +789,8 @@ void OpenGl_View::redraw (const Graphic3d_Camera::Projection theProjection,
 {
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::redraw", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::redraw")
 #endif
 
   Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
@@ -840,8 +840,8 @@ bool OpenGl_View::redrawImmediate (const Graphic3d_Camera::Projection theProject
                                    const Standard_Boolean             theIsPartialUpdate)
 {
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::redrawImmediate", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::redrawImmediate")
 #endif
 
   Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
@@ -921,8 +921,8 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
   // ==================================
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::render", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::render")
 #endif
 
   const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
@@ -1136,8 +1136,8 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
     return;
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::renderStructs", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::renderStructs")
 #endif
 
   Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
@@ -1265,8 +1265,8 @@ void OpenGl_View::renderScene (Graphic3d_Camera::Projection theProjection,
 {
 
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO("OpenGl_View::renderScene", "", &aPerfMeter, NULL)
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO("OpenGl_View::renderScene")
 #endif
 
   const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
index a9032de1f27cf4e094d1123e83045a026c2ebcf9..6758ce3b4c061a8c1541aa6f179022ccad4317ac 100644 (file)
@@ -36,7 +36,7 @@
 //#define DEBUG_INFO
 #ifdef DEBUG_INFO
 #include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
 #endif // DEBUG_INFO
 
 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
@@ -408,11 +408,12 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
 bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
 {
 #ifdef DEBUG_INFO
-  Message_PerfMeter aPerfMeter;
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO_OBJECT(this, "Workspace")
 
   Standard_SStream aWorkspaceStream;
   DumpJson (aWorkspaceStream);
-  MESSAGE_INFO_OBJECT(this, aWorkspaceStream, "Workspace", "", &aPerfMeter, NULL)
+  MESSAGE_INFO_STREAM(aWorkspaceStream, "parameters")
 #endif
 
   // render only non-raytracable elements when RayTracing is enabled
index 95eb535d8a5ec8279af2ff007d74211c600a9b19..e2bef68142c0ddd81be5b98650a5e61fe6c27edc 100644 (file)
@@ -340,6 +340,9 @@ void PrsMgr_PresentableObject::recomputeComputed() const
 //=======================================================================
 void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
 {
+  if (myTransformPersistence == theTrsfPers)
+    return;
+
   myTransformPersistence = theTrsfPers;
   for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
   {
index 37463e7e1de8ccdf3511a7428f9b51224f5138c0..2ef79f9fbae7301a951ca0eb220d4edee7e67e78 100644 (file)
@@ -28,6 +28,7 @@
 #include <Interface_InterfaceModel.hxx>
 #include <Interface_Macros.hxx>
 #include <Interface_Static.hxx>
+#include <Message_Level.hxx>
 #include <Message_Messenger.hxx>
 #include <Message_ProgressSentry.hxx>
 #include <OSD_Timer.hxx>
@@ -96,6 +97,7 @@
 #include <TColStd_HSequenceOfTransient.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
+#include <TopoDS_AlertAttribute.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Iterator.hxx>
@@ -467,6 +469,10 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
 
 {
   Handle(Message_Messenger) sout = TP->Messenger();
+#ifdef TRANSLOG
+  //if (TP->TraceLevel() > 1) 
+  MESSAGE_ADD_LEVEL_SENTRY
+#endif
   Handle(TransferBRep_ShapeBinder) shbinder;
   
   TopoDS_Compound Cund;
@@ -550,6 +556,8 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS,
 
     TopoDS_Shape theResult = TransferBRep::ShapeResult (binder);
     if (!theResult.IsNull()) {
+      if (TP->TraceLevel() > 3) 
+        sout<<"TransferBRep::ShapeResult"<<theResult;
       Result1 = theResult;
       // [BEGIN] ssv: OCCT#22436: extra compound in NMSSR case
       if (NM_DETECTED && Result1.ShapeType() == TopAbs_COMPOUND)
index aac6e489af4106680dc59c24731e42a9484fd7ed..886260ac0d2a6c3fbd16b8bbd7084c7ffdfd4dde 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <TopoDS_AlertAttribute.hxx>
 
-#include <Message_Msg.hxx>
+#include <Message_PrinterToReport.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute)
 
@@ -23,15 +23,34 @@ IMPLEMENT_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_Attribute)
 //function : TopoDS_AlertAttribute
 //purpose  : 
 //=======================================================================
-
-
 TopoDS_AlertAttribute::TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
-  const TCollection_AsciiString& theName,
-  const TCollection_AsciiString& theDescription)
-: Message_AttributeStream (Standard_SStream(), theName, theDescription), myShape (theShape)
+  const TCollection_AsciiString& theName)
+: Message_AttributeStream (Standard_SStream(), theName), myShape (theShape)
 {
   Standard_SStream aStream;
   theShape.DumpJson (aStream);
 
   SetStream (aStream);
 }
+
+//=======================================================================
+//function : Send
+//purpose  : 
+//=======================================================================
+void TopoDS_AlertAttribute::Send (const Handle(Message_Messenger)& theMessenger,
+                                  const TopoDS_Shape& theShape)
+{
+  for (Message_SequenceOfPrinters::Iterator aPrinterIter (theMessenger->Printers()); aPrinterIter.More(); aPrinterIter.Next())
+  {
+    const Handle(Message_Printer)& aPrinter = aPrinterIter.Value();
+    if (!aPrinter->IsKind (STANDARD_TYPE (Message_PrinterToReport)))
+      continue;
+
+    Handle (Message_PrinterToReport) aPrinterToReport = Handle(Message_PrinterToReport)::DownCast (aPrinter);
+    const Handle(Message_Report)& aReport = aPrinterToReport->Report();
+
+    Message_AlertExtended::AddAlert (aReport, new TopoDS_AlertAttribute (theShape, aPrinterToReport->Key()),
+                                     theMessenger->OuputGravity());
+    aPrinterToReport->Clear();
+  }
+}
index ea347944e757b2e7e245c29f1ebac3ad9d7be21a..49f13138161c85c5fb82909d6aada40a6fb85c3d 100644 (file)
 #define _TopoDS_AlertAttribute_HeaderFile
 
 #include <Message_AttributeStream.hxx>
+#include <Message.hxx>
+#include <Message_Alerts.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_Report.hxx>
+
 #include <TopoDS_Shape.hxx>
 
+class Message_Messenger;
+
 //! Alert attributre object storing TopoDS shape in its field
 class TopoDS_AlertAttribute : public Message_AttributeStream 
 {
 public:
   //! Constructor with shape argument
   Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
-    const TCollection_AsciiString& theName = TCollection_AsciiString(),
-    const TCollection_AsciiString& theDescription = TCollection_AsciiString());
+    const TCollection_AsciiString& theName = TCollection_AsciiString());
 
   //! Returns contained shape
   const TopoDS_Shape& GetShape() const { return myShape; }
-  
+
+  //! Push shape information into messenger
+  Standard_EXPORT static void Send (const Handle(Message_Messenger)& theMessenger,
+                                    const TopoDS_Shape& theShape);
+
   // OCCT RTTI
   DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream)
 
@@ -38,14 +48,21 @@ private:
   TopoDS_Shape myShape;
 };
 
-#define MESSAGE_INFO_SHAPE(Shape, Name, Description, PerfMeter, ParentAlert) \
+#define MESSAGE_INFO_SHAPE(Shape, Name) \
   { \
-    if (!Message_Report::CurrentReport().IsNull() && \
-         Message_Report::CurrentReport()->IsActive (Message_Info)) \
+    if (!Message::DefaultReport().IsNull()) \
     { \
-      OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
-        new TopoDS_AlertAttribute (Shape, Name, Description), PerfMeter, ParentAlert); \
+      Message_AlertExtended::AddAlert (Message::DefaultReport(), \
+        new TopoDS_AlertAttribute (Shape, Name), Message_Info); \
     } \
   }
 
+// HAsciiString
+inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
+                                                    const TopoDS_Shape& theShape)
+{
+  TopoDS_AlertAttribute::Send (theMessenger, theShape);
+  return theMessenger;
+}
+
 #endif // _TopoDS_AlertAttribute_HeaderFile
index b42e1c4aa433700daddcfc9b28a92d1bc68b319a..d979699e1cedf2b645adf77aa2bb9b184366a924 100644 (file)
@@ -1086,6 +1086,8 @@ Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& s
       thelevel = oldlev;
     }
     catch (Standard_Failure const& anException) {
+      Message_Gravity aPrevGravity = themessenger->OuputGravity();
+      themessenger->SetOuputGravity (Message_Fail);
       if (binder.IsNull()) {
        themessenger << "                  *** Exception Raised with no Result" << Message_EndLine;
        binder = new Transfer_VoidBinder;
@@ -1097,6 +1099,7 @@ Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& s
        StartTrace (binder, start, thelevel-1,4);
       }
       thelevel = oldlev;
+      themessenger->SetOuputGravity (aPrevGravity);
     }
   }
 
index 98eaa4dc1bda106c5d291075333119eae587fe77..7b08848208428536c1283afb58ca31647b17d21f 100644 (file)
 #include <STEPCAFControl_Writer.hxx>
 #include <STEPControl_Controller.hxx>
 #include <TCollection_ExtendedString.hxx>
+#include <Transfer_TransientProcess.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDF_Data.hxx>
 #include <TDocStd_Application.hxx>
 #include <TDocStd_Document.hxx>
 #include <XDEDRAW.hxx>
 #include <XDEDRAW_Common.hxx>
+#include <XSControl_TransferReader.hxx>
 #include <XSControl_WorkSession.hxx>
 #include <XSDRAW.hxx>
 #include <XSDRAW_Vars.hxx>
@@ -312,11 +314,17 @@ static Standard_Integer ReadStep (Draw_Interpretor& di, Standard_Integer argc, c
 
   Standard_CString aDocName = NULL;
   TCollection_AsciiString aFilePath, aModeStr;
+  Standard_Integer aTraceLevel = 0;
   for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
   {
     TCollection_AsciiString anArgCase (argv[anArgIter]);
     anArgCase.LowerCase();
-    if (aDocName == NULL)
+    if (anArgCase == "-tracelevel" && anArgIter < argc)
+    {
+      anArgIter++;
+      aTraceLevel = atoi (argv[anArgIter]);
+    }
+    else if (aDocName == NULL)
     {
       aDocName = argv[anArgIter];
     }
@@ -383,6 +391,12 @@ static Standard_Integer ReadStep (Draw_Interpretor& di, Standard_Integer argc, c
     Draw::Set (aDocName, DD);
 //     di << "Document saved with name " << aDocName;
   }
+
+  if (aTraceLevel > 0)
+  {
+    const Handle(XSControl_TransferReader) &TR1 = reader.Reader().WS()->TransferReader();
+    TR1->TransientProcess()->SetTraceLevel (aTraceLevel);
+  }
   if ( ! reader.Transfer ( doc ) ) {
     di << "Cannot read any relevant data from the STEP file\n";
     return 1;
@@ -617,7 +631,7 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& di)
   di.Add("ReadIges" , "Doc filename: Read IGES file to DECAF document" ,__FILE__, ReadIges, g);
   di.Add("WriteIges" , "Doc filename: Write DECAF document to IGES file" ,__FILE__, WriteIges, g);
   di.Add("ReadStep" ,
-         "Doc filename [mode]"
+         "Doc filename [mode] [-traceLevel level]"
          "\n\t\t: Read STEP file to a document.",
          __FILE__, ReadStep, g);
   di.Add("WriteStep" , "Doc filename [mode=a [multifile_prefix] [label]]: Write DECAF document to STEP file" ,__FILE__, WriteStep, g);  
index b6a5696f639f9e23a29038baebad215aebc853c0..8546a7e8c72a2f74033e21c3ed7aae20f81672e4 100644 (file)
 
 #include <Message.hxx>
 #include <Message_AlertExtended.hxx>
+#include <Message_AttributeObject.hxx>
 #include <Message_AttributeStream.hxx>
 #include <Message_CompositeAlerts.hxx>
+#include <Message_Level.hxx>
 #include <Message_Report.hxx>
 
+#include <Standard_Dump.hxx>
+
 #include <TCollection.hxx>
 #include <TDataStd_AsciiString.hxx>
 #include <TDataStd_Comment.hxx>
@@ -30,6 +34,8 @@
 #include <TDF_ChildIterator.hxx>
 #include <TDocStd_Application.hxx>
 #include <TDocStd_Document.hxx>
+#include <TopoDS_AlertAttribute.hxx>
+
 #include <XmlDrivers.hxx>
 
 // =======================================================================
@@ -73,7 +79,7 @@ void XmlDrivers_MessageReportStorage::ExportReport (const Handle(Message_Report)
     // Gravity Label
     TDF_Label aGravityLabel = aMainLabel.NewChild();
     // set gravity kind string
-    TCollection_ExtendedString aName (Message::GravityToString ((Message_Gravity)aGravity));
+    TCollection_ExtendedString aName (aGravity);
     if (!aName.IsEmpty())
       TDataStd_Name::Set (aGravityLabel, aName);
 
@@ -88,6 +94,7 @@ void XmlDrivers_MessageReportStorage::ExportReport (const Handle(Message_Report)
     }
   }
   GetApplication()->SaveAs (aDocument, theFileName);
+  GetApplication()->Close (aDocument);
 }
 
 // =======================================================================
@@ -131,7 +138,7 @@ Handle(Message_Report) XmlDrivers_MessageReportStorage::ImportReport (const TCol
 
     // get gravity type
     const TCollection_ExtendedString& aGravityName = aNameAttribute->Get();
-    Message_Gravity aGravity = Message::GravityFromString (TCollection_AsciiString (aGravityName).ToCString());
+    Message_Gravity aGravity = (Message_Gravity) (TCollection_AsciiString (aGravityName).IntegerValue());
 
     /// reserved label to store gravity information
     //TDF_Label aFirstAlertLabel = aGravityLabel.FindChild (1, Standard_False);
@@ -168,7 +175,7 @@ void XmlDrivers_MessageReportStorage::exportAlert (const Handle(Message_Alert)&
     // Gravity Label
     TDF_Label aGravityLabel = anAlertLabel.NewChild();
     // set gravity kind string
-    TDataStd_Name::Set (aGravityLabel, Message::GravityToString ((Message_Gravity)aGravityId));
+    TDataStd_Name::Set (aGravityLabel, aGravityId);
 
     Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
     if (anAlertExtended.IsNull())
@@ -214,7 +221,7 @@ void XmlDrivers_MessageReportStorage::importAlert (const TDF_Label& theAlertLabe
       continue;
 
     // get gravity type
-    Message_Gravity aGravity = Message::GravityFromString (TCollection_AsciiString (aNameAttribute->Get()).ToCString());
+    Message_Gravity aGravity = (Message_Gravity) (TCollection_AsciiString (aNameAttribute->Get()).IntegerValue());
     // find alerts information, add corresponded alerts to the report
     for (TDF_ChildIterator anAlertLabelsIt (aGravityLabel); anAlertLabelsIt.More(); anAlertLabelsIt.Next())
     {
@@ -225,7 +232,13 @@ void XmlDrivers_MessageReportStorage::importAlert (const TDF_Label& theAlertLabe
       importAlert (anAlertLabel, aGravity, theReport, anAlert);
     }
   }
-  theReport->AddAlert (theGravity, anAlert, 0, theParentAlert);
+  if (theParentAlert.IsNull())
+    theReport->AddAlert (theGravity, anAlert);
+  else
+  {
+    MESSAGE_ADD_LEVEL_SENTRY
+    theReport->AddAlert (theGravity, anAlert);
+  }
 }
 
 // =======================================================================
@@ -234,40 +247,30 @@ void XmlDrivers_MessageReportStorage::importAlert (const TDF_Label& theAlertLabe
 // =======================================================================
 void XmlDrivers_MessageReportStorage::exportAlertParameters (const Handle(Message_Alert)& theAlert, const TDF_Label& theAlertLabel)
 {
-  //Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
-  //if (anAlertExtended.IsNull()) // name attribute is empty
-  //  return;
-
-  //// store attribute time
-  //Handle(Message_Attribute) anAttribute = anAlertExtended->Attribute();
-
-  //TDataStd_Name::Set (theAlertLabel, anAttribute->DynamicType()->Name());
-  ////TDataStd_Real::Set (theAlertLabel, anAlertExtended->CumulativeMetric());
-
-  //TDataStd_AsciiString::Set (theAlertLabel, anAttribute->GetName());
-  //TCollection_AsciiString aDescription = anAttribute->GetDescription();
-  //if (!aDescription.IsEmpty())
-  //  TDataStd_Comment::Set (theAlertLabel, anAttribute->GetDescription());
-
-  //Standard_CString aDynamicTypeName = anAttribute->DynamicType()->Name();
-  //if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name())
-  //{
-  //  Handle(Message_AttributeStream) aValuesArrayAlert = Handle(Message_AttributeStream)::DownCast (anAttribute);
-  //  // store values
-  //  NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
-  //  TCollection_AsciiString aKey;
-  //  TCollection::Split (aValuesArrayAlert->GetStream(), aValues, aKey);
-  //  if (aValues.IsEmpty())
-  //    return;
-  //  int anArraySize = 2 * aValues.Size();
-  //  Handle(TDataStd_ExtStringArray) aListAttribute = TDataStd_ExtStringArray::Set (theAlertLabel, 0, anArraySize - 1);
-  //  for (int aValueId = 0; aValueId < anArraySize; aValueId++)
-  //  {
-  //    TCollection_AsciiString aKey = aValues.FindKey (aValueId);
-  //    aListAttribute->SetValue (aValueId * 2, aKey);
-  //    aListAttribute->SetValue (aValueId * 2 + 1, aValues.FindFromKey (aKey));
-  //  }
-  //}
+  Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
+  if (anAlertExtended.IsNull()) // name attribute is empty
+    return;
+
+  // store attribute time
+  Handle(Message_Attribute) anAttribute = anAlertExtended->Attribute();
+
+  TDataStd_Name::Set (theAlertLabel, anAttribute->DynamicType()->Name());
+  //TDataStd_Real::Set (theAlertLabel, anAlertExtended->CumulativeMetric());
+
+  TDataStd_AsciiString::Set (theAlertLabel, anAttribute->GetName());
+
+  Standard_CString aDynamicTypeName = anAttribute->DynamicType()->Name();
+  if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name() ||
+      aDynamicTypeName == STANDARD_TYPE (TopoDS_AlertAttribute)->Name())
+  {
+    Handle(Message_AttributeStream) aValuesArrayAlert = Handle(Message_AttributeStream)::DownCast (anAttribute);
+    // store values
+    TCollection_AsciiString aStreamText = Standard_Dump::Text (aValuesArrayAlert->GetStream());
+    if (aStreamText.IsEmpty())
+      return;
+    Handle(TDataStd_ExtStringArray) aListAttribute = TDataStd_ExtStringArray::Set (theAlertLabel, 0, 0);
+    aListAttribute->SetValue (0, aStreamText);
+  }
 }
 
 // =======================================================================
@@ -276,72 +279,59 @@ void XmlDrivers_MessageReportStorage::exportAlertParameters (const Handle(Messag
 // =======================================================================
 Handle(Message_Alert) XmlDrivers_MessageReportStorage::importAlertParameters (const TDF_Label& aParametersLabel)
 {
-  //Handle(TDF_Attribute) anAttribute;
-  //if (!aParametersLabel.FindAttribute (TDataStd_Name::GetID(), anAttribute))
-  //  return Handle(Message_Alert)();
-
-  //Handle(TDataStd_Name) aDynamicTypeAttribute = Handle(TDataStd_Name)::DownCast (anAttribute);
-  //if (aDynamicTypeAttribute.IsNull())
-  //  return Handle(Message_Alert)();
-  //const TCollection_ExtendedString& aDynamicTypeName = aDynamicTypeAttribute->Get();
-
-  //TCollection_ExtendedString aDescription;
-  //if (aParametersLabel.FindAttribute (TDataStd_Comment::GetID(), anAttribute))
-  //{
-  //  Handle(TDataStd_Comment) aDescriptionAttribute = Handle(TDataStd_Comment)::DownCast (anAttribute);
-  //  if (!aDescriptionAttribute.IsNull())
-  //    aDescription = aDescriptionAttribute->Get();
-  //}
-
-  //Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
-  //Handle(Message_Attribute) aMessageAttribute;
-  //if (aDynamicTypeName == STANDARD_TYPE (Message_Attribute)->Name())
-  //  aMessageAttribute = new Message_Attribute();
-  //else if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name())
-  //{
-  //  // values
-  //  NCollection_Vector<TCollection_AsciiString> anArrayValues;
-  //  if (!aParametersLabel.FindAttribute (TDataStd_ExtStringArray::GetID(), anAttribute))
-  //    return Handle(Message_Alert)();
-
-  //  Handle(TDataStd_ExtStringArray) aValuesAttribute = Handle(TDataStd_ExtStringArray)::DownCast (anAttribute);
-  //  if (aValuesAttribute.IsNull())
-  //    return Handle(Message_Alert)();
-
-  //  Standard_SStream aStream;
-  //  for (int aValueId = aValuesAttribute->Lower(); aValueId <= aValuesAttribute->Upper(); aValueId++)
-  //  {
-  //    TCollection_AsciiString aKey = aValuesAttribute->Value (aValueId++);
-  //    if (aValueId > aValuesAttribute->Upper())
-  //      break;
-  //    DUMP_VALUES (aStream, aKey, aValuesAttribute->Value (aValueId));
-  //  }
-  //  Handle(Message_AttributeStream) anAlert = new Message_AttributeStream (aStream);
-  //  aMessageAttribute = anAlert;
-  //}
-
-  //if (!aMessageAttribute.IsNull())
-  //{
-  //  // name
-  //  if (!aParametersLabel.FindAttribute (TDataStd_AsciiString::GetID(), anAttribute))
-  //    return Handle(Message_Alert)();
-  //  Handle(TDataStd_AsciiString) aNameAttribute = Handle(TDataStd_AsciiString)::DownCast (anAttribute);
-  //  if (aNameAttribute.IsNull())
-  //    return Handle(Message_Alert)();
-
-  //  aMessageAttribute->SetName (aNameAttribute->Get());
-  //  aMessageAttribute->SetDescription (aDescription);
-
-  //  anAlert->SetAttribute (aMessageAttribute);
-  //}
-
-  //// time
+  Handle(TDF_Attribute) anAttribute;
+  if (!aParametersLabel.FindAttribute (TDataStd_Name::GetID(), anAttribute))
+    return Handle(Message_Alert)();
+
+  Handle(TDataStd_Name) aDynamicTypeAttribute = Handle(TDataStd_Name)::DownCast (anAttribute);
+  if (aDynamicTypeAttribute.IsNull())
+    return Handle(Message_Alert)();
+  const TCollection_ExtendedString& aDynamicTypeName = aDynamicTypeAttribute->Get();
+
+  Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
+  Handle(Message_Attribute) aMessageAttribute;
+  if (aDynamicTypeName == STANDARD_TYPE (Message_Attribute)->Name())
+    aMessageAttribute = new Message_Attribute();
+  else if (aDynamicTypeName == STANDARD_TYPE (Message_AttributeStream)->Name() ||
+           aDynamicTypeName == STANDARD_TYPE (TopoDS_AlertAttribute)->Name())
+  {
+    // values
+    NCollection_Vector<TCollection_AsciiString> anArrayValues;
+    if (!aParametersLabel.FindAttribute (TDataStd_ExtStringArray::GetID(), anAttribute))
+      return Handle(Message_Alert)();
+
+    Handle(TDataStd_ExtStringArray) aValuesAttribute = Handle(TDataStd_ExtStringArray)::DownCast (anAttribute);
+    if (aValuesAttribute.IsNull())
+      return Handle(Message_Alert)();
+
+    Standard_SStream aStream;
+    for (int aValueId = aValuesAttribute->Lower(); aValueId <= aValuesAttribute->Upper(); aValueId++)
+    {
+      aStream << aValuesAttribute->Value (aValueId);
+    }
+    Handle(Message_AttributeStream) anAlert = new Message_AttributeStream (aStream);
+    aMessageAttribute = anAlert;
+  }
+
+  if (!aMessageAttribute.IsNull())
+  {
+    // name
+    if (!aParametersLabel.FindAttribute (TDataStd_AsciiString::GetID(), anAttribute))
+      return Handle(Message_Alert)();
+    Handle(TDataStd_AsciiString) aNameAttribute = Handle(TDataStd_AsciiString)::DownCast (anAttribute);
+    if (aNameAttribute.IsNull())
+      return Handle(Message_Alert)();
+
+    aMessageAttribute->SetName (aNameAttribute->Get());
+    anAlert->SetAttribute (aMessageAttribute);
+  }
+
+  // time
   //Standard_Real aTime = -1;
   //Handle(TDataStd_Real) aTimeAttribute;
   //if (aParametersLabel.FindAttribute (TDataStd_Real::GetID(), aTimeAttribute))
   //  aTime = aTimeAttribute->Get();
 
-  ////anAlert->SetCumulativeMetric (aTime);
-  //return anAlert;
-  return NULL;
+  //anAlert->SetCumulativeMetric (aTime);
+  return anAlert;
 }
index cd97441c1e6b86a243ae4673de39135a19adeab1..81e1db8f9cdf860bdf0c0c2b9616aefc1631881c 100644 (file)
@@ -65,4 +65,10 @@ private:
   static Handle(Message_Alert) importAlertParameters (const TDF_Label& aParametersLabel);
 };
 
+#define MESSAGE_STORE_XML_REPORT(FileName) \
+{ \
+  Handle(Message_Report) aReport = Message::DefaultReport (Standard_False); \
+  if (!aReport.IsNull()) XmlDrivers_MessageReportStorage::ExportReport (aReport, FileName); \
+}
+
 #endif // _XmlDrivers_MessageReportStorage
diff --git a/tests/de/step_5/B8 b/tests/de/step_5/B8
new file mode 100644 (file)
index 0000000..cae0e88
--- /dev/null
@@ -0,0 +1,23 @@
+pload ALL
+
+dsetreportprinter on
+
+dsetreportmetric 1
+
+ReadStep d d:/dmu/step1.stp -tracelevel 4
+#ReadStep d [locate_data_file bug21802_as1-oc-214.stp]
+dsetreportprinter off
+dsetreportmetric
+
+set aFile d:/dmu/B8_report.xml
+#set aFile ${imagedir}/B8_report.xml
+
+file delete ${aFile}
+WriteReport ${aFile}
+if { ![file exists ${aFile}] } {
+       puts "There is not ${aFile} file; WriteReport command: Error"
+       return
+}
+
+pload INSPECTOR
+tinspector -plugins MessageView
index 2aff65e7f1ddf7600c7b13ea03ed64e6dffa34ff..edd1a88239721a3fa3f2a246374b65314f91603f 100644 (file)
@@ -53,7 +53,9 @@ DFBrowser_Module::DFBrowser_Module()
 // =======================================================================
 void DFBrowser_Module::CreateViewModel (void* theParent)
 {
-  myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+  myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent);
+  myOCAFViewModel->InitColumns();
+  myOCAFViewModel->SetModule (this);
 }
 
 // =======================================================================
index 16fe10485e71c1c7fc56920d81cc0d81c14f2926..23ab2c2aa837e07d1034ab245d8a4ae4f73aa5f5 100644 (file)
@@ -38,12 +38,27 @@ const int COLUMN_NAME_WIDTH = 300;
 // function : Constructor
 // purpose :
 // =======================================================================
-DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule)
+DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+}
 
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::InitColumns()
+{
+  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::SetModule (DFBrowser_Module* theModule)
+{
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   aRootItem->SetModule (theModule);
 }
 
@@ -51,9 +66,9 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module*
 // function : createRootItem
 // purpose :
 // =======================================================================
-void DFBrowser_TreeModel::createRootItem (const int)
+TreeModel_ItemBasePtr DFBrowser_TreeModel::createRootItem (const int)
 {
-  m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
+  return DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
 }
 
 // =======================================================================
@@ -62,7 +77,7 @@ void DFBrowser_TreeModel::createRootItem (const int)
 // =======================================================================
 void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplication)
 {
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   Reset();
   aRootItem->SetApplication (theApplication);
   EmitLayoutChanged();
@@ -74,7 +89,7 @@ void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplicatio
 // =======================================================================
 Handle(TDocStd_Application) DFBrowser_TreeModel::GetTDocStdApplication() const
 {
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   return aRootItem->GetApplication();
 }
 
@@ -179,7 +194,7 @@ QModelIndex DFBrowser_TreeModel::FindIndexByPath (const QStringList& theLabelEnt
         if (aPathId == aPathCount && anItem->HasAttribute())
         {
           // processing attribute in theValue
-          DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(m_pRootItem);
+          DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(RootItem (0));
           QString anAttributeInfo = DFBrowser_Module::GetAttributeInfo (anItem->GetAttribute(), aRootAppItem->GetModule(),
                                                                         Qt::DisplayRole, 0).toString();
           if (anAttributeInfo == anEntry)
index 6182c25b567023dde6bfbd53c7f85871884faab1..dbe038ffc16e8b8e9cd318413eca728e419b139e 100644 (file)
@@ -45,14 +45,20 @@ class DFBrowser_TreeModel : public TreeModel_ModelBase
 public:
 
   //! Constructor
-  Standard_EXPORT DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule);
+  Standard_EXPORT DFBrowser_TreeModel (QObject* theParent);
 
   //! Destructor
   virtual ~DFBrowser_TreeModel() Standard_OVERRIDE {};
 
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
+
   //! Fills the root item by the application
   Standard_EXPORT void Init (const Handle(TDocStd_Application)& theApplication);
 
+  //! Fill root item by the module
+  void SetModule (DFBrowser_Module* theModule);
+
   //! Returns an OCAF application or NULL
   //! \return an application instance
   Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
@@ -98,7 +104,7 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId);
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
 
index 0e7982911408238308f7be225888af94dc025573..a903cf3f254c9865322a07c4a363f0ccaa837f95 100644 (file)
@@ -41,6 +41,7 @@ DFBrowserPane_TDataStdTreeNode::DFBrowserPane_TDataStdTreeNode()
 : DFBrowserPane_AttributePane(), myTreeNodeView (0)
 {
   myModel = new DFBrowserPane_TDataStdTreeNodeModel (0);
+  myModel->InitColumns();
   mySelectionModels.clear(); // do not use selection model of parent pane
   mySelectionModels.push_back (new QItemSelectionModel (myModel));
 }
@@ -99,15 +100,14 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
   }
 
 
-  DFBrowserPane_TDataStdTreeNodeModel* aModel = dynamic_cast<DFBrowserPane_TDataStdTreeNodeModel*> (myModel);
-  aModel->Reset();
+  myModel->Reset();
 
   if (!aTreeNode.IsNull())
   {
     Handle(TDataStd_TreeNode) aRootItem = aTreeNode->Root();
-    aModel->SetAttribute (aRootItem);
+    myModel->SetAttribute (aRootItem);
 
-    QModelIndex anIndex = aModel->FindIndex (theAttribute, QModelIndex());
+    QModelIndex anIndex = myModel->FindIndex (theAttribute, QModelIndex());
     if (myTreeNodeView && anIndex.isValid())
     {
       myTreeNodeView->setExpanded (anIndex.parent(), true);
@@ -119,7 +119,7 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
       anAttributeNodeItem->setCurrentAttribute (true);
     }
   }
-  aModel->EmitLayoutChanged();
+  myModel->EmitLayoutChanged();
 }
 
 // =======================================================================
index 9057060869ad983f03da70b2649045aad75cec39..50d676a41958bfb6f653108d82d12074dbaa6963 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <Standard.hxx>
 
-class QAbstractItemModel;
+class DFBrowserPane_TDataStdTreeNodeModel;
 class QTreeView;
 
 //! \class DFBrowserPane_TDataStdTreeNode
@@ -66,7 +66,7 @@ public:
 
 private:
 
-  QAbstractItemModel* myModel;
+  DFBrowserPane_TDataStdTreeNodeModel* myModel;
   QTreeView* myTreeNodeView;
 };
 
index aaa62b23b5c010a59460ca8c0359e7082b39425e..4f8a4847f0dabca1173e63ebad4041ef783c60a6 100644 (file)
 DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  createRootItem(0);
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeModel::InitColumns()
+{
+  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
 {
-  m_pRootItem = DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
+  return DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
@@ -47,7 +55,7 @@ void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
 // =======================================================================
 void DFBrowserPane_TDataStdTreeNodeModel::SetAttribute (const Handle(TDF_Attribute)& theAttribute)
 {
-  DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(m_pRootItem);
+  DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(RootItem (0));
   Reset();
   aRootItem->SetAttribute (theAttribute);
   EmitLayoutChanged();
index 9223cfa19bc90040763753fb213980e4c103811f..62e016ce86e2fd394f9b3f15ea9d099d525b6486 100644 (file)
@@ -40,6 +40,9 @@ public:
   //! Destructor
   virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {};
 
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
+
   //! Initializes the tree model by the attribute
   //! \param theAttribute a current attribute
   Standard_EXPORT void SetAttribute (const Handle(TDF_Attribute)& theAttribute);
@@ -59,7 +62,7 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
 
index 953018ceee593f5c48b9918b3293c702cd3dae91..5fbdcbc86bcd62a9e4d9498c9ee3202be2496e22 100644 (file)
@@ -10,8 +10,6 @@ MessageModel_ItemReport.cxx
 MessageModel_ItemReport.hxx
 MessageModel_ItemRoot.cxx
 MessageModel_ItemRoot.hxx
-MessageModel_ReportCallBack.cxx
-MessageModel_ReportCallBack.hxx
 MessageModel_Tools.cxx
 MessageModel_Tools.hxx
 MessageModel_TreeModel.cxx
index 6862cafe7d440e26d625ba14a4217a3d3009bb12..8b794a859901750f03e2d67cd77d9cf669a41c7c 100644 (file)
@@ -1,6 +1,6 @@
 <!DOCTYPE RCC><RCC version="1.0">
     <qresource>
         <file>icons/item_shape.png</file>
-        <file>icons/item_vectorOfValues.png</file>
+        <file>icons/item_streamValues.png</file>
     </qresource>
 </RCC>
index 8cd073c1c88a80a059bd7db81eea08ef37e6b1ff..7df28caaba5ce791a1a5434e8cd9731e8f2cb765 100644 (file)
@@ -24,7 +24,9 @@ enum MessageModel_ActionType
   MessageModel_ActionType_Clear, //!< clear Message_Report alerts
   MessageModel_ActionType_ExportToShapeView, //!< export TopoDS_Shape of selected item into TKShapeView plugin
   MessageModel_ActionType_TestMetric, //!< test alerts
-  MessageModel_ActionType_TestProperties //!< test alerts
+  MessageModel_ActionType_TestProperties, //!< test alerts
+  MessageModel_ActionType_TestMessenger, //!< test message view on messenger printer to report
+  MessageModel_ActionType_TestReportTree //!< test message view on hierarchical report
 };
 
 #endif
index 82f9268da86b659cc034bef2a81511d65f0bf3f0..b5e478526272e835a4f5c0369282ee62f7c15cf5 100644 (file)
 #include <inspector/TInspectorAPI_PluginParameters.hxx>
 #include <inspector/ViewControl_Tools.hxx>
 
+#include <Message.hxx>
 #include <Message_AlertExtended.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterToReport.hxx>
 
 #include <BRepBuilderAPI_MakeEdge.hxx>
+#include <OSD_Chronometer.hxx>
 #include <Quantity_Color.hxx>
 #include <Quantity_ColorRGBA.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <QWidget>
 #include <Standard_WarningsRestore.hxx>
 
-#define DEBUG_ALERTS
-
-#ifdef DEBUG_ALERTS
-#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
-#endif
-
 // =======================================================================
 // function : Constructor
 // purpose :
@@ -56,20 +53,14 @@ MessageModel_Actions::MessageModel_Actions (QWidget* theParent,
   MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel)
 : QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel)
 {
-  myActions.insert (MessageModel_ActionType_Deactivate,
-                    ViewControl_Tools::CreateAction ("Deactivate", SLOT (OnDeactivateReport()), parent(), this));
   myActions.insert (MessageModel_ActionType_Activate,
                     ViewControl_Tools::CreateAction ("Activate", SLOT (OnActivateReport()), parent(), this));
+  myActions.insert (MessageModel_ActionType_Deactivate,
+                    ViewControl_Tools::CreateAction ("Deactivate", SLOT (OnDeactivateReport()), parent(), this));
   myActions.insert (MessageModel_ActionType_Clear,
                     ViewControl_Tools::CreateAction ("Clear", SLOT (OnClearReport()), parent(), this));
   myActions.insert (MessageModel_ActionType_ExportToShapeView,
                     ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this));
-#ifdef DEBUG_ALERTS
-  myActions.insert (MessageModel_ActionType_TestMetric,
-                    ViewControl_Tools::CreateAction ("Test <metric>", SLOT (OnTestMetric()), parent(), this));
-  myActions.insert (MessageModel_ActionType_TestProperties,
-                    ViewControl_Tools::CreateAction ("Test <PropertyPanel>", SLOT (OnTestPropertyPanel()), parent(), this));
-#endif
 }
 
 // =======================================================================
@@ -121,10 +112,6 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd
     theMenu->addAction (myActions[MessageModel_ActionType_Deactivate]);
     theMenu->addAction (myActions[MessageModel_ActionType_Activate]);
     theMenu->addAction (myActions[MessageModel_ActionType_Clear]);
-#ifdef DEBUG_ALERTS
-    theMenu->addAction (myActions[MessageModel_ActionType_TestMetric]);
-    theMenu->addAction (myActions[MessageModel_ActionType_TestProperties]);
-#endif
   }
   else if (anAlertItem)
   {
@@ -135,7 +122,7 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd
 }
 
 // =======================================================================
-// function : onImportReport
+// function : getSelectedReport
 // purpose :
 // =======================================================================
 Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& theReportIndex) const
@@ -164,33 +151,40 @@ Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& the
 }
 
 // =======================================================================
-// function : OnDeactivateReport
+// function : OnActivateReport
 // purpose :
 // =======================================================================
-void MessageModel_Actions::OnDeactivateReport()
+static Handle(Message_PrinterToReport) MyPrinterToReport;
+static Message_SequenceOfPrinters MyDeactivatedPrinters;
+
+void MessageModel_Actions::OnActivateReport()
 {
-  QModelIndex aReportIndex;
-  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
-  if (aReport.IsNull())
+  if (MyPrinterToReport.IsNull())
+    MyPrinterToReport = new Message_PrinterToReport();
+
+  if (MyPrinterToReport->Report()->IsActiveInMessenger())
     return;
 
-  aReport->SetActive (Standard_False);
-  ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
+  MyDeactivatedPrinters = Message::DefaultMessenger()->Printers();
+  Message::DefaultMessenger()->ChangePrinters().Clear();
+
+  Message::DefaultMessenger()->AddPrinter (MyPrinterToReport);
+  myTreeModel->UpdateTreeModel();
 }
 
 // =======================================================================
-// function : OnActivateReport
+// function : OnDeactivateReport
 // purpose :
 // =======================================================================
-void MessageModel_Actions::OnActivateReport()
+void MessageModel_Actions::OnDeactivateReport()
 {
-  QModelIndex aReportIndex;
-  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
-  if (aReport.IsNull())
+  if (MyPrinterToReport.IsNull() || !MyPrinterToReport->Report()->IsActiveInMessenger())
     return;
 
-  aReport->SetActive (Standard_True);
-  ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
+  Message::DefaultMessenger()->RemovePrinter (MyPrinterToReport);
+  Message::DefaultMessenger()->ChangePrinters().Assign (MyDeactivatedPrinters);
+
+  myTreeModel->UpdateTreeModel();
 }
 
 // =======================================================================
@@ -205,7 +199,7 @@ void MessageModel_Actions::OnClearReport()
     return;
 
   aReport->Clear();
-  ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
+  myTreeModel->UpdateTreeModel();
 }
 
 // =======================================================================
@@ -270,172 +264,3 @@ void MessageModel_Actions::OnExportToShapeView()
   QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.")
     .arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString())));
 }
-
-// =======================================================================
-// function : OnTestMetric
-// purpose :
-// =======================================================================
-#include <OSD_Chronometer.hxx>
-#include <ctime>
-void MessageModel_Actions::OnTestMetric()
-{
-#ifdef DEBUG_ALERTS
-  QModelIndex aReportIndex;
-  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
-  if (aReport.IsNull())
-    return;
-
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL);
-  unsigned int start_time =  clock();
-  //Standard_Real aSystemSeconds, aCurrentSeconds;
-  //OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds);
-
-  Standard_Integer aCounter = 5000;//0;
-  Standard_Real aValue = 0., aValue2 = 0.1;
-
-  double* aMemValue;
-  for (int aTopIt = 0; aTopIt < 4; aTopIt++)
-  {
-    for (int j = 0; j < aCounter; j++)
-    {
-      for (int i = 0; i < aCounter; i++)
-      {
-        aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5;
-
-        Standard_Real aValue3 = aValue + aValue2 * 0.2;
-        (void)aValue3;
-
-        aMemValue = new double;
-      }
-    }
-    MESSAGE_INFO ("Calculate", "", &aPerfMeter, NULL);
-  }
-
-  //((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged();
-
-  myTreeModel->UpdateTreeModel();
-
-  //Standard_Real aSystemSeconds1, aCurrentSeconds1;
-  //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1);
-
-  //std::cout << aValue << std::endl;
-  //std::cout << "user time = " << aCurrentSeconds1 - aCurrentSeconds
-  //          << ",  system time = " << aSystemSeconds1 - aSystemSeconds << std::endl;
-
-  unsigned int end_time = clock();
-  std::cout << "clock() = " << end_time - start_time << std::endl;
-#endif
-}
-
-// =======================================================================
-// function : OnTestPropertyPanel
-// purpose :
-// =======================================================================
-void MessageModel_Actions::OnTestPropertyPanel()
-{
-#ifdef DEBUG_ALERTS
-  QModelIndex aReportIndex;
-  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
-  if (aReport.IsNull())
-    return;
-
-  Message_PerfMeter aPerfMeter;
-  MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL);
-
-  // gp_XYZ
-  {
-    gp_XYZ aCoords (1.3, 2.3, 3.4);
-    Standard_SStream aStream;
-    aCoords.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_XYZ", "", &aPerfMeter, NULL);
-  }
-  // gp_Dir
-  {
-    gp_Dir aDir (0.3, 0.3, 0.4);
-    Standard_SStream aStream;
-    aDir.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_Dir", "", &aPerfMeter, NULL);
-  }
-  // 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 (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_Ax1", "", &aPerfMeter, NULL);
-  }
-  // 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 (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_Ax2", "", &aPerfMeter, NULL);
-  }
-  // 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 (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_Ax3", "", &aPerfMeter, NULL);
-  }
-  // gp_Trsf
-  {
-    gp_Trsf aTrsf;
-    aTrsf.SetRotation (gp::OZ(), 0.3);
-    aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.));
-    aTrsf.SetScaleFactor (3.);
-
-    Standard_SStream aStream;
-    aTrsf.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "gp_Trsf", "", &aPerfMeter, NULL);
-  }
-  // Bnd_Box
-  {
-    Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.));
-    Standard_SStream aStream;
-    aBox.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "Bnd_Box", "", &aPerfMeter, NULL);
-  }
-  // Bnd_OBB
-  {
-    Bnd_OBB anOBB (gp_Pnt (-10., -15., -10.), gp_Dir (1., 0., 0.), gp_Dir (0., 1., 0.), gp_Dir (0., 0., 1.),
-                  5., 10., 5.);
-    Standard_SStream aStream;
-    anOBB.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "Bnd_OBB", "", &aPerfMeter, NULL);
-  }
-  // Quantity_ColorRGBA
-  {
-    Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f);
-    Standard_SStream aStream;
-    aColor.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "Quantity_ColorRGBA", "", &aPerfMeter, NULL);
-  }
-  // Quantity_Color
-  {
-    Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB);
-    Standard_SStream aStream;
-    aColor.DumpJson (aStream);
-    MESSAGE_INFO_STREAM(aStream, "Quantity_Color", "", &aPerfMeter, NULL);
-  }
-
-  // stream of some table values
-  {
-    Standard_SStream aStream;
-    OCCT_DUMP_FIELD_VALUES_NUMERICAL (aStream, "value_1", 1, 100);
-    OCCT_DUMP_FIELD_VALUES_STRING (aStream, "value_2", 2, "value_1", "value_2");
-
-    MESSAGE_INFO_STREAM(aStream, "Table: Name to value", "", &aPerfMeter, NULL);
-  }
-
-  // SHAPE messages
-  {
-    BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.));
-    TopoDS_Shape aShape = aBuilder.Shape();
-
-    MESSAGE_INFO_SHAPE (aShape, "Shape message edge", "", &aPerfMeter, NULL);
-  }
-
-  myTreeModel->UpdateTreeModel();
-#endif
-}
index c030c97fdf1bfd5c15e5656cf5fa02db564ee601..39eab429e26d3498554b5ab060438ff9431a812c 100644 (file)
@@ -70,24 +70,18 @@ public:
   { myParameters = theParameters; }
 
 public slots:
-  //! Set selected report not active
-  void OnDeactivateReport();
-
   //! Set selected report active
   void OnActivateReport();
 
+  //! Set selected report not active
+  void OnDeactivateReport();
+
   //! Clears container of alerts of selected report
   void OnClearReport();
 
   //! Exports the first selected shape into ShapeViewer plugin.
   void OnExportToShapeView();
 
-  //! Sending several alerts to check metric of message-alert-tool mechanizm
-  void OnTestMetric();
-
-  //! Sending several alerts to check property panel/presentations of message-alert-tool mechanizm
-  void OnTestPropertyPanel();
-
 protected:
   //! Returns report of selected tree view item if a report item is selected
   //! \param theReportIndex tree model index of the found report
index bcec35a4cd1d6ee89550d52f7b7192c18591d751..7b076871fea40734e1640ce8626e870545ada544 100644 (file)
 #include <inspector/MessageModel_ItemRoot.hxx>
 #include <inspector/MessageModel_ItemReport.hxx>
 #include <inspector/MessageModel_Tools.hxx>
+#include <inspector/MessageModel_TreeModel.hxx>
+
 #include <inspector/ViewControl_Tools.hxx>
 #include <inspector/Convert_TransientShape.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 
 #include <Message_AlertExtended.hxx>
 #include <Message_AttributeObject.hxx>
+#include <Message_AttributeMeter.hxx>
 #include <Message_AttributeStream.hxx>
 #include <Message_CompositeAlerts.hxx>
 
@@ -55,22 +58,15 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
   if (aReport.IsNull())
     return QVariant();
 
-  Standard_Boolean isTimeReport = aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
-                                  aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo;
-
-  if (aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
-      aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo)
-
   if (theRole == Qt::ForegroundRole)
   {
-    if (!aReport->GetAlerts (Message_Fail).IsEmpty())
+    if (!aReport->GetAlerts (Message_Fail).IsEmpty() ||
+        !aReport->GetAlerts (Message_Alarm).IsEmpty())
       return QColor(Qt::darkRed);
 
-    for (int aGravityId = (int)Message_Trace; aGravityId <= (int)Message_Fail; aGravityId++)
-    {
-      if (!aReport->IsActive ((Message_Gravity)aGravityId))
-        return QColor(Qt::darkGray);
-    }
+    if (!aReport->IsActiveInMessenger())
+      return QColor(Qt::darkGray);
+
     return QVariant();
   }
 
@@ -84,11 +80,13 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
       return QVariant();
 
     Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
+    if (anAttribute.IsNull())
+      return QVariant();
 
     if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
       return QIcon (":/icons/item_shape.png");
     else if (!Handle(Message_AttributeStream)::DownCast (anAttribute).IsNull())
-      return QIcon (":/icons/item_vectorOfValues.png");
+      return QIcon (":/icons/item_streamValues.png");
     else
       return QVariant();
   }
@@ -99,69 +97,33 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
   if (anAlert.IsNull())
     return QVariant();
 
-  switch (Column())
+  if (Column() == 0)
+    return theRole == Qt::DisplayRole ? anAlert->GetMessageKey() : anAlert->DynamicType()->Name();
+
+  Message_MetricType aMetricType;
+  int aPosition;
+  if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition))
   {
-    case 0:
-      return theRole == Qt::DisplayRole ? anAlert->GetMessageKey() : anAlert->DynamicType()->Name();
-    //case 1: return QVariant(); // visibility state
-    //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
-    //case 3: return anAlert->ElapsedTime() < 0 ? QVariant() : anAlert->ElapsedTime();
-    case 4:
-    {
-      if (!anExtendedAlert->IsMetricValid())
-        return QVariant();
+    if (anExtendedAlert.IsNull())
+      return QVariant();
 
-      if (isTimeReport)
-        return anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
-      else
-        return anExtendedAlert->MetricStart();
-    }
-    case 5:
-    {
-      if (!anExtendedAlert->IsMetricValid())
-        return QVariant();
+    Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anExtendedAlert->Attribute());
+    if (anAttribute.IsNull())
+      return QVariant();
 
-      if (isTimeReport)
-      {
-        TreeModel_ItemBasePtr aParentItem = Parent();
-        MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport> (aParentItem);
-        while (!aReportItem)
-        {
-          aParentItem = aParentItem->Parent();
-          aReportItem = itemDynamicCast<MessageModel_ItemReport> (aParentItem);
-        }
-        double aDivideTo = aReport->CumulativeMetric (Message_Info);
-        double anAlertTime = anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
-
-        return aDivideTo == 0 ? QVariant() : 100. * anAlertTime / aDivideTo;
-      }
-      else
-      {
-        TreeModel_ItemBasePtr aParentItem = Parent();
-        //MessageModel_ItemAlertPtr aParentAlertItem = itemDynamicCast<MessageModel_ItemAlert> (aParentItem);
-        //if (aParentAlertItem)
-        //{
-          //double aDeltaToParent = CumulativeMetric (anAlert) - CumulativeMetric (aParentAlertItem->GetAlert());
-
-          //return fabs (aDeltaToParent) > Precision::Confusion() ? QVariant (aDeltaToParent) : QVariant();
-        //}
-        double anAlertMem = anExtendedAlert->MetricStop() - anExtendedAlert->MetricStart();
-        return anAlertMem;
-      }
-    }
-    case 6: return MessageModel_Tools::GetPointerAlertInfo (anAlert).ToCString();
-    case 7: return MessageModel_Tools::GetShapeTypeAlertInfo (anAlert).ToCString();
-    case 8: return MessageModel_Tools::GetStandardTypeAlertInfo (anAlert).ToCString();
-    case 9:
+    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)
     {
-      if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull())
-      {
-        TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription();
-        return theRole == Qt::DisplayRole ? TreeModel_Tools::CutString (aDescription.ToCString())
-                                          : aDescription.ToCString();
-      }
+      Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType);
+      if (fabs (aReportCumulativeMetric) > Precision::Confusion())
+        return 100. * aCumulativeMetric / aReportCumulativeMetric;
+      else
+        return QVariant();
     }
-    default: break;
   }
   return QVariant();
 }
index c68a286759adebbd7ec4d224d74fa36fcb3b026e..40a7d0b6279aede147b2cbcff09d86f3f3b3e7b4 100644 (file)
 #include <inspector/MessageModel_ItemAlert.hxx>
 #include <inspector/MessageModel_ItemRoot.hxx>
 #include <inspector/MessageModel_Tools.hxx>
+#include <inspector/MessageModel_TreeModel.hxx>
 
+#include <Message.hxx>
+#include <Message_Alert.hxx>
+#include <Message_AttributeMeter.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterToReport.hxx>
 #include <OSD_Path.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -41,45 +47,33 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const
 
   if (theRole == Qt::ForegroundRole)
   {
-    if (!aReport->GetAlerts (Message_Fail).IsEmpty())
+    if (!aReport->GetAlerts (Message_Fail).IsEmpty() ||
+        !aReport->GetAlerts (Message_Alarm).IsEmpty())
       return QColor(Qt::darkRed);
 
-    for (int aGravityId = (int)Message_Trace; aGravityId <= (int)Message_Fail; aGravityId++)
-    {
-      if (!aReport->IsActive ((Message_Gravity)aGravityId))
-        return QColor(Qt::darkGray);
-    }
+    if (!aReport->IsActiveInMessenger())
+      return QColor(Qt::darkGray);
+
     return QVariant();
   }
-  if (theRole == Qt::ToolTipRole && !myDescription.IsEmpty() && Column() == 8)
-    return myDescription.ToCString();
+  if (theRole == Qt::ToolTipRole && !myDescription.IsEmpty() && Column() == 0) // display the exported file name in tool tip
+  {
+    OSD_Path aPath(myDescription);
+    return QString ("%1%2").arg (aPath.Name().ToCString()).arg (aPath.Extension().ToCString());
+  }
 
   if (theRole != Qt::DisplayRole)
     return QVariant();
 
-  switch (Column())
-  {
-    case 0: return aReport->DynamicType()->Name();
-    //case 1: return QVariant(); // visibility state
-    //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
-    case 4: return aReport->CumulativeMetric (Message_Info);
-    case 5:
-    {
-      if (aReport->PerfMeterMode() == Message_PerfMeterMode_UserTimeCPU ||
-          aReport->PerfMeterMode() == Message_PerfMeterMode_SystemTimeInfo)
-        return "100";
-      else
-        return QVariant();
-    }
-    case 9:
-    {
-      if (myDescription.IsEmpty())
-        return QVariant();
+  if (Column() == 0)
+    return aReport->DynamicType()->Name();
 
-      OSD_Path aPath(myDescription);
-      return QString ("%1%2").arg (aPath.Name().ToCString()).arg (aPath.Extension().ToCString());
-    }
-    default: break;
+  Message_MetricType aMetricType;
+  int aPosition;
+  if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition))
+  {
+    if (aPosition == 0) return CumulativeMetric (aReport, aMetricType);
+    else if (aPosition == 1) return "100";
   }
   return QVariant();
 }
@@ -200,29 +194,38 @@ Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_I
 }
 
 // =======================================================================
-// function : initStream
+// function : CumulativeMetric
 // purpose :
 // =======================================================================
-void MessageModel_ItemReport::initStream (Standard_OStream& theOStream) const
+Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType)
 {
-  Handle(Message_Report) aReport = GetReport();
-  if (aReport.IsNull())
-    return;
-
-  aReport->DumpJson (theOStream);
-}
+  if (!theReport->ActiveMetrics().Contains (theMetricType))
+    return 0;
 
-// =======================================================================
-// function : SetStream
-// purpose :
-// =======================================================================
-bool MessageModel_ItemReport::SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
-                                         Standard_Integer& theLastPos) const
-{
-  Handle(Message_Report) aReport = GetReport();
-  if (aReport.IsNull())
-    return false;
+  Standard_Real aMetric = 0;
+  for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
+  {
+    const Message_ListOfAlert& anAlerts = theReport->GetAlerts ((Message_Gravity)iGravity);
+    Handle(Message_AttributeMeter) aFirstAttribute, aLastAttribute;
+    for (Message_ListOfAlert::Iterator anAlertsIterator (anAlerts); anAlertsIterator.More(); anAlertsIterator.Next())
+    {
+      Handle(Message_AlertExtended) anAlert = Handle(Message_AlertExtended)::DownCast (anAlertsIterator.Value());
+      if (anAlert.IsNull())
+        continue;
+      Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anAlert->Attribute());
+      if (anAttribute.IsNull())
+        continue;
+      if (aFirstAttribute.IsNull())
+        aFirstAttribute = anAttribute;
+      else
+        aLastAttribute = anAttribute;
+    }
+    if (aFirstAttribute.IsNull())
+      continue;
+    if (aLastAttribute.IsNull())
+      aLastAttribute = aFirstAttribute;
 
-  Standard_Integer aStartPos = 1;
-  return aReport->InitJson (theSStream, aStartPos);
+    aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType);
+  }
+  return aMetric;
 }
index b0f67c768605b062a27b6a2a7800d3d051722958..f03d98e58da2e978a75ab01654547a883db9952b 100644 (file)
@@ -78,20 +78,14 @@ public:
   //! Returns report of the item
   static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem);
 
-  //! Returns stream value of the item to fulfill property panel.
-  //! \return stream value or dummy
-  Standard_EXPORT virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
-                                          Standard_Integer& theLastPos) const Standard_OVERRIDE;
+  //! Returns report cumulative metric as stop time of the last alert minus start time of the first alert
+  Standard_EXPORT static Standard_Real CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType);
 
 protected:
 
   //! Initialize the current item. It is empty because Reset() is also empty.
   virtual void initItem() const Standard_OVERRIDE;
 
-  //! Returns stream value of the item to fulfill property panel.
-  //! \return stream value or dummy
-  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
-
   //! Creates a child item in the given position.
   //! \param theRow the child row position
   //! \param theColumn the child column position
index b7465675c3bd0da18419e6bd93705b826d13a3f0..197bd1eb9a65dbd5c6f25c4cffba589978c28ad5 100644 (file)
 class MessageModel_ItemRoot;
 typedef QExplicitlySharedDataPointer<MessageModel_ItemRoot> MessageModel_ItemRootPtr;
 
+//! \struct to extend report by description
+struct MessageModel_ReportInformation
+{
+  //! Constructor
+  MessageModel_ReportInformation (Handle(Message_Report) theReport, const TCollection_AsciiString& theDescription)
+    : myReport (theReport), myDescription (theDescription) {}
+
+  Handle(Message_Report) myReport; //! report
+  TCollection_AsciiString myDescription; //! report description
+};
+
 //! \class MessageModel_ItemRoot
 //! Collects message reports that should be visualized in tree view. Reports are cached and if reports are not needed,
 //! cache should be cleared using RemoveAllReports
 //! Parent is NULL, children are MessageModel_ItemReport items.
 class MessageModel_ItemRoot : public MessageModel_ItemBase
 {
-private:
-  //! \struct to extend report by description
-  struct MessageModel_ReportInformation
-  {
-    //! Constructor
-    MessageModel_ReportInformation (Handle(Message_Report) theReport, const TCollection_AsciiString& theDescription)
-      : myReport (theReport), myDescription (theDescription) {}
-
-    Handle(Message_Report) myReport; //! report
-    TCollection_AsciiString myDescription; //! report description
-  };
 public:
 
   //! Creates an item wrapped by a shared pointer
@@ -71,6 +71,9 @@ public:
   //! \return boolen value
   Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport);
 
+  //!< Returns processed reports
+  const NCollection_List<MessageModel_ReportInformation>& Reports() const { return myReports; }
+
   //! Clears internal container of added reports
   void RemoveAllReports() { myReports.Clear(); }
 
diff --git a/tools/MessageModel/MessageModel_ReportCallBack.cxx b/tools/MessageModel/MessageModel_ReportCallBack.cxx
deleted file mode 100644 (file)
index 695722f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Created on: 2018-06-20
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include "MessageModel_ReportCallBack.hxx"
-
-IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ReportCallBack, Message_ReportCallBack)
diff --git a/tools/MessageModel/MessageModel_ReportCallBack.hxx b/tools/MessageModel/MessageModel_ReportCallBack.hxx
deleted file mode 100644 (file)
index be5d7c9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Created on: 2018-06-20
-// Created by: Natalia Ermolaeva
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _MessageModel_ReportCallBack_HeaderFile
-#define _MessageModel_ReportCallBack_HeaderFile
-
-#include <Message_ReportCallBack.hxx>
-
-#include "inspector/TInspectorAPI_Communicator.hxx"
-
-class TInspectorAPI_Communicator;
-DEFINE_STANDARD_HANDLE(MessageModel_ReportCallBack, Message_ReportCallBack)
-
-//! Class to update tree view model by message report events.
-class MessageModel_ReportCallBack : public Message_ReportCallBack
-{
-public:
-
-  //! Constructor
-  MessageModel_ReportCallBack (TInspectorAPI_Communicator* theWindow) : Message_ReportCallBack(), myCommunicator (theWindow) {}
-
-  //! Destructor
-  ~MessageModel_ReportCallBack() {}
-
-  // Interface to be implemented in the child to process the message report event
-  // \theAlert updated alert
-  virtual void Update(const Handle(Message_Alert)& theAlert) { (void)theAlert; /*myCommunicator->UpdateContent();*/ }
-
-  // OCCT RTTI
-  DEFINE_STANDARD_RTTIEXT(MessageModel_ReportCallBack, Message_ReportCallBack)
-
-private:
-  TInspectorAPI_Communicator* myCommunicator; //< communicator
-};
-
-#endif // _MessageModel_ReportCallBack_HeaderFile
index 189ecb573dd09f6940499a78da65f5c637d4dc9b..dfa5ee6704a627680df9c577a75c9a219e6367eb 100644 (file)
@@ -58,138 +58,3 @@ TCollection_AsciiString MessageModel_Tools::GetPointerInfo (const Handle(Standar
   }
   return aPtrStr.str().c_str();
 }
-
-// =======================================================================
-// function : GetPointerAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetPointerAlertInfo (const Handle(Message_Alert)& theAlert)
-{
-  Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anExtAlert.IsNull())
-    return TCollection_AsciiString();
-
-  Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
-  if (anAttribute.IsNull())
-    return TCollection_AsciiString();
-
-  if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
-    return GetPointerInfo (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape().TShape());
-  else if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
-    return GetPointerInfo (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject());
-  return TCollection_AsciiString();
-}
-
-// =======================================================================
-// function : GetShapeTypeAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetShapeTypeAlertInfo (const Handle(Message_Alert)& theAlert)
-{
-  Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anExtAlert.IsNull())
-    return TCollection_AsciiString();
-
-  Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
-  if (anAttribute.IsNull())
-    return TCollection_AsciiString();
-
-  TopoDS_Shape aShape;
-  if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
-    aShape = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape();
-
-  if (aShape.IsNull())
-    return TCollection_AsciiString();
-
-  TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
-  Standard_SStream aSStream;
-  TopAbs::Print ((TopAbs_ShapeEnum)aShapeType, aSStream);
-  return aSStream.str().c_str();
-}
-
-// =======================================================================
-// function : GetStandardTypeAlertInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString MessageModel_Tools::GetStandardTypeAlertInfo (const Handle(Message_Alert)& theAlert)
-{
-  Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
-  if (anExtAlert.IsNull())
-    return TCollection_AsciiString();
-
-  Handle(Message_Attribute) anAttribute = anExtAlert->Attribute();
-  if (anAttribute.IsNull())
-    return TCollection_AsciiString();
-
-  Handle(Standard_Transient) aPointer;
-  if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
-    aPointer = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape().TShape();
-  else if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
-    aPointer = Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject();
-
-  if (aPointer.IsNull())
-    return TCollection_AsciiString();
-
-  return aPointer->DynamicType()->Name();
-}
-
-// =======================================================================
-// function : GetPropertyTableValues
-// purpose :
-// =======================================================================
-void MessageModel_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
-                                                 QList<ViewControl_TableModelValues*>& theTableValues)
-{
-  //Handle(TreeModel_ItemProperties) anItemProperties = theItem->GetProperties();
-  //if (!anItemProperties.IsNull())
-  //{
-  //  ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues();
-  //  aTableValues->SetProperties (anItemProperties);
-  //  theTableValues.append (aTableValues);
-  //  return;
-  //}
-
-  //MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(theItem);
-  //if (!anAlertItem)
-  //  return;
-
-  //const Handle(Message_Alert)& anAlert = anAlertItem->GetAlert();
-  //Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
-  //if (anExtendedAlert.IsNull())
-  //  return;
-
-  //Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
-  //if (anAttribute.IsNull())
-  //  return;
-
-  ////if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeStream)))
-  ////{
-  //  //int aSectionSize = 200;
-  //  //ViewControl_TableModelValues* aTableValues = new MessageModel_TableModelValues (anAttribute, aSectionSize);
-  //  //theTableValues.append (aTableValues);
-  ////}
-  ////else
-  ////{
-  //if (!anAttribute->GetDescription().IsEmpty())
-  //{
-  //  ViewControl_TableModelValuesDefault* aTableValues = new ViewControl_TableModelValuesDefault();
-  //  QList<TreeModel_HeaderSection> aHeaderValues;
-  //  QVector<QVariant> aValues;
-  //  aHeaderValues << TreeModel_HeaderSection ("Description", -2);
-  //  aValues << anAttribute->GetDescription().ToCString();
-  //  aTableValues->SetHeaderValues (aHeaderValues, Qt::Horizontal);
-
-  //  QString aValueStr = anAttribute->GetDescription().ToCString();
-  //  QStringList aValueStrList = aValueStr.split ("\n");
-  //  int aNbRows = aValueStrList.size();
-
-  //  QFontMetrics aFontMetrics (qApp->font());
-  //  int aHeight = aFontMetrics.boundingRect(aValueStr).height();
-  //  aHeight = (aHeight + TreeModel_Tools::HeaderSectionMargin()) * aNbRows;
-  //  aTableValues->SetValues (aValues);
-  //  aTableValues->SetDefaultSectionSize(Qt::Vertical, aHeight);
-
-  //  theTableValues.append (aTableValues);
-  //}
-  ////}
-}
index 15ff5783756858ab3f707996e1af45d1b041b1f3..c83922aed6d4f3596ccfa7b0e86840ba241e82e5 100644 (file)
@@ -48,27 +48,6 @@ public:
   //! \return the string value 
   Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
                                                                  const bool isShortInfo = true);
-
-  //! Returns pointer alert information depening on type of alert (Transient_Object or TopoDS_TShape)
-  //! \param theAlert a message alert
-  //! \return text presentation
-  Standard_EXPORT static TCollection_AsciiString GetPointerAlertInfo (const Handle(Message_Alert)& theAlert);
-
-  //! Returns TopoDS_Shape type alert information or empty string
-  //! \param theAlert a message alert
-  //! \return text presentation
-  Standard_EXPORT static TCollection_AsciiString GetShapeTypeAlertInfo (const Handle(Message_Alert)& theAlert);
-
-  //! Returns dynamic type of an alert object/shape
-  //! \param theAlert a message alert
-  //! \return text presentation
-  Standard_EXPORT static TCollection_AsciiString GetStandardTypeAlertInfo (const Handle(Message_Alert)& theAlert);
-
-  //! Fills container of table values
-  //! \param theAlert a message alert
-  //! \param theTableValue container of values
-  Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
-                                                      QList<ViewControl_TableModelValues*>& theTableValues);
 };
 
 #endif
index a994a4ed99d733cea20501cb7f53d10672f342cd..85b539817bc93081ab41740b49f099bc941f4e1b 100644 (file)
 #include <inspector/MessageModel_ItemRoot.hxx>
 #include <inspector/MessageModel_ItemReport.hxx>
 
-const int COLUMN_NAME_WIDTH = 310;
-const int COLUMN_SIZE_WIDTH = 30;
-const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
-const int COLUMN_STANDARD_TYPE_WIDTH = 120;
+#include <Message.hxx>
+
+const int COLUMN_REAL_VALUE_WIDTH = 115;
+const int COLUMN_PERCENT_VALUE_WIDTH = 40;
 
 // =======================================================================
 // function : Constructor
@@ -32,33 +31,78 @@ const int COLUMN_STANDARD_TYPE_WIDTH = 120;
 MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent), myIsReversed (Standard_False)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
-
-  //SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  // column 1 is reserved for visiblity state
-  //SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-
-  SetHeaderItem (4, TreeModel_HeaderSection ("Metric", -1));
-  SetHeaderItem (5, TreeModel_HeaderSection ("Difference", -1));
-
-  SetHeaderItem (6, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (7, TreeModel_HeaderSection ("Shape Type", COLUMN_SHAPE_TYPE_WIDTH));
-  SetHeaderItem (8, TreeModel_HeaderSection ("Standard Type", COLUMN_STANDARD_TYPE_WIDTH));
-  SetHeaderItem (9, TreeModel_HeaderSection ("Description", -1));
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void MessageModel_TreeModel::InitColumns()
+{
+  TreeModel_ModelBase::InitColumns();
+  // 0 - Name, 1 - visibility, 2 - Row
+
+  int aNextIndex = 3;
+  for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
+  {
+    Message_MetricType aMetricType = (Message_MetricType)aMetricId;
+    OSD_MemInfo::Counter aMemInfo;
+    bool isMemInfo = Message::ToOSDMetric (aMetricType, aMemInfo);
+
+    SetHeaderItem (aNextIndex++,
+      TreeModel_HeaderSection (QString("%1 [%2]").arg (Message::MetricToString (aMetricType)).arg(isMemInfo ? "Mb" : "s"),
+      COLUMN_REAL_VALUE_WIDTH));
+    SetHeaderItem (aNextIndex++, TreeModel_HeaderSection ("%", COLUMN_PERCENT_VALUE_WIDTH));
+  }
+}
+
+// =======================================================================
+// function : GetMetricColumns
+// purpose :
+// =======================================================================
+void MessageModel_TreeModel::GetMetricColumns (const Message_MetricType theMetricType, QList<int>& theMetricColumns)
+{
+  theMetricColumns.clear();
+  int aNextIndex = 3; // after default parent columns, see InitColumns
+  for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
+  {
+    if (theMetricType != (Message_MetricType)aMetricId)
+    {
+      aNextIndex += 2;
+      continue;
+    }
+    theMetricColumns.append (aNextIndex++);
+    theMetricColumns.append (aNextIndex++);
+  }
+}
+
+// =======================================================================
+// function : IsMetricColumn
+// purpose :
+// =======================================================================
+bool MessageModel_TreeModel::IsMetricColumn (const int theColumnId, Message_MetricType& theMetricType, int& thePosition)
+{
+  int aNextIndex = 3; // after default parent columns, see InitColumns
+  for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
+  {
+    if (theColumnId == aNextIndex || theColumnId == aNextIndex + 1)
+    {
+      theMetricType = (Message_MetricType)aMetricId;
+      thePosition = theColumnId - aNextIndex;
+      return true;
+    }
+    aNextIndex += 2;
+  }
+  return false;
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void MessageModel_TreeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr MessageModel_TreeModel::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, MessageModel_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return MessageModel_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
@@ -112,6 +156,16 @@ void MessageModel_TreeModel::SetReport (const int theRowId, const Handle(Message
   EmitLayoutChanged();
 }
 
+// =======================================================================
+// function : Reports
+// purpose :
+// =======================================================================
+const NCollection_List<MessageModel_ReportInformation>& MessageModel_TreeModel::Reports() const
+{
+  MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
+  return aRootItem->Reports();
+}
+
 // =======================================================================
 // function : SetReversed
 // purpose :
index c4403a0c7fa9d56fbb39ddd261d4ce8ab962d891..01eeba4144b409fce2aef48ac353a0164ecc0501 100644 (file)
@@ -17,6 +17,7 @@
 #define MessageModel_TreeModel_H
 
 #include <inspector/MessageModel_ItemBase.hxx>
+#include <inspector/MessageModel_ItemRoot.hxx>
 #include <Standard.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Message_Report.hxx>
@@ -41,6 +42,21 @@ public:
   //! Destructor
   virtual ~MessageModel_TreeModel() Standard_OVERRIDE {};
 
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
+
+  //!< Returns columns of the model for the metric
+  //!< \param theMetricType metric
+  //!< \param theMetricColumns [out] container of metric columns
+  static Standard_EXPORT void GetMetricColumns (const Message_MetricType theMetricType, QList<int>& theMetricColumns);
+
+  //!< Returns metric type for the column
+  //!< \param theColumnId [in] index of the tree column
+  //!< \param theMetricType [out] metric type if found
+  //!< \param thePosition [out] index of the metric column, 0 - is metric, 1 - is delta
+  //!< \return true if the column has metric parameters
+  static Standard_EXPORT bool IsMetricColumn (const int theColumnId, Message_MetricType& theMetricType, int& thePosition);
+
   //! Returns true if parameter report was added into the model
   //! \param theReport a report instance
   //! \return boolen value
@@ -59,6 +75,9 @@ public:
   Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport,
     const TCollection_AsciiString& theReportDescription = "");
 
+  //!< Returns processed reports
+  Standard_EXPORT const NCollection_List<MessageModel_ReportInformation>& Reports() const;
+
   //! Set the view reversed. If reversed, the last report alert is upper item in the tree view
   //! \param theReversed boolean flag
   Standard_EXPORT void SetReversed (const Standard_Boolean& theReversed);
@@ -71,22 +90,15 @@ public:
   //! \theName visulized text of root item
   Standard_EXPORT void SetRootItemName (const TCollection_AsciiString& theName);
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
-  { return myRootItems.contains (theColumn) ? myRootItems[theColumn] : TreeModel_ItemBasePtr(); }
-
   //! Updates tree model
   Standard_EXPORT void UpdateTreeModel();
 
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
   Standard_Boolean myIsReversed; //!< state if the model is reversed
 };
 
diff --git a/tools/MessageModel/icons/item_streamValues.png b/tools/MessageModel/icons/item_streamValues.png
new file mode 100644 (file)
index 0000000..7181f94
Binary files /dev/null and b/tools/MessageModel/icons/item_streamValues.png differ
diff --git a/tools/MessageModel/icons/item_streamValues.svg b/tools/MessageModel/icons/item_streamValues.svg
new file mode 100644 (file)
index 0000000..38b1032
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="20"
+   height="20"
+   viewBox="0 0 5.2916664 5.2916666"
+   version="1.1"
+   id="svg8"
+   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
+   sodipodi:docname="item_vectorOfReal.svg"
+   inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
+   inkscape:export-xdpi="96"
+   inkscape:export-ydpi="96">
+  <defs
+     id="defs2">
+    <linearGradient
+       id="linearGradient4578"
+       osb:paint="solid">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop4576" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
+       inkscape:vp_y="0 : 1028.295 : 0"
+       inkscape:vp_z="9.504499 : -1.1228559 : 1"
+       inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
+       id="perspective3711" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="15.839192"
+     inkscape:cx="-10.548151"
+     inkscape:cy="10.279721"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     fit-margin-top="0"
+     fit-margin-left="0"
+     fit-margin-right="0"
+     fit-margin-bottom="0"
+     inkscape:window-width="1446"
+     inkscape:window-height="838"
+     inkscape:window-x="1733"
+     inkscape:window-y="67"
+     inkscape:window-maximized="0"
+     units="px" />
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(71.966667,-93.642022)">
+    <rect
+       id="rect3769"
+       width="4.660512"
+       height="4.443356"
+       x="-71.632576"
+       y="94.056023"
+       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <rect
+       id="rect3769-3"
+       width="4.7041783"
+       height="2.2966287"
+       x="-71.676239"
+       y="96.202751"
+       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <rect
+       id="rect3769-9"
+       width="2.3560426"
+       height="4.4502382"
+       x="-71.617508"
+       y="94.071091"
+       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+  </g>
+</svg>
diff --git a/tools/MessageModel/icons/item_vectorOfReal.png b/tools/MessageModel/icons/item_vectorOfReal.png
deleted file mode 100644 (file)
index 7181f94..0000000
Binary files a/tools/MessageModel/icons/item_vectorOfReal.png and /dev/null differ
diff --git a/tools/MessageModel/icons/item_vectorOfReal.svg b/tools/MessageModel/icons/item_vectorOfReal.svg
deleted file mode 100644 (file)
index 38b1032..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="20"
-   height="20"
-   viewBox="0 0 5.2916664 5.2916666"
-   version="1.1"
-   id="svg8"
-   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
-   sodipodi:docname="item_vectorOfReal.svg"
-   inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
-   inkscape:export-xdpi="96"
-   inkscape:export-ydpi="96">
-  <defs
-     id="defs2">
-    <linearGradient
-       id="linearGradient4578"
-       osb:paint="solid">
-      <stop
-         style="stop-color:#000000;stop-opacity:1;"
-         offset="0"
-         id="stop4576" />
-    </linearGradient>
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
-       inkscape:vp_y="0 : 1028.295 : 0"
-       inkscape:vp_z="9.504499 : -1.1228559 : 1"
-       inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
-       id="perspective3711" />
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="15.839192"
-     inkscape:cx="-10.548151"
-     inkscape:cy="10.279721"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     showgrid="false"
-     fit-margin-top="0"
-     fit-margin-left="0"
-     fit-margin-right="0"
-     fit-margin-bottom="0"
-     inkscape:window-width="1446"
-     inkscape:window-height="838"
-     inkscape:window-x="1733"
-     inkscape:window-y="67"
-     inkscape:window-maximized="0"
-     units="px" />
-  <metadata
-     id="metadata5">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(71.966667,-93.642022)">
-    <rect
-       id="rect3769"
-       width="4.660512"
-       height="4.443356"
-       x="-71.632576"
-       y="94.056023"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-3"
-       width="4.7041783"
-       height="2.2966287"
-       x="-71.676239"
-       y="96.202751"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9"
-       width="2.3560426"
-       height="4.4502382"
-       x="-71.617508"
-       y="94.071091"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-  </g>
-</svg>
diff --git a/tools/MessageModel/icons/item_vectorOfRealVec3.png b/tools/MessageModel/icons/item_vectorOfRealVec3.png
deleted file mode 100644 (file)
index 4d0ebf9..0000000
Binary files a/tools/MessageModel/icons/item_vectorOfRealVec3.png and /dev/null differ
diff --git a/tools/MessageModel/icons/item_vectorOfRealVec3.svg b/tools/MessageModel/icons/item_vectorOfRealVec3.svg
deleted file mode 100644 (file)
index 4d2d42b..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="20"
-   height="20"
-   viewBox="0 0 5.2916664 5.2916666"
-   version="1.1"
-   id="svg8"
-   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
-   sodipodi:docname="item_vectorOfRealVec3.svg"
-   inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
-   inkscape:export-xdpi="96"
-   inkscape:export-ydpi="96">
-  <defs
-     id="defs2">
-    <linearGradient
-       id="linearGradient4578"
-       osb:paint="solid">
-      <stop
-         style="stop-color:#000000;stop-opacity:1;"
-         offset="0"
-         id="stop4576" />
-    </linearGradient>
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
-       inkscape:vp_y="0 : 1028.295 : 0"
-       inkscape:vp_z="9.504499 : -1.1228559 : 1"
-       inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
-       id="perspective3711" />
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="15.839192"
-     inkscape:cx="-10.548151"
-     inkscape:cy="10.279721"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     showgrid="false"
-     fit-margin-top="0"
-     fit-margin-left="0"
-     fit-margin-right="0"
-     fit-margin-bottom="0"
-     inkscape:window-width="1446"
-     inkscape:window-height="838"
-     inkscape:window-x="1733"
-     inkscape:window-y="67"
-     inkscape:window-maximized="0"
-     units="px" />
-  <metadata
-     id="metadata5">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(71.966667,-93.642022)">
-    <rect
-       id="rect3769"
-       width="4.660512"
-       height="4.443356"
-       x="-71.632576"
-       y="94.056023"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-3"
-       width="4.7041783"
-       height="2.2966287"
-       x="-71.676239"
-       y="96.202751"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9"
-       width="2.3560426"
-       height="4.4502382"
-       x="-71.617508"
-       y="94.071091"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9-6"
-       width="0.78304976"
-       height="2.0045512"
-       x="-71.618477"
-       y="94.141006"
-       style="opacity:1;fill:#dc8c8c;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9-6-0"
-       width="0.78304976"
-       height="2.0045512"
-       x="-70.835426"
-       y="94.141006"
-       style="opacity:1;fill:#8cdc8c;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9-6-5"
-       width="0.78304976"
-       height="2.0045512"
-       x="-70.052376"
-       y="94.141006"
-       style="opacity:1;fill:#8c8cdc;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.07284392;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-  </g>
-</svg>
diff --git a/tools/MessageModel/icons/item_vectorOfValues.png b/tools/MessageModel/icons/item_vectorOfValues.png
deleted file mode 100644 (file)
index 7181f94..0000000
Binary files a/tools/MessageModel/icons/item_vectorOfValues.png and /dev/null differ
diff --git a/tools/MessageModel/icons/item_vectorOfValues.svg b/tools/MessageModel/icons/item_vectorOfValues.svg
deleted file mode 100644 (file)
index 38b1032..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="20"
-   height="20"
-   viewBox="0 0 5.2916664 5.2916666"
-   version="1.1"
-   id="svg8"
-   inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
-   sodipodi:docname="item_vectorOfReal.svg"
-   inkscape:export-filename="D:\OCCT\master_CR29451_1\tools\MessageModel\icons\item_vectorOfRealVec3.png"
-   inkscape:export-xdpi="96"
-   inkscape:export-ydpi="96">
-  <defs
-     id="defs2">
-    <linearGradient
-       id="linearGradient4578"
-       osb:paint="solid">
-      <stop
-         style="stop-color:#000000;stop-opacity:1;"
-         offset="0"
-         id="stop4576" />
-    </linearGradient>
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="-2.6544163 : -0.28690906 : 1"
-       inkscape:vp_y="0 : 1028.295 : 0"
-       inkscape:vp_z="9.504499 : -1.1228559 : 1"
-       inkscape:persp3d-origin="2.7661607 : -1.3768436 : 1"
-       id="perspective3711" />
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="15.839192"
-     inkscape:cx="-10.548151"
-     inkscape:cy="10.279721"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     showgrid="false"
-     fit-margin-top="0"
-     fit-margin-left="0"
-     fit-margin-right="0"
-     fit-margin-bottom="0"
-     inkscape:window-width="1446"
-     inkscape:window-height="838"
-     inkscape:window-x="1733"
-     inkscape:window-y="67"
-     inkscape:window-maximized="0"
-     units="px" />
-  <metadata
-     id="metadata5">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(71.966667,-93.642022)">
-    <rect
-       id="rect3769"
-       width="4.660512"
-       height="4.443356"
-       x="-71.632576"
-       y="94.056023"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.26458332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-3"
-       width="4.7041783"
-       height="2.2966287"
-       x="-71.676239"
-       y="96.202751"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.19110738;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <rect
-       id="rect3769-9"
-       width="2.3560426"
-       height="4.4502382"
-       x="-71.617508"
-       y="94.071091"
-       style="opacity:1;fill:none;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.18826659;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-  </g>
-</svg>
index 529ec64718582308b10d3688bdce145a9d8dd17c..5fe2f5266101f0dd505d8ab44cda0717b82ed8c8 100644 (file)
@@ -1,3 +1,5 @@
+MessageView_ActionsTest.cxx
+MessageView_ActionsTest.hxx
 MessageView_Communicator.cxx
 MessageView_Communicator.hxx
 MessageView_VisibilityState.cxx
diff --git a/tools/MessageView/MessageView_ActionsTest.cxx b/tools/MessageView/MessageView_ActionsTest.cxx
new file mode 100644 (file)
index 0000000..76472fd
--- /dev/null
@@ -0,0 +1,438 @@
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#include <inspector/MessageView_ActionsTest.hxx>
+
+#include <inspector/MessageModel_ItemReport.hxx>
+#include <inspector/MessageModel_ItemRoot.hxx>
+#include <inspector/MessageModel_ItemAlert.hxx>
+#include <inspector/MessageModel_Tools.hxx>
+#include <inspector/MessageModel_TreeModel.hxx>
+#include <inspector/TInspectorAPI_PluginParameters.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <Message.hxx>
+#include <Message_AlertExtended.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterToReport.hxx>
+
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <OSD_Chronometer.hxx>
+#include <Quantity_Color.hxx>
+#include <Quantity_ColorRGBA.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_AlertAttribute.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAction>
+#include <QFileDialog>
+#include <QItemSelectionModel>
+#include <QMenu>
+#include <QMessageBox>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+#define DEBUG_ALERTS
+
+#ifdef DEBUG_ALERTS
+#include <Message_Alerts.hxx>
+#include <Message_Level.hxx>
+#endif
+
+#include <ctime>
+
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+MessageView_ActionsTest::MessageView_ActionsTest (QWidget* theParent,
+  MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel)
+: QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel)
+{
+  myActions.insert (MessageModel_ActionType_TestMetric,
+                    ViewControl_Tools::CreateAction ("Test <metric>", SLOT (OnTestMetric()), parent(), this));
+  myActions.insert (MessageModel_ActionType_TestProperties,
+                    ViewControl_Tools::CreateAction ("Test <PropertyPanel>", SLOT (OnTestPropertyPanel()), parent(), this));
+  myActions.insert (MessageModel_ActionType_TestMessenger,
+                    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));
+}
+
+// =======================================================================
+// function : AddMenuActions
+// purpose :
+// =======================================================================
+void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu)
+{
+  MessageModel_ItemRootPtr aRootItem;
+  MessageModel_ItemReportPtr aReportItem;
+  MessageModel_ItemAlertPtr anAlertItem;
+  for (QModelIndexList::const_iterator aSelIt = theSelectedIndices.begin(); aSelIt != theSelectedIndices.end(); aSelIt++)
+  {
+    QModelIndex anIndex = *aSelIt;
+    if (anIndex.column() != 0)
+      continue;
+
+    TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+    if (!anItemBase)
+      continue;
+
+    aRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItemBase);
+    if (aRootItem)
+      break;
+
+    aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
+    if (aReportItem)
+      break;
+
+    anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (anItemBase);
+    if (anAlertItem)
+      break;
+  }
+
+  if (aReportItem && !aReportItem->GetReport().IsNull())
+  {
+    theMenu->addAction (myActions[MessageModel_ActionType_TestMetric]);
+    theMenu->addAction (myActions[MessageModel_ActionType_TestProperties]);
+    theMenu->addAction (myActions[MessageModel_ActionType_TestMessenger]);
+    theMenu->addAction (myActions[MessageModel_ActionType_TestReportTree]);
+
+    bool isReportEnabled = aReportItem->GetReport()->IsActiveInMessenger();
+
+    myActions[MessageModel_ActionType_TestMetric]->setEnabled (isReportEnabled);
+    myActions[MessageModel_ActionType_TestProperties]->setEnabled (isReportEnabled);
+    myActions[MessageModel_ActionType_TestMessenger]->setEnabled (isReportEnabled);
+    myActions[MessageModel_ActionType_TestReportTree]->setEnabled (isReportEnabled);
+  }
+  theMenu->addSeparator();
+}
+
+// =======================================================================
+// function : getSelectedReport
+// purpose :
+// =======================================================================
+Handle(Message_Report) MessageView_ActionsTest::getSelectedReport (QModelIndex& theReportIndex) const
+{
+  MessageModel_ItemReportPtr aReportItem;
+  QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes();
+  for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+  {
+    QModelIndex anIndex = *aSelIt;
+    if (anIndex.column() != 0)
+      continue;
+
+    TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+    if (!anItemBase)
+      continue;
+
+    aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
+    theReportIndex = anIndex;
+    if (aReportItem)
+      break;
+  }
+  if (!aReportItem)
+    return NULL;
+
+  return aReportItem->GetReport();
+}
+
+// =======================================================================
+// function : OnTestMetric
+// purpose :
+// =======================================================================
+void MessageView_ActionsTest::OnTestMetric()
+{
+#ifdef DEBUG_ALERTS
+  QModelIndex aReportIndex;
+  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
+  if (aReport.IsNull())
+    return;
+
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO ("MessageModel_Actions::OnTestMetric()");
+  unsigned int start_time =  clock();
+  //Standard_Real aSystemSeconds, aCurrentSeconds;
+  //OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds);
+
+  Standard_Integer aCounter = 1500;//0;
+  Standard_Real aValue = 0., aValue2 = 0.1;
+
+  double* aMemValue;
+  for (int aTopIt = 0; aTopIt < 4; aTopIt++)
+  {
+    MESSAGE_INFO ("Calculate");
+    for (int j = 0; j < aCounter; j++)
+    {
+      for (int i = 0; i < aCounter; i++)
+      {
+        aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5;
+
+        Standard_Real aValue3 = aValue + aValue2 * 0.2;
+        (void)aValue3;
+
+        aMemValue = new double;
+      }
+    }
+  }
+
+  //((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged();
+
+  myTreeModel->UpdateTreeModel();
+
+  //Standard_Real aSystemSeconds1, aCurrentSeconds1;
+  //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1);
+
+  //std::cout << aValue << std::endl;
+  //std::cout << "user time = " << aCurrentSeconds1 - aCurrentSeconds
+  //          << ",  system time = " << aSystemSeconds1 - aSystemSeconds << std::endl;
+
+  unsigned int end_time = clock();
+  std::cout << "clock() = " << end_time - start_time << std::endl;
+#endif
+}
+
+// =======================================================================
+// function : OnTestPropertyPanel
+// purpose :
+// =======================================================================
+void MessageView_ActionsTest::OnTestPropertyPanel()
+{
+#ifdef DEBUG_ALERTS
+  QModelIndex aReportIndex;
+  Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
+  if (aReport.IsNull())
+    return;
+
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO ("MessageModel_Actions::OnTestPropertyPanel()");
+
+  // gp_XYZ
+  {
+    gp_XYZ aCoords (1.3, 2.3, 3.4);
+    Standard_SStream aStream;
+    aCoords.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "gp_XYZ");
+  }
+  // gp_Dir
+  {
+    gp_Dir aDir (0.3, 0.3, 0.4);
+    Standard_SStream aStream;
+    aDir.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "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 (aStream);
+    MESSAGE_INFO_STREAM(aStream, "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 (aStream);
+    MESSAGE_INFO_STREAM(aStream, "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 (aStream);
+    MESSAGE_INFO_STREAM(aStream, "gp_Ax3");
+  }
+  // gp_Trsf
+  {
+    gp_Trsf aTrsf;
+    aTrsf.SetRotation (gp::OZ(), 0.3);
+    aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.));
+    aTrsf.SetScaleFactor (3.);
+
+    Standard_SStream aStream;
+    aTrsf.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "gp_Trsf");
+  }
+  // Bnd_Box
+  {
+    Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.));
+    Standard_SStream aStream;
+    aBox.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "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.);
+    Standard_SStream aStream;
+    anOBB.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "Bnd_OBB");
+  }
+  // Quantity_ColorRGBA
+  {
+    Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f);
+    Standard_SStream aStream;
+    aColor.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "Quantity_ColorRGBA");
+  }
+  // Quantity_Color
+  {
+    Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB);
+    Standard_SStream aStream;
+    aColor.DumpJson (aStream);
+    MESSAGE_INFO_STREAM(aStream, "Quantity_Color");
+  }
+
+  // stream of some table values
+  {
+    Standard_SStream aStream;
+    OCCT_DUMP_FIELD_VALUES_NUMERICAL (aStream, "value_1", 1, 100);
+    OCCT_DUMP_FIELD_VALUES_STRING (aStream, "value_2", 2, "value_1", "value_2");
+
+    MESSAGE_INFO_STREAM(aStream, "Table: Name to value");
+  }
+
+  // SHAPE messages
+  {
+    BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.));
+    TopoDS_Shape aShape = aBuilder.Shape();
+
+    MESSAGE_INFO_SHAPE (aShape, "Shape message edge");
+  }
+
+  myTreeModel->UpdateTreeModel();
+#endif
+}
+
+// =======================================================================
+// function : OnTestMessenger
+// purpose :
+// =======================================================================
+void MessageView_ActionsTest::OnTestMessenger()
+{
+  // string messages
+  const Handle(Message_Messenger)& aMessenger = Message::DefaultMessenger();
+
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO ("MessageModel_Actions::OnTestMessenger()");
+
+  aMessenger << "IGESBasic_Hierarchy" << Message_EndLine;
+  aMessenger << "Number of property valueaMessenger : " << 15 << Message_EndLine;
+  aMessenger << "Line Font    : " << 1 << Message_EndLine << "View Number  : " << 3 << Message_EndLine;
+  aMessenger << "Entity level : " << 1 << Message_EndLine;
+  aMessenger << "Blank statuaMessenger : " << 0 << Message_EndLine;
+  aMessenger << "Line weight  : " << 14 << Message_EndLine;
+  aMessenger << "Color number : " << 5 << Message_EndLine;
+
+  // stream messages
+  // gp_XYZ
+  {
+    gp_XYZ aCoords (1.3, 2.3, 3.4);
+    Standard_SStream aStream;
+    aCoords.DumpJson (aStream);
+    aMessenger << "gp_XYZ" << aStream << Message_EndLine;
+  }
+  // Bnd_Box
+  {
+    Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.));
+    Standard_SStream aStream;
+    aBox.DumpJson (aStream);
+    aMessenger << "Bnd_Box" << aStream;
+  }
+
+  // object messages
+  Handle(Standard_Transient) anObject = new Message_AlertExtended();
+  aMessenger << "Message_AlertExtended" << anObject;
+
+  // shape messages
+  {
+    BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.));
+    TopoDS_Shape aShape = aBuilder.Shape();
+
+    MESSAGE_INFO_SHAPE (aShape, "Shape message edge");
+
+    aMessenger << "Shape message edge" << aShape;
+  }
+  myTreeModel->UpdateTreeModel();
+}
+
+// =======================================================================
+// function : levelAlerts
+// purpose :
+// =======================================================================
+void levelAlerts (const int theCurrentLevel, const int theTopLevel)
+{
+  if (theTopLevel - theCurrentLevel <= 0)
+    return;
+
+  MESSAGE_ADD_LEVEL_SENTRY
+
+  const Handle(Message_Messenger)& aMessenger = Message::DefaultMessenger();
+  aMessenger << "Level: " << theCurrentLevel << Message_EndLine;
+  aMessenger << "Alert: " << 1 << ", " << 2 << Message_EndLine;
+  aMessenger << "Alert: " << 3 << ", " << 4 << Message_EndLine;
+
+  for (int i = 0; i < 2; i++)
+    levelAlerts (theCurrentLevel + 1, theTopLevel);
+
+  aMessenger << "Alert: " << 4 << ", " << 5 << Message_EndLine;
+}
+
+// =======================================================================
+// function : levelAlert
+// purpose :
+// =======================================================================
+void levelAlert (const int theCurrentLevel, const int theTopLevel)
+{
+  if (theTopLevel - theCurrentLevel <= 0)
+    return;
+
+  MESSAGE_ADD_LEVEL_SENTRY
+
+  const Handle(Message_Messenger)& aMessenger = Message::DefaultMessenger();
+  aMessenger << "Level: " << theCurrentLevel << "(Single, no alerts on the level)" << Message_EndLine;
+
+  for (int i = 0; i < 2; i++)
+    levelAlerts (theCurrentLevel + 1, theTopLevel);
+}
+
+// =======================================================================
+// function : OnTestMessenger
+// purpose :
+// =======================================================================
+void MessageView_ActionsTest::OnTestReportTree()
+{
+  MESSAGE_ADD_LEVEL_SENTRY
+  MESSAGE_INFO ("MessageModel_Actions::OnTestReportTree()");
+
+  const Handle(Message_Messenger)& aMessenger = Message::DefaultMessenger();
+
+  // string messages
+  //aMessenger << "Alert: " << 1 << Message_EndLine;
+  //aMessenger << "Alert: " << 2 << Message_EndLine;
+
+  int aTopLevel = 3;
+  levelAlerts (1, aTopLevel);
+
+  //aMessenger << "Alert: " << 3 << Message_EndLine;
+  //levelAlerts (1, aTopLevel);
+
+  aMessenger << "Alert: " << 4 << Message_EndLine;
+  levelAlert (1, aTopLevel);
+
+  myTreeModel->UpdateTreeModel();
+}
+
diff --git a/tools/MessageView/MessageView_ActionsTest.hxx b/tools/MessageView/MessageView_ActionsTest.hxx
new file mode 100644 (file)
index 0000000..5494381
--- /dev/null
@@ -0,0 +1,82 @@
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#ifndef MessageView_ActionsTest_H
+#define MessageView_ActionsTest_H
+
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Transient.hxx>
+
+#include <inspector/MessageModel_ActionType.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QObject>
+#include <QMap>
+#include <QModelIndexList>
+#include <QPoint>
+#include <QString>
+#include <Standard_WarningsRestore.hxx>
+
+class Message_Report;
+class MessageModel_TreeModel;
+class QItemSelectionModel;
+
+class QAction;
+class QWidget;
+class QMenu;
+
+//! \class MessageView_ActionsTest
+//! Window that unites all MessageView controls.
+class MessageView_ActionsTest : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  MessageView_ActionsTest (QWidget* theParent, MessageModel_TreeModel* theTreeModel, QItemSelectionModel* theModel);
+
+  //! Destructor
+  virtual ~MessageView_ActionsTest() {}
+
+  //! Fills popup menu with actions depending on the current selection
+  //! \param theSelectedIndices tree model selected indices
+  //! \param theMenu menu to be filled
+  Standard_EXPORT void AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu);
+
+public slots:
+  //! Sending several alerts to check metric of message-alert-tool mechanizm
+  void OnTestMetric();
+
+  //! Sending several alerts to check property panel/presentations of message-alert-tool mechanizm
+  void OnTestPropertyPanel();
+
+  //! Sending several alerts to check property panel/presentations of messenger-alert-tool mechanizm
+  void OnTestMessenger();
+
+  //! Check tree of alerts
+  void OnTestReportTree();
+
+protected:
+  //! Returns report of selected tree view item if a report item is selected
+  //! \param theReportIndex tree model index of the found report
+  //! \return report instance or NULL
+  Handle(Message_Report) getSelectedReport (QModelIndex& theReportIndex) const;
+
+protected:
+  MessageModel_TreeModel* myTreeModel; //< tree model
+  QItemSelectionModel* mySelectionModel; //< selection model
+  QMap<MessageModel_ActionType, QAction*> myActions; //!< container of all actions
+};
+
+#endif
index 2164e2257bfe3a8da2fd04f52569fbe46f069c9c..7d93c21b55ad99902289dde1a4540fd4aa459fa7 100644 (file)
@@ -16,7 +16,6 @@
 #ifndef MessageView_Communicator_H
 #define MessageView_Communicator_H
 
-#include <inspector/MessageModel_ReportCallBack.hxx>
 #include <inspector/MessageView_Window.hxx>
 #include <inspector/TInspectorAPI_Communicator.hxx>
 
@@ -27,8 +26,7 @@ class MessageView_Communicator : public TInspectorAPI_Communicator
 public:
 
   //! Constructor
-  MessageView_Communicator() : TInspectorAPI_Communicator(), myWindow (new MessageView_Window (0))
-  { myWindow->SetCallBack (new MessageModel_ReportCallBack (this)); }
+  MessageView_Communicator() : TInspectorAPI_Communicator(), myWindow (new MessageView_Window (0)) {}
 
   //! Destructor
   virtual ~MessageView_Communicator() Standard_OVERRIDE {}
index 14c000b7d6fa6153f0e8de5b8dcc8f38dfdde518..fdc1cc8ecefa00162055bcab7ef462b0d2a7d8aa 100644 (file)
 
 #include <inspector/MessageView_Window.hxx>
 #include <inspector/MessageView_VisibilityState.hxx>
+#include <inspector/MessageView_ActionsTest.hxx>
 
 #include <inspector/MessageModel_Actions.hxx>
 #include <inspector/MessageModel_ItemAlert.hxx>
 #include <inspector/MessageModel_ItemReport.hxx>
 #include <inspector/MessageModel_ItemRoot.hxx>
-#include <inspector/MessageModel_ReportCallBack.hxx>
 #include <inspector/MessageModel_Tools.hxx>
 #include <inspector/MessageModel_TreeModel.hxx>
 
 #include <AIS_Shape.hxx>
 #include <Graphic3d_Camera.hxx>
 #include <OSD_Environment.hxx>
-
 #include <OSD_Directory.hxx>
 #include <OSD_Protection.hxx>
-
+#include <Message.hxx>
 #include <TCollection_AsciiString.hxx>
-//#include <TopoDS_AlertWithShape.hxx>
+
+#define DEBUG_ALERTS
 
 #include <XmlDrivers_MessageReportStorage.hxx>
 
@@ -150,13 +150,8 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
   ((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (MESSAGEVIEW_DEFAULT_TREE_VIEW_WIDTH,
                                                                  MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT));
   MessageModel_TreeModel* aModel = new MessageModel_TreeModel (myTreeView);
+  aModel->InitColumns();
   //aModel->SetReversed (Standard_True);
-  for (int i = 6; i <= 8; i++) // hide shape parameters columns
-  {
-    TreeModel_HeaderSection anItem = aModel->GetHeaderItem (i);
-    anItem.SetIsHidden (true);
-    aModel->SetHeaderItem (i, anItem);
-  }
 
   myTreeView->setModel (aModel);
   MessageView_VisibilityState* aVisibilityState = new MessageView_VisibilityState (aModel);
@@ -172,10 +167,12 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
            this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
 
   myTreeViewActions = new MessageModel_Actions (myMainWindow, aModel, aSelectionModel);
+  myTestViewActions = new MessageView_ActionsTest (myMainWindow, aModel, aSelectionModel);
+
   myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
   connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
           this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
-  new TreeModel_ContextMenu (myTreeView);
+  //new TreeModel_ContextMenu (myTreeView);
 
   QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
   myTreeView->setExpanded (aParentIndex, true);
@@ -209,6 +206,8 @@ MessageView_Window::MessageView_Window (QWidget* theParent)
 
   myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
   myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
+
+  updateVisibleColumns();
 }
 
 // =======================================================================
@@ -257,7 +256,7 @@ 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);
+  //TreeModel_Tools::SaveState (myTreeView, anItems);
   View_Tools::SaveState (myViewWindow, anItems);
 
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
@@ -280,8 +279,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 (View_Tools::RestoreState (myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
   }
@@ -313,11 +312,10 @@ void MessageView_Window::UpdateContent()
     myParameters->SetFileNames (aName, aNames);
     isUpdated = true;
   }
-  Handle(Message_Report) aDefaultReport = Message_Report::CurrentReport( Standard_False);
+  Handle(Message_Report) aDefaultReport = Message::DefaultReport (Standard_False);
   MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   if (!aDefaultReport.IsNull() && !aViewModel->HasReport (aDefaultReport))
   {
-    aDefaultReport->SetCallBack (myCallBack);
     addReport (aDefaultReport);
   }
   // reload report of selected item
@@ -335,7 +333,6 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
   Handle(AIS_InteractiveContext) aContext;
   NCollection_List<Handle(Standard_Transient)> aParameters;
 
-  Handle(Message_ReportCallBack) aReportCallBack;
   Handle(Graphic3d_Camera) aViewCamera;
 
   for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters);
@@ -345,7 +342,6 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
     Handle(Message_Report) aMessageReport = Handle(Message_Report)::DownCast (anObject);
     if (!aMessageReport.IsNull())
     {
-      aMessageReport->SetCallBack (myCallBack);
       addReport (aMessageReport);
     }
     else if (!Handle(AIS_InteractiveContext)::DownCast (anObject).IsNull())
@@ -368,7 +364,7 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
   if (!aContext.IsNull())
   {
     myViewWindow->SetContext (View_ContextType_External, aContext);
-    myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External);
+    //myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External);
   }
 
   if (!aViewCamera.IsNull())
@@ -412,6 +408,8 @@ void MessageView_Window::addReport (const Handle(Message_Report)& theReport,
 {
   MessageModel_TreeModel* aModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
   aModel->AddReport (theReport, theReportDescription);
+
+  updateVisibleColumns();
 }
 
 // =======================================================================
@@ -492,7 +490,14 @@ void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePositi
      }
   }
   aMenu->addSeparator();
+
   myTreeViewActions->AddMenuActions (aSelectedIndices, aMenu);
+  addActivateMetricActions (aMenu);
+
+#ifdef DEBUG_ALERTS
+  aMenu->addSeparator();
+  myTestViewActions->AddMenuActions (aSelectedIndices, aMenu);
+#endif
 
   QPoint aPoint = myTreeView->mapToGlobal (thePosition);
   aMenu->exec (aPoint);
@@ -635,6 +640,9 @@ void MessageView_Window::onImportReport()
   QString aFilter (tr ("Document file (*.cbf *)"));
   QString aSelectedFilter;
 
+  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+  aSelectionModel->clear();
+
   QString aFileName = QFileDialog::getOpenFileName (0, tr("Import report"), QString(), aSelectedFilter);
   openFile (TCollection_AsciiString (aFileName.toStdString().c_str()));
 }
@@ -663,7 +671,6 @@ void MessageView_Window::onSetReversedAlerts()
   aTreeModel->SetReversed (!isReversed);
 }
 
-
 // =======================================================================
 // function : onReloadReport
 // purpose :
@@ -694,6 +701,65 @@ void MessageView_Window::onReloadReport()
   aTreeModel->SetReport (aReportItem->Row(), aReport, aDescription);
 }
 
+// =======================================================================
+// function : addActivateMetricActions
+// purpose :
+// =======================================================================
+void MessageView_Window::addActivateMetricActions (QMenu* theMenu)
+{
+  QMenu* aSubMenu = new QMenu ("Activate metric");
+
+  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+
+  for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
+  {
+    Message_MetricType aMetricType = (Message_MetricType)aMetricId;
+    QAction* anAction = ViewControl_Tools::CreateAction (Message::MetricToString (aMetricType),
+      SLOT (OnActivateMetric()), parent(), this);
+    anAction->setCheckable (true);
+    anAction->setChecked (aReport->ActiveMetrics().Contains (aMetricType));
+    aSubMenu->addAction (anAction);
+  }
+  aSubMenu->addSeparator();
+  aSubMenu->addAction (ViewControl_Tools::CreateAction ("Deactivate all", SLOT (OnDeactivateAllMetrics()), parent(), this));
+
+  theMenu->addMenu (aSubMenu);
+}
+
+// =======================================================================
+// function : OnActivateMetric
+// purpose :
+// =======================================================================
+void MessageView_Window::OnActivateMetric()
+{
+  QAction* anAction = (QAction*)(sender());
+
+  Message_MetricType aMetricType;
+  if (!Message::MetricFromString (anAction->text().toStdString().c_str(), aMetricType))
+    return;
+
+  Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
+  const NCollection_Map<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
+
+  aReport->SetActiveMetric (aMetricType, !anActiveMetrics.Contains (aMetricType));
+
+  updateVisibleColumns();
+}
+
+// =======================================================================
+// function : OnDeactivateAllMetrics
+// purpose :
+// =======================================================================
+void MessageView_Window::OnDeactivateAllMetrics()
+{
+  Handle(Message_Report) aReport = Message::DefaultReport();
+  if (aReport.IsNull())
+    return;
+  aReport->ClearMetrics();
+
+  updateVisibleColumns();
+}
+
 // =======================================================================
 // function : onContextSelected
 // purpose :
@@ -784,3 +850,41 @@ void MessageView_Window::updatePreviewPresentation()
   myDisplayPreview->SetContext (aContext);
   myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations);
 }
+
+// =======================================================================
+// function : updateVisibleColumns
+// purpose :
+// =======================================================================
+void MessageView_Window::updateVisibleColumns()
+{
+  MessageModel_TreeModel* aViewModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
+  const NCollection_List<MessageModel_ReportInformation>& aReports = aViewModel->Reports();
+
+  NCollection_Map<Message_MetricType> anActiveMetrics;
+  for (NCollection_List<MessageModel_ReportInformation>::Iterator anIterator (aViewModel->Reports()); anIterator.More(); anIterator.Next())
+  {
+    Handle(Message_Report) aReport = anIterator.Value().myReport;
+    for (NCollection_Map<Message_MetricType>::Iterator aMetricsIterator (aReport->ActiveMetrics()); aMetricsIterator.More(); aMetricsIterator.Next())
+    {
+      if (anActiveMetrics.Contains (aMetricsIterator.Value()))
+        continue;
+      anActiveMetrics.Add (aMetricsIterator.Value());
+    }
+  }
+
+  for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
+  {
+    Message_MetricType aMetricType = (Message_MetricType)aMetricId;
+    QList<int> aMetricColumns;
+    aViewModel->GetMetricColumns (aMetricType, aMetricColumns);
+    bool isColumnHidden = !anActiveMetrics.Contains (aMetricType);
+    for (int i = 0; i < aMetricColumns.size(); i++)
+    {
+      int aColumnId = aMetricColumns[i];
+      myTreeView->setColumnHidden (aColumnId, isColumnHidden);
+      TreeModel_HeaderSection aSection = aViewModel->GetHeaderItem (aColumnId);
+      aSection.SetIsHidden (isColumnHidden);
+      aViewModel->SetHeaderItem (aColumnId, aSection);
+    }
+  }
+}
index a602fe7e471d84dd6fa14def44c294df7c3fab16..dbf98b78ed6e902f572bc6ef129ad84ee6c904c7 100644 (file)
@@ -42,10 +42,12 @@ class View_Window;
 
 class View_DisplayPreview;
 class ViewControl_PropertyView;
-class MessageModel_ReportCallBack;
+
+class MessageView_ActionsTest;
 
 class QDockWidget;
 class QMainWindow;
+class QMenu;
 class QWidget;
 
 //! \class MessageView_Window
@@ -71,10 +73,6 @@ public:
   void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
   { myParameters = theParameters; myTreeViewActions->SetParameters (theParameters); }
 
-  //! Sets message callback to update the current content of the view
-  //! \param theCallBack
-  void SetCallBack (const Handle(Message_ReportCallBack)& theCallBack) { myCallBack = theCallBack; }
-
   //! Provide container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
   Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
@@ -161,16 +159,28 @@ protected slots:
   //! Reads if possible report of a selected item and updates this report in tree view
   void onReloadReport();
 
+  //! Switch active state in report for clicked type of metric
+  void OnActivateMetric();
+
+  //! Deactivate all types of metrics for the current report
+  void OnDeactivateAllMetrics();
+
   //! Updates context in preview display
   void onContextSelected();
 
 protected:
+  //! Appends items to activate report metrics
+  void addActivateMetricActions (QMenu* theMenu);
+
   //! Updates property panel content by item selected in tree view.
   void updatePropertyPanelBySelection();
 
   //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes
   void updatePreviewPresentation();
 
+  //!< Sets reports metric columns visible if used
+  void updateVisibleColumns();
+
 private:
   QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls
   QDockWidget* myViewDockWidget; //!< view dock widget to hide/show
@@ -183,9 +193,9 @@ private:
   View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
   QTreeView* myTreeView; //!< tree view visualized shapes
   MessageModel_Actions* myTreeViewActions; //!< processing history view actions
+  MessageView_ActionsTest* myTestViewActions; //!< check view actions
 
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
-  Handle(Message_ReportCallBack) myCallBack; //! < message call back to update content of the view
 
   Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
 };
index c660eab22bf8eaa8035140ea21bb1a0aeb689d9b..81f3b1d35107acd129783bb95e5ccbb28c034a69 100644 (file)
 // commercial license or contractual agreement. 
 
 #include <inspector/ShapeView_ItemBase.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant ShapeView_ItemBase::initValue (const int theItemRole) const
-{
-  if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
-    return QVariant();
-
-  switch (Column())
-  {
-    case 2: { return rowCount(); }
-    //case 3: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
-    case 4: { return Row(); }
-  }
-
-  return QVariant();
-}
index 27b09eb925ddf2bdf09d2ecf6c6ff00ba7b203f9..3e0559c50192ccc24960ec0d3a7efa2c32acdefc 100644 (file)
@@ -32,11 +32,6 @@ public:
   //! Resets cached values
   virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
 
-  //! Return data value for the role.
-  //! \param theRole a value role
-  //! \return the value
-  Standard_EXPORT virtual QVariant initValue(const int theRole) const;
-
 protected:
 
   //! Initialize the current item. It creates a backup of the specific item information
index 1783cb511535c21b2a1cfd762f4f8112b694c91e..4dec90d239536e6e7a25fc695f4ffb2bff00680c 100644 (file)
@@ -81,10 +81,6 @@ QVariant ShapeView_ItemShape::initValue(const int theRole) const
   switch (Column())
   {
     case 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
-    //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
-    case 3: return TShapePointer().ToCString();
-    case 5: return TopAbs::ShapeOrientationToString (aShape.Orientation());
-    case 6: return ViewControl_Tools::ToString (aShape.Location()).ToCString();
     default: break;
   }
   return QVariant();
@@ -115,6 +111,19 @@ int ShapeView_ItemShape::initRowCount() const
   return aRowsCount;
 }
 
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::initStream (Standard_OStream& theOStream) const
+{
+  TopoDS_Shape aShape = getShape();
+  if (aShape.IsNull())
+    return;
+
+  aShape.DumpJson (theOStream);
+}
+
 // =======================================================================
 // function : createChild
 // purpose :
@@ -135,6 +144,7 @@ void ShapeView_ItemShape::Init()
   myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
 
   //SetProperties (createItemProperties());
+  TreeModel_ItemBase::Init();
 }
 
 // =======================================================================
index 24cbb8bd890afc0aee9bfe225f6a1e7f8bf4beff..ce7871de9453554cc9a709b910944508deaa565c 100644 (file)
@@ -91,6 +91,10 @@ public:
   //! \return number of children.
   Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
 
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
+
 protected:
 
   //! Initialize the current item. It is empty because Reset() is also empty.
index 8b39f592cd032e5cfc2b7d6c35aac88f3503c52b..288b20c6a03b3a17467bee7eb3901449d5c96336 100644 (file)
 #include <inspector/ShapeView_ItemRoot.hxx>
 #include <inspector/ShapeView_ItemShape.hxx>
 
-const int COLUMN_NAME_WIDTH = 190;
-const int COLUMN_SIZE_WIDTH = 30;
-const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
-
-const int COLUMN_ORIENTATION_WIDTH = 70;
-const int COLUMN_LOCATION_WIDTH = 120;
-
 // =======================================================================
 // function : Constructor
 // purpose :
@@ -34,24 +26,15 @@ const int COLUMN_LOCATION_WIDTH = 120;
 ShapeView_TreeModel::ShapeView_TreeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  // column 1 is reserved for visiblity state
-  SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (5, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
-  SetHeaderItem (6, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void ShapeView_TreeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr ShapeView_TreeModel::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
index 7778ad535d2e479594ee93c2301275d155c130e0..13954d5ea7c719f95f16e8bcc877d7f343e29fe2 100644 (file)
@@ -47,12 +47,6 @@ public:
   //! Remove all shapes in the model root item
   Standard_EXPORT void RemoveAllShapes();
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE
-  { return myRootItems[theColumn]; }
-
   //! Returns model index of the shape.
   //! \param theShape a shape object
   //! \return the model index
@@ -61,10 +55,8 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
-private:
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
 };
 
 #endif
index 9d4ec97dfd39e4762274c0cea15fc891c0f26757..1e19a0e4940cba7d1152c2c52e43ad0415a8d878 100644 (file)
@@ -63,6 +63,9 @@
 #include <QVBoxLayout>
 #include <Standard_WarningsRestore.hxx>
 
+#include <Message_Alerts.hxx>
+#include <Message_Level.hxx>
+
 const int DEFAULT_TEXT_VIEW_WIDTH = 800;
 const int DEFAULT_TEXT_VIEW_HEIGHT = 700;
 const int DEFAULT_TEXT_VIEW_POSITION_X = 430;
@@ -85,7 +88,7 @@ const int SHAPEVIEW_DEFAULT_VIEW_HEIGHT = 1000;
 // purpose :
 // =======================================================================
 ShapeView_Window::ShapeView_Window (QWidget* theParent)
-: QObject (theParent), myNextPosition (0)
+: QObject (theParent)
 {
   myMainWindow = new QMainWindow (theParent);
 
@@ -97,13 +100,7 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
           this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
   new TreeModel_ContextMenu (myTreeView);
   ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
-  for (int i = 5; i <= 6; i++) // hide shape parameters columns
-  {
-    TreeModel_HeaderSection anItem = aModel->GetHeaderItem (i);
-    anItem.SetIsHidden (true);
-    aModel->SetHeaderItem (i, anItem);
-  }
-
+  aModel->InitColumns();
 
   myTreeView->setModel (aModel);
   ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
@@ -153,7 +150,6 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
 // =======================================================================
 ShapeView_Window::~ShapeView_Window()
 {
-  onCloseAllBREPViews();
 }
 
 // =======================================================================
@@ -341,8 +337,6 @@ void ShapeView_Window::RemoveAllShapes()
 {
   ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
   aModel->RemoveAllShapes();
-
-  onCloseAllBREPViews();
 }
 
 // =======================================================================
@@ -377,10 +371,7 @@ void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition
     aMenu->addAction (ViewControl_Tools::CreateAction ("Remove all shape items", SLOT (onClearView()), myMainWindow, this));
   }
   else {
-    if (!GetTemporaryDirectory().IsEmpty())
-      aMenu->addAction (ViewControl_Tools::CreateAction ("BREP view", SLOT (onBREPView()), myMainWindow, this));
-    aMenu->addAction (ViewControl_Tools::CreateAction ("Close All BREP views", SLOT (onCloseAllBREPViews()), myMainWindow, this));
-    aMenu->addAction (ViewControl_Tools::CreateAction ("BREP directory", SLOT (onBREPDirectory()), myMainWindow, this));
+    aMenu->addAction (ViewControl_Tools::CreateAction ("Export to BREP", SLOT (onExportToBREP()), myMainWindow, this));
     aMenu->addAction (ViewControl_Tools::CreateAction ("ShapeFix_Shape", SLOT (onShapeFixShape()), myMainWindow, this));
 
     ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
@@ -443,20 +434,6 @@ void ShapeView_Window::onEraseAllPerformed()
   aTreeModel->EmitLayoutChanged();
 }
 
-// =======================================================================
-// function : onBREPDirectory
-// purpose :
-// =======================================================================
-void ShapeView_Window::onBREPDirectory()
-{
-  QString aFilter (tr ("BREP file (*.brep*)"));
-  QString aSelectedFilter;
-  QString aFileName = QFileDialog::getOpenFileName (0, tr ("Export shape to BREP file"),
-                                                    GetTemporaryDirectory().ToCString(), aSelectedFilter);
-  if (!aFileName.isEmpty())
-    viewFile (aFileName);
-}
-
 // =======================================================================
 // function : onExplode
 // purpose :
@@ -483,6 +460,7 @@ void ShapeView_Window::onShapeFixShape()
   Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape (aShape);
   Fixer->SetPrecision (LinTol);
   Fixer->SetMaxTolerance (LinTol);
+
   Fixer->Perform();
 
   TopoDS_Shape aFixedShape = Fixer->Shape();
@@ -548,13 +526,14 @@ void ShapeView_Window::onLoadFile()
 }
 
 // =======================================================================
-// function : onBREPView
+// function : onExportToBREP
 // purpose :
 // =======================================================================
-void ShapeView_Window::onBREPView()
+void ShapeView_Window::onExportToBREP()
 {
-  if (GetTemporaryDirectory().IsEmpty())
-    return;
+  QString aFilter (tr ("Boundary representation file (*.brep *)"));
+  QString aSelectedFilter;
+  QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export shape to file"), QString(), aFilter, &aSelectedFilter);
 
   QItemSelectionModel* aModel = myTreeView->selectionModel();
   if (!aModel)
@@ -573,90 +552,36 @@ void ShapeView_Window::onBREPView()
   if (!anItem)
     return;
 
-  QString aFileName = anItem->GetFileName();
-  QDir aDir;
-  if (aFileName.isEmpty() || !aDir.exists (aFileName))
-  {
-    TCollection_AsciiString aFileNameIndiced = GetTemporaryDirectory() + TCollection_AsciiString ("\\") +
-                                               getNextTmpName (anItem->TShapePointer());
-    const TopoDS_Shape& aShape = anItem->GetItemShape();
-    BRepTools::Write (aShape, aFileNameIndiced.ToCString());
-    anItem->SetFileName (aFileNameIndiced.ToCString());
-    aFileName = aFileNameIndiced.ToCString();
-  }
-  viewFile (aFileName);
-}
-
-// =======================================================================
-// function : onCloseAllBREPViews
-// purpose :
-// =======================================================================
-void ShapeView_Window::onCloseAllBREPViews()
-{
-  removeBREPFiles();
-
-  for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
-    delete myBREPViews[aViewId];
-
-  myBREPViews.clear();
+  TCollection_AsciiString aFileNameIndiced = aFileName.toStdString().c_str();
+  const TopoDS_Shape& aShape = anItem->GetItemShape();
+  BRepTools::Write (aShape, aFileNameIndiced.ToCString());
+  anItem->SetFileName (aFileNameIndiced.ToCString());
+  aFileName = aFileNameIndiced.ToCString();
 }
 
 // =======================================================================
-// function : onEditorDestroyed
+// function : updatePropertyPanelBySelection
 // purpose :
 // =======================================================================
-void ShapeView_Window::onEditorDestroyed(QObject* theObject)
+void ShapeView_Window::updatePropertyPanelBySelection()
 {
-  QWidget* aWidget = dynamic_cast<QWidget*> (theObject);
+  QItemSelectionModel* aModel = myTreeView->selectionModel();
+  if (!aModel)
+    return;
 
-  for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
-  {
-    if (myBREPViews[aViewId] == aWidget)
-      myBREPViews.removeAll(aWidget);
-  }
-}
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+  if (!anItemBase)
+    return;
 
-// =======================================================================
-// function : viewFile
-// purpose :
-// =======================================================================
-void ShapeView_Window::viewFile (const QString& theFileName)
-{
-  QApplication::setOverrideCursor (Qt::WaitCursor);
-  QString aFileText;
-  QFile aFile (theFileName);
-  if (aFile.open (QIODevice::ReadOnly | QIODevice::Text))
+  Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties ();
+  ViewControl_TableModelValues* aTableValues = 0;
+  if (!anItemProperties.IsNull())
   {
-    QTextStream aStream(&aFile);
-    QString aLine = aStream.readLine();
-    while (!aLine.isNull())
-    {
-      aLine = aStream.readLine();
-      aFileText.append (aLine + QString ("\n"));
-    }
-    if (!aFileText.isEmpty())
-    {
-      QPlainTextEdit* anEditor = new QPlainTextEdit (0);
-      anEditor->setAttribute (Qt::WA_DeleteOnClose, true);
-      connect (anEditor, SIGNAL (destroyed(QObject*)), this, SLOT (onEditorDestroyed(QObject*)));
-      anEditor->setPlainText (aFileText);
-      anEditor->resize (DEFAULT_TEXT_VIEW_WIDTH, DEFAULT_TEXT_VIEW_HEIGHT);
-      anEditor->move (DEFAULT_TEXT_VIEW_POSITION_X + myNextPosition, DEFAULT_TEXT_VIEW_POSITION_Y);
-      myNextPosition += DEFAULT_TEXT_VIEW_DELTA;
-      anEditor->show();
-      myBREPViews.append (anEditor);
-    }
+    aTableValues = new ViewControl_TableModelValues();
+    aTableValues->SetProperties (anItemProperties);
   }
-  QApplication::restoreOverrideCursor();
-}
-
-
-// =======================================================================
-// function : updatePropertyPanelBySelection
-// purpose :
-// =======================================================================
-void ShapeView_Window::updatePropertyPanelBySelection()
-{
+  myPropertyView->Init (aTableValues);
   /*QItemSelectionModel* aModel = myTreeView->selectionModel();
   if (!aModel)
     return;
@@ -671,31 +596,3 @@ void ShapeView_Window::updatePropertyPanelBySelection()
   }
   myPropertyView->Init (aTableValues);*/
 }
-
-// =======================================================================
-// function : removeBREPFiles
-// purpose :
-// =======================================================================
-void ShapeView_Window::removeBREPFiles()
-{
-  QDir aDir (GetTemporaryDirectory().ToCString());
-
-  QStringList anEntries = aDir.entryList();
-  QString aPrefix(viewBREPPrefix().ToCString());
-  for (int anEntryId = 0, aSize = anEntries.size(); anEntryId < aSize; anEntryId++)
-  {
-    if (anEntries[anEntryId].contains (aPrefix))
-      aDir.remove (anEntries[anEntryId]);
-  }
-}
-
-// =======================================================================
-// function : getNextTmpName
-// purpose :
-// =======================================================================
-TCollection_AsciiString ShapeView_Window::getNextTmpName (const TCollection_AsciiString& thePointerInfo)
-{
-  TCollection_AsciiString aTmpName(viewBREPPrefix());
-  aTmpName += thePointerInfo;
-  return aTmpName;
-}
index 4ff8cd245f750b9d172dff14c4a152a7a193328d..d022a98a23b4e91e187300c9fd032cf95d8630b2 100644 (file)
@@ -83,9 +83,6 @@ public:
   //! Returns current tree view
   QTreeView* GetTreeView() const { return myTreeView; }
 
-  //! Returns path to temporary directory
-  TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
-
   //! Removes all shapes in tree view model, remove all stored BREP files
   Standard_EXPORT void RemoveAllShapes();
 
@@ -120,9 +117,6 @@ protected slots:
   //! Updates visibility states by erase all in context
   void onEraseAllPerformed();
 
-  //! Exports shape to BREP file and view result file
-  void onBREPDirectory();
-
   //! Perform shape fix for the selected shape. Result is a new shape in the tree.
   void onShapeFixShape();
 
@@ -136,13 +130,7 @@ protected slots:
   void onLoadFile();
 
   //! View BREP files of selected items if exist
-  void onBREPView();
-
-  //! Remove BREP views, close views
-  void onCloseAllBREPViews();
-
-  //! Remove all BREP Viewse excepting active
-  void onEditorDestroyed (QObject* theObject);
+  void onExportToBREP();
 
   //! Convers file name to Ascii String and perform opeging file
   //! \param theFileName a file name to be opened
@@ -153,27 +141,11 @@ protected:
   //! Updates property panel content by item selected in tree view.
   void updatePropertyPanelBySelection();
 
-  //! Views file name content in a text editor. It creates new Qt free control with content.
-  //! \param theFileName a file name
-  void viewFile (const QString& theFileName);
-
-  //! Removes all BREP files in tmp directory
-  void removeBREPFiles();
-
   //! Creates new action and connect it to the given slot
   //! \param theText an action text
   //! \param theSlot a listener method
   QAction* createAction (const QString& theText, const char* theSlot);
 
-  //! Key that uses to generate BREP file name
-  //! \return string value
-  static TCollection_AsciiString viewBREPPrefix() { return "ShapeView_Window"; }
-
-  //! Returns newxt temporary name using BREPPrefix and pointer information
-  //! \param thePointerInfo a pointer value
-  //! \return string value
-  TCollection_AsciiString getNextTmpName (const TCollection_AsciiString& thePointerInfo);
-
 private:
 
   QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
@@ -184,9 +156,6 @@ private:
   View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
   QTreeView* myTreeView; //!< tree view visualized shapes
 
-  int myNextPosition; //!< delta of moving control of view BREP file
-
-  QList<QWidget*> myBREPViews; //!< list of view BREP file controls
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
 };
 
index 1c42a38530772e9c4ba7d3af93f7ca9286716d2b..14050121ae9fc1ef1d72f4ca83c06f44b04e757f 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <inspector/TInspector_Communicator.hxx>
 
+#include <Message.hxx>
 #include <Message_Report.hxx>
 #include <OSD_Environment.hxx>
 
@@ -126,9 +127,8 @@ int main (int argc, char** argv)
     aPlugins.insert("TKShapeView");
     aPlugins.insert("TKVInspector");
 
-    Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True);
+    Handle(Message_Report) aReport = Message::DefaultReport (Standard_True);
     aReport->SetLimit (100);//30);
-    aReport->SetActive (Standard_True);//Standard_False);
     aPlugins.insert("TKMessageView");
 
     anActivatedPluginName = "TKVInspector";
index 31b62c871eb92177eb4c65c6152a22f099e0edff..58ca97a08445c91920aa973c939590a8214d6b57 100644 (file)
@@ -192,9 +192,7 @@ QVariant TreeModel_ItemBase::initValue (const int theItemRole) const
 
   switch (Column())
   {
-    case 1: { return rowCount(); }
-    //case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
-    case 3: { return Row(); }
+    case 1: { return Row(); }
   }
 
   return QVariant();
index 9a2d40fd6bc511a9850ae861c4e697470ddf7287..504641749221b5d16f6f6df58d78cbe0630979f9 100644 (file)
 #include <QIcon>
 #include <Standard_WarningsRestore.hxx>
 
+const int COLUMN_NAME_WIDTH = 260;
+const int COLUMN_SIZE_WIDTH = 30;
+
 // =======================================================================
 // function : Constructor
 // purpose :
 // =======================================================================
 TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
-: QAbstractItemModel (theParent), m_pRootItem (0), m_pUseVisibilityColumn (false),
+: QAbstractItemModel (theParent), m_pUseVisibilityColumn (false),
   myVisibilityState (0)
 {
   myVisibleIcon = QIcon (":/icons/item_visible.png");
   myInvisibleIcon = QIcon (":/icons/item_invisible.png");
 }
 
+// =======================================================================
+// function :  InitColumns
+// purpose :
+// =======================================================================
+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));
+}
+
 // =======================================================================
 // function :  GetItemByIndex
 // purpose :
@@ -217,6 +231,23 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
 #endif
 }
 
+// =======================================================================
+// function : GetSelected
+// 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 : GetSelected
 // purpose :
@@ -264,6 +295,15 @@ QList<TreeModel_ItemBasePtr> TreeModel_ModelBase::GetSelectedItems (const QModel
   return anItems;
 }
 
+// =======================================================================
+// function : createRoot
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::createRoot (const int theColumnId)
+{
+  myRootItems.insert (theColumnId, createRootItem (theColumnId));
+}
+
 // =======================================================================
 // function :  getIndexValue
 // purpose :
index f38b266f5c51fe54cff00cbe9ec27b5412a5e0d9..8042fc7c6eb64435bfd89a7844ca7816614ca8a4 100644 (file)
@@ -50,6 +50,10 @@ public:
   //! Destructor
   virtual ~TreeModel_ModelBase() {}
 
+  //! Creates model columns and root items.
+  //! Default columns are: [0] - Name, [1] - Visibility, [2] - Row
+  Standard_EXPORT virtual void InitColumns();
+
   //! Returns the item shared pointer by the model index
   //! if it is in the index internal pointer
   //! @param theIndex a model index
@@ -61,7 +65,7 @@ public:
 
   //! Returns the model root item.
   //! It is realized for OCAFBrowser
-  virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const { (void)theColumn; return m_pRootItem; }
+  TreeModel_ItemBasePtr RootItem (const int theColumn) const { return myRootItems[theColumn]; }
 
   //! Emits the layoutChanged signal from outside of this class
   Standard_EXPORT void EmitLayoutChanged();
@@ -142,8 +146,7 @@ public:
   //! Set header properties item.
   //! \param theColumnId a column index
   //! \param theSection a section value
-  void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
-  { myHeaderValues[theColumnId] = theSection; createRootItem (theColumnId); }
+  Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
 
   //! Returns count of columns in the model
   //! \param theParent an index of the parent item
@@ -181,16 +184,21 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) = 0;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0;
 
   //! Converts the item shared pointer to void* type
   //! \param theItem
   //!  \return an item pointer
   Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem);
 
+private:
+  //! Creates root item
+  //! \param theColumnId index of a column
+  Standard_EXPORT void createRoot (const int theColumnId);
+
 protected:
 
-  TreeModel_ItemBasePtr m_pRootItem; //!< the model root item. It should be created in the
+  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
   QMap<int, TreeModel_HeaderSection> myHeaderValues; //!< header values
   //!< model subclass. The model is fulfilled by this item content
 
index 56158a401804fe495c397fb57b0c27690c3a34af..f3aed4ba2ea878cc6f6ae5c184e2cc4d47c47ece 100644 (file)
@@ -40,9 +40,7 @@ QVariant VInspector_ItemBase::initValue (const int theItemRole) const
 
   switch (Column())
   {
-    case 1: { return rowCount(); }
-    case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
-    case 3: { return Row(); }
+    case 3: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
   }
 
   return QVariant();
index 57445893a3dd7ba5294386c56f4efa481b74e834..36d48179785a323f72645e23a542242d78fd75db 100644 (file)
@@ -26,8 +26,6 @@
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
-//#define DEBUG_FREE_OWNERS
-
 // =======================================================================
 // function : initRowCount
 // purpose :
@@ -39,7 +37,6 @@ int VInspector_ItemContext::initRowCount() const
 
   int aNbProperties = 1; // item to visualize Filters/Drawer information of context
 
-  int aNbPresentations = 0;
   Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (GetObject());
   if (aContext.IsNull())
     return 0;
@@ -47,37 +44,14 @@ int VInspector_ItemContext::initRowCount() const
   AIS_ListOfInteractive aListOfIO;
   aContext->DisplayedObjects (aListOfIO);
   aContext->ErasedObjects(aListOfIO);
-  aNbPresentations = aListOfIO.Extent();
-
-  // owners without Presentation
-#ifdef DEBUG_FREE_OWNERS
-  int aRows = 0;
-  // only local context is processed: TODO for global context
-  NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
-  aContext->MainSelector()->ActiveOwners(anActiveOwners);
-
-  Handle(SelectMgr_EntityOwner) anOwner;
-  for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(anActiveOwners);
-       anOwnersIt.More(); anOwnersIt.Next())
+  int aNbPresentations = 0;
+  for (AIS_ListIteratorOfListOfInteractive aListOfIOIt (aListOfIO); aListOfIOIt.More(); aListOfIOIt.Next())
   {
-    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
-    if (anOwner.IsNull())
-      continue;
-    Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
-    if (anAISObj.IsNull())
-      aRows++;
+    if (aListOfIOIt.Value()->Parent())
+      continue; // child presentation
+    aNbPresentations++;
   }
-  // owners in Global Context
-  NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
-  aContext->MainSelector()->ActiveOwners(anActiveOwners);
-  if (aRows > 0)
-    aNbPresentations += aRows;
-  NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
-  NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
-    VInspector_Tools::ActiveOwners (aContext, anEmptySelectableOwners);
-  if (anEmptySelectableOwners.Size() > 0)
-    aNbPresentations += 1;
-#endif
+
   return aNbProperties + aNbPresentations;
 }
 
index 3bc538d87c6ce8db272a3c684a050ad6ac610961..dfdc713b6ded5b4546172f5996046f0700db9fe9 100644 (file)
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
-const int COLUMN_NAME_WIDTH = 260;
-const int COLUMN_SIZE_WIDTH = 30;
 const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
 
 // =======================================================================
 // function : Constructor
@@ -42,44 +39,27 @@ const int COLUMN_SHAPE_TYPE_WIDTH = 75;
 VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
   : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); // ItemContext, ItemPresentableObject, ItemSelection
-  //SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
-  //SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
-  //SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
-  //SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
-
-  //SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
-  //SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
-  //SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
-  //SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
-
-  //SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
-  //SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
-  //SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
-  //SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
-
-  //SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
-  //SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
-  //SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
-
-  //SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
-
-  //SetHeaderItem (21, TreeModel_HeaderSection ("Owner Location", -1, true)); // ItemEntityOwner
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void VInspector_ViewModel::InitColumns()
+{
+  TreeModel_ModelBase::InitColumns();
+
+  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+  SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void VInspector_ViewModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModel::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
index 55bbecf99627ebfb890dea79b37366f47de0cc91..13873bda01b28d8f2de0cfe0f35ebff82d3658fb 100644 (file)
@@ -49,6 +49,9 @@ public:
   //! Destructor
   virtual ~VInspector_ViewModel() Standard_OVERRIDE {};
 
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
+
   //! Initialize the model by the given context
   //! \param theContext viewer context
   Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
@@ -70,12 +73,6 @@ public:
   //! \return model index if the value is found or Null model index
   Standard_EXPORT QModelIndex FindIndex (const Handle(AIS_InteractiveObject)& thePresentation) const;
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
-  { return myRootItems[theColumn]; }
-
   //! Returns select owners for tree view selected items
   //! \param theSelectionModel a selection model
   //! \param theOwners an output list of owners
@@ -86,14 +83,10 @@ public:
   Standard_EXPORT void UpdateTreeModel();
 
 protected:
-
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
-
-private:
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
 };
 
 #endif
index a8f584ef154d530e8529a86a8cfbb03eb09a19ff..980dc1e865890ff6dbfa76424b1c9dcce94b68a1 100644 (file)
@@ -42,8 +42,18 @@ const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
 // purpose :
 // =======================================================================
 VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
-: TreeModel_ModelBase (theParent)
+: TreeModel_ModelBase (theParent), myHistoryTypesMaxAmount (theHistoryTypesMaxAmount)
 {
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+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));
@@ -55,20 +65,17 @@ VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, co
   for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
   {
     VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot> (myRootItems[aColumnId]);
-    aRootItem->SetHistoryTypesMaxAmount (theHistoryTypesMaxAmount);
+    aRootItem->SetHistoryTypesMaxAmount (myHistoryTypesMaxAmount);
   }
 }
 
-
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void VInspector_ViewModelHistory::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModelHistory::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
index d4215c34755e1fd6423e022abfc5d68bfc1099df..2560246f70e81ad6ab2df9ac4a96165d54905c4c 100644 (file)
@@ -43,6 +43,9 @@ public:
   //! Destructor
   virtual ~VInspector_ViewModelHistory() Standard_OVERRIDE {};
 
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
+
   //! Append new element under the root item
   Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
 
@@ -51,20 +54,14 @@ public:
   //! \param container of strings
   Standard_EXPORT QStringList GetSelectedPointers (const QModelIndex& theIndex);
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE { return myRootItems[theColumn]; }
-
 protected:
 
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
-
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+  int myHistoryTypesMaxAmount; //!< maximum types in history
 };
 
 #endif
index 4d813c729f5c1397f38d930fe52047c0ea27c52c..3eb75f16010193f3013363be9a01fe90506b175a 100644 (file)
@@ -19,7 +19,7 @@
 #include <AIS_Shape.hxx>
 #include <AIS_Trihedron.hxx>
 //#include <BRep_Builder.hxx>
-//#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
 //#include <BRepBuilderAPI_MakeEdge.hxx>
 //#include <BRepBuilderAPI_MakeFace.hxx>
 #include <Geom_Axis2Placement.hxx>
@@ -77,6 +77,8 @@
 #include <QWidget>
 #include <Standard_WarningsRestore.hxx>
 
+#define DEBUG_ALERTS
+
 const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH = 300;//600;
 const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT = 1000;
 
@@ -125,6 +127,7 @@ VInspector_Window::VInspector_Window()
   //((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_TREE_VIEW_WIDTH,
   //                                                               VINSPECTOR_DEFAULT_TREE_VIEW_HEIGHT));
   VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
+  aTreeModel->InitColumns();
   //aTreeModel->AddPropertiesCreator(new VInspector_PropertiesCreator());
   myTreeView->setModel (aTreeModel);
   // hide Visibility column
@@ -166,6 +169,7 @@ VInspector_Window::VInspector_Window()
 
   myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
   VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
+  aHistoryModel->InitColumns();
   myHistoryView->setModel (aHistoryModel);
 
   QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
@@ -700,6 +704,11 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
   aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
   aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
 
+#ifdef DEBUG_ALERTS
+  aMenu->addSeparator();
+  aMenu->addAction (ViewControl_Tools::CreateAction ("Test AddChild", SLOT (OnTestAddChild()), GetMainWindow(), this));
+#endif
+
   QPoint aPoint = myTreeView->mapToGlobal (thePosition);
   aMenu->exec(aPoint);
 }
@@ -1054,6 +1063,24 @@ void VInspector_Window::onCollapseAll()
   }
 }
 
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void VInspector_Window::OnTestAddChild()
+{
+  Handle(AIS_Shape) aPresentation = new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt()));
+
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt (10., 10., 10.))));
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(20., 10., 10.))));
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(30., 10., 10.))));
+
+  View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+  aDisplayer->DisplayPresentation (aPresentation);
+
+  UpdateTreeModel();
+}
+
 // =======================================================================
 // function : UpdateTreeModel
 // purpose :
index 677b9a77a821ed3fc436f25313cfcd94ad0a1b07..ac872852693ae5f0eb3b7ad60cd992f357e76741 100644 (file)
@@ -173,6 +173,9 @@ private slots:
   //! Collapse all levels for all selected items
   void onCollapseAll();
 
+  //! Creates a tree of inherited presentable objects
+  void OnTestAddChild();
+
 private:
 
   //! Inits the window content by the given context