return Standard_True;
}
}
+
+ if (aName.IsIntegerValue())
+ {
+ theType = aName.IntegerValue();
+ return Standard_True;
+ }
+
return Standard_False;
}
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(); \
// 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)
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;
}
glext.h
+OpenGl.cxx
+OpenGl.hxx
OpenGl_ArbDbg.hxx
OpenGl_ArbFBO.hxx
OpenGl_ArbIns.hxx
--- /dev/null
+// 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 <OpenGl.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+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;
+}
--- /dev/null
+// 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 <OpenGl_LayerFilter.hxx>
+
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+
+//! 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__
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);
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; }
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,
}
//! @return current matrix.
- const typename OpenGl::MatrixType<T>::Mat4& Current()
+ const typename OpenGl_Vec::MatrixType<T>::Mat4& Current()
{
return myCurrent;
}
//! Sets given matrix as current.
- void SetCurrent (const typename OpenGl::MatrixType<T>::Mat4& theNewCurrent)
+ void SetCurrent (const typename OpenGl_Vec::MatrixType<T>::Mat4& theNewCurrent)
{
myCurrent = theNewCurrent;
}
//! Change current matrix.
- typename OpenGl::MatrixType<T>::Mat4& ChangeCurrent()
+ typename OpenGl_Vec::MatrixType<T>::Mat4& ChangeCurrent()
{
return myCurrent;
}
//! Sets given matrix as current.
template <typename Other_t>
- void SetCurrent (const typename OpenGl::MatrixType<Other_t>::Mat4& theNewCurrent)
+ void SetCurrent (const typename OpenGl_Vec::MatrixType<Other_t>::Mat4& theNewCurrent)
{
myCurrent.Convert (theNewCurrent);
}
//! Sets current matrix to identity.
void SetIdentity()
{
- myCurrent = typename OpenGl::MatrixType<T>::Mat4();
+ myCurrent = typename OpenGl_Vec::MatrixType<T>::Mat4();
}
private:
- NCollection_Vector<typename OpenGl::MatrixType<T>::Mat4> myStack; //!< Collection used to maintenance matrix stack
- typename OpenGl::MatrixType<T>::Mat4 myCurrent; //!< Current matrix
- Standard_Integer myStackHead; //!< Index of stack head
+ NCollection_Vector<typename OpenGl_Vec::MatrixType<T>::Mat4> myStack; //!< Collection used to maintenance matrix stack
+ typename OpenGl_Vec::MatrixType<T>::Mat4 myCurrent; //!< Current matrix
+ Standard_Integer myStackHead; //!< Index of stack head
};
#endif // _OpenGl_MatrixState_H__
//! 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);
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; }
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
}
return;
}
+ else
+ {
+ if (anApplication.IsNull() && CDF_Session::Exists())
+ anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
+ }
myModule = new DFBrowser_Module();
myModule->CreateViewModel (myMainWindow);
MessageModel_ItemBase.hxx
MessageModel_ItemReport.cxx
MessageModel_ItemReport.hxx
+MessageModel_ItemReportProperties.cxx
+MessageModel_ItemReportProperties.hxx
MessageModel_ItemRoot.cxx
MessageModel_ItemRoot.hxx
MessageModel_ReportCallBack.cxx
{
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
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
+#define DEBUG_ALERTS
+
+#ifdef DEBUG_ALERTS
+#include <Message_Alerts.hxx>
+#include <Message_PerfMeter.hxx>
+#endif
+
// =======================================================================
// function : Constructor
// purpose :
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
}
// =======================================================================
{
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]);
((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 :
QMessageBox::information (0, "Information", QString ("TShapes '%1' are sent to %2 tool.")
.arg (anExportedPointers.join (", ")).arg (QString (aPluginName.ToCString())));
}
+
+// =======================================================================
+// function : OnTestAlerts
+// purpose :
+// =======================================================================
+#include <OSD_Chronometer.hxx>
+#include <ctime>
+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
+}
//! 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
}
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)
{
if (aCompositeAlert.IsNull())
return GetUnitedAlerts().Size();
- int aRowCount = 0;
- NCollection_Vector<Message_ListOfAlert> 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();
}
// =======================================================================
{
MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport> (Parent());
MessageModel_ItemAlertPtr anAlertItem;
- Handle(Message_Report) aReport;
Handle(Message_Alert) anAlert;
if (aReportItem)
- aReport = aReportItem->GetReport();
- else
- {
- anAlertItem = itemDynamicCast<MessageModel_ItemAlert> (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<Message_ListOfAlert> 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<MessageModel_ItemAlert> (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();
}
// =======================================================================
MessageModel_ItemBase::Reset();
myAlert = Handle(Message_Alert)();
myUnitedAlerts.Clear();
+ myChildAlerts.Clear();
}
// =======================================================================
return anAmountTime;
}
-
-// =======================================================================
-// function : GetUnitedAlerts
-// purpose :
-// =======================================================================
-void MessageModel_ItemAlert::GetUnitedAlerts(const Message_ListOfAlert& theAlerts,
- NCollection_Vector<Message_ListOfAlert>& 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();
- }
- }
-}
#include <Message_Alert.hxx>
#include <Message_ListOfAlert.hxx>
#include <Message_Report.hxx>
+#include <NCollection_DataMap.hxx>
#include <Standard.hxx>
#include <TopoDS_Shape.hxx>
//! 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; }
//! \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<Message_ListOfAlert> & theUnitedAlerts);
-
protected:
//! Initialize the current item. It is empty because Reset() is also empty.
private:
Handle(Message_Alert) myAlert;
Message_ListOfAlert myUnitedAlerts;
+
+ NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
+
TopoDS_Shape myCustomShape;
};
#include <inspector/MessageModel_ItemReport.hxx>
-#include <inspector/MessageModel_ItemRoot.hxx>
#include <inspector/MessageModel_ItemAlert.hxx>
+#include <inspector/MessageModel_ItemReportProperties.hxx>
+#include <inspector/MessageModel_ItemRoot.hxx>
+#include <inspector/MessageModel_Tools.hxx>
#include <OSD_Path.hxx>
if (aReport.IsNull())
return 0;
- int aRowCount = 0;
- NCollection_Vector<Message_ListOfAlert> 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();
}
// =======================================================================
{
MessageModel_ItemRootPtr aRootItem = itemDynamicCast<MessageModel_ItemRoot> (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();
}
// =======================================================================
{
MessageModel_ItemBase::Reset();
myReport = Handle(Message_Report)();
+ myChildAlerts.Clear();
}
// =======================================================================
#include <inspector/MessageModel_ItemBase.hxx>
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
+#include <Message_Alert.hxx>
#include <Message_Report.hxx>
+#include <NCollection_DataMap.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QMap>
//! 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
private:
+ NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
+
Handle(Message_Report) myReport; //!< current report
TCollection_AsciiString myDescription; //!< description
};
--- /dev/null
+// 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 <inspector/MessageModel_ItemReportProperties.hxx>
+#include <inspector/MessageModel_ItemReport.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
+#include <inspector/ShapeView_Tools.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+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<MessageModel_ItemReport>(myItem);
+ if (!aReportItem)
+ return NULL;
+
+ return aReportItem->GetReport();
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <Message_Report.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+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
// 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)
// commercial license or contractual agreement.
#include <inspector/MessageModel_Tools.hxx>
+#include <inspector/MessageModel_ItemAlert.hxx>
#include <inspector/MessageModel_TableModelValues.hxx>
#include <inspector/ViewControl_Table.hxx>
// function : GetPropertyTableValues
// purpose :
// =======================================================================
-void MessageModel_Tools::GetPropertyTableValues (const Handle(Message_Alert)& theAlert,
+void MessageModel_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
QList<ViewControl_TableModelValues*>& 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<MessageModel_ItemAlert>(theItem);
+ if (!anAlertItem)
+ return;
+
+ const Handle(Message_Alert)& anAlert = anAlertItem->GetAlert();
+ Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(anAlert);
if (anExtendedAlert.IsNull())
return;
}
}
}
+
+// =======================================================================
+// function : GetUnitedAlerts
+// purpose :
+// =======================================================================
+void MessageModel_Tools::GetUnitedAlerts(const Message_ListOfAlert& theAlerts,
+ NCollection_DataMap<Standard_Integer, Message_ListOfAlert>& 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();
+ }
+ }
+}
#include <Standard.hxx>
#include <TCollection_AsciiString.hxx>
+#include <Message_ListOfAlert.hxx>
+#include <NCollection_DataMap.hxx>
+#include <NCollection_Vector.hxx>
#include <Standard_Transient.hxx>
#include <TopoDS_Shape.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
#include <Standard_WarningsDisable.hxx>
#include <QList>
#include <Standard_WarningsRestore.hxx>
//! 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<ViewControl_TableModelValues*>& 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<Standard_Integer, Message_ListOfAlert>& theUnitedAlerts);
};
#endif
break;
}
if (aRootItem)
+ {
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Import Report"), SLOT (onImportReport()), myMainWindow, this));
+ // unite
+ MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (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));
openFile (TCollection_AsciiString (aFileName.toStdString().c_str()));
}
+// =======================================================================
+// function : onImportReport
+// purpose :
+// =======================================================================
+void MessageView_Window::onUniteAlerts()
+{
+ MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
+ Standard_Boolean isUniteAlerts = aTreeModel->IsUniteAlerts();
+
+ aTreeModel->SetUniteAlerts (!isUniteAlerts);
+}
+
+// =======================================================================
+// function : onSetReversedAlerts
+// purpose :
+// =======================================================================
+void MessageView_Window::onSetReversedAlerts()
+{
+ MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
+ Standard_Boolean isReversed = aTreeModel->IsReversed();
+
+ aTreeModel->SetReversed (!isReversed);
+}
+
+
// =======================================================================
// function : onReloadReport
// purpose :
if (!anItemBase)
return;
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- if (!anAlertItem)
- return;
-
QList<ViewControl_TableModelValues*> aTableValues;
- MessageModel_Tools::GetPropertyTableValues (anAlertItem->GetAlert(), aTableValues);
+ MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues);
myPropertyView->Init (aTableValues);
}
//! 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();
#include <inspector/TInspector_Communicator.hxx>
+#include <Message_Report.hxx>
#include <OSD_Environment.hxx>
#include <Standard_WarningsDisable.hxx>
if (!strcmp (argv[anArgId], "vinspector"))
aPlugins.insert ("TKVInspector");
+
+ if (!strcmp (argv[anArgId], "messageview"))
+ aPlugins.insert ("TKMessageView");
}
NCollection_List<Handle(Standard_Transient)> aParameters;
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
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
#include <Draw_Interpretor.hxx>
#include <Standard.hxx>
+class TInspector_Communicator;
+
//! \class ToolsDraw
//! \brief Registers DRAW commands to connect to TInspector tools
class ToolsDraw
//! \param theCommands
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
+ Standard_EXPORT static TInspector_Communicator* GetCommunicator();
+
private:
};
#include <inspector/TreeModel_ItemProperties.hxx>
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;
+}
//! \return an integer value
virtual int GetTableRowCount() const { return 0; }
+ //! Returns table value for the row in form: <function name> <function value>
+ //! \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
virtual QList<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const
{ (void)theRow; (void)theColumn; return QList<QVariant>(); }
- //! Returns table value for the row in form: <function name> <function value>
- //! \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
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
: 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")
#include <inspector/VInspector_ItemV3dView.hxx>
#include <inspector/VInspector_ItemGraphic3dCamera.hxx>
#include <inspector/VInspector_ItemGraphic3dClipPlane.hxx>
+#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <AIS.hxx>
#include <Graphic3d_CView.hxx>
+#include <OpenGl_View.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
+// =======================================================================
+// 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 :
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();
{
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);
}
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
+#include <OpenGl_LayerList.hxx>
+
class Graphic3d_CView;
class VInspector_ItemGraphic3dCView;
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);
//! \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
--- /dev/null
+// 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 <inspector/VInspector_ItemOpenGlLayer.hxx>
+
+#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <AIS.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <Aspect.hxx>
+#include <Graphic3d.hxx>
+#include <OpenGl_Layer.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_PrimitiveArray.hxx>
+#include <OpenGl_Text.hxx>
+#include <SelectMgr.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemOpenGlLayer::Init()
+{
+ VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlLayerList>(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<VInspector_ItemOpenGlLayer*>(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();
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <Graphic3d_ZLayerSettings.hxx>
+#include <OpenGl_Layer.hxx>
+
+class Graphic3d_Group;
+
+class VInspector_ItemOpenGlLayer;
+typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayer> 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: <function name> <function value>
+ //! \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
--- /dev/null
+// 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 <inspector/VInspector_ItemOpenGlLayer.hxx>
+
+#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <AIS.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <Aspect.hxx>
+#include <Graphic3d.hxx>
+#include <OpenGl_Layer.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_PrimitiveArray.hxx>
+#include <OpenGl_Text.hxx>
+#include <SelectMgr.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemOpenGlLayer::Init()
+{
+ VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlLayerList>(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<VInspector_ItemOpenGlLayer*>(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();
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <Graphic3d_ZLayerSettings.hxx>
+#include <OpenGl_Layer.hxx>
+
+class Graphic3d_Group;
+
+class VInspector_ItemOpenGlLayer;
+typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayer> 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: <function name> <function value>
+ //! \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
--- /dev/null
+// 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 <inspector/VInspector_ItemOpenGlLayerList.hxx>
+
+#include <inspector/VInspector_ItemGraphic3dGroup.hxx>
+#include <inspector/VInspector_ItemGraphic3dCView.hxx>
+#include <inspector/VInspector_ItemOpenGlLayer.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <AIS.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <OpenGl_Element.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_PrimitiveArray.hxx>
+#include <OpenGl_Text.hxx>
+#include <SelectMgr.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// 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<VInspector_ItemGraphic3dCView>(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<VInspector_ItemOpenGlLayerList*>(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);
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <OpenGl_LayerList.hxx>
+
+class VInspector_ItemOpenGlLayerList;
+typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayerList> 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: <function name> <function value>
+ //! \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
--- /dev/null
+// 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 <inspector/VInspector_ItemOpenGlLayer.hxx>
+
+#include <inspector/VInspector_ItemOpenGlLayerList.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <AIS.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <Aspect.hxx>
+#include <Graphic3d.hxx>
+#include <OpenGl_Layer.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_PrimitiveArray.hxx>
+#include <OpenGl_Text.hxx>
+#include <SelectMgr.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemOpenGlLayer::Init()
+{
+ VInspector_ItemOpenGlLayerListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlLayerList>(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<VInspector_ItemOpenGlLayer*>(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();
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <Graphic3d_ZLayerSettings.hxx>
+#include <OpenGl_Layer.hxx>
+
+class Graphic3d_Group;
+
+class VInspector_ItemOpenGlLayer;
+typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlLayer> 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: <function name> <function value>
+ //! \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
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());
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<QVariant> ViewControl_TableModelValues::GetEnumValues (const int theRow, const int theColumn) const
+{
+ if (!GetProperties().IsNull())
+ {
+ return GetProperties()->GetTableEnumValues (theRow, theColumn);
+ }
+ return QList<QVariant>();
+}
+
// =======================================================================
// 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;
//! 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
//! \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<QVariant> GetEnumValues (const int theRow, const int theColumn) const
- { (void)theRow; (void)theColumn; return QList<QVariant>(); }
+ Standard_EXPORT virtual QList<QVariant> GetEnumValues (const int theRow, const int theColumn) const;
//! Returns default color for editable cell
//! \return color value
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/ViewControl_TableModel.hxx>
+#include <Geom_Transformation.hxx>
+
#include <Standard_WarningsDisable.hxx>
#include <QAction>
#include <QHeaderView>
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 :
#include <QVariant>
#include <Standard_WarningsRestore.hxx>
+class Geom_Transformation;
+
class QAction;
class QObject;
class QTableView;
//! \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