From: nds Date: Tue, 19 May 2020 16:53:20 +0000 (+0300) Subject: 0029451: Information Message Alert to debug an algorithm or object functionality X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=0fcf0a687b412673ff3883028efe4199b81b1039;p=occt-copy.git 0029451: Information Message Alert to debug an algorithm or object functionality --- diff --git a/src/Message/Message.cxx b/src/Message/Message.cxx index 505552b966..a6c63176e1 100644 --- a/src/Message/Message.cxx +++ b/src/Message/Message.cxx @@ -105,15 +105,15 @@ Standard_Boolean Message::ToOSDMetric (const Message_MetricType theMetric, OSD_M { switch (theMetric) { - case Message_MetricType_MemPrivate: theMemInfo = OSD_MemInfo::MemPrivate; break; - case Message_MetricType_MemVirtual: theMemInfo = OSD_MemInfo::MemVirtual; break; - case Message_MetricType_MemWorkingSet: theMemInfo = OSD_MemInfo::MemWorkingSet; break; - case Message_MetricType_MemWorkingSetPeak: theMemInfo = OSD_MemInfo::MemWorkingSetPeak; break; - case Message_MetricType_MemSwapUsage: theMemInfo = OSD_MemInfo::MemSwapUsage; break; - case Message_MetricType_MemSwapUsagePeak: theMemInfo = OSD_MemInfo::MemSwapUsagePeak; break; - case Message_MetricType_MemHeapUsage: theMemInfo = OSD_MemInfo::MemHeapUsage; break; + case Message_MetricType_MemPrivate: theMemInfo = OSD_MemInfo::MemPrivate; return Standard_True; + case Message_MetricType_MemVirtual: theMemInfo = OSD_MemInfo::MemVirtual; return Standard_True; + case Message_MetricType_MemWorkingSet: theMemInfo = OSD_MemInfo::MemWorkingSet; return Standard_True; + case Message_MetricType_MemWorkingSetPeak: theMemInfo = OSD_MemInfo::MemWorkingSetPeak; return Standard_True; + case Message_MetricType_MemSwapUsage: theMemInfo = OSD_MemInfo::MemSwapUsage; return Standard_True; + case Message_MetricType_MemSwapUsagePeak: theMemInfo = OSD_MemInfo::MemSwapUsagePeak; return Standard_True; + case Message_MetricType_MemHeapUsage: theMemInfo = OSD_MemInfo::MemHeapUsage; return Standard_True; } - return Standard_True; + return Standard_False; } // ======================================================================= diff --git a/src/Message/Message.hxx b/src/Message/Message.hxx index 601b0629ab..d93a903fd2 100644 --- a/src/Message/Message.hxx +++ b/src/Message/Message.hxx @@ -136,13 +136,12 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng //! Append into messenger result of DumpJson for the field //! It computes Dump of the fields. The expected field is a pointer. //! Use this macro for fields of the dumped class which has own DumpJson implementation. -#define OCCT_SEND_DUMPJSON(theField) \ +#define OCCT_SEND_DUMPJSON(theField, theMessage) \ { \ if ((void*)(theField) != NULL) \ { \ - Standard_SStream aFieldStream; \ - (theField)->DumpJson (aFieldStream, Message::DefaultMessenger()->TraceLevel()); \ - Message::DefaultMessenger() << aFieldStream; \ + Message::SendInfo() << theMessage; \ + (theField)->DumpJson (Message::SendInfo()); \ } \ } @@ -152,7 +151,17 @@ inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messeng //! Use this macro for fields of the dumped class which has own DumpJson implementation. #define OCCT_SEND_MESSAGE(theMessage) \ { \ - Message::DefaultMessenger() << theMessage << "" << std::endl; \ + Message::SendInfo() << theMessage; \ +} + +//! @def OCCT_SEND_DUMPJSON +//! Append into messenger result of DumpJson for the field +//! It computes Dump of the fields. The expected field is a pointer. +//! Use this macro for fields of the dumped class which has own DumpJson implementation. +#define OCCT_SEND_STREAM(theStream, theMessage) \ +{ \ + Message::SendInfo() << theMessage; \ + Message::SendInfo() << theStream.str().c_str(); \ } #endif // _Message_HeaderFile diff --git a/src/Message/Message_AttributeMeter.cxx b/src/Message/Message_AttributeMeter.cxx index 227c4b5e61..f9571b9bef 100644 --- a/src/Message/Message_AttributeMeter.cxx +++ b/src/Message/Message_AttributeMeter.cxx @@ -12,6 +12,10 @@ // commercial license or contractual agreement. #include +#include +#include +#include +#include #include @@ -63,6 +67,8 @@ Standard_Real Message_AttributeMeter::StartValue (const Message_MetricType& theM //======================================================================= void Message_AttributeMeter::SetStartValue (const Message_MetricType& theMetric, const Standard_Real theValue) { + //std::cout << GetName() << ": " << theValue << " (start)" << std::endl; + if (!HasMetric (theMetric)) { myMetrics.Bind (theMetric, std::make_pair (theValue, UndefinedMetricValue())); @@ -88,6 +94,7 @@ Standard_Real Message_AttributeMeter::StopValue (const Message_MetricType& theMe //======================================================================= void Message_AttributeMeter::SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue) { + //std::cout << GetName() << ": " << theValue << " (stop)" << std::endl; if (!HasMetric (theMetric)) { // start value should be already set @@ -95,3 +102,74 @@ void Message_AttributeMeter::SetStopValue (const Message_MetricType& theMetric, } myMetrics.ChangeFind (theMetric).second = theValue; } + +//======================================================================= +//function : SetAlertMetrics +//purpose : +//======================================================================= +void Message_AttributeMeter::SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert, + const Standard_Boolean theStartValue) +{ + if (theAlert.IsNull()) + return; + + Handle(Message_AttributeMeter) aMeterAttribute = Handle(Message_AttributeMeter)::DownCast (theAlert->Attribute()); + if (aMeterAttribute.IsNull()) + return; + + Handle(Message_Report) aReport = Message::DefaultReport (Standard_True); + const NCollection_Map& anActiveMetrics = aReport->ActiveMetrics(); + + // time metrics + if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU) || + anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo)) + { + Standard_Real aUserSeconds, aSystemSeconds; + OSD_Chronometer::GetProcessCPU (aUserSeconds, aSystemSeconds); + + if (anActiveMetrics.Contains (Message_MetricType_UserTimeCPU)) + { + if (theStartValue) + aMeterAttribute->SetStartValue (Message_MetricType_UserTimeCPU, aUserSeconds); + else + aMeterAttribute->SetStopValue (Message_MetricType_UserTimeCPU, aUserSeconds); + } + if (anActiveMetrics.Contains (Message_MetricType_SystemTimeInfo)) + { + if (theStartValue) + aMeterAttribute->SetStartValue (Message_MetricType_SystemTimeInfo, aSystemSeconds); + else + aMeterAttribute->SetStopValue (Message_MetricType_SystemTimeInfo, aSystemSeconds); + } + } + // memory metrics + OSD_MemInfo aMemInfo (Standard_False); + aMemInfo.SetActive (Standard_False); + NCollection_Map aCounters; + Standard_Boolean isCounterFound = Standard_False; + for (NCollection_Map::Iterator anIterator (anActiveMetrics); anIterator.More(); anIterator.Next()) + { + OSD_MemInfo::Counter anInfoCounter; + if (!Message::ToOSDMetric (anIterator.Value(), anInfoCounter)) + continue; + + aCounters.Add (anInfoCounter); + aMemInfo.SetActive (anInfoCounter, Standard_True); + isCounterFound = Standard_True; + } + if (aCounters.IsEmpty()) + return; + + aMemInfo.Update(); + Message_MetricType aMetricType; + for (NCollection_Map::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())); + } +} diff --git a/src/Message/Message_AttributeMeter.hxx b/src/Message/Message_AttributeMeter.hxx index f563c28377..72be3f6097 100644 --- a/src/Message/Message_AttributeMeter.hxx +++ b/src/Message/Message_AttributeMeter.hxx @@ -20,6 +20,7 @@ #include class Message_Alert; +class Message_AlertExtended; //! Alert object storing alert metrics values. //! Start and stop values for each metric. @@ -64,6 +65,21 @@ public: //! @param theMetric [in] metric type Standard_EXPORT void SetStopValue (const Message_MetricType& theMetric, const Standard_Real theValue); + //! Sets start values of default report metrics into the alert + //! @param theAlert an alert + static void StartAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_True); } + + //! Sets stop values of default report metrics into the alert + //! @param theAlert an alert + static void StopAlert (const Handle(Message_AlertExtended)& theAlert) { SetAlertMetrics (theAlert, Standard_False); } + + //! Sets current values of default report metrics into the alert. + //! Processed oly alert with Message_AttributeMeter attribute + //! @param theAlert an alert + //! @param theStartValue flag, if true, the start value is collected otherwise stop + static Standard_EXPORT void SetAlertMetrics (const Handle(Message_AlertExtended)& theAlert, + const Standard_Boolean theStartValue); + DEFINE_STANDARD_RTTIEXT(Message_AttributeMeter, Message_Attribute) private: diff --git a/src/Message/Message_Level.cxx b/src/Message/Message_Level.cxx index e012723651..7db8bf5621 100644 --- a/src/Message/Message_Level.cxx +++ b/src/Message/Message_Level.cxx @@ -27,11 +27,11 @@ //function : Message_Level //purpose : //======================================================================= -Message_Level::Message_Level() +Message_Level::Message_Level (const TCollection_AsciiString& theName) { const Handle(Message_Report)& aDefaultReport = Message::DefaultReport(); if (!aDefaultReport.IsNull() && aDefaultReport->IsActiveInMessenger()) - aDefaultReport->AddLevel (this); + aDefaultReport->AddLevel (this, theName); } //======================================================================= @@ -40,17 +40,19 @@ Message_Level::Message_Level() //======================================================================= Message_Level::~Message_Level() { - Remove(); + remove(); } //======================================================================= //function : SetRootAlert //purpose : //======================================================================= -void Message_Level::SetRootAlert (const Handle(Message_AlertExtended)& theAlert) +void Message_Level::SetRootAlert (const Handle(Message_AlertExtended)& theAlert, + const Standard_Boolean isRequiredToStart) { myRootAlert = theAlert; - startAlert (myRootAlert); + if (isRequiredToStart) + Message_AttributeMeter::StartAlert (myRootAlert); } //======================================================================= @@ -64,39 +66,17 @@ Standard_Boolean Message_Level::AddAlert (const Message_Gravity theGravity, if (anAlertExtended.IsNull()) return Standard_False; - if (myRootAlert.IsNull()) - return Standard_False; - // looking for the parent of the parameter alert to release the previous alert Handle(Message_AlertExtended) aRootAlert = myRootAlert; Handle(Message_CompositeAlerts) aCompositeAlert = aRootAlert->CompositeAlerts (Standard_True); // update metrics of the previous alert - stopAlert (myLastAlert); + Message_AttributeMeter::StopAlert (myLastAlert); myLastAlert = anAlertExtended; - // set start metrics of the new alert - startAlert (myLastAlert); - - // add child alert - aCompositeAlert->AddAlert (theGravity, theAlert); - - return Standard_True; -} - -//======================================================================= -//function : AddLevelAlert -//purpose : -//======================================================================= -Standard_Boolean Message_Level::AddLevelAlert (const Message_Gravity theGravity, - const Handle(Message_Alert)& theAlert) -{ - Handle(Message_AlertExtended) aRootAlert = /*!myLastAlert.IsNull() ? myLastAlert :*/ myRootAlert; - if (aRootAlert.IsNull()) - return Standard_False; + Message_AttributeMeter::StartAlert (myLastAlert); - Handle(Message_CompositeAlerts) aCompositeAlert = aRootAlert->CompositeAlerts (Standard_True); // add child alert aCompositeAlert->AddAlert (theGravity, theAlert); @@ -104,86 +84,17 @@ Standard_Boolean Message_Level::AddLevelAlert (const Message_Gravity theGravity, } //======================================================================= -//function : Remove() +//function : remove() //purpose : //======================================================================= -void Message_Level::Remove() +void Message_Level::remove() { const Handle(Message_Report)& aDefaultReport = Message::DefaultReport(); if (aDefaultReport.IsNull() || !aDefaultReport->IsActiveInMessenger()) return; - stopAlert (myLastAlert); - stopAlert (myRootAlert); + Message_AttributeMeter::StopAlert (myLastAlert); if (!Message::DefaultReport().IsNull()) Message::DefaultReport()->RemoveLevel (this); } - -//======================================================================= -//function : setAlertMetrics -//purpose : -//======================================================================= -void Message_Level::setAlertMetrics (const Handle(Message_AlertExtended)& theAlert, - const Standard_Boolean theStartValue) -{ - if (theAlert.IsNull()) - return; - - Handle(Message_AttributeMeter) aMeterAttribute = Handle(Message_AttributeMeter)::DownCast (theAlert->Attribute()); - if (aMeterAttribute.IsNull()) - return; - - Handle(Message_Report) aReport = Message::DefaultReport (Standard_True); - const NCollection_Map& 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 aCounters; - for (NCollection_Map::Iterator anIterator (anActiveMetrics); anIterator.More(); anIterator.Next()) - { - OSD_MemInfo::Counter aMemInfo; - if (!Message::ToOSDMetric (anIterator.Value(), aMemInfo)) - continue; - - aCounters.Add (aMemInfo); - } - if (aCounters.IsEmpty()) - return; - - OSD_MemInfo aMemInfo (Standard_False); - //aMemInfo.SetActiveCounters (aCounters); - aMemInfo.Update (); - Message_MetricType aMetricType; - for (NCollection_Map::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())); - } -} diff --git a/src/Message/Message_Level.hxx b/src/Message/Message_Level.hxx index de08c4c034..423561e97b 100644 --- a/src/Message/Message_Level.hxx +++ b/src/Message/Message_Level.hxx @@ -42,7 +42,7 @@ public: //! Constructor. Append //! One string key is used for all alert meters. The perf meter is not started automatically, it will be done in //! AddAlert method - Standard_EXPORT Message_Level(); + Standard_EXPORT Message_Level (const TCollection_AsciiString& theName = TCollection_AsciiString()); //! Assures stopping upon destruction Standard_EXPORT ~Message_Level(); @@ -53,7 +53,8 @@ public: //! Sets the root alert. Starts collects alert metrics if active. //! @param theAlert an alert - Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert); + Standard_EXPORT void SetRootAlert (const Handle(Message_AlertExtended)& theAlert, + const Standard_Boolean isRequiredToStart); //! Adds new alert on the level. Stops the last alert metric, appends the alert and starts the alert metrics collecting. //! Sets root alert beforehead this method using, if the root is NULL, it does nothing. @@ -63,31 +64,9 @@ public: Standard_EXPORT Standard_Boolean AddAlert (const Message_Gravity theGravity, const Handle(Message_Alert)& theAlert); - //! Add new alert as a child of the last alert if exists or as a child of the root alert. - //! @param theGravity an alert gravity - //! @param theAlert an alert - //! @return true if alert is added - Standard_EXPORT Standard_Boolean AddLevelAlert (const Message_Gravity theGravity, - const Handle(Message_Alert)& theAlert); - - //! Remove the current level from the report. It stops metric collecting for the last and the root alerts. - Standard_EXPORT void Remove(); - protected: - //! Sets start values of default report metrics into the alert - //! @param theAlert an alert - void startAlert (const Handle(Message_AlertExtended)& theAlert) { setAlertMetrics (theAlert, Standard_True); } - - //! Sets stop values of default report metrics into the alert - //! @param theAlert an alert - void stopAlert (const Handle(Message_AlertExtended)& theAlert) { setAlertMetrics (theAlert, Standard_True); } - - //! Sets current values of default report metrics into the alert. - //! Processed oly alert with Message_AttributeMeter attribute - //! @param theAlert an alert - //! @param theStartValue flag, if true, the start value is collected otherwise stop - Standard_EXPORT void setAlertMetrics (const Handle(Message_AlertExtended)& theAlert, - const Standard_Boolean theStartValue); + //! Remove the current level from the report. It stops metric collecting for the last and the root alerts. + Standard_EXPORT void remove(); protected: Handle(Message_AlertExtended) myRootAlert; //!< root alert @@ -97,7 +76,6 @@ protected: //! @def MESSAGE_NEW_LEVEL //! Creates a new level instance of Sentry. This row should be inserted before messages using in the method. #define OCCT_ADD_MESSAGE_LEVEL_SENTRY(theMessage) \ - Message_Level aLevel; \ - Message::SendInfo() << theMessage << std::endl; + Message_Level aLevel(theMessage); #endif // _Message_Level_HeaderFile diff --git a/src/Message/Message_Messenger.cxx b/src/Message/Message_Messenger.cxx index cd6488431a..b57c3e075e 100644 --- a/src/Message/Message_Messenger.cxx +++ b/src/Message/Message_Messenger.cxx @@ -147,6 +147,28 @@ void Message_Messenger::Send (const Standard_CString theString, } } +//======================================================================= +//function : Send +//purpose : +//======================================================================= + +void Message_Messenger::Send (const Standard_SStream& theStream, + const Message_Gravity theGravity) const +{ + if (TraceLevel() == 0) + return; + + for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More(); aPrinterIter.Next()) + { + const Handle(Message_Printer)& aPrinter = aPrinterIter.Value(); + if (!aPrinter.IsNull()) + { + aPrinter->Send (theStream, theGravity); + } + } +} + + //======================================================================= //function : Send //purpose : diff --git a/src/Message/Message_Messenger.hxx b/src/Message/Message_Messenger.hxx index e5306bfa76..8c63945840 100644 --- a/src/Message/Message_Messenger.hxx +++ b/src/Message/Message_Messenger.hxx @@ -77,7 +77,7 @@ public: { if (myMessenger) { - myMessenger->Send(myStream.str().c_str(), myGravity); + myMessenger->Send(myStream, myGravity); } myStream.str(std::string()); // empty the buffer for possible reuse } @@ -191,6 +191,10 @@ public: Standard_EXPORT void Send (const Standard_CString theString, const Message_Gravity theGravity = Message_Warning) const; + //! See above + Standard_EXPORT void Send (const Standard_SStream& theStream, + const Message_Gravity theGravity = Message_Warning) const; + //! See above Standard_EXPORT void Send (const TCollection_AsciiString& theString, const Message_Gravity theGravity = Message_Warning) const; diff --git a/src/Message/Message_Printer.cxx b/src/Message/Message_Printer.cxx index 5356a862f6..58d3da0159 100644 --- a/src/Message/Message_Printer.cxx +++ b/src/Message/Message_Printer.cxx @@ -73,13 +73,12 @@ void Message_Printer::Send (const TCollection_AsciiString& theString, //function : Send //purpose : //======================================================================= - void Message_Printer::Send (const Standard_SStream& theStream, const Message_Gravity theGravity) const { if (theGravity >= myTraceLevel) { - Send (TCollection_ExtendedString (theStream.str().c_str()), theGravity); + Send (theStream.str().c_str(), theGravity); } } diff --git a/src/Message/Message_PrinterToReport.cxx b/src/Message/Message_PrinterToReport.cxx index c66c83e8c6..ca225ab0af 100644 --- a/src/Message/Message_PrinterToReport.cxx +++ b/src/Message/Message_PrinterToReport.cxx @@ -40,6 +40,36 @@ const Handle(Message_Report)& Message_PrinterToReport::Report() const return Message::DefaultReport (Standard_True); } +//======================================================================= +//function : Send +//purpose : +//======================================================================= +void Message_PrinterToReport::Send (const Standard_SStream& theStream, + const Message_Gravity theGravity) const +{ + const Handle(Message_Report)& aReport = Report(); + if (!aReport->ActiveMetrics().IsEmpty()) + { + sendMetricAlert (theStream.str().c_str(), theGravity); + return; + } + if (Standard_Dump::HasChildKey(Standard_Dump::Text (theStream))) + { + Message_AlertExtended::AddAlert (aReport, new Message_AttributeStream (theStream, myName), theGravity); + myName.Clear(); + } + else + { + if (!myName.IsEmpty()) + { + TCollection_AsciiString aName = myName; + myName.Clear(); + send (aName, theGravity); + } + myName = Standard_Dump::Text (theStream); + } +} + //======================================================================= //function : Send //purpose : @@ -64,6 +94,12 @@ void Message_PrinterToReport::Send (const Handle(Standard_Transient)& /*theObjec void Message_PrinterToReport::send (const TCollection_AsciiString& theString, const Message_Gravity theGravity) const { + if (!myName.IsEmpty()) + { + send (myName, theGravity); + myName.Clear(); + } + const Handle(Message_Report)& aReport = Report(); if (!aReport->ActiveMetrics().IsEmpty()) { diff --git a/src/Message/Message_PrinterToReport.hxx b/src/Message/Message_PrinterToReport.hxx index bce9bdbb25..f61a5be2b0 100644 --- a/src/Message/Message_PrinterToReport.hxx +++ b/src/Message/Message_PrinterToReport.hxx @@ -44,12 +44,18 @@ public: //! @param theReport report for messages processing, if NULL, the default report is used Standard_EXPORT void SetReport (const Handle(Message_Report)& theReport) { myReport = theReport; } + //! Send a string message with specified trace level. + //! Stream is converted to string value. + //! Default implementation calls first method Send(). + Standard_EXPORT virtual void Send (const Standard_SStream& theStream, const Message_Gravity theGravity) const; + //! Send a string message with specified trace level. //! The object is converted to string in format: : . //! The parameter theToPutEol specified whether end-of-line should be added to the end of the message. //! Default implementation calls first method Send(). Standard_EXPORT virtual void Send (const Handle(Standard_Transient)& theObject, const Message_Gravity theGravity) const Standard_OVERRIDE; + //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; @@ -65,6 +71,7 @@ protected: const Message_Gravity theGravity) const; private: + mutable TCollection_AsciiString myName; Handle(Message_Report) myReport; //!< the report for sending alerts }; diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index e094b172b2..2850240119 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include #include @@ -66,33 +68,9 @@ void Message_Report::AddAlert (Message_Gravity theGravity, const Handle(Message_ return; } - // if there are some levels of alerts - // iterate by already recorded alerts and try to merge new one with one of those - Message_Level* aLevel = myAlertLevels.Last(); + // if there are some levels of alerts, the new alert will be placed below the root + myAlertLevels.Last()->AddAlert (theGravity, theAlert); - // level has root alert, the new alert will be placed below the root - if (!aLevel->RootAlert().IsNull()) - { - aLevel->AddAlert (theGravity, theAlert); - writeReport(); - return; - } - - Handle(Message_AlertExtended) anAlert = Handle(Message_AlertExtended)::DownCast (theAlert); - if (anAlert.IsNull()) - return; - // place new alert as a root of the level, after place the level alert below the report or - // below the previous level - aLevel->SetRootAlert (anAlert); - - if (myAlertLevels.Size() == 1) // this is the first level, so root alert should be pushed in the report composite of alerts - compositeAlerts (Standard_True)->AddAlert (theGravity, theAlert); - else - { - // root alert of next levels should be pushed under the previous level - Message_Level* aPrevLevel = myAlertLevels.Value (myAlertLevels.Size() - 1); // previous level - aPrevLevel->AddLevelAlert (theGravity, theAlert); - } writeReport(); } @@ -194,10 +172,32 @@ void Message_Report::ActivateInMessenger (const Standard_Boolean toActivate, //function : AddLevel //purpose : //======================================================================= - -void Message_Report::AddLevel (Message_Level* theLevel) +void Message_Report::AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName) { myAlertLevels.Append (theLevel); + + Handle(Message_AlertExtended) aLevelRootAlert = new Message_AlertExtended(); + + Handle(Message_Attribute) anAttribute; + if (!ActiveMetrics().IsEmpty()) + { + anAttribute = new Message_AttributeMeter (theName); + } + else + anAttribute = new Message_Attribute (theName); + aLevelRootAlert->SetAttribute (anAttribute); + theLevel->SetRootAlert (aLevelRootAlert, myAlertLevels.Size() == 1); + + if (myAlertLevels.Size() == 1) // this is the first level, so root alert should be pushed in the report composite of alerts + { + compositeAlerts (Standard_True)->AddAlert (Message_Info, theLevel->RootAlert()); + } + if (myAlertLevels.Size() > 1) // this is the first level, so root alert should be pushed in the report composite of alerts + { + // root alert of next levels should be pushed under the previous level + Message_Level* aPrevLevel = myAlertLevels.Value (myAlertLevels.Size() - 1); // previous level + aPrevLevel->AddAlert (Message_Info, aLevelRootAlert); + } } //======================================================================= @@ -210,6 +210,10 @@ void Message_Report::RemoveLevel (Message_Level* theLevel) for (int aLevelIndex = myAlertLevels.Size(); aLevelIndex >= 1; aLevelIndex--) { Message_Level* aLevel = myAlertLevels.Value (aLevelIndex); + if (myAlertLevels.Size() == 1) // the last level, the root item should be stopped + { + Message_AttributeMeter::StopAlert (aLevel->RootAlert()); + } myAlertLevels.Remove (aLevelIndex); if (aLevel == theLevel) diff --git a/src/Message/Message_Report.hxx b/src/Message/Message_Report.hxx index be35d38a9e..599b0fad7b 100644 --- a/src/Message/Message_Report.hxx +++ b/src/Message/Message_Report.hxx @@ -86,7 +86,7 @@ public: //! Add new level of alerts //! @param theLevel a level - Standard_EXPORT void AddLevel (Message_Level* theLevel); + Standard_EXPORT void AddLevel (Message_Level* theLevel, const TCollection_AsciiString& theName); //! Remove level of alerts Standard_EXPORT void RemoveLevel (Message_Level* theLevel); diff --git a/tools/MessageModel/MessageModel_ActionType.hxx b/tools/MessageModel/MessageModel_ActionType.hxx index 7df28caaba..3415c9d0d2 100644 --- a/tools/MessageModel/MessageModel_ActionType.hxx +++ b/tools/MessageModel/MessageModel_ActionType.hxx @@ -26,7 +26,8 @@ enum MessageModel_ActionType MessageModel_ActionType_TestMetric, //!< test alerts MessageModel_ActionType_TestProperties, //!< test alerts MessageModel_ActionType_TestMessenger, //!< test message view on messenger printer to report - MessageModel_ActionType_TestReportTree //!< test message view on hierarchical report + MessageModel_ActionType_TestReportTree, //!< test message view on hierarchical report + MessageModel_ActionType_TestReportTree2 //!< test message view on hierarchical report }; #endif diff --git a/tools/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx index 31e34e0aab..6aa1c7bb69 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.cxx +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -116,21 +116,38 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const return QVariant(); Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anExtendedAlert->Attribute()); - if (anAttribute.IsNull()) - return QVariant(); - - Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType); - if (fabs (aCumulativeMetric) < Precision::Confusion()) + if (anAttribute.IsNull() || !anAttribute->HasMetric (aMetricType)) return QVariant(); - if (aPosition == 0) return aCumulativeMetric; - else if (aPosition == 1) + if (aMetricType == Message_MetricType_UserTimeCPU || + aMetricType == Message_MetricType_SystemTimeInfo) { - Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType); - if (fabs (aReportCumulativeMetric) > Precision::Confusion()) - return 100. * aCumulativeMetric / aReportCumulativeMetric; - else + Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType); + if (fabs (aCumulativeMetric) < Precision::Confusion()) return QVariant(); + + if (aPosition == 0) return aCumulativeMetric; + else if (aPosition == 1) + { + Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType); + if (fabs (aReportCumulativeMetric) > Precision::Confusion()) + return 100. * aCumulativeMetric / aReportCumulativeMetric; + else + return QVariant(); + } + } + else + { + if (aPosition == 0) return anAttribute->StopValue (aMetricType); + else if (aPosition == 1) + { + Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType); + if (fabs (aCumulativeMetric) < Precision::Confusion()) + return QVariant(); + else + return aCumulativeMetric; + } + } } return QVariant(); diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx index 575de32fe4..32ef4ff4e1 100644 --- a/tools/MessageModel/MessageModel_ItemReport.cxx +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -66,7 +66,8 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const Message_MetricType aMetricType; int aPosition; - if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition)) + if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition) && + (aMetricType == Message_MetricType_UserTimeCPU || aMetricType == Message_MetricType_SystemTimeInfo)) { if (aPosition == 0) return CumulativeMetric (aReport, aMetricType); else if (aPosition == 1) return "100"; @@ -202,26 +203,29 @@ Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Re for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity) { const Message_ListOfAlert& anAlerts = theReport->GetAlerts ((Message_Gravity)iGravity); - Handle(Message_AttributeMeter) aFirstAttribute, aLastAttribute; + Handle(Message_AttributeMeter) aFirstAttribute/*, aLastAttribute*/; for (Message_ListOfAlert::Iterator anAlertsIterator (anAlerts); anAlertsIterator.More(); anAlertsIterator.Next()) { Handle(Message_AlertExtended) anAlert = Handle(Message_AlertExtended)::DownCast (anAlertsIterator.Value()); if (anAlert.IsNull()) continue; Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anAlert->Attribute()); - if (anAttribute.IsNull()) + if (anAttribute.IsNull() || !anAttribute->HasMetric(theMetricType)) continue; - if (aFirstAttribute.IsNull()) - aFirstAttribute = anAttribute; - else - aLastAttribute = anAttribute; + //if (aFirstAttribute.IsNull()) + // aFirstAttribute = anAttribute; + //else + //{ + //aLastAttribute = anAttribute; + //} + aMetric += anAttribute->StopValue (theMetricType) - anAttribute->StartValue (theMetricType); } - if (aFirstAttribute.IsNull()) - continue; - if (aLastAttribute.IsNull()) - aLastAttribute = aFirstAttribute; + //if (aFirstAttribute.IsNull()) + // continue; + //if (aLastAttribute.IsNull()) + // aLastAttribute = aFirstAttribute; - aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType); + //aMetric += aLastAttribute->StopValue (theMetricType) - aFirstAttribute->StartValue (theMetricType); } return aMetric; } diff --git a/tools/MessageModel/MessageModel_TreeModel.cxx b/tools/MessageModel/MessageModel_TreeModel.cxx index 85b539817b..7806eb35f7 100644 --- a/tools/MessageModel/MessageModel_TreeModel.cxx +++ b/tools/MessageModel/MessageModel_TreeModel.cxx @@ -18,11 +18,15 @@ #include #include #include +#include #include +const int COLUMN_NAME_WIDTH = 460; +const int COLUMN_SIZE_WIDTH = 30; + const int COLUMN_REAL_VALUE_WIDTH = 115; -const int COLUMN_PERCENT_VALUE_WIDTH = 40; +const int COLUMN_PERCENT_VALUE_WIDTH = 50; // ======================================================================= // function : Constructor @@ -39,8 +43,10 @@ MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent) // ======================================================================= void MessageModel_TreeModel::InitColumns() { - TreeModel_ModelBase::InitColumns(); // 0 - Name, 1 - visibility, 2 - Row + SetHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); + SetHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); + SetHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/)); int aNextIndex = 3; for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++) @@ -52,7 +58,7 @@ void MessageModel_TreeModel::InitColumns() SetHeaderItem (aNextIndex++, TreeModel_HeaderSection (QString("%1 [%2]").arg (Message::MetricToString (aMetricType)).arg(isMemInfo ? "Mb" : "s"), COLUMN_REAL_VALUE_WIDTH)); - SetHeaderItem (aNextIndex++, TreeModel_HeaderSection ("%", COLUMN_PERCENT_VALUE_WIDTH)); + SetHeaderItem (aNextIndex++, TreeModel_HeaderSection (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH)); } } diff --git a/tools/MessageView/MessageView_ActionsTest.cxx b/tools/MessageView/MessageView_ActionsTest.cxx index 9d23b96da1..439c595921 100644 --- a/tools/MessageView/MessageView_ActionsTest.cxx +++ b/tools/MessageView/MessageView_ActionsTest.cxx @@ -28,7 +28,11 @@ #include #include +#include +#include +#include #include +#include #include #include #include @@ -45,10 +49,9 @@ #include #include -//#define DEBUG_ALERTS +#define DEBUG_ALERTS #ifdef DEBUG_ALERTS -#include #include #endif @@ -71,6 +74,8 @@ MessageView_ActionsTest::MessageView_ActionsTest (QWidget* theParent, ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestMessenger()), parent(), this)); myActions.insert (MessageModel_ActionType_TestReportTree, ViewControl_Tools::CreateAction ("Test ", SLOT (OnTestReportTree()), parent(), this)); + myActions.insert (MessageModel_ActionType_TestReportTree2, + ViewControl_Tools::CreateAction ("Test 2", SLOT (OnTestReportTree2()), parent(), this)); } // ======================================================================= @@ -111,6 +116,7 @@ void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelected theMenu->addAction (myActions[MessageModel_ActionType_TestProperties]); theMenu->addAction (myActions[MessageModel_ActionType_TestMessenger]); theMenu->addAction (myActions[MessageModel_ActionType_TestReportTree]); + theMenu->addAction (myActions[MessageModel_ActionType_TestReportTree2]); bool isReportEnabled = aReportItem->GetReport()->IsActiveInMessenger(); @@ -118,6 +124,7 @@ void MessageView_ActionsTest::AddMenuActions (const QModelIndexList& theSelected myActions[MessageModel_ActionType_TestProperties]->setEnabled (isReportEnabled); myActions[MessageModel_ActionType_TestMessenger]->setEnabled (isReportEnabled); myActions[MessageModel_ActionType_TestReportTree]->setEnabled (isReportEnabled); + myActions[MessageModel_ActionType_TestReportTree2]->setEnabled (isReportEnabled); } theMenu->addSeparator(); } @@ -174,7 +181,7 @@ void MessageView_ActionsTest::OnTestMetric() double* aMemValue; for (int aTopIt = 0; aTopIt < 4; aTopIt++) { - MESSAGE_INFO ("Calculate"); + Message::SendInfo() << "Calculate"; for (int j = 0; j < aCounter; j++) { for (int i = 0; i < aCounter; i++) @@ -219,45 +226,32 @@ void MessageView_ActionsTest::OnTestPropertyPanel() OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestPropertyPanel()"); + OCCT_SEND_MESSAGE ("Values") + OCCT_SEND_MESSAGE ("Values2") // gp_XYZ { gp_XYZ aCoords (1.3, 2.3, 3.4); - aCoords.DumpJson (sout); - //Standard_SStream aStream; - //aCoords.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_XYZ"); + OCCT_SEND_DUMPJSON (&aCoords, "gp_XYZ") } // gp_Dir { gp_Dir aDir (0.3, 0.3, 0.4); - //Standard_SStream aStream; - aDir.DumpJson (sout); - //aDir.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_Dir"); + OCCT_SEND_DUMPJSON (&aDir, "gp_Dir") } // gp_Ax1 { gp_Ax1 aCoords (gp_Pnt (1.3, 2.3, 3.4), gp_Dir (0.3, 0.3, 0.4)); - //Standard_SStream aStream; - aCoords.DumpJson (sout); - //aCoords.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_Ax1"); + OCCT_SEND_DUMPJSON (&aCoords, "gp_Ax1") } // gp_Ax2 { gp_Ax2 aCoords (gp_Pnt (10.3, 20.3, 30.4), gp_Dir (0.3, 0.3, 0.4)); - //Standard_SStream aStream; - aCoords.DumpJson (sout); - //aCoords.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_Ax2"); + OCCT_SEND_DUMPJSON (&aCoords, "gp_Ax2") } // gp_Ax3 { gp_Ax3 aPln (gp_Pnt (10., 20., 15.), gp_Dir (0., 0., 1.), gp_Dir (1., 0., 0.)); - //Standard_SStream aStream; - aPln.DumpJson (sout); - //aPln.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_Ax3"); + OCCT_SEND_DUMPJSON (&aPln, "gp_Ax3") } // gp_Trsf { @@ -266,43 +260,28 @@ void MessageView_ActionsTest::OnTestPropertyPanel() aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.)); aTrsf.SetScaleFactor (3.); - aTrsf.DumpJson (sout); - //Standard_SStream aStream; - //aTrsf.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "gp_Trsf"); + OCCT_SEND_DUMPJSON (&aTrsf, "gp_Trsf") } // Bnd_Box { Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.)); - aBox.DumpJson (sout); - //Standard_SStream aStream; - //aBox.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "Bnd_Box"); + OCCT_SEND_DUMPJSON (&aBox, "Bnd_Box") } // Bnd_OBB { Bnd_OBB anOBB (gp_Pnt (-10., -15., -10.), gp_Dir (1., 0., 0.), gp_Dir (0., 1., 0.), gp_Dir (0., 0., 1.), 5., 10., 5.); - aBox.DumpJson (sout); - //Standard_SStream aStream; - //anOBB.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "Bnd_OBB"); + OCCT_SEND_DUMPJSON (&anOBB, "Bnd_OBB"); } // Quantity_ColorRGBA { Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f); - aColor.DumpJson (sout); - //Standard_SStream aStream; - //aColor.DumpJson (aStream); - //MESSAGE_INFO_STREAM(aStream, "Quantity_ColorRGBA"); + OCCT_SEND_DUMPJSON (&aColor, "Quantity_ColorRGBA"); } // Quantity_Color { Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB); - aColor.DumpJson (sout); - //Standard_SStream aStream; - //aColor.DumpJson (aStream); - ///MESSAGE_INFO_STREAM(aStream, "Quantity_Color"); + OCCT_SEND_DUMPJSON (&aColor, "Quantity_Color"); } // stream of some table values @@ -310,8 +289,7 @@ void MessageView_ActionsTest::OnTestPropertyPanel() Standard_SStream aStream; OCCT_DUMP_FIELD_VALUES_NUMERICAL (aStream, "value_1", 1, 100); OCCT_DUMP_FIELD_VALUES_STRING (aStream, "value_2", 2, "value_1", "value_2"); - - MESSAGE_INFO_STREAM(aStream, "Table: Name to value"); + OCCT_SEND_STREAM (aStream, "Table: Name to value"); } // SHAPE messages @@ -429,13 +407,13 @@ void levelAlerts (const int theCurrentLevel, const int theTopLevel) OCCT_ADD_MESSAGE_LEVEL_SENTRY (TCollection_AsciiString ("Level: " ) + theCurrentLevel) Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout << "Alert: " << 1 << ", " << 2 << std::endl; - sout << "Alert: " << 3 << ", " << 4 << std::endl; + sout << "Alert(" << theCurrentLevel << "): " << 1 << ", " << 2 << std::endl; + sout << "Alert(" << theCurrentLevel << "): " << 3 << ", " << 4 << std::endl; - for (int i = 0; i < 2; i++) + //for (int i = 0; i < 2; i++) levelAlerts (theCurrentLevel + 1, theTopLevel); - sout << "Alert: " << 4 << ", " << 5 << std::endl; + sout << "Alert(" << theCurrentLevel << "): " << 4 << ", " << 5 << std::endl; } // ======================================================================= @@ -452,12 +430,12 @@ void levelAlert (const int theCurrentLevel, const int theTopLevel) Message_Messenger::StreamBuffer sout = Message::SendInfo(); sout << "Level: " << theCurrentLevel << "(Single, no alerts on the level)" << std::endl; - for (int i = 0; i < 2; i++) + //for (int i = 0; i < 2; i++) levelAlerts (theCurrentLevel + 1, theTopLevel); } // ======================================================================= -// function : OnTestMessenger +// function : OnTestReportTree // purpose : // ======================================================================= void MessageView_ActionsTest::OnTestReportTree() @@ -481,3 +459,27 @@ void MessageView_ActionsTest::OnTestReportTree() myTreeModel->UpdateTreeModel(); } +// ======================================================================= +// function : OnTestReportTree2 +// purpose : +// ======================================================================= +void MessageView_ActionsTest::OnTestReportTree2() +{ + OCCT_ADD_MESSAGE_LEVEL_SENTRY ("MessageModel_Actions::OnTestReportTree()") + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + + // string messages + //sout << "Alert: " << 1 << std::endl; + //sout << "Alert: " << 2 << std::endl; + + int aTopLevel = 3; + levelAlerts (1, aTopLevel); + + //sout << "Alert: " << 3 << std::endl; + //levelAlerts (1, aTopLevel); + + //sout << "Alert: " << 4 << std::endl; + //levelAlert (1, aTopLevel); + + myTreeModel->UpdateTreeModel(); +} diff --git a/tools/MessageView/MessageView_ActionsTest.hxx b/tools/MessageView/MessageView_ActionsTest.hxx index 54943819e6..bf58b17ec9 100644 --- a/tools/MessageView/MessageView_ActionsTest.hxx +++ b/tools/MessageView/MessageView_ActionsTest.hxx @@ -67,6 +67,9 @@ public slots: //! Check tree of alerts void OnTestReportTree(); + //! Check tree of alerts + void OnTestReportTree2(); + protected: //! Returns report of selected tree view item if a report item is selected //! \param theReportIndex tree model index of the found report diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index aaa2c61dd2..7e9104db2e 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -155,6 +155,7 @@ MessageView_Window::MessageView_Window (QWidget* theParent) connect (aVisibilityState, SIGNAL (itemClicked (const QModelIndex&)), this, SLOT(onTreeViewVisibilityClicked(const QModelIndex&))); TreeModel_Tools::UseVisibilityColumn (myTreeView); + TreeModel_Tools::SetDefaultHeaderSections (myTreeView); QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel); myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection); @@ -267,12 +268,6 @@ void MessageView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIt // ======================================================================= void MessageView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) { - if (theItem.IsEmpty()) - { - TreeModel_Tools::SetDefaultHeaderSections (myTreeView); - return; - } - for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next()) { if (anItemIt.Key().IsEqual ("geometry")) diff --git a/tools/TreeModel/TreeModel_ColumnType.hxx b/tools/TreeModel/TreeModel_ColumnType.hxx index 80cb3f97da..520cec6fdf 100644 --- a/tools/TreeModel/TreeModel_ColumnType.hxx +++ b/tools/TreeModel/TreeModel_ColumnType.hxx @@ -24,7 +24,8 @@ enum TreeModel_ColumnType { TreeModel_ColumnType_Name = 0, //! name column - TreeModel_ColumnType_Visibility //! visibility state column + TreeModel_ColumnType_Visibility, //! visibility state column + TreeModel_ColumnType_Row //! row of the item column }; #endif diff --git a/tools/TreeModel/TreeModel_ModelBase.cxx b/tools/TreeModel/TreeModel_ModelBase.cxx index 806684a4f1..3421439659 100644 --- a/tools/TreeModel/TreeModel_ModelBase.cxx +++ b/tools/TreeModel/TreeModel_ModelBase.cxx @@ -47,9 +47,9 @@ TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent) // ======================================================================= void TreeModel_ModelBase::InitColumns() { - SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); - SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); - SetHeaderItem (2, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH)); + SetHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); + SetHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth())); + SetHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH)); } // =======================================================================