#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
+#include <Message.hxx>
#include <TDocStd_Document.hxx>
#include <TDF_Label.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_ListIteratorOfAttributeDeltaList.hxx>
#include <Standard_DomainError.hxx>
+#include <XmlDrivers_MessageReportStorage.hxx>
//=======================================================================
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
"DumpCommand (DOC)",
__FILE__, DDocStd_DumpCommand, g);
+ theCommands.Add ("WriteReport",
+ "WriteReport path",
+ __FILE__, DDocStd_WriteReport, g);
+
}
#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>
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 :
__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]"
Message_Algorithm.lxx
Message_Attribute.cxx
Message_Attribute.hxx
+Message_AttributeMeter.cxx
+Message_AttributeMeter.hxx
Message_AttributeObject.cxx
Message_AttributeObject.hxx
Message_AttributeStream.cxx
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
Message_ListOfAlert.hxx
Message_Report.cxx
Message_Report.hxx
-Message_ReportCallBack.cxx
-Message_ReportCallBack.hxx
#include <Message.hxx>
#include <Message_Messenger.hxx>
+#include <Message_Report.hxx>
#include <TCollection_AsciiString.hxx>
#include <stdio.h>
#include <string.h>
+
//=======================================================================
//function : DefaultMessenger
//purpose :
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 :
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;
}
}
}
// =======================================================================
-// 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;
-}
#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>
class Message_ProgressIndicator;
class Message_ProgressScale;
class Message_ProgressSentry;
+class Message_Report;
//! Defines
//! 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",
//! 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:
//function : GetCompositeAlerts
//purpose :
//=======================================================================
-
Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (const Standard_Boolean isCreate)
{
if (myCompositAlerts.IsNull() && isCreate)
}
//=======================================================================
-//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;
}
#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)
//! 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
{
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.
//! 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
#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
{
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.
//! @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
};
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
#include <Message_AttributeObject.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
+IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_Attribute)
//=======================================================================
//function : Message_AttributeObject
//=======================================================================
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;
}
#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
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;
#include <Message.hxx>
#include <Message_Msg.hxx>
-#include <Message_PerfMeter.hxx>
#include <Message_Report.hxx>
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);
}
#include <NCollection_Vector.hxx>
-class Message_PerfMeter;
class Message_Report;
//! Alert object storing container of Standard_Real values in its field
//! 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);
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;
}
//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];
}
//=======================================================================
{
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();
+ }
+ }
+ }
+}
//! 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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
//purpose :
//=======================================================================
Message_Messenger::Message_Messenger ()
+: myOutputGravity (Message_Info)
{
AddPrinter ( new Message_PrinterOStream );
}
//=======================================================================
Message_Messenger::Message_Messenger (const Handle(Message_Printer)& thePrinter)
+: myOutputGravity (Message_Info)
{
AddPrinter (thePrinter);
}
}
}
}
+
+//=======================================================================
+//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);
+ }
+ }
+}
//! 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.
//! 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;
}
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;
}
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;
}
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;
}
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;
}
const Standard_Integer theVal)
{
TCollection_AsciiString aStr (theVal);
- theMessenger->Send (aStr, Message_Info, Standard_False);
+ theMessenger->Send (aStr, theMessenger->OuputGravity(), Standard_False);
return theMessenger;
}
const Standard_Real theVal)
{
TCollection_AsciiString aStr (theVal);
- theMessenger->Send (aStr, Message_Info, Standard_False);
+ theMessenger->Send (aStr, theMessenger->OuputGravity(), Standard_False);
return theMessenger;
}
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;
}
// 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;
}
--- /dev/null
+// 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
+++ /dev/null
-// 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);
-}
+++ /dev/null
-// 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
+++ /dev/null
-// 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
#include <Message_Printer.hxx>
+#include <Standard_Dump.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
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);
+ }
+}
#include <Standard_Transient.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
+#include <Standard_SStream.hxx>
+
class TCollection_ExtendedString;
class TCollection_AsciiString;
//! 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
--- /dev/null
+// 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();
+}
--- /dev/null
+// 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
#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;
+ }
}
//=======================================================================
//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);
}
//=======================================================================
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);
}
//=======================================================================
//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();
}
//=======================================================================
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();
}
//=======================================================================
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();
+ // }
+ // }
+ //}
}
//=======================================================================
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()))
{
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()))
{
}
//=======================================================================
-//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;
}
#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)
//! 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;
//! 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.
//! \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
+++ /dev/null
-// 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 ()
-{
-}
+++ /dev/null
-// 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
// 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;
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();
return;
}
- if (theCounter == MemHeapUsage)
+ if (theCounters.Contains (MemHeapUsage))
{
_HEAPINFO hinfo;
int heapstatus;
#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.
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;
#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);
// 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())
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)
{
//#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)
{
#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
//#define DEBUG_INFO
#ifdef DEBUG_INFO
#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
#endif
namespace
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();
}
#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();
//#define DEBUG_INFO
#ifdef DEBUG_INFO
#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
#endif // DEBUG_INFO
namespace
}
#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();
//#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)
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)
//#define DEBUG_INFO
#ifdef DEBUG_INFO
#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
#endif
namespace
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();
#ifdef DEBUG_INFO
aGroupStream.str("");
OpenGl_Context::DumpJsonOpenGl (aGroupStream);
- MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters2", "", &aPerfMeter, aParentAlert)
+ MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters2")
#endif
}
}
#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
#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
#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)
//#define DEBUG_INFO
#ifdef DEBUG_INFO
#include <Message_Alerts.hxx>
-#include <Message_PerfMeter.hxx>
+#include <Message_Level.hxx>
#endif
namespace
}
#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();
}
#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;
{
#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();
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();
// ==================================
#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();
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();
{
#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();
//#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)
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
//=======================================================================
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())
{
#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>
#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>
{
Handle(Message_Messenger) sout = TP->Messenger();
+#ifdef TRANSLOG
+ //if (TP->TraceLevel() > 1)
+ MESSAGE_ADD_LEVEL_SENTRY
+#endif
Handle(TransferBRep_ShapeBinder) shbinder;
TopoDS_Compound Cund;
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)
#include <TopoDS_AlertAttribute.hxx>
-#include <Message_Msg.hxx>
+#include <Message_PrinterToReport.hxx>
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();
+ }
+}
#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)
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
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;
StartTrace (binder, start, thelevel-1,4);
}
thelevel = oldlev;
+ themessenger->SetOuputGravity (aPrevGravity);
}
}
#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>
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];
}
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;
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);
#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>
#include <TDF_ChildIterator.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
+#include <TopoDS_AlertAttribute.hxx>
+
#include <XmlDrivers.hxx>
// =======================================================================
// 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);
}
}
GetApplication()->SaveAs (aDocument, theFileName);
+ GetApplication()->Close (aDocument);
}
// =======================================================================
// 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);
// 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())
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())
{
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);
+ }
}
// =======================================================================
// =======================================================================
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);
+ }
}
// =======================================================================
// =======================================================================
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;
}
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
--- /dev/null
+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
// =======================================================================
void DFBrowser_Module::CreateViewModel (void* theParent)
{
- myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+ myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent);
+ myOCAFViewModel->InitColumns();
+ myOCAFViewModel->SetModule (this);
}
// =======================================================================
// 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);
}
// 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());
}
// =======================================================================
// =======================================================================
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();
// =======================================================================
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();
}
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)
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;
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:
: 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));
}
}
- 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);
anAttributeNodeItem->setCurrentAttribute (true);
}
}
- aModel->EmitLayoutChanged();
+ myModel->EmitLayoutChanged();
}
// =======================================================================
#include <Standard.hxx>
-class QAbstractItemModel;
+class DFBrowserPane_TDataStdTreeNodeModel;
class QTreeView;
//! \class DFBrowserPane_TDataStdTreeNode
private:
- QAbstractItemModel* myModel;
+ DFBrowserPane_TDataStdTreeNodeModel* myModel;
QTreeView* myTreeNodeView;
};
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);
}
// =======================================================================
// =======================================================================
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();
//! 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);
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:
MessageModel_ItemReport.hxx
MessageModel_ItemRoot.cxx
MessageModel_ItemRoot.hxx
-MessageModel_ReportCallBack.cxx
-MessageModel_ReportCallBack.hxx
MessageModel_Tools.cxx
MessageModel_Tools.hxx
MessageModel_TreeModel.cxx
<!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>
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
#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 :
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
}
// =======================================================================
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)
{
}
// =======================================================================
-// function : onImportReport
+// function : getSelectedReport
// purpose :
// =======================================================================
Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& theReportIndex) const
}
// =======================================================================
-// 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();
}
// =======================================================================
return;
aReport->Clear();
- ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex);
+ myTreeModel->UpdateTreeModel();
}
// =======================================================================
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
-}
{ 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
#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>
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();
}
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();
}
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();
}
#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>
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();
}
}
// =======================================================================
-// 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;
}
//! 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
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
//! \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(); }
+++ /dev/null
-// 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)
+++ /dev/null
-// 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
}
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);
- //}
- ////}
-}
//! \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
#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
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);
}
// =======================================================================
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 :
#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>
//! 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
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);
//! \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
};
--- /dev/null
+<?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>
+++ /dev/null
-<?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>
+++ /dev/null
-<?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>
+++ /dev/null
-<?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>
+MessageView_ActionsTest.cxx
+MessageView_ActionsTest.hxx
MessageView_Communicator.cxx
MessageView_Communicator.hxx
MessageView_VisibilityState.cxx
--- /dev/null
+// 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();
+}
+
--- /dev/null
+// 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
#ifndef MessageView_Communicator_H
#define MessageView_Communicator_H
-#include <inspector/MessageModel_ReportCallBack.hxx>
#include <inspector/MessageView_Window.hxx>
#include <inspector/TInspectorAPI_Communicator.hxx>
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 {}
#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>
((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);
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);
myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
+
+ updateVisibleColumns();
}
// =======================================================================
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++)
{
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;
}
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
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);
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())
if (!aContext.IsNull())
{
myViewWindow->SetContext (View_ContextType_External, aContext);
- myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External);
+ //myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External);
}
if (!aViewCamera.IsNull())
{
MessageModel_TreeModel* aModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
aModel->AddReport (theReport, theReportDescription);
+
+ updateVisibleColumns();
}
// =======================================================================
}
}
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);
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()));
}
aTreeModel->SetReversed (!isReversed);
}
-
// =======================================================================
// function : onReloadReport
// purpose :
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 :
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);
+ }
+ }
+}
class View_DisplayPreview;
class ViewControl_PropertyView;
-class MessageModel_ReportCallBack;
+
+class MessageView_ActionsTest;
class QDockWidget;
class QMainWindow;
+class QMenu;
class QWidget;
//! \class MessageView_Window
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);
//! 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
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
};
// 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();
-}
//! 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
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();
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 :
myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
//SetProperties (createItemProperties());
+ TreeModel_ItemBase::Init();
}
// =======================================================================
//! \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.
#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 :
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);
}
// =======================================================================
//! 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
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
#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;
// purpose :
// =======================================================================
ShapeView_Window::ShapeView_Window (QWidget* theParent)
-: QObject (theParent), myNextPosition (0)
+: QObject (theParent)
{
myMainWindow = new QMainWindow (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);
// =======================================================================
ShapeView_Window::~ShapeView_Window()
{
- onCloseAllBREPViews();
}
// =======================================================================
{
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
aModel->RemoveAllShapes();
-
- onCloseAllBREPViews();
}
// =======================================================================
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);
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 :
Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape (aShape);
Fixer->SetPrecision (LinTol);
Fixer->SetMaxTolerance (LinTol);
+
Fixer->Perform();
TopoDS_Shape aFixedShape = Fixer->Shape();
}
// =======================================================================
-// 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)
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;
}
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;
-}
//! 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();
//! 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();
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
//! 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
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
};
#include <inspector/TInspector_Communicator.hxx>
+#include <Message.hxx>
#include <Message_Report.hxx>
#include <OSD_Environment.hxx>
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";
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();
#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 :
#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 :
return anItems;
}
+// =======================================================================
+// function : createRoot
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::createRoot (const int theColumnId)
+{
+ myRootItems.insert (theColumnId, createRootItem (theColumnId));
+}
+
// =======================================================================
// function : getIndexValue
// purpose :
//! 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
//! 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();
//! 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
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
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();
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
-//#define DEBUG_FREE_OWNERS
-
// =======================================================================
// function : initRowCount
// purpose :
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;
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;
}
#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
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);
}
// =======================================================================
//! 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;
//! \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
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
// 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));
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);
}
// =======================================================================
//! 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);
//! \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
#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>
#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;
//((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
myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
+ aHistoryModel->InitColumns();
myHistoryView->setModel (aHistoryModel);
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
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);
}
}
}
+// =======================================================================
+// 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 :
//! 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