]> OCCT Git - occt-copy.git/commitdiff
0030517: Inspectors - improvements in ShapeView plugin
authornds <nds@opencascade.com>
Mon, 25 Feb 2019 09:12:44 +0000 (12:12 +0300)
committernds <nds@opencascade.com>
Mon, 25 Feb 2019 12:16:02 +0000 (15:16 +0300)
- implement "Explode" context menu action on a shape item in tree view. Calling this action cases build of the item subtree using TopExp::MapShapes by the type. (By default the tree generating uses TopoDS_Iterator)
- display properties of a selected tree item in Property Panel. (Similar to DFBrowser plugin).

(cherry picked from commit 2b4094183df26dfe0dae62f63822d7bf6d2214c6)

16 files changed:
tools/ShapeView/FILES
tools/ShapeView/ShapeView_ItemBase.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemBase.hxx
tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemPropertiesFace.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemPropertiesFace.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemPropertiesVertex.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemShape.cxx
tools/ShapeView/ShapeView_ItemShape.hxx
tools/ShapeView/ShapeView_Tools.cxx
tools/ShapeView/ShapeView_Tools.hxx
tools/ShapeView/ShapeView_TreeModel.cxx
tools/ShapeView/ShapeView_Window.cxx
tools/ShapeView/ShapeView_Window.hxx

index 895416efc17dab4fce982050472c0fc1aba565a0..6f3384957e228ab42c4c9e8960c2c67b81a636e6 100644 (file)
@@ -1,7 +1,14 @@
 ShapeView.qrc
 ShapeView_Communicator.cxx
 ShapeView_Communicator.hxx
+ShapeView_ItemBase.cxx
 ShapeView_ItemBase.hxx
+ShapeView_ItemPropertiesEdge.cxx
+ShapeView_ItemPropertiesEdge.hxx
+ShapeView_ItemPropertiesFace.cxx
+ShapeView_ItemPropertiesFace.hxx
+ShapeView_ItemPropertiesVertex.cxx
+ShapeView_ItemPropertiesVertex.hxx
 ShapeView_ItemRoot.cxx
 ShapeView_ItemRoot.hxx
 ShapeView_ItemShape.cxx
diff --git a/tools/ShapeView/ShapeView_ItemBase.cxx b/tools/ShapeView/ShapeView_ItemBase.cxx
new file mode 100644 (file)
index 0000000..c660eab
--- /dev/null
@@ -0,0 +1,35 @@
+// Created on: 2017-06-16
+// 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/ShapeView_ItemBase.hxx>
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant ShapeView_ItemBase::initValue (const int theItemRole) const
+{
+  if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
+    return QVariant();
+
+  switch (Column())
+  {
+    case 2: { return rowCount(); }
+    //case 3: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
+    case 4: { return Row(); }
+  }
+
+  return QVariant();
+}
index 3e0559c50192ccc24960ec0d3a7efa2c32acdefc..27b09eb925ddf2bdf09d2ecf6c6ff00ba7b203f9 100644 (file)
@@ -32,6 +32,11 @@ public:
   //! Resets cached values
   virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
 
+  //! Return data value for the role.
+  //! \param theRole a value role
+  //! \return the value
+  Standard_EXPORT virtual QVariant initValue(const int theRole) const;
+
 protected:
 
   //! Initialize the current item. It creates a backup of the specific item information
diff --git a/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx b/tools/ShapeView/ShapeView_ItemPropertiesEdge.cxx
new file mode 100644 (file)
index 0000000..efe1355
--- /dev/null
@@ -0,0 +1,110 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#include <inspector/ShapeView_ItemPropertiesEdge.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
+#include <inspector/ShapeView_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <Adaptor3d_Curve.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <GCPnts_AbscissaPoint.hxx>
+
+#include <Geom_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int ShapeView_ItemPropertiesEdge::GetTableRowCount() const
+{
+  return ShapeView_Tools::GetShapeGlobalPropertiesCount() + 7;
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+
+QVariant ShapeView_ItemPropertiesEdge::GetTableData (const int theRow, const int theColumn, int theRole) const
+{
+  if (theRole != Qt::DisplayRole)
+    return QVariant();
+
+  TopoDS_Shape aShape = getItemShape();
+
+  if (aShape.ShapeType() != TopAbs_EDGE)
+    return QVariant();
+
+  TopoDS_Edge anEdge = TopoDS::Edge(aShape);
+  double aFirst, aLast;
+  Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
+
+  GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
+  gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
+  gp_Pnt aLastPnt = aAdaptor.Value(aLast);
+
+  BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
+  Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
+
+  bool isFirstColumn = theColumn == 0;
+  switch (theRow)
+  {
+    case 0:  return isFirstColumn ? "Length" : QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
+    case 1:  return isFirstColumn ? "Geom_Curve" : aCurve->DynamicType()->Name();
+    case 2:  return isFirstColumn ? "FirstPnt" : ViewControl_Tools::ToString (aFirstPnt).ToCString();
+    case 3:  return isFirstColumn ? "LastPnt" : ViewControl_Tools::ToString (aLastPnt).ToCString();
+    case 4: return isFirstColumn ? "Continuity" : ShapeView_Tools::ToName (aCurve->Continuity());
+    case 5: return isFirstColumn ? "IsClosed" : ShapeView_Tools::ToString (aCurve->IsClosed());
+    case 6: return isFirstColumn ? "IsPeriodic" :  aCurve->IsPeriodic() ? QString::number (aCurve->Period())
+                                                                        : ShapeView_Tools::ToString (aCurve->IsPeriodic());
+    default: break;
+  }
+  int anOwnRows = 7;
+
+  return ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow - anOwnRows, theColumn);
+}
+
+// =======================================================================
+// function : getItemShape
+// purpose :
+// =======================================================================
+
+TopoDS_Shape ShapeView_ItemPropertiesEdge::getItemShape() const
+{
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(myItem);
+  if (!aShapeItem)
+    return TopoDS_Shape();
+
+  return aShapeItem->GetItemShape();
+}
diff --git a/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx b/tools/ShapeView/ShapeView_ItemPropertiesEdge.hxx
new file mode 100644 (file)
index 0000000..4b0e599
--- /dev/null
@@ -0,0 +1,75 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#ifndef ShapeView_ItemPropertiesEdge_H
+#define ShapeView_ItemPropertiesEdge_H
+
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+class QItemDelegate;
+
+DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
+
+//! \class ShapeView_ItemPropertiesEdge
+//! \brief This is an interace for ViewControl_TableModel to give real values of the model
+//! It should be filled or redefined.
+class ShapeView_ItemPropertiesEdge : public TreeModel_ItemProperties
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT ShapeView_ItemPropertiesEdge (TreeModel_ItemBasePtr theItem)
+    : TreeModel_ItemProperties(), myItem (theItem) {}
+
+  //! Destructor
+  virtual ~ShapeView_ItemPropertiesEdge() {}
+
+  //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+  //! Returns content of the model index for the given role, it is obtained from internal container of values
+  //! It returns value only for DisplayRole.
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesEdge, TreeModel_ItemProperties)
+
+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
new file mode 100644 (file)
index 0000000..46a7bc0
--- /dev/null
@@ -0,0 +1,66 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#include <inspector/ShapeView_ItemPropertiesFace.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
+#include <inspector/ShapeView_Tools.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int ShapeView_ItemPropertiesFace::GetTableRowCount() const
+{
+  return ShapeView_Tools::GetShapeGlobalPropertiesCount();
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+
+QVariant ShapeView_ItemPropertiesFace::GetTableData (const int theRow, const int theColumn, int theRole) const
+{
+  if (theRole != Qt::DisplayRole)
+    return QVariant();
+
+  TopoDS_Shape aShape = getItemShape();
+
+  QVariant aValue = ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow, theColumn);
+
+  return aValue;
+}
+
+// =======================================================================
+// function : getItemShape
+// purpose :
+// =======================================================================
+
+TopoDS_Shape ShapeView_ItemPropertiesFace::getItemShape() const
+{
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(myItem);
+  if (!aShapeItem)
+    return TopoDS_Shape();
+
+  return aShapeItem->GetItemShape();
+}
diff --git a/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx b/tools/ShapeView/ShapeView_ItemPropertiesFace.hxx
new file mode 100644 (file)
index 0000000..840abe4
--- /dev/null
@@ -0,0 +1,75 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#ifndef ShapeView_ItemPropertiesFace_H
+#define ShapeView_ItemPropertiesFace_H
+
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+class QItemDelegate;
+
+DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
+
+//! \class ShapeView_ItemPropertiesFace
+//! \brief This is an interace for ViewControl_TableModel to give real values of the model
+//! It should be filled or redefined.
+class ShapeView_ItemPropertiesFace : public TreeModel_ItemProperties
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT ShapeView_ItemPropertiesFace (TreeModel_ItemBasePtr theItem)
+    : TreeModel_ItemProperties(), myItem (theItem) {}
+
+  //! Destructor
+  virtual ~ShapeView_ItemPropertiesFace() {}
+
+  //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+  //! Returns content of the model index for the given role, it is obtained from internal container of values
+  //! It returns value only for DisplayRole.
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesFace, TreeModel_ItemProperties)
+
+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
new file mode 100644 (file)
index 0000000..63d80a2
--- /dev/null
@@ -0,0 +1,74 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#include <inspector/ShapeView_ItemPropertiesVertex.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
+#include <inspector/ShapeView_Tools.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int ShapeView_ItemPropertiesVertex::GetTableRowCount() const
+{
+  return ShapeView_Tools::GetShapeGlobalPropertiesCount() + 1;
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+
+QVariant ShapeView_ItemPropertiesVertex::GetTableData (const int theRow, const int theColumn, int theRole) const
+{
+  if (theRole != Qt::DisplayRole)
+    return QVariant();
+
+  TopoDS_Shape aShape = getItemShape();
+  switch (theRow)
+  {
+    case 0:  return theColumn == 0 ? "Vertex" : ViewControl_Tools::ToString (BRep_Tool::Pnt (TopoDS::Vertex (aShape))).ToCString();
+    default: break;
+  }
+  int anOwnRows = 1;
+
+  return ShapeView_Tools::GetShapeGlobalProperties (aShape, theRow - anOwnRows, theColumn);
+}
+
+// =======================================================================
+// function : getItemShape
+// purpose :
+// =======================================================================
+
+TopoDS_Shape ShapeView_ItemPropertiesVertex::getItemShape() const
+{
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(myItem);
+  if (!aShapeItem)
+    return TopoDS_Shape();
+
+  return aShapeItem->GetItemShape();
+}
diff --git a/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx b/tools/ShapeView/ShapeView_ItemPropertiesVertex.hxx
new file mode 100644 (file)
index 0000000..883eb6b
--- /dev/null
@@ -0,0 +1,75 @@
+// Created on: 2019-02-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#ifndef ShapeView_ItemPropertiesVertex_H
+#define ShapeView_ItemPropertiesVertex_H
+
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+class QItemDelegate;
+
+DEFINE_STANDARD_HANDLE (ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
+
+//! \class ShapeView_ItemPropertiesVertex
+//! \brief This is an interace for ViewControl_TableModel to give real values of the model
+//! It should be filled or redefined.
+class ShapeView_ItemPropertiesVertex : public TreeModel_ItemProperties
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT ShapeView_ItemPropertiesVertex (TreeModel_ItemBasePtr theItem)
+    : TreeModel_ItemProperties(), myItem (theItem) {}
+
+  //! Destructor
+  virtual ~ShapeView_ItemPropertiesVertex() {}
+
+  //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+  //! Returns content of the model index for the given role, it is obtained from internal container of values
+  //! It returns value only for DisplayRole.
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+  DEFINE_STANDARD_RTTIEXT (ShapeView_ItemPropertiesVertex, TreeModel_ItemProperties)
+
+protected:
+  //! Returns item shape
+  TopoDS_Shape getItemShape() const;
+
+protected:
+
+  TreeModel_ItemBasePtr myItem; //!< source item base
+};
+
+#endif
index 9f98f03b69ab1e2a1b30e5adb58766dcdecc053d..e82fa9a9b613893db6d8b5f234f910e14f6f125e 100644 (file)
 
 #include <inspector/ShapeView_ItemShape.hxx>
 
-#include <Adaptor3d_Curve.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Curve.hxx>
-
-#include <GCPnts_AbscissaPoint.hxx>
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-
 #include <inspector/ShapeView_ItemRoot.hxx>
 #include <inspector/ShapeView_ItemShape.hxx>
+#include <inspector/ShapeView_ItemPropertiesEdge.hxx>
+#include <inspector/ShapeView_ItemPropertiesFace.hxx>
+#include <inspector/ShapeView_ItemPropertiesVertex.hxx>
+
 #include <inspector/ViewControl_Tools.hxx>
+
+#include <TopAbs.hxx>
 #include <TCollection_AsciiString.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Edge.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <TopoDS_Vertex.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QObject>
 #include <Standard_WarningsRestore.hxx>
 
 // =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-QString ToString (const Standard_Boolean& theValue)
-{
-  return theValue ? "1" : "0";
-}
-
-// =======================================================================
-// function : ToString
-// purpose :
-// =======================================================================
-QString ToString (const gp_Pnt& thePoint)
-{
-  return QString ("(%1, %2, %3)").arg (thePoint.X()).arg (thePoint.Y()).arg (thePoint.Z());
-}
-
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-QString ToName (const TopAbs_ShapeEnum& theShapeType)
-{
-  Standard_SStream aSStream;
-  TopAbs::Print (theShapeType, aSStream);
-  return QString (aSStream.str().c_str());
-}
-
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-QString ToName (const TopAbs_Orientation& theOrientation)
-{
-  Standard_SStream aSStream;
-  TopAbs::Print(theOrientation, aSStream);
-  return QString (aSStream.str().c_str());
-}
-
-// =======================================================================
-// function : ToName
+// function : GetShape
 // purpose :
 // =======================================================================
-QString ToName (const GeomAbs_Shape& theType)
+TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
 {
-  switch (theType)
+  if (myChildShapes.IsEmpty())
   {
-    case GeomAbs_C0: return "GeomAbs_C0";
-    case GeomAbs_G1: return "GeomAbs_G1";
-    case GeomAbs_C1: return "GeomAbs_C1";
-    case GeomAbs_G2: return "GeomAbs_G2";
-    case GeomAbs_C2: return "GeomAbs_C2";
-    case GeomAbs_C3: return "GeomAbs_C3";
-    case GeomAbs_CN: return "GeomAbs_CN";
-    default: break;
-  }
-  return QString();
-}
+    ShapeView_ItemShape* aThis = (ShapeView_ItemShape*)this;
 
-// =======================================================================
-// function : ToOtherInfo
-// purpose :
-// =======================================================================
-void ToOtherInfo (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
-{
-  switch (theShape.ShapeType())
-  {
-    case TopAbs_COMPOUND:
-    case TopAbs_COMPSOLID:
-    case TopAbs_SOLID:
-    case TopAbs_SHELL:
-    case TopAbs_FACE:
-    case TopAbs_WIRE:
-      break;
-    case TopAbs_EDGE:
+    if (myExplodeType != TopAbs_SHAPE)
     {
-      TopoDS_Edge anEdge = TopoDS::Edge(theShape);
-      double aFirst, aLast;
-      Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-
-      GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
-      gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
-      gp_Pnt aLastPnt = aAdaptor.Value(aLast);
-
-      BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
-      Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
-
-      QStringList aValues, anInfo;
-      aValues.append (QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d)));
-      anInfo.append ("Length");
-
-      aValues.append (aCurve->DynamicType()->Name());
-      anInfo.append ("DynamicType");
-
-      aValues.append (ToString (aFirstPnt));
-      anInfo.append (QString ("First" + QString::number (aFirst)));
-
-      aValues.append (ToString (aLastPnt));
-      anInfo.append (QString ("Last" + QString::number (aLast)));
-
-      aValues.append (ToName (aCurve->Continuity()));
-      anInfo.append ("Continuity");
-
-      aValues.append (ToString (aCurve->IsClosed()));
-      anInfo.append ("IsClosed");
-
-      if (aCurve->IsPeriodic()) {
-        aValues.append (QString::number (aCurve->Period()));
-        anInfo.append ("IsPeriodic");
-      }
-      else
+      TopExp::MapShapes(myShape, myExplodeType, aThis->myChildShapes);
+    }
+    else
+    {
+      TopoDS_Iterator aSubShapeIt (myShape);
+      for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
       {
-        aValues.append (ToString (aCurve->IsPeriodic()));
-        anInfo.append ("IsPeriodic");
+        aThis->myChildShapes.Add (aSubShapeIt.Value());
       }
-      theValue = aValues.join (" / ");
-      theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
-      break;
     }
-    case TopAbs_SHAPE:
-    default:
-      break;
   }
-}
+  if (myChildShapes.Extent() >= theRowId + 1)
+    return myChildShapes(theRowId + 1);
 
-// =======================================================================
-// function : GetShape
-// purpose :
-// =======================================================================
-TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
-{
-  TopoDS_Iterator aSubShapeIt (myShape);
-  for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
-  {
-    if (aCurrentIndex != theRowId)
-      continue;
-    break;
-  }
-  return aSubShapeIt.Value();
+  return TopoDS_Shape();
 }
 
 // =======================================================================
@@ -185,6 +70,10 @@ TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
 // =======================================================================
 QVariant ShapeView_ItemShape::initValue(const int theRole) const
 {
+  QVariant aParentValue = ShapeView_ItemBase::initValue (theRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   TopoDS_Shape aShape = getShape();
   if (aShape.IsNull())
     return QVariant();
@@ -194,58 +83,11 @@ QVariant ShapeView_ItemShape::initValue(const int theRole) const
 
   switch (Column())
   {
-    case 0: return ToName (aShape.ShapeType());
-    case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
+    case 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
+    //case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
     case 3: return TShapePointer().ToCString();
-    case 4: return ToName(aShape.Orientation());
-    case 5: return ViewControl_Tools::ToString (aShape.Location()).ToCString();
-    case 6: return ToString (aShape.Checked());
-    case 7: return ToString (aShape.Closed());
-    case 8: return ToString (aShape.Infinite());
-    case 9: return ToString (aShape.Locked());
-    case 10: return ToString (aShape.Modified());
-    case 11: return ToString (aShape.Orientable());
-    case 12:
-    {
-      if (aShape.ShapeType() != TopAbs_VERTEX)
-        return QVariant();
-      TopoDS_Vertex aVertex = TopoDS::Vertex (aShape);
-      gp_Pnt aPoint = BRep_Tool::Pnt (aVertex);
-      return ToString (aPoint);
-    }
-    case 13:
-    case 14:
-    case 15:
-    case 16:
-    case 17:
-    case 18:
-    case 19:
-    {
-      if (aShape.ShapeType() != TopAbs_EDGE)
-        return QVariant();
-
-      TopoDS_Edge anEdge = TopoDS::Edge(aShape);
-      double aFirst, aLast;
-      Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-
-      GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
-      gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
-      gp_Pnt aLastPnt = aAdaptor.Value(aLast);
-
-      BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
-      Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
-
-      switch (Column())
-      {
-        case 13: return QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
-        case 14: return aCurve->DynamicType()->Name();
-        case 15: return ToString (aFirstPnt);
-        case 16: return ToString (aLastPnt);
-        case 17: return ToName (aCurve->Continuity());
-        case 18: return ToString (aCurve->IsClosed());
-        case 19: return aCurve->IsPeriodic() ? QString::number (aCurve->Period()) : ToString (aCurve->IsPeriodic());
-      }
-    }
+    case 5: return TopAbs::ShapeOrientationToString (aShape.Orientation());
+    case 6: return ViewControl_Tools::ToString (aShape.Location()).ToCString();
     default: break;
   }
   return QVariant();
@@ -262,8 +104,17 @@ int ShapeView_ItemShape::initRowCount() const
     return 0;
 
   int aRowsCount = 0;
-  for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
-    aRowsCount++;
+  if (myExplodeType != TopAbs_SHAPE)
+  {
+    TopTools_IndexedMapOfShape aSubShapes;
+    TopExp::MapShapes(aShape, myExplodeType, aSubShapes);
+    aRowsCount = aSubShapes.Extent();
+  }
+  else
+  {
+    for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
+      aRowsCount++;
+  }
   return aRowsCount;
 }
 
@@ -285,6 +136,8 @@ void ShapeView_ItemShape::Init()
   ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (Parent());
   ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape> (Parent());
   myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
+
+  SetProperties (createItemProperties());
 }
 
 // =======================================================================
@@ -328,6 +181,8 @@ TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standa
 void ShapeView_ItemShape::Reset()
 {
   myFileName = QString();
+  myChildShapes.Clear();
+  myShape = TopoDS_Shape();
 
   ShapeView_ItemBase::Reset();
 }
@@ -343,3 +198,29 @@ void ShapeView_ItemShape::initItem() const
   const_cast<ShapeView_ItemShape*>(this)->Init();
 }
 
+// =======================================================================
+// function : createItemProperties
+// purpose :
+// =======================================================================
+Handle(TreeModel_ItemProperties) ShapeView_ItemShape::createItemProperties() const
+{
+  if (myShape.IsNull())
+    return NULL;
+
+  TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false);
+
+  switch (myShape.ShapeType())
+  {
+    case TopAbs_COMPOUND:  break;
+    case TopAbs_COMPSOLID: break;
+    case TopAbs_SOLID:     break;
+    case TopAbs_SHELL:     break;
+    case TopAbs_FACE:      return new ShapeView_ItemPropertiesFace (anItem);
+    case TopAbs_WIRE:      break;
+    case TopAbs_EDGE:      return new ShapeView_ItemPropertiesEdge (anItem);
+    case TopAbs_VERTEX:    return new ShapeView_ItemPropertiesVertex (anItem);
+    case TopAbs_SHAPE:     break;
+    default: break;
+  }
+  return NULL;
+}
index b04076956e9b2fd502f1dae0ba80a33c21e09d24..ebae15fb36fd5b78543946f9561f43af5e5c885c 100644 (file)
 #define ShapeView_ItemShape_H
 
 #include <inspector/ShapeView_ItemBase.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+
 #include <Standard.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <TopAbs_ShapeEnum.hxx>
 #include <TopoDS_Shape.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -46,6 +50,13 @@ public:
   //! Destructor
   virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
 
+  //! Sets explore type
+  //! \param theType type of item explode. If TopAbs_SHAPE, no expode, only iteration by shape
+  void SetExplodeType (const TopAbs_ShapeEnum theType) { myExplodeType  = theType; }
+
+  //! Returns expode type of the item
+  TopAbs_ShapeEnum GetExplodeType() const { return myExplodeType; }
+
   //! Returns the current shape
   const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
 
@@ -105,16 +116,22 @@ protected:
   //! \return the string value
   static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
 
+  //! Creates container of item properties
+  Standard_EXPORT Handle(TreeModel_ItemProperties) createItemProperties() const;
+
 private:
 
   //! Constructor
-  ShapeView_ItemShape(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : ShapeView_ItemBase(theParent, theRow, theColumn) {}
+  ShapeView_ItemShape (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+    : ShapeView_ItemBase (theParent, theRow, theColumn), myExplodeType (TopAbs_SHAPE) {}
 
 private:
+  TopAbs_ShapeEnum myExplodeType; //!< type of explore own shape and get children
 
   TopoDS_Shape myShape; //!< current shape
   QString myFileName; //!< BREP file name
+
+  TopTools_IndexedMapOfShape myChildShapes; //! cached container of child shapes
 };
 
 #endif
index afa6de45718563efdfb15f4bebd8bd8e29eba020..56fe491b82e8b12cbab38a800d5cc1913a9dbb29 100644 (file)
 // commercial license or contractual agreement. 
 
 #include <inspector/ShapeView_Tools.hxx>
+#include <inspector/ShapeView_ItemShape.hxx>
+
 
-#include <BRep_Builder.hxx>
 #include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
-#include <AIS_Shape.hxx>
 // =======================================================================
 // function : ReadShape
 // purpose :
@@ -31,3 +39,108 @@ TopoDS_Shape ShapeView_Tools::ReadShape (const TCollection_AsciiString& theFileN
   BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
   return aShape;
 }
+
+// =======================================================================
+// function : IsPossibleToExplode
+// purpose :
+// =======================================================================
+Standard_Boolean ShapeView_Tools::IsPossibleToExplode (const TopoDS_Shape& theShape,
+  NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes)
+{
+  TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
+
+  if (!theExplodeTypes.Contains (aShapeType))
+    theExplodeTypes.Append(aShapeType);
+
+  if (theExplodeTypes.Extent() == TopAbs_SHAPE + 1) // all types are collected, stop
+    return Standard_True;
+
+  TopoDS_Iterator aSubShapeIt (theShape);
+  for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+  {
+    if (IsPossibleToExplode (aSubShapeIt.Value(), theExplodeTypes))
+      return Standard_True;
+  }
+  return Standard_False;
+}
+
+// =======================================================================
+// function : GetPropertyTableValues
+// purpose :
+// =======================================================================
+void ShapeView_Tools::GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
+                                              QList<ViewControl_TableModelValues*>& theTableValues)
+{
+  TreeModel_ItemBasePtr anItem = theItem;
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItem);
+  if (!aShapeItem)
+    return;
+
+  Handle(TreeModel_ItemProperties) anItemProperties = aShapeItem->GetProperties();
+  if (anItemProperties.IsNull())
+    return;
+
+  ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues();
+  aTableValues->SetProperties (anItemProperties);
+  theTableValues.append (aTableValues);
+}
+
+// =======================================================================
+// function : ToString
+// purpose :
+// =======================================================================
+QString ShapeView_Tools::ToString (const Standard_Boolean& theValue)
+{
+  return theValue ? "1" : "0";
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ShapeView_Tools::ToName (const GeomAbs_Shape& theType)
+{
+  switch (theType)
+  {
+    case GeomAbs_C0: return "GeomAbs_C0";
+    case GeomAbs_G1: return "GeomAbs_G1";
+    case GeomAbs_C1: return "GeomAbs_C1";
+    case GeomAbs_G2: return "GeomAbs_G2";
+    case GeomAbs_C2: return "GeomAbs_C2";
+    case GeomAbs_C3: return "GeomAbs_C3";
+    case GeomAbs_CN: return "GeomAbs_CN";
+    default: break;
+  }
+  return QString();
+}
+
+// =======================================================================
+// function : GetShapeGlobalPropertiesCount
+// purpose :
+// =======================================================================
+int ShapeView_Tools::GetShapeGlobalPropertiesCount()
+{
+  return 6;
+}
+
+// =======================================================================
+// function : GetShapeGlobalProperties
+// purpose :
+// =======================================================================
+QVariant ShapeView_Tools::GetShapeGlobalProperties (const TopoDS_Shape& theShape,
+                                                    const int theRow,
+                                                    const int theColumn)
+{
+  bool isFirstColumn = theColumn == 0;
+
+  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());
+  }
+  return QVariant();
+}
\ No newline at end of file
index a922e42b36b104819069c17081b4ad5410dbb040..dd12fc8e5699bf61230ac3ead3ab0b287cb28965 100644 (file)
 
 #include <Standard.hxx>
 
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <NCollection_List.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <Standard_Transient.hxx>
 #include <TopoDS_Shape.hxx>
 
+#include <inspector/ViewControl_TableModelValues.hxx>
+
+#include <GeomAbs_Shape.hxx>
+#include <Standard_WarningsDisable.hxx>
+#include <QList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
 //! \class ShapeView_Tools
 //! It gives auxiliary methods for TopoDS_Shape manipulation
 class ShapeView_Tools
@@ -32,6 +43,38 @@ public:
   //! \param theFileName a file name
   //! \return shape or NULL
   Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+
+  //! Checks whether it is possible to expode the shape. The search is recursive untill all types are collected.
+  //! \param theShape source shape object
+  //! \param theExplodeTypes container of possible shape types to be exploded
+  //! \return true if explode is finished, all types are collected.
+  Standard_EXPORT static Standard_Boolean IsPossibleToExplode(const TopoDS_Shape& theShape,
+    NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes);
+
+  //! Fills container of table values
+  //! \param theAlert a message alert
+  //! \param theTableValue container of values
+  Standard_EXPORT static void GetPropertyTableValues (const TreeModel_ItemBasePtr& theItem,
+                                                      QList<ViewControl_TableModelValues*>& theTableValues);
+
+  //! Returns count of gloal properties (6)
+  //! \return count value
+  Standard_EXPORT static int GetShapeGlobalPropertiesCount();
+
+  //! Returns shape global property by row/column
+  //! \param theShape investigated shape
+  //! \param theRow row index in [0, 6]
+  //! \param theColumn column index in [0, 1]
+  Standard_EXPORT static QVariant GetShapeGlobalProperties (const TopoDS_Shape& theShape,
+                                                            const int theRow,
+                                                            const int theColumn);
+
+  //! Returns text presentation of boolean value
+  Standard_EXPORT static QString ToString (const Standard_Boolean& theValue);
+
+  //! Returns shape type name
+  Standard_EXPORT static QString ToName (const GeomAbs_Shape& theType);
+
 };
 
 #endif
index bc29c119aecfe89c4b92797cdfad0909188abf1e..8b39f592cd032e5cfc2b7d6c35aac88f3503c52b 100644 (file)
@@ -38,25 +38,9 @@ ShapeView_TreeModel::ShapeView_TreeModel (QObject* theParent)
   // column 1 is reserved for visiblity state
   SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
   SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
-  SetHeaderItem (5, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
-
-  SetHeaderItem (6, TreeModel_HeaderSection ("Checked", -1, true));
-  SetHeaderItem (7, TreeModel_HeaderSection ("Closed", -1, true));
-  SetHeaderItem (8, TreeModel_HeaderSection ("Infinite", -1, true));
-  SetHeaderItem (9, TreeModel_HeaderSection ("Locked", -1, true));
-  SetHeaderItem (10, TreeModel_HeaderSection ("Modified", -1, true));
-  SetHeaderItem (11, TreeModel_HeaderSection ("Orientable", -1, true));
-
-  SetHeaderItem (12, TreeModel_HeaderSection ("VERTEX: (X, Y, Z)", -1, true));
-
-  SetHeaderItem (13, TreeModel_HeaderSection ("EDGE: Length", -1, true));
-  SetHeaderItem (14, TreeModel_HeaderSection ("DynamicType", -1, true));
-  SetHeaderItem (15, TreeModel_HeaderSection ("First", -1, true));
-  SetHeaderItem (16, TreeModel_HeaderSection ("Last", -1, true));
-  SetHeaderItem (17, TreeModel_HeaderSection ("Continuity", -1, true));
-  SetHeaderItem (18, TreeModel_HeaderSection ("IsClosed", -1, true));
-  SetHeaderItem (19, TreeModel_HeaderSection ("IsPeriodic", -1, true));
+  SetHeaderItem (4, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
+  SetHeaderItem (5, TreeModel_HeaderSection ("Orientation", COLUMN_ORIENTATION_WIDTH));
+  SetHeaderItem (6, TreeModel_HeaderSection ("Location", COLUMN_LOCATION_WIDTH));
 }
 
 // =======================================================================
index ebe3e21b5754d397690c0d864d7817123d53ac09..11a3fb0c2b48f0af0a8d85b571fa38be4e059d8f 100644 (file)
@@ -22,6 +22,7 @@
 #include <inspector/TreeModel_Tools.hxx>
 #include <inspector/TreeModel_ContextMenu.hxx>
 
+#include <inspector/ViewControl_PropertyView.hxx>
 #include <inspector/ViewControl_Tools.hxx>
 #include <inspector/ViewControl_TreeView.hxx>
 
@@ -39,6 +40,7 @@
 
 #include <BRep_Builder.hxx>
 #include <BRepTools.hxx>
+#include <ShapeFix_Shape.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QApplication>
@@ -95,15 +97,39 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
           this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
   new TreeModel_ContextMenu (myTreeView);
   ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
+  for (int i = 5; i <= 6; i++) // hide shape parameters columns
+  {
+    TreeModel_HeaderSection anItem = aModel->GetHeaderItem (i);
+    anItem.SetIsHidden (true);
+    aModel->SetHeaderItem (i, anItem);
+  }
+
+
   myTreeView->setModel (aModel);
   ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
   aModel->SetVisibilityState (aVisibilityState);
   TreeModel_Tools::UseVisibilityColumn (myTreeView);
 
+  QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
+  myTreeView->setSelectionModel (aSelModel);
+  connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+           this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
   QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
   myTreeView->setExpanded (aParentIndex, true);
   myMainWindow->setCentralWidget (myTreeView);
 
+  // property view
+  //myPaneCreators.Append (new VInspectorPaneAIS_PaneCreator());
+
+  myPropertyView = new ViewControl_PropertyView (myMainWindow,
+    QSize(SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT));
+  myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
+  myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
+  myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
+  myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
+  myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
+
   // view
   myViewWindow = new View_Window (myMainWindow, NULL, false);
   connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
@@ -117,6 +143,8 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
   aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
   myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
 
+  myMainWindow->splitDockWidget(myPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+
   myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
   myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
 }
@@ -355,12 +383,54 @@ void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition
       aMenu->addAction (ViewControl_Tools::CreateAction ("BREP view", SLOT (onBREPView()), myMainWindow, this));
     aMenu->addAction (ViewControl_Tools::CreateAction ("Close All BREP views", SLOT (onCloseAllBREPViews()), myMainWindow, this));
     aMenu->addAction (ViewControl_Tools::CreateAction ("BREP directory", SLOT (onBREPDirectory()), myMainWindow, this));
+    aMenu->addAction (ViewControl_Tools::CreateAction ("ShapeFix_Shape", SLOT (onShapeFixShape()), myMainWindow, this));
+
+    ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+    const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
+    TopAbs_ShapeEnum anExplodeType = aShapeItem->GetExplodeType();
+    NCollection_List<TopAbs_ShapeEnum> anExplodeTypes;
+    ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes);
+    if (anExplodeTypes.Size() > 0)
+    {
+      QMenu* anExplodeMenu = aMenu->addMenu ("Explode");
+      for (NCollection_List<TopAbs_ShapeEnum>::Iterator anExpIterator (anExplodeTypes); anExpIterator.More();
+        anExpIterator.Next())
+      {
+        TopAbs_ShapeEnum aType = anExpIterator.Value();
+        QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this);
+        anExplodeMenu->addAction (anAction);
+        if (anExplodeType == aType)
+        {
+          anAction->setCheckable (true);
+          anAction->setChecked (true);
+        }
+      }
+      QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this);
+      anExplodeMenu->addSeparator();
+      anExplodeMenu->addAction (anAction);
+    }
   }
 
   QPoint aPoint = myTreeView->mapToGlobal (thePosition);
   aMenu->exec (aPoint);
 }
 
+// =======================================================================
+// function : 
+// onTreeViewSelectionChanged
+// purpose :
+// =======================================================================
+void ShapeView_Window::onTreeViewSelectionChanged (const QItemSelection&,
+                                                   const QItemSelection&)
+{
+  QApplication::setOverrideCursor (Qt::WaitCursor);
+
+  if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+    updatePropertyPanelBySelection();
+
+  QApplication::restoreOverrideCursor();
+}
+
 // =======================================================================
 // function : onEraseAllPerformed
 // purpose :
@@ -389,6 +459,79 @@ void ShapeView_Window::onBREPDirectory()
     viewFile (aFileName);
 }
 
+// =======================================================================
+// function : onExplode
+// purpose :
+// =======================================================================
+void ShapeView_Window::onShapeFixShape()
+{
+  QItemSelectionModel* aModel = myTreeView->selectionModel();
+  if (!aModel)
+    return;
+
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
+  if (!anItemBase)
+    return;
+
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+  if (!aShapeItem)
+    return;
+
+  const TopoDS_Shape aShape = aShapeItem->GetItemShape();
+
+  Standard_Real LinTol = Precision::Confusion();
+  Standard_Real AngTol = Precision::Angular();
+
+  Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape (aShape);
+  Fixer->SetPrecision (LinTol);
+  Fixer->SetMaxTolerance (LinTol);
+  Fixer->Perform();
+
+  TopoDS_Shape aFixedShape = Fixer->Shape();
+  addShape (aFixedShape);
+}
+
+// =======================================================================
+// function : onExplode
+// purpose :
+// =======================================================================
+void ShapeView_Window::onExplode()
+{
+  QItemSelectionModel* aModel = myTreeView->selectionModel();
+  if (!aModel)
+    return;
+
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
+  if (!anItemBase)
+    return;
+
+  ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+  if (!aShapeItem)
+    return;
+
+  QAction* anAction = (QAction*)sender();
+  if (!anAction)
+    return;
+
+  QApplication::setOverrideCursor (Qt::WaitCursor);
+  TopAbs_ShapeEnum aShapeType;
+  if (anAction->text() == "NONE")
+    aShapeType = TopAbs_SHAPE;
+  else
+    aShapeType = TopAbs::ShapeTypeFromString(anAction->text().toStdString().c_str());
+
+  myViewWindow->GetDisplayer()->EraseAllPresentations();
+  aShapeItem->SetExplodeType(aShapeType);
+
+  //anItemBase->Parent()->Reset(); - TODO (update only modified sub-tree)
+  ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
+  aTreeModel->Reset();
+  aTreeModel->EmitLayoutChanged();
+  QApplication::restoreOverrideCursor();
+}
+
 // =======================================================================
 // function : onLoadFile
 // purpose :
@@ -399,8 +542,12 @@ void ShapeView_Window::onLoadFile()
 
   QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
   aFileName = QDir().toNativeSeparators (aFileName);
-  if (!aFileName.isEmpty())
+  if (aFileName.isEmpty())
+    return;
+
+    QApplication::setOverrideCursor (Qt::WaitCursor);
     onOpenFile(aFileName);
+    QApplication::restoreOverrideCursor();
 }
 
 // =======================================================================
@@ -506,6 +653,28 @@ void ShapeView_Window::viewFile (const QString& theFileName)
   QApplication::restoreOverrideCursor();
 }
 
+
+// =======================================================================
+// function : updatePropertyPanelBySelection
+// purpose :
+// =======================================================================
+void ShapeView_Window::updatePropertyPanelBySelection()
+{
+  QItemSelectionModel* aModel = myTreeView->selectionModel();
+  if (!aModel)
+    return;
+
+  QModelIndexList aSelected = TreeModel_ModelBase::GetSelected (aModel->selectedIndexes(), 0);
+  QList<ViewControl_TableModelValues*> aTableValues;
+
+  if (aSelected.size() == 1)
+  {
+    TreeModel_ItemBasePtr aSelectedItem = TreeModel_ModelBase::GetItemByIndex(aSelected.first());
+    ShapeView_Tools::GetPropertyTableValues (aSelectedItem, aTableValues);
+  }
+  myPropertyView->Init (aTableValues);
+}
+
 // =======================================================================
 // function : removeBREPFiles
 // purpose :
index 39274f893920d745e804b6aa463e3d44e94cb1a4..4ff8cd245f750b9d172dff14c4a152a7a193328d 100644 (file)
 
 class View_Window;
 
+class ViewControl_PropertyView;
+
 class QAction;
+class QDockWidget;
 class QMainWindow;
 class QWidget;
 
@@ -108,12 +111,24 @@ protected slots:
   //! \param thePosition a clicked point
   void onTreeViewContextMenuRequested (const QPoint& thePosition);
 
+  //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
+  //! check box is checked
+  //! \param theSelected a selected items
+  //! \param theDeselected a deselected items
+  void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
   //! Updates visibility states by erase all in context
   void onEraseAllPerformed();
 
   //! Exports shape to BREP file and view result file
   void onBREPDirectory();
 
+  //! Perform shape fix for the selected shape. Result is a new shape in the tree.
+  void onShapeFixShape();
+
+  //! Set the shape item exploded
+  void onExplode();
+
   //! Removes all shapes in tree view
   void onClearView() { RemoveAllShapes(); }
 
@@ -135,6 +150,9 @@ protected slots:
 
 protected:
 
+  //! Updates property panel content by item selected in tree view.
+  void updatePropertyPanelBySelection();
+
   //! Views file name content in a text editor. It creates new Qt free control with content.
   //! \param theFileName a file name
   void viewFile (const QString& theFileName);
@@ -160,6 +178,9 @@ private:
 
   QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
 
+  QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
+  ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
+
   View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
   QTreeView* myTreeView; //!< tree view visualized shapes