mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_ActionType_H
|
||||
#define MessageModel_ActionType_H
|
||||
@@ -19,13 +19,14 @@
|
||||
//! Kind of action type for tree view context menu item
|
||||
enum MessageModel_ActionType
|
||||
{
|
||||
MessageModel_ActionType_Activate, //!< set Message_Report active
|
||||
MessageModel_ActionType_Deactivate, //!< set Message_Report not active
|
||||
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_TestMessenger, //!< test message view on messenger printer to report
|
||||
MessageModel_ActionType_TestReportTree //!< test message view on hierarchical report
|
||||
MessageModel_ActionType_Activate, //!< set Message_Report active
|
||||
MessageModel_ActionType_Deactivate, //!< set Message_Report not active
|
||||
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_TestMessenger, //!< test message view on messenger printer to report
|
||||
MessageModel_ActionType_TestReportTree //!< test message view on hierarchical report
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_Actions.hxx>
|
||||
|
||||
@@ -46,71 +46,81 @@
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
MessageModel_Actions::MessageModel_Actions (QWidget* theParent,
|
||||
MessageModel_TreeModel* theTreeModel,
|
||||
QItemSelectionModel* theModel)
|
||||
: QObject (theParent), myTreeModel (theTreeModel), mySelectionModel (theModel)
|
||||
MessageModel_Actions::MessageModel_Actions(QWidget* theParent,
|
||||
MessageModel_TreeModel* theTreeModel,
|
||||
QItemSelectionModel* theModel)
|
||||
: QObject(theParent),
|
||||
myTreeModel(theTreeModel),
|
||||
mySelectionModel(theModel)
|
||||
{
|
||||
myActions.insert (MessageModel_ActionType_Activate,
|
||||
ViewControl_Tools::CreateAction (tr ("Activate"), SLOT (OnActivateReport()), parent(), this));
|
||||
myActions.insert (MessageModel_ActionType_Deactivate,
|
||||
ViewControl_Tools::CreateAction (tr ("Deactivate"), SLOT (OnDeactivateReport()), parent(), this));
|
||||
myActions.insert (MessageModel_ActionType_Clear,
|
||||
ViewControl_Tools::CreateAction (tr ("Clear"), SLOT (OnClearReport()), parent(), this));
|
||||
myActions.insert (MessageModel_ActionType_ExportToShapeView,
|
||||
ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this));
|
||||
myActions.insert(
|
||||
MessageModel_ActionType_Activate,
|
||||
ViewControl_Tools::CreateAction(tr("Activate"), SLOT(OnActivateReport()), parent(), this));
|
||||
myActions.insert(
|
||||
MessageModel_ActionType_Deactivate,
|
||||
ViewControl_Tools::CreateAction(tr("Deactivate"), SLOT(OnDeactivateReport()), parent(), this));
|
||||
myActions.insert(
|
||||
MessageModel_ActionType_Clear,
|
||||
ViewControl_Tools::CreateAction(tr("Clear"), SLOT(OnClearReport()), parent(), this));
|
||||
myActions.insert(MessageModel_ActionType_ExportToShapeView,
|
||||
ViewControl_Tools::CreateAction(tr("Export to ShapeView"),
|
||||
SLOT(OnExportToShapeView()),
|
||||
parent(),
|
||||
this));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetAction
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QAction* MessageModel_Actions::GetAction (const MessageModel_ActionType& theType)
|
||||
QAction* MessageModel_Actions::GetAction(const MessageModel_ActionType& theType)
|
||||
{
|
||||
return myActions.contains (theType) ? myActions[theType] : 0;
|
||||
return myActions.contains(theType) ? myActions[theType] : 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddMenuActions
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedIndices, QMenu* theMenu)
|
||||
void MessageModel_Actions::AddMenuActions(const QModelIndexList& theSelectedIndices, QMenu* theMenu)
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem;
|
||||
MessageModel_ItemRootPtr aRootItem;
|
||||
MessageModel_ItemReportPtr aReportItem;
|
||||
MessageModel_ItemAlertPtr anAlertItem;
|
||||
for (QModelIndexList::const_iterator aSelIt = theSelectedIndices.begin(); aSelIt != theSelectedIndices.end(); aSelIt++)
|
||||
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);
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
|
||||
if (!anItemBase)
|
||||
continue;
|
||||
|
||||
aRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItemBase);
|
||||
aRootItem = itemDynamicCast<MessageModel_ItemRoot>(anItemBase);
|
||||
if (aRootItem)
|
||||
break;
|
||||
|
||||
aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
|
||||
aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItemBase);
|
||||
if (aReportItem)
|
||||
break;
|
||||
|
||||
anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (anItemBase);
|
||||
anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
|
||||
if (anAlertItem)
|
||||
break;
|
||||
}
|
||||
|
||||
if (aReportItem && !aReportItem->GetReport().IsNull())
|
||||
{
|
||||
theMenu->addAction (myActions[MessageModel_ActionType_Deactivate]);
|
||||
theMenu->addAction (myActions[MessageModel_ActionType_Activate]);
|
||||
theMenu->addAction (myActions[MessageModel_ActionType_Clear]);
|
||||
theMenu->addAction(myActions[MessageModel_ActionType_Deactivate]);
|
||||
theMenu->addAction(myActions[MessageModel_ActionType_Activate]);
|
||||
theMenu->addAction(myActions[MessageModel_ActionType_Clear]);
|
||||
}
|
||||
else if (anAlertItem)
|
||||
{
|
||||
theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]);
|
||||
theMenu->addAction(myActions[MessageModel_ActionType_ExportToShapeView]);
|
||||
}
|
||||
|
||||
theMenu->addSeparator();
|
||||
@@ -120,21 +130,23 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd
|
||||
// function : getSelectedReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& theReportIndex) const
|
||||
Handle(Message_Report) MessageModel_Actions::getSelectedReport(QModelIndex& theReportIndex) const
|
||||
{
|
||||
MessageModel_ItemReportPtr aReportItem;
|
||||
QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes();
|
||||
for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
|
||||
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);
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
|
||||
if (!anItemBase)
|
||||
continue;
|
||||
|
||||
aReportItem = itemDynamicCast<MessageModel_ItemReport> (anItemBase);
|
||||
aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItemBase);
|
||||
theReportIndex = anIndex;
|
||||
if (aReportItem)
|
||||
break;
|
||||
@@ -150,7 +162,7 @@ Handle(Message_Report) MessageModel_Actions::getSelectedReport (QModelIndex& the
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
static Handle(Message_PrinterToReport) MyPrinterToReport;
|
||||
static Message_SequenceOfPrinters MyDeactivatedPrinters;
|
||||
static Message_SequenceOfPrinters MyDeactivatedPrinters;
|
||||
|
||||
void MessageModel_Actions::OnActivateReport()
|
||||
{
|
||||
@@ -163,7 +175,7 @@ void MessageModel_Actions::OnActivateReport()
|
||||
MyDeactivatedPrinters = Message::DefaultMessenger()->Printers();
|
||||
Message::DefaultMessenger()->ChangePrinters().Clear();
|
||||
|
||||
Message::DefaultMessenger()->AddPrinter (MyPrinterToReport);
|
||||
Message::DefaultMessenger()->AddPrinter(MyPrinterToReport);
|
||||
Message::DefaultReport()->UpdateActiveInMessenger();
|
||||
|
||||
myTreeModel->UpdateTreeModel();
|
||||
@@ -178,8 +190,8 @@ void MessageModel_Actions::OnDeactivateReport()
|
||||
if (MyPrinterToReport.IsNull() || !MyPrinterToReport->Report()->IsActiveInMessenger())
|
||||
return;
|
||||
|
||||
Message::DefaultMessenger()->RemovePrinter (MyPrinterToReport);
|
||||
Message::DefaultMessenger()->ChangePrinters().Assign (MyDeactivatedPrinters);
|
||||
Message::DefaultMessenger()->RemovePrinter(MyPrinterToReport);
|
||||
Message::DefaultMessenger()->ChangePrinters().Assign(MyDeactivatedPrinters);
|
||||
|
||||
myTreeModel->UpdateTreeModel();
|
||||
}
|
||||
@@ -190,8 +202,8 @@ void MessageModel_Actions::OnDeactivateReport()
|
||||
// =======================================================================
|
||||
void MessageModel_Actions::OnClearReport()
|
||||
{
|
||||
QModelIndex aReportIndex;
|
||||
Handle(Message_Report) aReport = getSelectedReport (aReportIndex);
|
||||
QModelIndex aReportIndex;
|
||||
Handle(Message_Report) aReport = getSelectedReport(aReportIndex);
|
||||
if (aReport.IsNull())
|
||||
return;
|
||||
|
||||
@@ -205,28 +217,30 @@ void MessageModel_Actions::OnClearReport()
|
||||
// =======================================================================
|
||||
void MessageModel_Actions::OnExportToShapeView()
|
||||
{
|
||||
TCollection_AsciiString aPluginName ("TKShapeView");
|
||||
TCollection_AsciiString aPluginName("TKShapeView");
|
||||
|
||||
NCollection_List<Handle(Standard_Transient)> aPluginParameters;
|
||||
if (myParameters->FindParameters (aPluginName))
|
||||
aPluginParameters = myParameters->Parameters (aPluginName);
|
||||
if (myParameters->FindParameters(aPluginName))
|
||||
aPluginParameters = myParameters->Parameters(aPluginName);
|
||||
NCollection_List<TCollection_AsciiString> anItemNames;
|
||||
if (myParameters->FindSelectedNames (aPluginName))
|
||||
anItemNames = myParameters->GetSelectedNames (aPluginName);
|
||||
if (myParameters->FindSelectedNames(aPluginName))
|
||||
anItemNames = myParameters->GetSelectedNames(aPluginName);
|
||||
|
||||
QModelIndexList aSelectedIndices = mySelectionModel->selectedIndexes();
|
||||
QStringList anExportedPointers;
|
||||
for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
|
||||
QStringList anExportedPointers;
|
||||
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);
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
|
||||
if (!anItemBase)
|
||||
continue;
|
||||
|
||||
MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (anItemBase);
|
||||
MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
|
||||
if (!anAlertItem)
|
||||
continue;
|
||||
|
||||
@@ -234,7 +248,7 @@ void MessageModel_Actions::OnExportToShapeView()
|
||||
if (anAlert.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (anAlert);
|
||||
Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
|
||||
if (anExtAlert.IsNull())
|
||||
continue;
|
||||
|
||||
@@ -242,22 +256,25 @@ void MessageModel_Actions::OnExportToShapeView()
|
||||
if (anAttribute.IsNull())
|
||||
continue;
|
||||
|
||||
if (!anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
|
||||
if (!anAttribute->IsKind(STANDARD_TYPE(TopoDS_AlertAttribute)))
|
||||
continue;
|
||||
|
||||
const TopoDS_Shape aShape = Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape();
|
||||
const TopoDS_Shape aShape = Handle(TopoDS_AlertAttribute)::DownCast(anAttribute)->GetShape();
|
||||
if (aShape.IsNull())
|
||||
continue;
|
||||
aPluginParameters.Append (aShape.TShape());
|
||||
anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString (aShape));
|
||||
aPluginParameters.Append(aShape.TShape());
|
||||
anItemNames.Append(TInspectorAPI_PluginParameters::ParametersToString(aShape));
|
||||
|
||||
anExportedPointers.append (Standard_Dump::GetPointerInfo (aShape.TShape(), true).ToCString());
|
||||
anExportedPointers.append(Standard_Dump::GetPointerInfo(aShape.TShape(), true).ToCString());
|
||||
}
|
||||
|
||||
if (anExportedPointers.empty())
|
||||
return;
|
||||
myParameters->SetSelectedNames (aPluginName, anItemNames);
|
||||
myParameters->SetParameters (aPluginName, aPluginParameters);
|
||||
QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.")
|
||||
.arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString())));
|
||||
return;
|
||||
myParameters->SetSelectedNames(aPluginName, anItemNames);
|
||||
myParameters->SetParameters(aPluginName, aPluginParameters);
|
||||
QMessageBox::information(0,
|
||||
"Information",
|
||||
QString("TShapes '%1' are sent to %2 tool.")
|
||||
.arg(anExportedPointers.join(", "))
|
||||
.arg(QString(aPluginName.ToCString())));
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_Actions_H
|
||||
#define MessageModel_Actions_H
|
||||
@@ -45,11 +45,10 @@ class MessageModel_Actions : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT MessageModel_Actions (QWidget* theParent,
|
||||
MessageModel_TreeModel* theTreeModel,
|
||||
QItemSelectionModel* theModel);
|
||||
Standard_EXPORT MessageModel_Actions(QWidget* theParent,
|
||||
MessageModel_TreeModel* theTreeModel,
|
||||
QItemSelectionModel* theModel);
|
||||
|
||||
//! Destructor
|
||||
virtual ~MessageModel_Actions() Standard_OVERRIDE {}
|
||||
@@ -57,17 +56,19 @@ public:
|
||||
//! Returns action by the type
|
||||
//! \param theType an action type
|
||||
//! \return an action instance if it exists
|
||||
Standard_EXPORT QAction* GetAction (const MessageModel_ActionType& theType);
|
||||
Standard_EXPORT QAction* GetAction(const MessageModel_ActionType& theType);
|
||||
|
||||
//! 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);
|
||||
Standard_EXPORT void AddMenuActions(const QModelIndexList& theSelectedIndices, QMenu* theMenu);
|
||||
|
||||
//! Sets parameters container, it should be used when the plugin is initialized or in update content
|
||||
//! \param theParameters a parameters container
|
||||
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
|
||||
{ myParameters = theParameters; }
|
||||
//! Sets parameters container, it should be used when the plugin is initialized or in update
|
||||
//! content \param theParameters a parameters container
|
||||
void SetParameters(const Handle(TInspectorAPI_PluginParameters)& theParameters)
|
||||
{
|
||||
myParameters = theParameters;
|
||||
}
|
||||
|
||||
public slots:
|
||||
//! Set selected report active
|
||||
@@ -86,13 +87,13 @@ 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;
|
||||
Handle(Message_Report) getSelectedReport(QModelIndex& theReportIndex) const;
|
||||
|
||||
protected:
|
||||
MessageModel_TreeModel* myTreeModel; //< tree model
|
||||
QItemSelectionModel* mySelectionModel; //< selection model
|
||||
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
|
||||
QMap<MessageModel_ActionType, QAction*> myActions; //!< container of all actions
|
||||
MessageModel_TreeModel* myTreeModel; //< tree model
|
||||
QItemSelectionModel* mySelectionModel; //< selection model
|
||||
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
|
||||
QMap<MessageModel_ActionType, QAction*> myActions; //!< container of all actions
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_ItemAlert.hxx>
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant MessageModel_ItemAlert::initValue (const int theRole) const
|
||||
QVariant MessageModel_ItemAlert::initValue(const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue(theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
MessageModel_ItemReportPtr aReportItem = MessageModel_ItemReport::FindReportItem (Parent());
|
||||
MessageModel_ItemReportPtr aReportItem = MessageModel_ItemReport::FindReportItem(Parent());
|
||||
if (!aReportItem)
|
||||
return QVariant();
|
||||
|
||||
@@ -63,7 +63,7 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Handle(Message_Alert) anAlert = getAlert();
|
||||
Handle(Message_Alert) anAlert = getAlert();
|
||||
Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
|
||||
|
||||
// if the alert is composite, process the real alert
|
||||
@@ -76,10 +76,10 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
|
||||
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_streamValues.png");
|
||||
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_streamValues.png");
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
@@ -104,32 +104,36 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
|
||||
}
|
||||
|
||||
Message_MetricType aMetricType;
|
||||
int aPosition;
|
||||
if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition))
|
||||
int aPosition;
|
||||
if (MessageModel_TreeModel::IsMetricColumn(Column(), aMetricType, aPosition))
|
||||
{
|
||||
if (anExtendedAlert.IsNull())
|
||||
return QVariant();
|
||||
|
||||
Handle(Message_AttributeMeter) anAttribute = Handle(Message_AttributeMeter)::DownCast (anExtendedAlert->Attribute());
|
||||
if (anAttribute.IsNull() || !anAttribute->HasMetric (aMetricType))
|
||||
Handle(Message_AttributeMeter) anAttribute =
|
||||
Handle(Message_AttributeMeter)::DownCast(anExtendedAlert->Attribute());
|
||||
if (anAttribute.IsNull() || !anAttribute->HasMetric(aMetricType))
|
||||
return QVariant();
|
||||
|
||||
if (!anAttribute->IsMetricValid (aMetricType))
|
||||
return QVariant ("in process");
|
||||
if (!anAttribute->IsMetricValid(aMetricType))
|
||||
return QVariant("in process");
|
||||
|
||||
if (aMetricType == Message_MetricType_ProcessCPUUserTime ||
|
||||
aMetricType == Message_MetricType_ProcessCPUSystemTime ||
|
||||
aMetricType == Message_MetricType_WallClock)
|
||||
if (aMetricType == Message_MetricType_ProcessCPUUserTime
|
||||
|| aMetricType == Message_MetricType_ProcessCPUSystemTime
|
||||
|| aMetricType == Message_MetricType_WallClock)
|
||||
{
|
||||
Standard_Real aCumulativeMetric = anAttribute->StopValue (aMetricType) - anAttribute->StartValue (aMetricType);
|
||||
if (fabs (aCumulativeMetric) < Precision::Confusion())
|
||||
Standard_Real aCumulativeMetric =
|
||||
anAttribute->StopValue(aMetricType) - anAttribute->StartValue(aMetricType);
|
||||
if (fabs(aCumulativeMetric) < Precision::Confusion())
|
||||
return QVariant();
|
||||
|
||||
if (aPosition == 0) return aCumulativeMetric;
|
||||
if (aPosition == 0)
|
||||
return aCumulativeMetric;
|
||||
else if (aPosition == 1)
|
||||
{
|
||||
Standard_Real aReportCumulativeMetric = MessageModel_ItemReport::CumulativeMetric (aReport, aMetricType);
|
||||
if (fabs (aReportCumulativeMetric) > Precision::Confusion())
|
||||
Standard_Real aReportCumulativeMetric =
|
||||
MessageModel_ItemReport::CumulativeMetric(aReport, aMetricType);
|
||||
if (fabs(aReportCumulativeMetric) > Precision::Confusion())
|
||||
return 100. * aCumulativeMetric / aReportCumulativeMetric;
|
||||
else
|
||||
return QVariant();
|
||||
@@ -137,16 +141,17 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aPosition == 0) return anAttribute->StopValue (aMetricType);
|
||||
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())
|
||||
Standard_Real aCumulativeMetric =
|
||||
anAttribute->StopValue(aMetricType) - anAttribute->StartValue(aMetricType);
|
||||
if (fabs(aCumulativeMetric) < Precision::Confusion())
|
||||
return QVariant();
|
||||
else
|
||||
return aCumulativeMetric;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
@@ -173,12 +178,12 @@ int MessageModel_ItemAlert::initRowCount() const
|
||||
MessageModel_ItemAlert* aCurrentItem = (MessageModel_ItemAlert*)this;
|
||||
for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
|
||||
{
|
||||
const Message_ListOfAlert& anAlerts = aCompositeAlert->Alerts ((Message_Gravity)aGravityId);
|
||||
const Message_ListOfAlert& anAlerts = aCompositeAlert->Alerts((Message_Gravity)aGravityId);
|
||||
{
|
||||
for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next())
|
||||
{
|
||||
Message_ListOfAlert aCurAlerts;
|
||||
aCurAlerts.Append (anIt.Value());
|
||||
aCurAlerts.Append(anIt.Value());
|
||||
aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts);
|
||||
}
|
||||
}
|
||||
@@ -190,9 +195,10 @@ int MessageModel_ItemAlert::initRowCount() const
|
||||
// function : initStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_ItemAlert::initStream (Standard_OStream& theOStream) const
|
||||
void MessageModel_ItemAlert::initStream(Standard_OStream& theOStream) const
|
||||
{
|
||||
Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert());
|
||||
Handle(Message_AlertExtended) anExtendedAlert =
|
||||
Handle(Message_AlertExtended)::DownCast(getAlert());
|
||||
if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull())
|
||||
return;
|
||||
|
||||
@@ -203,7 +209,8 @@ void MessageModel_ItemAlert::initStream (Standard_OStream& theOStream) const
|
||||
if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull())
|
||||
return;
|
||||
|
||||
Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute());
|
||||
Handle(Message_AttributeStream) anAttributeStream =
|
||||
Handle(Message_AttributeStream)::DownCast(anExtendedAlert->Attribute());
|
||||
theOStream << anAttributeStream->Stream().str();
|
||||
}
|
||||
|
||||
@@ -211,10 +218,12 @@ void MessageModel_ItemAlert::initStream (Standard_OStream& theOStream) const
|
||||
// function : SetStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool MessageModel_ItemAlert::SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
|
||||
Standard_Integer& theLastPos) const
|
||||
bool MessageModel_ItemAlert::SetStream(const Standard_SStream& theSStream,
|
||||
Standard_Integer& theStartPos,
|
||||
Standard_Integer& theLastPos) const
|
||||
{
|
||||
Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert());
|
||||
Handle(Message_AlertExtended) anExtendedAlert =
|
||||
Handle(Message_AlertExtended)::DownCast(getAlert());
|
||||
if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull())
|
||||
return false;
|
||||
|
||||
@@ -225,18 +234,19 @@ bool MessageModel_ItemAlert::SetStream (const Standard_SStream& theSStream, Stan
|
||||
if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull())
|
||||
return false;
|
||||
|
||||
Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute());
|
||||
TCollection_AsciiString aStreamValue = Standard_Dump::Text (anAttributeStream->Stream());
|
||||
Handle(Message_AttributeStream) anAttributeStream =
|
||||
Handle(Message_AttributeStream)::DownCast(anExtendedAlert->Attribute());
|
||||
TCollection_AsciiString aStreamValue = Standard_Dump::Text(anAttributeStream->Stream());
|
||||
|
||||
TCollection_AsciiString aNewValue = Standard_Dump::Text (theSStream);
|
||||
TCollection_AsciiString aNewValue = Standard_Dump::Text(theSStream);
|
||||
|
||||
Standard_SStream aStream;
|
||||
aStream << aStreamValue.SubString (1, theStartPos - 1);
|
||||
aStream << aStreamValue.SubString(1, theStartPos - 1);
|
||||
aStream << aNewValue;
|
||||
if (theLastPos + 1 <= aStreamValue.Length())
|
||||
aStream << aStreamValue.SubString (theLastPos + 1, aStreamValue.Length());
|
||||
aStream << aStreamValue.SubString(theLastPos + 1, aStreamValue.Length());
|
||||
|
||||
anAttributeStream->SetStream (aStream);
|
||||
anAttributeStream->SetStream(aStream);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -245,9 +255,9 @@ bool MessageModel_ItemAlert::SetStream (const Standard_SStream& theSStream, Stan
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr MessageModel_ItemAlert::createChild (int theRow, int theColumn)
|
||||
TreeModel_ItemBasePtr MessageModel_ItemAlert::createChild(int theRow, int theColumn)
|
||||
{
|
||||
return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn);
|
||||
return MessageModel_ItemAlert::CreateItem(currentItem(), theRow, theColumn);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -256,24 +266,24 @@ TreeModel_ItemBasePtr MessageModel_ItemAlert::createChild (int theRow, int theCo
|
||||
// =======================================================================
|
||||
void MessageModel_ItemAlert::Init()
|
||||
{
|
||||
MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport> (Parent());
|
||||
MessageModel_ItemAlertPtr anAlertItem;
|
||||
Handle(Message_Alert) anAlert;
|
||||
MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(Parent());
|
||||
MessageModel_ItemAlertPtr anAlertItem;
|
||||
Handle(Message_Alert) anAlert;
|
||||
if (aReportItem)
|
||||
{
|
||||
Message_ListOfAlert anAlerts;
|
||||
if (aReportItem->GetChildAlerts (Row(), anAlerts))
|
||||
if (aReportItem->GetChildAlerts(Row(), anAlerts))
|
||||
{
|
||||
myAlert = anAlerts.First();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (Parent());
|
||||
anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(Parent());
|
||||
if (anAlertItem)
|
||||
{
|
||||
Message_ListOfAlert anAlerts;
|
||||
if (anAlertItem->GetChildAlerts (Row(), anAlerts))
|
||||
if (anAlertItem->GetChildAlerts(Row(), anAlerts))
|
||||
{
|
||||
myAlert = anAlerts.First();
|
||||
}
|
||||
@@ -286,8 +296,9 @@ void MessageModel_ItemAlert::Init()
|
||||
Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute();
|
||||
if (!anAttribute.IsNull())
|
||||
{
|
||||
if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
|
||||
myPresentation = new Convert_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape());
|
||||
if (anAttribute->IsKind(STANDARD_TYPE(TopoDS_AlertAttribute)))
|
||||
myPresentation = new Convert_TransientShape(
|
||||
Handle(TopoDS_AlertAttribute)::DownCast(anAttribute)->GetShape());
|
||||
}
|
||||
}
|
||||
MessageModel_ItemBase::Init();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_ItemAlert_H
|
||||
#define MessageModel_ItemAlert_H
|
||||
@@ -39,7 +39,8 @@ typedef QExplicitlySharedDataPointer<MessageModel_ItemAlert> MessageModel_ItemAl
|
||||
|
||||
//! \class MessageModel_ItemAlert
|
||||
//! This item is connected to Message_Alert.
|
||||
//! Parent is either MessageModel_ItemRoot or MessageModel_ItemAlert, children are MessageModel_ItemAlert or no children
|
||||
//! Parent is either MessageModel_ItemRoot or MessageModel_ItemAlert, children are
|
||||
//! MessageModel_ItemAlert or no children
|
||||
class MessageModel_ItemAlert : public MessageModel_ItemBase
|
||||
{
|
||||
public:
|
||||
@@ -47,8 +48,12 @@ public:
|
||||
//! \param theRow the item row positition in the parent item
|
||||
//! \param theColumn the item column positition in the parent item
|
||||
//! \return the pointer to the created item
|
||||
static MessageModel_ItemAlertPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return MessageModel_ItemAlertPtr (new MessageModel_ItemAlert (theParent, theRow, theColumn)); }
|
||||
static MessageModel_ItemAlertPtr CreateItem(TreeModel_ItemBasePtr theParent,
|
||||
const int theRow,
|
||||
const int theColumn)
|
||||
{
|
||||
return MessageModel_ItemAlertPtr(new MessageModel_ItemAlert(theParent, theRow, theColumn));
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~MessageModel_ItemAlert() Standard_OVERRIDE {};
|
||||
@@ -57,7 +62,10 @@ public:
|
||||
const Handle(Message_Alert)& GetAlert() const { return myAlert; }
|
||||
|
||||
//! Returns alert of the report for the parameter row
|
||||
Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); }
|
||||
Standard_Boolean GetChildAlerts(const int theRow, Message_ListOfAlert& theAlerts) const
|
||||
{
|
||||
return myChildAlerts.Find(theRow, theAlerts);
|
||||
}
|
||||
|
||||
//! Inits the item, fills internal containers
|
||||
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
|
||||
@@ -68,49 +76,55 @@ public:
|
||||
//! Return data value for the role.
|
||||
//! \param theRole a value role
|
||||
//! \return the value
|
||||
Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual QVariant initValue(const int theRole) const Standard_OVERRIDE;
|
||||
|
||||
//! \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 bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
|
||||
Standard_Integer& theLastPos) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual bool SetStream(const Standard_SStream& theSStream,
|
||||
Standard_Integer& theStartPos,
|
||||
Standard_Integer& theLastPos) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns presentation of the attribute to be visualized in the view
|
||||
//! \thePresentations[out] container of presentation handles to be visualized
|
||||
virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE
|
||||
{ TreeModel_ItemBase::Presentations (thePresentations); thePresentations.Append (myPresentation); }
|
||||
virtual void Presentations(NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
Standard_OVERRIDE
|
||||
{
|
||||
TreeModel_ItemBase::Presentations(thePresentations);
|
||||
thePresentations.Append(myPresentation);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Initialize the current item.
|
||||
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;
|
||||
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
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
|
||||
virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
|
||||
|
||||
//! Returns current alert, initialized item if it has not been initialized yet
|
||||
//! \return alert value
|
||||
const Handle(Message_Alert)& getAlert() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
MessageModel_ItemAlert (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase (theParent, theRow, theColumn) {}
|
||||
MessageModel_ItemAlert(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase(theParent, theRow, theColumn)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
Handle(Message_Alert) myAlert; //!< current alert item
|
||||
NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
|
||||
NCollection_DataMap<Standard_Integer, Message_ListOfAlert>
|
||||
myChildAlerts; //!< container of child alerts
|
||||
Handle(Standard_Transient) myPresentation; //!< item presentation
|
||||
};
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_ItemBase.hxx>
|
||||
#include <inspector/MessageModel_ItemRoot.hxx>
|
||||
@@ -25,7 +25,7 @@ TreeModel_ItemBasePtr MessageModel_ItemBase::GetRootItem() const
|
||||
TreeModel_ItemBasePtr anItem = Parent();
|
||||
while (anItem)
|
||||
{
|
||||
if (MessageModel_ItemRootPtr aThisRootItem = itemDynamicCast<MessageModel_ItemRoot> (anItem))
|
||||
if (MessageModel_ItemRootPtr aThisRootItem = itemDynamicCast<MessageModel_ItemRoot>(anItem))
|
||||
{
|
||||
return aThisRootItem;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_ItemBase_H
|
||||
#define MessageModel_ItemBase_H
|
||||
@@ -28,12 +28,10 @@ typedef QExplicitlySharedDataPointer<MessageModel_ItemBase> MessageModel_ItemBas
|
||||
class MessageModel_ItemBase : public TreeModel_ItemBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! Resets cached values
|
||||
virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
|
||||
|
||||
protected:
|
||||
|
||||
//! Initialize the current item. It creates a backup of the specific item information
|
||||
virtual void initItem() const Standard_OVERRIDE {};
|
||||
|
||||
@@ -41,8 +39,10 @@ protected:
|
||||
//! param theParent a parent item
|
||||
//! \param theRow the item row positition in the parent item
|
||||
//! \param theColumn the item column positition in the parent item
|
||||
MessageModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: TreeModel_ItemBase (theParent, theRow, theColumn) {}
|
||||
MessageModel_ItemBase(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: TreeModel_ItemBase(theParent, theRow, theColumn)
|
||||
{
|
||||
}
|
||||
|
||||
//! Return root item
|
||||
//! \return an item instance
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_ItemReport.hxx>
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant MessageModel_ItemReport::initValue (const int theRole) const
|
||||
QVariant MessageModel_ItemReport::initValue(const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue(theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
@@ -51,10 +51,11 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
if (theRole == Qt::ToolTipRole && !myDescription.IsEmpty() && Column() == 0) // display the exported file name in tool tip
|
||||
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());
|
||||
return QString("%1%2").arg(aPath.Name().ToCString()).arg(aPath.Extension().ToCString());
|
||||
}
|
||||
|
||||
if (theRole != Qt::DisplayRole)
|
||||
@@ -64,13 +65,16 @@ QVariant MessageModel_ItemReport::initValue (const int theRole) const
|
||||
return aReport->DynamicType()->Name();
|
||||
|
||||
Message_MetricType aMetricType;
|
||||
int aPosition;
|
||||
if (MessageModel_TreeModel::IsMetricColumn (Column(), aMetricType, aPosition) &&
|
||||
(aMetricType == Message_MetricType_ProcessCPUUserTime || aMetricType == Message_MetricType_ProcessCPUSystemTime ||
|
||||
aMetricType == Message_MetricType_WallClock))
|
||||
int aPosition;
|
||||
if (MessageModel_TreeModel::IsMetricColumn(Column(), aMetricType, aPosition)
|
||||
&& (aMetricType == Message_MetricType_ProcessCPUUserTime
|
||||
|| aMetricType == Message_MetricType_ProcessCPUSystemTime
|
||||
|| aMetricType == Message_MetricType_WallClock))
|
||||
{
|
||||
if (aPosition == 0) return CumulativeMetric (aReport, aMetricType);
|
||||
else if (aPosition == 1) return "100";
|
||||
if (aPosition == 0)
|
||||
return CumulativeMetric(aReport, aMetricType);
|
||||
else if (aPosition == 1)
|
||||
return "100";
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@@ -88,11 +92,11 @@ int MessageModel_ItemReport::initRowCount() const
|
||||
MessageModel_ItemReport* aCurrentItem = (MessageModel_ItemReport*)this;
|
||||
for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++)
|
||||
{
|
||||
const Message_ListOfAlert& anAlerts = aReport->GetAlerts ((Message_Gravity)aGravityId);
|
||||
const Message_ListOfAlert& anAlerts = aReport->GetAlerts((Message_Gravity)aGravityId);
|
||||
for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next())
|
||||
{
|
||||
Message_ListOfAlert aCurAlerts;
|
||||
aCurAlerts.Append (anIt.Value());
|
||||
aCurAlerts.Append(anIt.Value());
|
||||
aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts);
|
||||
}
|
||||
}
|
||||
@@ -103,9 +107,9 @@ int MessageModel_ItemReport::initRowCount() const
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr MessageModel_ItemReport::createChild (int theRow, int theColumn)
|
||||
TreeModel_ItemBasePtr MessageModel_ItemReport::createChild(int theRow, int theColumn)
|
||||
{
|
||||
return MessageModel_ItemAlert::CreateItem (currentItem(), theRow, theColumn);
|
||||
return MessageModel_ItemAlert::CreateItem(currentItem(), theRow, theColumn);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -114,8 +118,8 @@ TreeModel_ItemBasePtr MessageModel_ItemReport::createChild (int theRow, int theC
|
||||
// =======================================================================
|
||||
void MessageModel_ItemReport::Init()
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (Parent());
|
||||
myReport = aRootItem ? aRootItem->GetReport (Row(), myDescription) : Handle(Message_Report)();
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(Parent());
|
||||
myReport = aRootItem ? aRootItem->GetReport(Row(), myDescription) : Handle(Message_Report)();
|
||||
|
||||
MessageModel_ItemBase::Init();
|
||||
}
|
||||
@@ -156,7 +160,8 @@ void MessageModel_ItemReport::initItem() const
|
||||
// function : FindReportItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
MessageModel_ItemReportPtr MessageModel_ItemReport::FindReportItem (const TreeModel_ItemBasePtr& theItem)
|
||||
MessageModel_ItemReportPtr MessageModel_ItemReport::FindReportItem(
|
||||
const TreeModel_ItemBasePtr& theItem)
|
||||
{
|
||||
TreeModel_ItemBasePtr anItem = theItem;
|
||||
while (anItem)
|
||||
@@ -173,7 +178,7 @@ MessageModel_ItemReportPtr MessageModel_ItemReport::FindReportItem (const TreeMo
|
||||
// function : FindReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_ItemBasePtr& theItem)
|
||||
Handle(Message_Report) MessageModel_ItemReport::FindReport(const MessageModel_ItemBasePtr& theItem)
|
||||
{
|
||||
Handle(Message_Report) aReport;
|
||||
|
||||
@@ -194,39 +199,45 @@ Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_I
|
||||
// function : CumulativeMetric
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Real MessageModel_ItemReport::CumulativeMetric (const Handle(Message_Report)& theReport, const Message_MetricType theMetricType)
|
||||
Standard_Real MessageModel_ItemReport::CumulativeMetric(const Handle(Message_Report)& theReport,
|
||||
const Message_MetricType theMetricType)
|
||||
{
|
||||
if (!theReport->ActiveMetrics().Contains (theMetricType))
|
||||
if (!theReport->ActiveMetrics().Contains(theMetricType))
|
||||
return 0;
|
||||
|
||||
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())
|
||||
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());
|
||||
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() || !anAttribute->HasMetric (theMetricType) || !anAttribute->IsMetricValid (theMetricType))
|
||||
Handle(Message_AttributeMeter) anAttribute =
|
||||
Handle(Message_AttributeMeter)::DownCast(anAlert->Attribute());
|
||||
if (anAttribute.IsNull() || !anAttribute->HasMetric(theMetricType)
|
||||
|| !anAttribute->IsMetricValid(theMetricType))
|
||||
continue;
|
||||
|
||||
//if (aFirstAttribute.IsNull())
|
||||
// aFirstAttribute = anAttribute;
|
||||
//else
|
||||
// if (aFirstAttribute.IsNull())
|
||||
// aFirstAttribute = anAttribute;
|
||||
// else
|
||||
//{
|
||||
//aLastAttribute = anAttribute;
|
||||
// aLastAttribute = anAttribute;
|
||||
//}
|
||||
aMetric += anAttribute->StopValue (theMetricType) - anAttribute->StartValue (theMetricType);
|
||||
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;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_ItemReport_H
|
||||
#define MessageModel_ItemReport_H
|
||||
@@ -37,13 +37,16 @@ typedef QExplicitlySharedDataPointer<MessageModel_ItemReport> MessageModel_ItemR
|
||||
class MessageModel_ItemReport : public MessageModel_ItemBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
//! \param theRow the item row positition in the parent item
|
||||
//! \param theColumn the item column positition in the parent item
|
||||
//! \return the pointer to the created item
|
||||
static MessageModel_ItemReportPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return MessageModel_ItemReportPtr (new MessageModel_ItemReport (theParent, theRow, theColumn)); }
|
||||
static MessageModel_ItemReportPtr CreateItem(TreeModel_ItemBasePtr theParent,
|
||||
const int theRow,
|
||||
const int theColumn)
|
||||
{
|
||||
return MessageModel_ItemReportPtr(new MessageModel_ItemReport(theParent, theRow, theColumn));
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~MessageModel_ItemReport() Standard_OVERRIDE {};
|
||||
@@ -52,7 +55,10 @@ public:
|
||||
const Handle(Message_Report)& GetReport() const { return myReport; }
|
||||
|
||||
//! Returns alert of the report for the parameter row
|
||||
Standard_Boolean GetChildAlerts (const int theRow, Message_ListOfAlert& theAlerts) const { return myChildAlerts.Find(theRow, theAlerts); }
|
||||
Standard_Boolean GetChildAlerts(const int theRow, Message_ListOfAlert& theAlerts) const
|
||||
{
|
||||
return myChildAlerts.Find(theRow, theAlerts);
|
||||
}
|
||||
|
||||
//! Returns the report description or NULL
|
||||
const TCollection_AsciiString& GetDescription() const { return myDescription; }
|
||||
@@ -66,23 +72,25 @@ public:
|
||||
//! Return data value for the role.
|
||||
//! \param theRole a value role
|
||||
//! \return the value
|
||||
Standard_EXPORT virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual QVariant initValue(const int theRole) const Standard_OVERRIDE;
|
||||
|
||||
//! \return number of children.
|
||||
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns report of the tree model item. Iterates up by parents intil the report item is found.
|
||||
//! \return an item or NULL
|
||||
Standard_EXPORT static MessageModel_ItemReportPtr FindReportItem (const TreeModel_ItemBasePtr& theItem);
|
||||
Standard_EXPORT static MessageModel_ItemReportPtr FindReportItem(
|
||||
const TreeModel_ItemBasePtr& theItem);
|
||||
|
||||
//! Returns report of the item
|
||||
static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem);
|
||||
static Handle(Message_Report) FindReport(const MessageModel_ItemBasePtr& thetItem);
|
||||
|
||||
//! 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);
|
||||
//! 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.
|
||||
virtual void initItem() const Standard_OVERRIDE;
|
||||
|
||||
@@ -90,7 +98,7 @@ protected:
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
|
||||
virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
|
||||
|
||||
//! Returns number of child shapes. Init item if it is not initialized
|
||||
//! \return integer value
|
||||
@@ -101,16 +109,17 @@ protected:
|
||||
const Handle(Message_Report)& getReport() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
MessageModel_ItemReport (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase (theParent, theRow, theColumn) {}
|
||||
MessageModel_ItemReport(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase(theParent, theRow, theColumn)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NCollection_DataMap<Standard_Integer, Message_ListOfAlert>
|
||||
myChildAlerts; //!< container of child alerts
|
||||
|
||||
NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
|
||||
|
||||
Handle(Message_Report) myReport; //!< current report
|
||||
Handle(Message_Report) myReport; //!< current report
|
||||
TCollection_AsciiString myDescription; //!< description
|
||||
};
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_ItemRoot.hxx>
|
||||
#include <inspector/MessageModel_ItemReport.hxx>
|
||||
@@ -20,16 +20,17 @@
|
||||
// function : SetReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_ItemRoot::SetReport (const int theRowId, const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
void MessageModel_ItemRoot::SetReport(const int theRowId,
|
||||
const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
{
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt(myReports);
|
||||
for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
|
||||
{
|
||||
if (aRowId == theRowId)
|
||||
break;
|
||||
}
|
||||
aReportsIt.ChangeValue().myReport = theReport;
|
||||
aReportsIt.ChangeValue().myReport = theReport;
|
||||
aReportsIt.ChangeValue().myDescription = theReportDescription;
|
||||
}
|
||||
|
||||
@@ -37,10 +38,11 @@ void MessageModel_ItemRoot::SetReport (const int theRowId, const Handle(Message_
|
||||
// function : GetReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Handle(Message_Report)& MessageModel_ItemRoot::GetReport (const int theRowId,
|
||||
const Handle(Message_Report)& MessageModel_ItemRoot::GetReport(
|
||||
const int theRowId,
|
||||
TCollection_AsciiString& theReportDescription)
|
||||
{
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt(myReports);
|
||||
for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
|
||||
{
|
||||
if (aRowId == theRowId)
|
||||
@@ -54,9 +56,9 @@ const Handle(Message_Report)& MessageModel_ItemRoot::GetReport (const int theRow
|
||||
// function : HasReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean MessageModel_ItemRoot::HasReport (const Handle(Message_Report)& theReport)
|
||||
Standard_Boolean MessageModel_ItemRoot::HasReport(const Handle(Message_Report)& theReport)
|
||||
{
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt (myReports);
|
||||
NCollection_List<MessageModel_ReportInformation>::Iterator aReportsIt(myReports);
|
||||
for (int aRowId = 0; aReportsIt.More(); aReportsIt.Next(), aRowId++)
|
||||
{
|
||||
if (aReportsIt.Value().myReport == theReport)
|
||||
@@ -69,9 +71,9 @@ Standard_Boolean MessageModel_ItemRoot::HasReport (const Handle(Message_Report)&
|
||||
// function : initValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant MessageModel_ItemRoot::initValue (const int theRole) const
|
||||
QVariant MessageModel_ItemRoot::initValue(const int theRole) const
|
||||
{
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue (theRole);
|
||||
QVariant aParentValue = MessageModel_ItemBase::initValue(theRole);
|
||||
if (aParentValue.isValid())
|
||||
return aParentValue;
|
||||
|
||||
@@ -88,8 +90,7 @@ QVariant MessageModel_ItemRoot::initValue (const int theRole) const
|
||||
// function : createChild
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr MessageModel_ItemRoot::createChild (int theRow, int theColumn)
|
||||
TreeModel_ItemBasePtr MessageModel_ItemRoot::createChild(int theRow, int theColumn)
|
||||
{
|
||||
return MessageModel_ItemReport::CreateItem (currentItem(), theRow, theColumn);
|
||||
return MessageModel_ItemReport::CreateItem(currentItem(), theRow, theColumn);
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_ItemRoot_H
|
||||
#define MessageModel_ItemRoot_H
|
||||
@@ -31,24 +31,31 @@ typedef QExplicitlySharedDataPointer<MessageModel_ItemRoot> MessageModel_ItemRoo
|
||||
struct MessageModel_ReportInformation
|
||||
{
|
||||
//! Constructor
|
||||
MessageModel_ReportInformation (Handle(Message_Report) theReport, const TCollection_AsciiString& theDescription)
|
||||
: myReport (theReport), myDescription (theDescription) {}
|
||||
MessageModel_ReportInformation(Handle(Message_Report) theReport,
|
||||
const TCollection_AsciiString& theDescription)
|
||||
: myReport(theReport),
|
||||
myDescription(theDescription)
|
||||
{
|
||||
}
|
||||
|
||||
Handle(Message_Report) myReport; //! report
|
||||
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.
|
||||
//! 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
|
||||
{
|
||||
public:
|
||||
|
||||
//! Creates an item wrapped by a shared pointer
|
||||
static MessageModel_ItemRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
{ return MessageModel_ItemRootPtr (new MessageModel_ItemRoot (theParent, theRow, theColumn)); }
|
||||
static MessageModel_ItemRootPtr CreateItem(TreeModel_ItemBasePtr theParent,
|
||||
const int theRow,
|
||||
const int theColumn)
|
||||
{
|
||||
return MessageModel_ItemRootPtr(new MessageModel_ItemRoot(theParent, theRow, theColumn));
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~MessageModel_ItemRoot() Standard_OVERRIDE {};
|
||||
@@ -56,20 +63,24 @@ public:
|
||||
//! Appends new report
|
||||
//! \param theReport a report instance
|
||||
//! \param theReportDescription an additional report information
|
||||
void AddReport (const Handle(Message_Report)& theReport, const TCollection_AsciiString& theReportDescription)
|
||||
{ myReports.Append (MessageModel_ReportInformation (theReport, theReportDescription)); }
|
||||
void AddReport(const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
{
|
||||
myReports.Append(MessageModel_ReportInformation(theReport, theReportDescription));
|
||||
}
|
||||
|
||||
//! Set report, se it into the given row index
|
||||
//! \param theRowId a report child row
|
||||
//! \param theReport a report instance
|
||||
//! \param theReportDescription an additional report information
|
||||
Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription = "");
|
||||
Standard_EXPORT void SetReport(const int theRowId,
|
||||
const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription = "");
|
||||
|
||||
//! Returns true if report exists is in the list of the current reports
|
||||
//! \param theReport a report instance
|
||||
//! \return boolean value
|
||||
Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport);
|
||||
Standard_EXPORT Standard_Boolean HasReport(const Handle(Message_Report)& theReport);
|
||||
|
||||
//!< Returns processed reports
|
||||
const NCollection_List<MessageModel_ReportInformation>& Reports() const { return myReports; }
|
||||
@@ -79,18 +90,19 @@ public:
|
||||
|
||||
//! Returns report by the number
|
||||
//! \param theRowId an index of the report in the internal container.
|
||||
Standard_EXPORT const Handle(Message_Report)& GetReport (const int theRowId, TCollection_AsciiString& theReportDescription);
|
||||
Standard_EXPORT const Handle(Message_Report)& GetReport(
|
||||
const int theRowId,
|
||||
TCollection_AsciiString& theReportDescription);
|
||||
|
||||
//! Set the item name
|
||||
//! \param theName text value
|
||||
void SetName (const TCollection_AsciiString& theName) { myName = theName; }
|
||||
void SetName(const TCollection_AsciiString& theName) { myName = theName; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Return data value for the role.
|
||||
//! \param theRole a value role
|
||||
//! \return the value
|
||||
virtual QVariant initValue (const int theRole) const Standard_OVERRIDE;
|
||||
virtual QVariant initValue(const int theRole) const Standard_OVERRIDE;
|
||||
|
||||
//! \return number of children.
|
||||
virtual int initRowCount() const Standard_OVERRIDE { return myReports.Size(); }
|
||||
@@ -99,19 +111,19 @@ protected:
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \return the created item
|
||||
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
|
||||
virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
//! param theParent a parent item
|
||||
MessageModel_ItemRoot (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase (theParent, theRow, theColumn) {}
|
||||
MessageModel_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
|
||||
: MessageModel_ItemBase(theParent, theRow, theColumn)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
NCollection_List<MessageModel_ReportInformation> myReports; //!< reports sent by algorithms
|
||||
TCollection_AsciiString myName; //!< DisplayRole data, if defined
|
||||
TCollection_AsciiString myName; //!< DisplayRole data, if defined
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/MessageModel_TreeModel.hxx>
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
const int COLUMN_NAME_WIDTH = 230;
|
||||
const int COLUMN_SIZE_WIDTH = 30;
|
||||
|
||||
const int COLUMN_REAL_VALUE_WIDTH = 115;
|
||||
const int COLUMN_REAL_VALUE_WIDTH = 115;
|
||||
const int COLUMN_PERCENT_VALUE_WIDTH = 50;
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
|
||||
: TreeModel_ModelBase (theParent)
|
||||
MessageModel_TreeModel::MessageModel_TreeModel(QObject* theParent)
|
||||
: TreeModel_ModelBase(theParent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,21 +44,29 @@ MessageModel_TreeModel::MessageModel_TreeModel (QObject* theParent)
|
||||
void MessageModel_TreeModel::InitColumns()
|
||||
{
|
||||
// 0 - Name, 1 - visibility, 2 - Row
|
||||
setHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
|
||||
setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
|
||||
setHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/));
|
||||
setHeaderItem(TreeModel_ColumnType_Name, TreeModel_HeaderSection("Name", COLUMN_NAME_WIDTH));
|
||||
setHeaderItem(
|
||||
TreeModel_ColumnType_Visibility,
|
||||
TreeModel_HeaderSection("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
|
||||
setHeaderItem(TreeModel_ColumnType_Row,
|
||||
TreeModel_HeaderSection("Row", COLUMN_SIZE_WIDTH, Standard_True /*hidden*/));
|
||||
|
||||
int aNextIndex = 3;
|
||||
for (int aMetricId = (int)Message_MetricType_None + 1; aMetricId <= (int)Message_MetricType_MemHeapUsage; aMetricId++)
|
||||
for (int aMetricId = (int)Message_MetricType_None + 1;
|
||||
aMetricId <= (int)Message_MetricType_MemHeapUsage;
|
||||
aMetricId++)
|
||||
{
|
||||
Message_MetricType aMetricType = (Message_MetricType)aMetricId;
|
||||
Message_MetricType aMetricType = (Message_MetricType)aMetricId;
|
||||
OSD_MemInfo::Counter aMemInfo;
|
||||
bool isMemInfo = Message::ToOSDMetric (aMetricType, 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 (isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
|
||||
setHeaderItem(
|
||||
aNextIndex++,
|
||||
TreeModel_HeaderSection(
|
||||
QString("%1 [%2]").arg(Message::MetricToString(aMetricType)).arg(isMemInfo ? "Mb" : "s"),
|
||||
COLUMN_REAL_VALUE_WIDTH));
|
||||
setHeaderItem(aNextIndex++,
|
||||
TreeModel_HeaderSection(isMemInfo ? "Delta" : "%", COLUMN_PERCENT_VALUE_WIDTH));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,19 +74,22 @@ void MessageModel_TreeModel::InitColumns()
|
||||
// function : GetMetricColumns
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_TreeModel::GetMetricColumns (const Message_MetricType theMetricType, QList<int>& theMetricColumns)
|
||||
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++)
|
||||
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++);
|
||||
theMetricColumns.append(aNextIndex++);
|
||||
theMetricColumns.append(aNextIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,15 +97,19 @@ void MessageModel_TreeModel::GetMetricColumns (const Message_MetricType theMetri
|
||||
// function : IsMetricColumn
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool MessageModel_TreeModel::IsMetricColumn (const int theColumnId, Message_MetricType& theMetricType, int& thePosition)
|
||||
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++)
|
||||
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;
|
||||
thePosition = theColumnId - aNextIndex;
|
||||
return true;
|
||||
}
|
||||
aNextIndex += 2;
|
||||
@@ -106,37 +121,37 @@ bool MessageModel_TreeModel::IsMetricColumn (const int theColumnId, Message_Metr
|
||||
// function : createRootItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TreeModel_ItemBasePtr MessageModel_TreeModel::createRootItem (const int theColumnId)
|
||||
TreeModel_ItemBasePtr MessageModel_TreeModel::createRootItem(const int theColumnId)
|
||||
{
|
||||
return MessageModel_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
|
||||
return MessageModel_ItemRoot::CreateItem(TreeModel_ItemBasePtr(), 0, theColumnId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean MessageModel_TreeModel::HasReport (const Handle(Message_Report)& theReport)
|
||||
Standard_Boolean MessageModel_TreeModel::HasReport(const Handle(Message_Report)& theReport)
|
||||
{
|
||||
if (columnCount() == 0)
|
||||
return Standard_False;
|
||||
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
|
||||
return aRootItem && aRootItem->HasReport (theReport);
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(RootItem(0));
|
||||
return aRootItem && aRootItem->HasReport(theReport);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_TreeModel::AddReport (const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
void MessageModel_TreeModel::AddReport(const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
{
|
||||
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (aColId));
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(RootItem(aColId));
|
||||
if (!aRootItem)
|
||||
continue;
|
||||
aRootItem->AddReport (theReport, theReportDescription);
|
||||
aRootItem->AddReport(theReport, theReportDescription);
|
||||
}
|
||||
|
||||
Reset();
|
||||
@@ -147,15 +162,16 @@ void MessageModel_TreeModel::AddReport (const Handle(Message_Report)& theReport,
|
||||
// function : SetReport
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_TreeModel::SetReport (const int theRowId, const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
void MessageModel_TreeModel::SetReport(const int theRowId,
|
||||
const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription)
|
||||
{
|
||||
for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (aColId));
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(RootItem(aColId));
|
||||
if (!aRootItem)
|
||||
continue;
|
||||
aRootItem->SetReport (theRowId, theReport, theReportDescription);
|
||||
aRootItem->SetReport(theRowId, theReport, theReportDescription);
|
||||
}
|
||||
Reset();
|
||||
EmitLayoutChanged();
|
||||
@@ -167,7 +183,7 @@ void MessageModel_TreeModel::SetReport (const int theRowId, const Handle(Message
|
||||
// =======================================================================
|
||||
const NCollection_List<MessageModel_ReportInformation>& MessageModel_TreeModel::Reports() const
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(RootItem(0));
|
||||
return aRootItem->Reports();
|
||||
}
|
||||
|
||||
@@ -175,11 +191,11 @@ const NCollection_List<MessageModel_ReportInformation>& MessageModel_TreeModel::
|
||||
// function : UpdateTreeModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void MessageModel_TreeModel::SetRootItemName (const TCollection_AsciiString& theName)
|
||||
void MessageModel_TreeModel::SetRootItemName(const TCollection_AsciiString& theName)
|
||||
{
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (RootItem (0));
|
||||
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot>(RootItem(0));
|
||||
if (aRootItem)
|
||||
aRootItem->SetName (theName);
|
||||
aRootItem->SetName(theName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// 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.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef MessageModel_TreeModel_H
|
||||
#define MessageModel_TreeModel_H
|
||||
@@ -35,9 +35,8 @@ class MessageModel_TreeModel;
|
||||
class MessageModel_TreeModel : public TreeModel_ModelBase
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT MessageModel_TreeModel (QObject* theParent);
|
||||
Standard_EXPORT MessageModel_TreeModel(QObject* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~MessageModel_TreeModel() Standard_OVERRIDE {};
|
||||
@@ -48,39 +47,43 @@ public:
|
||||
//!< Returns columns of the model for the metric
|
||||
//!< \param theMetricType metric
|
||||
//!< \param[out] theMetricColumns container of metric columns
|
||||
static Standard_EXPORT void GetMetricColumns (const Message_MetricType theMetricType, QList<int>& theMetricColumns);
|
||||
static Standard_EXPORT void GetMetricColumns(const Message_MetricType theMetricType,
|
||||
QList<int>& theMetricColumns);
|
||||
|
||||
//!< Returns metric type for the column
|
||||
//!< \param[in] theColumnId index of the tree column
|
||||
//!< \param[out] theMetricType metric type if found
|
||||
//!< \param[out] thePosition 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);
|
||||
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 boolean value
|
||||
Standard_EXPORT Standard_Boolean HasReport (const Handle(Message_Report)& theReport);
|
||||
Standard_EXPORT Standard_Boolean HasReport(const Handle(Message_Report)& theReport);
|
||||
|
||||
//! Add shape, append it to the model root item
|
||||
//! \param theReport a report instance
|
||||
//! \param theReportDescription an additional report information
|
||||
Standard_EXPORT void AddReport (const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription = "");
|
||||
Standard_EXPORT void AddReport(const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription = "");
|
||||
|
||||
//! Set report, se it into the given row index
|
||||
//! \param theRowId a report child row
|
||||
//! \param theReport a report instance
|
||||
//! \param theReportDescription an additional report information
|
||||
Standard_EXPORT void SetReport (const int theRowId, const Handle(Message_Report)& theReport,
|
||||
const TCollection_AsciiString& theReportDescription = "");
|
||||
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;
|
||||
|
||||
//! Sets the text value of the Root item, only "Name" column accepts the parameter value
|
||||
//! \theName visualized text of root item
|
||||
Standard_EXPORT void SetRootItemName (const TCollection_AsciiString& theName);
|
||||
Standard_EXPORT void SetRootItemName(const TCollection_AsciiString& theName);
|
||||
|
||||
//! Updates tree model
|
||||
Standard_EXPORT void UpdateTreeModel();
|
||||
@@ -88,7 +91,7 @@ public:
|
||||
protected:
|
||||
//! Creates root item
|
||||
//! \param theColumnId index of a column
|
||||
virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
|
||||
virtual TreeModel_ItemBasePtr createRootItem(const int theColumnId) Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user