]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin
authornds <nds@opencascade.com>
Wed, 17 Apr 2019 06:56:47 +0000 (09:56 +0300)
committernds <nds@opencascade.com>
Wed, 17 Apr 2019 06:56:47 +0000 (09:56 +0300)
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

32 files changed:
tools/MessageModel/MessageModel_ItemReportProperties.cxx
tools/MessageModel/MessageModel_ItemReportProperties.hxx
tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx
tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx
tools/ShapeView/ShapeView_ItemPropertiesFace.cxx
tools/ShapeView/ShapeView_ItemPropertiesFace.hxx
tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx
tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx
tools/ShapeView/ShapeView_Tools.cxx
tools/TreeModel/FILES
tools/TreeModel/TreeModel_ItemBase.cxx
tools/TreeModel/TreeModel_ItemBase.hxx
tools/TreeModel/TreeModel_ItemProperties.hxx
tools/TreeModel/TreeModel_ItemPropertiesCreator.cxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemPropertiesCreator.hxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ModelBase.cxx
tools/TreeModel/TreeModel_ModelBase.hxx
tools/VInspector/VInspector_ItemBase.hxx
tools/VInspector/VInspector_ItemPrs3dDrawer.cxx
tools/VInspector/VInspector_ItemPrs3dDrawer.hxx
tools/VInspector/VInspector_TableModelValues.cxx
tools/VInspector/VInspector_Window.cxx
tools/VInspectorPaneAIS/FILES
tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.cxx [new file with mode: 0644]
tools/VInspectorPaneAIS/VInspectorPaneAIS_ColoredShape.hxx [new file with mode: 0644]
tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.cxx [new file with mode: 0644]
tools/VInspectorPaneAIS/VInspectorPaneAIS_ItemPrs3dDrawer.hxx [new file with mode: 0644]
tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.cxx [new file with mode: 0644]
tools/VInspectorPaneAIS/VInspectorPaneAIS_PropertiesCreator.hxx [new file with mode: 0644]
tools/ViewControl/FILES
tools/ViewControl/ViewControl_TransientShape.cxx [new file with mode: 0644]
tools/ViewControl/ViewControl_TransientShape.hxx [new file with mode: 0644]

index f1337a454530d8ee85e21a36430ff7c05b78e5ce..4538856399ab96fa48ffca94fbc9179cf8242a9f 100644 (file)
@@ -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<MessageModel_ItemReport>(myItem);
+  MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(getItem());
   if (!aReportItem)
     return NULL;
 
index 65e159277241772c5981ab3c5c1b85bd4d8ff8ee..2970397b9fef10160a3464bb6eed4dd57f064592 100644 (file)
@@ -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
index efe135542bdaed5aa119a57f584105c074f6e689..b60235f0b1d5595f0f9190705d723777c5c114c7 100644 (file)
@@ -55,6 +55,9 @@ int ShapeView_ItemPropertiesEdge::GetTableRowCount() const
 // function : Data
 // purpose :
 // =======================================================================
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
 
 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<const BRep_TEdge*>(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<const BRep_PolygonOnTriangulation*>(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<ShapeView_ItemShape>(myItem);
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
   if (!aShapeItem)
     return TopoDS_Shape();
 
index 4b0e5996cc269c265431e9e9de6041b2ae71d6d1..a01d74fc17d6d755c031b41340752944d0e83920 100644 (file)
@@ -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
index 46a7bc0ceaf1273d3c609bebe185e3a048a5e1d4..b1c9852437eca42285e895e23e7703a8db21dfde 100644 (file)
@@ -58,7 +58,7 @@ QVariant ShapeView_ItemPropertiesFace::GetTableData (const int theRow, const int
 
 TopoDS_Shape ShapeView_ItemPropertiesFace::getItemShape() const
 {
-  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(myItem);
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
   if (!aShapeItem)
     return TopoDS_Shape();
 
index 840abe40d0a3fdeadeedef4e446c46e199d148a7..6ed1d2d7b6e820ae5d3babc019d41a508d119903 100644 (file)
@@ -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
index 63d80a2f9f7ae7a5e205a4057fa32a340864026f..bcfa01d090bdaf0856ceef586f6a531dafedb4d5 100644 (file)
@@ -66,7 +66,7 @@ QVariant ShapeView_ItemPropertiesVertex::GetTableData (const int theRow, const i
 
 TopoDS_Shape ShapeView_ItemPropertiesVertex::getItemShape() const
 {
-  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(myItem);
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(getItem());
   if (!aShapeItem)
     return TopoDS_Shape();
 
index 883eb6b447028ff74b4a1779bef318afafcb1f96..79a4965a9590b848c0d38506b6768ae7d17c2eb5 100644 (file)
@@ -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
index 56fe491b82e8b12cbab38a800d5cc1913a9dbb29..6f5addf555bdc829bd93eebb3a1be69a7f3e817d 100644 (file)
@@ -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
index 7bd7cdf3dfa6934cf46e3e49e02d4f9364798ec6..d7662e6a0e8dd634ca762c6950484adea46360a5 100644 (file)
@@ -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
index 464a788863675647b0713ff597f230ed15626299..703414f403266a409092a5895c0fd2058e0762d7 100644 (file)
@@ -14,7 +14,7 @@
 // commercial license or contractual agreement. 
 
 #include <inspector/TreeModel_ItemBase.hxx>
-
+#include <inspector/TreeModel_ItemProperties.hxx>
 #include <inspector/TreeModel_ItemRole.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -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<TreeModel_ItemBase*>(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<TreeModel_ItemBase*>(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();
+}
index b6c5e5668b8b390710e42d6d86ab7dc44d9fc57b..b7f3f7b634557bcd6b5c282ec414e0e323f73b65 100644 (file)
@@ -18,8 +18,8 @@
 
 #include <Standard.hxx>
 #include <Standard_Macro.hxx>
+#include <Standard_Handle.hxx>
 #include <inspector/TreeModel_ItemRole.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QExplicitlySharedDataPointer>
@@ -33,6 +33,7 @@
 #include <Standard_WarningsRestore.hxx>
 
 class TreeModel_ItemBase;
+class TreeModel_ItemProperties;
 
 typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> 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:
 
index 9364ac487e6b8a7eaa0326291d75ec20472f6b76..d096f71394b2280c7fae62043a53d59e12ba0b7f 100644 (file)
@@ -22,6 +22,9 @@
 #include <Standard_Type.hxx>
 #include <Standard_Transient.hxx>
 
+#include <NCollection_List.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
 #include <inspector/ViewControl_EditType.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -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<QVariant> GetTableEnumValues (const int theRow, const int theColumn) const
     { (void)theRow; (void)theColumn; return QList<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
   //! \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<Handle(Standard_Transient)>& 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 (file)
index 0000000..c5ae48d
--- /dev/null
@@ -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 <inspector/TreeModel_ItemPropertiesCreator.hxx>
+
+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 (file)
index 0000000..7e51e6c
--- /dev/null
@@ -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 <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+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 
index 2840fc829d33b53c4214b644d8b7dac27e9fe94d..1b07852a4541f9dd4966712f922201ddedd00bcc 100644 (file)
 #include <inspector/TreeModel_ModelBase.hxx>
 
 #include <inspector/TreeModel_ItemBase.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 #include <inspector/TreeModel_VisibilityState.hxx>
 
+#include <Standard_Transient.hxx>
+
 #include <Standard_WarningsDisable.hxx>
 #include <QIcon>
 #include <Standard_WarningsRestore.hxx>
@@ -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<Handle(TreeModel_ItemPropertiesCreator)>::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<Handle(TreeModel_ItemPropertiesCreator)>& TreeModel_ModelBase::GetPropertiesCreators() const
+{
+  return myPropertiesCreators;
+}
+
 // =======================================================================
 // function : GetSelected
 // purpose :
index b2eb8bc23b56b73be76e04040c0313f38707e3d3..2b83a0cf2bf05ef9a0d5ba3687d283dfb360e53f 100644 (file)
@@ -20,6 +20,8 @@
 #include <inspector/TreeModel_ItemBase.hxx>
 #include <inspector/TreeModel_HeaderSection.hxx>
 
+#include <NCollection_List.hxx>
+
 #include <Standard_WarningsDisable.hxx>
 #include <QAbstractItemModel>
 #include <QExplicitlySharedDataPointer>
@@ -29,6 +31,7 @@
 #include <QVector>
 #include <Standard_WarningsRestore.hxx>
 
+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<Handle(TreeModel_ItemPropertiesCreator)>& 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<Handle(TreeModel_ItemPropertiesCreator)> myPropertiesCreators; //!< property pane creators for items
 };
 
 #endif
index b5447aa3ec58d4daebc074d58d314b78ed54c4eb..674ea6418d1a3329c3b5e9be6bcae440ccfabd48 100644 (file)
@@ -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(); }
index eb341d941f715659fcc757dd6dc829e8730dfa7e..663a786b00aaff6cb66fc6116aa68687758717c2 100644 (file)
@@ -80,8 +80,8 @@ QVariant VInspector_ItemPrs3dDrawer::initValue (int theItemRole) const
 
 int VInspector_ItemPrs3dDrawer::initRowCount() const
 {
-  VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
-  if (!aParentItem)
+  VInspector_ItemPrs3dDrawerPtr aParentDrawerItem = itemDynamicCast<VInspector_ItemPrs3dDrawer>(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<VInspector_ItemFolderObject>(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"
index e597e005561e889aed750d13be1ff7e3161f82f9..8d971b057179b52323b0ecc7c0b22ef7647591e4 100644 (file)
@@ -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
index a94b4d5e1725f77e369e5bb87184d7db61d134be..79606ed7539afc1c96edf4fff01fff25dd74ed16 100644 (file)
@@ -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<Handle(ViewControl_PaneCreator)>::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<Handle(ViewControl_PaneCreator)>::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<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
   {
     Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
@@ -203,12 +246,25 @@ QList<QVariant> VInspector_TableModelValues::GetEnumValues (const int theRow, co
   if (theColumn != 1)
     return QList<QVariant>();
 
+  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<QVariant>();
+
   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<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
   {
     Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
@@ -230,7 +286,20 @@ QList<QVariant> VInspector_TableModelValues::GetEnumValues (const int theRow, co
 
 void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int theColumn, NCollection_List<TopoDS_Shape>& 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());
   }
index 48082d7cfe53d87e2b2ce22fd476ff2a52944c0c..8187ac7a17c30a935b0034591a210b3a2e74eca9 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <inspector/VInspector_Window.hxx>
 
+#include <AIS_ColoredShape.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_Trihedron.hxx>
 #include <BRep_Builder.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <TopoDS_Compound.hxx>
 
+#include <TopExp_Explorer.hxx>
+
 #include <inspector/TreeModel_ColumnType.hxx>
 #include <inspector/TreeModel_ContextMenu.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 
 #include <inspector/ViewControl_MessageDialog.hxx>
 #include <inspector/ViewControl_TableModel.hxx>
 #include <inspector/ViewControl_Tools.hxx>
+#include <inspector/ViewControl_TransientShape.hxx>
 
 #include <inspector/VInspector_ToolBar.hxx>
 #include <inspector/VInspector_Tools.hxx>
@@ -48,6 +53,7 @@
 #include <inspector/VInspector_ViewModelHistory.hxx>
 
 #include <inspector/VInspectorPaneAIS_PaneCreator.hxx>
+#include <inspector/VInspectorPaneAIS_PropertiesCreator.hxx>
 
 #include <inspector/ViewControl_PropertyView.hxx>
 #include <inspector/ViewControl_TreeView.hxx>
@@ -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<TopoDS_Shape> VInspector_Window::GetSelectedShapes (const QMode
   {
     TreeModel_ItemBasePtr anItem = *anItemIt;
     VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(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<TopoDS_Shape>& theShapes)
 {
   QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices);
+  NCollection_List<Handle(Standard_Transient)> aPropertyPresentations;
   for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
   {
     TreeModel_ItemBasePtr anItem = *anItemIt;
-    VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
-    if (!aVItem || aVItem->Column() != 0)
+    if (!anItem || anItem->Column() != 0)
       continue;
 
     QList<ViewControl_TableModelValues*> 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<VInspector_TableModelValues*>(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<Handle(Standard_Transient)>::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<Handle(Standard_Transient)>
       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<VInspector_ViewModel*>(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);
 
index 310e98b5ae4dfd98ae0480bb172d12120b4d5a1a..79a7145510fe00040aef3812914aa05a462525c4 100644 (file)
@@ -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 (file)
index 0000000..281e432
--- /dev/null
@@ -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 <inspector/VInspectorPaneAIS_ColoredShape.hxx>
+#include <inspector/VInspectorPaneAIS_ItemPrs3dDrawer.hxx>
+
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/VInspector_Tools.hxx>
+
+#include <AIS_ColoredShape.hxx>
+
+// =======================================================================
+// 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 (file)
index 0000000..c8b6531
--- /dev/null
@@ -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 <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
+
+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 (file)
index 0000000..fe0fd50
--- /dev/null
@@ -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 <inspector/VInspectorPaneAIS_ItemPrs3dDrawer.hxx>
+
+#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
+
+#include <AIS_ColoredShape.hxx>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+
+void VInspectorPaneAIS_ItemPrs3dDrawer::Init()
+{
+  Handle(Prs3d_Drawer) aDrawer;
+  TCollection_AsciiString aName;
+  VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(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<VInspectorPaneAIS_ItemPrs3dDrawer*>(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 (file)
index 0000000..d0fbf64
--- /dev/null
@@ -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 <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+#include <inspector/VInspector_ItemPrs3dDrawer.hxx>
+
+#include <TopoDS_Shape.hxx>
+
+class Prs3d_BasicAspect;
+class QItemSelectionModel;
+
+class VInspectorPaneAIS_ItemPrs3dDrawer;
+typedef QExplicitlySharedDataPointer<VInspectorPaneAIS_ItemPrs3dDrawer> 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: <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 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 (file)
index 0000000..cee0808
--- /dev/null
@@ -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 <inspector/VInspectorPaneAIS_PropertiesCreator.hxx>
+#include <inspector/VInspectorPaneAIS_ColoredShape.hxx>
+
+#include <AIS_ColoredShape.hxx>
+
+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 (file)
index 0000000..a4f8e6e
--- /dev/null
@@ -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 <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
+#include <inspector/ViewControl_Pane.hxx>
+
+#include <NCollection_DataMap.hxx>
+#include <TCollection_AsciiString.hxx>
+
+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<TCollection_AsciiString, ViewControl_Pane*> myPanes; //!< created panes
+};
+
+#endif 
index 8efb5920cb9a3ad7d6d25bbebc749fdf3b7ffa35..7ccc28b096787442b673cf99001c2a60e8e6f588 100644 (file)
@@ -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 (file)
index 0000000..fc537b0
--- /dev/null
@@ -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 <inspector/ViewControl_TransientShape.hxx>
+
+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 (file)
index 0000000..5b28f7c
--- /dev/null
@@ -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 <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+#include <TopoDS_Shape.hxx>
+
+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