From 103763138d1b4a3cffc1933863141506e25201a9 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 24 Apr 2019 11:15:41 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin - items for OpenGl Context/Window classes, - uncomment definition of reporting selection messages. --- .../SelectMgr_SelectableObjectSet.cxx | 2 +- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 12 +- src/StdSelect/StdSelect_ViewerSelector3d.cxx | 6 +- tools/VInspector/FILES | 4 + .../VInspector_ItemOpenGlContext.cxx | 216 ++++++++++++++++++ .../VInspector_ItemOpenGlContext.hxx | 110 +++++++++ .../VInspector_ItemOpenGlWindow.cxx | 216 ++++++++++++++++++ .../VInspector_ItemOpenGlWindow.hxx | 110 +++++++++ 8 files changed, 673 insertions(+), 3 deletions(-) create mode 100644 tools/VInspector/VInspector_ItemOpenGlContext.cxx create mode 100644 tools/VInspector/VInspector_ItemOpenGlContext.hxx create mode 100644 tools/VInspector/VInspector_ItemOpenGlWindow.cxx create mode 100644 tools/VInspector/VInspector_ItemOpenGlWindow.hxx diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx index b81e6a067f..8fc2e17865 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx @@ -19,7 +19,7 @@ #include #include -//#define REPORT_SELECTION_BUILD +#define REPORT_SELECTION_BUILD #ifdef REPORT_SELECTION_BUILD #include #include diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 3b3d9dad9f..8e1644e46d 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -36,7 +36,7 @@ #include -//#define REPORT_SELECTION_BUILD +#define REPORT_SELECTION_BUILD #ifdef REPORT_SELECTION_BUILD #include #include @@ -280,6 +280,16 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive return; } + if (!mySelectingVolumeMgr.ViewClipping().IsNull()) + { + Standard_Real aDepth = /*aPickResult.HasPickedPoint() ?*+/ aPickResult.Depth();// :*/ aPickResult.DistToGeomCenter(); + Standard_Boolean isClipped = mySelectingVolumeMgr.IsClipped (*mySelectingVolumeMgr.ViewClipping(), + aDepth); + if (isClipped) + return; + else + int aValue = 9; + } if (HasDepthClipping (anOwner) && !aSelectable.IsNull() && theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point) diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 19fc15a01d..a22fbf8962 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -69,7 +69,7 @@ #include -//#define REPORT_SELECTION_BUILD +#define REPORT_SELECTION_BUILD #ifdef REPORT_SELECTION_BUILD #include #include @@ -175,6 +175,8 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin, mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos, aMaxMousePos); + mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes()); + TraverseSensitives(); } @@ -193,6 +195,8 @@ void StdSelect_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline, mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight); mySelectingVolumeMgr.BuildSelectingVolume (thePolyline); + mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes()); + TraverseSensitives(); } diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index 744181b067..b0e3e01520 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -32,12 +32,16 @@ VInspector_ItemHistoryRoot.hxx VInspector_ItemHistoryType.cxx VInspector_ItemHistoryType.hxx VInspector_ItemHistoryTypeInfo.hxx +VInspector_ItemOpenGlContext.cxx +VInspector_ItemOpenGlContext.hxx VInspector_ItemOpenGlElement.cxx VInspector_ItemOpenGlElement.hxx VInspector_ItemOpenGlLayer.cxx VInspector_ItemOpenGlLayer.hxx VInspector_ItemOpenGlLayerList.cxx VInspector_ItemOpenGlLayerList.hxx +VInspector_ItemOpenGlWindow.cxx +VInspector_ItemOpenGlWindow.hxx VInspector_ItemPresentableObject.cxx VInspector_ItemPresentableObject.hxx VInspector_ItemPresentations.cxx diff --git a/tools/VInspector/VInspector_ItemOpenGlContext.cxx b/tools/VInspector/VInspector_ItemOpenGlContext.cxx new file mode 100644 index 0000000000..6a83dd0d81 --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlContext.cxx @@ -0,0 +1,216 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +//#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlContext::Init() +{ + //VInspector_ItemOpenGlContextListPtr aParentItem = itemDynamicCast(Parent()); + //myLayer = aParentItem->GetLayer (Row(), myLayerId); + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlContext::Reset() +{ + VInspector_ItemBase::Reset(); + myLayer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlContext::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlContext::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlContext::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_ItemOpenGlContext::GetTableRowCount() const +{ + return 40; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlContext::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_ItemOpenGlContext::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_ItemOpenGlContext::createChild (int theRow, int theColumn) +{ + (void)theRow; + (void)theColumn; + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlContext.hxx b/tools/VInspector/VInspector_ItemOpenGlContext.hxx new file mode 100644 index 0000000000..1f9d2e2b1f --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlContext.hxx @@ -0,0 +1,110 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlContext_H +#define VInspector_ItemOpenGlContext_H + +#include +#include + +#include +#include + +class Graphic3d_Group; + +class VInspector_ItemOpenGlContext; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlContextPtr; + +//! \class VInspector_ItemOpenGlContext +//! 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_ItemOpenGlContext : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlContextPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlContextPtr (new VInspector_ItemOpenGlContext (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlContext() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; } + + //! Returns the current graphic3d group, init item if it was not initialized yet + //! \return graphic group + Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const + { return Handle(OpenGl_Layer)::DownCast (GetObject());} + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + //! Returns table presentation of layer settings + QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + VInspector_ItemOpenGlContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemBase(theParent, theRow, theColumn) {} + +private: + Handle(OpenGl_Layer) myLayer; //! current layer + Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View +}; + +#endif diff --git a/tools/VInspector/VInspector_ItemOpenGlWindow.cxx b/tools/VInspector/VInspector_ItemOpenGlWindow.cxx new file mode 100644 index 0000000000..a8d9063e57 --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlWindow.cxx @@ -0,0 +1,216 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +//#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlWindow::Init() +{ + //VInspector_ItemOpenGlWindowListPtr aParentItem = itemDynamicCast(Parent()); + //myLayer = aParentItem->GetLayer (Row(), myLayerId); + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlWindow::Reset() +{ + VInspector_ItemBase::Reset(); + myLayer = NULL; +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlWindow::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : initRowCount +// purpose : +// ======================================================================= +int VInspector_ItemOpenGlWindow::initRowCount() const +{ + if (Column() != 0) + return 0; + + return 0; +} + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlWindow::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_ItemOpenGlWindow::GetTableRowCount() const +{ + return 40; +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspector_ItemOpenGlWindow::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_ItemOpenGlWindow::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_ItemOpenGlWindow::createChild (int theRow, int theColumn) +{ + (void)theRow; + (void)theColumn; + return TreeModel_ItemBasePtr(); +} diff --git a/tools/VInspector/VInspector_ItemOpenGlWindow.hxx b/tools/VInspector/VInspector_ItemOpenGlWindow.hxx new file mode 100644 index 0000000000..bcc6f46a0c --- /dev/null +++ b/tools/VInspector/VInspector_ItemOpenGlWindow.hxx @@ -0,0 +1,110 @@ +// Created on: 2019-03-15 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef VInspector_ItemOpenGlWindow_H +#define VInspector_ItemOpenGlWindow_H + +#include +#include + +#include +#include + +class Graphic3d_Group; + +class VInspector_ItemOpenGlWindow; +typedef QExplicitlySharedDataPointer VInspector_ItemOpenGlWindowPtr; + +//! \class VInspector_ItemOpenGlWindow +//! 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_ItemOpenGlWindow : public VInspector_ItemBase +{ +public: + + //! Creates an item wrapped by a shared pointer + static VInspector_ItemOpenGlWindowPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspector_ItemOpenGlWindowPtr (new VInspector_ItemOpenGlWindow (theParent, theRow, theColumn)); } + + //! Destructor + virtual ~VInspector_ItemOpenGlWindow() Standard_OVERRIDE {}; + + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; } + + //! Returns the current graphic3d group, init item if it was not initialized yet + //! \return graphic group + Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const + { return Handle(OpenGl_Layer)::DownCast (GetObject());} + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + + //! Returns number of table rows + //! \return an integer value + virtual int GetTableRowCount() const Standard_OVERRIDE; + + //! Returns table value for the row in form: + //! \param theRow a model index row + //! \param theColumn a model index column + virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE; + +protected: + + //! Initialize the current item. It creates a backup of the specific item information + //! Do nothing as context has been already set into item + virtual void initItem() const Standard_OVERRIDE; + + //! Returns number of displayed presentations + //! \return rows count + Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE; + + //! Returns item information for the given role. Fills internal container if it was not filled yet + //! \param theItemRole a value role + //! \return the value + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + +protected: + //! Returns table presentation of layer settings + QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole, + const Graphic3d_ZLayerSettings& theSettings) const; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + //! \param theRow the item row positition in the parent item + //! \param theColumn the item column positition in the parent item + VInspector_ItemOpenGlWindow(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 -- 2.39.5