From: nds Date: Tue, 2 Apr 2019 03:22:28 +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=62de4cb5c237612a0fa8bda69216e2753b3f1dfb;p=occt-copy.git 0029451: Information Message Alert to debug an algorithm or object functionality - improvements --- diff --git a/src/Graphic3d/Graphic3d.cxx b/src/Graphic3d/Graphic3d.cxx index 10bfca243d..19e05b2e8f 100644 --- a/src/Graphic3d/Graphic3d.cxx +++ b/src/Graphic3d/Graphic3d.cxx @@ -130,6 +130,13 @@ Standard_Boolean Graphic3d::ZLayerIdFromString (Standard_CString theTypeString, return Standard_True; } } + + if (aName.IsIntegerValue()) + { + theType = aName.IntegerValue(); + return Standard_True; + } + return Standard_False; } diff --git a/src/Message/Message_Alerts.hxx b/src/Message/Message_Alerts.hxx index 9af6695031..267cc8c8e1 100644 --- a/src/Message/Message_Alerts.hxx +++ b/src/Message/Message_Alerts.hxx @@ -60,6 +60,11 @@ static Handle(Message_Alert) OCCT_Message_Alert; OS << Value << Message::DumpSeparator(); \ } +#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \ + { \ + OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \ + } + #define DUMP_VALUES(OS, Value1, Value2) \ { \ OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \ diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index 38f3c3c875..c56de714e0 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -132,7 +132,7 @@ void Message_Report::AddAlert (const Message_Gravity theGravity, const Handle(Me // if not merged, just add to the list aList.Append (theAlert); // remove alerts under the report only - if (theParentAlert.IsNull() && aParentAlert.IsNull() && myLimit > 0 && aList.Extent() >= myLimit) + if (theParentAlert.IsNull() && aParentAlert.IsNull() && myLimit > 0 && aList.Extent() > myLimit) aList.RemoveFirst(); if (thePerfMeter) @@ -207,8 +207,8 @@ Handle(Message_Alert) Message_Report::getLastAlert (const Message_Gravity theGra anExtendedAlert = Handle(Message_AlertExtended)::DownCast (aLastAlert); if (anExtendedAlert.IsNull()) return aLastAlert; - if (anExtendedAlert->GetPerfMeter()) - aLastAlert = anExtendedAlert->GetPerfMeter()->GetAlert(); + //if (anExtendedAlert->GetPerfMeter()) + // aLastAlert = anExtendedAlert->GetPerfMeter()->GetAlert(); return aLastAlert; } diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index 52c9165584..c74e15c90b 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -1,4 +1,6 @@ glext.h +OpenGl.cxx +OpenGl.hxx OpenGl_ArbDbg.hxx OpenGl_ArbFBO.hxx OpenGl_ArbIns.hxx diff --git a/src/OpenGl/OpenGl.cxx b/src/OpenGl/OpenGl.cxx new file mode 100644 index 0000000000..a162a936fd --- /dev/null +++ b/src/OpenGl/OpenGl.cxx @@ -0,0 +1,56 @@ +// Created on: 2019-03-16 +// Created by: Natalia Ermolaeva +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +namespace +{ + static Standard_CString OpenGl_Table_PrintLayerFilter[4] = + { + "ALL", "UPPER", "BOTTOM", "DEFAULT" + }; +} + +//======================================================================= +//function : LayerFilterToString +//purpose : +//======================================================================= +Standard_CString OpenGl::LayerFilterToString (const OpenGl_LayerFilter theType) +{ + return OpenGl_Table_PrintLayerFilter[theType]; +} + +//======================================================================= +//function : LayerFilterFromString +//purpose : +//======================================================================= +Standard_Boolean OpenGl::LayerFilterFromString (const Standard_CString theTypeString, + OpenGl_LayerFilter& theType) +{ + TCollection_AsciiString aName (theTypeString); + aName.UpperCase(); + for (Standard_Integer aTypeIter = 0; aTypeIter <= OpenGl_LF_Default; ++aTypeIter) + { + Standard_CString aTypeName = OpenGl_Table_PrintLayerFilter[aTypeIter]; + if (aName == aTypeName) + { + theType = OpenGl_LayerFilter (aTypeIter); + return Standard_True; + } + } + return Standard_False; +} diff --git a/src/OpenGl/OpenGl.hxx b/src/OpenGl/OpenGl.hxx new file mode 100644 index 0000000000..159c982463 --- /dev/null +++ b/src/OpenGl/OpenGl.hxx @@ -0,0 +1,57 @@ +// Created on: 2019-03-16 +// Created by: Natalia Ermolaeva +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _OpenGl_H__ +#define _OpenGl_H__ + +#include + +#include +#include +#include + +//! Provides methods to cast enumerations of package to string value +class OpenGl +{ + +public: + + DEFINE_STANDARD_ALLOC + + //! Returns the string name for a given type. + //! @param theType an enumeration type + //! @return string identifier from the enumeration list + Standard_EXPORT static Standard_CString LayerFilterToString (const OpenGl_LayerFilter theType); + + //! Returns the orientation type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @return enumeration type or OpenGl_LF_All if string identifier is invalid + static OpenGl_LayerFilter LayerFilterFromString (const Standard_CString theTypeString) + { + OpenGl_LayerFilter aType = OpenGl_LF_All; + LayerFilterFromString (theTypeString, aType); + return aType; + } + + //! Determines the type from the given string identifier (using case-insensitive comparison). + //! @param theTypeString string identifier + //! @param theType detected type + //! @return TRUE if string identifier is known + Standard_EXPORT static Standard_Boolean LayerFilterFromString (const Standard_CString theTypeString, + OpenGl_LayerFilter& theType); + +}; + +#endif // _OpenGl_H__ diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx index cf33b3f76d..e70c1d85d6 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx @@ -51,7 +51,7 @@ public: virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; //! Release OpenGL resources. - virtual void Release (OpenGl_Context* theCtx); + virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE; //! Setup configuration. void SetValues (const Graphic3d_GraduatedTrihedron& theData); diff --git a/src/OpenGl/OpenGl_LayerList.hxx b/src/OpenGl/OpenGl_LayerList.hxx index 3701607734..2589e6136a 100644 --- a/src/OpenGl/OpenGl_LayerList.hxx +++ b/src/OpenGl/OpenGl_LayerList.hxx @@ -35,10 +35,10 @@ class OpenGl_LayerList public: //! Constructor - OpenGl_LayerList (const Standard_Integer theNbPriorities); + Standard_EXPORT OpenGl_LayerList (const Standard_Integer theNbPriorities); //! Destructor - virtual ~OpenGl_LayerList(); + virtual ~OpenGl_LayerList() {} //! Method returns the number of available priorities Standard_Integer NbPriorities() const { return myNbPriorities; } @@ -79,10 +79,10 @@ public: const Standard_Integer theNewPriority); //! Returns reference to the layer with given ID. - OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId); + Standard_EXPORT OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId); //! Returns reference to the layer with given ID. - const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const; + Standard_EXPORT const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const; //! Assign new settings to the layer. void SetLayerSettings (const Graphic3d_ZLayerId theLayerId, diff --git a/src/OpenGl/OpenGl_MatrixState.hxx b/src/OpenGl/OpenGl_MatrixState.hxx index 00f16d0d09..7a0ecd3718 100644 --- a/src/OpenGl/OpenGl_MatrixState.hxx +++ b/src/OpenGl/OpenGl_MatrixState.hxx @@ -54,26 +54,26 @@ public: } //! @return current matrix. - const typename OpenGl::MatrixType::Mat4& Current() + const typename OpenGl_Vec::MatrixType::Mat4& Current() { return myCurrent; } //! Sets given matrix as current. - void SetCurrent (const typename OpenGl::MatrixType::Mat4& theNewCurrent) + void SetCurrent (const typename OpenGl_Vec::MatrixType::Mat4& theNewCurrent) { myCurrent = theNewCurrent; } //! Change current matrix. - typename OpenGl::MatrixType::Mat4& ChangeCurrent() + typename OpenGl_Vec::MatrixType::Mat4& ChangeCurrent() { return myCurrent; } //! Sets given matrix as current. template - void SetCurrent (const typename OpenGl::MatrixType::Mat4& theNewCurrent) + void SetCurrent (const typename OpenGl_Vec::MatrixType::Mat4& theNewCurrent) { myCurrent.Convert (theNewCurrent); } @@ -81,14 +81,14 @@ public: //! Sets current matrix to identity. void SetIdentity() { - myCurrent = typename OpenGl::MatrixType::Mat4(); + myCurrent = typename OpenGl_Vec::MatrixType::Mat4(); } private: - NCollection_Vector::Mat4> myStack; //!< Collection used to maintenance matrix stack - typename OpenGl::MatrixType::Mat4 myCurrent; //!< Current matrix - Standard_Integer myStackHead; //!< Index of stack head + NCollection_Vector::Mat4> myStack; //!< Collection used to maintenance matrix stack + typename OpenGl_Vec::MatrixType::Mat4 myCurrent; //!< Current matrix + Standard_Integer myStackHead; //!< Index of stack head }; #endif // _OpenGl_MatrixState_H__ diff --git a/src/OpenGl/OpenGl_StencilTest.hxx b/src/OpenGl/OpenGl_StencilTest.hxx index 5771d1086e..e1bd1f1849 100755 --- a/src/OpenGl/OpenGl_StencilTest.hxx +++ b/src/OpenGl/OpenGl_StencilTest.hxx @@ -29,7 +29,7 @@ public: //! Render primitives to the window virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; - virtual void Release (OpenGl_Context* theContext); + virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE; void SetOptions (const Standard_Boolean theIsEnabled); diff --git a/src/OpenGl/OpenGl_Text.hxx b/src/OpenGl/OpenGl_Text.hxx index 4da269760a..b8e0cd362a 100755 --- a/src/OpenGl/OpenGl_Text.hxx +++ b/src/OpenGl/OpenGl_Text.hxx @@ -76,7 +76,7 @@ public: const Standard_Integer theFontSize); Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; - Standard_EXPORT virtual void Release (OpenGl_Context* theContext); + Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE; //! Return defined text. const NCollection_String& Text() const { return myString; } diff --git a/src/OpenGl/OpenGl_Vec.hxx b/src/OpenGl/OpenGl_Vec.hxx index cb4cf962c4..8e50a2da88 100755 --- a/src/OpenGl/OpenGl_Vec.hxx +++ b/src/OpenGl/OpenGl_Vec.hxx @@ -45,7 +45,7 @@ typedef Graphic3d_Vec4d OpenGl_Vec4d; typedef Graphic3d_Mat4 OpenGl_Mat4; typedef Graphic3d_Mat4d OpenGl_Mat4d; -namespace OpenGl +namespace OpenGl_Vec { //! Tool class for selecting appropriate vector type. //! \tparam T Numeric data type diff --git a/tools/DFBrowser/DFBrowser_Window.cxx b/tools/DFBrowser/DFBrowser_Window.cxx index a34cd16f43..cad3f7c1d4 100644 --- a/tools/DFBrowser/DFBrowser_Window.cxx +++ b/tools/DFBrowser/DFBrowser_Window.cxx @@ -420,6 +420,11 @@ void DFBrowser_Window::Init (const NCollection_List& } return; } + else + { + if (anApplication.IsNull() && CDF_Session::Exists()) + anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication()); + } myModule = new DFBrowser_Module(); myModule->CreateViewModel (myMainWindow); diff --git a/tools/MessageModel/FILES b/tools/MessageModel/FILES index bb44a4de71..fb8efa0e50 100644 --- a/tools/MessageModel/FILES +++ b/tools/MessageModel/FILES @@ -8,6 +8,8 @@ MessageModel_ItemBase.cxx MessageModel_ItemBase.hxx MessageModel_ItemReport.cxx MessageModel_ItemReport.hxx +MessageModel_ItemReportProperties.cxx +MessageModel_ItemReportProperties.hxx MessageModel_ItemRoot.cxx MessageModel_ItemRoot.hxx MessageModel_ReportCallBack.cxx diff --git a/tools/MessageModel/MessageModel_ActionType.hxx b/tools/MessageModel/MessageModel_ActionType.hxx index d5092aa08e..de036fefd4 100644 --- a/tools/MessageModel/MessageModel_ActionType.hxx +++ b/tools/MessageModel/MessageModel_ActionType.hxx @@ -21,7 +21,9 @@ enum MessageModel_ActionType { MessageModel_ActionType_Activate, //!< set Message_Report active MessageModel_ActionType_Deactivate, //!< set Message_Report not active - MessageModel_ActionType_ExportToShapeView //!< export TopoDS_Shape of selected item into TKShapeView plugin + MessageModel_ActionType_Clear, //!< clear Message_Report alerts + MessageModel_ActionType_ExportToShapeView, //!< export TopoDS_Shape of selected item into TKShapeView plugin + MessageModel_ActionType_Test //!< test alerts }; #endif diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 1f6f26509c..4a587b5591 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -38,6 +38,13 @@ #include #include +#define DEBUG_ALERTS + +#ifdef DEBUG_ALERTS +#include +#include +#endif + // ======================================================================= // function : Constructor // purpose : @@ -50,8 +57,14 @@ MessageModel_Actions::MessageModel_Actions (QWidget* theParent, ViewControl_Tools::CreateAction ("Deactivate", SLOT (OnDeactivateReport()), parent(), this)); myActions.insert (MessageModel_ActionType_Activate, ViewControl_Tools::CreateAction ("Activate", SLOT (OnActivateReport()), parent(), this)); + myActions.insert (MessageModel_ActionType_Clear, + ViewControl_Tools::CreateAction ("Clear", SLOT (OnClearReport()), parent(), this)); myActions.insert (MessageModel_ActionType_ExportToShapeView, ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (OnExportToShapeView()), parent(), this)); +#ifdef DEBUG_ALERTS + myActions.insert (MessageModel_ActionType_Test, + ViewControl_Tools::CreateAction ("Test", SLOT (OnTestAlerts()), parent(), this)); +#endif } // ======================================================================= @@ -102,6 +115,10 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd { theMenu->addAction (myActions[MessageModel_ActionType_Deactivate]); theMenu->addAction (myActions[MessageModel_ActionType_Activate]); + theMenu->addAction (myActions[MessageModel_ActionType_Clear]); +#ifdef DEBUG_ALERTS + theMenu->addAction (myActions[MessageModel_ActionType_Test]); +#endif } else if (anAlertItem) theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]); @@ -168,6 +185,21 @@ void MessageModel_Actions::OnActivateReport() ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex); } +// ======================================================================= +// function : OnClearReport +// purpose : +// ======================================================================= +void MessageModel_Actions::OnClearReport() +{ + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + aReport->Clear(); + ((MessageModel_TreeModel*)mySelectionModel->model())->EmitDataChanged (aReportIndex, aReportIndex); +} + // ======================================================================= // function : OnExportToShapeView // purpose : @@ -230,3 +262,50 @@ void MessageModel_Actions::OnExportToShapeView() QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.") .arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString()))); } + +// ======================================================================= +// function : OnTestAlerts +// purpose : +// ======================================================================= +#include +#include +void MessageModel_Actions::OnTestAlerts() +{ +#ifdef DEBUG_ALERTS + QModelIndex aReportIndex; + Handle(Message_Report) aReport = getSelectedReport (aReportIndex); + if (aReport.IsNull()) + return; + + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("MessageModel_Actions::OnTestAlerts()", "", &aPerfMeter, NULL); + unsigned int start_time = clock(); + //Standard_Real aSystemSeconds, aCurrentSeconds; + //OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds); + + Standard_Integer aCounter = 50000; + Standard_Real aValue = 0., aValue2 = 0.1; + for (int j = 0; j < aCounter; j++) + { + for (int i = 0; i < aCounter; i++) + { + aValue = (aValue * 2. + 3.) * 0.5 - 0.3 * 0.5; + + Standard_Real aValue3 = aValue + aValue2 * 0.2; + //MESSAGE_INFO ("Calculate", aValue, &aPerfMeter, NULL); + } + } + + ((MessageModel_TreeModel*)mySelectionModel->model())->EmitLayoutChanged(); + + //Standard_Real aSystemSeconds1, aCurrentSeconds1; + //OSD_Chronometer::GetThreadCPU (aCurrentSeconds1, aSystemSeconds1); + + //std::cout << aValue << std::endl; + //std::cout << "user time = " << aCurrentSeconds1 - aCurrentSeconds + // << ", system time = " << aSystemSeconds1 - aSystemSeconds << std::endl; + + unsigned int end_time = clock(); + std::cout << "clock() = " << end_time - start_time << std::endl; +#endif +} diff --git a/tools/MessageModel/MessageModel_Actions.hxx b/tools/MessageModel/MessageModel_Actions.hxx index 2de60eca78..71da2a0935 100644 --- a/tools/MessageModel/MessageModel_Actions.hxx +++ b/tools/MessageModel/MessageModel_Actions.hxx @@ -76,9 +76,15 @@ public slots: //! Set selected report active void OnActivateReport(); + //! Clears container of alerts of selected report + void OnClearReport(); + //! Exports the first selected shape into ShapeViewer plugin. void OnExportToShapeView(); + //! Sending several alerts to check message-alert-tool mechanizm + void OnTestAlerts(); + 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/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx index c884a45e53..c05a71b800 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.cxx +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -60,9 +60,6 @@ QVariant MessageModel_ItemAlert::initValue (const int theRole) const } Handle(Message_Alert) anAlert = getAlert(); - if (anAlert.IsNull()) - return QVariant(); - // if the alert is composite, process the real alert if (theRole == Qt::DecorationRole && Column() == 0) { @@ -145,17 +142,26 @@ int MessageModel_ItemAlert::initRowCount() const if (aCompositeAlert.IsNull()) return GetUnitedAlerts().Size(); - int aRowCount = 0; - NCollection_Vector aUnitedAlerts; + MessageModel_ItemAlert* aCurrentItem = (MessageModel_ItemAlert*)this; for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++) { const Message_ListOfAlert& anAlerts = aCompositeAlert->GetAlerts ((Message_Gravity)aGravityId); if (isUniteAlerts()) - GetUnitedAlerts (anAlerts, aUnitedAlerts); + { + MessageModel_Tools::GetUnitedAlerts (anAlerts, aCurrentItem->myChildAlerts); + } else - aRowCount += anAlerts.Size(); + { + for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next()) + { + Message_ListOfAlert aCurAlerts; + aCurAlerts.Append (anIt.Value()); + aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts); + } + } } - return isUniteAlerts() ? aUnitedAlerts.Size() : aRowCount; + + return aCurrentItem->myChildAlerts.Size(); } // ======================================================================= @@ -175,90 +181,34 @@ void MessageModel_ItemAlert::Init() { MessageModel_ItemReportPtr aReportItem = itemDynamicCast (Parent()); MessageModel_ItemAlertPtr anAlertItem; - Handle(Message_Report) aReport; Handle(Message_Alert) anAlert; if (aReportItem) - aReport = aReportItem->GetReport(); - else - { - anAlertItem = itemDynamicCast (Parent()); - if (anAlertItem) - anAlert = anAlertItem->GetAlert(); - } - if (aReport.IsNull() && anAlert.IsNull() && !anAlertItem) - return; - - if (anAlert.IsNull() && anAlertItem) // union folder item { - int aCurrentSubId = 0; - for (Message_ListOfAlert::Iterator anAlertsIt (anAlertItem->GetUnitedAlerts()); anAlertsIt.More(); - anAlertsIt.Next(), aCurrentSubId++) + Message_ListOfAlert anAlerts; + if (aReportItem->GetChildAlerts (Row(), anAlerts)) { - if (aCurrentSubId != Row()) - continue; - myAlert = anAlertsIt.Value(); - MessageModel_ItemBase::Init(); - return; + if (anAlerts.Size() == 1) + myAlert = anAlerts.First(); + else + myUnitedAlerts = anAlerts; } - return; } - - // iterates through all gravity types, skip types where report is empty, if report is not empty, increment - // current index until it equal to the current row index - Message_ListOfAlert anAlerts; - NCollection_Vector aUnitedAlerts; - int aRowId = Row(); - int aPreviousAlertsCount = 0; - for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++) + else { - if (!aReport.IsNull()) - anAlerts = aReport->GetAlerts ((Message_Gravity)aGravityId); - else if (!anAlert.IsNull()) - { - Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert); - Handle(Message_CompositeAlerts) aCompositeAlert = !anExtendedAlert.IsNull() ? anExtendedAlert->GetCompositeAlerts() - : Handle(Message_CompositeAlerts)(); - if (!aCompositeAlert.IsNull()) - anAlerts = aCompositeAlert->GetAlerts ((Message_Gravity)aGravityId); - } - - if (isReversed()) - anAlerts.Reverse(); - - if (isUniteAlerts()) + anAlertItem = itemDynamicCast (Parent()); + if (anAlertItem) { - GetUnitedAlerts (anAlerts, aUnitedAlerts); - if (aRowId < aUnitedAlerts.Size()) + Message_ListOfAlert anAlerts; + if (anAlertItem->GetChildAlerts (Row(), anAlerts)) { - anAlerts = aUnitedAlerts.Value (aRowId); - if (anAlerts.Size() == 1) myAlert = anAlerts.First(); else myUnitedAlerts = anAlerts; - - MessageModel_ItemBase::Init(); - return; - } - } - else - { - if (aRowId < aPreviousAlertsCount + anAlerts.Size()) - { - aRowId = aRowId - aPreviousAlertsCount; - int aCurrentId = 0; - for (Message_ListOfAlert::Iterator anAlertsIt (anAlerts); anAlertsIt.More(); anAlertsIt.Next(), aCurrentId++) - { - if (aCurrentId != Row()) - continue; - myAlert = anAlertsIt.Value(); - MessageModel_ItemBase::Init(); - return; - } } - aPreviousAlertsCount += anAlerts.Size(); } } + MessageModel_ItemBase::Init(); } // ======================================================================= @@ -270,6 +220,7 @@ void MessageModel_ItemAlert::Reset() MessageModel_ItemBase::Reset(); myAlert = Handle(Message_Alert)(); myUnitedAlerts.Clear(); + myChildAlerts.Clear(); } // ======================================================================= @@ -319,29 +270,3 @@ double MessageModel_ItemAlert::AmountElapsedTime(const Handle(Message_Alert)& th return anAmountTime; } - -// ======================================================================= -// function : GetUnitedAlerts -// purpose : -// ======================================================================= -void MessageModel_ItemAlert::GetUnitedAlerts(const Message_ListOfAlert& theAlerts, - NCollection_Vector& theUnitedAlerts) -{ - //theUnitedAlerts.Clear(); - TCollection_AsciiString anAlertMessageKey; - for (Message_ListOfAlert::Iterator anAlertsIt (theAlerts); anAlertsIt.More(); anAlertsIt.Next()) - { - Handle(Message_Alert) anAlert = anAlertsIt.Value(); - if (anAlertMessageKey.IsEqual (anAlert->GetMessageKey())) { - Message_ListOfAlert anAlerts = theUnitedAlerts.Last(); - anAlerts.Append (anAlert); - theUnitedAlerts.SetValue(theUnitedAlerts.Size()-1, anAlerts); - } - else { - Message_ListOfAlert anAlerts; - anAlerts.Append (anAlert); - theUnitedAlerts.Append (anAlerts); - anAlertMessageKey = anAlert->GetMessageKey(); - } - } -} diff --git a/tools/MessageModel/MessageModel_ItemAlert.hxx b/tools/MessageModel/MessageModel_ItemAlert.hxx index 3f338c1d0c..f32df889d7 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.hxx +++ b/tools/MessageModel/MessageModel_ItemAlert.hxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,9 @@ public: //! Returns the current shape 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); } + //! Returns united alerts or empty list const Message_ListOfAlert& GetUnitedAlerts() const { return myUnitedAlerts; } @@ -85,12 +89,6 @@ public: //! \return double value Standard_EXPORT static double AmountElapsedTime (const Handle(Message_Alert)& theAlert); - //! Returns alerts united by Message Key - //! \param theAlerts source message alert - //! \param theUnitedAlerts arranged source message alerts - Standard_EXPORT static void GetUnitedAlerts (const Message_ListOfAlert& theAlerts, - NCollection_Vector & theUnitedAlerts); - protected: //! Initialize the current item. It is empty because Reset() is also empty. @@ -124,6 +122,9 @@ private: private: Handle(Message_Alert) myAlert; Message_ListOfAlert myUnitedAlerts; + + NCollection_DataMap myChildAlerts; //!< container of child alerts + TopoDS_Shape myCustomShape; }; diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx index 2ba14ae1c7..bc4c4877e4 100644 --- a/tools/MessageModel/MessageModel_ItemReport.cxx +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -15,8 +15,10 @@ #include -#include #include +#include +#include +#include #include @@ -86,20 +88,25 @@ int MessageModel_ItemReport::initRowCount() const if (aReport.IsNull()) return 0; - int aRowCount = 0; - NCollection_Vector aUnitedAlerts; + MessageModel_ItemReport* aCurrentItem = (MessageModel_ItemReport*)this; for (int aGravityId = Message_Trace; aGravityId <= Message_Fail; aGravityId++) { const Message_ListOfAlert& anAlerts = aReport->GetAlerts ((Message_Gravity)aGravityId); if (isUniteAlerts()) { - MessageModel_ItemAlert::GetUnitedAlerts (anAlerts, aUnitedAlerts); - aRowCount += aUnitedAlerts.Size(); + MessageModel_Tools::GetUnitedAlerts (anAlerts, aCurrentItem->myChildAlerts); } else - aRowCount += anAlerts.Size(); + { + for (Message_ListOfAlert::Iterator anIt(anAlerts); anIt.More(); anIt.Next()) + { + Message_ListOfAlert aCurAlerts; + aCurAlerts.Append (anIt.Value()); + aCurrentItem->myChildAlerts.Bind(myChildAlerts.Size(), aCurAlerts); + } + } } - return isUniteAlerts() ? aUnitedAlerts.Size() : aRowCount; + return aCurrentItem->myChildAlerts.Size(); } // ======================================================================= @@ -119,6 +126,11 @@ void MessageModel_ItemReport::Init() { MessageModel_ItemRootPtr aRootItem = itemDynamicCast (Parent()); myReport = aRootItem ? aRootItem->GetReport (Row(), myDescription) : Handle(Message_Report)(); + + TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); + SetProperties (new MessageModel_ItemReportProperties(anItem)); + + MessageModel_ItemBase::Init(); } // ======================================================================= @@ -139,6 +151,7 @@ void MessageModel_ItemReport::Reset() { MessageModel_ItemBase::Reset(); myReport = Handle(Message_Report)(); + myChildAlerts.Clear(); } // ======================================================================= diff --git a/tools/MessageModel/MessageModel_ItemReport.hxx b/tools/MessageModel/MessageModel_ItemReport.hxx index 1c7c081fa7..c6ce246fc2 100644 --- a/tools/MessageModel/MessageModel_ItemReport.hxx +++ b/tools/MessageModel/MessageModel_ItemReport.hxx @@ -19,7 +19,9 @@ #include #include #include +#include #include +#include #include #include @@ -49,6 +51,10 @@ public: //! Returns the current shape 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); } + + //! Returns the report description or NULL const TCollection_AsciiString& GetDescription() const { return myDescription; } //! Inits the item, fills internal containers @@ -101,6 +107,8 @@ private: private: + NCollection_DataMap myChildAlerts; //!< container of child alerts + Handle(Message_Report) myReport; //!< current report TCollection_AsciiString myDescription; //!< description }; diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.cxx b/tools/MessageModel/MessageModel_ItemReportProperties.cxx new file mode 100644 index 0000000000..f1337a4545 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemReportProperties.cxx @@ -0,0 +1,102 @@ +// Created on: 2019-02-25 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(MessageModel_ItemReportProperties, TreeModel_ItemProperties) + +// ======================================================================= +// function : RowCount +// purpose : +// ======================================================================= + +int MessageModel_ItemReportProperties::GetTableRowCount() const +{ + return 1; +} + +// ======================================================================= +// function : Data +// purpose : +// ======================================================================= + +QVariant MessageModel_ItemReportProperties::GetTableData (const int theRow, const int theColumn, int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + Handle(Message_Report) aReport = getItemReport(); + switch (theRow) + { + case 0: return theColumn == 0 ? QVariant ("Limit") : QVariant (aReport->GetLimit()); + default: break; + } + + return QVariant(); +} + +// ======================================================================= +// function : GetTableEditType +// purpose : +// ======================================================================= +ViewControl_EditType MessageModel_ItemReportProperties::GetTableEditType (const int theRow, const int theColumn) const +{ + switch (theRow) + { + case 0: return ViewControl_EditType_Spin; + default: return ViewControl_EditType_None; + } +} + +// ======================================================================= +// function : SetTableData +// purpose : +// ======================================================================= +bool MessageModel_ItemReportProperties::SetTableData (const int theRow, const int theColumn, const QVariant& theValue) +{ + Handle(Message_Report) aReport = getItemReport(); + switch (theRow) + { + case 0: aReport->SetLimit (theValue.toInt()); break; + default: break; + } + return true; +} + +// ======================================================================= +// function : getItemReport +// purpose : +// ======================================================================= + +Handle(Message_Report) MessageModel_ItemReportProperties::getItemReport() const +{ + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(myItem); + if (!aReportItem) + return NULL; + + return aReportItem->GetReport(); +} diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.hxx b/tools/MessageModel/MessageModel_ItemReportProperties.hxx new file mode 100644 index 0000000000..65e1592772 --- /dev/null +++ b/tools/MessageModel/MessageModel_ItemReportProperties.hxx @@ -0,0 +1,87 @@ +// Created on: 2019-02-25 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef MessageModel_ItemReportProperties_H +#define MessageModel_ItemReportProperties_H + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +class QItemDelegate; + +DEFINE_STANDARD_HANDLE (MessageModel_ItemReportProperties, TreeModel_ItemProperties) + +//! \class MessageModel_ItemReportProperties +//! \brief This is an interace for ViewControl_TableModel to give real values of the model +//! It should be filled or redefined. +class MessageModel_ItemReportProperties : public TreeModel_ItemProperties +{ +public: + + //! Constructor + Standard_EXPORT MessageModel_ItemReportProperties (TreeModel_ItemBasePtr theItem) + : TreeModel_ItemProperties(), myItem (theItem) {} + + //! Destructor + virtual ~MessageModel_ItemReportProperties() {} + + //! Returns number of rows, depending on orientation: myColumnCount or size of values container + //! \param theParent an index of the parent item + //! \return an integer value + Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns content of the model index for the given role, it is obtained from internal container of values + //! It returns value only for DisplayRole. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theRole a view role + //! \return value intepreted depending on the given role + Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE; + + //! Returns type of edit control for the model index. By default, it is an empty control + //! \param theRow a model index row + //! \param theColumn a model index column + //! \return edit type + Standard_EXPORT virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE; + + //! Sets the value into the table cell. Only 1st column value might be modified. + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theValue a new cell value + Standard_EXPORT virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT (MessageModel_ItemReportProperties, TreeModel_ItemProperties) + +protected: + //! Returns report + Handle(Message_Report) getItemReport() const; + +protected: + + TreeModel_ItemBasePtr myItem; //!< source item base +}; + +#endif diff --git a/tools/MessageModel/MessageModel_ReportCallBack.hxx b/tools/MessageModel/MessageModel_ReportCallBack.hxx index d59fea8ba2..be5d7c98f3 100644 --- a/tools/MessageModel/MessageModel_ReportCallBack.hxx +++ b/tools/MessageModel/MessageModel_ReportCallBack.hxx @@ -36,7 +36,7 @@ public: // Interface to be implemented in the child to process the message report event // \theAlert updated alert - virtual void Update(const Handle(Message_Alert)& theAlert) { (void)theAlert; myCommunicator->UpdateContent(); } + virtual void Update(const Handle(Message_Alert)& theAlert) { (void)theAlert; /*myCommunicator->UpdateContent();*/ } // OCCT RTTI DEFINE_STANDARD_RTTIEXT(MessageModel_ReportCallBack, Message_ReportCallBack) diff --git a/tools/MessageModel/MessageModel_Tools.cxx b/tools/MessageModel/MessageModel_Tools.cxx index 67ac9b5edf..0adacedd37 100644 --- a/tools/MessageModel/MessageModel_Tools.cxx +++ b/tools/MessageModel/MessageModel_Tools.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include #include #include @@ -137,10 +138,24 @@ TCollection_AsciiString MessageModel_Tools::GetStandardTypeAlertInfo (const Hand // function : GetPropertyTableValues // purpose : // ======================================================================= -void MessageModel_Tools::GetPropertyTableValues (const Handle(Message_Alert)& theAlert, +void MessageModel_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem, QList& theTableValues) { - Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(theAlert); + Handle(TreeModel_ItemProperties) anItemProperties = theItem->GetProperties(); + if (!anItemProperties.IsNull()) + { + ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues(); + aTableValues->SetProperties (anItemProperties); + theTableValues.append (aTableValues); + return; + } + + MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(theItem); + if (!anAlertItem) + return; + + const Handle(Message_Alert)& anAlert = anAlertItem->GetAlert(); + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert); if (anExtendedAlert.IsNull()) return; @@ -179,3 +194,33 @@ void MessageModel_Tools::GetPropertyTableValues (const Handle(Message_Alert)& th } } } + +// ======================================================================= +// function : GetUnitedAlerts +// purpose : +// ======================================================================= +void MessageModel_Tools::GetUnitedAlerts(const Message_ListOfAlert& theAlerts, + NCollection_DataMap& theUnitedAlerts) +{ + //theUnitedAlerts.Clear(); + TCollection_AsciiString anAlertMessageKey; + Standard_Integer aRowIndex = 0; + Standard_Integer aCurIndex = 0; + for (Message_ListOfAlert::Iterator anAlertsIt (theAlerts); anAlertsIt.More(); anAlertsIt.Next()) + { + aCurIndex++; + Handle(Message_Alert) anAlert = anAlertsIt.Value(); + if (anAlertMessageKey.IsEqual (anAlert->GetMessageKey())) { + Message_ListOfAlert anAlerts = theUnitedAlerts.Find(aRowIndex-1); // already in the map + anAlerts.Append (anAlert); + theUnitedAlerts.Bind(aRowIndex-1, anAlerts); + } + else { + Message_ListOfAlert anAlerts; + anAlerts.Append (anAlert); + theUnitedAlerts.Bind(aRowIndex, anAlerts); + aRowIndex++; + anAlertMessageKey = anAlert->GetMessageKey(); + } + } +} diff --git a/tools/MessageModel/MessageModel_Tools.hxx b/tools/MessageModel/MessageModel_Tools.hxx index 2b63be0061..22ca579856 100644 --- a/tools/MessageModel/MessageModel_Tools.hxx +++ b/tools/MessageModel/MessageModel_Tools.hxx @@ -19,9 +19,14 @@ #include #include +#include +#include +#include #include #include +#include + #include #include #include @@ -62,8 +67,14 @@ public: //! Fills container of table values //! \param theAlert a message alert //! \param theTableValue container of values - Standard_EXPORT static void GetPropertyTableValues (const Handle(Message_Alert)& theAlert, + Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem, QList& theTableValues); + + //! Returns alerts united by Message Key + //! \param theAlerts source message alert + //! \param theUnitedAlerts arranged source message alerts + Standard_EXPORT static void GetUnitedAlerts(const Message_ListOfAlert& theAlerts, + NCollection_DataMap& theUnitedAlerts); }; #endif diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index 6f78e0ff91..c0c0aebf39 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -417,7 +417,16 @@ void MessageView_Window::onTreeViewContextMenuRequested (const QPoint& thePositi break; } if (aRootItem) + { aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Import Report"), SLOT (onImportReport()), myMainWindow, this)); + // unite + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsUniteAlerts() ? tr ("SetUniteAlerts - OFF") : tr ("SetUniteAlerts - ON"), + SLOT (onUniteAlerts()), myMainWindow, this)); + // reversed + //aMenu->addAction (ViewControl_Tools::CreateAction (aTreeModel->IsReversed() ? tr ("SetReversed - OFF") : tr ("SetReversed - ON"), + // SLOT (onSetReversedAlerts()), myMainWindow, this)); + } else if (aReportItem) { aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export Report"), SLOT (onExportReport()), myMainWindow, this)); @@ -563,6 +572,31 @@ void MessageView_Window::onImportReport() openFile (TCollection_AsciiString (aFileName.toStdString().c_str())); } +// ======================================================================= +// function : onImportReport +// purpose : +// ======================================================================= +void MessageView_Window::onUniteAlerts() +{ + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + Standard_Boolean isUniteAlerts = aTreeModel->IsUniteAlerts(); + + aTreeModel->SetUniteAlerts (!isUniteAlerts); +} + +// ======================================================================= +// function : onSetReversedAlerts +// purpose : +// ======================================================================= +void MessageView_Window::onSetReversedAlerts() +{ + MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); + Standard_Boolean isReversed = aTreeModel->IsReversed(); + + aTreeModel->SetReversed (!isReversed); +} + + // ======================================================================= // function : onReloadReport // purpose : @@ -608,12 +642,8 @@ void MessageView_Window::updatePropertyPanelBySelection() if (!anItemBase) return; - MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); - if (!anAlertItem) - return; - QList aTableValues; - MessageModel_Tools::GetPropertyTableValues (anAlertItem->GetAlert(), aTableValues); + MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues); myPropertyView->Init (aTableValues); } diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx index 470ba79054..31d5b4ce7b 100644 --- a/tools/MessageView/MessageView_Window.hxx +++ b/tools/MessageView/MessageView_Window.hxx @@ -145,6 +145,12 @@ protected slots: //! Import report into document void onImportReport(); + //! Unite alerts in view model + void onUniteAlerts(); + + //! Sets report reversed + void onSetReversedAlerts(); + //! Reads if possible report of a selected item and updates this report in tree view void onReloadReport(); diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx index 36ce63c639..3d3fd45304 100644 --- a/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -18,6 +18,7 @@ #include +#include #include #include @@ -103,6 +104,9 @@ int main (int argc, char** argv) if (!strcmp (argv[anArgId], "vinspector")) aPlugins.insert ("TKVInspector"); + + if (!strcmp (argv[anArgId], "messageview")) + aPlugins.insert ("TKMessageView"); } NCollection_List aParameters; @@ -122,6 +126,11 @@ int main (int argc, char** argv) aPlugins.insert("TKShapeView"); aPlugins.insert("TKVInspector"); + Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True); + aReport->SetLimit(30); + aReport->SetActive (Standard_False); + aPlugins.insert("TKMessageView"); + anActivatedPluginName = "TKVInspector"; } else diff --git a/tools/ToolsDraw/ToolsDraw.cxx b/tools/ToolsDraw/ToolsDraw.cxx index ca4b96c779..8eddf24029 100644 --- a/tools/ToolsDraw/ToolsDraw.cxx +++ b/tools/ToolsDraw/ToolsDraw.cxx @@ -40,6 +40,15 @@ Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); static TInspector_Communicator* MyCommunicator; +// ======================================================================= +// function : GetCommunicator +// purpose : defines plugin library name by the command argument +// ======================================================================= +TInspector_Communicator* ToolsDraw::GetCommunicator() +{ + return MyCommunicator; +} + // ======================================================================= // function : convertToPluginName // purpose : defines plugin library name by the command argument diff --git a/tools/ToolsDraw/ToolsDraw.hxx b/tools/ToolsDraw/ToolsDraw.hxx index b004ad50df..376361289f 100644 --- a/tools/ToolsDraw/ToolsDraw.hxx +++ b/tools/ToolsDraw/ToolsDraw.hxx @@ -20,6 +20,8 @@ #include #include +class TInspector_Communicator; + //! \class ToolsDraw //! \brief Registers DRAW commands to connect to TInspector tools class ToolsDraw @@ -36,6 +38,8 @@ public: //! \param theCommands Standard_EXPORT static void Commands (Draw_Interpretor& theCommands); + Standard_EXPORT static TInspector_Communicator* GetCommunicator(); + private: }; diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index 628ee6748c..a16e3a2ca5 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -16,3 +16,18 @@ #include IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient) + +// ======================================================================= +// function : GetTableFlags +// purpose : +// ======================================================================= + +Qt::ItemFlags TreeModel_ItemProperties::GetTableFlags (const int, const int theColumn) const +{ + Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; + + if (theColumn == 1) + aFlags = aFlags | Qt::ItemIsEditable; + + return aFlags; +} diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index d9a05c5484..9364ac487e 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -53,6 +53,12 @@ public: //! \return an integer value virtual int GetTableRowCount() const { return 0; } + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const + { (void)theRow; (void)theColumn; (void)theRole; return QVariant(); } + //! Returns type of edit control for the model index. By default, it is an empty control //! \param theRow a model index row //! \param theColumn a model index column @@ -67,11 +73,11 @@ public: virtual QList GetTableEnumValues (const int theRow, const int theColumn) const { (void)theRow; (void)theColumn; return QList(); } - //! Returns table value for the row in form: - //! \param theRow a model index row - //! \param theColumn a model index column - virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const - { (void)theRow; (void)theColumn; (void)theRole; return QVariant(); } + //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable. + //! Additional flag for the column 1 is Qt::ItemIsEditable. + //! \param theIndex a model index + //! \return flags + Standard_EXPORT virtual Qt::ItemFlags GetTableFlags (const int theRow, const int theColumn) const; //! Sets the value into the table cell. Only 1st column value might be modified. //! \param theRow a model index row diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index bc4ca4a8c3..744181b067 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -34,6 +34,10 @@ VInspector_ItemHistoryType.hxx VInspector_ItemHistoryTypeInfo.hxx VInspector_ItemOpenGlElement.cxx VInspector_ItemOpenGlElement.hxx +VInspector_ItemOpenGlLayer.cxx +VInspector_ItemOpenGlLayer.hxx +VInspector_ItemOpenGlLayerList.cxx +VInspector_ItemOpenGlLayerList.hxx VInspector_ItemPresentableObject.cxx VInspector_ItemPresentableObject.hxx VInspector_ItemPresentations.cxx diff --git a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx index a50f2d8ab9..24ec1c3174 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx @@ -182,8 +182,7 @@ QVariant VInspector_ItemGraphic3dCStructure::GetTableData (const int theRow, con : QVariant (ViewControl_Tools::GetPointerInfo (aCStructure->GraphicDriver()).ToCString()); case 1: return isFirstColumn ? QVariant ("Groups") : QVariant (aCStructure->Groups().Length()); case 2: return isFirstColumn ? QVariant ("Transformation") - : (!aCStructure->Transformation().IsNull() ? - QVariant (ViewControl_Tools::ToString (aCStructure->Transformation()->Trsf()).ToCString()) : QVariant()); + : QVariant (ViewControl_Tools::ToString (aCStructure->Transformation()).ToCString()); case 3: return isFirstColumn ? QVariant ("TransformPersistence") : QVariant (ViewControl_Tools::GetPointerInfo (aCStructure->TransformPersistence()).ToCString()); case 4: return isFirstColumn ? QVariant ("ClipPlanes") diff --git a/tools/VInspector/VInspector_ItemGraphic3dCView.cxx b/tools/VInspector/VInspector_ItemGraphic3dCView.cxx index 5adef08ccc..414a0652ea 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCView.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCView.cxx @@ -18,16 +18,38 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include +// ======================================================================= +// function : GetLayerList +// purpose : +// ======================================================================= +const OpenGl_LayerList& VInspector_ItemGraphic3dCView::GetLayerList (Standard_Boolean& isDefault) const +{ + isDefault = Standard_True; + + Handle(Graphic3d_CView) aCView = GetCView(); + if (aCView.IsNull()) + return myDefaultLayer; + + Handle(OpenGl_View) aOpenGlView = Handle(OpenGl_View)::DownCast (aCView); + if (aOpenGlView.IsNull()) + return myDefaultLayer; + + isDefault = Standard_False; + return aOpenGlView->LayerList(); +} + // ======================================================================= // function : GetClipPlane // purpose : @@ -90,7 +112,7 @@ int VInspector_ItemGraphic3dCView::initRowCount() const if (Column() != 0) return 0; - int aNbElements = 1; // Camera + int aNbElements = 2; // Camera, OpenGl_LayerList Handle(Graphic3d_CView) aCView = GetCView(); const Handle(Graphic3d_SequenceOfHClipPlane)& aClipPlanes = aCView->ClipPlanes(); @@ -268,6 +290,8 @@ TreeModel_ItemBasePtr VInspector_ItemGraphic3dCView::createChild (int theRow, in { if (theRow == 0) return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn); + else if (theRow == 1) + return VInspector_ItemOpenGlLayerList::CreateItem (currentItem(), theRow, theColumn); else return VInspector_ItemGraphic3dClipPlane::CreateItem (currentItem(), theRow, theColumn); } diff --git a/tools/VInspector/VInspector_ItemGraphic3dCView.hxx b/tools/VInspector/VInspector_ItemGraphic3dCView.hxx index 4e56cf2ba5..662cdc6ef6 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCView.hxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCView.hxx @@ -19,6 +19,8 @@ #include #include +#include + class Graphic3d_CView; class VInspector_ItemGraphic3dCView; @@ -48,6 +50,10 @@ public: Standard_EXPORT Handle(Graphic3d_CView) GetCView() const { return Handle(Graphic3d_CView)::DownCast (GetObject()); } + //! Returns layer list if the View is OpenGl_View + //! \param isDefault flag is true if the layer is absent and the default value of this class is used + Standard_EXPORT const OpenGl_LayerList& GetLayerList (Standard_Boolean& isDefault) const; + //! Returns clip plane of the row if possible //! \param theRow child row index Standard_EXPORT Handle(Graphic3d_ClipPlane) GetClipPlane(const int theRow); @@ -115,10 +121,11 @@ private: //! \param theRow the item row positition in the parent item //! \param theColumn the item column positition in the parent item VInspector_ItemGraphic3dCView(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) - : VInspector_ItemBase(theParent, theRow, theColumn) {} + : VInspector_ItemBase(theParent, theRow, theColumn), myDefaultLayer (1) {} private: Handle(Graphic3d_CView) myCView; //! current graphical CView + OpenGl_LayerList myDefaultLayer; //! default layer if the view is not OpenGl }; #endif diff --git a/tools/VInspector/VInspector_ItemOpenGlLayer.cxx b/tools/VInspector/VInspector_ItemOpenGlLayer.cxx new file mode 100644 index 0000000000..b9697cab9d --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayer.cxx @@ -0,0 +1,216 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Init() +{ + VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast(Parent()); + myLayer = aParentItem->GetLayer (Row(), myLayerId); + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Reset() +{ + VInspector_ItemBase::Reset(); + myLayer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return Column() == 0 ? "Empty element" : ""; + + switch (Column()) + { + case 0: + { + TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId); + if (aLayerId.IsEmpty()) + aLayerId = TCollection_AsciiString (myLayerId); + return theItemRole == Qt::ToolTipRole ? QVariant ("") + : QVariant (QString("%1 (%2)") + .arg(aLayer->DynamicType()->Name()) + .arg (aLayerId.ToCString())); + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::GetTableRowCount() const +{ + return 40; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return QVariant(); + + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures()); + case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled()); + case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities()); + + case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size()); + case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled()); + case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects()); + + case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size()); + case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size()); + case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size()); + + default: + break; + } + + Standard_Integer aRow = theRow - 9; + return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings()); +} + +// ======================================================================= +// function : getLayerSettingsTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const +{ + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant(); + case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString()); + case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString()); + + case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString()); + case 4: return isFirstColumn ? QVariant ("OriginTransformation") + : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString()); + + case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance()); + case 6: return isFirstColumn ? QVariant ("CullingDistance") + : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0); + + case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize()); + case 8: return isFirstColumn ? QVariant ("CullingSize") + : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0); + + case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate()); + case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture()); + case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest()); + case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite()); + case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth()); + case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass()); + + case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode") + : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode)); + case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor); + case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units); + + default: break; + } + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemOpenGlLayer::createChild (int theRow, int theColumn) +{ + (void)theRow; + (void)theColumn; + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlLayer.hxx b/tools/VInspector/VInspector_ItemOpenGlLayer.hxx new file mode 100644 index 0000000000..b2c9546afc --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayer.hxx @@ -0,0 +1,110 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlLayer_H +#define VInspector_ItemOpenGlLayer_H + +#include +#include + +#include +#include + +class Graphic3d_Group; + +class VInspector_ItemOpenGlLayer; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlLayerPtr; + +//! \class VInspector_ItemOpenGlLayer +//! Parent item, that corresponds to AIS_InteractiveContext +//! Children of the item are: +//! - "Property" item to show context attributes such as selection filters and drawer properties +//! - presentation items to show all interactive elements displayed/erased in the context +class VInspector_ItemOpenGlLayer : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlLayerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlLayerPtr (new VInspector_ItemOpenGlLayer (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlLayer() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; } + + //! Returns the current graphic3d group, init item if it was not initialized yet + //! \return graphic group + Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const + { return Handle(OpenGl_Layer)::DownCast (GetObject());} + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + //! Returns table presentation of layer settings + QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const; + + //! 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; + +private: + + //! Constructor + //! 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 + VInspector_ItemOpenGlLayer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +private: + Handle(OpenGl_Layer) myLayer; //! current layer + Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerArray.cxx b/tools/VInspector/VInspector_ItemOpenGlLayerArray.cxx new file mode 100644 index 0000000000..9836ba073d --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerArray.cxx @@ -0,0 +1,217 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Init() +{ + VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast(Parent()); + myLayer = aParentItem->GetLayer (Row(), myLayerId); + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Reset() +{ + VInspector_ItemBase::Reset(); + myLayer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return Column() == 0 ? "Empty element" : ""; + + switch (Column()) + { + case 0: + { + TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId); + if (aLayerId.IsEmpty()) + aLayerId = TCollection_AsciiString (myLayerId); + return theItemRole == Qt::ToolTipRole ? QVariant ("") + : QVariant (QString("%1 (%2)") + .arg(aLayer->DynamicType()->Name()) + .arg (aLayerId.ToCString())); + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::GetTableRowCount() const +{ + return 40; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return QVariant(); + + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures()); + case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled()); + case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities()); + + case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size()); + case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled()); + case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects()); + + case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size()); + case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size()); + case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size()); + + default: + break; + } + + Standard_Integer aRow = theRow - 9; + return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings()); +} + +// ======================================================================= +// function : getLayerSettingsTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const +{ + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant(); + case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString()); + case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString()); + + case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString()); + case 4: return isFirstColumn ? QVariant ("OriginTransformation") + : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString()); + + case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance()); + case 6: return isFirstColumn ? QVariant ("CullingDistance") + : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0); + + case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize()); + case 8: return isFirstColumn ? QVariant ("CullingSize") + : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0); + + case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate()); + case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture()); + case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest()); + case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite()); + case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth()); + case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass()); + + case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode") + : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode)); + case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor); + case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units); + + default: break; + } + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemOpenGlLayer::createChild (int theRow, int theColumn) +{ + (void)theRow; + (void)theColumn; + + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerArray.hxx b/tools/VInspector/VInspector_ItemOpenGlLayerArray.hxx new file mode 100644 index 0000000000..b2c9546afc --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerArray.hxx @@ -0,0 +1,110 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlLayer_H +#define VInspector_ItemOpenGlLayer_H + +#include +#include + +#include +#include + +class Graphic3d_Group; + +class VInspector_ItemOpenGlLayer; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlLayerPtr; + +//! \class VInspector_ItemOpenGlLayer +//! Parent item, that corresponds to AIS_InteractiveContext +//! Children of the item are: +//! - "Property" item to show context attributes such as selection filters and drawer properties +//! - presentation items to show all interactive elements displayed/erased in the context +class VInspector_ItemOpenGlLayer : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlLayerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlLayerPtr (new VInspector_ItemOpenGlLayer (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlLayer() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; } + + //! Returns the current graphic3d group, init item if it was not initialized yet + //! \return graphic group + Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const + { return Handle(OpenGl_Layer)::DownCast (GetObject());} + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + //! Returns table presentation of layer settings + QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const; + + //! 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; + +private: + + //! Constructor + //! 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 + VInspector_ItemOpenGlLayer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +private: + Handle(OpenGl_Layer) myLayer; //! current layer + Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx b/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx new file mode 100644 index 0000000000..3812a28c3f --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx @@ -0,0 +1,197 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayerList::Init() +{ + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayerList::Reset() +{ + VInspector_ItemBase::Reset(); +} + +// ======================================================================= +// function : GetLayerList +// purpose : +// ======================================================================= +const OpenGl_LayerList& VInspector_ItemOpenGlLayerList::GetLayerList (Standard_Boolean& isDefault) const +{ + VInspector_ItemGraphic3dCViewPtr aParentItem = itemDynamicCast(Parent()); + return aParentItem->GetLayerList (isDefault); +} + +// ======================================================================= +// function : GetLayer +// purpose : +// ======================================================================= +Handle(OpenGl_Layer) VInspector_ItemOpenGlLayerList::GetLayer (const int theRow, Graphic3d_ZLayerId& theLayerId) const +{ + Standard_Boolean isDefault; + const OpenGl_LayerList& aLayerList = GetLayerList (isDefault); + + if (isDefault) + return NULL; + + Standard_Integer aLayerIndex = (int)theRow + 1; + Handle(OpenGl_Layer) aLayer = aLayerList.Layers().Value (aLayerIndex); // OpenGl_LayerSeqIds range is in [1...N] + if (aLayer.IsNull()) + return NULL; + + const OpenGl_LayerSeqIds& aLayerIDs = aLayerList.LayerIDs(); + for (OpenGl_LayerSeqIds::Iterator aMapIt (aLayerIDs); aMapIt.More(); aMapIt.Next()) + { + Standard_Integer anIndex = aMapIt.Value(); + if (anIndex != aLayerIndex) + continue; + + theLayerId = aMapIt.Key(); + } + + return aLayer; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayerList::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayerList::initRowCount() const +{ + if (Column() != 0) + return 0; + + Standard_Boolean isDefault; + const OpenGl_LayerList& aListOfLayers = GetLayerList (isDefault); + if (isDefault) + return 0; + + return aListOfLayers.Layers().Length(); +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayerList::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + + switch (Column()) + { + case 0: + { + Standard_Boolean isDefault; + GetLayerList (isDefault); + if (isDefault) + return 0; + + return isDefault ? "Empty layer list" : "OpenGl_LayerList"; + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayerList::GetTableRowCount() const +{ + return 3; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayerList::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + Standard_Boolean isDefault; + const OpenGl_LayerList& aListOfLayers = GetLayerList (isDefault); + if (isDefault) + return QVariant(); + + bool isFirstColumn = theColumn == 0; + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aListOfLayers.NbPriorities()); + case 1: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aListOfLayers.NbStructures()); + case 2: return isFirstColumn ? QVariant ("NbImmediateStructures") : QVariant (aListOfLayers.NbImmediateStructures()); + + default: return QVariant(); + } + + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemOpenGlLayerList::createChild (int theRow, int theColumn) +{ + return VInspector_ItemOpenGlLayer::CreateItem (currentItem(), theRow, theColumn); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx b/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx new file mode 100644 index 0000000000..d08f3d8bd0 --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx @@ -0,0 +1,102 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlLayerList_H +#define VInspector_ItemOpenGlLayerList_H + +#include +#include + +#include + +class VInspector_ItemOpenGlLayerList; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlLayerListPtr; + +//! \class VInspector_ItemOpenGlLayerList +//! Parent item, that corresponds to OpenGl_LayerList +//! Children of the item are: +//! - OpenGl_Layer items +class VInspector_ItemOpenGlLayerList : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlLayerListPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlLayerListPtr (new VInspector_ItemOpenGlLayerList (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlLayerList() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; } + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns layer list if the View is OpenGl_View + //! \param isDefault flag is true if the layer is absent and the default value of this class is used + Standard_EXPORT const OpenGl_LayerList& GetLayerList (Standard_Boolean& isDefault) const; + + //! Returns layer list if the View is OpenGl_View + //! \param theLayerId index of the layer + Standard_EXPORT Handle(OpenGl_Layer) GetLayer (const int theRow, Graphic3d_ZLayerId& theLayerId) const; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + + //! 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; + +private: + + //! Constructor + //! 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 + VInspector_ItemOpenGlLayerList(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerStructure.cxx b/tools/VInspector/VInspector_ItemOpenGlLayerStructure.cxx new file mode 100644 index 0000000000..9836ba073d --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerStructure.cxx @@ -0,0 +1,217 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Init() +{ + VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast(Parent()); + myLayer = aParentItem->GetLayer (Row(), myLayerId); + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::Reset() +{ + VInspector_ItemBase::Reset(); + myLayer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayer::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::initValue (const int theItemRole) const +{ + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return Column() == 0 ? "Empty element" : ""; + + switch (Column()) + { + case 0: + { + TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId); + if (aLayerId.IsEmpty()) + aLayerId = TCollection_AsciiString (myLayerId); + return theItemRole == Qt::ToolTipRole ? QVariant ("") + : QVariant (QString("%1 (%2)") + .arg(aLayer->DynamicType()->Name()) + .arg (aLayerId.ToCString())); + } + default: + break; + } + return QVariant(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlLayer::GetTableRowCount() const +{ + return 40; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + if (theRole != Qt::DisplayRole) + return QVariant(); + + Handle(OpenGl_Layer) aLayer = GetLayer(); + if (aLayer.IsNull()) + return QVariant(); + + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures()); + case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled()); + case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities()); + + case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size()); + case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled()); + case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects()); + + case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size()); + case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size()); + case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size()); + + default: + break; + } + + Standard_Integer aRow = theRow - 9; + return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings()); +} + +// ======================================================================= +// function : getLayerSettingsTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlLayer::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const +{ + bool isFirstColumn = theColumn == 0; + + switch (theRow) + { + case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant(); + case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString()); + case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString()); + + case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString()); + case 4: return isFirstColumn ? QVariant ("OriginTransformation") + : QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString()); + + case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance()); + case 6: return isFirstColumn ? QVariant ("CullingDistance") + : QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0); + + case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize()); + case 8: return isFirstColumn ? QVariant ("CullingSize") + : QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0); + + case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate()); + case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture()); + case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest()); + case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite()); + case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth()); + case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass()); + + case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode") + : QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode)); + case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor); + case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units); + + default: break; + } + return QVariant(); +} + +// ======================================================================= +// function : createChild +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspector_ItemOpenGlLayer::createChild (int theRow, int theColumn) +{ + (void)theRow; + (void)theColumn; + + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerStructure.hxx b/tools/VInspector/VInspector_ItemOpenGlLayerStructure.hxx new file mode 100644 index 0000000000..b2c9546afc --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlLayerStructure.hxx @@ -0,0 +1,110 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlLayer_H +#define VInspector_ItemOpenGlLayer_H + +#include +#include + +#include +#include + +class Graphic3d_Group; + +class VInspector_ItemOpenGlLayer; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlLayerPtr; + +//! \class VInspector_ItemOpenGlLayer +//! Parent item, that corresponds to AIS_InteractiveContext +//! Children of the item are: +//! - "Property" item to show context attributes such as selection filters and drawer properties +//! - presentation items to show all interactive elements displayed/erased in the context +class VInspector_ItemOpenGlLayer : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlLayerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlLayerPtr (new VInspector_ItemOpenGlLayer (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlLayer() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; } + + //! Returns the current graphic3d group, init item if it was not initialized yet + //! \return graphic group + Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const + { return Handle(OpenGl_Layer)::DownCast (GetObject());} + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + //! Returns table presentation of layer settings + QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const; + + //! 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; + +private: + + //! Constructor + //! 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 + VInspector_ItemOpenGlLayer(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +private: + Handle(OpenGl_Layer) myLayer; //! current layer + Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index 22083e4bdd..a66255ca63 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -428,8 +428,7 @@ QVariant VInspector_ItemPresentableObject::GetTableData (const int theRow, const case 31: return isFirstColumn ? QVariant ("HasOwnPresentations") : QVariant (aPrs->HasOwnPresentations()); case 32: return isFirstColumn ? QVariant ("ZLayer") : QVariant (Graphic3d::ZLayerIdToString (aPrs->ZLayer())); case 33: return isFirstColumn ? QVariant ("TransformationGeom") - : (!aPrs->TransformationGeom().IsNull() - ? QVariant (ViewControl_Tools::ToString(aPrs->TransformationGeom()->Trsf()).ToCString()) : QVariant()); + : QVariant (ViewControl_Tools::ToString(aPrs->TransformationGeom()).ToCString()); case 34: return isFirstColumn ? QVariant ("LocalTransformationGeom") : (!aPrs->LocalTransformationGeom().IsNull() ? QVariant (ViewControl_Tools::ToString(aPrs->LocalTransformationGeom()->Trsf()).ToCString()) : QVariant()); diff --git a/tools/ViewControl/ViewControl_TableModelValues.cxx b/tools/ViewControl/ViewControl_TableModelValues.cxx index 2017acc7eb..d5274b7a1a 100644 --- a/tools/ViewControl/ViewControl_TableModelValues.cxx +++ b/tools/ViewControl/ViewControl_TableModelValues.cxx @@ -107,11 +107,49 @@ QVariant ViewControl_TableModelValues::HeaderData (int theSection, Qt::Orientati return QVariant(); } +// ======================================================================= +// function : GetEditType +// purpose : +// ======================================================================= +ViewControl_EditType ViewControl_TableModelValues::GetEditType (const int theRow, const int theColumn) const +{ + if (!GetProperties().IsNull()) + { + return GetProperties()->GetTableEditType (theRow, theColumn); + } + return ViewControl_EditType_None; +} + +// ======================================================================= +// function : GetEnumValues +// purpose : +// ======================================================================= +QList ViewControl_TableModelValues::GetEnumValues (const int theRow, const int theColumn) const +{ + if (!GetProperties().IsNull()) + { + return GetProperties()->GetTableEnumValues (theRow, theColumn); + } + return QList(); +} + // ======================================================================= // function : isItalicHeader // purpose : // ======================================================================= +Qt::ItemFlags ViewControl_TableModelValues::Flags (const QModelIndex& theIndex) const +{ + if (!GetProperties().IsNull()) + { + return GetProperties()->GetTableFlags (theIndex.row(), theIndex.column()); + } + return Qt::NoItemFlags; +} +// ======================================================================= +// function : isItalicHeader +// purpose : +// ======================================================================= bool ViewControl_TableModelValues::isItalicHeader (const int theRow, const int theColumn) const { Qt::Orientation anOrientation = myOrientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical; diff --git a/tools/ViewControl/ViewControl_TableModelValues.hxx b/tools/ViewControl/ViewControl_TableModelValues.hxx index 63e6a32967..5250635cd1 100644 --- a/tools/ViewControl/ViewControl_TableModelValues.hxx +++ b/tools/ViewControl/ViewControl_TableModelValues.hxx @@ -132,8 +132,7 @@ public: //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable //! \param theIndex a model index //! \return flags - virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const - { return theIndex.isValid() ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags; } + Standard_EXPORT virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const; //! Returns item delegate to provide cell editors. By default, it is empty //! \return delegate @@ -143,15 +142,13 @@ public: //! \param theRow a model index row //! \param theColumn a model index column //! \return edit type - virtual ViewControl_EditType GetEditType (const int theRow, const int theColumn) const - { (void)theRow; (void)theColumn; return ViewControl_EditType_None; } + Standard_EXPORT virtual ViewControl_EditType GetEditType (const int theRow, const int theColumn) const; //! Returns container of string values for enumeration in the model row //! \param theRow table model row index //! \param theColumn a model index column //! \return string values for the enumeration presented in the row or an empty container - virtual QList GetEnumValues (const int theRow, const int theColumn) const - { (void)theRow; (void)theColumn; return QList(); } + Standard_EXPORT virtual QList GetEnumValues (const int theRow, const int theColumn) const; //! Returns default color for editable cell //! \return color value diff --git a/tools/ViewControl/ViewControl_Tools.cxx b/tools/ViewControl/ViewControl_Tools.cxx index dece84a49e..1bcf999a37 100644 --- a/tools/ViewControl/ViewControl_Tools.cxx +++ b/tools/ViewControl/ViewControl_Tools.cxx @@ -16,6 +16,8 @@ #include #include +#include + #include #include #include @@ -157,6 +159,18 @@ Standard_Real ViewControl_Tools::ToRealValue (const QVariant& theValue) return QLocale().toDouble (theValue.toString()); } +// ======================================================================= +// function : ToString +// purpose : +// ======================================================================= +TCollection_AsciiString ViewControl_Tools::ToString (const Handle(Geom_Transformation)& theValue) +{ + if (theValue.IsNull()) + return TCollection_AsciiString(); + + return ViewControl_Tools::ToString (theValue->Trsf()); +} + // ======================================================================= // function : ToString // purpose : diff --git a/tools/ViewControl/ViewControl_Tools.hxx b/tools/ViewControl/ViewControl_Tools.hxx index 08c779e46f..7a9b90a3a4 100644 --- a/tools/ViewControl/ViewControl_Tools.hxx +++ b/tools/ViewControl/ViewControl_Tools.hxx @@ -32,6 +32,8 @@ #include #include +class Geom_Transformation; + class QAction; class QObject; class QTableView; @@ -101,6 +103,11 @@ public: //! \return the real value Standard_EXPORT static Standard_Real ToRealValue (const QVariant& theValue); + //! Returns text of orientation + //! \param theLocation a location value + //! \return text value + Standard_EXPORT static TCollection_AsciiString ToString (const Handle(Geom_Transformation)& theValue); + //! Returns text of orientation //! \param theLocation a location value //! \return text value