From: nds Date: Wed, 17 Apr 2019 06:56:47 +0000 (+0300) Subject: 0030268: Inspectors - improvements in VInspector plugin X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=dbc139494b6403b7c4b87c550db794073ae29559;p=occt-copy.git 0030268: Inspectors - improvements in VInspector plugin TreeModel is extended by ItemPropertiesCreator (to customize items/panes outside tools), ViewControl have TransientShape to use in interface TopoDS_Shape as a Handle(Standard_Transient) ShapeView start of curve description for edge item --- diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.cxx b/tools/MessageModel/MessageModel_ItemReportProperties.cxx index f1337a4545..4538856399 100644 --- a/tools/MessageModel/MessageModel_ItemReportProperties.cxx +++ b/tools/MessageModel/MessageModel_ItemReportProperties.cxx @@ -63,7 +63,7 @@ QVariant MessageModel_ItemReportProperties::GetTableData (const int theRow, cons // function : GetTableEditType // purpose : // ======================================================================= -ViewControl_EditType MessageModel_ItemReportProperties::GetTableEditType (const int theRow, const int theColumn) const +ViewControl_EditType MessageModel_ItemReportProperties::GetTableEditType (const int theRow, const int) const { switch (theRow) { @@ -94,7 +94,7 @@ bool MessageModel_ItemReportProperties::SetTableData (const int theRow, const in Handle(Message_Report) MessageModel_ItemReportProperties::getItemReport() const { - MessageModel_ItemReportPtr aReportItem = itemDynamicCast(myItem); + MessageModel_ItemReportPtr aReportItem = itemDynamicCast(getItem()); if (!aReportItem) return NULL; diff --git a/tools/MessageModel/MessageModel_ItemReportProperties.hxx b/tools/MessageModel/MessageModel_ItemReportProperties.hxx index 65e1592772..2970397b9f 100644 --- a/tools/MessageModel/MessageModel_ItemReportProperties.hxx +++ b/tools/MessageModel/MessageModel_ItemReportProperties.hxx @@ -43,7 +43,7 @@ public: //! Constructor Standard_EXPORT MessageModel_ItemReportProperties (TreeModel_ItemBasePtr theItem) - : TreeModel_ItemProperties(), myItem (theItem) {} + : TreeModel_ItemProperties (theItem) {} //! Destructor virtual ~MessageModel_ItemReportProperties() {} @@ -78,10 +78,6 @@ public: protected: //! Returns report Handle(Message_Report) getItemReport() const; - -protected: - - TreeModel_ItemBasePtr myItem; //!< source item base }; #endif diff --git a/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx b/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx index efe135542b..b60235f0b1 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx @@ -55,6 +55,9 @@ int ShapeView_ItemPropertiesEdge::GetTableRowCount() const // function : Data // purpose : // ======================================================================= +#include +#include +#include QVariant ShapeView_ItemPropertiesEdge::GetTableData (const int theRow, const int theColumn, int theRole) const { @@ -90,8 +93,41 @@ QVariant ShapeView_ItemPropertiesEdge::GetTableData (const int theRow, const int : ShapeView_Tools::ToString (aCurve->IsPeriodic()); default: break; } + int anOwnRows = 7; + /*int aTableRow = theRow - anOwnRows; + // BRep_Tool::PolygonOnTriangulation // find the representation + + TopoDS_Edge E = TopoDS::Edge(aShape); + Handle(Poly_PolygonOnTriangulation) P; + Handle(Poly_Triangulation) T; + TopLoc_Location L; + + const BRep_TEdge* TE = static_cast(anEdge.TShape().get()); + BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves()); + + int aCurRow = 0; + while (itcr.More()) { + const Handle(BRep_CurveRepresentation)& cr = itcr.Value(); + if (cr->IsPolygonOnTriangulation()) { + if (aCurRow < aTableRow) + continue; + const BRep_PolygonOnTriangulation* PT = + static_cast(cr.get()); + P = PT->PolygonOnTriangulation(); + T = PT->Triangulation(); + L = E.Location() * PT->Location(); + return isFirstColumn ? QVariant("Polygon: ") : P.; + } + itcr.Next(); + } + L.Identity(); + P.Nullify(); + T.Nullify(); + + anOwnRows += aTableRow; + */ return ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow - anOwnRows, theColumn); } @@ -102,7 +138,7 @@ QVariant ShapeView_ItemPropertiesEdge::GetTableData (const int theRow, const int TopoDS_Shape ShapeView_ItemPropertiesEdge::getItemShape() const { - ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(myItem); + ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(getItem()); if (!aShapeItem) return TopoDS_Shape(); diff --git a/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx b/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx index 4b0e5996cc..a01d74fc17 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx @@ -42,8 +42,8 @@ class ShapeView_ItemPropertiesEdge : public TreeModel_ItemProperties public: //! Constructor - Standard_EXPORT ShapeView_ItemPropertiesEdge (TreeModel_ItemBasePtr theItem) - : TreeModel_ItemProperties(), myItem (theItem) {} + Standard_EXPORT ShapeView_ItemPropertiesEdge (const TreeModel_ItemBasePtr& theItem) + : TreeModel_ItemProperties (theItem) {} //! Destructor virtual ~ShapeView_ItemPropertiesEdge() {} @@ -67,9 +67,6 @@ protected: //! Returns item shape TopoDS_Shape getItemShape() const; -protected: - - TreeModel_ItemBasePtr myItem; //!< source item base }; #endif diff --git a/tools/ShapeView/ShapeView_ItemPropertiesFace.cxx b/tools/ShapeView/ShapeView_ItemPropertiesFace.cxx index 46a7bc0cea..b1c9852437 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesFace.cxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesFace.cxx @@ -58,7 +58,7 @@ QVariant ShapeView_ItemPropertiesFace::GetTableData (const int theRow, const int TopoDS_Shape ShapeView_ItemPropertiesFace::getItemShape() const { - ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(myItem); + ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(getItem()); if (!aShapeItem) return TopoDS_Shape(); diff --git a/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx b/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx index 840abe40d0..6ed1d2d7b6 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx @@ -42,8 +42,8 @@ class ShapeView_ItemPropertiesFace : public TreeModel_ItemProperties public: //! Constructor - Standard_EXPORT ShapeView_ItemPropertiesFace (TreeModel_ItemBasePtr theItem) - : TreeModel_ItemProperties(), myItem (theItem) {} + Standard_EXPORT ShapeView_ItemPropertiesFace (const TreeModel_ItemBasePtr& theItem) + : TreeModel_ItemProperties (theItem) {} //! Destructor virtual ~ShapeView_ItemPropertiesFace() {} @@ -67,9 +67,6 @@ protected: //! Returns item shape TopoDS_Shape getItemShape() const; -protected: - - TreeModel_ItemBasePtr myItem; //!< source item base }; #endif diff --git a/tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx b/tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx index 63d80a2f9f..bcfa01d090 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx @@ -66,7 +66,7 @@ QVariant ShapeView_ItemPropertiesVertex::GetTableData (const int theRow, const i TopoDS_Shape ShapeView_ItemPropertiesVertex::getItemShape() const { - ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(myItem); + ShapeView_ItemShapePtr aShapeItem = itemDynamicCast(getItem()); if (!aShapeItem) return TopoDS_Shape(); diff --git a/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx b/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx index 883eb6b447..79a4965a95 100644 --- a/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx +++ b/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx @@ -42,8 +42,8 @@ class ShapeView_ItemPropertiesVertex : public TreeModel_ItemProperties public: //! Constructor - Standard_EXPORT ShapeView_ItemPropertiesVertex (TreeModel_ItemBasePtr theItem) - : TreeModel_ItemProperties(), myItem (theItem) {} + Standard_EXPORT ShapeView_ItemPropertiesVertex (const TreeModel_ItemBasePtr& theItem) + : TreeModel_ItemProperties (theItem) {} //! Destructor virtual ~ShapeView_ItemPropertiesVertex() {} @@ -67,9 +67,6 @@ protected: //! Returns item shape TopoDS_Shape getItemShape() const; -protected: - - TreeModel_ItemBasePtr myItem; //!< source item base }; #endif diff --git a/tools/ShapeView/ShapeView_Tools.cxx b/tools/ShapeView/ShapeView_Tools.cxx index 56fe491b82..6f5addf555 100644 --- a/tools/ShapeView/ShapeView_Tools.cxx +++ b/tools/ShapeView/ShapeView_Tools.cxx @@ -135,12 +135,13 @@ QVariant ShapeView_Tools::GetShapeGlobalProperties (const TopoDS_Shape& theShape switch (theRow) { - case 0: return isFirstColumn ? "Checked" : ToString (theShape.Checked()); - case 1: return isFirstColumn ? "Closed" : ToString (theShape.Closed()); - case 2: return isFirstColumn ? "Infinite" : ToString (theShape.Infinite()); - case 3: return isFirstColumn ? "Locked" : ToString (theShape.Locked()); - case 4: return isFirstColumn ? "Modified" : ToString (theShape.Modified()); - case 5: return isFirstColumn ? "Orientable" : ToString (theShape.Orientable()); + case 0: return isFirstColumn ? "COMMON PROPERTIES" : ""; + case 1: return isFirstColumn ? "Checked" : ToString (theShape.Checked()); + case 2: return isFirstColumn ? "Closed" : ToString (theShape.Closed()); + case 3: return isFirstColumn ? "Infinite" : ToString (theShape.Infinite()); + case 4: return isFirstColumn ? "Locked" : ToString (theShape.Locked()); + case 5: return isFirstColumn ? "Modified" : ToString (theShape.Modified()); + case 6: return isFirstColumn ? "Orientable" : ToString (theShape.Orientable()); } return QVariant(); } \ No newline at end of file diff --git a/tools/TreeModel/FILES b/tools/TreeModel/FILES index 7bd7cdf3df..d7662e6a0e 100644 --- a/tools/TreeModel/FILES +++ b/tools/TreeModel/FILES @@ -8,6 +8,8 @@ TreeModel_ItemBase.cxx TreeModel_ItemBase.hxx TreeModel_ItemProperties.cxx TreeModel_ItemProperties.hxx +TreeModel_ItemPropertiesCreator.cxx +TreeModel_ItemPropertiesCreator.hxx TreeModel_ItemRole.hxx TreeModel_ModelBase.cxx TreeModel_ModelBase.hxx diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 464a788863..703414f403 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -14,7 +14,7 @@ // commercial license or contractual agreement. #include - +#include #include #include @@ -33,6 +33,24 @@ TreeModel_ItemBase::TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const i m_iColumn = theColumn; } +// ======================================================================= +// function : SetProperties +// purpose : +// ======================================================================= +void TreeModel_ItemBase::SetProperties (const Handle(TreeModel_ItemProperties)& theProperties) +{ + myProperties = theProperties; +} + +// ======================================================================= +// function : GetProperties +// purpose : +// ======================================================================= +Handle(TreeModel_ItemProperties) TreeModel_ItemBase::GetProperties() const +{ + return myProperties; +} + // ======================================================================= // function : reset // purpose : @@ -74,7 +92,12 @@ TreeModel_ItemBasePtr TreeModel_ItemBase::Child (int theRow, int theColumn, cons TreeModel_ItemBasePtr anItem; if (isToCreate) { - anItem = createChild (theRow, theColumn); + int aRowCount = rowCount(); + if (myProperties.IsNull() || theRow < aRowCount - myProperties->ChildItemCount()) + anItem = createChild (theRow, theColumn); + else if (!myProperties.IsNull()) + anItem = myProperties->CreateChildItem (theRow, theColumn); + if (anItem) m_ChildItems[aPos] = anItem; } @@ -99,8 +122,45 @@ QVariant TreeModel_ItemBase::cachedValue (const int theItemRole) const if (myCachedValues.contains (theItemRole)) return myCachedValues[theItemRole]; - const_cast(this)->myCachedValues.insert (theItemRole, - theItemRole == TreeModel_ItemRole_RowCountRole ? QVariant (initRowCount()) : initValue (theItemRole)); + QVariant aValueToCache; + if (theItemRole == TreeModel_ItemRole_RowCountRole) + { + aValueToCache = myProperties.IsNull() ? initRowCount() : (initRowCount() + myProperties->ChildItemCount()); + } + else + aValueToCache = initValue (theItemRole); + const_cast(this)->myCachedValues.insert (theItemRole, aValueToCache); return myCachedValues.contains (theItemRole) ? myCachedValues[theItemRole] : QVariant(); } + +// ======================================================================= +// function : initValue +// purpose : +// ======================================================================= +QVariant TreeModel_ItemBase::initValue (const int theItemRole) const +{ + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole) + return QVariant(); + + switch (Column()) + { + case 1: { return rowCount(); } + //case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString(); + case 3: { return Row(); } + } + + return QVariant(); +} + +// ======================================================================= +// function : RowCountWithoutProperties +// purpose : +// ======================================================================= +int TreeModel_ItemBase::RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem) +{ + if (!theItem->GetProperties()) + return theItem->rowCount(); + + return theItem->rowCount() - theItem->GetProperties()->ChildItemCount(); +} diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index b6c5e5668b..b7f3f7b634 100644 --- a/tools/TreeModel/TreeModel_ItemBase.hxx +++ b/tools/TreeModel/TreeModel_ItemBase.hxx @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include @@ -33,6 +33,7 @@ #include class TreeModel_ItemBase; +class TreeModel_ItemProperties; typedef QExplicitlySharedDataPointer TreeModel_ItemBasePtr; @@ -84,6 +85,10 @@ public: //! there should be initialized here. virtual void Init() { m_bInitialized = true; } + //! Returns data object of the item. + //! \return object + virtual Handle(Standard_Transient) GetObject() const { return NULL; } + //! Resets the item and the child items content. Sets the initialized state to false. //! If the item has internal values, there should be reseted here. Standard_EXPORT virtual void Reset(); @@ -129,10 +134,13 @@ public: int rowCount() const { return cachedValue(TreeModel_ItemRole_RowCountRole).toInt(); } //! Sets item table properties builder - void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties) { myProperties = theProperties; } + Standard_EXPORT void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties); //! Returns item table properties builder - Handle(TreeModel_ItemProperties) GetProperties() const { return myProperties; } + Standard_EXPORT Handle(TreeModel_ItemProperties) GetProperties() const; + + //! Returns number of item rows only + static Standard_EXPORT int RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem); protected: @@ -141,6 +149,9 @@ protected: //! \param theColumn the item column positition in the parent item Standard_EXPORT TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn); + //! Initialize the current item. It creates a backup of the specific item information + virtual void initItem() const {} + //! Creates a child item in the given position. //! \param theRow the child row position //! \param theColumn the child column position @@ -163,7 +174,7 @@ protected: //! Return data value for the role. It should be reimplemented in child //! \param theItemRole a value role //! \return the value - virtual QVariant initValue (const int theItemRole) const = 0; + Standard_EXPORT virtual QVariant initValue (const int theItemRole) const; private: diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index 9364ac487e..d096f71394 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -22,6 +22,9 @@ #include #include +#include + +#include #include #include @@ -40,11 +43,22 @@ class TreeModel_ItemProperties : public Standard_Transient { public: //! Constructor - TreeModel_ItemProperties() {} + TreeModel_ItemProperties (const TreeModel_ItemBasePtr& theItem) : myItem (theItem) {} //! Destructor ~TreeModel_ItemProperties() {} + //! Returns number of item children + //! \return an integer value, ZERO by default + virtual int ChildItemCount() const { return 0; } + + //! 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 CreateChildItem (int theRow, int theColumn) const + { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); } + //! Returns number of table rows //! \return an integer value virtual int GetTableColumnCount() const { return 2; } @@ -73,12 +87,6 @@ public: virtual QList GetTableEnumValues (const int theRow, const int theColumn) const { (void)theRow; (void)theColumn; return QList(); } - //! 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 //! \param theColumn a model index column @@ -86,7 +94,29 @@ public: virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) { (void)theRow; (void)theColumn; (void)theValue; return false; } + //! Returns presentation of the attribute to be visualized in the view + //! \param theRow a model index row + //! \param theColumn a model index column + //! \thePresentations [out] container of presentation handles to be visualized + virtual void GetPresentations (const int theRow, const int theColumn, + NCollection_List& thePresentations) + { (void)theRow; (void)theColumn; (void)thePresentations; } + + //! 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; + + DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient) + +protected: + //! Returns current item + TreeModel_ItemBasePtr getItem() const { return myItem; } + +private: + TreeModel_ItemBasePtr myItem; //! current item }; #endif \ No newline at end of file diff --git a/tools/TreeModel/TreeModel_ItemPropertiesCreator.cxx b/tools/TreeModel/TreeModel_ItemPropertiesCreator.cxx new file mode 100644 index 0000000000..c5ae48db04 --- /dev/null +++ b/tools/TreeModel/TreeModel_ItemPropertiesCreator.cxx @@ -0,0 +1,18 @@ +// Created on: 2019-04-12 +// 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 + +IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemPropertiesCreator, Standard_Transient) diff --git a/tools/TreeModel/TreeModel_ItemPropertiesCreator.hxx b/tools/TreeModel/TreeModel_ItemPropertiesCreator.hxx new file mode 100644 index 0000000000..7e51e6ca98 --- /dev/null +++ b/tools/TreeModel/TreeModel_ItemPropertiesCreator.hxx @@ -0,0 +1,51 @@ +// Created on: 2019-04-12 +// 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 TreeModel_ItemPropertiesCreator_H +#define TreeModel_ItemPropertiesCreator_H + +#include + +#include +#include +#include +#include +#include + +class TreeModel_ItemProperties; + +DEFINE_STANDARD_HANDLE (TreeModel_ItemPropertiesCreator, Standard_Transient) + +//! \class TreeModel_ItemPropertiesCreator +//! \brief An interface to create custom panes by transient object name. +class TreeModel_ItemPropertiesCreator : public Standard_Transient +{ +public: + + //! Constructor + TreeModel_ItemPropertiesCreator() {} + + //! Destructor + virtual ~TreeModel_ItemPropertiesCreator() {} + + //! Creates pane for type + //! \param theName a type name + //! \return a pane if it can be created for this type or NULL + virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) = 0; + + DEFINE_STANDARD_RTTIEXT (TreeModel_ItemPropertiesCreator, Standard_Transient) +}; + +#endif diff --git a/tools/TreeModel/TreeModel_ModelBase.cxx b/tools/TreeModel/TreeModel_ModelBase.cxx index 2840fc829d..1b07852a45 100644 --- a/tools/TreeModel/TreeModel_ModelBase.cxx +++ b/tools/TreeModel/TreeModel_ModelBase.cxx @@ -16,9 +16,13 @@ #include #include +#include +#include #include #include +#include + #include #include #include @@ -180,6 +184,24 @@ int TreeModel_ModelBase::rowCount (const QModelIndex& theParent) const else aParentItem = GetItemByIndex (theParent); + if (!aParentItem) + return 0; + if (!aParentItem->IsInitialized()) + { + TreeModel_ItemProperties* aProperties = 0; + if (!myPropertiesCreators.IsEmpty()) + { + for (NCollection_List::Iterator anIterator (myPropertiesCreators); anIterator.More(); anIterator.Next()) + { + Handle(TreeModel_ItemPropertiesCreator) aCreator = anIterator.Value(); + aProperties = aCreator->GetProperties (aParentItem); + if (aProperties) + break; + } + } + aParentItem->SetProperties (aProperties); + } + return aParentItem ? aParentItem->rowCount() : 0; } @@ -212,6 +234,26 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const #endif } +// ======================================================================= +// function : SetPropertiesCreator +// purpose : +// ======================================================================= +void TreeModel_ModelBase::AddPropertiesCreator (const Handle(TreeModel_ItemPropertiesCreator)& theCreator) +{ + if (myPropertiesCreators.Contains (theCreator)) + return; + myPropertiesCreators.Append (theCreator); +} + +// ======================================================================= +// function : GetProperties +// purpose : +// ======================================================================= +const NCollection_List& TreeModel_ModelBase::GetPropertiesCreators() const +{ + return myPropertiesCreators; +} + // ======================================================================= // function : GetSelected // purpose : diff --git a/tools/TreeModel/TreeModel_ModelBase.hxx b/tools/TreeModel/TreeModel_ModelBase.hxx index b2eb8bc23b..2b83a0cf2b 100644 --- a/tools/TreeModel/TreeModel_ModelBase.hxx +++ b/tools/TreeModel/TreeModel_ModelBase.hxx @@ -20,6 +20,8 @@ #include #include +#include + #include #include #include @@ -29,6 +31,7 @@ #include #include +class TreeModel_ItemPropertiesCreator; class TreeModel_VisibilityState; //! \class TreeModel_ModelBase @@ -149,6 +152,12 @@ public: virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE { (void)theParent; return myHeaderValues.size(); } + //! Sets item table properties builder + Standard_EXPORT void AddPropertiesCreator (const Handle(TreeModel_ItemPropertiesCreator)& theCreator); + + //! Returns item table properties builder + Standard_EXPORT const NCollection_List& GetPropertiesCreators() const; + //! Returns default value of the visibility column //! \return integer value static int ColumnVisibilityWidth() { return 20; } @@ -198,6 +207,8 @@ protected: QIcon myInvisibleIcon; //!< icon of invisible state QModelIndexList myHighlightedIndices; //!< tree model indices that should be visualized as highlighted + + NCollection_List myPropertiesCreators; //!< property pane creators for items }; #endif diff --git a/tools/VInspector/VInspector_ItemBase.hxx b/tools/VInspector/VInspector_ItemBase.hxx index b5447aa3ec..674ea6418d 100644 --- a/tools/VInspector/VInspector_ItemBase.hxx +++ b/tools/VInspector/VInspector_ItemBase.hxx @@ -49,10 +49,6 @@ public: //! \return a context Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; - //! Returns data object of the item. - //! \return object - virtual Handle(Standard_Transient) GetObject() const { return NULL; } - //! Returns item information for the given role. Fills internal container if it was not filled yet //! \param theItemRole a value role //! \return the value @@ -107,9 +103,6 @@ public: protected: - //! Initialize the current item. It creates a backup of the specific item information - virtual void initItem() const {} - //! Build presentation shape //! \return generated shape of the item parameters virtual TopoDS_Shape buildPresentationShape() { return TopoDS_Shape(); } diff --git a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx index eb341d941f..663a786b00 100644 --- a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx @@ -80,8 +80,8 @@ QVariant VInspector_ItemPrs3dDrawer::initValue (int theItemRole) const int VInspector_ItemPrs3dDrawer::initRowCount() const { - VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast(Parent()); - if (!aParentItem) + VInspector_ItemPrs3dDrawerPtr aParentDrawerItem = itemDynamicCast(Parent()); + if (aParentDrawerItem) return 0; Handle(Prs3d_Drawer) aDrawer = GetDrawer(); @@ -102,9 +102,7 @@ TreeModel_ItemBasePtr VInspector_ItemPrs3dDrawer::createChild (int theRow, int t { if (theRow == 0) { - VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast(Parent()); - if (aParentItem) - return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn); // "Link" + return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn); // "Link" } else return VInspector_ItemPrs3dAspect::CreateItem (currentItem(), theRow, theColumn); // "Aspects" diff --git a/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx b/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx index e597e00556..8d971b0571 100644 --- a/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx +++ b/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx @@ -110,7 +110,7 @@ protected: //! \return the created item virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE; -private: +protected: //! Set interactive object into the current field //! \param theIO a presentation @@ -118,7 +118,7 @@ private: void setDrawer (const Handle(Prs3d_Drawer)& theDrawer, const TCollection_AsciiString& theName) { myDrawer = theDrawer; myName = theName; } -private: +protected: //! Constructor //! param theParent a parent item diff --git a/tools/VInspector/VInspector_TableModelValues.cxx b/tools/VInspector/VInspector_TableModelValues.cxx index a94b4d5e17..79606ed753 100644 --- a/tools/VInspector/VInspector_TableModelValues.cxx +++ b/tools/VInspector/VInspector_TableModelValues.cxx @@ -51,6 +51,15 @@ VInspector_TableModelValues::VInspector_TableModelValues (const TreeModel_ItemBa QVariant VInspector_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const { + int aRow = theRow; + if (!myItem->GetProperties().IsNull()) + { + int aPropertiesCount = myItem->GetProperties()->GetTableRowCount(); + if (aRow < aPropertiesCount) + return myItem->GetProperties()->GetTableData (theRow, theColumn, theRole); + else + aRow = aRow - aPropertiesCount; + } switch (theRole) { case Qt::FontRole: @@ -66,17 +75,19 @@ QVariant VInspector_TableModelValues::Data (const int theRow, const int theColum { if (theColumn == 0) return QColor (Qt::darkGray).darker(150); - else if (GetEditType (theRow, theColumn) != ViewControl_EditType_None) + else if (GetEditType (aRow, theColumn) != ViewControl_EditType_None) return ViewControl_TableModelValues::EditCellColor(); } default: { VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return QVariant(); Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) - return anItem->GetTableData (theRow, theColumn, theRole); + return anItem->GetTableData (aRow, theColumn, theRole); - int aCurrentRow = theRow; + int aCurrentRow = aRow; for (NCollection_List::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next()) { Handle(ViewControl_PaneCreator) aCreator = anIterator.Value(); @@ -103,12 +114,25 @@ bool VInspector_TableModelValues::SetData (const int theRow, const int theColumn if (theRole != Qt::EditRole) return false; + int aRow = theRow; + if (!myItem->GetProperties().IsNull()) + { + int aPropertiesCount = myItem->GetProperties()->GetTableRowCount(); + if (aRow < aPropertiesCount) + return myItem->GetProperties()->SetTableData (theRow, theColumn, theValue); + else + aRow = aRow - aPropertiesCount; + } + VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return false; + Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) - return anItem->SetTableData (theRow, theColumn, theValue); + return anItem->SetTableData (aRow, theColumn, theValue); - int aCurrentRow = theRow; + int aCurrentRow = aRow; for (NCollection_List::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next()) { Handle(ViewControl_PaneCreator) aCreator = anIterator.Value(); @@ -145,9 +169,15 @@ Qt::ItemFlags VInspector_TableModelValues::Flags (const QModelIndex& theIndex) c int VInspector_TableModelValues::RowCount (const QModelIndex& theParent) const { + int aRowCount = 0; + if (!myItem->GetProperties().IsNull()) + aRowCount = myItem->GetProperties()->GetTableRowCount(); + VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return aRowCount; - int aRowCount = anItem->GetTableRowCount(); + aRowCount += anItem->GetTableRowCount(); Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) return aRowCount; @@ -170,15 +200,28 @@ int VInspector_TableModelValues::RowCount (const QModelIndex& theParent) const ViewControl_EditType VInspector_TableModelValues::GetEditType (const int theRow, const int theColumn) const { + int aRow = theRow; + if (!myItem->GetProperties().IsNull()) + { + int aPropertiesCount = myItem->GetProperties()->GetTableRowCount(); + if (aRow < aPropertiesCount) + return myItem->GetProperties()->GetTableEditType (theRow, theColumn); + else + aRow = aRow - aPropertiesCount; + } + if (theColumn == 0) return ViewControl_EditType_None; VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return ViewControl_EditType_None; + Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) - return anItem->GetTableEditType (theRow, theColumn); + return anItem->GetTableEditType (aRow, theColumn); - int aCurrentRow = theRow; + int aCurrentRow = aRow; for (NCollection_List::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next()) { Handle(ViewControl_PaneCreator) aCreator = anIterator.Value(); @@ -203,12 +246,25 @@ QList VInspector_TableModelValues::GetEnumValues (const int theRow, co if (theColumn != 1) return QList(); + int aRow = theRow; + if (!myItem->GetProperties().IsNull()) + { + int aPropertiesCount = myItem->GetProperties()->GetTableRowCount(); + if (aRow < aPropertiesCount) + return myItem->GetProperties()->GetTableEnumValues (theRow, theColumn); + else + aRow = aRow - aPropertiesCount; + } + VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return QList(); + Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) - return anItem->GetTableEnumValues (theRow, theColumn); + return anItem->GetTableEnumValues (aRow, theColumn); - int aCurrentRow = theRow; + int aCurrentRow = aRow; for (NCollection_List::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next()) { Handle(ViewControl_PaneCreator) aCreator = anIterator.Value(); @@ -230,7 +286,20 @@ QList VInspector_TableModelValues::GetEnumValues (const int theRow, co void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int theColumn, NCollection_List& theShapes) { + int aRow = theRow; + if (!myItem->GetProperties().IsNull()) + { + int aPropertiesCount = myItem->GetProperties()->GetTableRowCount(); + if (aRow < aPropertiesCount) + return;// myItem->GetProperties()->GetEnumValues (theRow, theColumn); + else + aRow = aRow - aPropertiesCount; + } + VInspector_ItemBasePtr anItem = GetItem(); + if (!anItem) + return; + Handle(Standard_Transient) anObject = anItem->GetObject(); if (anObject.IsNull()) return; @@ -242,7 +311,7 @@ void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int the if (!aPane) continue; - ViewControl_PaneItem* anItem = aPane->GetSelected (anObject, theRow, theColumn); + ViewControl_PaneItem* anItem = aPane->GetSelected (anObject, aRow, theColumn); if (anItem && !anItem->GetShape().IsNull()) theShapes.Append (anItem->GetShape()); } diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 48082d7cfe..8187ac7a17 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -22,13 +23,17 @@ #include #include +#include + #include #include +#include #include #include #include #include +#include #include #include @@ -48,6 +53,7 @@ #include #include +#include #include #include @@ -142,6 +148,7 @@ VInspector_Window::VInspector_Window() // property view myPaneCreators.Append (new VInspectorPaneAIS_PaneCreator()); + aTreeModel->AddPropertiesCreator (new VInspectorPaneAIS_PropertiesCreator()); myPropertyView = new ViewControl_PropertyView (myMainWindow, QSize(VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH, VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT)); @@ -373,7 +380,7 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode { TreeModel_ItemBasePtr anItem = *anItemIt; VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (!aVItem && aVItem->Row() == 0) + if (!aVItem || aVItem->Row() == 0) continue; TopoDS_Shape aShape = aVItem->GetPresentationShape(); @@ -411,18 +418,19 @@ void VInspector_Window::GetSelectedPropertyPanelShapes (const QModelIndexList& t NCollection_List& theShapes) { QList anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices); + NCollection_List aPropertyPresentations; for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) { TreeModel_ItemBasePtr anItem = *anItemIt; - VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (!aVItem || aVItem->Column() != 0) + if (!anItem || anItem->Column() != 0) continue; QList aTableValues; - VInspector_Tools::GetPropertyTableValues (aVItem, myPaneCreators, aTableValues); + VInspector_Tools::GetPropertyTableValues (anItem, myPaneCreators, aTableValues); if (aTableValues.isEmpty()) continue; + Handle(TreeModel_ItemProperties) anItemProperties = anItem->GetProperties(); for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++) { VInspector_TableModelValues* aTableVals = dynamic_cast(aTableValues[aTableIt]); @@ -436,9 +444,24 @@ void VInspector_Window::GetSelectedPropertyPanelShapes (const QModelIndexList& t { QModelIndex anIndex = *anIndicesIt; aTableVals->GetPaneShapes (anIndex.row(), anIndex.column(), theShapes); + + if (!anItemProperties.IsNull()) + { + anItemProperties->GetPresentations (anIndex.row(), anIndex.column(), aPropertyPresentations); + } } } } + + if (!aPropertyPresentations.IsEmpty()) + { + for (NCollection_List::Iterator aPrsIterator (aPropertyPresentations); aPrsIterator.More(); aPrsIterator.Next()) + { + Handle(ViewControl_TransientShape) aShapePrs = Handle(ViewControl_TransientShape)::DownCast (aPrsIterator.Value()); + if (!aShapePrs.IsNull()) + theShapes.Append (aShapePrs->GetShape()); + } + } } // ======================================================================= @@ -530,6 +553,12 @@ bool VInspector_Window::Init (const NCollection_List if (!myPaneCreators.Contains (aPaneCreator)) myPaneCreators.Append (aPaneCreator); } + if (!Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject).IsNull()) + { + Handle(TreeModel_ItemPropertiesCreator) aPropCreator = Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject); + VInspector_ViewModel* aViewModel = dynamic_cast(myTreeView->model()); + aViewModel->AddPropertiesCreator (aPropCreator); + } } if (aContext.IsNull()) return false; @@ -587,8 +616,17 @@ bool VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName) if (aShape.IsNull()) return isModelUpdated; +#ifndef DEBUG_COLORED_SHAPE Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape); +#else + Handle(AIS_ColoredShape) aPresentation = new AIS_ColoredShape (aShape); + TopExp_Explorer expS(aShape, TopAbs_EDGE); + for (; expS.More(); expS.Next()) + { + aPresentation->SetCustomColor (expS.Current(), Quantity_Color (Quantity_NOC_GREEN)); + } +#endif View_Displayer* aDisplayer = myViewWindow->GetDisplayer(); aDisplayer->DisplayPresentation (aPresentation); diff --git a/tools/VInspectorPaneAIS/FILES b/tools/VInspectorPaneAIS/FILES index 310e98b5ae..79a7145510 100644 --- a/tools/VInspectorPaneAIS/FILES +++ b/tools/VInspectorPaneAIS/FILES @@ -1,4 +1,10 @@ +VInspectorPaneAIS_ColoredShape.cxx +VInspectorPaneAIS_ColoredShape.hxx +VInspectorPaneAIS_ItemPrs3dDrawer.cxx +VInspectorPaneAIS_ItemPrs3dDrawer.hxx VInspectorPaneAIS_PaneCreator.cxx VInspectorPaneAIS_PaneCreator.hxx +VInspectorPaneAIS_PropertiesCreator.cxx +VInspectorPaneAIS_PropertiesCreator.hxx VInspectorPaneAIS_Shape.cxx VInspectorPaneAIS_Shape.hxx \ No newline at end of file diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.cxx new file mode 100644 index 0000000000..281e432fa0 --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.cxx @@ -0,0 +1,59 @@ +// Created on: 2019-04-14 +// 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 + +// ======================================================================= +// function : ChildItemCount +// purpose : +// ======================================================================= +int VInspectorPaneAIS_ColoredShape::ChildItemCount() const +{ + Handle(AIS_ColoredShape) aPrs = GetPresentation(); + if (aPrs.IsNull()) + return 0; + + return aPrs->CustomAspectsMap().Size(); +} + +// ======================================================================= +// function : CreateChildItem +// purpose : +// ======================================================================= +TreeModel_ItemBasePtr VInspectorPaneAIS_ColoredShape::CreateChildItem (int theRow, int theColumn) const +{ + Handle(AIS_ColoredShape) aPrs = GetPresentation(); + if (aPrs.IsNull()) + return TreeModel_ItemBasePtr(); + + return VInspectorPaneAIS_ItemPrs3dDrawer::CreateItem (getItem(), theRow, theColumn); +} + +// ======================================================================= +// function : GetPresentation +// purpose : +// ======================================================================= +Handle(AIS_ColoredShape) VInspectorPaneAIS_ColoredShape::GetPresentation() const +{ + return Handle(AIS_ColoredShape)::DownCast (getItem()->GetObject()); +} diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.hxx new file mode 100644 index 0000000000..c8b65317e0 --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.hxx @@ -0,0 +1,53 @@ +// Created on: 2019-04-14 +// 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 VInspectorPaneAIS_ColoredShape_H +#define VInspectorPaneAIS_ColoredShape_H + +#include +#include +#include + +class AIS_ColoredShape; + +//! \class VInspectorPaneAIS_ColoredShape +//! Item presents information about AIS_InteractiveObject. +//! Parent is item context, children are item selections. +class VInspectorPaneAIS_ColoredShape : public TreeModel_ItemProperties +{ +public: + //! Constructor + VInspectorPaneAIS_ColoredShape (const TreeModel_ItemBasePtr& theItem) : TreeModel_ItemProperties (theItem) {} + + //! Destructor + ~VInspectorPaneAIS_ColoredShape() {} + + //! Returns number of item children + //! \return an integer value, ZERO by default + Standard_EXPORT virtual int ChildItemCount() const Standard_OVERRIDE; + + //! Creates a child item in the given position. + //! \param theRow the child row position + //! \param theColumn the child column position + //! \return the created item + Standard_EXPORT virtual TreeModel_ItemBasePtr CreateChildItem (int theRow, int theColumn) const Standard_OVERRIDE; + +protected: + //! Converts transient object to custom presentation type + //! \return custom presentation + Handle(AIS_ColoredShape) GetPresentation() const; +}; + +#endif diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.cxx new file mode 100644 index 0000000000..fe0fd50dc4 --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.cxx @@ -0,0 +1,115 @@ +// Created on: 2018-08-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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 + +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= + +void VInspectorPaneAIS_ItemPrs3dDrawer::Init() +{ + Handle(Prs3d_Drawer) aDrawer; + TCollection_AsciiString aName; + VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast(Parent()); + if (!aParentItem) + { + VInspector_ItemPrs3dDrawer::Init(); + return; + } + + Handle(AIS_ColoredShape) aPrs = Handle(AIS_ColoredShape)::DownCast (aParentItem->GetInteractiveObject()); + const AIS_DataMapOfShapeDrawer& anAspectsMap = aPrs->CustomAspectsMap(); + + int aRowId = Row(); + int anItemRows = TreeModel_ItemBase::RowCountWithoutProperties (aParentItem); + int aCurrentRow = anItemRows; + for (AIS_DataMapOfShapeDrawer::Iterator anIter (anAspectsMap); anIter.More(); anIter.Next(), aCurrentRow++) + { + if (aRowId != aCurrentRow) + continue; + + aDrawer = anIter.Value(); + break; + } + aName = aDrawer.IsNull() ? "NULL" : (TCollection_AsciiString(aDrawer->DynamicType()->Name()) + "_" + (aRowId - anItemRows)); + setDrawer (aDrawer, aName); + TreeModel_ItemBase::Init(); // to use getIO() without circling initialization +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= + +void VInspectorPaneAIS_ItemPrs3dDrawer::Reset() +{ + VInspector_ItemPrs3dDrawer::Reset(); + + myShape = TopoDS_Shape(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= + +void VInspectorPaneAIS_ItemPrs3dDrawer::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +int VInspectorPaneAIS_ItemPrs3dDrawer::GetTableRowCount() const +{ + Handle(Prs3d_Drawer) aDrawer = GetDrawer(); + if (aDrawer.IsNull()) + return 0; + + return 1 + VInspector_ItemPrs3dDrawer::GetTableRowCount(); +} + +// ======================================================================= +// function : GetTableData +// purpose : +// ======================================================================= +QVariant VInspectorPaneAIS_ItemPrs3dDrawer::GetTableData (const int theRow, const int theColumn, const int theRole) const +{ + Handle(Prs3d_Drawer) aDrawer = GetDrawer(); + if (aDrawer.IsNull()) + return QVariant(); + + if (theRow == 0) + { + if (theRole == Qt::DisplayRole) + return theColumn == 0 ? QVariant ("TopoDS_Shape") : QVariant(); + else + return QVariant(); + } + + return VInspector_ItemPrs3dDrawer::GetTableData (theRow, theColumn, theRole); +} + diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.hxx new file mode 100644 index 0000000000..d0fbf64c2b --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.hxx @@ -0,0 +1,79 @@ +// Created on: 2018-08-10 +// Created by: Natalia ERMOLAEVA +// Copyright (c) 2017 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 VInspectorPaneAIS_ItemPrs3dDrawer_H +#define VInspectorPaneAIS_ItemPrs3dDrawer_H + +#include +#include +#include + +#include + +class Prs3d_BasicAspect; +class QItemSelectionModel; + +class VInspectorPaneAIS_ItemPrs3dDrawer; +typedef QExplicitlySharedDataPointer VInspectorPaneAIS_ItemPrs3dDrawerPtr; + +//! \class VInspectorPaneAIS_ItemPrs3dDrawer +//! Item presents information about AIS_InteractiveObject. +//! Parent is item context, children are item selections. +class VInspectorPaneAIS_ItemPrs3dDrawer : public VInspector_ItemPrs3dDrawer +{ + +public: + + //! Creates an item wrapped by a shared pointer + static VInspectorPaneAIS_ItemPrs3dDrawerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + { return VInspectorPaneAIS_ItemPrs3dDrawerPtr (new VInspectorPaneAIS_ItemPrs3dDrawer (theParent, theRow, theColumn)); } + //! Destructor + virtual ~VInspectorPaneAIS_ItemPrs3dDrawer() Standard_OVERRIDE {}; + + //! 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 is empty because Reset() is also empty. + virtual void initItem() const Standard_OVERRIDE; + +private: + + //! Constructor + //! param theParent a parent item + VInspectorPaneAIS_ItemPrs3dDrawer (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) + : VInspector_ItemPrs3dDrawer (theParent, theRow, theColumn) {} + +protected: + + TopoDS_Shape myShape; //!< current shape + + friend class VInspectorPaneAIS_ColoredShape; +}; + +#endif diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.cxx new file mode 100644 index 0000000000..cee0808a87 --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.cxx @@ -0,0 +1,38 @@ +// Created on: 2019-04-14 +// 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 + +IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +// ======================================================================= +// function : GetProperties +// purpose : +// ======================================================================= +TreeModel_ItemProperties* VInspectorPaneAIS_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem) +{ + Handle(Standard_Transient) anObject = theItem->GetObject(); + if (anObject.IsNull()) + return NULL; + + if (!Handle(AIS_ColoredShape)::DownCast (anObject).IsNull()) + return new VInspectorPaneAIS_ColoredShape (theItem); + + return NULL; +} + diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx new file mode 100644 index 0000000000..a4f8e6e13e --- /dev/null +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx @@ -0,0 +1,53 @@ +// Created on: 2019-04-14 +// 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 VInspectorPaneAIS_PropertiesCreator_H +#define VInspectorPaneAIS_PropertiesCreator_H + +#include +#include + +#include +#include + +#include +#include + +DEFINE_STANDARD_HANDLE (VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +//! \class VInspectorPaneAIS_PropertiesCreator +//! \brief An interface to create custom panes by transient object name. +class VInspectorPaneAIS_PropertiesCreator : public TreeModel_ItemPropertiesCreator +{ +public: + + //! Constructor + VInspectorPaneAIS_PropertiesCreator() {} + + //! Destructor + virtual ~VInspectorPaneAIS_PropertiesCreator() {} + + //! Returns pane for the name, creates a new pane if it does not exist and possible to create + //! \param theName type of the pane + //! \return a pane instance or NULL + virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator) + +private: + NCollection_DataMap myPanes; //!< created panes +}; + +#endif diff --git a/tools/ViewControl/FILES b/tools/ViewControl/FILES index 8efb5920cb..7ccc28b096 100644 --- a/tools/ViewControl/FILES +++ b/tools/ViewControl/FILES @@ -22,4 +22,6 @@ ViewControl_TableModelValuesDefault.cxx ViewControl_TableModelValuesDefault.hxx ViewControl_Tools.cxx ViewControl_Tools.hxx +ViewControl_TransientShape.cxx +ViewControl_TransientShape.hxx ViewControl_TreeView.hxx diff --git a/tools/ViewControl/ViewControl_TransientShape.cxx b/tools/ViewControl/ViewControl_TransientShape.cxx new file mode 100644 index 0000000000..fc537b0d81 --- /dev/null +++ b/tools/ViewControl/ViewControl_TransientShape.cxx @@ -0,0 +1,18 @@ +// Created on: 2019-04-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 + +IMPLEMENT_STANDARD_RTTIEXT(ViewControl_TransientShape, Standard_Transient) diff --git a/tools/ViewControl/ViewControl_TransientShape.hxx b/tools/ViewControl/ViewControl_TransientShape.hxx new file mode 100644 index 0000000000..5b28f7cc99 --- /dev/null +++ b/tools/ViewControl/ViewControl_TransientShape.hxx @@ -0,0 +1,53 @@ +// Created on: 2019-04-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 ViewControl_TransientShape_H +#define ViewControl_TransientShape_H + +#include +#include +#include +#include +#include + +#include + +DEFINE_STANDARD_HANDLE (ViewControl_TransientShape, Standard_Transient) + +//! \class ViewControl_TransientShape +//! \brief An interface to create custom panes by transient object name. +class ViewControl_TransientShape : public Standard_Transient +{ +public: + + //! Constructor + ViewControl_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); } + + //! Destructor + virtual ~ViewControl_TransientShape() {} + + //! Fills current shape + void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; } + + //! Returns current shape + const TopoDS_Shape GetShape() const { return myShape; } + + DEFINE_STANDARD_RTTIEXT (ViewControl_TransientShape, Standard_Transient) + +private: + TopoDS_Shape myShape; +}; + +#endif