]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin
authornds <nds@opencascade.com>
Fri, 31 Jan 2020 10:12:45 +0000 (13:12 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 12 Feb 2020 15:00:36 +0000 (18:00 +0300)
- Convert package creation. It is used to prepare some auxiliary presentations/methods to prepare variables for inspector based on occt classes.
- ViewControl package improvement:
  Classes for property view, table, table model are implemented to visualize view of properties.
  This view is filled by selection in tree if the selected object has implemented DumpJson functionality.
- TreeModel package improvements:
  Method InitColumn is implemented in TreeModel_TreeModel to fill default columns in base model. The default columns are:
    Name, Visibility, Rows. Additional columns should be added in successors.
  Container of root items is moved into the base class
- View package imrovements:
  Store preferences: display mode, fit all checked state and type of external context
  View_DisplayPreview is added to process preview for selected in tree view objects
  hide actions Clear, Multi, Single by default (as selection in tree view or Visibility state of item define which presentations should be displayed or erased)
- ShapeView plugin improvements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for TopoDS_Shape are displayed
  Explode shape action in tree view to see content of shape by selected shape type. Type of displayed shapes is only preview, it is not used in export action.
  Export shape into BREP. The previous implementation about BREP files in some directory and default view is removed.
- VInspector plugin imrovements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for AIS_InteractiveContext and AIS_InteractiveObject are displayed
  obsolete classes to provide properties are removed.
- DFBrowser plugin improvements:
  Property View content based on DumpJson is not used yet. But there is the USE_DUMPJSON macro. It's switch off by default.
  If switch ON, it creates a Property View filled with DumpJson. It's a way of DFBrowser moving on this property view.
  Init uses static variable CDF_Session::CurrentSession()->CurrentApplication to fill plugin if application in plugin is not set but OCAF application exists

- OCC_VERSION_HEX variable used for previous OCCT versions support (before 6.9.0 or 7.2.0) is removed

214 files changed:
tools/Convert/Convert_Tools.cxx [new file with mode: 0644]
tools/Convert/Convert_Tools.hxx [new file with mode: 0644]
tools/Convert/Convert_TransientShape.hxx [new file with mode: 0644]
tools/Convert/FILES [new file with mode: 0644]
tools/DFBrowser/DFBrowser_AttributePaneStack.cxx
tools/DFBrowser/DFBrowser_Communicator.hxx
tools/DFBrowser/DFBrowser_DumpView.hxx
tools/DFBrowser/DFBrowser_HighlightDelegate.hxx
tools/DFBrowser/DFBrowser_Item.cxx
tools/DFBrowser/DFBrowser_Item.hxx
tools/DFBrowser/DFBrowser_ItemApplication.hxx
tools/DFBrowser/DFBrowser_ItemBase.cxx
tools/DFBrowser/DFBrowser_ItemBase.hxx
tools/DFBrowser/DFBrowser_ItemDocument.hxx
tools/DFBrowser/DFBrowser_Module.cxx
tools/DFBrowser/DFBrowser_Module.hxx
tools/DFBrowser/DFBrowser_OpenApplication.cxx
tools/DFBrowser/DFBrowser_OpenApplication.hxx
tools/DFBrowser/DFBrowser_PropertyPanel.hxx
tools/DFBrowser/DFBrowser_SearchLine.hxx
tools/DFBrowser/DFBrowser_SearchLineModel.hxx
tools/DFBrowser/DFBrowser_SearchView.hxx
tools/DFBrowser/DFBrowser_Thread.cxx
tools/DFBrowser/DFBrowser_ThreadItemSearch.hxx
tools/DFBrowser/DFBrowser_TreeLevelLine.hxx
tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.hxx
tools/DFBrowser/DFBrowser_TreeLevelLineModel.cxx
tools/DFBrowser/DFBrowser_TreeLevelLineModel.hxx
tools/DFBrowser/DFBrowser_TreeLevelView.hxx
tools/DFBrowser/DFBrowser_TreeLevelViewModel.cxx
tools/DFBrowser/DFBrowser_TreeLevelViewModel.hxx
tools/DFBrowser/DFBrowser_TreeModel.cxx
tools/DFBrowser/DFBrowser_TreeModel.hxx
tools/DFBrowser/DFBrowser_Window.cxx
tools/DFBrowser/DFBrowser_Window.hxx
tools/DFBrowserPane/DFBrowserPane.hxx [deleted file]
tools/DFBrowserPane/DFBrowserPane_AttributePane.cxx
tools/DFBrowserPane/DFBrowserPane_AttributePane.hxx
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreator.cxx
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreator.hxx
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreatorAPI.hxx
tools/DFBrowserPane/DFBrowserPane_AttributePaneModel.hxx
tools/DFBrowserPane/DFBrowserPane_HelperExport.hxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.hxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeItem.hxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.hxx
tools/DFBrowserPane/DFBrowserPane_TDocStdOwner.cxx
tools/DFBrowserPane/DFBrowserPane_TNamingNamedShape.cxx
tools/DFBrowserPane/DFBrowserPane_TNamingNaming.cxx
tools/DFBrowserPane/DFBrowserPane_TNamingUsedShapes.cxx
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISPresentation.cxx
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISViewer.cxx
tools/DFBrowserPane/DFBrowserPane_Tools.cxx
tools/DFBrowserPane/DFBrowserPane_Tools.hxx
tools/DFBrowserPane/FILES
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributeCommonPane.cxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributeCommonPane.hxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributePaneCreator.cxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributePaneCreator.hxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDatum.cxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocShapeMapTool.cxx
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XDEDRAW.cxx
tools/ShapeView/FILES
tools/ShapeView/ShapeView_Communicator.hxx
tools/ShapeView/ShapeView_ItemBase.hxx [deleted file]
tools/ShapeView/ShapeView_ItemRoot.cxx
tools/ShapeView/ShapeView_ItemRoot.hxx
tools/ShapeView/ShapeView_ItemShape.cxx
tools/ShapeView/ShapeView_ItemShape.hxx
tools/ShapeView/ShapeView_OpenFileDialog.hxx
tools/ShapeView/ShapeView_OpenFileViewModel.hxx
tools/ShapeView/ShapeView_Tools.cxx
tools/ShapeView/ShapeView_Tools.hxx
tools/ShapeView/ShapeView_TreeModel.cxx
tools/ShapeView/ShapeView_TreeModel.hxx
tools/ShapeView/ShapeView_VisibilityState.cxx
tools/ShapeView/ShapeView_VisibilityState.hxx
tools/ShapeView/ShapeView_Window.cxx
tools/ShapeView/ShapeView_Window.hxx
tools/TInspector/FILES
tools/TInspector/TInspector.qrc
tools/TInspector/TInspector_Communicator.hxx
tools/TInspector/TInspector_OpenButton.cxx [new file with mode: 0644]
tools/TInspector/TInspector_OpenButton.hxx [new file with mode: 0644]
tools/TInspector/TInspector_OpenFileDialog.cxx [new file with mode: 0644]
tools/TInspector/TInspector_OpenFileDialog.hxx [new file with mode: 0644]
tools/TInspector/TInspector_OpenFileViewModel.cxx [new file with mode: 0644]
tools/TInspector/TInspector_OpenFileViewModel.hxx [new file with mode: 0644]
tools/TInspector/TInspector_PluginParameters.hxx
tools/TInspector/TInspector_Preferences.hxx
tools/TInspector/TInspector_Window.cxx
tools/TInspector/TInspector_Window.hxx
tools/TInspector/icons/folder_export.png [new file with mode: 0644]
tools/TInspector/icons/folder_import.png [new file with mode: 0644]
tools/TInspector/icons/folder_open.png [new file with mode: 0644]
tools/TInspector/icons/item_algo_folder.png [deleted file]
tools/TInspectorAPI/FILES
tools/TInspectorAPI/TInspectorAPI_Communicator.hxx
tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx
tools/TInspectorAPI/TInspectorAPI_PluginParameters.hxx
tools/TInspectorAPI/TInspectorAPI_Version.hxx [deleted file]
tools/TInspectorEXE/EXTERNLIB
tools/TInspectorEXE/FILES
tools/TInspectorEXE/PACKAGES [deleted file]
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TInspectorEXE/TInspectorEXE.qrc [deleted file]
tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx [deleted file]
tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx [deleted file]
tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx [deleted file]
tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx [deleted file]
tools/TInspectorEXE/icons/folder_export.png [deleted file]
tools/TInspectorEXE/icons/folder_import.png [deleted file]
tools/TInspectorEXE/icons/folder_open.png [deleted file]
tools/TKShapeView/EXTERNLIB
tools/TKTInspectorAPI/EXTERNLIB
tools/TKTInspectorAPI/PACKAGES
tools/TKToolsDraw/EXTERNLIB
tools/TKTreeModel/EXTERNLIB
tools/TKView/EXTERNLIB
tools/ToolsDraw/ToolsDraw.cxx
tools/ToolsDraw/ToolsDraw.hxx
tools/TreeModel/FILES
tools/TreeModel/TreeModel.hxx [deleted file]
tools/TreeModel/TreeModel_ContextMenu.hxx
tools/TreeModel/TreeModel_HeaderSection.hxx
tools/TreeModel/TreeModel_ItemBase.cxx
tools/TreeModel/TreeModel_ItemBase.hxx
tools/TreeModel/TreeModel_ItemProperties.cxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemProperties.hxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemStream.cxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemStream.hxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ModelBase.cxx
tools/TreeModel/TreeModel_ModelBase.hxx
tools/TreeModel/TreeModel_Tools.cxx
tools/TreeModel/TreeModel_Tools.hxx
tools/TreeModel/TreeModel_VisibilityState.cxx
tools/TreeModel/TreeModel_VisibilityState.hxx
tools/VInspector/FILES
tools/VInspector/VInspectorAPI_CallBack.cxx
tools/VInspector/VInspectorAPI_CallBack.hxx
tools/VInspector/VInspector_CallBack.cxx
tools/VInspector/VInspector_CallBack.hxx
tools/VInspector/VInspector_Communicator.hxx
tools/VInspector/VInspector_ItemBase.cxx
tools/VInspector/VInspector_ItemBase.hxx
tools/VInspector/VInspector_ItemContext.cxx
tools/VInspector/VInspector_ItemContext.hxx
tools/VInspector/VInspector_ItemEntityOwner.cxx [deleted file]
tools/VInspector/VInspector_ItemEntityOwner.hxx [deleted file]
tools/VInspector/VInspector_ItemFolderObject.cxx [deleted file]
tools/VInspector/VInspector_ItemFolderObject.hxx [deleted file]
tools/VInspector/VInspector_ItemHistoryElement.cxx
tools/VInspector/VInspector_ItemHistoryElement.hxx
tools/VInspector/VInspector_ItemHistoryRoot.cxx
tools/VInspector/VInspector_ItemHistoryRoot.hxx
tools/VInspector/VInspector_ItemHistoryType.cxx
tools/VInspector/VInspector_ItemHistoryType.hxx
tools/VInspector/VInspector_ItemPresentableObject.cxx
tools/VInspector/VInspector_ItemPresentableObject.hxx
tools/VInspector/VInspector_ItemSelectMgrFilter.cxx [deleted file]
tools/VInspector/VInspector_ItemSelectMgrFilter.hxx [deleted file]
tools/VInspector/VInspector_ItemSelection.cxx [deleted file]
tools/VInspector/VInspector_ItemSelection.hxx [deleted file]
tools/VInspector/VInspector_ItemSensitiveEntity.cxx [deleted file]
tools/VInspector/VInspector_ItemSensitiveEntity.hxx [deleted file]
tools/VInspector/VInspector_SelectionType.hxx [deleted file]
tools/VInspector/VInspector_ToolActionType.hxx
tools/VInspector/VInspector_ToolBar.cxx
tools/VInspector/VInspector_ToolBar.hxx
tools/VInspector/VInspector_Tools.cxx
tools/VInspector/VInspector_Tools.hxx
tools/VInspector/VInspector_ViewModel.cxx
tools/VInspector/VInspector_ViewModel.hxx
tools/VInspector/VInspector_ViewModelHistory.cxx
tools/VInspector/VInspector_ViewModelHistory.hxx
tools/VInspector/VInspector_Window.cxx
tools/VInspector/VInspector_Window.hxx
tools/View/FILES
tools/View/View.qrc
tools/View/View_DisplayActionType.hxx [new file with mode: 0644]
tools/View/View_DisplayPreview.cxx [new file with mode: 0644]
tools/View/View_DisplayPreview.hxx [new file with mode: 0644]
tools/View/View_Displayer.cxx
tools/View/View_Displayer.hxx
tools/View/View_PreviewParameters.cxx [new file with mode: 0644]
tools/View/View_PreviewParameters.hxx [new file with mode: 0644]
tools/View/View_ToolActionType.hxx
tools/View/View_ToolBar.cxx
tools/View/View_ToolBar.hxx
tools/View/View_Tools.cxx [deleted file]
tools/View/View_Tools.hxx [deleted file]
tools/View/View_Viewer.cxx
tools/View/View_Viewer.hxx
tools/View/View_Widget.cxx
tools/View/View_Widget.hxx
tools/View/View_Window.cxx
tools/View/View_Window.hxx
tools/View/icons/trihedron.png [new file with mode: 0644]
tools/ViewControl/FILES
tools/ViewControl/ViewControl_EditType.hxx [new file with mode: 0644]
tools/ViewControl/ViewControl_MessageDialog.hxx
tools/ViewControl/ViewControl_PropertyView.cxx [new file with mode: 0644]
tools/ViewControl/ViewControl_PropertyView.hxx [new file with mode: 0644]
tools/ViewControl/ViewControl_Table.cxx [new file with mode: 0644]
tools/ViewControl/ViewControl_Table.hxx [new file with mode: 0644]
tools/ViewControl/ViewControl_TableModel.cxx [new file with mode: 0644]
tools/ViewControl/ViewControl_TableModel.hxx [new file with mode: 0644]
tools/ViewControl/ViewControl_TableModelValues.cxx [new file with mode: 0644]
tools/ViewControl/ViewControl_TableModelValues.hxx [new file with mode: 0644]
tools/ViewControl/ViewControl_Tools.cxx
tools/ViewControl/ViewControl_Tools.hxx
tools/ViewControl/ViewControl_TreeView.hxx

diff --git a/tools/Convert/Convert_Tools.cxx b/tools/Convert/Convert_Tools.cxx
new file mode 100644 (file)
index 0000000..47b6407
--- /dev/null
@@ -0,0 +1,54 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+// =======================================================================
+// function : ReadShape
+// purpose :
+// =======================================================================
+TopoDS_Shape Convert_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+{
+  TopoDS_Shape aShape;
+
+  BRep_Builder aBuilder;
+  BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
+  return aShape;
+}
+
+//=======================================================================
+//function : ConvertStreamToPresentations
+//purpose  :
+//=======================================================================
+void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream&,
+                                                  const Standard_Integer,
+                                                  const Standard_Integer,
+                                                  NCollection_List<Handle(Standard_Transient)>&)
+{
+}
+
+//=======================================================================
+//function : ConvertStreamToColor
+//purpose  :
+//=======================================================================
+Standard_Boolean Convert_Tools::ConvertStreamToColor (const Standard_SStream&,
+                                                      Quantity_Color&)
+{
+  return Standard_False;
+}
diff --git a/tools/Convert/Convert_Tools.hxx b/tools/Convert/Convert_Tools.hxx
new file mode 100644 (file)
index 0000000..3145c77
--- /dev/null
@@ -0,0 +1,54 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 Convert_Tools_H
+#define Convert_Tools_H
+
+#include <NCollection_List.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_SStream.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx> 
+
+//! \class Convert_Tools
+//! \brief The tool that gives auxiliary methods converting.
+class Convert_Tools
+{
+public:
+  //! Reads Shape using BREP reader
+  //! \param theFileName a file name
+  //! \return shape or NULL
+  Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+
+
+  //! Creates shape presentations on the stream if possible. Tries to init some OCCT base for a new presentation
+  //! \param theStream source of presentation
+  //! \param thePresentations container to collect new presentations
+  Standard_EXPORT static void ConvertStreamToPresentations (const Standard_SStream& theSStream,
+                                                            const Standard_Integer theStartPos,
+                                                            const Standard_Integer theLastPos,
+                                                            NCollection_List<Handle(Standard_Transient)>& thePresentations);
+
+  //! Converts stream to color if possible. It processes Quantity_Color, Quantity_ColorRGBA
+  //! \param theStream source of presentation
+  //! \param theColor [out] converted color
+  //! \returns true if done
+  Standard_EXPORT static Standard_Boolean ConvertStreamToColor (const Standard_SStream& theSStream,
+                                                                Quantity_Color& theColor);
+};
+
+#endif
diff --git a/tools/Convert/Convert_TransientShape.hxx b/tools/Convert/Convert_TransientShape.hxx
new file mode 100644 (file)
index 0000000..b3e20b4
--- /dev/null
@@ -0,0 +1,51 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 Convert_TransientShape_H
+#define Convert_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>
+
+//! \class Convert_TransientShape
+//! \brief An interface to covert a shape into a transient object to use it in arguments
+class Convert_TransientShape : public Standard_Transient
+{
+public:
+
+  //! Constructor
+  Convert_TransientShape (const TopoDS_Shape& theShape) { SetShape (theShape); }
+
+  //! Destructor
+  virtual ~Convert_TransientShape() {}
+
+  //! Returns current shape
+  const TopoDS_Shape Shape() const { return myShape; }
+
+  //! Fills current shape
+  void SetShape (const TopoDS_Shape& theShape) { myShape = theShape; }
+
+  DEFINE_STANDARD_RTTI_INLINE (Convert_TransientShape, Standard_Transient)
+
+private:
+  TopoDS_Shape myShape; //!< the shape
+};
+
+#endif 
diff --git a/tools/Convert/FILES b/tools/Convert/FILES
new file mode 100644 (file)
index 0000000..77362ef
--- /dev/null
@@ -0,0 +1,3 @@
+Convert_Tools.cxx
+Convert_Tools.hxx
+Convert_TransientShape.hxx
index e602209316abc00f94f1eaaaa175fec84fdfc01b..10bd0fd05912727405241b686bbd3255ea4c4f49 100644 (file)
@@ -80,7 +80,7 @@ void DFBrowser_AttributePaneStack::SetPaneMode (const DFBrowser_AttributePaneTyp
   myPaneMode = theMode;
   if (myPaneMode == DFBrowser_AttributePaneType_SearchView)
   {
-    //! clear highlight in tree model
+    // clear highlight in tree model
     DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
     if (aModel && aModel->HasHighlighted())
       aModel->SetHighlighted (QModelIndexList());
@@ -103,7 +103,7 @@ void DFBrowser_AttributePaneStack::SetCurrentItem (const QModelIndex& theIndex)
   if (myPaneMode != DFBrowser_AttributePaneType_ItemView)
     return;
 
-  //! clear highlight in tree model
+  // clear highlight in tree model
   DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
   if (aModel && aModel->HasHighlighted())
     aModel->SetHighlighted (QModelIndexList());
index a1c0b6c37ec0b456f9a0951f341a96fa30abadb6..8281348f9a423632b3a5ad63cfba61e4d84202d7 100644 (file)
@@ -38,7 +38,7 @@ public:
   Standard_EXPORT DFBrowser_Communicator();
 
   //! Destructor
-  virtual ~DFBrowser_Communicator() Standard_OVERRIDE {}
+  virtual ~DFBrowser_Communicator() {}
 
   //! Provides the container with a parent where this container should be inserted.
   //! If Qt implementation, it should be QWidget with QLayout set inside
@@ -49,7 +49,7 @@ public:
   //! \param theParameters a parameters container
   Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE;
 
-  //! Provide container for actions available in inspector on general level
+  //! Provides container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
   Standard_EXPORT virtual void FillActionsMenu (void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
 
index 95c35f86f327cd16945d41461fe7eb9720fff9cf..a174c83e5e7d01f6f323ad8b86fbdaa9502055e5 100644 (file)
@@ -38,14 +38,14 @@ public:
   DFBrowser_DumpView (QWidget* theParent) : QObject(theParent), myTextEdit( new QPlainTextEdit(theParent) ) {}
 
   //! Destructor
-  virtual ~DFBrowser_DumpView() Standard_OVERRIDE {}
+  virtual ~DFBrowser_DumpView() {}
 
   //! \return the text edit control
   QWidget* GetControl() const { return myTextEdit; }
 
 public slots:
 
-  //! Slots listen selection change and update the current control content by selection
+  //! Listens selection change and update the current control content by selection
   //! \param theSelected container of selected items
   //! \param theDeselected container of items that become deselected
   Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
index 5106821b9cf6271dcc4dfd3858309a93cf65a27c..351154ab0591131bb3c1d8678f923d9f10a948bd 100644 (file)
@@ -33,9 +33,9 @@ public:
   DFBrowser_HighlightDelegate (QObject* theParent = 0) : QItemDelegate (theParent) {}
 
   //! Destructor
-  virtual ~DFBrowser_HighlightDelegate() Standard_OVERRIDE {}
+  virtual ~DFBrowser_HighlightDelegate() {}
 
-  //! Redefine of the parent virtual method to color the cell rectangle in highlight style
+  //! Redefines of the parent virtual method to color the cell rectangle in highlight style
   //! \param thePainter a painter
   //! \param theOption a paint options
   //! \param theIndex a view index
index 1f0ea229ef241c625b88c0484400ab88ff98806a..28f482ac3c1f17941380f24099b68871b670d48d 100644 (file)
@@ -31,6 +31,8 @@
 #include <QObject>
 #include <Standard_WarningsRestore.hxx>
 
+//#define USE_DUMPJSON
+
 // =======================================================================
 // function : hasAttribute
 // purpose :
@@ -147,6 +149,24 @@ QVariant DFBrowser_Item::initValue (const int theItemRole) const
   return DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), theItemRole, Column());
 }
 
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void DFBrowser_Item::initStream (Standard_OStream& theOStream) const
+{
+  if (!HasAttribute())
+    return;
+
+#ifdef USE_DUMPJSON
+  Handle(TDF_Attribute) anAttribute = GetAttribute();
+  if (!anAttribute.IsNull())
+    anAttribute->DumpJson (theOStream);
+#else
+  (void)theOStream;
+#endif
+}
+
 // =======================================================================
 // function : GetAttributeInfo
 // purpose :
index 5b9220ceb47c4cc934b7cc3d84f156214086d6da..c2d4b558898829c92f97abd81c68d6e5dced008d 100644 (file)
@@ -38,14 +38,14 @@ class DFBrowser_Item : public DFBrowser_ItemBase
 public:
 
   //! Creates an item wrapped by a shared pointer
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   //! \return the pointer to the created item
   static DFBrowser_ItemPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   { return DFBrowser_ItemPtr (new DFBrowser_Item (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~DFBrowser_Item() Standard_OVERRIDE {};
+  virtual ~DFBrowser_Item() {}
 
   //! \return true if the attribute is set in the item, otherwise it is initialized by a label
   Standard_EXPORT bool HasAttribute() const;
@@ -59,7 +59,7 @@ public:
   //! Resets the cached item values, set null attribute and calls reset of the parent class
   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
-  //! Init item and calls cachedValue() for the role
+  //! Inits item and calls cachedValue() for the role
   //! \param theItemRole a value role
   //! \return the value
   Standard_EXPORT QVariant GetAttributeInfo(int theRole) const;
@@ -69,21 +69,25 @@ protected:
   //! \return number of children.
   virtual int initRowCount() const Standard_OVERRIDE;
 
-  //! Return data value for the role:
+  //! Returns data value for the role:
   //! - if content is label, calls DFBrowser_ItemBase;
   //! - if content is attribute, if the fole is extended display, asks additional info text or ask module about info
   //! \param theItemRole a value role
   //! \return the value
   virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
 
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
+
   //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   DFBrowser_Item (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
 
-  //! Initialize the current item. It creates a backup of the specific item information
+  //! Initializes the current item. It creates a backup of the specific item information
   void initItem() const;
 
   //! Sets the item attribute
index dbc675f385046f3d7be618206d45250aacd4aaf6..a50d503b2afbd18c675e56faa18102c49b8c14ef 100644 (file)
@@ -35,7 +35,7 @@ public:
   { return DFBrowser_ItemApplicationPtr (new DFBrowser_ItemApplication (theParent)); }
 
   //! Destructor
-  virtual ~DFBrowser_ItemApplication() Standard_OVERRIDE {};
+  virtual ~DFBrowser_ItemApplication() {}
 
   //! Sets the item label
   //! \param theLabel an object where the child items structure is found
@@ -67,7 +67,7 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   DFBrowser_ItemApplication(TreeModel_ItemBasePtr theParent) : DFBrowser_ItemBase(theParent, 0, 0) {}
 
 private:
index 89d58b98bd1de51363bcf792799adcadbd4ae033..e1d696b63e523cd32dc86d2b1f50fc3245dd08f3 100644 (file)
@@ -113,7 +113,7 @@ QVariant DFBrowser_ItemBase::initValue (const int theItemRole) const
       if (DFBrowser_Tools::IsEmptyLabel(GetLabel()))
         aValue = QColor (Qt::lightGray);
       else
-      { //! TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
+      { // TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
         Handle(TDataStd_Name) aName;
         if (useAdditionalInfo() && myLabel.FindAttribute (TDataStd_Name::GetID(), aName))
           aValue = QColor (Qt::darkGreen);
index c1ef3b6e949f95e92b9fad4d8724f47bdc3a509b..c87ca1d0818a86341f6c031956cc10389bb6b98f 100644 (file)
@@ -48,7 +48,7 @@ public:
   //! \return the current module
   DFBrowser_Module* GetModule() const { return myModule; }
 
-  //! Change using of additional information in item. It it does not use additional info,
+  //! Changes using of additional information in item. If it does not use additional info,
   //! it will not return extended text in initValue().
   //! \param theValue a new value
   //! \return the previous value
@@ -84,15 +84,15 @@ protected:
   //! \return the created item
   virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
 
-  //! Initialize the current item. It creates a backup of the specific item information
-  virtual void initItem() const {};
+  //! Initializes the current item. It creates a backup of the specific item information
+  virtual void initItem() const {}
 
 protected:
 
   //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
 
 private:
index 52b516ae85820e6dbc06b54d1d03c0501368dc32..3f5984da2d53e3ad5bbca6ea86cd796896102c60 100644 (file)
@@ -32,14 +32,14 @@ class DFBrowser_ItemDocument : public DFBrowser_ItemBase
 public:
 
   //! Creates an item wrapped by a shared pointer
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   //! \return the pointer to the created item
   static DFBrowser_ItemDocumentPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   { return DFBrowser_ItemDocumentPtr (new DFBrowser_ItemDocument (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~DFBrowser_ItemDocument() Standard_OVERRIDE {};
+  virtual ~DFBrowser_ItemDocument() {}
 
   //! Returns the current label
   //! \return a label
@@ -65,10 +65,10 @@ public:
 
 protected:
 
-  //! Initialize the current item. It is empty because Reset() is also empty.
+  //! Initializes the current item. It is empty because Reset() is also empty.
   virtual void initItem() const Standard_OVERRIDE;
 
-  //!
+  //! Initializes the current item. It creates a backup of the specific item information
   virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
 
 protected:
@@ -82,7 +82,7 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   DFBrowser_ItemDocument(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
 
index 2aff65e7f1ddf7600c7b13ea03ed64e6dffa34ff..ec353e724bd4422d11f928bab1f00d5489fdaf0f 100644 (file)
@@ -53,7 +53,9 @@ DFBrowser_Module::DFBrowser_Module()
 // =======================================================================
 void DFBrowser_Module::CreateViewModel (void* theParent)
 {
-  myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+  myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent);
+  myOCAFViewModel->InitColumns();
+  myOCAFViewModel->SetModule (this);
 }
 
 // =======================================================================
@@ -152,7 +154,7 @@ DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Handle(TDF_A
 // function : GetAttributePane
 // purpose :
 // =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Standard_CString theAttributeName)
 {
   DFBrowserPane_AttributePaneAPI* aPane = 0;
 
@@ -197,7 +199,7 @@ QVariant DFBrowser_Module::GetAttributeInfo (Handle(TDF_Attribute) theAttribute,
 // function : GetAttributeInfo
 // purpose :
 // =======================================================================
-QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+QVariant DFBrowser_Module::GetAttributeInfo (Standard_CString theAttributeName, DFBrowser_Module* theModule,
                                              int theRole, int theColumnId)
 {
   DFBrowserPane_AttributePane* anAttributePane = 0;
@@ -222,7 +224,7 @@ QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttribut
 // function : CreateAttributePane
 // purpose :
 // =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (Standard_CString theAttributeName)
 {
   DFBrowserPane_AttributePaneAPI* aPane = 0;
   // iteration should be performed from the tail of the list, as latest added creator has
index e75fbb0f34193bdf3740c210f0630072d67ff91a..b8f2a481d1dacb3abb309df09c9f19e610ae2310 100644 (file)
@@ -55,7 +55,7 @@ public:
   Standard_EXPORT DFBrowser_Module();
 
   //! Destructor
-  virtual ~DFBrowser_Module() Standard_OVERRIDE {};
+  virtual ~DFBrowser_Module() {}
 
   //! Creates tree model for OCAF application
   Standard_EXPORT void CreateViewModel (void* theParent);
@@ -85,7 +85,7 @@ public:
   //! \return an application instance
   Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
 
-  //! Rebuild an OCAF tree view model
+  //! Rebuilds an OCAF tree view model
   Standard_EXPORT void UpdateTreeModel();
 
   //! Sets initial selection in OCAF tree view, it is an application(root) item
@@ -96,7 +96,7 @@ public:
   //! \return an attribute
   Standard_EXPORT Handle(TDF_Attribute) FindAttribute (const QModelIndex& theIndex);
 
-  //! Append creator of a pane by attribute type
+  //! Appends creator of a pane by attribute type
   //! \param thePaneCreator
   void RegisterPaneCreator (DFBrowserPane_AttributePaneCreatorAPI* thePaneCreator)
   { myPaneCreators.append (thePaneCreator); }
@@ -111,7 +111,7 @@ public:
   //! internal map and the module processes this kind of attribute
   //! \param theAttributeGUID an attribute key
   //! \return attribute pane
-  Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (const Standard_CString& theAttributeName);
+  Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (Standard_CString theAttributeName);
 
   //! Finds the attribute pane according to the give attribute and returns its information
   //! \param theAttribute a source attribute
@@ -127,7 +127,7 @@ public:
   //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
   //! \param theColumnId a tree model column
   //! \return value, interpreted by tree model depending on the role
-  Standard_EXPORT static QVariant GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+  Standard_EXPORT static QVariant GetAttributeInfo (Standard_CString theAttributeName, DFBrowser_Module* theModule,
                                                     int theRole, int theColumnId);
 signals:
 
@@ -139,7 +139,7 @@ protected:
   //! Tries to create attribute pane for the attribute name using registered attribute pane creators
   //! \param theAttributeName a source attribute
   //! \return attribute pane or NULL
-  DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName);
+  DFBrowserPane_AttributePaneAPI* CreateAttributePane (Standard_CString theAttributeName);
 
 private:
 
index 65785a7518f48bc9e30d3a6ff2e7ffea01dc8f9b..f915f91ad3ac1c4b599544adafd3d2dfe5cb37a8 100644 (file)
@@ -19,7 +19,6 @@
 #include <BinLDrivers.hxx>
 #include <BinXCAFDrivers.hxx>
 #include <PCDM_ReadWriter.hxx>
-#include <Standard_Version.hxx>
 #include <StdDrivers.hxx>
 #include <StdLDrivers.hxx>
 #include <STEPCAFControl_Reader.hxx>
@@ -48,7 +47,6 @@ namespace DFBrowser_OpenApplication
       return anApplication;
     }
 
-#if OCC_VERSION_HEX > 0x060901
     // Load static variables for STEPCAF (ssv; 16.08.2012)
     STEPCAFControl_Controller::Init();
 
@@ -74,7 +72,6 @@ namespace DFBrowser_OpenApplication
     PCDM_ReaderStatus aStatus = anApplication->Open (theFileName, aDocument);
     if (aStatus != PCDM_RS_OK)
       return Handle(TDocStd_Application)();
-#endif
     return anApplication;
   }
 
index ccff70860cab0d408cb4695ac7d59379c0ed37ef..4e1311729a31b006e736d3700c7bd66d077e4e20 100644 (file)
@@ -24,7 +24,7 @@
 namespace DFBrowser_OpenApplication
 {
 
-  //! Open the application by the name.
+  //! Opens the application by the name.
   //! \param theFileName a name of the file initialized the application
   //! \param isSTEPFile an output parameter, true if the file name is a STEP file
   //! \return an opened application
index 1a55af76f88d31bf3a0974287fce7febe6d875a8..acc831263048bf6a4944ee0cf7f10a419d080d6d 100644 (file)
@@ -41,7 +41,7 @@ public:
   Standard_EXPORT DFBrowser_PropertyPanel (QWidget* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_PropertyPanel() Standard_OVERRIDE {}
+  virtual ~DFBrowser_PropertyPanel() {}
 
   //! Returns main control
   QWidget* GetControl() const { return myMainWindow; }
@@ -57,7 +57,7 @@ public:
                                                  const QItemSelection& theDeselected);
 private:
 
-  QWidget* myMainWindow; //! < parent of attribute stack control
-  DFBrowser_AttributePaneStack* myAttributesStack; //! < panes stack
+  QWidget* myMainWindow; //!< parent of attribute stack control
+  DFBrowser_AttributePaneStack* myAttributesStack; //!< panes stack
 };
 #endif
index 54c3ae15d3b5976675eea619d8ed88b0674f4c07..91fc5679113c624a136660b6af985ad058397974 100644 (file)
@@ -47,7 +47,7 @@ public:
   Standard_EXPORT DFBrowser_SearchLine (QWidget* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_SearchLine() Standard_OVERRIDE {}
+  virtual ~DFBrowser_SearchLine() {}
 
   //! Creates search line model filled by the module. It is necessary for auto completion of line edit
   //! \param theModule a current module
@@ -66,10 +66,10 @@ public:
   Standard_EXPORT void ClearValues();
 
   //! Returns completer model
-  Standard_EXPORT QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
+  QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
 
   //! Returns completion completer model
-  Standard_EXPORT QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
+  QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
 
   //! Returns the current line edit text
   QString Text() const { return myLineControl->text(); }
@@ -87,15 +87,17 @@ private slots:
 
   //! Updates icon of search button depending on text is empty and emits searchActivated signal
   void onTextChanged (const QString& theText);
-  //! Set completion prefix in completer model
+
+  //! Sets completion prefix in completer model
   void onReturnPressed() { myLineControl->completer()->setCompletionPrefix (myLineControl->text()); }
-  //! Set empty text if the current text is not empty: new search is started
+
+  //! Sets empty text if the current text is not empty: new search is started
   void onSearchButtonClicked();
 
 private:
 
   QLineEdit* myLineControl; //!< line editor control
-  QToolButton* mySearchButton; //! < search button
+  QToolButton* mySearchButton; //!< search button
 };
 
 #endif
index 3aeb9eae7cde0a424b020878c31ec9b80bdb5282..b7e73631d295466d0404f56ee68dd3d835ccf4c5 100644 (file)
@@ -49,7 +49,7 @@ public:
   Standard_EXPORT DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule);
 
   //! Destructor
-  virtual ~DFBrowser_SearchLineModel() Standard_OVERRIDE {}
+  virtual ~DFBrowser_SearchLineModel() {}
 
   //! Separator as attribute name is divided from the label entry in information text
   static QString SplitSeparator() { return ": "; }
@@ -87,7 +87,6 @@ public:
   //! Returns the data stored under the given role for the item referred to by the index.
   //! \param theIndex a model index
   //! \param theRole an enumeration value of role for data obtaining
-
   Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
                                          int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
   //! Returns the number of rows under the given parent.
@@ -96,10 +95,10 @@ public:
 
   virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
   { (void)theParent; return myRowCount; }
+
   //! Returns the number of columns for the children of the given parent.
   //! \param theParent a parent model index
   //! \return the number of columns
-
   virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
   { (void)theParent; return 3; }
 
index dd5b482143bcfa9f2488b0333518bbab53fd912d..8e4abdf7a1716f04716d3d3a0f5aa09e6c9764ce 100644 (file)
@@ -41,7 +41,7 @@ public:
   Standard_EXPORT DFBrowser_SearchView (QWidget* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_SearchView() Standard_OVERRIDE {}
+  virtual ~DFBrowser_SearchView() {}
 
   //! Returns search parent control
   QWidget* GetControl() const { return myMainWindow; }
index 00e6649cfaa06a20cff8bdc760b51d24ae1eb360..75996be31a2ecf12970cfde7da5eb5f071202179 100644 (file)
@@ -34,7 +34,7 @@ public:
   DFBrowser_QThread (QObject* theParent) : QThread (theParent), myItem (0) {}
 
   //! Destructor
-  virtual ~DFBrowser_QThread() Standard_OVERRIDE {}
+  virtual ~DFBrowser_QThread() {}
 
   //! Sets thread item to be processed
   //! \param theItem a thread item
index 5b73d2b635284c2b27a2b3b16c1c79983f0bdb65..674eedbbdc7b6c896edff1ba2d3b4ba990ee9649 100644 (file)
@@ -48,10 +48,10 @@ public:
   //! internal containers for search functionality
   Standard_EXPORT virtual void Run() Standard_OVERRIDE;
 
-  //! Set filled containers into search line
+  //! Sets filled containers into search line
   Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
 
-  //! Clear search line values
+  //! Clears search line values
   Standard_EXPORT static void ClearValues (DFBrowser_SearchLine* theSearchLine);
 
 private:
@@ -73,7 +73,7 @@ private:
   void addLabel (const TDF_Label& theLabel, const QStringList& theCurrentPath,
                  QMap<QString, DFBrowser_SearchItemInfo>& theValues, QStringList& theInfoValues);
 
-  //! Add attribute information, it is either attribute kind or attribure value for TDataStd_Name or TDataStd_Comment
+  //! Adds attribute information, it is either attribute kind or attribure value for TDataStd_Name or TDataStd_Comment
   //! \parm theAttribute a current attribute
   //! \param theCurrentPath it contains the current path to the label (stores in container)
   //! \param theValues container of document item values
index 2de8bfe3e6fd555238e3de05e4563261a7e0f6ba..7b305d51dbe484059c70c16c7b456ec782894689 100644 (file)
@@ -54,7 +54,7 @@ public:
   Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
+  virtual ~DFBrowser_TreeLevelLine() {}
 
   //! Clears history of selected items
   Standard_EXPORT void ClearHistory();
index c97c078a339727c2fdd2ece3fd65323d6151766a..65d6b7432333aa63f172170e2bad9aaf84074a8d 100644 (file)
@@ -38,7 +38,7 @@ public:
   //! Destructor
   virtual ~DFBrowser_TreeLevelLineDelegate() {}
 
-  //! Draw an icon in the cell and highlight cell if mouse is over the cell
+  //! Draws an icon in the cell and highlight cell if mouse is over the cell
   //! \param thePainter a painter
   //! \param theOption a paint options
   //! \param theIndex a view index
index 16e29642329e0e5576c90031ce04b19b74500ef4..9bb3069ec2b00c435a6408ffe8ca2922b8fadaba 100644 (file)
@@ -59,14 +59,17 @@ QVariant DFBrowser_TreeLevelLineModel::data (const QModelIndex& theIndex, int th
     if (theRole == Qt::DecorationRole) //! do not show icons presented in tree view
       return aValue;
     TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aTreeIndex);
-    if (anItemBase)
-    {
-      DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
-      bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
-      aValue = aDBrowserItem->data (aTreeIndex, theRole);
-      aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
+    if (!anItemBase)
+      return aValue;
+
+    DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+    if (!aDBrowserItem)
+      return aValue;
+
+    bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
+    aValue = aDBrowserItem->data (aTreeIndex, theRole);
+    aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
 
-    }
     if (theRole == Qt::DisplayRole)
       aValue = aValue.toString() + "  "; //! TEMPORARY to leave place for the action icon
   }
index 667f208d8b7d9fb9c30be27517d92211aaffae3d..e8f4e51ed600b726e6b40cb158d94278d53a0f34 100644 (file)
@@ -40,7 +40,7 @@ public:
   //! Destructor
   virtual ~DFBrowser_TreeLevelLineModel() {}
 
-  //!
+  //! Resets the cached values
   void Reset() { myLevelItems.clear(); }
 
   //! Inits the model by the index
@@ -50,7 +50,7 @@ public:
   //! Returns true if the tree model index is filled
   bool IsInitialized() const { return myTreeIndex.isValid(); }
 
-  //! Return OCAF tree view model index on level defined by column of the parameter index
+  //! Returns OCAF tree view model index on level defined by column of the parameter index
   //! \param theIndex a tree level view model index
   //! \return model index
   const QModelIndex& GetTreeViewIndex (const QModelIndex& theIndex) const
@@ -82,7 +82,7 @@ public:
 private:
 
   QModelIndex myTreeIndex; //!< the current OCAF tree view model index
-  QList<QModelIndex> myLevelItems; //! cached parent indices of myTreeIndex for quick access to item information
+  QList<QModelIndex> myLevelItems; //!< cached parent indices of myTreeIndex for quick access to item information
 };
 
 #endif
index ae961a9644646e378d1237bf7ddc6405e4aaa790..5878545f4e1398f05629e3775d367adcee6bdbb4 100644 (file)
@@ -42,12 +42,12 @@ public:
   Standard_EXPORT DFBrowser_TreeLevelView (QWidget* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_TreeLevelView() Standard_OVERRIDE {}
+  virtual ~DFBrowser_TreeLevelView() {}
 
   //! Returns parent control
   QWidget* GetControl() const { return myMainWindow; }
 
-  //! Clear selection of the table view selection model
+  //! Clears selection of the table view selection model
   Standard_EXPORT void ClearSelection();
 
   //! Returns true if this control may be filled by the index
@@ -56,7 +56,7 @@ public:
   //! \return boolean result
   Standard_EXPORT static bool ProcessItem (const QModelIndex& theIndex);
 
-  //! Init view by the first selected item in OCAF tree view
+  //! Inits view by the first selected item in OCAF tree view
   //! \param theSelected selected items
   //! \param theDeselected deselected items
   Standard_EXPORT void UpdateByTreeSelectionChanged (const QItemSelection& theSelected,
index 63802ba1aaa10c2d8d4cb235c07fb9e864d6270c..59c6a7f14f0c42b906d5fd4ec4997f1c441b66b7 100644 (file)
@@ -92,6 +92,9 @@ QVariant DFBrowser_TreeLevelViewModel::data (const QModelIndex& theIndex, int th
   if (theIndex.column() == 0)
   {
     DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+    if (!aDBrowserItem)
+      return QVariant();
+
     bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
     aValue = anItemBase->data (anIndex, theRole);
     aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
index 5c564f348f3f136b1c3d79cb3cbb81dba2c6e829..a2c06136d01d1a31a041f305435a91d771572477 100644 (file)
@@ -37,9 +37,9 @@ public:
   DFBrowser_TreeLevelViewModel (QObject* theParent) : QAbstractTableModel (theParent), myRowCount (0) {}
 
   //! Destructor
-  virtual ~DFBrowser_TreeLevelViewModel() Standard_OVERRIDE {}
+  virtual ~DFBrowser_TreeLevelViewModel() {}
 
-  //! Reset OCAF tree model index
+  //! Resets OCAF tree model index
   void Reset() { myIndex = QModelIndex(); }
 
   //! Fills OCAF tree model index
@@ -49,7 +49,7 @@ public:
   //! Returns true if the index is filled
   bool IsInitialized() const { return myIndex.isValid(); }
 
-  //! Return OCAF tree view model index on level defined by column of the parameter index
+  //! Returns OCAF tree view model index on level defined by column of the parameter index
   //! \param theIndex a tree level view model index
   //! \return model index
   Standard_EXPORT QModelIndex GetTreeViewIndex (const QModelIndex& theIndex) const;
@@ -57,7 +57,7 @@ public:
   //! Emits the layoutChanged signal from outside of this class
   void EmitLayoutChanged() { emit layoutChanged(); }
 
-  //! It returns value only for DisplayRole for column = 1
+  //! Returns value only for DisplayRole for column = 1
   //! \param theSection an index of value in the container 
   //! \param theIndex a model index
   //! \param theRole a view role
index 16fe10485e71c1c7fc56920d81cc0d81c14f2926..23ab2c2aa837e07d1034ab245d8a4ae4f73aa5f5 100644 (file)
@@ -38,12 +38,27 @@ const int COLUMN_NAME_WIDTH = 300;
 // function : Constructor
 // purpose :
 // =======================================================================
-DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule)
+DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+}
 
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::InitColumns()
+{
+  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::SetModule (DFBrowser_Module* theModule)
+{
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   aRootItem->SetModule (theModule);
 }
 
@@ -51,9 +66,9 @@ DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module*
 // function : createRootItem
 // purpose :
 // =======================================================================
-void DFBrowser_TreeModel::createRootItem (const int)
+TreeModel_ItemBasePtr DFBrowser_TreeModel::createRootItem (const int)
 {
-  m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
+  return DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
 }
 
 // =======================================================================
@@ -62,7 +77,7 @@ void DFBrowser_TreeModel::createRootItem (const int)
 // =======================================================================
 void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplication)
 {
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   Reset();
   aRootItem->SetApplication (theApplication);
   EmitLayoutChanged();
@@ -74,7 +89,7 @@ void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplicatio
 // =======================================================================
 Handle(TDocStd_Application) DFBrowser_TreeModel::GetTDocStdApplication() const
 {
-  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+  DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (RootItem (0));
   return aRootItem->GetApplication();
 }
 
@@ -179,7 +194,7 @@ QModelIndex DFBrowser_TreeModel::FindIndexByPath (const QStringList& theLabelEnt
         if (aPathId == aPathCount && anItem->HasAttribute())
         {
           // processing attribute in theValue
-          DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(m_pRootItem);
+          DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(RootItem (0));
           QString anAttributeInfo = DFBrowser_Module::GetAttributeInfo (anItem->GetAttribute(), aRootAppItem->GetModule(),
                                                                         Qt::DisplayRole, 0).toString();
           if (anAttributeInfo == anEntry)
index 6182c25b567023dde6bfbd53c7f85871884faab1..c1e1f0523babf64957a9b7dfaad916ac3ce7265d 100644 (file)
@@ -45,14 +45,20 @@ class DFBrowser_TreeModel : public TreeModel_ModelBase
 public:
 
   //! Constructor
-  Standard_EXPORT DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule);
+  Standard_EXPORT DFBrowser_TreeModel (QObject* theParent);
 
   //! Destructor
-  virtual ~DFBrowser_TreeModel() Standard_OVERRIDE {};
+  virtual ~DFBrowser_TreeModel() {}
+
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
 
   //! Fills the root item by the application
   Standard_EXPORT void Init (const Handle(TDocStd_Application)& theApplication);
 
+  //! Fills root item by the module
+  Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
   //! Returns an OCAF application or NULL
   //! \return an application instance
   Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
@@ -98,7 +104,7 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId);
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
 
index 5801326f843a3cbb3992f00ac4ebb7932b627bdc..01b100b1899111e4e0f7b1cecedafa8e0b99e818 100644 (file)
 #include <inspector/TreeModel_ContextMenu.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 
+#include <inspector/ViewControl_PropertyView.hxx>
 #include <inspector/ViewControl_TreeView.hxx>
 
-#include <inspector/View_Tools.hxx>
-
 #include <OSD_Directory.hxx>
 #include <OSD_Environment.hxx>
 #include <OSD_Protection.hxx>
@@ -102,6 +101,8 @@ const int DFBROWSER_DEFAULT_POSITION_Y = 60;
 const int DEFAULT_PROPERTY_PANEL_HEIGHT = 200;
 const int DEFAULT_BROWSER_HEIGHT = 800;
 
+//#define USE_DUMPJSON
+
 // =======================================================================
 // function : Constructor
 // purpose :
@@ -161,12 +162,24 @@ DFBrowser_Window::DFBrowser_Window()
   connect (aLevelView, SIGNAL (indexDoubleClicked (const QModelIndex&)),
            this, SLOT (onLevelDoubleClicked (const QModelIndex&)));
 
+  // property widget
   QDockWidget* aPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
   aPropertyPanelWidget->setObjectName (aPropertyPanelWidget->windowTitle());
   aPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
   aPropertyPanelWidget->setWidget (myPropertyPanel->GetControl());
   myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aPropertyPanelWidget);
 
+  // property view
+#ifdef USE_DUMPJSON
+  myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel (DumpJson)"), myMainWindow);
+  myPropertyView = new ViewControl_PropertyView (myMainWindow,
+    QSize(DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT));
+  myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
+  myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
+  myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
+  myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
+#endif
+
   // dump view window
   QWidget* aDumpWidget = new QWidget(myMainWindow);
   QVBoxLayout* aDumpLay = new QVBoxLayout(aDumpWidget);
@@ -181,20 +194,26 @@ DFBrowser_Window::DFBrowser_Window()
 
   // view
   myViewWindow = new View_Window (myMainWindow);
-  myViewWindow->GetView()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
+  myViewWindow->ViewWidget()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
 
   QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
   aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
-  aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
+  aViewDockWidget->setTitleBarWidget (myViewWindow->ViewToolBar()->GetControl());
   aViewDockWidget->setWidget (myViewWindow);
   myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
 
   QColor aHColor (229, 243, 255);
-  myViewWindow->GetDisplayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
-                                                   aHColor.blue() / 255., Quantity_TOC_RGB), View_PresentationType_Additional);
+  myViewWindow->Displayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
+                                                aHColor.blue() / 255., Quantity_TOC_sRGB), View_PresentationType_Additional);
 
-  myMainWindow->splitDockWidget(aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+  myMainWindow->splitDockWidget (aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
+
+#ifdef USE_DUMPJSON
+  myMainWindow->tabifyDockWidget (aDumpDockWidget, myPropertyPanelWidget);
+  myMainWindow->tabifyDockWidget (myPropertyPanelWidget, aViewDockWidget);
+#else
   myMainWindow->tabifyDockWidget (aDumpDockWidget, aViewDockWidget);
+#endif
 
   myTreeView->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
 
@@ -254,7 +273,7 @@ void DFBrowser_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem
 
   QMap<QString, QString> anItems;
   TreeModel_Tools::SaveState (myTreeView, anItems);
-  View_Tools::SaveState(myViewWindow, anItems);
+  View_Window::SaveState(myViewWindow, anItems);
 
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
@@ -278,7 +297,7 @@ void DFBrowser_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
       myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
     else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
-    else if (View_Tools::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+    else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
   }
 }
@@ -420,6 +439,11 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
     }
     return;
   }
+  else
+  {
+    if (anApplication.IsNull() && CDF_Session::Exists())
+      anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
+  }
 
   myModule = new DFBrowser_Module();
   myModule->CreateViewModel (myMainWindow);
@@ -659,7 +683,7 @@ void DFBrowser_Window::onExpand()
   for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
   {
     int aLevels = 2;
-    setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
   }
   QApplication::restoreOverrideCursor();
 }
@@ -677,7 +701,7 @@ void DFBrowser_Window::onExpandAll()
   for (int  aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
   {
     int aLevels = -1;
-    setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
   }
   QApplication::restoreOverrideCursor();
 }
@@ -692,7 +716,7 @@ void DFBrowser_Window::onCollapseAll()
   QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
   for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++) {
     int aLevels = -1;
-    setExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
   }
 }
 
@@ -705,6 +729,12 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
 {
   if (!myModule)
     return;
+
+#ifdef USE_DUMPJSON
+  if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+    myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+#endif
+
   // previuos selection should be cleared in the panel selectors
   DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
   anAttributePaneStack->GetPaneSelector()->ClearSelected();
@@ -716,7 +746,7 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
   QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
 
   myTreeView->scrollTo (aSelectedIndex);
-  View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+  View_Displayer* aDisplayer = myViewWindow->Displayer();
   
   aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
   aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
@@ -765,7 +795,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
       {
         TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
         QString aMessage = QString ("TShape %1 is sent to %2.")
-          .arg (DFBrowserPane_Tools::GetPointerInfo (aParameters.Last()).ToCString())
+          .arg (Standard_Dump::GetPointerInfo (aParameters.Last()).ToCString())
           .arg (aPluginShortName.ToCString());
         QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
           .arg (aPluginShortName.ToCString()).toStdString().c_str();
@@ -793,7 +823,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
 
   // make the shape visualized
   QModelIndex aSelectedIndex = aSelectedIndices.first();
-  View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+  View_Displayer* aDisplayer = myViewWindow->Displayer();
   aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
 
   // highlight and scroll to the referenced item if it exists
@@ -894,7 +924,7 @@ void DFBrowser_Window::onLevelSelected (const QModelIndex& theIndex)
   QModelIndexList anIndices;
   anIndices.append (theIndex);
   highlightIndices (anIndices);
-  View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+  View_Displayer* aDisplayer = myViewWindow->Displayer();
   aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
   aDisplayer->DisplayPresentation (findPresentation (theIndex), View_PresentationType_Main);
 }
@@ -988,26 +1018,3 @@ void DFBrowser_Window::findPresentations (const QModelIndexList& theIndices, AIS
     thePresentations.Append (aPresentation);
   }
 }
-
-// =======================================================================
-// function : setExpanded
-// purpose :
-// =======================================================================
-void DFBrowser_Window::setExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
-                                    int& theLevels)
-{
-  bool isToExpand = theLevels == -1 || theLevels > 0;
-  if (!isToExpand)
-    return;
-
-  theTreeView->setExpanded (theIndex, isExpanded);
-  if (theLevels != -1)
-    theLevels--;
-
-  QAbstractItemModel* aModel = theTreeView->model();
-  for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
-  {
-    int aLevels = theLevels;
-    setExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
-  }
-}
index 93fb3d7e0c18ba1121e4dc0000a1dc093360d3a0..17b2f21c4d494c73bee306fc3a24f77a3cceefd6 100644 (file)
@@ -39,12 +39,14 @@ class DFBrowser_Thread;
 class DFBrowser_TreeLevelLine;
 
 class ViewControl_MessageDialog;
+class ViewControl_PropertyView;
 
 class View_ToolBar;
 class View_Window;
 
 class QAbstractItemModel;
 class QAction;
+class QDockWidget;
 class QTreeView;
 class QWidget;
 
@@ -62,7 +64,7 @@ public:
   Standard_EXPORT DFBrowser_Window();
 
   //! Destructor
-  Standard_EXPORT virtual ~DFBrowser_Window() Standard_OVERRIDE;
+  Standard_EXPORT virtual ~DFBrowser_Window();
 
   //! Appends main window into layout of the parent if the parent is child of QWidget
   //! \param theParent a parent class
@@ -72,7 +74,7 @@ public:
   //! \param theParameters a parameters container
   void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
 
-  //! Provide container for actions available in inspector on general level
+  //! Provides container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
   Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
 
@@ -125,13 +127,13 @@ private slots:
   //! \param thePosition a clicked point
   void onTreeViewContextMenuRequested (const QPoint& thePosition);
 
-  //! Expand two next levels for all selected item
+  //! Expands two next levels for all selected item
   void onExpand();
 
-  //! Expand all levels for all selected items
+  //! Expands all levels for all selected items
   void onExpandAll();
 
-  //! Collapse all levels for all selected items
+  //! Collapses all levels for all selected items
   void onCollapseAll();
 
   //! Udpates all controls by changed selection in OCAF tree view
@@ -206,13 +208,6 @@ protected:
   //! \return container of presentations or NULL
   void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
 
-  //! Recursive items expanding in tree view staring from the index
-  //! \param theTreeView an OCAF tree view
-  //! \param theParentIndex an index which children should be expanded
-  //! \param isExpanded a boolean state if the item should be expanded or collapsed
-  //! \param theLevels a number of levels to be expanded, or -1 for all levels
-  static void setExpanded (QTreeView* theTreeView, const QModelIndex& theParentIndex, const bool isExpanded, int& theLevels);
-
 private:
 
   DFBrowser_Module* myModule; //!< current module
@@ -220,7 +215,9 @@ private:
   QMainWindow* myMainWindow; //!< main control for all components
   DFBrowser_TreeLevelLine* myTreeLevelLine; //!< navigate line of tree levels to the selected item
   QTreeView* myTreeView; //!< OCAF tree view
+  QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
   DFBrowser_PropertyPanel* myPropertyPanel; //!< property panel shows full information about attribute or search view
+  ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
   View_Window* myViewWindow; //!< V3d view to visualize presentations/references if it can be build for a selected item
   DFBrowser_DumpView* myDumpView; //!< Text editor where "Dump" method output is shown
   DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
diff --git a/tools/DFBrowserPane/DFBrowserPane.hxx b/tools/DFBrowserPane/DFBrowserPane.hxx
deleted file mode 100644 (file)
index be7be47..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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. 
-
-#ifndef DFBROWSERPANE_H
-#define DFBROWSERPANE_H
-
-#ifdef __DFBrowserPane_DLL
-  #ifdef _WIN32
-    #define DFBROWSERPANE_EXPORT __declspec(dllexport)
-  #else
-    #define DFBROWSERPANE_EXPORT
-  #endif
-#else
-  #ifdef _WIN32
-    #define DFBROWSERPANE_EXPORT __declspec(dllimport)
-  #else
-    #define DFBROWSERPANE_EXPORT
-  #endif
-#endif
-
-#endif
index 9468629a8b18b7f9188ccf1c072fa4151cc4b270..2bf6f29dbb5023e9060e98d781c3bc51d275c358 100644 (file)
@@ -140,7 +140,7 @@ void DFBrowserPane_AttributePane::GetShortAttributeInfo (const Handle(TDF_Attrib
 // function : GetAttributeInfoByType
 // purpose :
 // =======================================================================
-QVariant DFBrowserPane_AttributePane::GetAttributeInfoByType (const Standard_CString& theAttributeName,
+QVariant DFBrowserPane_AttributePane::GetAttributeInfoByType (Standard_CString theAttributeName,
                                                               int theRole, int theColumnId)
 {
   if (theColumnId != 0)
index c312d15668a3a0c2ffea5d2af894c89ee6901d44..2a3d1a92187214dbae0e550300c82d5d290ba0a8 100644 (file)
@@ -74,7 +74,7 @@ public:
   //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
   //! \param theColumnId a tree model column
   //! \return value, interpreted by tree model depending on the role
-  Standard_EXPORT static QVariant GetAttributeInfoByType(const Standard_CString& theAttributeName, int theRole, int theColumnId);
+  Standard_EXPORT static QVariant GetAttributeInfoByType(Standard_CString theAttributeName, int theRole, int theColumnId);
 
   //! Returns information for the given attribute
   //! \param theAttribute a current attribute
index 9869790ed48bf886af6a5bef2a91ce3805c59a61..872a590ac5ed69e4ab74df5d84f4b4594ae208d3 100644 (file)
 // function : Constructor
 // purpose :
 // =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPane_AttributePaneCreator::CreateAttributePane (
-                                                                        const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPane_AttributePaneCreator::CreateAttributePane (Standard_CString theAttributeName)
 {
   DFBrowserPane_AttributePaneAPI* aPane = 0;
   if (theAttributeName == STANDARD_TYPE (TDF_Reference)->Name())
index 5e4fdb89bdacfe2c373b3041396874c3c6ebb1e6..0b6a64e2417f3e606964e29e4833ad6499aa3f7d 100644 (file)
@@ -38,7 +38,7 @@ public:
   //! Creates attribute pane for TDF, TDataStd, TDocStd, TPrsStd, TNaming and TFunction attribute types
   //! \param theAttributeName a standard type of attribute
   //! \return an attribute pane if it can be created for this type
-  Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane(const Standard_CString& theAttributeName) Standard_OVERRIDE;
+  Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane(Standard_CString theAttributeName) Standard_OVERRIDE;
 };
 
 #endif
index e818c4dc51e9e6298f4d778d0007626dac7e0358..1537b696912e5db11390e91ef411f900c8e46330 100644 (file)
@@ -36,7 +36,7 @@ public:
   //! Creates attribute pane for attribute types
   //! \param theAttributeName a standard type of attribute
   //! \return an attribute pane if it can be created for this type
-  virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName) = 0;
+  virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane (Standard_CString theAttributeName) = 0;
 };
 
 #endif 
index a5780527945acbe87161201cda0607d9a697416b..69c64f4ec51ecf977d5494b4d250203e5fd58bd0 100644 (file)
@@ -42,7 +42,7 @@ public:
   virtual ~DFBrowserPane_AttributePaneModel() {}
 
   //! Sets direction of the values applying, whether it should be placed by rows or by columns
-  //! \param theOrientation if horizontal, the values are applyed by rows, otherwise by columns
+  //! \param theOrientation if horizontal, the values are applied by rows, otherwise by columns
   void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
 
   //! Returns table orientation for setting data values
index dac03024a34d3ca0913017ee4e61bde3b8d0d1ff..071532679843188e062ad584e41cbbd3a3cc99cf 100644 (file)
@@ -16,7 +16,6 @@
 #ifndef DFBrowserPane_HelperExport_H
 #define DFBrowserPane_HelperExport_H
 
-#include <inspector/DFBrowserPane.hxx>
 #include <TopoDS_Shape.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -29,7 +28,7 @@
 //! It contains a conainer of shapes for model indices. If button is pressed for index where the 
 //! shape exists, this shape is exported to BREP file.
 //! It contains a container of shapes, it is important to clear this helper after using.
-class DFBROWSERPANE_EXPORT DFBrowserPane_HelperExport : public QObject
+class DFBrowserPane_HelperExport : public QObject
 {
   Q_OBJECT
 public:
@@ -55,7 +54,7 @@ public:
   //! Returns shape for the index
   //! \param theIndex a model view index
   //! \return a cached shape
-  const TopoDS_Shape& GetShape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
+  const TopoDS_Shape& Shape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
 
 public slots:
 
index 0e7982911408238308f7be225888af94dc025573..a903cf3f254c9865322a07c4a363f0ccaa837f95 100644 (file)
@@ -41,6 +41,7 @@ DFBrowserPane_TDataStdTreeNode::DFBrowserPane_TDataStdTreeNode()
 : DFBrowserPane_AttributePane(), myTreeNodeView (0)
 {
   myModel = new DFBrowserPane_TDataStdTreeNodeModel (0);
+  myModel->InitColumns();
   mySelectionModels.clear(); // do not use selection model of parent pane
   mySelectionModels.push_back (new QItemSelectionModel (myModel));
 }
@@ -99,15 +100,14 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
   }
 
 
-  DFBrowserPane_TDataStdTreeNodeModel* aModel = dynamic_cast<DFBrowserPane_TDataStdTreeNodeModel*> (myModel);
-  aModel->Reset();
+  myModel->Reset();
 
   if (!aTreeNode.IsNull())
   {
     Handle(TDataStd_TreeNode) aRootItem = aTreeNode->Root();
-    aModel->SetAttribute (aRootItem);
+    myModel->SetAttribute (aRootItem);
 
-    QModelIndex anIndex = aModel->FindIndex (theAttribute, QModelIndex());
+    QModelIndex anIndex = myModel->FindIndex (theAttribute, QModelIndex());
     if (myTreeNodeView && anIndex.isValid())
     {
       myTreeNodeView->setExpanded (anIndex.parent(), true);
@@ -119,7 +119,7 @@ void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttri
       anAttributeNodeItem->setCurrentAttribute (true);
     }
   }
-  aModel->EmitLayoutChanged();
+  myModel->EmitLayoutChanged();
 }
 
 // =======================================================================
index 9057060869ad983f03da70b2649045aad75cec39..50d676a41958bfb6f653108d82d12074dbaa6963 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <Standard.hxx>
 
-class QAbstractItemModel;
+class DFBrowserPane_TDataStdTreeNodeModel;
 class QTreeView;
 
 //! \class DFBrowserPane_TDataStdTreeNode
@@ -66,7 +66,7 @@ public:
 
 private:
 
-  QAbstractItemModel* myModel;
+  DFBrowserPane_TDataStdTreeNodeModel* myModel;
   QTreeView* myTreeNodeView;
 };
 
index 2c3818f9cd1f79bca2475881d96f13a2de74e1b9..9570aea1b6a36c64ea866804e6600490ab4257ea 100644 (file)
@@ -39,15 +39,15 @@ class DFBrowserPane_TDataStdTreeNodeItem : public TreeModel_ItemBase
 public:
 
   //! Creates an item wrapped by a shared pointer
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   //! \return the pointer to the created item
   static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
                                                            const int theRow, const int theColumn)
   { return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
 
   //!Destructor
-  virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {};
+  virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {}
 
   //! Store a current attribute
   //! \param theAttribute an attribute
@@ -90,13 +90,13 @@ protected:
 protected:
 
   //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
 
-  //! Initialize the current item. It creates a backup of the specific item information
+  //! Initializes the current item. It creates a backup of the specific item information
   void initItem() const;
 
   //! Returns number of children attributes, initializes item is necessary
index aaa62b23b5c010a59460ca8c0359e7082b39425e..4f8a4847f0dabca1173e63ebad4041ef783c60a6 100644 (file)
 DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  createRootItem(0);
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeModel::InitColumns()
+{
+  SetHeaderItem (0, TreeModel_HeaderSection ("Name"));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
 {
-  m_pRootItem = DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
+  return DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
@@ -47,7 +55,7 @@ void DFBrowserPane_TDataStdTreeNodeModel::createRootItem (const int theColumnId)
 // =======================================================================
 void DFBrowserPane_TDataStdTreeNodeModel::SetAttribute (const Handle(TDF_Attribute)& theAttribute)
 {
-  DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(m_pRootItem);
+  DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(RootItem (0));
   Reset();
   aRootItem->SetAttribute (theAttribute);
   EmitLayoutChanged();
index 9223cfa19bc90040763753fb213980e4c103811f..b5acae2c79361d491691740ba50f630374851113 100644 (file)
@@ -38,7 +38,10 @@ public:
   Standard_EXPORT DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent);
 
   //! Destructor
-  virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {};
+  virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {}
+
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
 
   //! Initializes the tree model by the attribute
   //! \param theAttribute a current attribute
@@ -59,7 +62,7 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
 
index 590af0b64b480d2352a3c0d03ec190aca1112256..61f48d334ffbe9e7a9e1f5aaa441348a90c35dd9 100644 (file)
@@ -23,7 +23,6 @@
 #include <TDocStd_Owner.hxx>
 #include <TDF_Delta.hxx>
 #include <TDF_ListIteratorOfDeltaList.hxx>
-#include <Standard_Version.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QGridLayout>
@@ -56,7 +55,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
   if (aDocument.IsNull())
     return;
 
-  TCollection_AsciiString aDocumentInfo = DFBrowserPane_Tools::GetPointerInfo (aDocument).ToCString();
+  TCollection_AsciiString aDocumentInfo = Standard_Dump::GetPointerInfo (aDocument).ToCString();
   TColStd_SequenceOfExtendedString anExtensions;
   aDocument->Extensions(anExtensions);
   TCollection_AsciiString aSeparationStr = "---------------------------";
@@ -100,7 +99,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
 
   // TDocStd_Document methods
   TCollection_AsciiString aDocumentDataInfo = !aDocument->GetData().IsNull()
-    ? DFBrowserPane_Tools::GetPointerInfo (aDocument->GetData()).ToCString() : "";
+    ? Standard_Dump::GetPointerInfo (aDocument->GetData()).ToCString() : "";
   theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString()
             << STANDARD_TYPE (TDocStd_Document)->Name() << ""
             << aSeparationStr.ToCString() << aSeparationStr.ToCString()
@@ -119,9 +118,7 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
             << "GetUndos" << convertToString (aDocument->GetUndos())
             << "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos())
             << "GetRedos" << convertToString (aDocument->GetRedos())
-#if OCC_VERSION_HEX > 0x070100
             << "EmptyLabelsSavingMode" << DFBrowserPane_Tools::BoolToStr (aDocument->EmptyLabelsSavingMode())
-#endif
             << "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode())
             << "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode());
 }
index bd40910bb51f4d9ccb72460e9dd667d74d25deb9..e9220e56bcdb68143a0b1513867d614e27675c11 100644 (file)
@@ -154,7 +154,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
   aFreeRows << 0 << 1;
 
   TopoDS_Shape aShape = aShapeAttr->Get();
-  TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()) : "";
+  TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? Standard_Dump::GetPointerInfo (aShape.TShape()) : "";
   aValues << "Shape" << aShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aShape) << "" << "";
   aShapes.Append (aShape);
   if (aShape.IsNull())
@@ -162,7 +162,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
 
   TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape (aShapeAttr);
   TCollection_AsciiString aCurrentShapeInfo = !aCurrentShape.IsNull() ?
-                                  DFBrowserPane_Tools::GetPointerInfo (aCurrentShape.TShape()) : "";
+    Standard_Dump::GetPointerInfo (aCurrentShape.TShape()) : "";
   aValues << "CurrentShape" << aCurrentShapeInfo.ToCString()
           << DFBrowserPane_Tools::ShapeTypeInfo (aCurrentShape) << "" << "";
   aShapes.Append (aCurrentShape);
@@ -171,7 +171,7 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
 
   TopoDS_Shape anOriginalShape = TNaming_Tool::OriginalShape (aShapeAttr);
   TCollection_AsciiString anOriginalShapeInfo = !anOriginalShape.IsNull() ?
-            DFBrowserPane_Tools::GetPointerInfo (anOriginalShape.TShape()) : "";
+    Standard_Dump::GetPointerInfo (anOriginalShape.TShape()) : "";
   aValues << "OriginalShape" << anOriginalShapeInfo.ToCString()
           << DFBrowserPane_Tools::ShapeTypeInfo (anOriginalShape) << "" << "";
   aShapes.Append (anOriginalShape);
@@ -227,14 +227,14 @@ void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttr
         aLabelInfo = QString (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString());
     }
     if (!aNewShape.IsNull())
-      aValues << DFBrowserPane_Tools::GetPointerInfo (aNewShape.TShape()->This()).ToCString()
+      aValues << Standard_Dump::GetPointerInfo (aNewShape.TShape()->This()).ToCString()
               << DFBrowserPane_Tools::ShapeTypeInfo (aNewShape)
               << "";
     else
       aValues << "-" << "-" << "";
     aValues << "Old:";
     if (!anOldShape.IsNull())
-      aValues << DFBrowserPane_Tools::GetPointerInfo (anOldShape.TShape()->This()).ToCString()
+      aValues << Standard_Dump::GetPointerInfo (anOldShape.TShape()->This()).ToCString()
               << DFBrowserPane_Tools::ShapeTypeInfo (anOldShape)
               << aLabelInfo
               << "";
@@ -382,7 +382,7 @@ void DFBrowserPane_TNamingNamedShape::GetSelectionParameters (QItemSelectionMode
   if (aSelectedIndex.column() != 4)
     return;
 
-  const TopoDS_Shape& aShape = myHelperExport.GetShape (aSelectedIndex);
+  const TopoDS_Shape& aShape = myHelperExport.Shape (aSelectedIndex);
   if (aShape.IsNull())
     return;
   theParameters.Append (aShape.TShape());
@@ -467,7 +467,7 @@ TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes()
     QModelIndex anIndex = *anIt;
     if (!myHelperExport.HasShape (anIndex))
       continue;
-    aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+    aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
     aHasShapes = true;
   }
 
@@ -480,7 +480,7 @@ TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes()
     QModelIndex anIndex = *anIt;
     if (!myHelperExport.HasShape (anIndex))
       continue;
-    aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+    aBuilder.Add (aComp, myHelperExport.Shape (anIndex));
     aHasShapes = true;
   }
   if (aHasShapes)
index a70d5f2e6f70aa7551f33c1a07f7128a5019abf2..afd1cbe085c7ae8936576d61b37b867c1eb3b282 100644 (file)
@@ -124,7 +124,7 @@ void DFBrowserPane_TNamingNaming::GetValues (const Handle(TDF_Attribute)& theAtt
   theValues.append (QString::number (aNamingName.Index()));
   TopoDS_Shape aShape = aNamingName.Shape();
   theValues.append ("Shape(TShape)");
-  theValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
+  theValues.append (!aShape.IsNull() ? Standard_Dump::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
   TDF_Label aContextLabel = aNamingName.ContextLabel();
   theValues.append ("ContextLabel");
   theValues.append (!aContextLabel.IsNull() ? DFBrowserPane_Tools::GetEntry (aContextLabel).ToCString() : "");
index 19d54ad8d4025482ce1dd2d4f918c0c39235604a..6f5f6c1269d0567862a6678220c245fe6a21d00c 100644 (file)
@@ -80,7 +80,7 @@ void DFBrowserPane_TNamingUsedShapes::GetValues (const Handle(TDF_Attribute)& th
     if (!aShape.IsNull())
     {
       theValues.append(DFBrowserPane_Tools::ToName(DB_SHAPE_TYPE, aShape.ShapeType()).ToCString());
-      theValues.append(DFBrowserPane_Tools::GetPointerInfo(aShape.TShape()->This()).ToCString());
+      theValues.append(Standard_Dump::GetPointerInfo(aShape.TShape()->This()).ToCString());
     }
     else
       theValues << "EMPTY SHAPE" << "";
@@ -89,7 +89,7 @@ void DFBrowserPane_TNamingUsedShapes::GetValues (const Handle(TDF_Attribute)& th
     {
       theValues.append(DFBrowserPane_Tools::GetEntry(aPtrRefShape->Label()).ToCString());
       const TopoDS_Shape& aValueShape = aPtrRefShape->Shape();
-      theValues.append(!aValueShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo(aValueShape.TShape()->This()).ToCString() : "");
+      theValues.append(!aValueShape.IsNull() ? Standard_Dump::GetPointerInfo(aValueShape.TShape()->This()).ToCString() : "");
     }
     else
       theValues << "" << "";
index 3b210443a4eb0fed6125e24e2073067cd3ae08fd..4a3e75989f5218444fb2195335e91be3b94247c9 100644 (file)
@@ -63,7 +63,7 @@ void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute
             << "GetAIS" << (anIO.IsNull() ? "Null" : anAttribute->DynamicType()->Name())
             << "IsDisplayed" << DFBrowserPane_Tools::BoolToStr (anAttribute->IsDisplayed())
             << "GetContext()" << ((!anIO.IsNull() && !anIO->GetContext().IsNull()) ?
-                                 DFBrowserPane_Tools::GetPointerInfo (anIO->GetContext()).ToCString() : "")
+                                 Standard_Dump::GetPointerInfo (anIO->GetContext()).ToCString() : "")
             << "HasOwnMaterial" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMaterial())
             << "Material" << (anAttribute->HasOwnMaterial() ?
                              DFBrowserPane_Tools::ToName (DB_MATERIAL_TYPE, anAttribute->Material()) : "").ToCString()
index 6037bb2d82e22219fdc4a3a9c513faebe6149610..eecf1ee30fea628f7604c131c383261599e0e719 100644 (file)
@@ -35,7 +35,7 @@ void DFBrowserPane_TPrsStdAISViewer::GetValues (const Handle(TDF_Attribute)& the
 
   Handle(AIS_InteractiveContext) aContext = aViewerAttribute->GetInteractiveContext();
   TCollection_AsciiString aPointerInfo = !aContext.IsNull()
-    ? DFBrowserPane_Tools::GetPointerInfo (aContext).ToCString() : "";
+    ? Standard_Dump::GetPointerInfo (aContext).ToCString() : "";
 
   theValues << "GetInteractiveContext" << aPointerInfo.ToCString();
 
index 3deb0ba70f974396abb3cbef717abbfd4bb52c36..8abacd84a3b44ceeea0495f0fa41b32117a80190 100644 (file)
@@ -19,7 +19,6 @@
 #include <CDM_CanCloseStatus.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 #include <Graphic3d_NameOfMaterial.hxx>
-#include <Standard_Version.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TDataStd.hxx>
 #include <TDataStd_RealEnum.hxx>
@@ -70,30 +69,6 @@ TCollection_AsciiString DFBrowserPane_Tools::GetEntry (const TDF_Label& theLabel
   return anAsciiEntry;
 }
 
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString DFBrowserPane_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
-  std::ostringstream aPtrStr;
-  aPtrStr << thePointer.operator->();
-  if (!isShortInfo)
-    return aPtrStr.str().c_str();
-
-  TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
-  for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
-  {
-    if (anInfoPtr.Value(aSymbolId) != '0')
-    {
-      anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
-      anInfoPtr.Prepend("0x");
-      return anInfoPtr;
-    }
-  }
-  return aPtrStr.str().c_str();
-}
-
 // =======================================================================
 // function : ShapeTypeInfo
 // purpose :
index cb194777a9b77f79bdb1b25f78d6f19fef98995a..892bc7e10bb1c605720b8bd71d75e2543b84af06 100644 (file)
@@ -48,13 +48,6 @@ public:
   //! \return the string value
   Standard_EXPORT static TCollection_AsciiString GetEntry (const TDF_Label& theLabel);
 
-  //! Convert pointer to string value
-  //! \param thePointer a pointer
-  //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
-  //! \return the string value
-  Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
-                                                                 const bool isShortInfo = true);
-
   //! Returns string value corresponded to the shape type if it is not null.
   //! \param theShape a checked shape
   //! \return string value or empty string value
index 1ea8358f9ef4540d0b108451be01ba2869643d0a..de80d10eb0e4ca4df6db1fc28d36800ab0164c7d 100644 (file)
@@ -1,4 +1,3 @@
-DFBrowserPane.hxx
 DFBrowserPane.qrc
 DFBrowserPane_AttributePane.cxx
 DFBrowserPane_AttributePane.hxx
index b531305725f6109d3b117b2e57be311a94c38a9d..35e15aed7395449d4b9788b28b3cc24beb9c5688 100644 (file)
@@ -52,7 +52,7 @@ DFBrowserPaneXDE_AttributeCommonPane::DFBrowserPaneXDE_AttributeCommonPane (DFBr
 // function : ProcessAttribute
 // purpose :
 // =======================================================================
-bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType)
+bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (Standard_CString theAttributeType)
 {
   if (AttributeTypes.empty())
   {
index dd34d91db3810882074057c07507d44327c4f3df..c15e30c2b174a42f18404686f45bd6e6569bf2e2 100644 (file)
@@ -46,7 +46,7 @@ public:
   //! have difference in presentation (TDataStd_TreeNode, TDF_Reference, TNaming_NamedShape and TDataStd_UAttribute).
   //! Also it contains XCAFDoc attributes (should be implemented in this package or pane will be empty)
   //! \param theAttributeType an attribute type
-  Standard_EXPORT static bool ProcessAttribute (const Standard_CString& theAttributeType);
+  Standard_EXPORT static bool ProcessAttribute (Standard_CString theAttributeType);
 
   //! Creates table view and call create widget of array table helper
   //! \param theParent a parent widget
index 8c0641fe11dc21715b971e6cae7033bbcddb0f4b..7ace10af55c209020ceaaa330438071f94d677e4 100644 (file)
 #include <inspector/DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx>
 #include <inspector/DFBrowserPaneXDE_XCAFDocShapeTool.hxx>
 
-#include <Standard_Version.hxx>
-
 #include <XCAFDoc_Area.hxx>
 #include <XCAFDoc_Centroid.hxx>
 #include <XCAFDoc_Color.hxx>
 #include <XCAFDoc_ColorTool.hxx>
 #include <XCAFDoc_Datum.hxx>
-#if OCC_VERSION_HEX > 0x060901
 #include <XCAFDoc_Dimension.hxx>
 #include <XCAFDoc_GeomTolerance.hxx>
-#endif
 #include <XCAFDoc_DimTol.hxx>
 #include <XCAFDoc_DimTolTool.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
@@ -71,7 +67,7 @@ DFBrowserPaneXDE_AttributePaneCreator::DFBrowserPaneXDE_AttributePaneCreator(
 // function : CreateAttributePane
 // purpose :
 // =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAttributePane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAttributePane (Standard_CString theAttributeName)
 {
   DFBrowserPane_AttributePaneAPI* aPane = 0;
   if (DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (theAttributeName))
@@ -91,7 +87,7 @@ DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAtt
 // function : createXDEPane
 // purpose :
 // =======================================================================
-DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDEPane (const Standard_CString& theAttributeName)
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDEPane (Standard_CString theAttributeName)
 {
   DFBrowserPane_AttributePaneAPI* aPane = 0;
   if (theAttributeName == STANDARD_TYPE (XCAFDoc_ShapeMapTool)->Name())
@@ -106,20 +102,16 @@ DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDE
     aPane = new DFBrowserPaneXDE_XCAFDocColorTool();
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Datum)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocDatum();
-#if OCC_VERSION_HEX > 0x060901
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Dimension)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocDimension();
-#endif
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTol)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocDimTol();
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTolTool)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocDimTolTool();
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DocumentTool)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocDocumentTool();
-#if OCC_VERSION_HEX > 0x060901
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GeomTolerance)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocGeomTolerance();
-#endif
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GraphNode)->Name())
     aPane = new DFBrowserPaneXDE_XCAFDocGraphNode();
   else if (theAttributeName == STANDARD_TYPE (XCAFDoc_LayerTool)->Name())
index 2520a026510b4101876047ea30021b67000a2031..00e3a866705897fe2bc2fc2cb81a57a993676f1e 100644 (file)
@@ -43,14 +43,14 @@ public:
   //! \param theAttributeName a type of attribute
   //! \return an attribute pane if it can be created for this type
   Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane
-    (const Standard_CString& theAttributeName) Standard_OVERRIDE;
+    (Standard_CString theAttributeName) Standard_OVERRIDE;
 
 protected:
 
   //! Cretates pane for XCAFDoc attribute name
   //! \param theAttributeName a type of attribute
   //! \return an attribute pane if it can be created for this type
-  DFBrowserPane_AttributePaneAPI* createXDEPane (const Standard_CString& theAttributeName);
+  DFBrowserPane_AttributePaneAPI* createXDEPane (Standard_CString theAttributeName);
 
 private:
 
index f9e64d76950f7da6f8cfc994d2650f1f2f39cf6c..437a9b4016ec55562478ee7e088c800ff151e25c 100644 (file)
 
 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
 
-#include <Standard_Version.hxx>
 #include <TCollection_HAsciiString.hxx>
 
 #include <XCAFDoc_Datum.hxx>
-#if OCC_VERSION_HEX > 0x060901
 #include <XCAFDimTolObjects_DatumObject.hxx>
-#endif
 
 // =======================================================================
 // function : Constructor
@@ -50,13 +47,11 @@ void DFBrowserPaneXDE_XCAFDocDatum::GetValues (const Handle(TDF_Attribute)& theA
             << "Description" << (!aDescription.IsNull() ? aDescription->ToCString() : QString (""))
             << "Indentification" << (!anIndentification.IsNull() ? anIndentification->ToCString() : QString (""));
 
-#if OCC_VERSION_HEX > 0x060901
   Handle(XCAFDimTolObjects_DatumObject) anObject = anAttr->GetObject();
   Handle(TCollection_HAsciiString) anObjectName;
   if (!anObject.IsNull())
     anObjectName = anObject->GetName();
   theValues << "Object" << (!anObjectName.IsNull() ? anObjectName->ToCString() : "Empty Name");
-#endif
 }
 
 // =======================================================================
index 7fc6cef64c97e96f3532b0177a68540d828ec8ff..7cec914b78d047e1e213d0444669a5e22bf71799 100644 (file)
@@ -116,7 +116,7 @@ void DFBrowserPaneXDE_XCAFDocShapeMapTool::GetValues (const Handle(TDF_Attribute
     const TopoDS_Shape& aShape = aShapeMap(aShapeValueId);
 
     if (!aShape.IsNull())
-      theValues << DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString()
+      theValues << Standard_Dump::GetPointerInfo (aShape.TShape()->This()).ToCString()
                 << DFBrowserPane_Tools::ShapeTypeInfo (aShape)
                 << "";
     else
index 17280152c450697ce2723ff6c95ca58dda7605a0..a3b7632c3b59fde26b7495e15f9d567442cb94b3 100644 (file)
 #include <XCAFDoc_Color.hxx>
 #include <XCAFDoc_ColorTool.hxx>
 #include <XCAFDoc_DimTol.hxx>
-#include <Standard_Version.hxx>
-#if OCC_VERSION_HEX > 0x060901
 #include <XCAFDoc_Dimension.hxx>
 #include <XCAFDoc_GeomTolerance.hxx>
-#endif
 #include <XCAFDoc_Datum.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
 #include <XCAFDoc_GraphNode.hxx>
@@ -247,7 +244,6 @@ TCollection_AsciiString DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (Handle(TDF_A
     else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
       type = "DatumToler Link";
     }
-#if OCC_VERSION_HEX > 0x060901
     else if ( att->ID() == XCAFDoc::DimensionRefFirstGUID() ) {
       type = "Dimension Link First";
     }
@@ -257,7 +253,6 @@ TCollection_AsciiString DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (Handle(TDF_A
     else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
       type = "GeomTolerance Link";
     }
-#endif
     else
       return TCollection_AsciiString();
 
index 895416efc17dab4fce982050472c0fc1aba565a0..09979b4e83277157114a88e1c90c919a7e48174b 100644 (file)
@@ -1,7 +1,6 @@
 ShapeView.qrc
 ShapeView_Communicator.cxx
 ShapeView_Communicator.hxx
-ShapeView_ItemBase.hxx
 ShapeView_ItemRoot.cxx
 ShapeView_ItemRoot.hxx
 ShapeView_ItemShape.cxx
index babb61b0feaba222d0d0806508d9a6c7418b37b2..1850cff1b7c962eaa786d481c3b436995d51d02e 100644 (file)
@@ -29,7 +29,7 @@ public:
   ShapeView_Communicator() : TInspectorAPI_Communicator(), myWindow (new ShapeView_Window (0)) {}
 
   //! Destructor
-  virtual ~ShapeView_Communicator() Standard_OVERRIDE { myWindow->RemoveAllShapes(); }
+  virtual ~ShapeView_Communicator() { myWindow->RemoveAllShapes(); }
 
   //! Provides the container with a parent where this container should be inserted.
   //! If Qt implementation, it should be QWidget with QLayout set inside
@@ -41,9 +41,9 @@ public:
   virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
   { myWindow->SetParameters (theParameters); }
 
-  //! Provide container for actions available in inspector on general level
+  //! Provides container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
-  Standard_EXPORT virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
+  virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
 
   //! Returns plugin preferences, empty implementation by default
   //! \param theItem container of preference elements
diff --git a/tools/ShapeView/ShapeView_ItemBase.hxx b/tools/ShapeView/ShapeView_ItemBase.hxx
deleted file mode 100644 (file)
index 3e0559c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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. 
-
-#ifndef ShapeView_ItemBase_H
-#define ShapeView_ItemBase_H
-
-#include <Standard.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/TreeModel_ItemBase.hxx>
-
-class ShapeView_ItemBase;
-typedef QExplicitlySharedDataPointer<ShapeView_ItemBase> ShapeView_ItemBasePtr;
-
-//! \class ShapeView_ItemBase
-// \brief Declaration of the tree model base item.
-class ShapeView_ItemBase : public TreeModel_ItemBase
-{
-public:
-
-  //! Resets cached values
-  virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
-
-protected:
-
-  //! Initialize the current item. It creates a backup of the specific item information
-  virtual void initItem() const {};
-
-  //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
-  ShapeView_ItemBase(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : TreeModel_ItemBase (theParent, theRow, theColumn) {}
-};
-
-#endif
\ No newline at end of file
index 64d1dbec32b1d4aae1bb5aed1e75658c5a15c576..d9f5cb269dfb52a13d5b3a59b7fe291aa9f6ba46 100644 (file)
 #include <inspector/ShapeView_ItemShape.hxx>
 
 // =======================================================================
-// function : GetShape
+// function : Shape
 // purpose :
 // =======================================================================
-const TopoDS_Shape& ShapeView_ItemRoot::GetShape (const int theRowId)
+const TopoDS_Shape& ShapeView_ItemRoot::Shape (const int theRowId)
 {
   NCollection_List<TopoDS_Shape>::Iterator aShapesIt (myShapes);
   for (int aRowId = 0; aShapesIt.More(); aShapesIt.Next(), aRowId++)
index 370ab5b272aad7c1212622864ec97ef0ac5d96b2..c05495dfd2cebdc6f6973558bf19c5cdca39a76c 100644 (file)
@@ -17,7 +17,7 @@
 #define ShapeView_ItemRoot_H
 
 #include <NCollection_List.hxx>
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
 #include <Standard.hxx>
 #include <TopoDS_Shape.hxx>
 
@@ -28,7 +28,7 @@ typedef QExplicitlySharedDataPointer<ShapeView_ItemRoot> ShapeView_ItemRootPtr;
 //! Collects shapes that should be visualized in tree view. Shapes are cached and if shapes are not needed,
 //! cache should be cleared using RemoveAllShapes.
 //! Parent is NULL, children are ShapeView_ItemShape items.
-class ShapeView_ItemRoot : public ShapeView_ItemBase
+class ShapeView_ItemRoot : public TreeModel_ItemBase
 {
 public:
 
@@ -37,7 +37,7 @@ public:
     { return ShapeView_ItemRootPtr (new ShapeView_ItemRoot (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~ShapeView_ItemRoot() Standard_OVERRIDE {};
+  virtual ~ShapeView_ItemRoot() {}
 
   //! Appends new shape
   //! \param theShape a shape instance
@@ -48,11 +48,11 @@ public:
 
   //! Returns shape by the number
   //! \param theRowId an index of the shape in the internal container.
-  Standard_EXPORT const TopoDS_Shape& GetShape (const int theRowId);
+  Standard_EXPORT const TopoDS_Shape& Shape (const int theRowId);
 
 protected:
 
-  //! Return data value for the role.
+  //! Returns data value for the role.
   //! \param theItemRole a value role
   //! \return the value
   virtual QVariant initValue(const int theItemRole) const;
@@ -69,9 +69,9 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   ShapeView_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : ShapeView_ItemBase (theParent, theRow, theColumn) {}
+  : TreeModel_ItemBase (theParent, theRow, theColumn) {}
 
 private:
 
index 952534ba4a81d68d12d362ec32edcb368b16c981..7a69f45ffd328b85a25eeb672ef9b3023e492791 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/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 : Shape
 // purpose :
 // =======================================================================
-QString ToName (const GeomAbs_Shape& theType)
+TopoDS_Shape ShapeView_ItemShape::Shape (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 : locationInfo
-// purpose :
-// =======================================================================
-QString locationInfo (const TopLoc_Location& theLocation)
-{
-  QString anInfo;
-
-  gp_Trsf aTrsf = theLocation.Transformation();
-  QStringList aValues, aRowValues;
-  for (int aRowId = 1; aRowId <= 3; aRowId++)
-  {
-    aRowValues.clear();
-    for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
-      aRowValues.append (QString::number (aTrsf.Value(aRowId, aColumnId)));
-    aValues.append (aRowValues.join (","));
-  }
-  anInfo.append (aValues.join ("  "));
-  return anInfo;
-}
-
-// =======================================================================
-// 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();
 }
 
 // =======================================================================
@@ -205,6 +67,10 @@ TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
 // =======================================================================
 QVariant ShapeView_ItemShape::initValue(const int theRole) const
 {
+  QVariant aParentValue = TreeModel_ItemBase::initValue (theRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   TopoDS_Shape aShape = getShape();
   if (aShape.IsNull())
     return QVariant();
@@ -214,58 +80,7 @@ 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 3: return TShapePointer().ToCString();
-    case 4: return ToName(aShape.Orientation());
-    case 5: return locationInfo(aShape.Location());
-    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 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
     default: break;
   }
   return QVariant();
@@ -282,11 +97,33 @@ 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;
 }
 
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::initStream (Standard_OStream& theOStream) const
+{
+  TopoDS_Shape aShape = getShape();
+  if (aShape.IsNull())
+    return;
+
+  aShape.DumpJson (theOStream);
+}
+
 // =======================================================================
 // function : createChild
 // purpose :
@@ -304,7 +141,9 @@ 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());
+  myShape = aRootItem ? aRootItem->Shape (Row()) : aShapeItem->Shape (Row());
+
+  TreeModel_ItemBase::Init();
 }
 
 // =======================================================================
@@ -317,30 +156,6 @@ TopoDS_Shape ShapeView_ItemShape::getShape() const
   return myShape;
 }
 
-// =======================================================================
-// function : getPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
-  std::ostringstream aPtrStr;
-  aPtrStr << thePointer.operator->();
-  if (!isShortInfo)
-    return aPtrStr.str().c_str();
-
-  TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
-  for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
-  {
-    if (anInfoPtr.Value(aSymbolId) != '0')
-    {
-      anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
-      anInfoPtr.Prepend("0x");
-      return anInfoPtr;
-    }
-  }
-  return aPtrStr.str().c_str();
-}
-
 // =======================================================================
 // function : Reset
 // purpose :
@@ -348,8 +163,10 @@ TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standa
 void ShapeView_ItemShape::Reset()
 {
   myFileName = QString();
+  myChildShapes.Clear();
+  myShape = TopoDS_Shape();
 
-  ShapeView_ItemBase::Reset();
+  TreeModel_ItemBase::Reset();
 }
 
 // =======================================================================
@@ -362,4 +179,3 @@ void ShapeView_ItemShape::initItem() const
     return;
   const_cast<ShapeView_ItemShape*>(this)->Init();
 }
-
index b04076956e9b2fd502f1dae0ba80a33c21e09d24..b6706d939d89f65083ed98bfff6603039fdad1bf 100644 (file)
 #ifndef ShapeView_ItemShape_H
 #define ShapeView_ItemShape_H
 
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_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>
@@ -32,19 +36,26 @@ typedef QExplicitlySharedDataPointer<ShapeView_ItemShape> ShapeView_ItemShapePtr
 //! \class ShapeView_ItemShape
 //! This item is connected to TopoDS_Shape.
 //! Parent is either ShapeView_ItemRoot or ShapeView_ItemShape, children are ShapeView_ItemShape or no children
-class ShapeView_ItemShape : public ShapeView_ItemBase
+class ShapeView_ItemShape : public TreeModel_ItemBase
 {
 public:
 
   //! Creates an item wrapped by a shared pointer
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   //! \return the pointer to the created item
   static ShapeView_ItemShapePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   { return ShapeView_ItemShapePtr (new ShapeView_ItemShape (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
+  virtual ~ShapeView_ItemShape() {}
+
+  //! Returns explode type of the item
+  TopAbs_ShapeEnum ExplodeType() const { return myExplodeType; }
+
+  //! Sets explore type
+  //! \param theType type of item explode. If TopAbs_SHAPE, no explode, only iteration by shape
+  void SetExplodeType (const TopAbs_ShapeEnum theType) { myExplodeType  = theType; }
 
   //! Returns the current shape
   const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
@@ -52,7 +63,7 @@ public:
   //! Returns child(extracted) shape for the current shape by the index
   //! \param theRowId an index of child shape
   //! \returns shape instance or NULL
-  Standard_EXPORT TopoDS_Shape GetShape (const int theRowId) const;
+  Standard_EXPORT TopoDS_Shape Shape (const int theRowId) const;
 
   //! Returns name of BREP file for the shape if exists
   //! \return string valuie
@@ -62,17 +73,13 @@ public:
   //! \return string valuie
   void SetFileName (const QString& theFileName) { myFileName = theFileName; }
 
-  //! Returns TShape pointer info of the current TopoDS Shape
-  //! \return string value
-  TCollection_AsciiString TShapePointer() const { return getPointerInfo (myShape.TShape()); }
-
   //! Inits the item, fills internal containers
   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
 
   //! Resets cached values
   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
-  //! Return data value for the role.
+  //! Returns data value for the role.
   //! \param theRole a value role
   //! \return the value
   Standard_EXPORT virtual QVariant initValue(const int theRole) const;
@@ -80,9 +87,13 @@ public:
   //! \return number of children.
   Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
 
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
+
 protected:
 
-  //! Initialize the current item. It is empty because Reset() is also empty.
+  //! Initializes the current item. It is empty because Reset() is also empty.
   virtual void initItem() const Standard_OVERRIDE;
 
   //! Creates a child item in the given position.
@@ -99,22 +110,19 @@ protected:
   //! \return shape value
   TopoDS_Shape getShape() const;
 
-  //! Convert pointer to string value
-  //! \param thePointer a pointer
-  //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
-  //! \return the string value
-  static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
-
 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)
+    : TreeModel_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 306326b4f9f83bfb900525615a304b2760ff054d..295078913b49194a40da55d1141bdad1dabaf4a0 100644 (file)
@@ -135,9 +135,9 @@ private:
 
   QString myDataDir; //!< samples directory
   QString myFileName; //!< result file name
-  QTableView* mySamplesView; //! <view of sample file names
+  QTableView* mySamplesView; //!view of sample file names
   QLineEdit* mySelectedName; //!< alternative control to open file
-  QToolButton* myFolderApplyOpen; //! button to open file
+  QToolButton* myFolderApplyOpen; //!< button to open file
 };
 
 #endif
index 5a2847da17b286cefa3776104fe8e89d0ff2c26c..779fef52fefaea3a2e07258fdd25a96077503fe9 100644 (file)
@@ -28,7 +28,7 @@
 class QObject;
 class QPainter;
 
-//! \class TInspectorEXE_OpenFileItemDelegate
+//! \class ShapeView_OpenFileItemDelegate
 //! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
 class ShapeView_OpenFileItemDelegate : public QItemDelegate
 {
@@ -41,7 +41,7 @@ public:
   //! Destructor
   virtual ~ShapeView_OpenFileItemDelegate() {}
 
-  //! Draw an icon in the cell
+  //! Draws an icon in the cell
   //! \param thePainter a painter
   //! \param theOption a paint options
   //! \param theIndex a view index
@@ -53,7 +53,7 @@ private:
   QColor myColor; //!< highlight color
 };
 
-//! \class TInspectorEXE_OpenFileViewModel
+//! \class ShapeView_OpenFileViewModel
 //! Table model that visualizes container of string values (file names)
 //! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
 class ShapeView_OpenFileViewModel : public QAbstractTableModel
@@ -66,7 +66,7 @@ public:
   //! Destructor
   virtual ~ShapeView_OpenFileViewModel() {}
 
-  //! Store values
+  //! Stores values
   //! \param theValues a container of values to fill model
   void Init (const QStringList& theValues);
 
index afa6de45718563efdfb15f4bebd8bd8e29eba020..daea444f754f6cfdff20e7c393486451e5ae3c6c 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 <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
-#include <AIS_Shape.hxx>
 // =======================================================================
-// function : ReadShape
+// function : IsPossibleToExplode
 // purpose :
 // =======================================================================
-TopoDS_Shape ShapeView_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+Standard_Boolean ShapeView_Tools::IsPossibleToExplode (const TopoDS_Shape& theShape,
+  NCollection_List<TopAbs_ShapeEnum>& theExplodeTypes)
 {
-  TopoDS_Shape aShape;
+  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;
 
-  BRep_Builder aBuilder;
-  BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
-  return aShape;
+  TopoDS_Iterator aSubShapeIt (theShape);
+  for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+  {
+    if (IsPossibleToExplode (aSubShapeIt.Value(), theExplodeTypes))
+      return Standard_True;
+  }
+  return Standard_False;
 }
index a922e42b36b104819069c17081b4ad5410dbb040..fd8b4d45a5784da2be1532b60a2135a2fc644383 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
 {
 public:
 
-  //! Read Shape using BREP reader
-  //! \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 explode the shape. The search is recursive until all types are collected.
+  //! \param theShape [in] source shape object
+  //! \param theExplodeTypes [out] 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);
+
 };
 
 #endif
index bc29c119aecfe89c4b92797cdfad0909188abf1e..288b20c6a03b3a17467bee7eb3901449d5c96336 100644 (file)
 #include <inspector/ShapeView_ItemRoot.hxx>
 #include <inspector/ShapeView_ItemShape.hxx>
 
-const int COLUMN_NAME_WIDTH = 190;
-const int COLUMN_SIZE_WIDTH = 30;
-const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
-
-const int COLUMN_ORIENTATION_WIDTH = 70;
-const int COLUMN_LOCATION_WIDTH = 120;
-
 // =======================================================================
 // function : Constructor
 // purpose :
@@ -34,40 +26,15 @@ const int COLUMN_LOCATION_WIDTH = 120;
 ShapeView_TreeModel::ShapeView_TreeModel (QObject* theParent)
 : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  // 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));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void ShapeView_TreeModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr ShapeView_TreeModel::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return ShapeView_ItemRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
index 7778ad535d2e479594ee93c2301275d155c130e0..81b925b90ae573cf000bbf26e3605b5460ee9c67 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef ShapeView_TreeModel_H
 #define ShapeView_TreeModel_H
 
-#include <inspector/ShapeView_ItemBase.hxx>
+#include <inspector/TreeModel_ItemBase.hxx>
 #include <Standard.hxx>
 #include <TopoDS_Shape.hxx>
 #include <inspector/TreeModel_ModelBase.hxx>
@@ -38,21 +38,15 @@ public:
   Standard_EXPORT ShapeView_TreeModel (QObject* theParent);
 
   //! Destructor
-  virtual ~ShapeView_TreeModel() Standard_OVERRIDE {};
+  virtual ~ShapeView_TreeModel() {}
 
-  //! Add shape, append it to the model root item
+  //! Adds shape, append it to the model root item
   //! \param theShape a shape instance
   Standard_EXPORT void AddShape (const TopoDS_Shape& theShape);
 
-  //! Remove all shapes in the model root item
+  //! Removes all shapes in the model root item
   Standard_EXPORT void RemoveAllShapes();
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE
-  { return myRootItems[theColumn]; }
-
   //! Returns model index of the shape.
   //! \param theShape a shape object
   //! \return the model index
@@ -61,10 +55,8 @@ public:
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
-private:
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
 };
 
 #endif
index 7e7e02f600a7488862ceac2ccc1c1158a4727259..3b330f7f55b0d5f9152268e9746d7a8969caec4d 100644 (file)
 
 #include <inspector/ShapeView_ItemShape.hxx>
 
+// =======================================================================
+// function : OnClicked
+// purpose :
+// =======================================================================
+void ShapeView_VisibilityState::OnClicked (const QModelIndex& theIndex)
+{
+  processClicked (theIndex);
+  emit itemClicked (theIndex);
+}
+
 // =======================================================================
 // function : SetVisible
 // purpose :
 // =======================================================================
 bool ShapeView_VisibilityState::SetVisible (const QModelIndex& theIndex, const bool theState, const bool toEmitDataChanged)
 {
-  TopoDS_Shape aShape = GetShape (theIndex);
+  TopoDS_Shape aShape = Shape (theIndex);
   if (aShape.IsNull())
     return false;
 
@@ -35,10 +45,10 @@ bool ShapeView_VisibilityState::SetVisible (const QModelIndex& theIndex, const b
 }
 
 // =======================================================================
-// function : GetShape
+// function : Shape
 // purpose :
 // =======================================================================
-TopoDS_Shape ShapeView_VisibilityState::GetShape (const QModelIndex& theIndex) const
+TopoDS_Shape ShapeView_VisibilityState::Shape (const QModelIndex& theIndex) const
 {
   TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
   if (!anItemBase)
index 4d384d61c256e73d4c5460e4ed9e7030a0c55623..f38229db25aa3ea49b44d4a3d7ea148e9a1aa3c9 100644 (file)
@@ -28,8 +28,9 @@ class TreeModel_ModelBase;
 
 //! \class ShapeView_VisibilityState
 //! \brief Class provides connection between model and visualization control
-class ShapeView_VisibilityState : public TreeModel_VisibilityState
+class ShapeView_VisibilityState : public QObject, public TreeModel_VisibilityState
 {
+  Q_OBJECT
 public:
   //! Constructor
   ShapeView_VisibilityState (TreeModel_ModelBase* theModel) : TreeModel_VisibilityState (theModel),
@@ -49,7 +50,7 @@ public:
   //! Returns true if visibility of the item can be changed
   //! \param theIndex tree model index
   //! \return boolean value
-  virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE { return !GetShape (theIndex).IsNull(); }
+  virtual bool CanBeVisible (const QModelIndex& theIndex) const Standard_OVERRIDE { return !Shape (theIndex).IsNull(); }
 
   //! Sets visibility state
   //! \theIndex tree model index
@@ -60,17 +61,28 @@ public:
 
   //! Returns visibility state value
   virtual bool IsVisible (const QModelIndex& theIndex) const Standard_OVERRIDE
-  { return myDisplayer->IsVisible (GetShape (theIndex), myPresentationType); }
+  { return myDisplayer->IsVisible (Shape (theIndex), myPresentationType); }
+
+public slots:
+  //! Processes the mouse clicked on the index.
+  //! It changes the item visibility if model allows to change it.
+  //! \theIndex tree model index
+  void OnClicked (const QModelIndex& theIndex);
+
+signals:
+  //! Signal after OnClicked is performed
+  //! \theIndex tree model index
+  void itemClicked (const QModelIndex& theIndex);
 
 protected:
   //! Gets shape of the view model by the parameter index if it has a shape
   //! \param theIndex tree model index
   //! \return shape instance
-  TopoDS_Shape GetShape (const QModelIndex& theIndex) const;
+  TopoDS_Shape Shape (const QModelIndex& theIndex) const;
 
 private:
-  View_Displayer* myDisplayer; //! view displayer
-  View_PresentationType myPresentationType; //! presentation type
+  View_Displayer* myDisplayer; //!< view displayer
+  View_PresentationType myPresentationType; //!< presentation type
 };
 
 #endif
index 76eaefa6b413793580ba5b49784ed476aedc511a..bfe8d34ecabb9666c87732caadb98f15933803c8 100644 (file)
 #include <inspector/ShapeView_TreeModel.hxx>
 #include <inspector/ShapeView_VisibilityState.hxx>
 
+#include <inspector/Convert_Tools.hxx>
+
 #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>
 
 #include <inspector/View_Displayer.hxx>
 #include <inspector/View_PresentationType.hxx>
-#include <inspector/View_Tools.hxx>
 #include <inspector/View_ToolBar.hxx>
 #include <inspector/View_Widget.hxx>
 #include <inspector/View_Window.hxx>
@@ -83,7 +85,7 @@ const int SHAPEVIEW_DEFAULT_VIEW_HEIGHT = 1000;
 // purpose :
 // =======================================================================
 ShapeView_Window::ShapeView_Window (QWidget* theParent)
-: QObject (theParent), myNextPosition (0)
+: QObject (theParent)
 {
   myMainWindow = new QMainWindow (theParent);
 
@@ -95,28 +97,48 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
           this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
   new TreeModel_ContextMenu (myTreeView);
   ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
+  aModel->InitColumns();
+
   myTreeView->setModel (aModel);
   ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
   aModel->SetVisibilityState (aVisibilityState);
   TreeModel_Tools::UseVisibilityColumn (myTreeView);
+  QObject::connect (myTreeView, SIGNAL (clicked (const QModelIndex&)), 
+                    aVisibilityState, SLOT (OnClicked(const QModelIndex&)));
+
+  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
+  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, false);
+  myViewWindow = new View_Window (myMainWindow, NULL, false);
   connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
-  aVisibilityState->SetDisplayer (myViewWindow->GetDisplayer());
+  aVisibilityState->SetDisplayer (myViewWindow->Displayer());
   aVisibilityState->SetPresentationType (View_PresentationType_Main);
-  myViewWindow->GetView()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
+  myViewWindow->ViewWidget()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
 
   QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
   aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
   aViewDockWidget->setWidget (myViewWindow);
-  aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
+  aViewDockWidget->setTitleBarWidget (myViewWindow->ViewToolBar()->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);
 }
@@ -127,7 +149,6 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent)
 // =======================================================================
 ShapeView_Window::~ShapeView_Window()
 {
-  onCloseAllBREPViews();
 }
 
 // =======================================================================
@@ -171,7 +192,7 @@ void ShapeView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem
 
   QMap<QString, QString> anItems;
   TreeModel_Tools::SaveState (myTreeView, anItems);
-  View_Tools::SaveState(myViewWindow, anItems);
+  View_Window::SaveState(myViewWindow, anItems);
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
 }
@@ -194,7 +215,7 @@ void ShapeView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
       myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
     else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
-    else if (View_Tools::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+    else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
       continue;
   }
 }
@@ -302,7 +323,7 @@ void ShapeView_Window::Init (NCollection_List<Handle(Standard_Transient)>& thePa
 // =======================================================================
 void ShapeView_Window::OpenFile(const TCollection_AsciiString& theFileName)
 {
-  TopoDS_Shape aShape = ShapeView_Tools::ReadShape (theFileName);
+  TopoDS_Shape aShape = Convert_Tools::ReadShape (theFileName);
   if (!aShape.IsNull())
     addShape(aShape);
 }
@@ -315,8 +336,6 @@ void ShapeView_Window::RemoveAllShapes()
 {
   ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
   aModel->RemoveAllShapes();
-
-  onCloseAllBREPViews();
 }
 
 // =======================================================================
@@ -351,16 +370,52 @@ void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition
     aMenu->addAction (ViewControl_Tools::CreateAction ("Remove all shape items", SLOT (onClearView()), myMainWindow, this));
   }
   else {
-    if (!GetTemporaryDirectory().IsEmpty())
-      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 ("Export to BREP", SLOT (onExportToBREP()), myMainWindow, this));
+    ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+    const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
+    TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType();
+    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())
+    myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+
+  QApplication::restoreOverrideCursor();
+}
+
 // =======================================================================
 // function : onEraseAllPerformed
 // purpose :
@@ -376,17 +431,43 @@ void ShapeView_Window::onEraseAllPerformed()
 }
 
 // =======================================================================
-// function : onBREPDirectory
+// function : onExplode
 // purpose :
 // =======================================================================
-void ShapeView_Window::onBREPDirectory()
+void ShapeView_Window::onExplode()
 {
-  QString aFilter (tr ("BREP file (*.brep*)"));
-  QString aSelectedFilter;
-  QString aFileName = QFileDialog::getOpenFileName (0, tr ("Export shape to BREP file"),
-                                                    GetTemporaryDirectory().ToCString(), aSelectedFilter);
-  if (!aFileName.isEmpty())
-    viewFile (aFileName);
+  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->Displayer()->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();
 }
 
 // =======================================================================
@@ -399,18 +480,23 @@ void ShapeView_Window::onLoadFile()
 
   QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
   aFileName = QDir().toNativeSeparators (aFileName);
-  if (!aFileName.isEmpty())
-    onOpenFile(aFileName);
+  if (aFileName.isEmpty())
+    return;
+
+  QApplication::setOverrideCursor (Qt::WaitCursor);
+  onOpenFile(aFileName);
+  QApplication::restoreOverrideCursor();
 }
 
 // =======================================================================
-// function : onBREPView
+// function : onExportToBREP
 // purpose :
 // =======================================================================
-void ShapeView_Window::onBREPView()
+void ShapeView_Window::onExportToBREP()
 {
-  if (GetTemporaryDirectory().IsEmpty())
-    return;
+  QString aFilter (tr ("Boundary representation file (*.brep *)"));
+  QString aSelectedFilter;
+  QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export shape to file"), QString(), aFilter, &aSelectedFilter);
 
   QItemSelectionModel* aModel = myTreeView->selectionModel();
   if (!aModel)
@@ -429,107 +515,9 @@ void ShapeView_Window::onBREPView()
   if (!anItem)
     return;
 
-  QString aFileName = anItem->GetFileName();
-  QDir aDir;
-  if (aFileName.isEmpty() || !aDir.exists (aFileName))
-  {
-    TCollection_AsciiString aFileNameIndiced = GetTemporaryDirectory() + TCollection_AsciiString ("\\") +
-                                               getNextTmpName (anItem->TShapePointer());
-    const TopoDS_Shape& aShape = anItem->GetItemShape();
-    BRepTools::Write (aShape, aFileNameIndiced.ToCString());
-    anItem->SetFileName (aFileNameIndiced.ToCString());
-    aFileName = aFileNameIndiced.ToCString();
-  }
-  viewFile (aFileName);
-}
-
-// =======================================================================
-// function : onCloseAllBREPViews
-// purpose :
-// =======================================================================
-void ShapeView_Window::onCloseAllBREPViews()
-{
-  removeBREPFiles();
-
-  for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
-    delete myBREPViews[aViewId];
-
-  myBREPViews.clear();
-}
-
-// =======================================================================
-// function : onEditorDestroyed
-// purpose :
-// =======================================================================
-void ShapeView_Window::onEditorDestroyed(QObject* theObject)
-{
-  QWidget* aWidget = dynamic_cast<QWidget*> (theObject);
-
-  for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
-  {
-    if (myBREPViews[aViewId] == aWidget)
-      myBREPViews.removeAll(aWidget);
-  }
-}
-
-// =======================================================================
-// function : viewFile
-// purpose :
-// =======================================================================
-void ShapeView_Window::viewFile (const QString& theFileName)
-{
-  QApplication::setOverrideCursor (Qt::WaitCursor);
-  QString aFileText;
-  QFile aFile (theFileName);
-  if (aFile.open (QIODevice::ReadOnly | QIODevice::Text))
-  {
-    QTextStream aStream(&aFile);
-    QString aLine = aStream.readLine();
-    while (!aLine.isNull())
-    {
-      aLine = aStream.readLine();
-      aFileText.append (aLine + QString ("\n"));
-    }
-    if (!aFileText.isEmpty())
-    {
-      QPlainTextEdit* anEditor = new QPlainTextEdit (0);
-      anEditor->setAttribute (Qt::WA_DeleteOnClose, true);
-      connect (anEditor, SIGNAL (destroyed(QObject*)), this, SLOT (onEditorDestroyed(QObject*)));
-      anEditor->setPlainText (aFileText);
-      anEditor->resize (DEFAULT_TEXT_VIEW_WIDTH, DEFAULT_TEXT_VIEW_HEIGHT);
-      anEditor->move (DEFAULT_TEXT_VIEW_POSITION_X + myNextPosition, DEFAULT_TEXT_VIEW_POSITION_Y);
-      myNextPosition += DEFAULT_TEXT_VIEW_DELTA;
-      anEditor->show();
-      myBREPViews.append (anEditor);
-    }
-  }
-  QApplication::restoreOverrideCursor();
-}
-
-// =======================================================================
-// function : removeBREPFiles
-// purpose :
-// =======================================================================
-void ShapeView_Window::removeBREPFiles()
-{
-  QDir aDir (GetTemporaryDirectory().ToCString());
-
-  QStringList anEntries = aDir.entryList();
-  QString aPrefix(viewBREPPrefix().ToCString());
-  for (int anEntryId = 0, aSize = anEntries.size(); anEntryId < aSize; anEntryId++)
-  {
-    if (anEntries[anEntryId].contains (aPrefix))
-      aDir.remove (anEntries[anEntryId]);
-  }
-}
-
-// =======================================================================
-// function : getNextTmpName
-// purpose :
-// =======================================================================
-TCollection_AsciiString ShapeView_Window::getNextTmpName (const TCollection_AsciiString& thePointerInfo)
-{
-  TCollection_AsciiString aTmpName(viewBREPPrefix());
-  aTmpName += thePointerInfo;
-  return aTmpName;
+  TCollection_AsciiString aFileNameIndiced = aFileName.toStdString().c_str();
+  const TopoDS_Shape& aShape = anItem->GetItemShape();
+  BRepTools::Write (aShape, aFileNameIndiced.ToCString());
+  anItem->SetFileName (aFileNameIndiced.ToCString());
+  aFileName = aFileNameIndiced.ToCString();
 }
index 39274f893920d745e804b6aa463e3d44e94cb1a4..950119326efde75b397ae5c11b469e751b086ec3 100644 (file)
 
 class View_Window;
 
+class ViewControl_PropertyView;
+
 class QAction;
+class QDockWidget;
 class QMainWindow;
 class QWidget;
 
@@ -59,7 +62,7 @@ public:
   //! \param theParameters a parameters container
   void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
 
-  //! Provide container for actions available in inspector on general level
+  //! Provides container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
   Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
 
@@ -80,9 +83,6 @@ public:
   //! Returns current tree view
   QTreeView* GetTreeView() const { return myTreeView; }
 
-  //! Returns path to temporary directory
-  TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
-
   //! Removes all shapes in tree view model, remove all stored BREP files
   Standard_EXPORT void RemoveAllShapes();
 
@@ -98,7 +98,7 @@ private:
   //! \param theParameters a parameters container
   void Init (NCollection_List<Handle(Standard_Transient)>& theParameters);
 
-  //! Read Shape from the file name, add Shape into tree view
+  //! Reads Shape from the file name, add Shape into tree view
   //! \param theFileName BREP file name
   void OpenFile (const TCollection_AsciiString& theFileName);
 
@@ -108,64 +108,47 @@ 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();
+  //! Sets the shape item exploded
+  void onExplode();
 
   //! Removes all shapes in tree view
   void onClearView() { RemoveAllShapes(); }
 
-  //! Load BREP file and updates tree model to have shape of the file
+  //! Loads BREP file and updates tree model to have shape of the file
   void onLoadFile();
 
-  //! View BREP files of selected items if exist
-  void onBREPView();
-
-  //! Remove BREP views, close views
-  void onCloseAllBREPViews();
-
-  //! Remove all BREP Viewse excepting active
-  void onEditorDestroyed (QObject* theObject);
+  //! Views BREP files of selected items if exist
+  void onExportToBREP();
 
   //! Convers file name to Ascii String and perform opeging file
   //! \param theFileName a file name to be opened
   void onOpenFile(const QString& theFileName) { OpenFile (TCollection_AsciiString (theFileName.toUtf8().data())); }
 
 protected:
-
-  //! 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);
-
-  //! Removes all BREP files in tmp directory
-  void removeBREPFiles();
-
   //! Creates new action and connect it to the given slot
   //! \param theText an action text
   //! \param theSlot a listener method
   QAction* createAction (const QString& theText, const char* theSlot);
 
-  //! Key that uses to generate BREP file name
-  //! \return string value
-  static TCollection_AsciiString viewBREPPrefix() { return "ShapeView_Window"; }
-
-  //! Returns newxt temporary name using BREPPrefix and pointer information
-  //! \param thePointerInfo a pointer value
-  //! \return string value
-  TCollection_AsciiString getNextTmpName (const TCollection_AsciiString& thePointerInfo);
-
 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
 
-  int myNextPosition; //!< delta of moving control of view BREP file
-
-  QList<QWidget*> myBREPViews; //!< list of view BREP file controls
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
 };
 
index 21dba46d9deb0b5a5ee0c4108c1879030d079a40..471fd38cb1059524e90b61f1e30500219da37edc 100644 (file)
@@ -1,6 +1,12 @@
 TInspector.qrc
 TInspector_Communicator.cxx
 TInspector_Communicator.hxx
+TInspector_OpenButton.cxx
+TInspector_OpenButton.hxx
+TInspector_OpenFileDialog.cxx
+TInspector_OpenFileDialog.hxx
+TInspector_OpenFileViewModel.cxx
+TInspector_OpenFileViewModel.hxx
 TInspector_PluginParameters.cxx
 TInspector_PluginParameters.hxx
 TInspector_Preferences.cxx
index 8fbf4bb7a59e88350ef4a6818b8c2dc84e1b607f..439185f9fc0b247135363949805d0fb48611c178 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE RCC><RCC version="1.0">
     <qresource>
-        <file>icons/item_algo_folder.png</file>
-        <file>icons/plugin_actions.png</file>
+        <file alias="folder_open.png">icons/folder_open.png</file>
+        <file alias="folder_import.png">icons/folder_import.png</file>
+        <file alias="plugin_actions.png">icons/plugin_actions.png</file>
     </qresource>
 </RCC>
index bd5fbc7b47d2078b7ef68193684a420ddfcccb81..f2d8633878430d58e372f26bce133ccfb8c0a2fc 100644 (file)
@@ -64,13 +64,13 @@ public:
              const Standard_Boolean theAppend = Standard_False)
   { myWindow->Init (thePluginName, theParameters, theAppend); }
 
-  //! UpdateContent for the TInspector window
+  //! Updates content for the TInspector window
   void UpdateContent() { myWindow->UpdateContent(); }
 
-  //! SetOpenButton for the TInspector window
+  //! Sets open button for the TInspector window
   void SetOpenButton (QPushButton* theButton) { myWindow->SetOpenButton (theButton); }
 
-  //! OpenFile in TInspector window
+  //! Opens file in TInspector window
   void OpenFile (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theFileName)
   { myWindow->OpenFile (thePluginName, theFileName); }
 
@@ -78,14 +78,13 @@ public:
   //! \param thePluginName a name of the plugin
   void Activate (const TCollection_AsciiString& thePluginName) { myWindow->ActivateTool (thePluginName); }
 
-  //! Set item selected in the active plugin
+  //! Sets item selected in the active plugin
   //! \param theItemName a containerr of name of items in plugin that should become selected
   void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames) { myWindow->SetSelected (theItemNames); }
 
   //! Sets objects to be selected in the plugin
   //! \param theObjects an objects
-  Standard_EXPORT void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects)
-    { myWindow->SetSelected (theObjects); }
+  void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects) { myWindow->SetSelected (theObjects); }
 
   //! Sets path to a directory for temporary plugin files
   //! \param thePath a path
@@ -95,11 +94,11 @@ public:
   //! \return path
   TCollection_AsciiString GetTemporaryDirectory() const { return myWindow->GetTemporaryDirectory(); }
 
-  //! Change window visibility
+  //! Changes window visibility
   //! \param theVisible boolean state
   Standard_EXPORT virtual void SetVisible (const bool theVisible);
 
-  //! Change window position
+  //! Changes window position
   //! \param theX X pixel position of top left corner of the window
   //! \param theY Y pixel position
   Standard_EXPORT virtual void Move (const int theXPosition, const int theYPosition);
diff --git a/tools/TInspector/TInspector_OpenButton.cxx b/tools/TInspector/TInspector_OpenButton.cxx
new file mode 100644 (file)
index 0000000..6898f2a
--- /dev/null
@@ -0,0 +1,96 @@
+// 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/TInspector_OpenButton.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+#include <inspector/TInspector_OpenFileDialog.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QDir>
+#include <QPushButton>
+#include <Standard_WarningsRestore.hxx>
+
+const int RECENT_FILES_CACHE_SIZE = 10;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_OpenButton::TInspector_OpenButton (QObject* theParent)
+ : QObject (theParent), myStartButton (0)
+{
+}
+
+// =======================================================================
+// function : StartButton
+// purpose :
+// =======================================================================
+QPushButton* TInspector_OpenButton::StartButton()
+{
+  if (!myStartButton)
+  {
+    myStartButton = new QPushButton();
+    myStartButton->setIcon (QIcon (":folder_open.png"));
+    connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
+  }
+  return myStartButton;
+}
+
+// =======================================================================
+// function : onStartButtonClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenButton::onStartButtonClicked()
+{
+  QPushButton* aButton = (QPushButton*)sender();
+  TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
+  if (aPluginName.IsEmpty())
+    return;
+  
+  QStringList aPluginRecentlyOpenedFiles;
+  if (myRecentlyOpenedFiles.contains(aPluginName))
+  {
+    QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
+    for (int i = 0; i < aFileNames.size(); i++)
+    {
+      QFileInfo aFileInfo (aFileNames[i]);
+      if (aFileInfo.exists() && aFileInfo.isFile())
+        aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
+    }
+  }
+
+  QString aFileName = TInspector_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
+  aFileName = QDir().toNativeSeparators (aFileName);
+  if (!aFileName.isEmpty()) {
+    QApplication::setOverrideCursor (Qt::WaitCursor);
+    TInspector_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
+
+    QFileInfo aFileInfo (aFileName);
+    if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
+    {
+      myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
+      for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
+        myRecentlyOpenedFiles[aPluginName].removeFirst();
+      TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
+        TInspector_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
+
+      TInspector_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
+    }
+
+    QApplication::restoreOverrideCursor();
+  }
+}
diff --git a/tools/TInspector/TInspector_OpenButton.hxx b/tools/TInspector/TInspector_OpenButton.hxx
new file mode 100644 (file)
index 0000000..d7caaec
--- /dev/null
@@ -0,0 +1,65 @@
+// 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. 
+
+#ifndef TInspectorEXE_OpenButton_H
+#define TInspectorEXE_OpenButton_H
+
+#include <TCollection_AsciiString.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QObject>
+#include <QMap>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+class QPushButton;
+
+//! \class TInspector_OpenButton
+//! Class that contains push button and the button processing. It obtains a file name from the default or current
+//! directory and gives the name into TInspector communicator
+//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
+class TInspector_OpenButton : public QObject
+{
+  Q_OBJECT
+
+public:
+
+  //! Constructor
+  Standard_EXPORT TInspector_OpenButton (QObject* theParent);
+
+  //! Destructor
+  virtual ~TInspector_OpenButton() {}
+
+  //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
+  Standard_EXPORT QPushButton* StartButton();
+
+  //! Sets the default directory of plugin.
+  void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                     const QStringList& theRecentlyOpenedFiles)
+  { myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
+
+private slots:
+
+  //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
+  void onStartButtonClicked();
+
+private:
+
+  QPushButton* myStartButton; //!< processed button
+  //!< plugins recently opened files
+  QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
+};
+
+#endif
diff --git a/tools/TInspector/TInspector_OpenFileDialog.cxx b/tools/TInspector/TInspector_OpenFileDialog.cxx
new file mode 100644 (file)
index 0000000..622818a
--- /dev/null
@@ -0,0 +1,281 @@
+// 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/TInspector_OpenFileDialog.hxx>
+
+#include <inspector/TInspector_OpenButton.hxx>
+#include <inspector/TInspector_OpenFileViewModel.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QCompleter>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileSystemModel>
+#include <QItemSelectionModel>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QScrollBar>
+#include <QTableView>
+#include <QToolButton>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+const int FONT_POINT_SIZE = 18;
+const int ICON_SIZE = 40;
+
+const int OPEN_DIALOG_WIDTH = 550;
+const int OPEN_DIALOG_HEIGHT = 200;
+
+const int MARGIN_DIALOG = 4;
+const int SPACING_DIALOG = 2;
+
+const int RECENT_FILES_CACHE_SIZE = 10;
+
+TInspector_Communicator* MyCommunicator;
+
+// =======================================================================
+// function : changeMargins
+// purpose :
+// =======================================================================
+void changeMargins (QBoxLayout* theLayout)
+{
+  theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+  theLayout->setSpacing (SPACING_DIALOG);
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_OpenFileDialog::TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
+: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
+{
+  setWindowTitle (tr ("Open File"));
+
+  QVBoxLayout* aDialogLay = new QVBoxLayout (this);
+  changeMargins (aDialogLay);
+
+  // Samples View
+  QGroupBox* aSamplesBox = new QGroupBox (this);
+  aSamplesBox->setTitle (tr ("Recent files"));
+  aDialogLay->addWidget (aSamplesBox);
+  QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
+  changeMargins (aSampleLay);
+  mySamplesView = createTableView (theRecentlyOpenedFiles);
+  aSampleLay->addWidget (mySamplesView);
+
+  // Select file
+  QGroupBox* aSelectFileBox = new QGroupBox (this);
+  aSelectFileBox->setTitle (tr ("Select file"));
+  aDialogLay->addWidget (aSelectFileBox);
+  QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
+  aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+
+  mySelectedName = new QLineEdit (aSelectFileBox);
+  QCompleter* aCompleter = new QCompleter();
+  QFileSystemModel* aFileSystemModel = new QFileSystemModel;
+  aFileSystemModel->setRootPath (QDir::rootPath());
+  aCompleter->setModel (aFileSystemModel);
+  mySelectedName->setCompleter (aCompleter);
+  aSelectFileLay->addWidget (mySelectedName, 1, 0);
+
+  QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
+  aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
+  aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
+
+  connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
+  connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
+
+  resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+QString TInspector_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
+{
+  QString aFileName;
+  TInspector_OpenFileDialog* aDialog = new TInspector_OpenFileDialog (theParent, theRecentlyOpenedFiles);
+  if (aDialog->exec() == QDialog::Accepted)
+    aFileName = aDialog->GetFileName();
+
+  return aFileName;
+}
+
+// =======================================================================
+// function : Communicator
+// purpose :
+// =======================================================================
+TInspector_Communicator* TInspector_OpenFileDialog::Communicator()
+{
+  if (!MyCommunicator)
+    MyCommunicator = new TInspector_Communicator();
+  return MyCommunicator;
+}
+
+// =======================================================================
+// function : GetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                                 TInspector_Communicator* theCommunicator,
+                                                                 QStringList& theFileNames)
+{
+  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+  TInspectorAPI_PreferencesDataMap aPreferencesItem;
+  aParameters->GetPreferences (thePluginName, aPreferencesItem);
+
+  for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
+  {
+    if (!anItemIt.Key().IsEqual("recently_opened_files"))
+      continue;
+    theFileNames = QString(anItemIt.Value().ToCString()).split(";", QString::SkipEmptyParts);
+    if (theFileNames.size() > RECENT_FILES_CACHE_SIZE)
+      for (int i = 0; i < theFileNames.size() - RECENT_FILES_CACHE_SIZE; i++)
+        theFileNames.removeFirst();
+    break;
+  }
+}
+
+// =======================================================================
+// function : SetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                                 TInspector_Communicator* theCommunicator,
+                                                                 QStringList& theFileNames)
+{
+  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+
+  TInspectorAPI_PreferencesDataMap aPreferencesItem;
+  aParameters->GetPreferences (thePluginName, aPreferencesItem);
+  aPreferencesItem.Bind ("recently_opened_files", TCollection_AsciiString (theFileNames.join (";").toUtf8().data()));
+
+  aParameters->SetPreferences (thePluginName, aPreferencesItem);
+}
+
+// =======================================================================
+// function : onSampleSelectionChanged
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
+                                                             const QItemSelection&)
+{
+  QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
+  if (!aSelectionModel)
+    return;
+  if (theSelected.isEmpty())
+    return;
+
+  QModelIndex anIndex = theSelected.first().indexes().first();
+  if (!anIndex.isValid())
+    return;
+
+  myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
+  accept();
+}
+
+// =======================================================================
+// function : onSelectClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onSelectClicked()
+{
+  QString anEnteredPath;
+  QString aDirName = mySelectedName->text();
+  if (!aDirName.isEmpty())
+  {
+    QDir aDir (aDirName);
+    if (aDir.exists())
+      anEnteredPath = aDirName;
+  }
+
+  QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
+
+  if (aFileName.isEmpty())
+    return; // do nothing, left the previous value
+
+
+  myFileName = aFileName;
+  accept();
+}
+
+// =======================================================================
+// function : onApplySelectClicked
+// purpose :
+// =======================================================================
+void TInspector_OpenFileDialog::onApplySelectClicked()
+{
+  QString aFileName = mySelectedName->text();
+
+  QFileInfo aFileInfo (aFileName);
+  if (!aFileInfo.exists() || !aFileInfo.isFile())
+    return;
+
+  myFileName = mySelectedName->text();
+  accept();
+}
+
+// =======================================================================
+// function : createTableView
+// purpose :
+// =======================================================================
+QTableView* TInspector_OpenFileDialog::createTableView (const QStringList& theFileNames)
+{
+  QTableView* aTableView = new QTableView (this);
+  aTableView->setFrameStyle (QFrame::NoFrame);
+  QPalette aPalette = aTableView->viewport()->palette();
+  QColor aWindowColor = aPalette.color (QPalette::Window);
+  aPalette.setBrush (QPalette::Base, aWindowColor);
+  aTableView->viewport()->setPalette (aPalette);
+
+  aTableView->horizontalHeader()->setVisible (false);
+  aTableView->verticalHeader()->setVisible (false);
+  aTableView->setGridStyle (Qt::NoPen);
+  aTableView->setModel (createModel (theFileNames));
+  aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
+                                                          aPalette.color (QPalette::Highlight)));
+  aTableView->viewport()->setAttribute (Qt::WA_Hover);
+  int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
+  aTableView->setRowHeight (0, aCellHeight);
+  int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
+  aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
+  QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
+  connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+           this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
+  aTableView->setSelectionModel (aSelectionModel);
+
+  return aTableView;
+}
+
+// =======================================================================
+// function : createModel
+// purpose :
+// =======================================================================
+QAbstractItemModel* TInspector_OpenFileDialog::createModel (const QStringList& theFileNames)
+{
+  TInspector_OpenFileViewModel* aModel = new TInspector_OpenFileViewModel (this);
+  aModel->Init (theFileNames);
+  return aModel;
+}
diff --git a/tools/TInspector/TInspector_OpenFileDialog.hxx b/tools/TInspector/TInspector_OpenFileDialog.hxx
new file mode 100644 (file)
index 0000000..9776c43
--- /dev/null
@@ -0,0 +1,116 @@
+// 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. 
+
+#ifndef TInspectorEXE_OpenFileDialog_H
+#define TInspectorEXE_OpenFileDialog_H
+
+#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
+
+#include <NCollection_DataMap.hxx>
+#include <NCollection_List.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QDialog>
+#include <QItemSelection>
+#include <QStringList>
+#include <Standard_WarningsRestore.hxx>
+
+class TInspector_Communicator;
+
+class QAbstractItemModel;
+class QLineEdit;
+class QPushButton;
+class QTableView;
+class QToolButton;
+class QWidget;
+
+//! \class TInspector_OpenFileDialog
+//! Control that contains table view of samples and line to select a file name from other directory.
+//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
+//! the import becomes active. Click on the button will open selected file if it is possible
+class TInspector_OpenFileDialog : public QDialog
+{
+  Q_OBJECT
+private:
+
+  //! Constructor
+  Standard_EXPORT TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
+
+public:
+
+  //! Destructor
+  virtual ~TInspector_OpenFileDialog() Standard_OVERRIDE {}
+
+  //! Opens this file dialog using for samples view the given directory and try to open new file
+  //! \param theParent a parent for the new dialog
+  //! \param theDataDirName path to default samples directory
+  //! \returns a file name from the open file dialog
+  Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
+
+  //! Returns selection name from the dialog
+  QString GetFileName() const { return myFileName; }
+
+  //! Returns communicator, if this is the first call, create a communicator instance
+  Standard_EXPORT static TInspector_Communicator* Communicator();
+
+  //! Returns preferences: previous opened documents.
+  //! \param thePluginName name of the plugin
+  //! \param theCommunicator source of preferences
+  //! \param theFileNames [out] container of recently opened file names
+  Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                            TInspector_Communicator* theCommunicator,
+                                                            QStringList& theFileNames);
+
+  //! Sets preferences: previous opened documents.
+  //! \param thePluginName name of the plugin
+  //! \param theCommunicator source of preferences
+  //! \param theFileNames container of recently opened file names to be set into communicator preferences
+  Standard_EXPORT static void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                            TInspector_Communicator* theCommunicator,
+                                                            QStringList& theFileNames);
+
+private slots:
+
+  //! Stores name of selected sample file
+  void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+  //! Opens file dialog to select a file name. Fills file name line, enable import button
+  void onSelectClicked();
+
+  //! Accepts open file dialog
+  void onApplySelectClicked();
+
+private:
+
+  //! Creates view of file names in samples directory
+  //! \param theFileNames a container of names
+  //! \return table view
+  QTableView* createTableView (const QStringList& theFileNames);
+
+  //! Creates view model and fills it by the file names
+  //! \param theFileNames a container of names
+  //! \return model
+  QAbstractItemModel* createModel (const QStringList& theFileNames);
+
+private:
+
+  QStringList myRecentlyOpenedFiles; //!< recently opened files
+  QString myFileName; //!< result file name
+  QTableView* mySamplesView; //!< view of sample file names
+  QLineEdit* mySelectedName; //!< alternative control to open file
+};
+
+#endif
diff --git a/tools/TInspector/TInspector_OpenFileViewModel.cxx b/tools/TInspector/TInspector_OpenFileViewModel.cxx
new file mode 100644 (file)
index 0000000..d1e208a
--- /dev/null
@@ -0,0 +1,75 @@
+// 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/TInspector_OpenFileViewModel.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFileInfo>
+#include <QIcon>
+#include <QPainter>
+#include <Standard_WarningsRestore.hxx>
+
+const int ICON_SIZE = 40;
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                                                const QModelIndex& theIndex) const
+{
+  // highlight cell
+  if (theOption.state & QStyle::State_MouseOver)
+    thePainter->fillRect (theOption.rect, myColor);
+
+  // action icon for all indices before the last one
+  QIcon anIcon (":folder_import.png");
+  QSize anIconSize (ICON_SIZE, ICON_SIZE);
+  int aDX = (theOption.rect.width() - anIconSize.width()) / 2;
+  int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
+  thePainter->drawPixmap (QRect (theOption.rect.left() + aDX,
+                          theOption.rect.top() + aMargin,
+                          anIconSize.width(),
+                          anIconSize.height()),
+                          anIcon.pixmap(anIconSize.width(), anIconSize.height()));
+  // default paint
+  QItemDelegate::paint (thePainter, theOption, theIndex);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TInspector_OpenFileViewModel::Init (const QStringList& theValues)
+{
+  myValues = theValues;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant TInspector_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
+{
+  switch (theRole)
+  {
+    case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
+    case Qt::ToolTipRole: return myValues[theIndex.column()];
+    case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
+    default: break;
+  }
+  return QVariant();
+}
diff --git a/tools/TInspector/TInspector_OpenFileViewModel.hxx b/tools/TInspector/TInspector_OpenFileViewModel.hxx
new file mode 100644 (file)
index 0000000..a7ec5b4
--- /dev/null
@@ -0,0 +1,98 @@
+// 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. 
+
+#ifndef TInspectorEXE_OpenFileViewModel_H
+#define TInspectorEXE_OpenFileViewModel_H
+
+#include <Standard_Macro.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QItemDelegate>
+#include <Standard_WarningsRestore.hxx>
+
+class QObject;
+class QPainter;
+
+//! \class TInspectorEXE_OpenFileItemDelegate
+//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
+class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
+{
+
+public:
+
+  //! Constructor
+  TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
+  : QItemDelegate (theParent), myColor(theHighlightColor) {}
+
+  //! Destructor
+  virtual ~TInspectorEXE_OpenFileItemDelegate() {}
+
+  //! Draws an icon in the cell
+  //! \param thePainter a painter
+  //! \param theOption a paint options
+  //! \param theIndex a view index
+  virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                      const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+private:
+
+  QColor myColor; //!< highlight color
+};
+
+//! \class TInspector_OpenFileViewModel
+//! Table model that visualizes container of string values (file names)
+//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
+class TInspector_OpenFileViewModel : public QAbstractTableModel
+{
+
+public:
+
+  //! Constructor
+  TInspector_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+  //! Destructor
+  virtual ~TInspector_OpenFileViewModel() {}
+
+  //! Store values
+  //! \param theValues a container of values to fill model
+  void Init (const QStringList& theValues);
+
+  //! 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 theIndex a model index
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+  //! Returns number of rows
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+  { (void)theParent; return 1; }
+
+  //! Returns number of columns
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+  { (void)theParent; return myValues.size(); }
+
+private:
+
+  QStringList myValues; //!< file names
+};
+
+#endif
index 0f1810eff745afba1839f963e5bb4701030b38d3..a46da81f24d2999d866e99cde79144e82b9b0641 100644 (file)
@@ -35,7 +35,7 @@ public:
   Standard_EXPORT TInspector_PluginParameters (TInspector_Window* theWindow);
 
   //! Destructor
-  virtual ~TInspector_PluginParameters() Standard_OVERRIDE {}
+  virtual ~TInspector_PluginParameters() {}
 
   //! Stores the parameters for plugin
   //! \param thePluginName a plugin name
@@ -62,10 +62,10 @@ public:
                                const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
    { myPreferences->SetPreferences (thePluginName, theItem); }
 
-  //! Store plugin preferences into a preferences file
+  //! Stores plugin preferences into a preferences file
   virtual void StorePreferences() Standard_OVERRIDE { myPreferences->StorePreferences(); }
 
-  //! Remove plugin preferences file
+  //! Removes plugin preferences file
   void RemovePreferences() { myPreferences->RemovePreferences(); }
 
 private:
index 141cf2d98e00194c572d45c0bfb8836101777abb..d0ebefc88e92dea8844c6111c2f071fa2e89f324 100644 (file)
@@ -57,17 +57,17 @@ public:
   void SetPreferences (const TCollection_AsciiString& thePluginName, const TInspectorAPI_PreferencesDataMap& theItem)
   { myLoadedPreferences.Bind(thePluginName, theItem); }
 
-  //! Store plugin preferences into a preferences file
+  //! Stores plugin preferences into a preferences file
   Standard_EXPORT void StorePreferences();
 
-  //! Remove plugin preferences file
+  //! Removes plugin preferences file
   Standard_EXPORT void RemovePreferences();
 
 private:
   //! Loads the directory preference file with filling internal container
   void loadPreferences();
 
-  //! clears all internal containers with information of already loaded file
+  //! Clears all internal containers with information of already loaded file
   void reset() { myLoadedPreferences.Clear(); myIsLoadedPreferences = Standard_False; }
 
   //! Reads plugin preferences and fill container
index 8bb89ab31a8e73bcf2590ec4c18b4cd33c861145..af22ab7709a3cc2d2b79157a9cc455069041b016 100644 (file)
@@ -83,7 +83,7 @@ TInspector_Window::TInspector_Window()
 
   myActionsWidget = new QToolButton(aCentralWidget);
   myActionsWidget->setPopupMode(QToolButton::InstantPopup);
-  myActionsWidget->setIcon (QIcon (":/icons/plugin_actions.png"));
+  myActionsWidget->setIcon (QIcon (":plugin_actions.png"));
   myActionsWidget->setIconSize (QSize (20, 20));
   QMenu* anActionsMenu = new QMenu(myActionsWidget);
   myActionsWidget->setMenu(anActionsMenu);
index 4e7e50bb7da224230f962a3dc9f4dee7d2ff306d..c0c802d0bf546697ef3e039d9f0c3d70db123418 100644 (file)
@@ -68,7 +68,7 @@ public:
   Standard_EXPORT TInspector_Window();
 
   //! Destructor
-  virtual ~TInspector_Window() Standard_OVERRIDE {}
+  virtual ~TInspector_Window() {}
 
   //! Appends the plugin names into internal conainer
   //! \param thePluginName a name of the plugin
@@ -102,7 +102,7 @@ public:
   //! \param thePluginName a name of the plugin
   Standard_EXPORT void ActivateTool (const TCollection_AsciiString& thePluginName);
 
-  //! Set item selected in the active plugin
+  //! Sets item selected in the active plugin
   //! \param theItemNames a container of name of items in plugin that should become selected
   Standard_EXPORT void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames);
 
@@ -149,7 +149,7 @@ public slots:
   //! Stores preferences (current state) of all plugins into a preferences file
   Standard_EXPORT void OnStorePreferences();
 
-  //! Remove preferences file
+  //! Removes preferences file
   Standard_EXPORT void OnRemovePreferences();
 
 protected slots:
@@ -180,7 +180,7 @@ protected:
   //! Applies desktop preferences to window
   void applyPreferences();
 
-  //! Generate default temp directory by 'TEMP' or 'TMP' environment variables
+  //! Generates default temp directory by 'TEMP' or 'TMP' environment variables
   //! \return generated path
   TCollection_AsciiString defaultTemporaryDirectory() const;
 
diff --git a/tools/TInspector/icons/folder_export.png b/tools/TInspector/icons/folder_export.png
new file mode 100644 (file)
index 0000000..5f45f99
Binary files /dev/null and b/tools/TInspector/icons/folder_export.png differ
diff --git a/tools/TInspector/icons/folder_import.png b/tools/TInspector/icons/folder_import.png
new file mode 100644 (file)
index 0000000..02743ab
Binary files /dev/null and b/tools/TInspector/icons/folder_import.png differ
diff --git a/tools/TInspector/icons/folder_open.png b/tools/TInspector/icons/folder_open.png
new file mode 100644 (file)
index 0000000..b0a139e
Binary files /dev/null and b/tools/TInspector/icons/folder_open.png differ
diff --git a/tools/TInspector/icons/item_algo_folder.png b/tools/TInspector/icons/item_algo_folder.png
deleted file mode 100644 (file)
index 078dd34..0000000
Binary files a/tools/TInspector/icons/item_algo_folder.png and /dev/null differ
index dcb881a01bfb43773d016fa2d811aa3fedc0fa04..63cf600d14b7772a4585db5ac4572addf2d75533 100644 (file)
@@ -3,4 +3,3 @@ TInspectorAPI_Communicator.hxx
 TInspectorAPI_PluginParameters.cxx
 TInspectorAPI_PluginParameters.hxx
 TInspectorAPI_PreferencesDataMap.hxx
-TInspectorAPI_Version.hxx
index b25f4dbf0bd6f37b5b35dedf9d624b5a33101031..9c9cf8dd4463d3720b358f3cc5e44a98fcb1a3a8 100644 (file)
 
 #include <NCollection_List.hxx>
 #include <Standard_Transient.hxx>
-#include <Standard_Version.hxx>
-#if OCC_VERSION_HEX > 0x060901
-  #include <Standard_Handle.hxx>
-#endif
+#include <Standard_Handle.hxx>
 #include <inspector/TInspectorAPI_PluginParameters.hxx>
 
 //! The Communicator is an interface that should be implemented for a separate plugin
 //! It will be placed in layout of the given parent. After the plugin is created, it is possible to
 //! set container of parameters into plugin to provide the plugin's initialization by some external
 //! objects(e.g. Interactive Context or OCAF Application). If the parameters are changed, it may be
-//! applyed in UpdateContent function. The communicator can change parameters in the following cases:
+//! applied in UpdateContent function. The communicator can change parameters in the following cases:
 //! - the plugin removes own processed parameters (e.g. file names, that was opened by the plugin)
 //! - the plugin sends some parameters to another plugin(by name) (e.g. shape to be analized)
 //!   (at the same time we should be careful here to do not change essential parameters of other plugins)
@@ -50,9 +47,9 @@ public:
   //! \param theParent a parent class
   Standard_EXPORT virtual void SetParent (void* theParent) = 0;
 
-  //! Provide container for actions available in inspector on general level
+  //! Provides container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
-  Standard_EXPORT virtual void FillActionsMenu (void* theMenu) { (void)theMenu; }
+  virtual void FillActionsMenu (void* theMenu) { (void)theMenu; }
 
   //! Returns plugin preferences, empty implementation by default
   virtual void GetPreferences (TInspectorAPI_PreferencesDataMap&) {}
index 9393949faf8b2da2d4bd7e59e805b0a83c5f445c..53132b4271b42ca4e6f13c8d86af0ad3ce3fa036 100644 (file)
 // commercial license or contractual agreement. 
 
 #include <inspector/TInspectorAPI_PluginParameters.hxx>
-#include <inspector/TInspectorAPI_Version.hxx>
 
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#else
-IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#endif
 
 // =======================================================================
 // function : SetParameters
@@ -275,7 +269,6 @@ void TInspectorAPI_PluginParameters::ParametersToShape (const TCollection_AsciiS
     return;
   anOrientationStr.Split (anOrientationStr.Length() - 1);
 
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
   TopAbs_Orientation anOrientation;
   if (!TopAbs::ShapeOrientationFromString (anOrientationStr.ToCString(), anOrientation))
     return;
@@ -284,7 +277,4 @@ void TInspectorAPI_PluginParameters::ParametersToShape (const TCollection_AsciiS
 
   theShape.Location (aLocation);
   theShape.Orientation (anOrientation);
-#else
-  (void)theValue; (void)theShape;
-#endif
 }
index c92b518bfc363ca955a53899e2c808b4e508d463..c7975cde3f7f13dd6ed8fb35651e91aa573359ef 100644 (file)
 
 #include <NCollection_DataMap.hxx>
 #include <NCollection_List.hxx>
-#include <Standard_Version.hxx>
 #include <Standard_Transient.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TopoDS_Shape.hxx>
 
 #include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
 
-class TInspectorAPI_PluginParameters;
-DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
-
 //! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
 //! it was not be loaded yet. There is a map of plugin name into plugin parameters.
 //! The parameters may be:
@@ -41,7 +37,7 @@ public:
   Standard_EXPORT TInspectorAPI_PluginParameters() {}
 
   //! Destructor
-  Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
+  Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() {}
 
   //! Stores the parameters for plugin
   //! \param thePluginName a plugin name
@@ -131,7 +127,7 @@ public:
   Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
                                                const TInspectorAPI_PreferencesDataMap& theItem) = 0;
 
-  //! Store plugin preferences into a preferences file
+  //! Stores plugin preferences into a preferences file
   Standard_EXPORT virtual void StorePreferences() = 0;
 
   //! Converts a Shape parameters excepting TShape into a string value
@@ -145,11 +141,7 @@ public:
   Standard_EXPORT static void ParametersToShape (const TCollection_AsciiString& theValue, TopoDS_Shape& theShape);
 
 
-#if OCC_VERSION_HEX <= 0x060901
-  DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
-#else
   DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
-#endif
 private:
   //! container of parameters
   NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
diff --git a/tools/TInspectorAPI/TInspectorAPI_Version.hxx b/tools/TInspectorAPI/TInspectorAPI_Version.hxx
deleted file mode 100644 (file)
index 88bcc11..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2018 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.
-
-/*======================================================================
-// 
-// Purpose:   Defines macros identifying current version of Inspector
-// The version is equal to current OCCT version and used to support compile compatibility
-// to previous OCCT versions interface.
-// To compile Inspector with earlier version of OCCT, change version variable here to needed OCCT version.
-//
-//            TINSPECTORAPI_VERSION_MAJOR       : (integer) number identifying major version 
-//            TINSPECTORAPI_VERSION_MINOR       : (integer) number identifying minor version 
-//            TINSPECTORAPI_VERSION_MAINTENANCE : (integer) number identifying maintenance version 
-//            TINSPECTORAPI_VERSION_HEX         : (hex)     complete number as hex, two positions per each of major, minor, and patch number 
-//            
-//======================================================================*/
-
-#ifndef _TInspectorAPI_Version_HeaderFile
-#define _TInspectorAPI_Version_HeaderFile
-
-#include <Standard_Version.hxx>
-
-// Primary definitions
-#define TINSPECTORAPI_VERSION_MAJOR         OCC_VERSION_MAJOR
-#define TINSPECTORAPI_VERSION_MINOR         OCC_VERSION_MINOR
-#define TINSPECTORAPI_VERSION_MAINTENANCE   0//OCC_VERSION_MAINTENANCE
-
-// Derived: complete version as hex (0x0'major'0'minor'0'maintenance')
-#define TINSPECTORAPI_VERSION_HEX    (TINSPECTORAPI_VERSION_MAJOR << 16 | TINSPECTORAPI_VERSION_MINOR << 8 | TINSPECTORAPI_VERSION_MAINTENANCE)
-
-#endif  /* _TInspectorAPI_Version_HeaderFile */
index 8f800f24cd68f57866d45db624e6f7bdeb91a8b7..83dde91d4d522c4aafb38d2afea3e6a32e7e841d 100644 (file)
@@ -1 +1,4 @@
-TKTInspector
\ No newline at end of file
+TKTInspector
+TKTInspectorAPI
+TKernel
+CSF_QT
\ No newline at end of file
index 68b0c79ed545b45db41f442e8a5eb9fd036fa454..44a1d285c2fb67a6a1c15eaa5365a7292bc67ea3 100644 (file)
@@ -1,7 +1,2 @@
 TInspectorEXE.cxx
-TInspectorEXE_OpenFileDialog.cxx
-TInspectorEXE_OpenFileDialog.hxx
-TInspectorEXE_OpenFileViewModel.cxx
-TInspectorEXE_OpenFileViewModel.hxx
-TInspectorEXE.qrc
 EXTERNLIB
diff --git a/tools/TInspectorEXE/PACKAGES b/tools/TInspectorEXE/PACKAGES
deleted file mode 100644 (file)
index 1736c7d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-TInspectorEXE
index 10dcf4b84574d3a18db5f9ce0310fec05736359c..73ab6963599cb315a6c134c2ac6de78d6c6af8d0 100644 (file)
@@ -14,7 +14,8 @@
 // commercial license or contractual agreement. 
 
 
-#include <inspector/TInspectorEXE_OpenFileDialog.hxx>
+#include <inspector/TInspector_OpenFileDialog.hxx>
+#include <inspector/TInspector_OpenButton.hxx>
 
 #include <inspector/TInspector_Communicator.hxx>
 
@@ -50,10 +51,10 @@ TCollection_AsciiString fileNameInDataDir (const TCollection_AsciiString& theEnv
 // purpose :
 // =======================================================================
 void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
-                               TInspectorEXE_OpenButton* theButtonControl)
+                               TInspector_OpenButton* theButtonControl)
 {
   QStringList aRecentlyOpenedFiles;
-  TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (theName, theCommunicator, aRecentlyOpenedFiles);
+  TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (theName, theCommunicator, aRecentlyOpenedFiles);
   TCollection_AsciiString aFileName, anAdditionalFileName;
   if (!aRecentlyOpenedFiles.isEmpty())
     aFileName = TCollection_AsciiString (aRecentlyOpenedFiles.last().toUtf8().data());
@@ -107,14 +108,14 @@ int main (int argc, char** argv)
   NCollection_List<Handle(Standard_Transient)> aParameters;
 
   // Create tool communicator
-  TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator();
+  TInspector_Communicator* aCommunicator = TInspector_OpenFileDialog::Communicator();
   if (!aCommunicator)
   {
     std::cout << "Communicator can not be created" << std::endl;
     return 0;
   }
 
-  TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0);
+  TInspector_OpenButton* aButtonControl = new TInspector_OpenButton (0);
   TCollection_AsciiString anActivatedPluginName;
   if (aPlugins.empty())
   {
diff --git a/tools/TInspectorEXE/TInspectorEXE.qrc b/tools/TInspectorEXE/TInspectorEXE.qrc
deleted file mode 100644 (file)
index 5b8eac8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-    <qresource prefix="/">
-        <file alias="folder_open.png">icons/folder_open.png</file>
-        <file alias="folder_import.png">icons/folder_import.png</file>
-    </qresource>
-</RCC>
diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx
deleted file mode 100644 (file)
index 2393827..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-// 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/TInspectorEXE_OpenFileDialog.hxx>
-#include <inspector/TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <inspector/TInspector_Communicator.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QCompleter>
-#include <QDir>
-#include <QFileDialog>
-#include <QFileSystemModel>
-#include <QItemSelectionModel>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QLineEdit>
-#include <QScrollBar>
-#include <QTableView>
-#include <QToolButton>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QWidget>
-#include <Standard_WarningsRestore.hxx>
-
-const int FONT_POINT_SIZE = 18;
-const int ICON_SIZE = 40;
-
-const int OPEN_DIALOG_WIDTH = 550;
-const int OPEN_DIALOG_HEIGHT = 200;
-
-const int MARGIN_DIALOG = 4;
-const int SPACING_DIALOG = 2;
-
-const int RECENT_FILES_CACHE_SIZE = 10;
-
-TInspector_Communicator* MyCommunicator;
-
-// =======================================================================
-// function : StartButton
-// purpose :
-// =======================================================================
-QPushButton* TInspectorEXE_OpenButton::StartButton()
-{
-  if (!myStartButton)
-  {
-    myStartButton = new QPushButton();
-    myStartButton->setIcon (QIcon (":folder_open.png"));
-    connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
-  }
-  return myStartButton;
-}
-
-// =======================================================================
-// function : onStartButtonClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenButton::onStartButtonClicked()
-{
-  QPushButton* aButton = (QPushButton*)sender();
-  TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
-  if (aPluginName.IsEmpty())
-    return;
-  
-  QStringList aPluginRecentlyOpenedFiles;
-  if (myRecentlyOpenedFiles.contains(aPluginName))
-  {
-    QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
-    for (int i = 0; i < aFileNames.size(); i++)
-    {
-      QFileInfo aFileInfo (aFileNames[i]);
-      if (aFileInfo.exists() && aFileInfo.isFile())
-        aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
-    }
-  }
-
-  QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
-  aFileName = QDir().toNativeSeparators (aFileName);
-  if (!aFileName.isEmpty()) {
-    QApplication::setOverrideCursor (Qt::WaitCursor);
-    TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
-
-    QFileInfo aFileInfo (aFileName);
-    if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
-    {
-      myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
-      for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
-        myRecentlyOpenedFiles[aPluginName].removeFirst();
-      TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
-        TInspectorEXE_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
-
-      TInspectorEXE_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
-    }
-
-    QApplication::restoreOverrideCursor();
-  }
-}
-
-// =======================================================================
-// function : changeMargins
-// purpose :
-// =======================================================================
-void changeMargins (QBoxLayout* theLayout)
-{
-  theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
-  theLayout->setSpacing (SPACING_DIALOG);
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
-: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
-{
-  setWindowTitle (tr ("Open File"));
-
-  QVBoxLayout* aDialogLay = new QVBoxLayout (this);
-  changeMargins (aDialogLay);
-
-  // Samples View
-  QGroupBox* aSamplesBox = new QGroupBox (this);
-  aSamplesBox->setTitle (tr ("Recent files"));
-  aDialogLay->addWidget (aSamplesBox);
-  QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
-  changeMargins (aSampleLay);
-  mySamplesView = createTableView (theRecentlyOpenedFiles);
-  aSampleLay->addWidget (mySamplesView);
-
-  // Select file
-  QGroupBox* aSelectFileBox = new QGroupBox (this);
-  aSelectFileBox->setTitle (tr ("Select file"));
-  aDialogLay->addWidget (aSelectFileBox);
-  QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
-  aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
-
-  mySelectedName = new QLineEdit (aSelectFileBox);
-  QCompleter* aCompleter = new QCompleter();
-  QFileSystemModel* aFileSystemModel = new QFileSystemModel;
-  aFileSystemModel->setRootPath (QDir::rootPath());
-  aCompleter->setModel (aFileSystemModel);
-  mySelectedName->setCompleter (aCompleter);
-  aSelectFileLay->addWidget (mySelectedName, 1, 0);
-
-  QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
-  aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
-  aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
-
-  connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
-  connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
-
-  resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
-}
-
-// =======================================================================
-// function : OpenFile
-// purpose :
-// =======================================================================
-QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
-{
-  QString aFileName;
-  TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog (theParent, theRecentlyOpenedFiles);
-  if (aDialog->exec() == QDialog::Accepted)
-    aFileName = aDialog->GetFileName();
-
-  return aFileName;
-}
-
-// =======================================================================
-// function : Communicator
-// purpose :
-// =======================================================================
-TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
-{
-  if (!MyCommunicator)
-    MyCommunicator = new TInspector_Communicator();
-  return MyCommunicator;
-}
-
-// =======================================================================
-// function : GetPluginRecentlyOpenedFiles
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
-                                                                 TInspector_Communicator* theCommunicator,
-                                                                 QStringList& theFileNames)
-{
-  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
-  TInspectorAPI_PreferencesDataMap aPreferencesItem;
-  aParameters->GetPreferences (thePluginName, aPreferencesItem);
-
-  for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
-  {
-    if (!anItemIt.Key().IsEqual("recently_opened_files"))
-      continue;
-    theFileNames = QString(anItemIt.Value().ToCString()).split(";", QString::SkipEmptyParts);
-    if (theFileNames.size() > RECENT_FILES_CACHE_SIZE)
-      for (int i = 0; i < theFileNames.size() - RECENT_FILES_CACHE_SIZE; i++)
-        theFileNames.removeFirst();
-    break;
-  }
-}
-
-// =======================================================================
-// function : SetPluginRecentlyOpenedFiles
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
-                                                                 TInspector_Communicator* theCommunicator,
-                                                                 QStringList& theFileNames)
-{
-  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
-
-  TInspectorAPI_PreferencesDataMap aPreferencesItem;
-  aParameters->GetPreferences (thePluginName, aPreferencesItem);
-  aPreferencesItem.Bind ("recently_opened_files", TCollection_AsciiString (theFileNames.join (";").toUtf8().data()));
-
-  aParameters->SetPreferences (thePluginName, aPreferencesItem);
-}
-
-// =======================================================================
-// function : onSampleSelectionChanged
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
-                                                             const QItemSelection&)
-{
-  QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
-  if (!aSelectionModel)
-    return;
-  if (theSelected.isEmpty())
-    return;
-
-  QModelIndex anIndex = theSelected.first().indexes().first();
-  if (!anIndex.isValid())
-    return;
-
-  myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
-  accept();
-}
-
-// =======================================================================
-// function : onSelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSelectClicked()
-{
-  QString anEnteredPath;
-  QString aDirName = mySelectedName->text();
-  if (!aDirName.isEmpty())
-  {
-    QDir aDir (aDirName);
-    if (aDir.exists())
-      anEnteredPath = aDirName;
-  }
-
-  QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
-
-  if (aFileName.isEmpty())
-    return; // do nothing, left the previous value
-
-
-  myFileName = aFileName;
-  accept();
-}
-
-// =======================================================================
-// function : onApplySelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
-{
-  QString aFileName = mySelectedName->text();
-
-  QFileInfo aFileInfo (aFileName);
-  if (!aFileInfo.exists() || !aFileInfo.isFile())
-    return;
-
-  myFileName = mySelectedName->text();
-  accept();
-}
-
-// =======================================================================
-// function : createTableView
-// purpose :
-// =======================================================================
-QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames)
-{
-  QTableView* aTableView = new QTableView (this);
-  aTableView->setFrameStyle (QFrame::NoFrame);
-  QPalette aPalette = aTableView->viewport()->palette();
-  QColor aWindowColor = aPalette.color (QPalette::Window);
-  aPalette.setBrush (QPalette::Base, aWindowColor);
-  aTableView->viewport()->setPalette (aPalette);
-
-  aTableView->horizontalHeader()->setVisible (false);
-  aTableView->verticalHeader()->setVisible (false);
-  aTableView->setGridStyle (Qt::NoPen);
-  aTableView->setModel (createModel (theFileNames));
-  aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
-                                                          aPalette.color (QPalette::Highlight)));
-  aTableView->viewport()->setAttribute (Qt::WA_Hover);
-  int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
-  aTableView->setRowHeight (0, aCellHeight);
-  int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
-  aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
-  QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
-  connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
-           this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
-  aTableView->setSelectionModel (aSelectionModel);
-
-  return aTableView;
-}
-
-// =======================================================================
-// function : createModel
-// purpose :
-// =======================================================================
-QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames)
-{
-  TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this);
-  aModel->Init (theFileNames);
-  return aModel;
-}
diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx
deleted file mode 100644 (file)
index b4d63ee..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-// 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. 
-
-#ifndef TInspectorEXE_OpenFileDialog_H
-#define TInspectorEXE_OpenFileDialog_H
-
-#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
-
-#include <NCollection_DataMap.hxx>
-#include <NCollection_List.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QDialog>
-#include <QItemSelection>
-#include <QStringList>
-#include <Standard_WarningsRestore.hxx>
-
-#include <map>
-
-class TInspector_Communicator;
-
-class QAbstractItemModel;
-class QLineEdit;
-class QPushButton;
-class QTableView;
-class QToolButton;
-class QWidget;
-
-//! \class TInspectorEXE_OpenButton
-//! Class that contains push button and the button processing. It obtains a file name from the default or current
-//! directory and gives the name into TInspector communicator
-//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
-class TInspectorEXE_OpenButton : public QObject
-{
-  Q_OBJECT
-
-public:
-
-  //! Constructor
-  TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {}
-
-  //! Destructor
-  virtual ~TInspectorEXE_OpenButton() {}
-
-  //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
-  QPushButton* StartButton();
-
-  //! Sets the default directory of plugin.
-  void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
-                                     const QStringList& theRecentlyOpenedFiles)
-  { myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
-
-private slots:
-
-  //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
-  void onStartButtonClicked();
-
-private:
-
-  QPushButton* myStartButton; //!< processed button
-  //!< plugins recently opened files
-  QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
-};
-
-//! \class TInspectorEXE_OpenFileDialog
-//! Control that contains table view of samples and line to select a file name from other directory.
-//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
-//! the import becomes active. Click on the button will open selected file if it is possible
-class TInspectorEXE_OpenFileDialog : public QDialog
-{
-  Q_OBJECT
-private:
-
-  //! Constructor
-  Standard_EXPORT TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
-
-public:
-
-  //! Destructor
-  virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {}
-
-  //! Opens this file dialog using for samples view the given directory and try to open new file
-  //! \param theParent a parent for the new dialog
-  //! \param theDataDirName path to default samples directory
-  //! \returns a file name from the open file dialog
-  Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
-
-  //! Returns selection name from the dialog
-  QString GetFileName() const { return myFileName; }
-
-  //! Returns communicator, if this is the first call, create a communicator instance
-  Standard_EXPORT static TInspector_Communicator* Communicator();
-
-  //! Returns preferences: previous opened documents.
-  //! \param thePluginName name of the plugin
-  //! \param theCommunicator source of preferences
-  //! \param theFileNames [out] container of recently opened file names
-  Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
-                                                            TInspector_Communicator* theCommunicator,
-                                                            QStringList& theFileNames);
-
-  //! Sets preferences: previous opened documents.
-  //! \param thePluginName name of the plugin
-  //! \param theCommunicator source of preferences
-  //! \param theFileNames container of recently opened file names to be set into communicator preferences
-  Standard_EXPORT static void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
-                                                            TInspector_Communicator* theCommunicator,
-                                                            QStringList& theFileNames);
-
-private slots:
-
-  //! Stores name of selected sample file
-  void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
-  //! Open file dialog to select a file name. Fills file name line, enable import button
-  void onSelectClicked();
-
-  //! Accepts open file dialog
-  void onApplySelectClicked();
-
-private:
-
-  //! Creates view of file names in samples directory
-  //! \param theFileNames a container of names
-  //! \return table view
-  QTableView* createTableView (const QStringList& theFileNames);
-
-  //! Creates view model and fills it by the file names
-  //! \param theFileNames a container of names
-  //! \return model
-  QAbstractItemModel* createModel (const QStringList& theFileNames);
-
-private:
-
-  QStringList myRecentlyOpenedFiles; //!< recently opened files
-  QString myFileName; //!< result file name
-  QTableView* mySamplesView; //! <view of sample file names
-  QLineEdit* mySelectedName; //!< alternative control to open file
-};
-
-#endif
diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx
deleted file mode 100644 (file)
index 03be935..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// 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/TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QApplication>
-#include <QFileInfo>
-#include <QIcon>
-#include <QPainter>
-#include <Standard_WarningsRestore.hxx>
-
-const int ICON_SIZE = 40;
-
-// =======================================================================
-// function : paint
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
-                                                const QModelIndex& theIndex) const
-{
-  // highlight cell
-  if (theOption.state & QStyle::State_MouseOver)
-    thePainter->fillRect (theOption.rect, myColor);
-
-  // action icon for all indices before the last one
-  QIcon anIcon (":folder_import.png");
-  QSize anIconSize (ICON_SIZE, ICON_SIZE);
-  int aDX = (theOption.rect.width() - anIconSize.width()) / 2;
-  int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
-  thePainter->drawPixmap (QRect (theOption.rect.left() + aDX,
-                          theOption.rect.top() + aMargin,
-                          anIconSize.width(),
-                          anIconSize.height()),
-                          anIcon.pixmap(anIconSize.width(), anIconSize.height()));
-  // default paint
-  QItemDelegate::paint (thePainter, theOption, theIndex);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
-{
-  myValues = theValues;
-}
-
-// =======================================================================
-// function : data
-// purpose :
-// =======================================================================
-QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
-{
-  switch (theRole)
-  {
-    case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
-    case Qt::ToolTipRole: return myValues[theIndex.column()];
-    case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
-    default: break;
-  }
-  return QVariant();
-}
diff --git a/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx b/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx
deleted file mode 100644 (file)
index 42b6604..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-// 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. 
-
-#ifndef TInspectorEXE_OpenFileViewModel_H
-#define TInspectorEXE_OpenFileViewModel_H
-
-#include <Standard_Macro.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAbstractTableModel>
-#include <QStringList>
-#include <QItemDelegate>
-#include <Standard_WarningsRestore.hxx>
-
-class QObject;
-class QPainter;
-
-//! \class TInspectorEXE_OpenFileItemDelegate
-//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
-class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
-{
-
-public:
-
-  //! Constructor
-  TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
-  : QItemDelegate (theParent), myColor(theHighlightColor) {}
-
-  //! Destructor
-  virtual ~TInspectorEXE_OpenFileItemDelegate() {}
-
-  //! Draw an icon in the cell
-  //! \param thePainter a painter
-  //! \param theOption a paint options
-  //! \param theIndex a view index
-  virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
-                      const QModelIndex& theIndex) const Standard_OVERRIDE;
-
-private:
-
-  QColor myColor; //!< highlight color
-};
-
-//! \class TInspectorEXE_OpenFileViewModel
-//! Table model that visualizes container of string values (file names)
-//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
-class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
-{
-
-public:
-
-  //! Constructor
-  TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
-
-  //! Destructor
-  virtual ~TInspectorEXE_OpenFileViewModel() {}
-
-  //! Store values
-  //! \param theValues a container of values to fill model
-  void Init (const QStringList& theValues);
-
-  //! 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 theIndex a model index
-  //! \param theRole a view role
-  //! \return value intepreted depending on the given role
-  virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
-  //! Returns number of rows
-  //! \param theParent an index of the parent item
-  //! \return an integer value
-  virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
-  { (void)theParent; return 1; }
-
-  //! Returns number of columns
-  //! \param theParent an index of the parent item
-  //! \return an integer value
-  virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
-  { (void)theParent; return myValues.size(); }
-
-private:
-
-  QStringList myValues; //!< file names
-};
-
-#endif
diff --git a/tools/TInspectorEXE/icons/folder_export.png b/tools/TInspectorEXE/icons/folder_export.png
deleted file mode 100644 (file)
index 5f45f99..0000000
Binary files a/tools/TInspectorEXE/icons/folder_export.png and /dev/null differ
diff --git a/tools/TInspectorEXE/icons/folder_import.png b/tools/TInspectorEXE/icons/folder_import.png
deleted file mode 100644 (file)
index 02743ab..0000000
Binary files a/tools/TInspectorEXE/icons/folder_import.png and /dev/null differ
diff --git a/tools/TInspectorEXE/icons/folder_open.png b/tools/TInspectorEXE/icons/folder_open.png
deleted file mode 100644 (file)
index b0a139e..0000000
Binary files a/tools/TInspectorEXE/icons/folder_open.png and /dev/null differ
index a028066963cd72347996d958a223167dc346ce9b..b9f14514bc25c15cba74853843f6adbee02196a0 100644 (file)
@@ -1,9 +1,11 @@
 TKTInspectorAPI
+TKernel
 TKMath
 TKBRep
 TKGeomBase
 TKG3d
 TKService
 TKTreeModel
+TKV3d
 TKView
 CSF_QT
index df0002f9afbd0fe4d4a95c77e1c51093a25cdeca..0e517c2551cee31cdb3c6f748f13f6741659bc36 100644 (file)
@@ -1,4 +1,8 @@
 TKG3d
 TKernel
 TKLCAF
-TKMath
\ No newline at end of file
+TKMath
+TKBRep
+TKTopAlgo
+TKPrim
+TKV3d
index 7cb3cd210e16873a2bd23d2e3002969b3fa6949b..72bf985bdeda8bc00483f2506529db251ee40397 100644 (file)
@@ -1 +1,3 @@
+Convert
 TInspectorAPI
+
index 62a89ecedfb2f2354f29bbeaf8e4f963bc4723fb..95df12df083f5d3f855a2abf5e891033f96fff4b 100644 (file)
@@ -2,6 +2,7 @@ TKDraw
 TKDCAF
 TKTInspector
 TKTInspectorAPI
+TKernel
 TKService
 TKV3d
 TKViewerTest
index 893b52c7088cbb8bccc069b59b185f9c86d5d38e..74b7426c2227d44ff69dc9a421f01b7602bb86ce 100644 (file)
@@ -1 +1,6 @@
+TKernel
+TKMath
+TKPrim
+TKTopAlgo
+TKTInspectorAPI
 CSF_QT
\ No newline at end of file
index b5f64414c04abc1fbee622a2aad729ba8071f5cc..72cf33304fd53133e63f80a04f682b53734f730b 100644 (file)
@@ -4,4 +4,5 @@ TKMath
 TKService
 TKOpenGl
 TKV3d
+TKTInspectorAPI
 CSF_QT
\ No newline at end of file
index e03dd5b61eb78598aaa35f157c299b0acde10bb0..c0abd7766ab10208f5166ca90932698d952e19c5 100644 (file)
@@ -40,6 +40,15 @@ Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
 
 static TInspector_Communicator* MyCommunicator;
 
+// =======================================================================
+// function : Communicator
+// purpose  : defines plugin library name by the command argument
+// =======================================================================
+TInspector_Communicator* ToolsDraw::Communicator()
+{
+  return MyCommunicator;
+}
+
 // =======================================================================
 // function : convertToPluginName
 // purpose  : defines plugin library name by the command argument
@@ -386,7 +395,7 @@ void ToolsDraw::Commands(Draw_Interpretor& theCommands)
     "\n\t\t:           Plugins order will be the same as defined in arguments."
     "\n\t\t:           'all' adds all available plugins in the order:"
     "\n\t\t:                 DFBrowser, VInspector and ShapeView."
-    "\n\t\t:           If at the first call this option is not used, 'all' option is applyed;"
+    "\n\t\t:           If at the first call this option is not used, 'all' option is applied;"
     "\n\t\t:  -activate activates the plugin in the tool view."
     "\n\t\t:           If at the first call this option is not used, the first plugin is activated;"
     "\n\t\t:  -shape initializes plugin/s by the shape object. If 'name' is empty, initializes all plugins;"
index b004ad50dfff3c3b0aa08c895dda28c972bbf780..9b5dcf529c172fc3dae9081a93512ce36b5ac553 100644 (file)
@@ -20,6 +20,8 @@
 #include <Draw_Interpretor.hxx>
 #include <Standard.hxx>
 
+class TInspector_Communicator;
+
 //! \class ToolsDraw
 //! \brief Registers DRAW commands to connect to TInspector tools
 class ToolsDraw
@@ -32,10 +34,13 @@ public:
   //! \param theDI Draw interpretor
   Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
 
-  //! Add all tools command in the Draw_Interpretor
+  //! Adds all tools command in the Draw_Interpretor
   //! \param theCommands
   Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
 
+  //! Returns default communicator used in DRAW commands
+  Standard_EXPORT static TInspector_Communicator* Communicator();
+
 private:
 };
 
index 2eeab8f369def8c80428efd6c31210a6423d1db7..45b20c9dc0a1ebd17035621e3efd3b34d7b075a8 100644 (file)
@@ -1,4 +1,3 @@
-TreeModel.hxx
 TreeModel.qrc
 TreeModel_ColumnType.hxx
 TreeModel_ContextMenu.cxx
@@ -6,7 +5,11 @@ TreeModel_ContextMenu.hxx
 TreeModel_HeaderSection.hxx
 TreeModel_ItemBase.cxx
 TreeModel_ItemBase.hxx
+TreeModel_ItemProperties.cxx
+TreeModel_ItemProperties.hxx
 TreeModel_ItemRole.hxx
+TreeModel_ItemStream.cxx
+TreeModel_ItemStream.hxx
 TreeModel_ModelBase.cxx
 TreeModel_ModelBase.hxx
 TreeModel_Tools.cxx
diff --git a/tools/TreeModel/TreeModel.hxx b/tools/TreeModel/TreeModel.hxx
deleted file mode 100644 (file)
index 30ba380..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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. 
-
-#ifndef TREEMODEL_H
-#define TREEMODEL_H
-
-#ifdef __TreeModel_DLL
-  #ifdef _WIN32
-    #define TREEMODEL_EXPORT __declspec(dllexport)
-  #else
-    #define TREEMODEL_EXPORT
-  #endif
-#else
-  #ifdef _WIN32
-    #define TREEMODEL_EXPORT __declspec(dllimport)
-  #else
-    #define TREEMODEL_EXPORT
-  #endif
-#endif
-
-#endif
index 925185a679259d2a504b3b897f943ecd5ff24b18..c6df4238b4e3c889b035e640c917f7bb98577e8f 100644 (file)
@@ -47,7 +47,7 @@ protected slots:
   void onColumnVisibilityChanged();
 
 private:
-  QTreeView* myTreeView;
+  QTreeView* myTreeView; //!< current tree view
 };
 
 #endif
index 5ea9ca1e4f0e9bc40b0af21825244d39f4216c92..6e84d7ea0691fb6e45754356a51427aa8b7a4fa9 100644 (file)
@@ -41,6 +41,11 @@ public:
   //! Destructor
   ~TreeModel_HeaderSection() {}
 
+  //! Returns whether the header section is not initialized with values.
+  //! The check is empty value of the name text
+  //! \return boolean value
+  bool IsEmpty() const { return myName.isEmpty(); }
+
   //! Sets text value
   //! \theName text value
   void SetName (const QString& theName) { myName = theName; }
@@ -69,10 +74,10 @@ public:
   bool IsItalic() const { return myIsItalic; }
 
 private:
-  QString myName;  //! text value
-  int myWidth; //! section width
-  bool myIsHidden; //! visibility
-  bool myIsItalic; //! italic
+  QString myName;  //!< text value
+  int myWidth; //!< section width
+  bool myIsHidden; //!< visibility
+  bool myIsItalic; //!< italic
 };
 
 #endif
index 464a788863675647b0713ff597f230ed15626299..38ef9b23cafe3040d988e2bba2545bc84aa7cd36 100644 (file)
 // commercial license or contractual agreement. 
 
 #include <inspector/TreeModel_ItemBase.hxx>
-
+#include <inspector/TreeModel_ItemProperties.hxx>
 #include <inspector/TreeModel_ItemRole.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
 
+#include <Standard_Dump.hxx>
 #include <Standard_WarningsDisable.hxx>
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
@@ -26,7 +28,7 @@
 // purpose :
 // =======================================================================
 TreeModel_ItemBase::TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
- : m_bInitialized (false)
+ : m_iStreamChildren (0), m_bInitialized (false)
 {
   m_pParent = theParent;
   m_iRow = theRow;
@@ -34,7 +36,7 @@ TreeModel_ItemBase::TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const i
 }
 
 // =======================================================================
-// function :  reset
+// function :  Reset
 // purpose :
 // =======================================================================
 void TreeModel_ItemBase::Reset()
@@ -46,7 +48,12 @@ void TreeModel_ItemBase::Reset()
       anItem->Reset();
   }
   m_bInitialized = false;
+  if (!myProperties.IsNull())
+  {
+    myProperties->Reset();
+  }
   myCachedValues.clear();
+  myStream.str ("");
 }
 
 // =======================================================================
@@ -55,7 +62,7 @@ void TreeModel_ItemBase::Reset()
 // =======================================================================
 void TreeModel_ItemBase::Reset (int theRole)
 {
-  if (!myCachedValues.contains (theRole))  
+  if (!myCachedValues.contains (theRole))
     return;
 
   myCachedValues.remove (theRole);
@@ -74,7 +81,11 @@ TreeModel_ItemBasePtr TreeModel_ItemBase::Child (int theRow, int theColumn, cons
 
   TreeModel_ItemBasePtr anItem;
   if (isToCreate) {
-    anItem = createChild (theRow, theColumn);
+    if (theRow < m_iStreamChildren)
+      anItem = TreeModel_ItemStream::CreateItem (currentItem(), theRow, theColumn);
+    else
+      anItem = createChild (theRow - m_iStreamChildren, theColumn);
+
     if (anItem)
       m_ChildItems[aPos] = anItem;
   }
@@ -99,8 +110,77 @@ 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 = initRowCount() + const_cast<TreeModel_ItemBase*>(this)->initStreamRowCount();
+  else
+    aValueToCache = initValue (theItemRole);
 
+  myCachedValues.insert (theItemRole, aValueToCache);
   return myCachedValues.contains (theItemRole) ? myCachedValues[theItemRole] : QVariant();
 }
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemBase::Init()
+{
+  m_bInitialized = true;
+
+  initStream(myStream);
+  initStreamRowCount();
+}
+
+// =======================================================================
+// function : Object
+// purpose :
+// =======================================================================
+const Handle(Standard_Transient)& TreeModel_ItemBase::Object() const
+{
+  static Handle(Standard_Transient) aNullObject;
+  return aNullObject;
+}
+
+// =======================================================================
+// function : initStreamRowCount
+// purpose :
+// =======================================================================
+int TreeModel_ItemBase::initStreamRowCount()
+{
+  int aStreamChildrenCount = 0;
+  if (Column() == 0)
+  {
+    Standard_SStream aStream;
+    initStream (aStream);
+    if (!Standard_Dump::Text (aStream).IsEmpty())
+    {
+      if (!myProperties)
+      {
+        myProperties = new TreeModel_ItemProperties();
+        myProperties->SetItem (currentItem());
+      }
+      myProperties->Init();
+      aStreamChildrenCount = myProperties->Children().Extent();
+    }
+  }
+  m_iStreamChildren = aStreamChildrenCount;
+  return m_iStreamChildren;
+}
+
+// =======================================================================
+// 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 Row(); }
+  }
+
+  return QVariant();
+}
index 82ba6dc360852223d811ddf764d788c6780848ab..99f7d210683d21c666ac7d8e94327e6c52df76f2 100644 (file)
 
 #include <Standard.hxx>
 #include <Standard_Macro.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_OStream.hxx>
+#include <Standard_SStream.hxx>
+
 #include <inspector/TreeModel_ItemRole.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -32,6 +36,7 @@
 #include <Standard_WarningsRestore.hxx>
 
 class TreeModel_ItemBase;
+class TreeModel_ItemProperties;
 
 typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> TreeModel_ItemBasePtr;
 
@@ -81,7 +86,11 @@ public:
 
   //! Sets the item internal initialized state to the true. If the item has internal values,
   //! there should be initialized here.
-  virtual void Init() { m_bInitialized = true; }
+  Standard_EXPORT virtual void Init();
+
+  //! Returns data object of the item.
+  //! \return object
+  Standard_EXPORT virtual const Handle(Standard_Transient)& Object() const;
 
   //! 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.
@@ -91,6 +100,16 @@ public:
   //! \param theRole an item role
   Standard_EXPORT virtual void Reset(int theRole);
 
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  const Standard_SStream& Stream() const { return myStream; }
+
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos,
+                          Standard_Integer& theLastPos) const
+  { (void)theSStream; (void)theStartPos; (void)theLastPos; return false; }
+
   //! Gets the parent of the item, or TreeModel_ItemBasePtr() if it has no parent.
   //! \return pointer to the item
   TreeModel_ItemBasePtr Parent() const { return m_pParent; };
@@ -115,7 +134,7 @@ public:
   //! Sets a custom value for the role in an internal cache
   //! \param theValue a value
   //! \param theRole a value role
-  void SetCustomData(const QVariant theValue, int theRole) { myCachedValues.insert (theRole, theValue); }
+  void SetCustomData(const QVariant& theValue, int theRole) { myCachedValues.insert (theRole, theValue); }
 
   //! Returns the data stored under the given role for the current item
   //! \param theIndex the item model index
@@ -127,18 +146,25 @@ public:
   //! \return the row count
   int rowCount() const { return cachedValue(TreeModel_ItemRole_RowCountRole).toInt(); }
 
+  //! Returns the item properties
+  const Handle(TreeModel_ItemProperties)& Properties() const { return myProperties; }
+
 protected:
 
   //! \param theParent the parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   Standard_EXPORT TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
 
+  //! Initializes 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
   //! \return the created item
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) = 0;
+  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn)
+  { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
 
   //! Wraps the currrent item by shared pointer
   //! \return the shared pointer to the current item
@@ -153,17 +179,29 @@ protected:
   //! \return number of children. It should be reimplemented in child
   virtual int initRowCount() const = 0;
 
-  //! Return data value for the role. It should be reimplemented in child
+  //! \return number of children. It should be reimplemented in child
+  Standard_EXPORT int initStreamRowCount();
+
+  //! Returns 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;
+
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  virtual void initStream (Standard_OStream& theOStream) const { (void)theOStream; }
+
+protected:
+  Handle(TreeModel_ItemProperties) myProperties; //!< the properties
+  int m_iStreamChildren; //!< the count of stream items
+  Standard_SStream myStream; //!< stream value
 
 private:
 
   typedef QHash< QPair<int, int>, TreeModel_ItemBasePtr > PositionToItemHash;
   PositionToItemHash m_ChildItems; //!< the hash of item children
 
-  QMap<int, QVariant> myCachedValues; //!< cached values, should be cleared by reset
+  mutable QMap<int, QVariant> myCachedValues; //!< cached values, should be cleared by reset
   TreeModel_ItemBasePtr m_pParent; //!< the parent item
   int m_iRow;          //!< the item row position in the parent item
   int m_iColumn;       //!< the item column position in the parent item
diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx
new file mode 100644 (file)
index 0000000..631d2f2
--- /dev/null
@@ -0,0 +1,232 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <gp_XYZ.hxx>
+#include <Standard_Dump.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient)
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Init ()
+{
+  myRowValues.Clear();
+
+  const Standard_SStream& aStream = Item()->Stream();
+
+  NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aValues;
+  TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream);
+  Standard_Dump::SplitJson (aStreamText, aValues);
+
+  TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(Item());
+  TCollection_AsciiString aKey;
+  Standard_DumpValue aKeyValue;
+  if (!aStreamParent)
+  {
+    const Handle(Standard_Transient)& anItemObject = Item()->Object();
+    aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name();
+    aKeyValue = Standard_DumpValue (aStreamText, 1);
+
+    myKey = aKey;
+    myStreamValue = aKeyValue;
+  }
+  else
+  {
+    TCollection_AsciiString aValue;
+    if (Item()->Parent())
+    {
+      const Handle(TreeModel_ItemProperties)& aParentProperties = Item()->Parent()->Properties();
+      if (aParentProperties)
+        aParentProperties->ChildStream (Item()->Row(), aKey, aKeyValue);
+    }
+    myKey = aKey;
+    myStreamValue = aKeyValue;
+
+    aValues.Clear();
+    Standard_Dump::SplitJson (myStreamValue.myValue, aValues);
+  }
+
+  for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++)
+  {
+    Standard_DumpValue aValue = aValues.FindFromIndex (anIndex);
+    if (Standard_Dump::HasChildKey (aValue.myValue))
+      myChildren.Add (aValues.FindKey (anIndex), aValue);
+    else
+    {
+      TreeModel_RowValue aRowValue (aValue.myStartPosition, aValues.FindKey (anIndex).ToCString(), aValue.myValue.ToCString());
+      myRowValues.Add (myRowValues.Size() + 1, aRowValue);
+    }
+  }
+  if (myRowValues.Size() == 1)
+  {
+    Quantity_Color aColor;
+    if (Convert_Tools::ConvertStreamToColor (aStream, aColor))
+    {
+      Standard_Real aRed, aGreen, aBlue;
+      aColor.Values (aRed, aGreen, aBlue, Quantity_TOC_sRGB);
+
+      int aDelta = 255;
+      myRowValues.ChangeFromIndex (1).CustomValues.insert ((int)Qt::BackgroundRole, QColor((int)(aRed * aDelta),
+        (int)(aGreen * aDelta), (int)(aBlue * aDelta)));
+    }
+  }
+}
+
+// =======================================================================
+// function :  Reset
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Reset()
+{
+  myKey = "";
+  myStreamValue = Standard_DumpValue();
+
+  myChildren.Clear();
+  myRowValues.Clear();
+}
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+int TreeModel_ItemProperties::RowCount() const
+{
+  return RowValues().Size();
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn, int theRole) const
+{
+  if (theColumn == 1 && theRole == Qt::BackgroundRole)
+  {
+    const QMap<int, QVariant>& aCachedValues = RowValues().FindFromIndex (theRow + 1).CustomValues;
+    if (aCachedValues.contains ((int)theRole))
+      return aCachedValues[(int)theRole];
+  }
+
+  if (theRole == Qt::FontRole) // method name is in italic
+  {
+    if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+    {
+      QFont aFont = qApp->font();
+      aFont.setItalic (true);
+      return aFont;
+    }
+  }
+  if (theRole == Qt::ForegroundRole)
+  {
+    if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+      return QColor (Qt::darkGray).darker(150);
+  }
+
+  if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
+  {
+    if (theColumn == 0) return RowValues().FindFromIndex (theRow + 1).Key;
+    else if (theColumn == 1) return RowValues().FindFromIndex (theRow + 1).Value;
+  }
+
+  return QVariant();
+}
+
+// =======================================================================
+// function : EditType
+// purpose :
+// =======================================================================
+ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int theColumn) const
+{
+  if (theColumn == 0)
+    return ViewControl_EditType_None;
+
+  return ViewControl_EditType_Line;
+}
+
+// =======================================================================
+// function : SetData
+// purpose :
+// =======================================================================
+bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColumn, const QVariant& /*theValue*/, int)
+{
+  if (theColumn == 0)
+    return false;
+  return false;
+}
+
+// =======================================================================
+// function : Presentations
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
+{
+  const Standard_SStream& aStream = Item()->Stream();
+  Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations);
+}
+
+// =======================================================================
+// function : TableFlags
+// purpose :
+// =======================================================================
+Qt::ItemFlags TreeModel_ItemProperties::TableFlags (const int, const int theColumn) const
+{
+  Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+
+  if (theColumn == 1)
+    aFlags = aFlags | Qt::ItemIsEditable;
+
+  return aFlags;
+}
+
+// =======================================================================
+// function : ChildStream
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::ChildStream (const int theRowId,
+                                            TCollection_AsciiString& theKey,
+                                            Standard_DumpValue& theValue) const
+{
+  if (myChildren.Size() <= theRowId)
+    return;
+
+  theKey = myChildren.FindKey (theRowId + 1);
+  theValue = myChildren.FindFromIndex (theRowId + 1);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void TreeModel_ItemProperties::initItem() const
+{
+  if (!Item())
+    return;
+  if (Item()->IsInitialized())
+    return;
+  Item()->Init();
+}
diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx
new file mode 100644 (file)
index 0000000..7f498d7
--- /dev/null
@@ -0,0 +1,162 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_ItemProperties_H
+#define TreeModel_ItemProperties_H
+
+#include <Standard.hxx>
+#include <Standard_Dump.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Type.hxx>
+#include <Standard_Transient.hxx>
+
+#include <NCollection_IndexedDataMap.hxx>
+#include <NCollection_IndexedMap.hxx>
+#include <NCollection_List.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+#include <inspector/ViewControl_EditType.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class TreeModel_ItemProperties
+//! Class to manipulate properties of tree item. The properties are organized in table structure
+class TreeModel_ItemProperties : public Standard_Transient
+{
+  //! enum defined the dimension type
+  enum TreeModel_DimType
+  {
+    TreeModel_DimType_Rows,   //!< defines number of rows
+    TreeModel_DimType_Columns //!< defines number of columns
+  };
+
+  //! container of values in a row of property table
+  struct TreeModel_RowValue
+  {
+    TreeModel_RowValue (const Standard_Integer theValueStartPosition, const QVariant& theKey, QVariant theValue)
+    : ValueStartPosition (theValueStartPosition), Key (theKey), Value (theValue) {}
+
+    Standard_Integer ValueStartPosition; //!< start position of the key
+    QVariant Key; //!< value in the first column
+    QVariant Value; //!< value in the second column
+    QMap<int, QVariant> CustomValues; //!< custom values, e.g. key is Background, value is a defined color
+  };
+
+public:
+  //! Constructor
+  TreeModel_ItemProperties() {}
+
+  //! Destructor
+  ~TreeModel_ItemProperties() {}
+
+  //! Sets the current item
+  void SetItem (const TreeModel_ItemBasePtr& theItem) { myItem = theItem; }
+
+  //! Returns the current item
+  TreeModel_ItemBasePtr Item() const { return myItem; }
+
+  //! Fills internal containers by item stream values
+  Standard_EXPORT void Init();
+
+  //! If the item has internal values, there should be reseted here.
+  Standard_EXPORT virtual void Reset();
+
+  //! Returns number of table rows
+  //! \return an integer value
+  Standard_EXPORT int RowCount() const;
+
+  //! Returns number of table columns
+  //! \return an integer value
+  int ColumnCount() const { return 2; }
+
+  //! Returns content of the model index for the given role, it is obtained from internal container of values
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return value interpreted depending on the given role
+  Standard_EXPORT QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
+
+  //! Returns type of edit control for the model index. By default, it is an empty control
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \return edit type
+  Standard_EXPORT ViewControl_EditType EditType (const int theRow, const int theColumn) const;
+
+  //! Sets content of the model index for the given role, it is applied to internal container of values
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return true if the value is changed
+  Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
+                                        int theRole = Qt::DisplayRole);
+
+  //! Returns presentation of the attribute to be visualized in the view
+  //! \thePresentations [out] container of presentation handles to be visualized
+  Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& 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 TableFlags (const int theRow, const int theColumn) const;
+
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT void ChildStream (const int theRowId,
+                                    TCollection_AsciiString& theKey,
+                                    Standard_DumpValue& theValue) const;
+
+  //! Returns data object of the item.
+  //! \return object key
+  const TCollection_AsciiString& Key() const { return myKey; }
+
+  //! Returns stream value of the item.
+  //! \return value
+  const TCollection_AsciiString& StreamValue() const { return myStreamValue.myValue; }
+
+  //! Returns children stream values
+  //const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& Values() const { initItem(); return myValues; }
+
+  //! Returns children stream values
+  const NCollection_IndexedDataMap<Standard_Integer, TreeModel_RowValue>& RowValues() const { initItem(); return myRowValues; }
+
+  //! Returns children stream values
+  const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& Children() const { initItem(); return myChildren; }
+
+  DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient)
+
+protected:
+  //! Initializes the current item. It creates a backup of the specific item information
+  Standard_EXPORT void initItem() const;
+
+private:
+  TreeModel_ItemBasePtr myItem; //!< current item
+
+  TCollection_AsciiString myKey; //!< the item key
+  Standard_DumpValue myStreamValue; //!< the stream value
+  NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> myChildren; //!< the children
+  NCollection_IndexedDataMap<Standard_Integer, TreeModel_RowValue> myRowValues; //!< the values
+};
+
+#endif
\ No newline at end of file
diff --git a/tools/TreeModel/TreeModel_ItemStream.cxx b/tools/TreeModel/TreeModel_ItemStream.cxx
new file mode 100644 (file)
index 0000000..efa8b36
--- /dev/null
@@ -0,0 +1,120 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_ItemStream.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+
+#include <Standard_Dump.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TreeModel_ItemStream::TreeModel_ItemStream (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn)
+{
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::Init()
+{
+  TreeModel_ItemBase::Init();
+
+  int aStreamChildrenCount = 0;
+  if (Column() == 0)
+  {
+    if (!myProperties)
+    {
+      myProperties = new TreeModel_ItemProperties();
+      myProperties->SetItem (currentItem());
+    }
+    myProperties->Init();
+    aStreamChildrenCount = myProperties->Children().Extent();
+  }
+  m_iStreamChildren = aStreamChildrenCount;
+  initStream (myStream);
+}
+
+// =======================================================================
+// function : Rest
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::Reset()
+{
+  myStream.str ("");
+  TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemStream::initValue (const int theItemRole) const
+{
+  QVariant aParentValue = TreeModel_ItemBase::initValue (theItemRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
+  if (Column() != 0)
+    return QVariant();
+
+  if (theItemRole == Qt::ForegroundRole)
+    return QColor (Qt::darkBlue);
+
+  if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+    return QVariant();
+
+  switch (Column())
+  {
+    case 0: return Properties() ? Properties()->Key().ToCString() : "";
+  }
+  return QVariant();
+}
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::initStream (Standard_OStream& theOStream) const
+{
+  if (!Properties())
+    return;
+
+  theOStream << Properties()->StreamValue();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void TreeModel_ItemStream::initItem() const
+{
+  if (IsInitialized())
+    return;
+  const_cast<TreeModel_ItemStream*>(this)->Init();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr TreeModel_ItemStream::createChild (int theRow, int theColumn)
+{
+  return TreeModel_ItemStream::CreateItem (currentItem(), theRow, theColumn);
+}
diff --git a/tools/TreeModel/TreeModel_ItemStream.hxx b/tools/TreeModel/TreeModel_ItemStream.hxx
new file mode 100644 (file)
index 0000000..3d3f13e
--- /dev/null
@@ -0,0 +1,89 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_ItemStream_H
+#define TreeModel_ItemStream_H
+
+#include <Standard.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+
+class TreeModel_ItemProperties;
+class TreeModel_ItemStream;
+
+typedef QExplicitlySharedDataPointer<TreeModel_ItemStream> TreeModel_ItemStreamPtr;
+
+//! \class TreeModel_ItemStream
+//! Parent item, that corresponds to AIS_InteractiveContext
+//! Children of the item are:
+//! - "Property" item to show context attributes such as selection filters and drawer properties
+//! - presentation items to show all interactive elements displayed/erased in the context
+class TreeModel_ItemStream : public TreeModel_ItemBase
+{
+public:
+
+  //! Creates an item wrapped by a shared pointer
+  static TreeModel_ItemStreamPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+  { return TreeModel_ItemStreamPtr (new TreeModel_ItemStream (theParent, theRow, theColumn)); }
+
+  //! Destructor
+  virtual ~TreeModel_ItemStream() {}
+
+  //! Sets the item internal initialized state to the true. If the item has internal values,
+  //! there should be initialized here.
+  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+  //! 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() Standard_OVERRIDE;
+
+  //! Returns number of displayed presentations
+  //! \return rows count
+  virtual int initRowCount() const Standard_OVERRIDE { initItem(); return 0; }
+
+  //! Returns item information for the given role. Fills internal container if it was not filled yet
+  //! \param theItemRole a value role
+  //! \return the value
+  Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const;
+
+  //! Initializes the current item. It creates a backup of the specific item information
+  //! Does nothing as context has been already set into item
+  Standard_EXPORT virtual void initItem() const Standard_OVERRIDE;
+
+protected:
+
+  //! Creates a child item in the given position.
+  //! \param theRow the child row position
+  //! \param theColumn the child column position
+  //! \return the created item
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+  //! Constructor
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
+  Standard_EXPORT TreeModel_ItemStream(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+};
+
+#endif
index 72acad8d01514a9419014454165921cb94519df9..a87cbe662ee767d024f82a581eae42c29b0bf807 100644 (file)
 #include <inspector/TreeModel_Tools.hxx>
 #include <inspector/TreeModel_VisibilityState.hxx>
 
+#include <Standard_Transient.hxx>
+
 #include <Standard_WarningsDisable.hxx>
 #include <QIcon>
 #include <Standard_WarningsRestore.hxx>
 
+const int COLUMN_NAME_WIDTH = 260;
+const int COLUMN_SIZE_WIDTH = 30;
+
 // =======================================================================
 // function : Constructor
 // purpose :
 // =======================================================================
 TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
-: QAbstractItemModel (theParent), m_pRootItem (0), m_pUseVisibilityColumn (false),
+: QAbstractItemModel (theParent), m_pUseVisibilityColumn (false),
   myVisibilityState (0)
 {
+  myVisibleIcon = QIcon (":/icons/item_visible.png");
+  myInvisibleIcon = QIcon (":/icons/item_invisible.png");
+}
+
+// =======================================================================
+// function :  InitColumns
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::InitColumns()
+{
+  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
+  SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
+  SetHeaderItem (2, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
 }
 
 // =======================================================================
@@ -104,14 +122,18 @@ QVariant TreeModel_ModelBase::data (const QModelIndex& theIndex, int theRole) co
     if (!myVisibilityState || !myVisibilityState->CanBeVisible (theIndex))
       return QVariant();
 
-    QVariant aValue = QIcon (myVisibilityState->IsVisible (theIndex) ? ":/icons/item_visible.png"
-                                                                     : ":/icons/item_invisible.png");
+    QVariant aValue = myVisibilityState->IsVisible (theIndex) ? myVisibleIcon : myInvisibleIcon;
     anItem->SetCustomData (aValue, theRole);
     return aValue;
   }
 
   TreeModel_ItemBasePtr anItem = GetItemByIndex (theIndex);
-  return anItem->data (theIndex, theRole);
+  QVariant anItemData = anItem->data (theIndex, theRole);
+
+  if (anItemData.isNull() && theRole == Qt::BackgroundRole && myHighlightedIndices.contains (theIndex))
+    anItemData = TreeModel_Tools::LightHighlightColor();
+
+  return anItemData;
 }
 
 // =======================================================================
@@ -174,6 +196,9 @@ int TreeModel_ModelBase::rowCount (const QModelIndex& theParent) const
   else
     aParentItem = GetItemByIndex (theParent);
 
+  if (!aParentItem)
+    return 0;
+
   return aParentItem ? aParentItem->rowCount() : 0;
 }
 
@@ -207,21 +232,76 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
 }
 
 // =======================================================================
-// function : SingleSelected
+// function : SetHeaderItem
 // purpose :
 // =======================================================================
-QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
-                                                 const Qt::Orientation theOrientation)
+void TreeModel_ModelBase::SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
+{
+  if (theSection.IsEmpty())
+  {
+    // remove section
+    myHeaderValues.remove (theColumnId);
+    myRootItems.remove (theColumnId);
+  }
+
+  myHeaderValues[theColumnId] = theSection;
+  createRoot (theColumnId);
+}
+
+// =======================================================================
+// function : Selected
+// purpose :
+// =======================================================================
+QModelIndexList TreeModel_ModelBase::Selected (const QModelIndexList& theIndices, const int theCellId,
+                                               const Qt::Orientation theOrientation)
 {
-  QModelIndexList aFirstColumnSelectedIndices;
+  QModelIndexList aSelected;
   for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
   {
     QModelIndex anIndex = *anIndicesIt;
     if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
         (theOrientation == Qt::Vertical && anIndex.row() == theCellId))
-      aFirstColumnSelectedIndices.append (anIndex);
+      aSelected.append (anIndex);
   }
-  return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
+  return aSelected;
+}
+
+// =======================================================================
+// function : SingleSelected
+// purpose :
+// =======================================================================
+QModelIndex TreeModel_ModelBase::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
+                                                 const Qt::Orientation theOrientation)
+{
+  QModelIndexList aSelected = Selected (theIndices, theCellId, theOrientation);
+  return aSelected.size() == 1 ? aSelected.first() : QModelIndex();
+}
+
+// =======================================================================
+// function :  SelectedItems
+// purpose :
+// =======================================================================
+QList<TreeModel_ItemBasePtr> TreeModel_ModelBase::SelectedItems (const QModelIndexList& theIndices)
+{
+  QList<TreeModel_ItemBasePtr> anItems;
+
+  for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
+  {
+    TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
+    if (!anItem || anItems.contains (anItem))
+      continue;
+    anItems.append (anItem);
+  }
+  return anItems;
+}
+
+// =======================================================================
+// function : createRoot
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::createRoot (const int theColumnId)
+{
+  myRootItems.insert (theColumnId, createRootItem (theColumnId));
 }
 
 // =======================================================================
index d304c164e5ca3c4b2a9feecb3776cab402f902de..b8a31e903ec77565087ca2b67baf225354856d4d 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>
@@ -48,6 +50,10 @@ public:
   //! Destructor
   virtual ~TreeModel_ModelBase() {}
 
+  //! Creates model columns and root items.
+  //! Default columns are: [0] - Name, [1] - Visibility, [2] - Row
+  Standard_EXPORT virtual void InitColumns();
+
   //! Returns the item shared pointer by the model index
   //! if it is in the index internal pointer
   //! @param theIndex a model index
@@ -59,7 +65,7 @@ public:
 
   //! Returns the model root item.
   //! It is realized for OCAFBrowser
-  virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const { (void)theColumn; return m_pRootItem; }
+  TreeModel_ItemBasePtr RootItem (const int theColumn) const { return myRootItems[theColumn]; }
 
   //! Emits the layoutChanged signal from outside of this class
   Standard_EXPORT void EmitLayoutChanged();
@@ -76,14 +82,21 @@ public:
   //! \param theState state
   bool IsUseVisibilityColumn() const { return m_pUseVisibilityColumn; }
 
-  //!< Fills visibility state checker
-  //!< \param theController the checker interface
+  //! Fills visibility state checker
+  //! \param theController the checker interface
   void SetVisibilityState (TreeModel_VisibilityState* theController) { myVisibilityState = theController; }
 
-  //!< Returns visibility state checker
-  //!< \return the checker interface
+  //! Returns visibility state checker
+  //! \return the checker interface
   TreeModel_VisibilityState* GetVisibilityState () const { return myVisibilityState; }
 
+  //! Returns true if the tree view model contains highlighted items. This highlight is set manually.
+  bool HasHighlighted() { return !myHighlightedIndices.isEmpty(); }
+
+  //! Sets items of the indices highlighted in the model.
+  //! \param theIndices a list of tree model indices
+  void SetHighlighted (const QModelIndexList& theIndices = QModelIndexList()) { myHighlightedIndices = theIndices; }
+
   //! Returns the index of the item in the model specified by the given row, column and parent index.
   //! Saves an internal pointer at the createIndex. This pointer is a shared pointer to the class,
   //! that realizes a base item interface. If the parent is invalid, a root item is used, otherwise a new item
@@ -130,11 +143,10 @@ public:
   //! \return header section values container
   TreeModel_HeaderSection GetHeaderItem (const int theColumnId) const { return myHeaderValues[theColumnId]; }
 
-  //! Set header properties item.
+  //! Sets header properties item.
   //! \param theColumnId a column index
   //! \param theSection a section value
-  void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
-  { myHeaderValues[theColumnId] = theSection; createRootItem (theColumnId); }
+  Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
 
   //! Returns count of columns in the model
   //! \param theParent an index of the parent item
@@ -146,6 +158,14 @@ public:
   //! \return integer value
   static int ColumnVisibilityWidth() { return 20; }
 
+  //! Returns selected items in the cell of given orientation.
+  //! \param theIndices a container of selected indices
+  //! \param theCellId column index if orientation is horizontal, row index otherwise
+  //! \param theOrientation an orientation to apply the cell index
+  //! \return model indices from the list
+  Standard_EXPORT static QModelIndexList Selected (const QModelIndexList& theIndices, const int theCellId,
+                                                   const Qt::Orientation theOrientation = Qt::Horizontal);
+
   //! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
   //! in the cell id colum, one row should be selected.
   //! \param theIndices a container of selected indices
@@ -155,24 +175,38 @@ public:
   Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
                                                      const Qt::Orientation theOrientation = Qt::Horizontal);
 
+  //! Returns selected tree model items for indices.
+  //! \param theIndices a container of selected indices
+  //! \return model items from the list
+  Standard_EXPORT static QList<TreeModel_ItemBasePtr> SelectedItems (const QModelIndexList& theIndices);
+
 protected:
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) = 0;
+  virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0;
 
   //! Converts the item shared pointer to void* type
   //! \param theItem
   //!  \return an item pointer
   Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem);
 
+private:
+  //! Creates root item
+  //! \param theColumnId index of a column
+  Standard_EXPORT void createRoot (const int theColumnId);
+
 protected:
 
-  TreeModel_ItemBasePtr m_pRootItem; //!< the model root item. It should be created in the
+  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
   QMap<int, TreeModel_HeaderSection> myHeaderValues; //!< header values
   //!< model subclass. The model is fulfilled by this item content
 
   bool m_pUseVisibilityColumn; //!< the state whether column=0 is reserved for Visibility state
   TreeModel_VisibilityState* myVisibilityState; //!< the interface of item visibility
+  QIcon myVisibleIcon; //!< icon of visible state
+  QIcon myInvisibleIcon; //!< icon of invisible state
+
+  QModelIndexList myHighlightedIndices; //!< tree model indices that should be visualized as highlighted
 };
 
 #endif
index c1b217b529836955a55e08c3d6597d1c5e33730a..e3d8b2afa54f7d917b1ec5861f55a0e0751314c1 100644 (file)
@@ -172,13 +172,7 @@ void TreeModel_Tools::UseVisibilityColumn (QTreeView* theTreeView, const bool th
   TreeModel_ModelBase* aModel = dynamic_cast<TreeModel_ModelBase*> (theTreeView->model());
   aModel->SetHeaderItem (TreeModel_ColumnType_Visibility,
     TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
-
-  TreeModel_VisibilityState* aVisibilityState = aModel->GetVisibilityState ();
-
-  aModel->SetUseVisibilityColumn (true);
-  if (theActive && aVisibilityState)
-    QObject::connect (theTreeView, SIGNAL (clicked (const QModelIndex&)), 
-                      aVisibilityState, SLOT (OnClicked(const QModelIndex&)));
+  aModel->SetUseVisibilityColumn (theActive);
 }
 
 // =======================================================================
@@ -211,3 +205,53 @@ QString TreeModel_Tools::CutString (const QString& theText, const int theWidth,
 
   return aLength < theText.length() ? theText.mid (0, aLength) + theTail : theText;
 }
+
+// =======================================================================
+// function : LightHighlightColor
+// purpose :
+// =======================================================================
+QColor TreeModel_Tools::LightHighlightColor()
+{
+  QWidget aWidget;
+  QPalette aPalette = aWidget.palette();
+  return aPalette.highlight().color().lighter();
+}
+
+// =======================================================================
+// function : SetExpandedTo
+// purpose :
+// =======================================================================
+void TreeModel_Tools::SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex)
+{
+  QAbstractItemModel* aModel = theTreeView->model();
+
+  QModelIndex aParent = aModel->parent (theIndex);
+  while (aParent.isValid())
+  {
+    theTreeView->setExpanded (aParent, true);
+    aParent = aModel->parent (aParent);
+  }
+}
+
+// =======================================================================
+// function : setExpanded
+// purpose :
+// =======================================================================
+void TreeModel_Tools::SetExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
+                                   int& theLevels)
+{
+  bool isToExpand = theLevels == -1 || theLevels > 0;
+  if (!isToExpand)
+    return;
+
+  theTreeView->setExpanded (theIndex, isExpanded);
+  if (theLevels != -1)
+    theLevels--;
+
+  QAbstractItemModel* aModel = theTreeView->model();
+  for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
+  {
+    int aLevels = theLevels;
+    SetExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
+  }
+}
index 39047a2f03c16fb497eafc3556977bbd3ca9c2a1..a2c260ca88ed91b8faf1c7cc23d51cea4ca06ef7 100644 (file)
@@ -22,7 +22,9 @@
 #include <Standard_WarningsDisable.hxx>
 #include <QApplication>
 #include <QByteArray>
+#include <QColor>
 #include <QMap>
+#include <QModelIndex>
 #include <QString>
 #include <QStyle>
 #include <Standard_WarningsRestore.hxx>
@@ -49,22 +51,23 @@ public:
 
   //! Returns header margin, defined in style settings of application
   //! \return integer value
-  Standard_EXPORT static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
+  static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
 
-  //! Save state of three view in a container in form: key, value. It saves:
-  //! - visibiblity of columns,
+  //! Saves state of tree view in a container in form: key, value. It saves:
+  //! - visibility of columns,
   //! - columns width
   //! \param theTreeView a view instance
   //! \param theItems [out] properties
   //! \param thePrefix peference item prefix
   Standard_EXPORT static void SaveState (QTreeView* theTreeView, QMap<QString, QString>& theItems,
                                          const QString& thePrefix = QString());
-  //! Restore state of three view by a container
+
+  //! Restores state of tree view by a container
   //! \param theTreeView a view instance
   //! \param theKey property key
   //! \param theValue property value
   //! \param thePrefix peference item prefix
-  //! \return boolean value whether the property is applyed to the tree view
+  //! \return boolean value whether the property is applied to the tree view
   Standard_EXPORT static bool RestoreState (QTreeView* theTreeView, const QString& theKey, const QString& theValue,
                                             const QString& thePrefix = QString());
 
@@ -90,6 +93,24 @@ public:
   //! \param theWidth width value, if -1, default value is used
   //! \param theTail symbols added to the end of the cut string
   Standard_EXPORT static QString CutString (const QString& theText, const int theWidth = -1, const QString& theTail = "...");
+
+  //! Returns light highlight color
+  //! \returns Qt color
+  Standard_EXPORT static QColor LightHighlightColor();
+
+  //! Makes the view expanded from the root till the index
+  Standard_EXPORT static void SetExpandedTo (QTreeView* theTreeView, const QModelIndex& theIndex);
+
+  //! Expands items in tree view staring from the index recursive in given number of levels
+  //! \param theTreeView an OCAF tree view
+  //! \param theParentIndex an index which children should be expanded
+  //! \param isExpanded a boolean state if the item should be expanded or collapsed
+  //! \param theLevels a number of levels to be expanded, or -1 for all levels
+  Standard_EXPORT static void SetExpanded (QTreeView* theTreeView,
+                                           const QModelIndex& theIndex,
+                                           const bool isExpanded,
+                                           int& theLevels);
+
 };
 
 #endif
index 599e635fe5749e3e4ecc1cf079659ed69f323773..0639291b78e2b0667bf207dcfafd8ec1603432a4 100644 (file)
 // function : OnClicked
 // purpose :
 // =======================================================================
-void TreeModel_VisibilityState::OnClicked (const QModelIndex& theIndex)
+bool TreeModel_VisibilityState::processClicked (const QModelIndex& theIndex)
 {
   if (theIndex.column() != TreeModel_ColumnType_Visibility)
-    return;
+    return false;
 
   if (!CanBeVisible (theIndex))
-    return;
+    return false;
 
   SetVisible (theIndex, !IsVisible (theIndex), true);
-  emit itemClicked (theIndex);
+  return true;
 }
index 9718b5962f13007ddbce68acd16b239704a1735a..962e2421a693669a5d5c199c03e2e48629197669 100644 (file)
 #ifndef TreeModel_VisibilityState_H
 #define TreeModel_VisibilityState_H
 
-#include <inspector/TreeModel.hxx>
 #include <inspector/TreeModel_ModelBase.hxx>
 #include <inspector/TreeModel_ColumnType.hxx>
 
 #include <Standard.hxx>
 #include <Standard_Macro.hxx>
 
-#include <Standard_WarningsDisable.hxx>
-#include <QObject>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
 //! \class TreeModel_VisibilityState
 //! \brief Interface that provides connection between model and visualization control to:
 //! - know whether the model item is visible
 //! - change visibility of the model item
-class TREEMODEL_EXPORT TreeModel_VisibilityState : public QObject
+class TreeModel_VisibilityState
 {
-  Q_OBJECT
 public:
   //! Constructor
   TreeModel_VisibilityState (TreeModel_ModelBase* theModel) : myModel (theModel) {}
@@ -59,23 +52,19 @@ public:
   //! \return boolean value
   virtual bool IsVisible (const QModelIndex& theIndex) const = 0;
 
-public slots:
+protected:
   //! Processes the mouse clicked on the index.
   //! It changes the item visibility if model allows to change it.
   //! \theIndex tree model index
-  void OnClicked (const QModelIndex& theIndex);
-
-signals:
-  //! Signal after OnClicked is performed
-  //! \theIndex tree model index
-  void itemClicked (const QModelIndex& theIndex);
+  //! \return true if click is processed
+  Standard_EXPORT bool processClicked (const QModelIndex& theIndex);
 
 protected:
   //! tree view model
   TreeModel_ModelBase* getModel() const { return myModel; }
 
 private:
-  TreeModel_ModelBase* myModel; //! tree view model
+  TreeModel_ModelBase* myModel; //!< tree view model
 };
 
 #endif
index 68312f8eb143ca930b00824146a1ad1bec7b490a..0394262f8d73c358aa96c08d68b5ab1b1b880cb5 100644 (file)
@@ -1,4 +1,6 @@
 VInspector.qrc
+VInspectorAPI_CallBack.cxx
+VInspectorAPI_CallBack.hxx
 VInspector_CallBack.cxx
 VInspector_CallBack.hxx
 VInspector_CallBackMode.hxx
@@ -8,10 +10,6 @@ VInspector_ItemBase.cxx
 VInspector_ItemBase.hxx
 VInspector_ItemContext.cxx
 VInspector_ItemContext.hxx
-VInspector_ItemFolderObject.cxx
-VInspector_ItemFolderObject.hxx
-VInspector_ItemEntityOwner.cxx
-VInspector_ItemEntityOwner.hxx
 VInspector_ItemHistoryElement.cxx
 VInspector_ItemHistoryElement.hxx
 VInspector_ItemHistoryRoot.cxx
@@ -21,13 +19,6 @@ VInspector_ItemHistoryType.hxx
 VInspector_ItemHistoryTypeInfo.hxx
 VInspector_ItemPresentableObject.cxx
 VInspector_ItemPresentableObject.hxx
-VInspector_ItemSelection.cxx
-VInspector_ItemSelection.hxx
-VInspector_ItemSelectMgrFilter.cxx
-VInspector_ItemSelectMgrFilter.hxx
-VInspector_ItemSensitiveEntity.cxx
-VInspector_ItemSensitiveEntity.hxx
-VInspector_SelectionType.hxx
 VInspector_ToolActionType.hxx
 VInspector_ToolBar.cxx
 VInspector_ToolBar.hxx
@@ -39,5 +30,3 @@ VInspector_ViewModelHistory.cxx
 VInspector_ViewModelHistory.hxx
 VInspector_Window.cxx
 VInspector_Window.hxx
-VInspectorAPI_CallBack.cxx
-VInspectorAPI_CallBack.hxx
index bdb5fb3cfeefb3c7eeb7c397466c7a3748f8649b..accb7a3975f81f0158a2a1020d7f5ffcfba6cb66 100644 (file)
 
 #include <inspector/VInspectorAPI_CallBack.hxx>
 
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#else
-IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#endif
 
 // =======================================================================
 // function : Constructor
index fb63800087e5c38656143516ec0591b8793c7fdc..0b8e812feafa83275ca6afea22bc6b6a4fff6faa 100644 (file)
 
 #include <Standard.hxx>
 #include <Standard_Integer.hxx>
-#include <Standard_Version.hxx>
 #include <Standard_Transient.hxx>
 #include <TColStd_ListOfInteger.hxx>
 #include <TopoDS_Shape.hxx>
 
-#if OCC_VERSION_HEX > 0x060901
 class AIS_InteractiveObject;
-#else
-#include <AIS_InteractiveObject.hxx>
-#endif
 class SelectMgr_EntityOwner;
 
-DEFINE_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
-
 //! \class VInspectorAPI_CallBack
 //! API of AIS_InteractiveContext methods to provide information about the actions
 class VInspectorAPI_CallBack : public Standard_Transient
@@ -96,11 +89,7 @@ public:
   //! Processing method of context
   virtual void ShiftSelect() = 0;
 
-#if OCC_VERSION_HEX <= 0x060901
-  DEFINE_STANDARD_RTTI(VInspectorAPI_CallBack)
-#else
   DEFINE_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
-#endif
 };
 
 #endif
index 481ec6f6b23c17f6c49d46bf35de3199bd5ebb41..a9101415197e4431b2a719fe0f1acd9826579881 100644 (file)
 #include <AIS_InteractiveObject.hxx>
 
 #include <SelectMgr_EntityOwner.hxx>
-#include <Standard_Version.hxx>
 
 #include <inspector/VInspector_CallBackMode.hxx>
 #include <inspector/VInspector_Tools.hxx>
 #include <inspector/VInspector_ViewModelHistory.hxx>
 
-#if OCC_VERSION_HEX <= 0x060901
-IMPLEMENT_STANDARD_HANDLE(VInspector_CallBack, Standard_Transient)
 IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#else
-IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#endif
 
 // =======================================================================
 // function : Activate
@@ -38,7 +32,18 @@ IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
 // =======================================================================
 void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode)
 {
-  QList<QVariant> anInfo = VInspector_Tools::GetInfo (thePrs);
+  if (!myHistoryModel)
+    return;
+
+  QList<QVariant> anInfo;
+  if (!thePrs.IsNull())
+    anInfo = VInspector_Tools::GetInfo (thePrs);
+  else
+  {
+    anInfo.append ("Activate");
+    anInfo.append ("");
+    anInfo.append ("");
+  }
   anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode);
   myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo);
 }
@@ -49,6 +54,8 @@ void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const
 // =======================================================================
 void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   aValues.append (""); // Name
   aValues.append (""); // Pointer
@@ -63,6 +70,8 @@ void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
 // =======================================================================
 void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
   aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
   myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
@@ -74,9 +83,11 @@ void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) the
 // =======================================================================
 void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   aValues.append (""); // Name
-  aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer
+  aValues.append (Standard_Dump::GetPointerInfo (theOwner, true).ToCString()); // Pointer
   aValues.append (""); // Shape type
   aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
 
@@ -89,6 +100,8 @@ void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) the
 // =======================================================================
 void VInspector_CallBack::ClearSelected()
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
 }
@@ -99,6 +112,8 @@ void VInspector_CallBack::ClearSelected()
 // =======================================================================
 void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   aValues = VInspector_Tools::GetHighlightInfo (myContext);
   myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
@@ -110,6 +125,8 @@ void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Stan
 // =======================================================================
 void VInspector_CallBack::Select()
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   aValues = VInspector_Tools::GetSelectedInfo (myContext);
   myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
@@ -121,6 +138,8 @@ void VInspector_CallBack::Select()
 // =======================================================================
 void VInspector_CallBack::ShiftSelect()
 {
+  if (!myHistoryModel)
+    return;
   QList<QVariant> aValues;
   aValues = VInspector_Tools::GetSelectedInfo (myContext);
   myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
index 57bdeae4ffd92dee5094497943e9df02ba3784d2..668e1a88e7e8e2df98fd52507c8294b27ae77dc7 100644 (file)
@@ -26,8 +26,6 @@
 class AIS_InteractiveObject;
 class SelectMgr_EntityOwner;
 
-DEFINE_STANDARD_HANDLE(VInspector_CallBack, VInspectorAPI_CallBack)
-
 //! \class VInspector_CallBack
 //! Updates inspector state on actions in context
 class VInspector_CallBack : public VInspectorAPI_CallBack
@@ -38,27 +36,27 @@ public:
   VInspector_CallBack() : VInspectorAPI_CallBack() {}
 
   //! Destructor
-  virtual ~VInspector_CallBack() Standard_OVERRIDE {}
+  virtual ~VInspector_CallBack() {}
 
   //! Appends displayed presentation into history model
   //! \param thePrs the presentation
   virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends redisplayed presentation into history model
   //! \param thePrs the presentation
   virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends removed presentation into history model
   //! \param thePrs the presentation
   virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends loaded presentation into history model
   //! \param thePrs the presentation
   virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends information about modes activation
   //! \param thePrs the presentation
@@ -75,13 +73,14 @@ public:
   //! Appends information about modes deactivation
   //! \param thePrs the presentation
   virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends information about modes deactivation
   //! \param thePrs the presentation
   //! \param theMode the selection mode
   virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
-  { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+  { (void)theMode;
+    if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends information about selection change
   //! \param theShape the selected shape
@@ -101,7 +100,7 @@ public:
   //! Appends information about selection clear
   //! \param thePrs the selected presentation
   virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends information about moving to point
   //! \param theXPix a pixels on horizontal
@@ -111,7 +110,7 @@ public:
   //! Appends information about setting selection
   //! \param thePrs the selected presentation
   virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
-  { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
+  { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
 
   //! Appends information about select
   Standard_EXPORT virtual void Select() Standard_OVERRIDE;
@@ -126,11 +125,7 @@ public:
   //! Sets context, where actions happen
   //! \param theContext a context instance
   void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
-#if OCC_VERSION_HEX <= 0x060901
-  DEFINE_STANDARD_RTTI(VInspector_CallBack)
-#else
   DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
-#endif
 
   //! Returns string information of call back mode
   //! \param theMode type of AIS action
index e0fe1f51474fdb472b605287da7feac212234944..8cdf7a933fc54b9c5ae5b571ca78877153007db7 100644 (file)
@@ -32,7 +32,7 @@ public:
   Standard_EXPORT VInspector_Communicator();
 
   //! Destructor
-  virtual ~VInspector_Communicator() Standard_OVERRIDE {}
+  virtual ~VInspector_Communicator() {}
 
   //! Provides the container with a parent where this container should be inserted.
   //! If Qt implementation, it should be QWidget with QLayout set inside
@@ -46,7 +46,7 @@ public:
 
   //! Provide container for actions available in inspector on general level
   //! \param theMenu if Qt implementation, it is QMenu object
-  Standard_EXPORT virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
+  virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
 
   //! Returns plugin preferences, empty implementation by default
   //! \param theItem container of preference elements
index 8f1cee216ebf2a40401c4e23410f239d44446adf..591ecb0661d4de1871ac655b98f15b45dc46a59d 100644 (file)
 #include <inspector/VInspector_ItemBase.hxx>
 #include <inspector/VInspector_ItemContext.hxx>
 
+#include <inspector/ViewControl_Tools.hxx>
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemBase::Reset()
+{
+  myPresentationShape = TopoDS_Shape();
+  TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemBase::initValue (const int theItemRole) const
+{
+  if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
+    return QVariant();
+
+  switch (Column())
+  {
+    case 3: return Standard_Dump::GetPointerInfo (Object(), true).ToCString();
+  }
+
+  return QVariant();
+}
+
 // =======================================================================
 // function : GetContext
 // purpose :
@@ -49,3 +78,16 @@ Handle(AIS_InteractiveContext) VInspector_ItemBase::GetContext() const
 
   return myContext;
 }
+
+// =======================================================================
+// function : GetContext
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemBase::GetPresentationShape() const
+{
+  if (Column() != TreeModel_ColumnType_Name)
+    return TopoDS_Shape();
+  
+  initItem();
+  return myPresentationShape;
+}
index c0c268d395f54e7b96d3e8a52e91dac29ea53534..4e35513625cb3fb928ee5909ac37b868c5d6da25 100644 (file)
@@ -18,6 +18,9 @@
 
 #include <AIS_InteractiveContext.hxx>
 #include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <inspector/TreeModel_ColumnType.hxx>
 #include <inspector/TreeModel_ItemBase.hxx>
 
 class VInspector_ItemBase;
@@ -29,7 +32,7 @@ class VInspector_ItemBase : public TreeModel_ItemBase
 {
 public:
   //! Resets cached values
-  virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
+  Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
   //! Sets the context 
   //! \param theLabel an object where the child items structure is found
@@ -43,23 +46,47 @@ public:
   //! \return a context
   Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
 
+  //! Returns item information for the given role. Fills internal container if it was not filled yet
+  //! \param theItemRole a value role
+  //! \return the value
+  Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+  //! Returns presentation of the attribute to be visualized in the view
+  //! \thePresentations [out] container of presentation handles to be visualized
+  virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
+  { (void)thePresentations; }
+
+  //! Returns transform persistent of the item or NULL
+  Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
+
+  //! Returns shape of the item parameters
+  //! \return generated shape of the item parameters
+  Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
+
+  //! Rebuild presentation shape if the item use it
+  //! \return generated shape of the item parameters
+  void UpdatePresentationShape() { myPresentationShape = buildPresentationShape(); }
+
 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(); }
 
 protected:
 
   //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   VInspector_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : TreeModel_ItemBase (theParent, theRow, theColumn), myContext (0) {}
 
 protected:
 
   Handle(AIS_InteractiveContext) myContext; //!< the current context
+  TopoDS_Shape myPresentationShape; //!< item presentation shape
+  Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
 };
 
 #endif
\ No newline at end of file
index 51770e4f0ac7297751dfbc7d34f6a7f6d8c80e8f..27400ac661bc69d4db0595ff76653c3631012052 100644 (file)
@@ -15,9 +15,9 @@
 
 #include <inspector/VInspector_ItemContext.hxx>
 
+#include <AIS.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <SelectMgr_EntityOwner.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
 #include <inspector/VInspector_ItemPresentableObject.hxx>
 #include <inspector/VInspector_Tools.hxx>
 
@@ -25,8 +25,6 @@
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
-//#define DEBUG_FREE_OWNERS
-
 // =======================================================================
 // function : initRowCount
 // purpose :
@@ -36,47 +34,22 @@ int VInspector_ItemContext::initRowCount() const
   if (Column() != 0)
     return 0;
 
-  int aNbProperties = 1; // item to visualize Filters/Drawer information of context
-
-  int aNbPresentations = 0;
-  Handle(AIS_InteractiveContext) aContext = GetContext();
+  Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (Object());
   if (aContext.IsNull())
     return 0;
 
   AIS_ListOfInteractive aListOfIO;
   aContext->DisplayedObjects (aListOfIO);
   aContext->ErasedObjects(aListOfIO);
-  aNbPresentations = aListOfIO.Extent();
-
-  // owners without Presentation
-#ifdef DEBUG_FREE_OWNERS
-  int aRows = 0;
-  // only local context is processed: TODO for global context
-  NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
-  aContext->MainSelector()->ActiveOwners(anActiveOwners);
-
-  Handle(SelectMgr_EntityOwner) anOwner;
-  for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(anActiveOwners); anOwnersIt.More(); anOwnersIt.Next())
+  int aNbPresentations = 0;
+  for (AIS_ListIteratorOfListOfInteractive aListOfIOIt (aListOfIO); aListOfIOIt.More(); aListOfIOIt.Next())
   {
-    anOwner = anOwnersIt.Value();
-    if (anOwner.IsNull())
-      continue;
-    Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
-    if (anAISObj.IsNull())
-      aRows++;
+    if (aListOfIOIt.Value()->Parent())
+      continue; // child presentation
+    aNbPresentations++;
   }
-  // owners in Global Context
-  NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
-  aContext->MainSelector()->ActiveOwners(anActiveOwners);
-  if (aRows > 0)
-    aNbPresentations += aRows;
-  NCollection_List<Handle(SelectMgr_EntityOwner)> anEmptySelectableOwners;
-  NCollection_List<Handle(SelectMgr_EntityOwner)> anOwners =
-    VInspector_Tools::ActiveOwners (aContext, anEmptySelectableOwners);
-  if (anEmptySelectableOwners.Size() > 0)
-    aNbPresentations += 1;
-#endif
-  return aNbProperties + aNbPresentations;
+
+  return aNbPresentations;
 }
 
 // =======================================================================
@@ -85,37 +58,85 @@ int VInspector_ItemContext::initRowCount() const
 // =======================================================================
 QVariant VInspector_ItemContext::initValue (const int theItemRole) const
 {
+  QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
     return QVariant();
 
-  if (GetContext().IsNull())
+  Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (Object());
+  if (aContext.IsNull())
     return Column() == 0 ? "Empty context" : "";
 
   switch (Column())
   {
-    case 0: return GetContext()->DynamicType()->Name();
-    case 1: return rowCount();
+    case 0: return aContext->DynamicType()->Name();
     case 4:
     {
       Handle(AIS_InteractiveObject) anEmptyIO;
-      int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false);
+      int aSelectedCount = VInspector_Tools::SelectedOwners (aContext, anEmptyIO, false);
       return aSelectedCount > 0 ? QString::number (aSelectedCount) : "";
     }
-    case 6: return GetContext()->DeviationCoefficient();
+    case 6: return aContext->DeviationCoefficient();
     default:
       break;
   }
   return QVariant();
 }
 
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::Init()
+{
+  Handle(AIS_InteractiveContext) aContext = GetContext();
+  if (aContext.IsNull())
+    return;
+
+  TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::Reset()
+{
+  VInspector_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::initItem() const
+{
+  if (IsInitialized())
+    return;
+  const_cast<VInspector_ItemContext*>(this)->Init();
+}
+
 // =======================================================================
 // function : createChild
 // purpose :
 // =======================================================================
 TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theColumn)
 {
-  if (theRow == 0)
-    return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
-  else
-    return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
+  return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
 }
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void VInspector_ItemContext::initStream (Standard_OStream& theOStream) const
+{
+  Handle(AIS_InteractiveContext) aContext = GetContext();
+  if (aContext.IsNull())
+    return;
+
+  aContext->DumpJson (theOStream);
+}
+
index 166b8a6519cb786937af9e8b48dec81067345b0e..6308f59df64176c25ddfee8f0d9a8c8f2060737c 100644 (file)
@@ -36,7 +36,11 @@ public:
   { return VInspector_ItemContextPtr (new VInspector_ItemContext (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~VInspector_ItemContext() Standard_OVERRIDE {};
+  virtual ~VInspector_ItemContext() {}
+
+  //! Returns data object of the item.
+  //! \return object
+  virtual const Handle(Standard_Transient)& Object() const { initItem(); return myContext; }
 
   //! Returns number of displayed presentations
   //! \return rows count
@@ -47,11 +51,21 @@ public:
   //! \return the value
   Standard_EXPORT virtual QVariant initValue (const int theItemRole) const 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;
+
 protected:
 
-  //! Initialize the current item. It creates a backup of the specific item information
-  //! Do nothing as context has been already set into item
-  virtual void initItem() const Standard_OVERRIDE {}
+  //! Initializes the current item. It creates a backup of the specific item information
+  //! Does nothing as context has been already set into item
+  virtual void initItem() const Standard_OVERRIDE;
+
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
 
 protected:
 
@@ -64,9 +78,9 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
-  //! \param theRow the item row positition in the parent item
-  //! \param theColumn the item column positition in the parent item
+  //! \param theParent a parent item
+  //! \param theRow the item row position in the parent item
+  //! \param theColumn the item column position in the parent item
   VInspector_ItemContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : VInspector_ItemBase(theParent, theRow, theColumn) {}
 };
diff --git a/tools/VInspector/VInspector_ItemEntityOwner.cxx b/tools/VInspector/VInspector_ItemEntityOwner.cxx
deleted file mode 100644 (file)
index 309bb45..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-// 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/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QItemSelectionModel>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemEntityOwner::initValue(int theItemRole) const
-{
-  switch (theItemRole)
-  { 
-    case Qt::DisplayRole:
-    case Qt::EditRole:
-    case Qt::ToolTipRole:
-    {
-      Handle(SelectMgr_EntityOwner) anOwner = getEntityOwner();
-      if (anOwner.IsNull())
-        return QVariant();
-
-      switch (Column())
-      {
-        case 0: return anOwner->DynamicType()->Name();
-        case 2: return VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
-        case 3:
-        {
-          Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
-          if (BROwnr.IsNull())
-            return QVariant();
-
-          const TopoDS_Shape& aShape = BROwnr->Shape();
-          if (aShape.IsNull())
-            return QVariant();
-
-          return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
-        }
-        case 17:
-        case 18:
-        case 19:
-          {
-          Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
-          if (BROwnr.IsNull())
-            return QVariant();
-
-          const TopoDS_Shape& aShape = BROwnr->Shape();
-          if (aShape.IsNull())
-            return QVariant();
-
-          return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
-               : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
-               :           /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
-        }
-        default: break;
-      }
-      break;
-    }
-    case Qt::BackgroundRole:
-    case Qt::ForegroundRole:
-    {
-      if (Column() == 2)
-      {
-        Handle(AIS_InteractiveContext) aContext = GetContext();
-        if (!aContext.IsNull())
-        {
-          if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
-            return (theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white);
-        }
-      }
-      VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
-      if (aParentItem)
-        return aParentItem->data(QModelIndex(), theItemRole);
-      break;
-    }
-  }
-  return QVariant();
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::Init()
-{
-  Handle(SelectMgr_EntityOwner) anOwner;
-
-  VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
-  if (aParentItem)
-  {
-    Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
-    anOwner = anEntity->BaseSensitive()->OwnerId();
-  }
-  else
-  {
-    VInspector_ItemPresentableObjectPtr aPOItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
-    if (aPOItem)
-    {
-      Handle(AIS_InteractiveObject) anIO = aPOItem->GetInteractiveObject();
-
-      int aRowId = Row();
-      int aCurrentIndex = 0;
-#if OCC_VERSION_HEX < 0x070201
-      for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
-      {
-        const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
-        for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
-        {
-          Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
-#else
-      for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
-      {
-        const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
-        for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
-        {
-          Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
-#endif
-          const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
-          if (!aBase.IsNull())
-          {
-            if (aRowId == aCurrentIndex)
-              anOwner = aBase->OwnerId();
-            aCurrentIndex++;
-          }
-        }
-      }
-    }
-  }
-  myOwner = anOwner;
-  TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::Reset()
-{
-  VInspector_ItemBase::Reset();
-  SetContext (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemEntityOwner::initItem() const
-{
-  if (IsInitialized())
-    return;
-  const_cast<VInspector_ItemEntityOwner*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectMgr_EntityOwner) VInspector_ItemEntityOwner::getEntityOwner() const
-{
-  initItem();
-  return myOwner;
-}
diff --git a/tools/VInspector/VInspector_ItemEntityOwner.hxx b/tools/VInspector/VInspector_ItemEntityOwner.hxx
deleted file mode 100644 (file)
index f00adc2..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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. 
-
-#ifndef VInspector_ItemEntityOwner_H
-#define VInspector_ItemEntityOwner_H
-
-#include <AIS_InteractiveObject.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemEntityOwner;
-typedef QExplicitlySharedDataPointer<VInspector_ItemEntityOwner> VInspector_ItemEntityOwnerPtr;
-
-//! \class VInspector_ItemPresentableObject
-//! Item for selection entity owner. The parent is sensitive entity item, there are no children
-class VInspector_ItemEntityOwner : public VInspector_ItemBase
-{
-
-public:
-
-  //! Creates an item wrapped by a shared pointer
-  static VInspector_ItemEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  { return VInspector_ItemEntityOwnerPtr (new VInspector_ItemEntityOwner (theParent, theRow, theColumn)); }
-
-  //! Destructor
-  virtual ~VInspector_ItemEntityOwner() 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 the current entity owner
-  Handle(SelectMgr_EntityOwner) EntityOwner() const { return myOwner; }
-
-protected:
-  //! \return number of children.
-  virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
-
-  //! Returns item information for the given role. Fills internal container if it was not filled yet
-  //! \param theItemRole a value role
-  //! \return the value
-  virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-  //! Initialize the current item. It is empty because Reset() is also empty.
-  virtual void initItem() const Standard_OVERRIDE;
-
-protected:
-
-  //! Creates a child item in the given position.
-  //! \param theRow the child row position
-  //! \param theColumn the child column position
-  //! \return the created item
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
-  { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
-
-private:
-
-  //! Constructor
-  //! param theParent a parent item
-  VInspector_ItemEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
-  //! Returns the current entity owner. Initializes the item if it was not initialized yet
-  Handle(SelectMgr_EntityOwner) getEntityOwner() const;
-
-private:
-
-  Handle(SelectMgr_EntityOwner) myOwner; //!< the current entity owner
-};
-
-#endif
diff --git a/tools/VInspector/VInspector_ItemFolderObject.cxx b/tools/VInspector/VInspector_ItemFolderObject.cxx
deleted file mode 100644 (file)
index cbd413b..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-// 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/VInspector_ItemFolderObject.hxx>
-
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
-{
-  if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
-  {
-    if (parentItemIsContext()) return "Properties";
-    else if (Row() == 0) return "Filters";
-    else return QVariant();
-  }
-  return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemFolderObject::initRowCount() const
-{
-  return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
-{
-  if (parentItemIsContext())
-    return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
-  else
-    return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::Init()
-{
-  TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::Reset()
-{
-  VInspector_ItemBase::Reset();
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemFolderObject::initItem() const
-{
-  if (IsInitialized())
-    return;
-  const_cast<VInspector_ItemFolderObject*> (this)->Init();
-}
-
-// =======================================================================
-// function : parentItemIsContext
-// purpose :
-// =======================================================================
-bool VInspector_ItemFolderObject::parentItemIsContext() const
-{
-  return itemDynamicCast<VInspector_ItemContext> (Parent());
-}
diff --git a/tools/VInspector/VInspector_ItemFolderObject.hxx b/tools/VInspector/VInspector_ItemFolderObject.hxx
deleted file mode 100644 (file)
index a0a754f..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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. 
-
-#ifndef VInspector_ItemFolderObject_H
-#define VInspector_ItemFolderObject_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <AIS_InteractiveObject.hxx>
-#include <NCollection_List.hxx>
-#include <TCollection_AsciiString.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemFolderObject;
-typedef QExplicitlySharedDataPointer<VInspector_ItemFolderObject> VInspector_ItemFolderObjectPtr;
-
-//! \class VInspector_ItemFolderObject
-//! Item presents additional level of information in the tree model.
-//! Parent is item context, children are either folder item or Selection filter item.
-class VInspector_ItemFolderObject : public VInspector_ItemBase
-{
-
-public:
-
-  //! Creates an item wrapped by a shared pointer
-  static VInspector_ItemFolderObjectPtr CreateItem (TreeModel_ItemBasePtr theParent,
-    const int theRow, const int theColumn)
-  { return VInspector_ItemFolderObjectPtr (new VInspector_ItemFolderObject (theParent, theRow, theColumn)); }
-  //! Destructor
-  virtual ~VInspector_ItemFolderObject() 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;
-
-protected:
-
-  //! Initialize the current item. It is empty because Reset() is also empty.
-  virtual void initItem() const Standard_OVERRIDE;
-
-  //! Returns number of item selected
-  //! \return rows count
-  virtual int initRowCount() const Standard_OVERRIDE;
-
-  //! Returns item information for the given role. Fills internal container if it was not filled yet
-  //! \param theItemRole a value role
-  //! \return the value
-  virtual QVariant initValue (const int theItemRole) 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
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-  //! Returns whether the parent item is context item
-  //! \returns bolean value
-  bool parentItemIsContext() const;
-
-private:
-
-  //! Constructor
-  //! param theParent a parent item
-  VInspector_ItemFolderObject (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : VInspector_ItemBase (theParent, theRow, theColumn) {}
-
-};
-
-#endif
index f6a6b1df6544200ddf562a498965ea0bcda26f6a..ef579927592eb69b64939b8a5d6a37d90f4fc5fd 100644 (file)
 // =======================================================================
 QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
 {
+  QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
     return QVariant();
 
   switch (Column())
   {
     case 0: return getName();
-    case 1: return QVariant();
-    case 2: return GetPointerInfo();
-    case 3: return GetShapeTypeInfo();
+    case 2: return QVariant();
+    case 3: return GetPointerInfo();
+    case 4: return GetShapeTypeInfo();
     default: break;
   }
   return QVariant();
index 07bdc0ade135d464d69449297da3156148cf4216..70a19774553f6a9a573a8c6a724ea284605a0ae2 100644 (file)
@@ -35,7 +35,7 @@ public:
   { return VInspector_ItemHistoryElementPtr (new VInspector_ItemHistoryElement (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~VInspector_ItemHistoryElement() Standard_OVERRIDE {};
+  virtual ~VInspector_ItemHistoryElement() {}
 
   //! Inits the item, fills internal containers
   Standard_EXPORT virtual void Init() Standard_OVERRIDE;
@@ -78,7 +78,7 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   VInspector_ItemHistoryElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   : VInspector_ItemBase(theParent, theRow, theColumn) {}
 
index 7a5c2bd50127783d2710cc4933b253101db876f7..77f9512140aa5eab4fb05e673006b0152c7cf6bd 100644 (file)
@@ -64,6 +64,11 @@ void VInspector_ItemHistoryRoot::AddElement (const VInspector_CallBackMode& theM
 const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (const int theChildRowIndex)
 {
   int anInfoMapIndex = theChildRowIndex + myFirstIndex;
+
+  bool aReversed = true;
+  if (aReversed)
+    anInfoMapIndex = (myInfoMap.size() - myFirstIndex) - 1 - anInfoMapIndex;
+
   return myInfoMap[anInfoMapIndex];
 }
 
@@ -73,13 +78,17 @@ const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (c
 // =======================================================================
 QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
 {
+  QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
     return QVariant();
  
   switch (Column())
   {
     case 0: return "History";
-    case 1: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
+    case 2: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
     default:
       break;
   }
index 42630670d497d77cd68c8e986c9b6dcb1c302adf..d0b16d5c7efb3b89c287842423c50e9092bfdc36 100644 (file)
@@ -37,7 +37,7 @@ public:
   { return VInspector_ItemHistoryRootPtr (new VInspector_ItemHistoryRoot (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~VInspector_ItemHistoryRoot() Standard_OVERRIDE {};
+  virtual ~VInspector_ItemHistoryRoot() {}
 
   //! Sets maximum count of history elements in internal container.
   //! \param theSize a size value
@@ -72,7 +72,7 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
 
 private:
index bd8f90a9a98e96aceebcfc1a6c787b32b23c58ff..70ab2c90490268593560aee2c6d8b5c01a4cf076 100644 (file)
@@ -31,6 +31,8 @@ QString VInspector_ItemHistoryType::PointerInfo() const
 
   VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
   const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+  if (aTypeInfo.myElements.size() < rowCount())
+    return QString();
   QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
   return anElements.size() > 1 ? anElements[1].toString() : QString();
 }
@@ -46,6 +48,8 @@ QString VInspector_ItemHistoryType::OwnerInfo() const
 
   VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
   const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+  if ( aTypeInfo.myElements.size() < rowCount())
+    return QString();
   QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
   return anElements.size() > 3 ? anElements[3].toString() : QString();
 }
@@ -56,21 +60,29 @@ QString VInspector_ItemHistoryType::OwnerInfo() const
 // =======================================================================
 QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
 {
+  QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+  if (aParentValue.isValid())
+    return aParentValue;
+
   if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
     return QVariant();
 
   VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
   const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+  int aRowCount = rowCount();
+  if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
+    return QVariant();
+
   QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
   int anInfoSize = anElements.size();
   switch (Column())
   {
     case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
-    case 1: return rowCount();
-    case 2: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
-    case 3: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
-    case 4: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
-    case 5: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
+    case 3: return rowCount();
+    case 4: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
+    case 5: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
+    case 6: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
+    case 7: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
     default: break;
   }
   return QVariant();
index 875a9b6418124dd5972b8901e3cef8715baf7235..1632e83e2a9712a89aa3466e225058c2a7abede4 100644 (file)
@@ -35,7 +35,7 @@ public:
   { return VInspector_ItemHistoryTypePtr (new VInspector_ItemHistoryType (theParent, theRow, theColumn)); }
 
   //! Destructor
-  virtual ~VInspector_ItemHistoryType() Standard_OVERRIDE {};
+  virtual ~VInspector_ItemHistoryType() {}
 
   //! Returns the pointer info of the first child item, initialize item if it has not been initialized yet.
   Standard_EXPORT QString PointerInfo() const;
@@ -67,7 +67,7 @@ protected:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   VInspector_ItemHistoryType(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
     : VInspector_ItemBase(theParent, theRow, theColumn) {}
 
index e1747f7f3fa2c2affa3f9f8fa09d143b0e0fdbde..135170ea1b674b303003cb39e74c5c139df3d255 100644 (file)
 
 #include <inspector/VInspector_ItemPresentableObject.hxx>
 
+#include <AIS.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
+
 #include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelection.hxx>
 #include <inspector/VInspector_Tools.hxx>
 #include <inspector/VInspector_ViewModel.hxx>
 
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
 #include <NCollection_List.hxx>
 #include <Prs3d.hxx>
 #include <Prs3d_Drawer.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
-#include <Standard_Version.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QColor>
 // =======================================================================
 QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
 {
-  if (Column() == 20 && theItemRole == Qt::BackgroundRole) {
-    Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
-    if (!anIO.IsNull() && anIO->HasColor())
-    {
-      Quantity_Color aColor;
-      anIO->Color(aColor);
-      return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
-    }
-  }
+  QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+  if (aParentValue.isValid())
+    return aParentValue;
 
   if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
   {
@@ -67,45 +63,11 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
           return theItemRole == Qt::ToolTipRole ? QVariant ("")
                                                 : QVariant (anIO->DynamicType()->Name());
       }
-      case 1:
-        return rowCount();
-      case 2:
-      {
-        if (!aNullIO)
-          return VInspector_Tools::GetPointerInfo (anIO, true).ToCString();
-        break;
-      }
-      case 3:
-      {
-        Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
-        if (!aShapeIO.IsNull())
-        {
-          const TopoDS_Shape& aShape = aShapeIO->Shape();
-          if (!aShape.IsNull())
-            return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
-        }
-        break;
-      }
       case 4:
       {
         int aNbSelected = VInspector_Tools::SelectedOwners (GetContext(), anIO, false);
         return aNbSelected > 0 ? QString::number (aNbSelected) : "";
       }
-      case 5:
-      {
-        TColStd_ListOfInteger aModes;
-        Handle(AIS_InteractiveContext) aContext = GetContext();
-        aContext->ActivatedModes(anIO, aModes);
-        TCollection_AsciiString aModesInfo;
-        for (TColStd_ListIteratorOfListOfInteger itr (aModes); itr.More(); itr.Next())
-        {
-          if (!aModesInfo.IsEmpty())
-            aModesInfo += ", ";
-          aModesInfo += VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType(itr.Value()));
-        }
-        return aModesInfo.ToCString();
-      }
-      break;
       case 6:
       {
         double aDeviationCoefficient = 0;
@@ -117,18 +79,6 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
         }
         return QString::number(aDeviationCoefficient);
       }
-      case 7:
-      {
-        double aShapeDeflection = 0;
-        Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
-        if (!aShapeIO.IsNull())
-        {
-          const TopoDS_Shape& aShape = aShapeIO->Shape();
-          if (!aShape.IsNull())
-            aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
-        }
-        return QString::number (aShapeDeflection);
-      }
       case 8:
       {
         double aDeviationCoefficient = 0;
@@ -142,21 +92,6 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
         bool anIsAutoTriangulation = aNullIO ? false : anIO->Attributes()->IsAutoTriangulation();
         return anIsAutoTriangulation ? QString ("true") : QString ("false");
       }
-      case 17:
-      case 18:
-      case 19:
-        {
-        Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
-        if (aShapeIO.IsNull())
-          return QVariant();
-        const TopoDS_Shape& aShape = aShapeIO->Shape();
-        if (aShape.IsNull())
-          return QVariant();
-
-        return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
-              : Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
-              :           /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
-      }
       default: break;
     }
   }
@@ -192,29 +127,7 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
 // =======================================================================
 int VInspector_ItemPresentableObject::initRowCount() const
 {
-  Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
-#if OCC_VERSION_HEX < 0x070201
-  int aRows = 0;
-  if (anIO.IsNull())
-    return aRows;
-  // iteration through sensitive privitives
-  for (anIO->Init(); anIO->More(); anIO->Next())
-    aRows++;
-  return aRows;
-#else
-  return !anIO.IsNull()
-        ? anIO->Selections().Size()
-        : 0;
-#endif
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemPresentableObject::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemSelection::CreateItem(currentItem(), theRow, theColumn);
+  return 0;
 }
 
 // =======================================================================
@@ -234,18 +147,28 @@ void VInspector_ItemPresentableObject::Init()
     AIS_ListOfInteractive aListOfIO;
     GetContext()->DisplayedObjects (aListOfIO); // the presentation is in displayed objects of Context
     GetContext()->ErasedObjects (aListOfIO); // the presentation is in erased objects of Context
-    int aDeltaIndex = 1; // properties item
+
+    std::vector<Handle(AIS_InteractiveObject)> aListOfIOSorted;
+    aListOfIOSorted.reserve (aListOfIO.Size());
+    for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next())
+    {
+      aListOfIOSorted.push_back (anIOIt.Value());
+    }
+    std::sort (aListOfIOSorted.begin(), aListOfIOSorted.end());
+
     int aCurrentIndex = 0;
-    for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next(), aCurrentIndex++)
+    for (std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIOIt = aListOfIOSorted.begin(); anIOIt != aListOfIOSorted.end(); anIOIt++, aCurrentIndex++)
     {
-      if (aCurrentIndex != aRowId - aDeltaIndex)
+      if (aCurrentIndex != aRowId)
         continue;
-      anIO = anIOIt.Value();
+      anIO = *anIOIt;
       break;
     }
   }
 
   setInteractiveObject (anIO);
+  myTransformPersistence = !anIO.IsNull() ? anIO->TransformPersistence() : NULL;
+  UpdatePresentationShape();
   TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
 }
 
@@ -259,6 +182,7 @@ void VInspector_ItemPresentableObject::Reset()
 
   SetContext (NULL);
   setInteractiveObject (NULL);
+  myTransformPersistence = NULL;
 }
 
 // =======================================================================
@@ -273,13 +197,20 @@ void VInspector_ItemPresentableObject::initItem() const
 }
 
 // =======================================================================
-// function : GetInteractiveObject
+// function : buildPresentationShape
 // purpose :
 // =======================================================================
-Handle(AIS_InteractiveObject) VInspector_ItemPresentableObject::GetInteractiveObject() const
+TopoDS_Shape VInspector_ItemPresentableObject::buildPresentationShape()
 {
-  initItem();
-  return myIO;
+  Handle(AIS_InteractiveObject) aPrs = myIO;
+  if (aPrs.IsNull())
+    return TopoDS_Shape();
+
+  Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast (aPrs);
+  if (!aShapePrs.IsNull())
+    return aShapePrs->Shape();
+
+  return TopoDS_Shape();
 }
 
 // =======================================================================
@@ -288,44 +219,31 @@ Handle(AIS_InteractiveObject) VInspector_ItemPresentableObject::GetInteractiveOb
 // =======================================================================
 QString VInspector_ItemPresentableObject::PointerInfo() const
 {
-  return VInspector_Tools::GetPointerInfo (GetInteractiveObject(), true).ToCString();
+  return Standard_Dump::GetPointerInfo (GetInteractiveObject(), true).ToCString();
 }
 
 // =======================================================================
-// function : GetSelectedPresentations
+// function : Presentations
 // purpose :
 // =======================================================================
-NCollection_List<Handle(AIS_InteractiveObject)> VInspector_ItemPresentableObject::GetSelectedPresentations
-                                                                  (QItemSelectionModel* theSelectionModel)
+void VInspector_ItemPresentableObject::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
 {
-  NCollection_List<Handle(AIS_InteractiveObject)> aResultList;
-  if (!theSelectionModel)
-    return aResultList;
-  
-  QList<TreeModel_ItemBasePtr> anItems;
-  
-  QModelIndexList anIndices = theSelectionModel->selectedIndexes();
-  for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
-  {
-    TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
-    if (!anItem || anItems.contains (anItem))
-      continue;
-    anItems.append (anItem);
-  }
+  if (Column() != 0)
+    return;
 
-  QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
-  for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
-  {
-    TreeModel_ItemBasePtr anItem = *anItemIt;
-    VInspector_ItemPresentableObjectPtr aPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(anItem);
-    if (!aPrsItem)
-      continue;
-    Handle(AIS_InteractiveObject) aPresentation = aPrsItem->GetInteractiveObject();
-    if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
-      continue;
-    aSelectedIds.append ((size_t)aPresentation.operator->());
-    if (!aPresentation.IsNull())
-      aResultList.Append (aPresentation);
-  }
-  return aResultList;
+  thePresentations.Append (GetInteractiveObject());
+}
+
+// =======================================================================
+// function : initStream
+// purpose :
+// =======================================================================
+void VInspector_ItemPresentableObject::initStream (Standard_OStream& theOStream) const
+{
+  Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+  if (anIO.IsNull())
+    return;
+
+  anIO->DumpJson (theOStream);
 }
+
index ed5765200f2757368a6afc18a669c314187e05c8..28ea2399535ddb60096c370342f5add140e1d726 100644 (file)
@@ -39,11 +39,15 @@ public:
   static VInspector_ItemPresentableObjectPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   { return VInspector_ItemPresentableObjectPtr (new VInspector_ItemPresentableObject (theParent, theRow, theColumn)); }
   //! Destructor
-  virtual ~VInspector_ItemPresentableObject() Standard_OVERRIDE {};
+  virtual ~VInspector_ItemPresentableObject() {}
+
+  //! Returns data object of the item.
+  //! \return object
+  virtual const Handle(Standard_Transient)& Object() const { initItem(); return myIO; }
 
   //! Returns the current interactive object, init item if it was not initialized yet
   //! \return interactive object
-  Standard_EXPORT Handle(AIS_InteractiveObject) GetInteractiveObject() const;
+  Handle(AIS_InteractiveObject) GetInteractiveObject() const { return Handle(AIS_InteractiveObject)::DownCast (Object()); }
 
   //! Returns pointer information for the current interactive object, init item if it was not initialized yet
   //! \return string value
@@ -55,11 +59,9 @@ public:
   //! Resets cached values
   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
-  //! Returns presentations, which items are selected in tree view
-  //! \param theSelectionModel a selection model
-  //! \return container of presentations
-  Standard_EXPORT static NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations
-    (QItemSelectionModel* theSelectionModel);
+  //! Returns presentation of the attribute to be visualized in the view
+  //! \thePresentations [out] container of presentation handles to be visualized
+  Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
 
 protected:
 
@@ -75,13 +77,14 @@ protected:
   //! \return the value
   virtual QVariant initValue (const int theItemRole) 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
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+  //! Returns stream value of the item to fulfill property panel.
+  //! \return stream value or dummy
+  Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const Standard_OVERRIDE;
 
-private:
+protected:
+  //! Build presentation shape
+  //! \return generated shape of the item parameters
+  virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
 
   //! Set interactive object into the current field
   //! \param theIO a presentation
@@ -90,7 +93,7 @@ private:
 private:
 
   //! Constructor
-  //! param theParent a parent item
+  //! \param theParent a parent item
   VInspector_ItemPresentableObject(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
   : VInspector_ItemBase(theParent, theRow, theColumn) {}
 
diff --git a/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx b/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx
deleted file mode 100644 (file)
index a274b05..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-// 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/VInspector_ItemSelectMgrFilter.hxx>
-#include <inspector/VInspector_ItemFolderObject.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <SelectMgr_AndFilter.hxx>
-#include <SelectMgr_OrFilter.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QIcon>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const
-{
-  if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
-  {
-    Handle(SelectMgr_Filter) aFilter = GetFilter();
-    switch (Column())
-    {
-      case 0: return theItemRole == Qt::ToolTipRole ? QVariant ("")
-                                                    : QVariant (aFilter->DynamicType()->Name());
-      case 1: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
-      case 2: return VInspector_Tools::GetPointerInfo (aFilter, true).ToCString();
-      default: break;
-    }
-  }
-  if (Column() == 0 && theItemRole == Qt::DecorationRole)
-  {
-    Handle(SelectMgr_Filter) aFilter = GetFilter();
-    if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_AndFilter))) return QIcon (":/icons/treeview_and.png");
-    if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_OrFilter))) return QIcon (":/icons/treeview_or.png");
-  }
-  return QVariant();
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelectMgrFilter::initRowCount() const
-{
-  Handle(SelectMgr_Filter) aFilter = GetFilter();
-  if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_CompositionFilter)))
-  {
-    Handle(SelectMgr_CompositionFilter) aCompositionFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
-    return aCompositionFilter->StoredFilters().Size();
-  }
-  return 0;
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelectMgrFilter::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemSelectMgrFilter::CreateItem(currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::Init()
-{
-  Handle(AIS_InteractiveContext) aContext = GetContext();
-
-  Handle(SelectMgr_Filter) aFilter;
-
-  Handle(SelectMgr_CompositionFilter) aParentCompositeFilter;
-  VInspector_ItemSelectMgrFilterPtr aParentSelectMgrItem = itemDynamicCast<VInspector_ItemSelectMgrFilter> (Parent());
-  if (aParentSelectMgrItem)
-    aParentCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aParentSelectMgrItem->GetFilter());
-
-  int aRowId = Row();
-  const SelectMgr_ListOfFilter& aFilters = !aParentCompositeFilter.IsNull() ? aParentCompositeFilter->StoredFilters()
-    : aContext->Filters();
-  int aCurrentIndex = 0;
-  for (SelectMgr_ListOfFilter::Iterator aFiltersIt (aFilters); aFiltersIt.More(); aFiltersIt.Next(), aCurrentIndex++)
-  {
-    if (aCurrentIndex != aRowId)
-      continue;
-    aFilter = aFiltersIt.Value();
-    break;
-  }
-  setFilter (aFilter);
-  TreeModel_ItemBase::Init(); // to use getFilter() without circling initialization
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::Reset()
-{
-  VInspector_ItemBase::Reset();
-
-  setFilter (NULL);
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelectMgrFilter::initItem() const
-{
-  if (IsInitialized())
-    return;
-  const_cast<VInspector_ItemSelectMgrFilter*>(this)->Init();
-}
-
-// =======================================================================
-// function : GetInteractiveObject
-// purpose :
-// =======================================================================
-Handle(SelectMgr_Filter) VInspector_ItemSelectMgrFilter::GetFilter() const
-{
-  initItem();
-  return myFilter;
-}
diff --git a/tools/VInspector/VInspector_ItemSelectMgrFilter.hxx b/tools/VInspector/VInspector_ItemSelectMgrFilter.hxx
deleted file mode 100644 (file)
index 6840835..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// 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. 
-
-#ifndef VInspector_ItemSelectMgrFilter_H
-#define VInspector_ItemSelectMgrFilter_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <SelectMgr_Filter.hxx>
-
-class QItemSelectionModel;
-
-class VInspector_ItemSelectMgrFilter;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrFilter> VInspector_ItemSelectMgrFilterPtr;
-
-//! \class VInspector_ItemSelectMgrFilter
-//! Item presents information about SelectMgr_Filter.
-//! Parent is item folder, children are sub filter if the filter is a composition filter.
-class VInspector_ItemSelectMgrFilter : public VInspector_ItemBase
-{
-
-public:
-
-  //! Creates an item wrapped by a shared pointer
-  static VInspector_ItemSelectMgrFilterPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  { return VInspector_ItemSelectMgrFilterPtr (new VInspector_ItemSelectMgrFilter (theParent, theRow, theColumn)); }
-  //! Destructor
-  virtual ~VInspector_ItemSelectMgrFilter() Standard_OVERRIDE {};
-
-  //! Returns the current filter, init item if it was not initialized yet
-  //! \return filter object
-  Standard_EXPORT Handle(SelectMgr_Filter) GetFilter() const;
-
-  //! Inits the item, fills internal containers
-  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
-  //! Resets cached values
-  Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
-  //! Initialize the current item. It is empty because Reset() is also empty.
-  virtual void initItem() const Standard_OVERRIDE;
-
-  //! Returns number of item selected
-  //! \return rows count
-  virtual int initRowCount() const Standard_OVERRIDE;
-
-  //! Returns item information for the given role. Fills internal container if it was not filled yet
-  //! \param theItemRole a value role
-  //! \return the value
-  virtual QVariant initValue (const int theItemRole) 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
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
-  //! Set filter into the current item
-  //! \param theFilter a filter
-  void setFilter (Handle(SelectMgr_Filter) theFilter) { myFilter = theFilter; }
-
-private:
-
-  //! Constructor
-  //! param theParent a parent item
-  VInspector_ItemSelectMgrFilter (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : VInspector_ItemBase (theParent, theRow, theColumn) {}
-
-protected:
-
-  Handle(SelectMgr_Filter) myFilter; //!< the current filter
-};
-
-#endif
diff --git a/tools/VInspector/VInspector_ItemSelection.cxx b/tools/VInspector/VInspector_ItemSelection.cxx
deleted file mode 100644 (file)
index 1912329..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-// 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/VInspector_ItemSelection.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : getSelection
-// purpose :
-// =======================================================================
-Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
-{
-  initItem();
-  return mySelection;
-}
-
-// =======================================================================
-// function : initRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemSelection::initRowCount() const
-{
-  Handle(SelectMgr_Selection) aSelection = getSelection();
-#if OCC_VERSION_HEX < 0x070201
-  int aRows = 0;
-  for (aSelection->Init(); aSelection->More(); aSelection->Next())
-    aRows++;
-  return aRows;
-#else
-  return aSelection->Entities().Size();
-#endif
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSelection::initValue (int theItemRole) const
-{
-  switch (theItemRole)
-  {
-    case Qt::DisplayRole:
-    case Qt::EditRole:
-    case Qt::ToolTipRole:
-    {
-      switch (Column())
-      {
-        case 0: return getSelection()->DynamicType()->Name();
-        case 1: return rowCount();
-        case 3:
-        {
-          if (theItemRole == Qt::ToolTipRole)
-            return "Mode";
-          else
-          {
-            VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
-            return VInspector_Tools::SelectionModeToName(getSelection()->Mode(), aParentItem->GetInteractiveObject()).ToCString();
-          }
-        }
-        case 4:
-        {
-          if (theItemRole == Qt::ToolTipRole)
-            return "SelectMgr_StateOfSelection";
-          else {
-            int aNbSelected = 0;
-            SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
-            if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
-            {
-              Handle(AIS_InteractiveContext) aContext = GetContext();
-#if OCC_VERSION_HEX < 0x070201
-              for (mySelection->Init(); mySelection->More(); mySelection->Next())
-              {
-                const Handle(SelectMgr_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
-#else
-              for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
-              {
-                const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
-#endif
-                if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
-                  aNbSelected++;
-              }
-            }
-            return aNbSelected > 0 ? QString::number (aNbSelected) : "";
-          }
-        }
-        case 9:
-        {
-          SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
-          return VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
-        }
-        case 10: return QString::number (getSelection()->Sensitivity());
-        case 11:
-          return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
-                                           getSelection()->UpdateStatus()).ToCString();
-        case 12:
-          return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
-                                           getSelection()->BVHUpdateStatus()).ToCString();
-        default:
-          break;
-      }
-      break;
-    }
-    case Qt::ForegroundRole:
-    {
-      SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
-      return QVariant (aState == SelectMgr_SOS_Activated ? QColor (Qt::black) : QColor (Qt::darkGray));
-    }
-  }
-  return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSelection::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::Init()
-{
-  VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
-
-  Handle(AIS_InteractiveObject) anIO = aParentItem->GetInteractiveObject();
-
-  int aRowId = Row();
-  int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
-  for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
-#else
-  for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
-#endif
-  {
-    if (aCurrentId != aRowId)
-      continue;
-#if OCC_VERSION_HEX < 0x070201
-    mySelection = anIO->CurrentSelection();
-#else
-    mySelection = aSelIter.Value();
-#endif
-    break;
-  }
-  TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::Reset()
-{
-  // an empty method to don't clear the main label, otherwise the model will be empty
-  TreeModel_ItemBase::Reset();
-
-  mySelection = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSelection::initItem() const
-{
-  if (IsInitialized())
-    return;
-  const_cast<VInspector_ItemSelection*>(this)->Init();
-  // an empty method to don't initialize the main label, as it was not cleared in Reset()
-}
diff --git a/tools/VInspector/VInspector_ItemSelection.hxx b/tools/VInspector/VInspector_ItemSelection.hxx
deleted file mode 100644 (file)
index f1565a6..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// 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. 
-
-#ifndef VInspector_ItemSelection_H
-#define VInspector_ItemSelection_H
-
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-#include <SelectMgr_Selection.hxx>
-
-class VInspector_ItemSelection;
-typedef QExplicitlySharedDataPointer<VInspector_ItemSelection> VInspector_ItemSelectionPtr;
-
-//! \class VInspector_ItemSelection
-//! Item about SelectMgr_Selection.
-//! Parent is presentable object item, children are sensitive entity items 
-class VInspector_ItemSelection : public VInspector_ItemBase
-{
-public:
-
-  //! Creates an item wrapped by a shared pointer
-  static VInspector_ItemSelectionPtr CreateItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  { return VInspector_ItemSelectionPtr (new VInspector_ItemSelection (theParent, theRow, theColumn)); }
-
-  //! Destructor
-  virtual ~VInspector_ItemSelection() {};
-
-  //! \return current selection value
-  Standard_EXPORT Handle(SelectMgr_Selection) getSelection() const;
-
-  //! Inits the item, fills internal containers
-  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
-  //! Resets cached values
-  Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
-  //! Initializes the current item. It is empty because Reset() is also empty.
-  virtual void initItem() const Standard_OVERRIDE;
-
-  //! Initializes number of children
-  //! \return integer value
-  virtual int initRowCount() const Standard_OVERRIDE;
-
-  //! Returns item information for the given role. Fills internal container if it was not filled yet
-  //! \param theItemRole a value role
-  //! \return the value
-  virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
-  //! Creates a child item in the given position.
-  //! \param theRow the child row position
-  //! \param theColumn the child column position
-  //! \return the created item
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-private:
-
-  //! Constructor
-  //! param theParent a parent item
-  VInspector_ItemSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
-  Handle(SelectMgr_Selection) mySelection; //!< the current selection
-};
-
-#endif
diff --git a/tools/VInspector/VInspector_ItemSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSensitiveEntity.cxx
deleted file mode 100644 (file)
index b5f9d59..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-// 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/VInspector_ItemSensitiveEntity.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Standard_Version.hxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TopoDS_Shape.hxx>
-#include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemSelection.hxx>
-#include <inspector/VInspector_Tools.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QStringList>
-#include <QColor>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : GetSensitiveEntity
-// purpose :
-// =======================================================================
-Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEntity() const
-{
-  initItem();
-  return myEntity;
-}
-
-// =======================================================================
-// function : initValue
-// purpose :
-// =======================================================================
-QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
-{
-  Handle(SelectMgr_SensitiveEntity) aBase = GetSensitiveEntity();
-  Handle(SelectMgr_EntityOwner) anOwner = aBase->BaseSensitive()->OwnerId();
-
-  switch (theItemRole)
-  {
-    case Qt::DisplayRole:
-    case Qt::EditRole:
-    case Qt::ToolTipRole:
-    {
-      switch (Column())
-      {
-        case 0: return myEntity->DynamicType()->Name();
-        case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
-        case 3:
-        {
-          Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
-          if (BROwnr.IsNull())
-            return QVariant();
-
-          const TopoDS_Shape& aShape = BROwnr->Shape();
-          if (aShape.IsNull())
-            return QVariant();
-
-          return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
-        }
-        case 13: return
-#if OCC_VERSION_HEX <= 0x060901
-                       ("none");
-#else
-                       myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
-#endif
-        case 14: return QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
-        case 15: return QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
-        case 16:
-        {
-          Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
-          if (BROwnr.IsNull())
-            return QVariant();
-          return anOwner->Priority();
-        }
-        default:
-          break;
-      }
-      break;
-    }
-    case Qt::BackgroundRole:
-    case Qt::ForegroundRole:
-    {
-      if (Column() == 2)
-      {
-        Handle(AIS_InteractiveContext) aContext = GetContext();
-        if (!aContext.IsNull())
-        {
-          if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
-            return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
-        }
-      }
-      VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
-      if (aParentItem)
-        return aParentItem->data(QModelIndex(), theItemRole);
-      break;
-    }
-    default:
-    break;
-  }
-  return QVariant();
-}
-
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemSensitiveEntity::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemEntityOwner::CreateItem (currentItem(), theRow, theColumn);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::Init()
-{
-  VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
-
-  Handle(SelectMgr_Selection) aSelection = aParentItem->getSelection();
-
-  int aRowId = Row();
-  int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
-  for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
-#else
-  for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
-#endif
-  {
-    if (aCurrentId != aRowId)
-      continue;
-#if OCC_VERSION_HEX < 0x070201
-    myEntity = aSelection->Sensitive();
-#else
-    myEntity = aSelEntIter.Value();
-#endif
-    break;
-  }
-  TreeModel_ItemBase::Init();
-}
-
-// =======================================================================
-// function : Reset
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::Reset()
-{
-  // an empty method to don't clear the main label, otherwise the model will be empty
-  TreeModel_ItemBase::Reset();
-  myEntity = NULL;
-}
-
-// =======================================================================
-// function : initItem
-// purpose :
-// =======================================================================
-void VInspector_ItemSensitiveEntity::initItem() const
-{
-  if (IsInitialized())
-    return;
-  const_cast<VInspector_ItemSensitiveEntity*>(this)->Init();
-}
-
-// =======================================================================
-// function : getEntityOwner
-// purpose :
-// =======================================================================
-Handle(SelectMgr_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner() const
-{
-  initItem();
-
-  Handle(SelectMgr_EntityOwner) anOwner;
-  const Handle(Select3D_SensitiveEntity)& aBase = myEntity->BaseSensitive();
-  if (aBase.IsNull())
-    return anOwner;
-  return aBase->OwnerId();
-}
diff --git a/tools/VInspector/VInspector_ItemSensitiveEntity.hxx b/tools/VInspector/VInspector_ItemSensitiveEntity.hxx
deleted file mode 100644 (file)
index 4fbe804..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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. 
-
-#ifndef VInspector_ItemSensitiveEntity_H
-#define VInspector_ItemSensitiveEntity_H
-
-#include <SelectMgr_SensitiveEntity.hxx>
-#include <Select3D_SensitiveEntity.hxx>
-#include <Standard.hxx>
-#include <inspector/VInspector_ItemBase.hxx>
-
-class SelectMgr_EntityOwner;
-class VInspector_ItemSensitiveEntity;
-
-typedef QExplicitlySharedDataPointer<VInspector_ItemSensitiveEntity> VInspector_ItemSensitiveEntityPtr;
-
-//! \class VInspector_ItemSensitiveEntity
-//! The item shows information about SelectMgr_EntityOwner.
-//! The parent is item selection, children are item entity owners
-class VInspector_ItemSensitiveEntity : public VInspector_ItemBase
-{
-
-public:
-
-  //! Creates an item wrapped by a shared pointer
-  static VInspector_ItemSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  { return VInspector_ItemSensitiveEntityPtr (new VInspector_ItemSensitiveEntity (theParent, theRow, theColumn)); }
-
-  //! Destructor
-  virtual ~VInspector_ItemSensitiveEntity() Standard_OVERRIDE {};
-
-  //! \return the current sensitive entity
-  Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const;
-
-  //! Inits the item, fills internal containers
-  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
-
-  //! Resets cached values
-  Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
-
-protected:
-
-  //! Initialize the current item. It is empty because Reset() is also empty.
-  virtual void initItem() const Standard_OVERRIDE;
-
-  //! \return number of children.
-  virtual int initRowCount() const Standard_OVERRIDE { return !GetSensitiveEntity()->BaseSensitive().IsNull() ? 1 : 0; }
-
-  //! Returns item information for the given role. Fills internal container if it was not filled yet
-  //! \param theItemRole a value role
-  //! \return the value
-  virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
-
-protected:
-
-  //! Creates a child item in the given position.
-  //! \param theRow the child row position
-  //! \param theColumn the child column position
-  //! \return the created item
-  virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
-
-  //! Returns owner of the current sensitive entity
-  //! \return owner
-  Handle(SelectMgr_EntityOwner) getEntityOwner() const;
-
-private:
-
-  //! Constructor
-  //! param theParent a parent item
-  VInspector_ItemSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
-  : VInspector_ItemBase(theParent, theRow, theColumn) {}
-
-private:
-
-  Handle(SelectMgr_SensitiveEntity) myEntity; //!< the current entity owner
-};
-
-#endif
diff --git a/tools/VInspector/VInspector_SelectionType.hxx b/tools/VInspector/VInspector_SelectionType.hxx
deleted file mode 100644 (file)
index 1de71e1..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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. 
-
-#ifndef VInspector_SelectionType_H
-#define VInspector_SelectionType_H
-
-//! Type of SelectMgr enumeration types
-enum VInspector_SelectionType
-{
-  VInspector_SelectionType_TypeOfUpdate, //!< Values of SelectMgr_TypeOfUpdate
-  VInspector_SelectionType_StateOfSelection, //!< Values of SelectMgr_StateOfSelection
-  VInspector_SelectionType_TypeOfBVHUpdate //!< Values of SelectMgr_TypeOfBVHUpdate
-};
-
-#endif
-                                                           
\ No newline at end of file
index 762645463bc3f1b9d193edf079f96e365b319e73..fe062f979316173e4bbf12106406387312c74b49 100644 (file)
@@ -20,9 +20,7 @@
 enum VInspector_ToolActionType
 {
   VInspector_ToolActionType_NoneId, //!< No action activated
-  VInspector_ToolActionType_UpdateId, //!< Update content of tree view (content of AIS_InteractiveContext)
-  VInspector_ToolActionType_SelectPresentationsId, //!< Selects presentation in context by selection in tree view
-  VInspector_ToolActionType_SelectOwnersId //!< Selects owners in context by selection in tree view
+  VInspector_ToolActionType_UpdateId //!< Update content of tree view (content of AIS_InteractiveContext)
 };
 
 #endif
index 819a8856c3366a5e56dc16fac4874909a157c252..193e5dc55c9761a88a224b05501047766e139f01 100644 (file)
@@ -35,14 +35,6 @@ VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
 
   myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
 
-  myActionsMap[VInspector_ToolActionType_SelectPresentationsId] = new QPushButton (theParent);
-  myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setText ("Select Presentations");
-  myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setCheckable (true);
-
-  myActionsMap[VInspector_ToolActionType_SelectOwnersId] = new QPushButton (theParent);
-  myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setText ("Select Owners");
-  myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setCheckable (true);
-
   myMainWindow = new QWidget (theParent);
 
   QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
@@ -84,11 +76,6 @@ void VInspector_ToolBar::onActionClicked()
     break;
   }
 
-  if (anId == VInspector_ToolActionType_SelectPresentationsId && myActionsMap[VInspector_ToolActionType_SelectOwnersId]->isChecked())
-    myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setChecked(false);
-  else if (anId == VInspector_ToolActionType_SelectOwnersId && myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->isChecked())
-    myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setChecked(false);
-
   if (anId != -1)
     emit actionClicked (anId);
 }
index 97ddbaeee4291b1567e6a17c2377bed98ebffb90..f4c7433aaa414e1f9f967299c4a0410645f92b7b 100644 (file)
@@ -40,7 +40,7 @@ public:
   Standard_EXPORT VInspector_ToolBar (QWidget* theParent);
 
   //! Destructor
-  virtual ~VInspector_ToolBar() Standard_OVERRIDE {}
+  virtual ~VInspector_ToolBar() {}
 
   //! Returns main control
   QWidget* GetControl() const { return myMainWindow; }
index eeb52fe9832b5f766d85af2c7b0bc37d46542d31..8c33d500de2af160f3f23273de2a6062fae94efa 100644 (file)
 
 #include <inspector/VInspector_Tools.hxx>
 
+#include <inspector/ViewControl_TableModelValues.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/Convert_Tools.hxx>
+
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_Selection.hxx>
 #include <AIS_Shape.hxx>
-#include <AIS_Trihedron.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
-#include <gp_Trsf.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <Graphic3d_IndexBuffer.hxx>
+#include <Graphic3d_Buffer.hxx>
+#include <Graphic3d_BoundBuffer.hxx>
+
 #include <SelectMgr_StateOfSelection.hxx>
 #include <SelectMgr_TypeOfUpdate.hxx>
 #include <SelectMgr_TypeOfBVHUpdate.hxx>
-#include <Standard_Version.hxx>
 #include <StdSelect_BRepOwner.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
+#include <TopoDS_Compound.hxx>
+
 #include <sstream>
 
 // =======================================================================
@@ -46,30 +55,6 @@ TCollection_AsciiString VInspector_Tools::GetShapeTypeInfo (const TopAbs_ShapeEn
   return aSStream.str().c_str();
 }
 
-// =======================================================================
-// function : GetPointerInfo
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
-  std::ostringstream aPtrStr;
-  aPtrStr << thePointer.operator->();
-  if (!isShortInfo)
-    return aPtrStr.str().c_str();
-
-  TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
-  for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
-  {
-    if (anInfoPtr.Value(aSymbolId) != '0')
-    {
-      anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
-      anInfoPtr.Prepend("0x");
-      return anInfoPtr;
-    }
-  }
-  return aPtrStr.str().c_str();
-}
-
 // =======================================================================
 // function : SelectedOwners
 // purpose :
@@ -100,12 +85,12 @@ int VInspector_Tools::SelectedOwners (const Handle(AIS_InteractiveContext)& theC
     if (theShapeInfoOnly && BROwnr.IsNull())
       continue;
 
-    Standard_Transient* anOwnerPtr = anOwner.operator->();
+    Standard_Transient* anOwnerPtr = anOwner.get();
     if (aSelectedIds.contains ((size_t)anOwnerPtr))
       continue;
     aSelectedIds.append ((size_t)anOwnerPtr);
 
-    anObjects.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+    anObjects.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
   }
   return anObjects.size();
 }
@@ -115,12 +100,11 @@ int VInspector_Tools::SelectedOwners (const Handle(AIS_InteractiveContext)& theC
 // purpose :
 // =======================================================================
 bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
-                                        const Handle(SelectMgr_EntityOwner)& theOwner)
+                                        const Handle(SelectBasics_EntityOwner)& theOwner)
 {
   bool anIsSelected = false;
-  Handle(SelectMgr_EntityOwner) anOwner = theOwner;
   for (theContext->InitSelected(); theContext->MoreSelected() && !anIsSelected; theContext->NextSelected())
-    anIsSelected = theContext->SelectedOwner() == anOwner;
+    anIsSelected = theContext->SelectedOwner() == theOwner;
   return anIsSelected;
 }
 
@@ -128,10 +112,10 @@ bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& th
 // function : ContextOwners
 // purpose :
 // =======================================================================
-NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners (
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwners (
                                                const Handle(AIS_InteractiveContext)& theContext)
 {
-  NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
+  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
   if (theContext.IsNull())
     return aResultOwners;
 
@@ -143,16 +127,6 @@ NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners
     Handle(AIS_InteractiveObject) anIO = aIt.Value();
     if (anIO.IsNull())
       continue;
-#if OCC_VERSION_HEX < 0x070201
-    for (anIO->Init(); anIO->More(); anIO->Next())
-    {
-      Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection();
-      if (aSelection.IsNull())
-        continue;
-      for (aSelection->Init(); aSelection->More(); aSelection->Next())
-      {
-        Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
-#else
     for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next())
     {
       Handle(SelectMgr_Selection) aSelection = aSelIter.Value();
@@ -161,12 +135,11 @@ NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners
       for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
       {
         Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
-#endif
         if (anEntity.IsNull())
           continue;
-        const Handle(Select3D_SensitiveEntity)& aBase = anEntity->BaseSensitive();
-        Handle(SelectMgr_EntityOwner) anOwner = aBase->OwnerId();
-        Standard_Transient* anOwnerPtr = anOwner.operator->();
+        const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+        Handle(SelectBasics_EntityOwner) anOwner = aBase->OwnerId();
+        Standard_Transient* anOwnerPtr = anOwner.get();
         if (aSelectedIds.contains ((size_t)anOwnerPtr))
           continue;
         aSelectedIds.append ((size_t)anOwnerPtr);
@@ -181,32 +154,29 @@ NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ContextOwners
 // function : ActiveOwners
 // purpose :
 // =======================================================================
-NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ActiveOwners (
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ActiveOwners (
                                 const Handle(AIS_InteractiveContext)& theContext,
-                                NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners)
+                                NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners)
 {
-  NCollection_List<Handle(SelectMgr_EntityOwner)> aResultOwners;
+  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
 
   // only local context is processed: TODO for global context
   Handle(AIS_InteractiveContext) aContext = theContext;
   if (aContext.IsNull())
     return aResultOwners;
-  NCollection_List<Handle(SelectMgr_EntityOwner)> anActiveOwners;
+  NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
   // OCCT BUG:1 - equal pointer owners are appears in the list
-#if OCC_VERSION_HEX > 0x060901
   aContext->MainSelector()->ActiveOwners (anActiveOwners);
-#else
-  anActiveOwners = aContext->MainSelector()->ActiveOwners();
-#endif
   QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
-  for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+  Handle(SelectMgr_EntityOwner) anOwner;
+  for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
        anOwnersIt.More(); anOwnersIt.Next())
   {
-    const Handle(SelectMgr_EntityOwner)& anOwner = anOwnersIt.Value();
+    anOwner = anOwnersIt.Value();
     if (anOwner.IsNull())
       continue;
 
-    Standard_Transient* anOwnerPtr = anOwner.operator->();
+    Standard_Transient* anOwnerPtr = anOwner.get();
     if (aSelectedIds.contains ((size_t)anOwnerPtr))
       continue;
     aSelectedIds.append ((size_t)anOwnerPtr);
@@ -225,7 +195,7 @@ NCollection_List<Handle(SelectMgr_EntityOwner)> VInspector_Tools::ActiveOwners (
 // purpose :
 // =======================================================================
 void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
-                                                  const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
+                                                  const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
 {
   // TODO: the next two rows are to be removed later
   theContext->UnhilightSelected(false);
@@ -233,7 +203,7 @@ void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveCo
 
   theContext->UnhilightSelected(Standard_False);
 
-  for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anOwnersIt(theOwners);
+  for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
        anOwnersIt.More(); anOwnersIt.Next())
   {
     Handle(SelectMgr_EntityOwner) anOwner = anOwnersIt.Value();
@@ -267,7 +237,7 @@ QList<QVariant> VInspector_Tools::GetInfo (Handle(AIS_InteractiveObject)& theObj
 {
   QList<QVariant> anInfo;
   anInfo.append (theObject->DynamicType()->Name());
-  anInfo.append (VInspector_Tools::GetPointerInfo (theObject, true).ToCString());
+  anInfo.append (Standard_Dump::GetPointerInfo (theObject, true).ToCString());
 
   Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theObject);
   if (aShapeIO.IsNull())
@@ -300,7 +270,7 @@ QList<QVariant> VInspector_Tools::GetHighlightInfo (const Handle(AIS_Interactive
     Handle(SelectMgr_EntityOwner) anOwner = theContext->DetectedOwner();
     if (anOwner.IsNull())
       continue;
-    Standard_Transient* anOwnerPtr = anOwner.operator->();
+    Standard_Transient* anOwnerPtr = anOwner.get();
     if (aSelectedIds.contains ((size_t)anOwnerPtr))
       continue;
     aSelectedIds.append ((size_t)anOwnerPtr);
@@ -314,7 +284,7 @@ QList<QVariant> VInspector_Tools::GetHighlightInfo (const Handle(AIS_Interactive
       aSelectedPointers.append (anIOInfo[1].toString());
       aSelectedTypes.append (anIOInfo[2].toString());
     }
-    aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+    aSelectedOwners.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
   }
   aValues.append (aSelectedNames.join (", "));
   aValues.append (aSelectedPointers.join (", "));
@@ -344,7 +314,7 @@ QList<QVariant> VInspector_Tools::GetSelectedInfo (const Handle(AIS_InteractiveC
     Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
     if (anOwner.IsNull())
       continue;
-    Standard_Transient* anOwnerPtr = anOwner.operator->();
+    Standard_Transient* anOwnerPtr = anOwner.get();
     if (aSelectedIds.contains ((size_t)anOwnerPtr))
       continue;
     aSelectedIds.append ((size_t)anOwnerPtr);
@@ -359,7 +329,7 @@ QList<QVariant> VInspector_Tools::GetSelectedInfo (const Handle(AIS_InteractiveC
       aSelectedPointers.append (anIOInfo[1].toString());
       aSelectedTypes.append (anIOInfo[2].toString());
     }
-    aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+    aSelectedOwners.append (Standard_Dump::GetPointerInfo (anOwnerPtr, true).ToCString());
   }
   aValues.append (aSelectedNames.join (", "));
   aValues.append (aSelectedPointers.join (", "));
@@ -378,125 +348,39 @@ QString VInspector_Tools::GetSelectedInfoPointers (const Handle(AIS_InteractiveC
   return aSelectedInfo.size() > 2 ? aSelectedInfo[1].toString() : QString();
 }
 
-// =======================================================================
-// function : ToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::ToName (const VInspector_SelectionType theType, const int theValue)
-{
-  switch (theType)
-  {
-    case VInspector_SelectionType_TypeOfUpdate:
-    {
-      switch (theValue)
-      {
-        case SelectMgr_TOU_Full:    return "Full";
-        case SelectMgr_TOU_Partial: return "Partial";
-        case SelectMgr_TOU_None:    return "None";
-        default: break;
-      }
-    }
-    break;
-    case VInspector_SelectionType_StateOfSelection:
-    {
-      switch (theValue)
-      {
-        case SelectMgr_SOS_Any:         return "Any";
-        case SelectMgr_SOS_Unknown:     return "Unknown";
-        case SelectMgr_SOS_Activated:   return "Activated";
-        case SelectMgr_SOS_Deactivated: return "Deactivated";
-        default: break;
-      }
-    }
-    break;
-    case VInspector_SelectionType_TypeOfBVHUpdate:
-    {
-      switch (theValue)
-      {
-        case SelectMgr_TBU_Add:        return "Add";
-        case SelectMgr_TBU_Remove:     return "Remove";
-        case SelectMgr_TBU_Renew:      return "Renew";
-        case SelectMgr_TBU_Invalidate: return "Invalidate";
-        case SelectMgr_TBU_None:       return "None";
-        default: break;
-      }
-    }
-    default: break;
-  }
-  return "";
-}
-
-// =======================================================================
-// function : SelectionModeToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation)
+namespace
 {
-  // types are obtained by comment of SelectMgr_Selection class;
-  Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (thePresentation);
-  if (!aShapePresentation.IsNull())
-    return VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType (theMode)).ToCString();
-  else
+  static Standard_CString VInspector_Table_PrintDisplayActionType[5] =
   {
-    Handle(AIS_Trihedron) aTrihedronPresentation = Handle(AIS_Trihedron)::DownCast (thePresentation);
-    if (!aTrihedronPresentation.IsNull())
-    {
-      switch (theMode)
-      {
-        case 0: return "Trihedron";
-        case 1: return "Trihedron Origin";
-        case 2: return "Trihedron Axes";
-        case 3: return "Trihedron Planes";
-        default: break;
-      }
-    }
-  }
-  return TCollection_AsciiString (theMode);
+    "None", "Display", "Redisplay", "Erase", "Remove"
+  };
 }
 
-// =======================================================================
-// function : OrientationToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::OrientationToName (const TopAbs_Orientation& theOrientation)
+//=======================================================================
+//function : DisplayActionTypeToString
+//purpose  :
+//=======================================================================
+Standard_CString VInspector_Tools::DisplayActionTypeToString (View_DisplayActionType theType)
 {
-  Standard_SStream aSStream;
-  TopAbs::Print(theOrientation, aSStream);
-  return aSStream.str().c_str();
+  return VInspector_Table_PrintDisplayActionType[theType];
 }
 
-// =======================================================================
-// function : LocationToName
-// purpose :
-// =======================================================================
-TCollection_AsciiString VInspector_Tools::LocationToName (const TopLoc_Location& theLocation)
+//=======================================================================
+//function : DisplayActionTypeFromString
+//purpose  :
+//=======================================================================
+Standard_Boolean VInspector_Tools::DisplayActionTypeFromString (Standard_CString theTypeString,
+                                                                View_DisplayActionType& theType)
 {
-  gp_Trsf aTrsf = theLocation.Transformation();
-
-  TCollection_AsciiString aValues;
-  for (int aRowId = 1; aRowId <= 3; aRowId++)
+  const TCollection_AsciiString aName (theTypeString);
+  for (Standard_Integer aTypeIter = 0; aTypeIter <= View_DisplayActionType_RemoveId; ++aTypeIter)
   {
-    for (int aColId = 1; aColId <= 4; aColId++) {
-      aValues += TCollection_AsciiString (aTrsf.Value(aRowId, aColId));
-      if (aColId != 4)
-        aValues += ",";
+    Standard_CString aTypeName = VInspector_Table_PrintDisplayActionType[aTypeIter];
+    if (aName == aTypeName)
+    {
+      theType = View_DisplayActionType (aTypeIter);
+      return Standard_True;
     }
-    if (aRowId != 3)
-      aValues += "  ";
   }
-  return aValues;
-}
-
-// =======================================================================
-// function : ReadShape
-// purpose :
-// =======================================================================
-TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFileName)
-{
-  TopoDS_Shape aShape;
-
-  BRep_Builder aBuilder;
-  BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
-
-  return aShape;
+  return Standard_False;
 }
index 5b116b446fa054c4f3eca3f1c9461ed5f961d5e7..2b65f9d338ff2fee974104acd62e08f1155fd4a0 100644 (file)
 #define VInspector_Tools_H
 
 #include <AIS_InteractiveContext.hxx>
+#include <Bnd_Box.hxx>
+#include <Bnd_OBB.hxx>
+#include <Graphic3d_Buffer.hxx>
+#include <Graphic3d_Mat4.hxx>
+#include <Graphic3d_Mat4d.hxx>
+#include <Select3D_BndBox3d.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TopoDS_Shape.hxx>
 
 #include <inspector/VInspector_CallBackMode.hxx>
-#include <inspector/VInspector_SelectionType.hxx>
+#include <inspector/View_DisplayActionType.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QList>
 #include <QVariant>
 #include <Standard_WarningsRestore.hxx>
 
+class ViewControl_TableModelValues;
+
+class Graphic3d_IndexBuffer;
+class Graphic3d_Buffer;
+class Graphic3d_BoundBuffer;
+
 //! \class VInspector_Tools
 //! The class that gives auxiliary methods for Visualization elements manipulation
 class VInspector_Tools
@@ -45,13 +59,6 @@ public:
   //! \return text value
   Standard_EXPORT static TCollection_AsciiString GetShapeTypeInfo (const TopAbs_ShapeEnum& theType);
 
-  //! Convert pointer to string value
-  //! \param thePointer a pointer
-  //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
-  //! \return the string value 
-  Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
-                                                                 const bool isShortInfo);
-
   //! Returns number of selected owners for presentation
   //! \param theContext an interactive context
   //! \param theObject a presentation
@@ -65,27 +72,27 @@ public:
   //! \param theOwner a selectable owner
   //! \return boolean value
   Standard_EXPORT static bool IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
-                                               const Handle(SelectMgr_EntityOwner)& theOwner);
+                                               const Handle(SelectBasics_EntityOwner)& theOwner);
 
   //! Returns all owners present in the context
   //! \param theContext an interactive context
   //! \return container of owners
-  Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ContextOwners (
+  Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ContextOwners (
                                                  const Handle(AIS_InteractiveContext)& theContext);
 
   //! Returns active owners in main selector of context
   //! \param theContext an interactive context
   //! \param theEmptySelectableOwners container of owners with NULL presentation or not displayed presentation
   //! \return container of owners
-  Standard_EXPORT static NCollection_List<Handle(SelectMgr_EntityOwner)> ActiveOwners (
+  Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners (
                             const Handle(AIS_InteractiveContext)& theContext,
-                            NCollection_List<Handle(SelectMgr_EntityOwner)>& theEmptySelectableOwners);
+                            NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners);
 
   //! Unhighlight selected, set selected the owners
   //! \param theContext an interactive context
   //! \param theOwners a container of owners
   Standard_EXPORT static void AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
-                                         const NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
+                                         const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
 
   //! Unhighlight selected, set selected presentations
   //! \param theContext an interactive context
@@ -111,32 +118,27 @@ public:
   //! Returns the first pointer of selection in the context
   Standard_EXPORT static QString GetSelectedInfoPointers (const Handle(AIS_InteractiveContext)& theContext);
 
-  //! Returns string information of call back mode
-  //! \param theMode type of selection
-  //! \param theValue a value in selection enumeration
-  //! \return information text
-  Standard_EXPORT static TCollection_AsciiString ToName (const VInspector_SelectionType theType, const int theValue);
-
-  //! Returns selection information 
-  //! \param theMode a selection mode
-  //! \param thePresentation a presentation
-  //! \return text value
-  Standard_EXPORT static TCollection_AsciiString SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation);
-
-  //! Returns text of orientation
-  //! \param theOrientation an orientation value
-  //! \return text value
-  Standard_EXPORT static TCollection_AsciiString OrientationToName (const TopAbs_Orientation& theOrientation);
-
-  //! Returns text of orientation
-  //! \param theLocation a location value
-  //! \return text value
-  Standard_EXPORT static TCollection_AsciiString LocationToName (const TopLoc_Location& theLocation);
-
-  //! Read Shape using BREP reader
-  //! \param theFileName a file name
-  //! \return shape or NULL
-  Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+  //! Returns the string name for a given type.
+  //! @param theType action type
+  //! @return string identifier from the display action type
+  Standard_EXPORT static Standard_CString DisplayActionTypeToString (View_DisplayActionType theType);
+
+  //! Returns the enumeration type from the given string identifier (using case-insensitive comparison).
+  //! @param theTypeString string identifier
+  //! @return string identifier from the display action type
+  static View_DisplayActionType DisplayActionTypeFromString (Standard_CString theTypeString)
+  {
+    View_DisplayActionType aType = View_DisplayActionType_NoneId;
+    DisplayActionTypeFromString (theTypeString, aType);
+    return aType;
+  }
+
+  //! Determines the enumeration type from the given string identifier (using case-insensitive comparison).
+  //! @param theTypeString string identifier
+  //! @param theType detected action type
+  //! @return TRUE if string identifier is known
+  Standard_EXPORT static Standard_Boolean DisplayActionTypeFromString (Standard_CString theTypeString,
+                                                                       View_DisplayActionType& theType);
 };
 
 #endif
index 207ad48541b62cf6642098c75e354e3a77509f66..2ca792b334b158835662706cc562885cd7648344 100644 (file)
 
 #include <inspector/TreeModel_Tools.hxx>
 #include <inspector/VInspector_ItemContext.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
 #include <inspector/VInspector_ItemPresentableObject.hxx>
-#include <inspector/VInspector_ItemSensitiveEntity.hxx>
-#include <SelectMgr_EntityOwner.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QItemSelectionModel>
 #include <QStringList>
 #include <Standard_WarningsRestore.hxx>
 
-const int COLUMN_NAME_WIDTH = 260;
-const int COLUMN_SIZE_WIDTH = 30;
 const int COLUMN_POINTER_WIDTH = 70;
-const int COLUMN_SHAPE_TYPE_WIDTH = 75;
 
 // =======================================================================
 // function : Constructor
@@ -39,42 +33,27 @@ const int COLUMN_SHAPE_TYPE_WIDTH = 75;
 VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
   : TreeModel_ModelBase (theParent)
 {
-  SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("ShapeType", COLUMN_SHAPE_TYPE_WIDTH)); // ItemPresentableObject, ItemSelection
-  SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); // ItemContext, ItemPresentableObject, ItemSelection
-  SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
-  SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
-  SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
-  SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
-
-  SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
-  SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
-  SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
-  SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
-
-  SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
-  SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
-  SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
-  SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
-
-  SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
-  SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
-  SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
-
-  SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void VInspector_ViewModel::InitColumns()
+{
+  TreeModel_ModelBase::InitColumns();
+
+  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+  SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1));
 }
 
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void VInspector_ViewModel::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModel::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
@@ -95,29 +74,42 @@ void VInspector_ViewModel::SetContext (const Handle(AIS_InteractiveContext)& the
   // fill root item by the application
   for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
     itemDynamicCast<VInspector_ItemContext>(myRootItems[aColId])->SetContext (theContext);
-  EmitLayoutChanged();
+
+  UpdateTreeModel();
 }
 
 // =======================================================================
 // function : FindPointers
 // purpose :
 // =======================================================================
-QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers)
+void VInspector_ViewModel::FindPointers (const QStringList& thePointers,
+                                         const QModelIndex& theParent,
+                                         QModelIndexList& theFoundIndices)
 {
-  QModelIndexList anIndices;
-  QModelIndex aParentIndex = index (0, 0);
+  (void)thePointers;
+  (void)theParent;
+  (void)theFoundIndices;
+  // should be used after Object of items is improved, as it takes a lot of time on BVH item
+  /*
+  if (thePointers.isEmpty())
+    return;
+
+  QModelIndex aParentIndex = theParent.isValid() ? theParent : index (0, 0);
   TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item
   for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++)
   {
     QModelIndex anIndex = index (aRowId, 0, aParentIndex);
     TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
-    VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast<VInspector_ItemPresentableObject>(anItemBase);
-    if (!anItemPrs)
+    VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItemBase);
+    if (!aVItem)
       continue;
-    if (thePointers.contains (anItemPrs->PointerInfo()))
-      anIndices.append (anIndex);
-  }
-  return anIndices;
+    const Handle(Standard_Transient)& anObject = aVItem->Object();
+    TCollection_AsciiString aPointerInfo = Standard_Dump::GetPointerInfo (anObject);
+    if (thePointers.contains (aPointerInfo.ToCString()))
+      theFoundIndices.append (anIndex);
+
+    FindPointers (thePointers, anIndex, theFoundIndices);
+  }*/
 }
 
 // =======================================================================
@@ -141,49 +133,6 @@ QModelIndex VInspector_ViewModel::FindIndex (const Handle(AIS_InteractiveObject)
   return QModelIndex();
 }
 
-// =======================================================================
-// function : GetSelectedOwners
-// purpose :
-// =======================================================================
-void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionModel,
-                                              NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners)
-{
-  if (!theSelectionModel)
-    return;
-  QList<TreeModel_ItemBasePtr> anItems;
-  
-  QModelIndexList anIndices = theSelectionModel->selectedIndexes();
-  for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
-  {
-    TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
-    if (!anItem || anItems.contains (anItem))
-      continue;
-    anItems.append (anItem);
-  }
-
-  QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
-  for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
-  {
-    TreeModel_ItemBasePtr anItem = *anItemIt;
-    Handle(SelectMgr_EntityOwner) anEntityOwner;
-    if (VInspector_ItemEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemEntityOwner>(anItem))
-    {
-      anEntityOwner = anOwnerItem->EntityOwner();
-    }
-    else if (VInspector_ItemSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(anItem))
-    {
-      anEntityOwner = aSensItem->GetSensitiveEntity()->BaseSensitive()->OwnerId();
-    }
-    if (anEntityOwner.IsNull())
-      continue;
-    if (aSelectedIds.contains ((size_t)anEntityOwner.operator->()))
-      continue;
-    aSelectedIds.append ((size_t)anEntityOwner.operator->());
-    if (!anEntityOwner.IsNull())
-      theOwners.Append (anEntityOwner);
-  }
-}
-
 // =======================================================================
 // function : UpdateTreeModel
 // purpose :
index 839e5500576063cdf9167d4b0baf3e2ebb845299..906f9f60f768c8da09fc2fa544750241f50d0611 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <AIS_InteractiveContext.hxx>
 #include <NCollection_List.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
 #include <Standard.hxx>
 #include <inspector/TreeModel_ModelBase.hxx>
 #include <inspector/VInspector_ItemBase.hxx>
@@ -47,7 +47,10 @@ public:
   Standard_EXPORT VInspector_ViewModel (QObject* theParent);
 
   //! Destructor
-  virtual ~VInspector_ViewModel() Standard_OVERRIDE {};
+  virtual ~VInspector_ViewModel() {}
+
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
 
   //! Initialize the model by the given context
   //! \param theContext viewer context
@@ -59,38 +62,25 @@ public:
 
   //! Returns tree view indices for the given pointers of presentable object
   //! \param thePointers a list of presentation pointers
-  //! \return container of indices
-  Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers);
+  //! \param theParent an index of the parent item
+  //! \param [out] container of indices
+  Standard_EXPORT void FindPointers (const QStringList& thePointers,
+                                     const QModelIndex& theParent,
+                                     QModelIndexList& theFoundIndices);
 
   //! Returns tree model index of the presentation item in the tree view.
   //! \param thePresentation a presentation
   //! \return model index if the value is found or Null model index
   Standard_EXPORT QModelIndex FindIndex (const Handle(AIS_InteractiveObject)& thePresentation) const;
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
-  { return myRootItems[theColumn]; }
-
-  //! Returns select owners for tree view selected items
-  //! \param theSelectionModel a selection model
-  //! \param theOwners an output list of owners
-  Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel,
-                                                 NCollection_List<Handle(SelectMgr_EntityOwner)>& theOwners);
-
   //! Updates tree model
   Standard_EXPORT void UpdateTreeModel();
 
 protected:
-
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
-
-private:
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
 };
 
 #endif
index de42b99fd77ad3c07a540575f2f9d52b0e04c79e..980dc1e865890ff6dbfa76424b1c9dcce94b68a1 100644 (file)
@@ -42,32 +42,40 @@ const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
 // purpose :
 // =======================================================================
 VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
-: TreeModel_ModelBase (theParent)
+: TreeModel_ModelBase (theParent), myHistoryTypesMaxAmount (theHistoryTypesMaxAmount)
 {
+}
+
+// =======================================================================
+// function : InitColumns
+// purpose :
+// =======================================================================
+void VInspector_ViewModelHistory::InitColumns()
+{
+  TreeModel_ModelBase::InitColumns();
+
   SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
-  SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
-  SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
-  SetHeaderItem (3, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
-  SetHeaderItem (4, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
-  SetHeaderItem (5, TreeModel_HeaderSection ("Selected/Highlighted", -1));
+  SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", COLUMN_SIZE_WIDTH)); // visualization item
+  SetHeaderItem (2, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
+  SetHeaderItem (3, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
+  SetHeaderItem (4, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
+  SetHeaderItem (5, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
+  SetHeaderItem (6, TreeModel_HeaderSection ("Selected/Highlighted", -1));
 
   for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
   {
     VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot> (myRootItems[aColumnId]);
-    aRootItem->SetHistoryTypesMaxAmount (theHistoryTypesMaxAmount);
+    aRootItem->SetHistoryTypesMaxAmount (myHistoryTypesMaxAmount);
   }
 }
 
-
 // =======================================================================
 // function : createRootItem
 // purpose :
 // =======================================================================
-void VInspector_ViewModelHistory::createRootItem (const int theColumnId)
+TreeModel_ItemBasePtr VInspector_ViewModelHistory::createRootItem (const int theColumnId)
 {
-  myRootItems.insert (theColumnId, VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
-  if (theColumnId == 0)
-      m_pRootItem = myRootItems[0];
+  return VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId);
 }
 
 // =======================================================================
index d4215c34755e1fd6423e022abfc5d68bfc1099df..304023477e83467802035e7f716bac0a14e8b421 100644 (file)
@@ -41,7 +41,10 @@ public:
   Standard_EXPORT VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount = 50);
 
   //! Destructor
-  virtual ~VInspector_ViewModelHistory() Standard_OVERRIDE {};
+  virtual ~VInspector_ViewModelHistory() {}
+
+  //! Creates model columns and root items.
+  Standard_EXPORT virtual void InitColumns() Standard_OVERRIDE;
 
   //! Append new element under the root item
   Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
@@ -51,20 +54,14 @@ public:
   //! \param container of strings
   Standard_EXPORT QStringList GetSelectedPointers (const QModelIndex& theIndex);
 
-  //! Returns root item by column
-  //! \param theColumn an index of the column
-  //! \return root item instance
-  virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE { return myRootItems[theColumn]; }
-
 protected:
 
   //! Creates root item
   //! \param theColumnId index of a column
-  virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
+  Standard_EXPORT virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) Standard_OVERRIDE;
 
 private:
-
-  QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+  int myHistoryTypesMaxAmount; //!< maximum types in history
 };
 
 #endif
index e102fbb709dabfb26c501a7c35dfabac9bf13ef1..22ed9e50f63d4decff4ffec8054315ba17d1f20a 100644 (file)
 #include <inspector/VInspector_Window.hxx>
 
 #include <AIS_Shape.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+
+#include <inspector/Convert_Tools.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/Convert_TransientShape.hxx>
 
-#include <inspector/VInspector_ItemPresentableObject.hxx>
 #include <inspector/VInspector_ToolBar.hxx>
 #include <inspector/VInspector_Tools.hxx>
 #include <inspector/VInspector_ViewModel.hxx>
 #include <inspector/VInspector_CallBack.hxx>
 #include <inspector/VInspector_Communicator.hxx>
-#include <inspector/VInspector_ItemEntityOwner.hxx>
-#include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
 #include <inspector/VInspector_ToolBar.hxx>
 #include <inspector/VInspector_Tools.hxx>
 #include <inspector/VInspector_ViewModel.hxx>
 #include <inspector/VInspector_ViewModelHistory.hxx>
 
+#include <inspector/ViewControl_PropertyView.hxx>
 #include <inspector/ViewControl_TreeView.hxx>
 
+#include <inspector/View_Displayer.hxx>
+#include <inspector/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
 #include <inspector/View_Widget.hxx>
 #include <inspector/View_Window.hxx>
 
@@ -56,6 +64,9 @@
 #include <QWidget>
 #include <Standard_WarningsRestore.hxx>
 
+const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH = 300;
+const int VINSPECTOR_DEFAULT_PROPERTY_VIEW_HEIGHT = 1000;
+
 const int VINSPECTOR_DEFAULT_WIDTH  = 1250;
 const int VINSPECTOR_DEFAULT_HEIGHT = 800;
 
@@ -78,6 +89,8 @@ const int VINSPECTOR_DEFAULT_VIEW_POSITION_Y = 60; // TINSPECTOR_DEFAULT_POSITIO
 VInspector_Window::VInspector_Window()
 : myParent (0), myExportToShapeViewDialog (0), myViewWindow (0)
 {
+  myDisplayer = new View_Displayer();
+
   myMainWindow = new QMainWindow (0);
 
   QWidget* aCentralWidget = new QWidget (myMainWindow);
@@ -97,6 +110,7 @@ VInspector_Window::VInspector_Window()
   myTreeView->header()->setStretchLastSection (true);
   myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
   VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
+  aTreeModel->InitColumns();
   myTreeView->setModel (aTreeModel);
   // hide Visibility column
   TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
@@ -110,12 +124,22 @@ VInspector_Window::VInspector_Window()
   QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
   myTreeView->setSelectionModel (aSelModel);
   connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
-           this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
+           this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
 
   aParentLay->addWidget(myTreeView, 1, 0);
   aParentLay->setRowStretch (1, 1);
   myMainWindow->setCentralWidget (aCentralWidget);
 
+  // property view
+  myPropertyView = new ViewControl_PropertyView (myMainWindow,
+    QSize(VINSPECTOR_DEFAULT_PROPERTY_VIEW_WIDTH, VINSPECTOR_DEFAULT_PROPERTY_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);
+  connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool)));
+
   myHistoryView = new ViewControl_TreeView (myMainWindow);
   myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
   ((ViewControl_TreeView*)myHistoryView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
@@ -126,6 +150,7 @@ VInspector_Window::VInspector_Window()
 
   myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
   VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
+  aHistoryModel->InitColumns();
   myHistoryView->setModel (aHistoryModel);
 
   QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
@@ -134,8 +159,8 @@ VInspector_Window::VInspector_Window()
     this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
 
   anItem = aHistoryModel->GetHeaderItem (0);
-  TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
   // hide Visibility column
+  TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
   anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
   anItem.SetIsHidden (true);
   aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
@@ -203,9 +228,29 @@ void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIte
   }
 
   anItems.clear();
-  TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_");
+  View_PreviewParameters::SaveState (displayer()->DisplayPreview()->GetPreviewParameters(), anItems, "preview_parameters_");
   for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
     theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+
+  anItems.clear();
+  TreeModel_Tools::SaveState (myTreeView, anItems);
+  for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+  {
+    theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+  }
+
+  anItems.clear();
+  ViewControl_PropertyView::SaveState (myPropertyView, anItems, "property_view_parameters_");
+  for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+    theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+
+  if (myViewWindow)
+  {
+    anItems.clear();
+    View_Window::SaveState(myViewWindow, anItems);
+    for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+      theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
+  }
 }
 
 // =======================================================================
@@ -223,13 +268,23 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
 
   for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
   {
-    if (anItemIt.Key().IsEqual ("geometry"))
-      myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
-    else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+    TCollection_AsciiString anItemKey = anItemIt.Key();
+    TCollection_AsciiString anItemValue = anItemIt.Value();
+    if (anItemKey.IsEqual ("geometry"))
+      myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemValue.ToCString()));
+    else if (TreeModel_Tools::RestoreState (myTreeView, anItemKey.ToCString(), anItemValue.ToCString()))
       continue;
-    else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
+    else if (TreeModel_Tools::RestoreState (myHistoryView, anItemKey.ToCString(), anItemValue.ToCString(),
                                             "history_view_"))
       continue;
+    else if (View_PreviewParameters::RestoreState (displayer()->DisplayPreview()->GetPreviewParameters(), anItemKey.ToCString(),
+      anItemValue.ToCString(), "preview_parameters_"))
+      continue;
+    else if (ViewControl_PropertyView::RestoreState (myPropertyView, anItemKey.ToCString(),
+      anItemValue.ToCString(), "property_view_parameters_"))
+      continue;
+    else if (myViewWindow && View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
+      continue;
   }
 }
 
@@ -278,6 +333,73 @@ void VInspector_Window::UpdateContent()
        myTreeView->scrollTo (aPresentationIndex);
     }
   }
+
+  if (!myCallBack.IsNull())
+  {
+    VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
+      (myHistoryView->model());
+    aHistoryModel->Reset();
+    aHistoryModel->EmitLayoutChanged();
+  }
+}
+
+// =======================================================================
+// function : SelectedPresentations
+// purpose :
+// =======================================================================
+NCollection_List<Handle(AIS_InteractiveObject)> VInspector_Window::SelectedPresentations (QItemSelectionModel* theModel)
+{
+  NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations;
+
+  QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (theModel->selectedIndexes());
+
+  QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+  NCollection_List<Handle(Standard_Transient)> anItemPresentations;
+  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)
+      continue;
+
+    anItemPresentations.Clear();
+    aVItem->Presentations (anItemPresentations);
+
+    for (NCollection_List<Handle(Standard_Transient)>::Iterator anIt (anItemPresentations); anIt.More(); anIt.Next())
+    {
+      Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (anIt.Value());
+      if (aSelectedIds.contains ((size_t)aPresentation.get()))
+        continue;
+      aSelectedIds.append ((size_t)aPresentation.get());
+      if (!aPresentation.IsNull())
+        aSelectedPresentations.Append (aPresentation);
+    }
+  }
+  return aSelectedPresentations;
+}
+
+// =======================================================================
+// function : SelectedShapes
+// purpose :
+// =======================================================================
+void VInspector_Window::SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations)
+{
+  QModelIndexList theIndices = myTreeView->selectionModel()->selectedIndexes();
+
+  QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (theIndices);
+  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->Row() == 0*/)
+      continue;
+
+    TopoDS_Shape aShape = aVItem->GetPresentationShape();
+    if (aShape.IsNull())
+      continue;
+
+    theSelPresentations.Append (new Convert_TransientShape (aShape));
+  }
 }
 
 // =======================================================================
@@ -286,8 +408,13 @@ void VInspector_Window::UpdateContent()
 // =======================================================================
 bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
 {
+  VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  if (!aViewModel)
+    return Standard_False;
+
   Handle(AIS_InteractiveContext) aContext;
   Handle(VInspector_CallBack) aCallBack;
+  Standard_Boolean isModelUpdated = Standard_False;
 
   for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
   {
@@ -298,13 +425,10 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
     if (aCallBack.IsNull())
       aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
   }
-  if (aContext.IsNull())
-    return false;
-  VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
-  if (aViewModel && aViewModel->GetContext() == aContext)
-    UpdateTreeModel();
+  if (aViewModel->GetContext() != aContext)
+    SetContext(aContext);
   else
-    SetContext (aContext);
+    isModelUpdated = Standard_True;
 
   if (!aCallBack.IsNull() && aCallBack != myCallBack)
   {
@@ -314,6 +438,10 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
     myCallBack->SetContext(aContext);
     myCallBack->SetHistoryModel(aHistoryModel);
   }
+
+  if (isModelUpdated)
+    UpdateTreeModel();
+
   return true;
 }
 
@@ -323,12 +451,18 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
 // =======================================================================
 void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
 {
+  if (theContext.IsNull())
+    return;
+
   VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
   aViewModel->SetContext (theContext);
   myTreeView->setExpanded (aViewModel->index (0, 0), true);
 
   if (!myCallBack.IsNull())
     myCallBack->SetContext (theContext);
+
+  if (myDisplayer)
+    myDisplayer->SetContext (theContext);
 }
 
 // =======================================================================
@@ -350,13 +484,13 @@ bool VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
     isModelUpdated = true;
   }
 
-  TopoDS_Shape aShape = VInspector_Tools::ReadShape (theFileName);
+  TopoDS_Shape aShape = Convert_Tools::ReadShape (theFileName);
   if (aShape.IsNull())
     return isModelUpdated;
 
   Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
-  aContext->Display (aPresentation, false);
-  aContext->Load (aPresentation, -1/*selection mode*/);
+  View_Displayer* aDisplayer = myViewWindow->Displayer();
+  aDisplayer->DisplayPresentation (aPresentation);
   aContext->UpdateCurrentViewer();
 
   UpdateTreeModel();
@@ -372,8 +506,34 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
 {
   QMenu* aMenu = new QMenu (GetMainWindow());
   aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
-  aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Show"), SLOT (onShow()), GetMainWindow(), this));
-  aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Hide"), SLOT (onHide()), GetMainWindow(), this));
+  aMenu->addSeparator();
+
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+  if (anItemBase)
+  {
+    if (itemDynamicCast<VInspector_ItemContext> (anItemBase))
+    {
+      aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this));
+      aMenu->addSeparator();
+    }
+  }
+
+  aMenu->addSeparator();
+  for (int aTypeId = (int)View_DisplayActionType_DisplayId; aTypeId <= (int)View_DisplayActionType_RemoveId; aTypeId++)
+  {
+    aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((View_DisplayActionType) aTypeId),
+                      SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this));
+  }
+  aMenu->addSeparator();
+
+  aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand"), SLOT (onExpand()), GetMainWindow(), this));
+  aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
+  aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
+
+  aMenu->addSeparator();
+  aMenu->addAction (ViewControl_Tools::CreateAction ("Test AddChild", SLOT (OnTestAddChild()), GetMainWindow(), this));
+
   QPoint aPoint = myTreeView->mapToGlobal (thePosition);
   aMenu->exec(aPoint);
 }
@@ -395,46 +555,55 @@ void VInspector_Window::onToolBarActionClicked (const int theActionId)
       UpdateTreeModel();
       break;
     }
-    case VInspector_ToolActionType_SelectPresentationsId:
-    {
-      bool isChecked = myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked();
-      NCollection_List<Handle(AIS_InteractiveObject)> aPresentationsForViewer;
-      if (isChecked)
-        aPresentationsForViewer = VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
-      Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
-      VInspector_Tools::AddOrRemovePresentations(aContext, aPresentationsForViewer);
-      UpdateTreeModel();
-      break;
-    }
-    case VInspector_ToolActionType_SelectOwnersId:
-    {
-      NCollection_List<Handle(SelectMgr_EntityOwner)> anOwnersForViewer;
-      if (myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked())
-        VInspector_ViewModel::GetSelectedOwners(myTreeView->selectionModel(), anOwnersForViewer);
-      VInspector_Tools::AddOrRemoveSelectedShapes(aViewModel->GetContext(), anOwnersForViewer);
-      UpdateTreeModel();
-      break;
-    }
     default:
       break;
   }
 }
 
 // =======================================================================
-// function : onSelectionChanged
+// function : onPropertyPanelShown
 // purpose :
 // =======================================================================
-void VInspector_Window::onSelectionChanged (const QItemSelection&,
-                                            const QItemSelection&)
+void VInspector_Window::onPropertyPanelShown (bool isToggled)
 {
-  QApplication::setOverrideCursor (Qt::WaitCursor);
+  if (!isToggled)
+    return;
 
-  if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectPresentationsId)->isChecked())
-    onToolBarActionClicked(VInspector_ToolActionType_SelectPresentationsId);
-  else if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectOwnersId)->isChecked())
-    onToolBarActionClicked(VInspector_ToolActionType_SelectOwnersId);
+  myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+}
 
-  QApplication::restoreOverrideCursor();
+// =======================================================================
+// function : onTreeViewSelectionChanged
+// purpose :
+// =======================================================================
+void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&,
+                                                    const QItemSelection&)
+{
+  if (myPropertyPanelWidget->toggleViewAction()->isChecked())
+    myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
+
+  NCollection_List<Handle(Standard_Transient)> aSelPresentations;
+
+  QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes();
+  for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+  {
+    QModelIndex anIndex = *aSelIt;
+    if (anIndex.column() != 0)
+      continue;
+
+    TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+    if (!anItemBase)
+      continue;
+
+    const Handle(TreeModel_ItemProperties)& anItemProperties = anItemBase->Properties();
+    if (anItemProperties)
+    {
+      anItemProperties->Presentations (aSelPresentations);
+    }
+  }
+
+  SelectedShapes (aSelPresentations);
+  displayer()->DisplayPreview()->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations, myViewWindow->ViewWidget()->DisplayMode());
 }
 
 // =======================================================================
@@ -453,20 +622,7 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the
 
   QModelIndexList aSelectedIndices = theSelected.indexes();
   QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
-
-  VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
-  if (!aTreeModel)
-    return;
-
-  QModelIndexList anIndices = aTreeModel->FindPointers (aPointers);
-  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
-  aSelectionModel->clear();
-  for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
-  {
-    QModelIndex anIndex = anIndices[anIndicesId];
-    myTreeView->setExpanded (aTreeModel->parent (anIndex), true);
-    aSelectionModel->select (anIndex, QItemSelectionModel::Select);
-  }
+  selectTreeViewItems (aPointers);
 }
 
 // =======================================================================
@@ -475,10 +631,8 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the
 // =======================================================================
 void VInspector_Window::onExportToShapeView()
 {
-  NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
-            VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
-  if (aSelectedPresentations.Extent() <= 0)
-    return;
+  NCollection_List<Handle(Standard_Transient)> aSelectedShapes;
+  SelectedShapes (aSelectedShapes);
 
   TCollection_AsciiString aPluginName ("TKShapeView");
   NCollection_List<Handle(Standard_Transient)> aParameters;
@@ -490,24 +644,46 @@ void VInspector_Window::onExportToShapeView()
     anItemNames = myParameters->GetSelectedNames (aPluginName);
 
   QStringList anExportedPointers;
-  for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (aSelectedPresentations); anIOIt.More(); anIOIt.Next())
+  if (aSelectedShapes.Extent() > 0)
   {
-    Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (anIOIt.Value());
-    if (aShapePresentation.IsNull())
-      continue;
+    for (NCollection_List<Handle(Standard_Transient)>::Iterator aShapeIt (aSelectedShapes); aShapeIt.More(); aShapeIt.Next())
+    {
+      Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (aShapeIt.Value());
+      if (aShapePtr.IsNull())
+        continue;
 
-    const TopoDS_Shape& aShape = aShapePresentation->Shape();
-    if (aShape.IsNull())
+      const TopoDS_Shape& aShape = aShapePtr->Shape();
+      if (aShape.IsNull())
+        continue;
+      aParameters.Append (aShape.TShape());
+      anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
+      anExportedPointers.append (Standard_Dump::GetPointerInfo (aShape.TShape(), true).ToCString());
+    }
+  }
+
+  // search for objects to be exported
+  QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::SelectedItems (myTreeView->selectionModel()->selectedIndexes());
+  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)
+    continue;
+
+    const Handle(Standard_Transient)& anObject = aVItem->Object();
+    if (anObject.IsNull())
       continue;
-    aParameters.Append (aShape.TShape());
-    anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
-    anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
+
+    aParameters.Append (anObject);
+    anItemNames.Append (anObject->DynamicType()->Name());
+    anExportedPointers.append (Standard_Dump::GetPointerInfo (anObject, true).ToCString());
   }
-  if (anExportedPointers.empty())
+
+  if (anExportedPointers.isEmpty())
     return;
 
   TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
-  QString aMessage = QString ("TShape %1 is sent to %2.")
+  QString aMessage = QString ("Objects %1 are sent to %2.")
     .arg (anExportedPointers.join(", "))
     .arg (aPluginShortName.ToCString());
   QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
@@ -523,21 +699,82 @@ void VInspector_Window::onExportToShapeView()
 }
 
 // =======================================================================
-// function : onShow
+// function : onDisplayActionTypeClicked
 // purpose :
 // =======================================================================
-void VInspector_Window::onShow()
+void VInspector_Window::onDisplayActionTypeClicked()
 {
-  displaySelectedPresentations (true);
+  QAction* anAction = (QAction*)sender();
+
+  displaySelectedPresentations (VInspector_Tools::DisplayActionTypeFromString (anAction->text().toStdString().c_str()));
 }
 
 // =======================================================================
-// function : onHide
+// function : onExpand
 // purpose :
 // =======================================================================
-void VInspector_Window::onHide()
+void VInspector_Window::onExpand()
 {
-  displaySelectedPresentations (false);
+  QApplication::setOverrideCursor (Qt::WaitCursor);
+
+  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+  QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+  for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+  {
+    int aLevels = 2;
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+  }
+  QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onExpandAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onExpandAll()
+{
+  QApplication::setOverrideCursor (Qt::WaitCursor);
+
+  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+  QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+  for (int  aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+  {
+    int aLevels = -1;
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+  }
+  QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onCollapseAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onCollapseAll()
+{
+  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+  QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+  for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+  {
+    int aLevels = -1;
+    TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+  }
+}
+
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void VInspector_Window::OnTestAddChild()
+{
+  Handle(AIS_Shape) aPresentation = new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt()));
+
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt (10., 10., 10.))));
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(20., 10., 10.))));
+  aPresentation->AddChild (new AIS_Shape (BRepBuilderAPI_MakeVertex (gp_Pnt(30., 10., 10.))));
+
+  displayer()->DisplayPresentation (aPresentation);
+
+  UpdateTreeModel();
 }
 
 // =======================================================================
@@ -555,7 +792,8 @@ void VInspector_Window::UpdateTreeModel()
 // function : displaySelectedPresentations
 // purpose :
 // =======================================================================
-void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
+
+void VInspector_Window::displaySelectedPresentations (const View_DisplayActionType theType)
 {
   VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
   if (!aViewModel)
@@ -565,30 +803,85 @@ void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
   if (aContext.IsNull())
     return;
 
-  NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
-    VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
-  if (aSelectedPresentations.Extent() <= 0)
+  QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+  if (!aSelectionModel)
+    return;
+
+  NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations = SelectedPresentations (aSelectionModel);
+  // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
+  // Erased to Displayed container or back
+  aSelectionModel->clear();
+
+
+  if (aSelectedPresentations.Extent() == 0)
     return;
 
   for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt(aSelectedPresentations); anIOIt.More(); anIOIt.Next())
   {
     Handle(AIS_InteractiveObject) aPresentation = anIOIt.Value();
-    if (theToDisplay)
+    switch (theType)
     {
-      aContext->Display(aPresentation, false);
-      aContext->Load(aPresentation, -1);
+      case View_DisplayActionType_DisplayId:
+      {
+        aContext->Display(aPresentation, false);
+        aContext->Load(aPresentation, -1);
+      }
+      break;
+
+      case View_DisplayActionType_RedisplayId: aContext->Redisplay (aPresentation, false); break;
+      case View_DisplayActionType_EraseId: aContext->Erase (aPresentation, false); break;
+      case View_DisplayActionType_RemoveId: aContext->Remove (aPresentation, false); break;
+      default: break;
     }
-    else
-      aContext->Erase(aPresentation, false);
   }
   aContext->UpdateCurrentViewer();
 
-  // the order of objects returned by AIS_InteractiveContext is changed because the processed object is moved from
-  // Erased to Displayed container or back
+  UpdateTreeModel();
+}
+
+// =======================================================================
+// function : highlightTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::highlightTreeViewItems (const QStringList& thePointers)
+{
+  VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  if (!aTreeModel)
+    return;
+
+  QModelIndexList anIndices;
+  aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
+  for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+  {
+    QModelIndex anIndex = anIndices[anIndicesId];
+    TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+  }
+  aTreeModel->SetHighlighted (anIndices);
+
+  if (!anIndices.isEmpty())
+    myTreeView->scrollTo (anIndices.last());
+}
+
+// =======================================================================
+// function : selectTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::selectTreeViewItems (const QStringList& thePointers)
+{
+  VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  if (!aTreeModel)
+    return;
+  
+  QModelIndexList anIndices;
+  aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
   QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
   aSelectionModel->clear();
-
-  UpdateTreeModel();
+  for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+  {
+    QModelIndex anIndex = anIndices[anIndicesId];
+    TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+    aSelectionModel->select (anIndex, QItemSelectionModel::Select);
+  }
 }
 
 // =======================================================================
@@ -597,10 +890,25 @@ void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
 // =======================================================================
 Handle(AIS_InteractiveContext) VInspector_Window::createView()
 {
-  myViewWindow = new View_Window (0);
-  myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
+  // create two view windows
+  Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer();
+
+  myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true);
+  myViewWindow->ViewWidget()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
   myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
   myViewWindow->show();
 
-  return myViewWindow->GetView()->GetViewer()->GetContext();
+  return aContext;
+}
+
+// =======================================================================
+// function : displayer
+// purpose :
+// =======================================================================
+View_Displayer* VInspector_Window::displayer()
+{
+  if (myViewWindow)
+    return myViewWindow->Displayer();
+
+  return myDisplayer;
 }
index 73783f39b017c91fee33b05d06ad7714c6928492..3eedc14685e7cd603193c6dd4ad943bda5c7e37c 100644 (file)
 
 #include <AIS_InteractiveContext.hxx>
 #include <NCollection_List.hxx>
-#include <SelectMgr_EntityOwner.hxx>
+#include <SelectBasics_EntityOwner.hxx>
 #include <Standard.hxx>
 
 #include <inspector/TInspectorAPI_PluginParameters.hxx>
 #include <inspector/VInspector_CallBack.hxx>
+#include <inspector/View_DisplayActionType.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QObject>
 #include <Standard_WarningsRestore.hxx>
 
 class ViewControl_MessageDialog;
+class ViewControl_PropertyView;
 
 class VInspector_ToolBar;
+
+class View_Displayer;
 class View_Window;
 
 class QAbstractItemModel;
 class QAction;
-class QMainWindow;
+class QDockWidget;
 class QTreeView;
 class QWidget;
 
@@ -53,7 +57,7 @@ public:
   Standard_EXPORT VInspector_Window();
 
   //! Destructor
-  virtual ~VInspector_Window() Standard_OVERRIDE {}
+  virtual ~VInspector_Window() {}
 
   //! Provides the container with a parent where this container should be inserted.
   //! If Qt implementation, it should be QWidget with QLayout set inside
@@ -82,6 +86,15 @@ public:
   //! Returns main control
   QWidget* GetMainWindow() const { return myMainWindow; }
 
+  //! Returns presentations of selected items in tree model
+  //! \param theModel selection model
+  //! \return container of presentations
+  NCollection_List<Handle(AIS_InteractiveObject)> SelectedPresentations (QItemSelectionModel* theModel);
+
+  //! Returns selected shapes
+  //! \param [out] container of shapes
+  void SelectedShapes (NCollection_List<Handle(Standard_Transient)>& theSelPresentations);
+
 private:
 
   //! Fills controls of the plugin by parameters:
@@ -103,6 +116,10 @@ private slots:
   //! \param theActionId an action identifier in tool bar
   void onToolBarActionClicked (const int theActionId);
 
+  //! Display content of selected tree view item if isToggled is true
+  //! \param isToggled true if the property dock widget is shown
+  void onPropertyPanelShown (bool isToggled);
+
   //! Synchronization selection between history and tree view. Selection by history view
   //! \param theSelected a selected items
   //! \param theDeselected a deselected items
@@ -113,16 +130,25 @@ private slots:
   //! check box is checked
   //! \param theSelected a selected items
   //! \param theDeselected a deselected items
-  void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+  void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
 
   //! Exports the first selected shape into ShapeViewer plugin.
   void onExportToShapeView();
 
-  //! Shows selected presentation if it is not shown yet
-  void onShow();
+  //! Apply activated display action
+  void onDisplayActionTypeClicked();
+
+  //! Expand two next levels for all selected item
+  void onExpand();
+
+  //! Expand all levels for all selected items
+  void onExpandAll();
+
+  //! Collapse all levels for all selected items
+  void onCollapseAll();
 
-  //! Erase selected presentation if it is shown
-  void onHide();
+  //! Creates a tree of inherited presentable objects
+  void OnTestAddChild();
 
 private:
 
@@ -135,8 +161,20 @@ private:
 
   //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
   //! still belongs to the current context until Remove is called.
-  //! \param theToDisplay if true, presentation is displayed otherwise erased
-  void displaySelectedPresentations (const bool theToDisplay);
+  //! \param theType display action type
+  void displaySelectedPresentations (const View_DisplayActionType theType);
+
+  //! Set items of the pointers highlighted in tree view
+  //! \param theType display action type
+  void highlightTreeViewItems (const QStringList& thePointers);
+
+  //! Set items of the pointers selected in tree view
+  //! \param theType display action type
+  void selectTreeViewItems (const QStringList& thePointers);
+
+  //! Returns displayer where the presentations/preview should be shown/erased
+  //! If default view is created, it returns displayer of this view
+  Standard_EXPORT View_Displayer* displayer();
 
   //! Creates an istance of 3D view to initialize context.
   //! \return a context of created view.
@@ -148,6 +186,10 @@ private:
 
   QMainWindow* myMainWindow; //!< main control
   VInspector_ToolBar* myToolBar; //!< tool bar actions
+
+  QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget
+  ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist
+
   QTreeView* myTreeView; //!< tree view of AIS content
   QTreeView* myHistoryView; //!< history of AIS context calls
   Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
@@ -156,6 +198,8 @@ private:
   View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
 
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+
+  View_Displayer* myDisplayer; //!< class to display presentations/preview if myMainWindow is not used
 };
 
 #endif
index f0c48897a48788041c23aae724348aa601d81948..0048d3b82967c170568f56bee58df20580cc98b0 100644 (file)
@@ -1,14 +1,17 @@
 View.qrc
 View_ContextType.hxx
+View_DisplayActionType.hxx
 View_Displayer.cxx
 View_Displayer.hxx
+View_DisplayPreview.cxx
+View_DisplayPreview.hxx
 View_PresentationType.hxx
+View_PreviewParameters.cxx
+View_PreviewParameters.hxx
 View_ToolActionType.hxx
 View_ToolBar.cxx
 View_ToolBar.hxx
 View_ToolButton.hxx
-View_Tools.cxx
-View_Tools.hxx
 View_ViewActionType.hxx
 View_Viewer.cxx
 View_Viewer.hxx
index 6be49efee24537b4295d2701850ce7e2ba3ccf96..89d2f9a795803b44bd4484f98cadf6a87865598f 100644 (file)
@@ -4,6 +4,7 @@
         <file>icons/cursor_zoom.png</file>
         <file>icons/keep_view_off.png</file>
         <file>icons/keep_view_on.png</file>
+        <file>icons/trihedron.png</file>
         <file>icons/view_clear.png</file>
         <file>icons/view_dm_shading.png</file>
         <file>icons/view_dm_wireframe.png</file>
diff --git a/tools/View/View_DisplayActionType.hxx b/tools/View/View_DisplayActionType.hxx
new file mode 100644 (file)
index 0000000..bc0126e
--- /dev/null
@@ -0,0 +1,29 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 View_DisplayActionType_H
+#define View_DisplayActionType_H
+
+//! \enum View_DisplayActionType
+enum View_DisplayActionType
+{
+  View_DisplayActionType_NoneId, //!< No action activated
+  View_DisplayActionType_DisplayId, //!< Display action
+  View_DisplayActionType_RedisplayId, //!< Redisplay action
+  View_DisplayActionType_EraseId, //!< Erase action
+  View_DisplayActionType_RemoveId //!< Remove action
+};
+
+#endif
diff --git a/tools/View/View_DisplayPreview.cxx b/tools/View/View_DisplayPreview.cxx
new file mode 100644 (file)
index 0000000..7e6c551
--- /dev/null
@@ -0,0 +1,167 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+
+#include <Geom_Axis2Placement.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TopoDS_Compound.hxx>
+
+static void enableGlobalClipping (const Handle(AIS_InteractiveObject)& theObject, const bool theIsEnable)
+{
+  if (theIsEnable)
+  {
+    theObject->SetClipPlanes (Handle(Graphic3d_SequenceOfHClipPlane)());
+  }
+  else
+  {
+    Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane();
+    aPlanes->SetOverrideGlobal (Standard_True);
+    theObject->SetClipPlanes (aPlanes);
+  }
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_DisplayPreview::View_DisplayPreview()
+{
+  myPreviewParameters = new View_PreviewParameters();
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theContext)
+{
+  if (myContext == theContext)
+    return;
+
+  // remove all preview presentations from the previous context, display it in the new 
+
+  myContext = theContext;
+  if (!theContext.IsNull())
+    myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer());
+}
+
+// =======================================================================
+// function : UpdatePreview
+// purpose :
+// =======================================================================
+void View_DisplayPreview::UpdatePreview (const View_DisplayActionType,
+                                         const NCollection_List<Handle(Standard_Transient)>& thePresentations,
+                                         int theDisplayMode)
+{
+  if (myContext.IsNull())
+    return;
+
+  // clear previous previews
+  for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIterator (myPreviewReadyPresentations); anIterator.More(); anIterator.Next())
+  {
+    if (!anIterator.Value()->GetContext().IsNull())
+      anIterator.Value()->GetContext()->Remove (anIterator.Value(), Standard_True);
+  }
+  myPreviewReadyPresentations.Clear();
+
+  if (thePresentations.IsEmpty())
+  {
+    if (!myPreviewPresentation.IsNull() && !myPreviewPresentation->GetContext().IsNull())
+      myPreviewPresentation->GetContext()->Remove (myPreviewPresentation, Standard_True);
+    myPreviewPresentation = NULL;
+
+    return;
+  }
+
+  // display parameter previews
+  BRep_Builder aBuilder;
+  TopoDS_Compound aCompound;
+  aBuilder.MakeCompound (aCompound);
+  for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (thePresentations); anIterator.More(); anIterator.Next())
+  {
+    if (Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (anIterator.Value()))
+    {
+      aBuilder.Add (aCompound, aShapePtr->Shape());
+    }
+    Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (anIterator.Value());
+    if (!aPrs.IsNull() && aPrs->GetContext().IsNull()/*is not displayed in another context*/)
+    {
+      myContext->Display (aPrs, theDisplayMode, -1/*does not participate in selection*/, Standard_True);
+      enableGlobalClipping(aPrs, false);
+      myPreviewReadyPresentations.Append (aPrs);
+    }
+  }
+
+  if (myPreviewPresentation.IsNull())
+  {
+    myPreviewPresentation = new AIS_Shape (aCompound);
+    Quantity_Color aColor(Quantity_NOC_TOMATO);
+    myPreviewPresentation->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+    myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
+
+    myContext->Display (myPreviewPresentation, theDisplayMode, -1/*does not participate in selection*/, Standard_True);
+    enableGlobalClipping(myPreviewPresentation, false);
+  }
+  else
+  {
+    Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
+    if (!myPreviewPresentation->GetContext().IsNull())
+    {
+      myPreviewPresentation->GetContext()->Redisplay (myPreviewPresentation, Standard_True);
+    }
+  }
+}
+
+// =======================================================================
+// function : SetDisplayMode
+// purpose :
+// =======================================================================
+void View_DisplayPreview::SetDisplayMode (const int theDisplayMode, const bool theToUpdateViewer)
+{
+  if (myContext.IsNull())
+    return;
+
+  if (!myPreviewPresentation.IsNull())
+  {
+     if (myContext == myPreviewPresentation->GetContext())
+       myContext->SetDisplayMode (myPreviewPresentation, theDisplayMode, Standard_False);
+  }
+
+  for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator aPreviewIt (myPreviewReadyPresentations); aPreviewIt.More(); aPreviewIt.Next())
+  {
+     if (myContext == aPreviewIt.Value()->GetContext())
+       myContext->SetDisplayMode (aPreviewIt.Value(), theDisplayMode, Standard_False);
+  }
+
+  if (theToUpdateViewer)
+    myContext->UpdateCurrentViewer();
+}
diff --git a/tools/View/View_DisplayPreview.hxx b/tools/View/View_DisplayPreview.hxx
new file mode 100644 (file)
index 0000000..530bfea
--- /dev/null
@@ -0,0 +1,80 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 View_DisplayPreview_H
+#define View_DisplayPreview_H
+
+#include <inspector/View_DisplayActionType.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <Standard.hxx>
+#include <Standard_Handle.hxx>
+#include <Standard_Macro.hxx>
+
+class AIS_InteractiveObject;
+class View_PreviewParameters;
+
+//! \class View_DisplayPreview
+//! \brief It is responsible for communication with AIS Interactive Context to:
+//! - display/erase presentations;
+//! - change display mode of visualized presentations (Shaded or WireFrame mode)
+//!
+//! It contains containers of visualized presentations to obtain presentations relating only to this displayer.
+//! Displayer is connected to AIS Interactive Context
+class View_DisplayPreview
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT View_DisplayPreview();
+
+  //! Destructor
+  virtual ~View_DisplayPreview() {}
+
+  //! Stores the current context where the presentations will be displayed/erased.
+  //! Erases previuously displayd presentations if there were some displayed
+  //! \param theContext a context instance
+  Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
+
+  //! Returns preview parameters
+  View_PreviewParameters* GetPreviewParameters() const { return myPreviewParameters; }
+
+  //! Updates visibility of the presentations for the display type
+  Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType,
+                                      const NCollection_List<Handle(Standard_Transient)>& thePresentations,
+                                      int theDisplayMode);
+
+  //! Sets display mode for all displayed presentations
+  Standard_EXPORT void SetDisplayMode (const int theDisplayMode,
+                                       const bool theToUpdateViewer = true);
+
+  //! Returns true if preview presentation is shown
+  Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); }
+
+private:
+
+  //! Returns the current context
+  const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; }
+
+private:
+
+  Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
+
+  View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation
+  Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
+  NCollection_List<Handle(AIS_InteractiveObject)> myPreviewReadyPresentations; //!< presentation of preview for a selected object
+};
+
+#endif
index 50d41a989c6d3c7d15cb8c6c77b839a730d89857..9d36606c96b83d9dac7045d87de66508b60145d5 100644 (file)
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_Trihedron.hxx>
+#include <Geom_Axis2Placement.hxx>
 #include <Prs3d_PointAspect.hxx>
 #include <V3d_View.hxx>
 #include <V3d_Viewer.hxx>
+
+#include <inspector/View_DisplayPreview.hxx>
 #include <inspector/View_Viewer.hxx>
 #include <inspector/View_Widget.hxx>
 
@@ -33,6 +36,7 @@
 View_Displayer::View_Displayer()
 : myIsKeepPresentations (false), myFitAllActive (false), myDisplayMode (-1)
 {
+  myDisplayPreview = new View_DisplayPreview();
 }
 
 // =======================================================================
@@ -53,6 +57,7 @@ void View_Displayer::SetContext (const Handle(AIS_InteractiveContext)& theContex
          aPresentationsIt.More(); aPresentationsIt.Next())
       DisplayPresentation (aPresentationsIt.Value(), aType, false);
   }
+  myDisplayPreview->SetContext (theContext);
   UpdateViewer();
 }
 
@@ -74,6 +79,8 @@ void View_Displayer::SetDisplayMode (const int theDisplayMode,
   for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
     GetContext()->SetDisplayMode (aDisplayedIt.Value(), theDisplayMode, Standard_False);
 
+  myDisplayPreview->SetDisplayMode (theDisplayMode, Standard_False);
+
   if (theToUpdateViewer)
     UpdateViewer();
 }
@@ -209,6 +216,22 @@ void View_Displayer::ErasePresentation (const Handle(Standard_Transient)& thePre
     UpdateViewer();
 }
 
+// =======================================================================
+// function : DisplayDefaultTrihedron
+// purpose :
+// =======================================================================
+void View_Displayer::DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer)
+{
+  const Handle(AIS_Trihedron)& aTrihedron = defaultTrihedron (toDisplay);
+  if (aTrihedron.IsNull())
+    return;
+
+  if (toDisplay)
+    GetContext()->Display (aTrihedron, theToUpdateViewer);
+  else
+    GetContext()->Erase (aTrihedron, theToUpdateViewer);
+}
+
 // =======================================================================
 // function : SetVisible
 // purpose :
@@ -240,6 +263,18 @@ bool View_Displayer::IsVisible (const TopoDS_Shape& theShape, const View_Present
   return !aPresentation.IsNull();
 }
 
+// =======================================================================
+// function : UpdatePreview
+// purpose :
+// =======================================================================
+void View_Displayer::UpdatePreview (const View_DisplayActionType theType,
+                                    const NCollection_List<Handle(Standard_Transient)>& thePresentations)
+{
+  myDisplayPreview->UpdatePreview (theType, thePresentations, myDisplayMode);
+  if (!myIsKeepPresentations || myFitAllActive)
+    fitAllView();
+}
+
 // =======================================================================
 // function : UpdateViewer
 // purpose :
@@ -321,11 +356,7 @@ Handle(AIS_InteractiveObject) View_Displayer::FindPresentation (const TopoDS_Sha
 // =======================================================================
 Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shape& theShape)
 {
-  Handle(AIS_Shape) aShape = new AIS_Shape (theShape);
-
-  aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
-
-  return aShape;
+  return new AIS_Shape (theShape);
 }
 
 // =======================================================================
@@ -340,4 +371,18 @@ void  View_Displayer::fitAllView()
     aView->FitAll();
     aView->Redraw();
   }
-}
\ No newline at end of file
+}
+
+// =======================================================================
+// function : defaultTrihedron
+// purpose :
+// =======================================================================
+const Handle(AIS_Trihedron)& View_Displayer::defaultTrihedron (const bool toCreate)
+{
+  if (myDefaultTrihedron.IsNull() && toCreate)
+  {
+    myDefaultTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY()));
+    myDefaultTrihedron->SetSize (1);
+  }
+  return myDefaultTrihedron;
+}
index 8e7bc4ccf7dff1e0258e3f6d99f2faa462c98aff..da1f029a46c11372f0b7b9c86aaa6204379de606 100644 (file)
 #include <NCollection_Shared.hxx>
 #include <TopoDS_Shape.hxx>
 #include <Quantity_Color.hxx>
+
 #include <inspector/View_PresentationType.hxx>
+#include <inspector/View_DisplayActionType.hxx>
 
+class AIS_Trihedron;
 class V3d_View;
+class View_DisplayPreview;
 
 //! \class View_Displayer
 //! \brief It is responsible for communication with AIS Interactive Context to:
@@ -44,6 +48,9 @@ public:
   //! Destructor
   virtual ~View_Displayer() {}
 
+  //! Returns preview display instance
+  View_DisplayPreview* DisplayPreview() const { return myDisplayPreview; }
+
   //! Stores the current context where the presentations will be displayed/erased.
   //! Erases previuously displayd presentations if there were some displayed
   //! \param theContext a context instance
@@ -54,10 +61,16 @@ public:
   //! \param theToKeepPresentation boolean state
   void KeepPresentations (const bool theToKeepPresentations) { myIsKeepPresentations = theToKeepPresentations; }
 
+  //! Returns true if fit Fit All should be peformed automatically by each Display
+  bool IsFitAllActive() const { return myFitAllActive; }
+
   //! Stores flag whether the FitAll shoud be done automatically for each display
   //! \param theFitAllActive boolean value
   void SetFitAllActive (const bool theFitAllActive) { myFitAllActive = theFitAllActive; }
 
+  //! Returns current display mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+  int DisplayMode() const { return myDisplayMode; }
+
   //! Stores display mode and changes display mode of displayed presentations
   //! \param theDisplayMode a mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
   //! \param theType presentation type
@@ -95,7 +108,7 @@ public:
   Standard_EXPORT void ErasePresentations (const View_PresentationType theType = View_PresentationType_Main,
                                            const bool theToUpdateViewer = true);
 
-  //! Erase presentation from viewer
+  //! Erases presentation from viewer
   //! \param thePresentation a presentation, it will be casted to AIS_InteractiveObject
   //! \param theType presentation type
   //! \param isToUpdateView boolean state if viewer should be updated
@@ -103,6 +116,11 @@ public:
                                           const View_PresentationType theType = View_PresentationType_Main,
                                           const bool theToUpdateViewer = true);
 
+  //! Displays presentation of default trihedron, create it by the first call
+  //! \param toDisplay flag to display presentation if true, or erase it
+  //! \param isToUpdateView boolean state if viewer should be updated
+  Standard_EXPORT void DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer);
+
   //! Sets shape visible/invisible
   //! \theShape shape instance
   //! \theState visibility state
@@ -114,6 +132,10 @@ public:
   Standard_EXPORT bool IsVisible (const TopoDS_Shape& theShape,
                                   const View_PresentationType theType = View_PresentationType_Main) const;
 
+  //! Updates visibility of the presentations for the display type
+  Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType,
+                                      const NCollection_List<Handle(Standard_Transient)>& thePresentations);
+
   //! Calls UpdateCurrentViewer of context
   Standard_EXPORT void UpdateViewer();
 
@@ -152,12 +174,20 @@ private:
   //! Returns 3d view
   Handle(V3d_View) GetView() const;
 
-  //! Fit all view
+  //! Fits all view
   void fitAllView();
 
+  //! Returns default trihedron, create it if flag allows
+  //! \param toCreate boolean state if trihedron should be created if it is NULL
+  const Handle(AIS_Trihedron)& defaultTrihedron (const bool toCreate);
+
 private:
 
+  View_DisplayPreview* myDisplayPreview; //!< class for preview display
+
   Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
+  Handle(AIS_Trihedron) myDefaultTrihedron; //!< NULL presentation until the first display
+
   NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>> myDisplayed; //!< visualized presentations
   NCollection_DataMap<View_PresentationType, Quantity_Color> myColorAttributes; //!< color properties of presentations
 
diff --git a/tools/View/View_PreviewParameters.cxx b/tools/View/View_PreviewParameters.cxx
new file mode 100644 (file)
index 0000000..8cc48d0
--- /dev/null
@@ -0,0 +1,46 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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/View_PreviewParameters.hxx>
+
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_PreviewParameters::View_PreviewParameters()
+{
+  myDrawer = new Prs3d_Drawer();
+
+  Quantity_Color aColor(Quantity_NOC_TOMATO);
+
+  // point parameters
+  myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+
+  // shading parameters
+  Graphic3d_MaterialAspect aShadingMaterial;
+  aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+
+  myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+  myDrawer->ShadingAspect()->SetColor (aColor);
+  myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial);
+
+  // common parameters
+  myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
+}
diff --git a/tools/View/View_PreviewParameters.hxx b/tools/View/View_PreviewParameters.hxx
new file mode 100644 (file)
index 0000000..700ecc2
--- /dev/null
@@ -0,0 +1,71 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 View_PreviewParameters_H
+#define View_PreviewParameters_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <Prs3d_Drawer.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QMap>
+#include <QString>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class View_PreviewParameters
+//! Container of View tool bar actions
+class View_PreviewParameters
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT View_PreviewParameters ();
+
+  //! Destructor
+  virtual ~View_PreviewParameters() {}
+
+  //! Returns main control
+  const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; }
+
+  //! Saves state of preview parameters in a container in form: key, value. It saves:
+  //! - visibility of columns,
+  //! - columns width
+  //! \param theTreeView a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  static void SaveState (View_PreviewParameters* theParameters,
+                         QMap<QString, QString>& theItems,
+                         const QString& thePrefix = QString())
+  { (void)theParameters; (void)theItems; (void)thePrefix; }
+
+  //! Restores state of preview parameters by a container
+  //! \param theTreeView a view instance
+  //! \param theKey property key
+  //! \param theValue property value
+  //! \param thePrefix peference item prefix
+  //! \return boolean value whether the property is applied to the tree view
+  static bool RestoreState (View_PreviewParameters* theParameters,
+                            const QString& theKey, const QString& theValue,
+                            const QString& thePrefix = QString())
+  { (void)theParameters; (void)theKey; (void)theValue; (void)thePrefix; return false; }
+
+private:
+
+  Handle(Prs3d_Drawer) myDrawer; //!< attributes for preview presentation
+};
+
+#endif
index d5308a62900ee3c9f96e480875f21dd1839759c2..a518d2ba541e47e786fadb82a381d8b3eb5332f3 100644 (file)
@@ -21,7 +21,8 @@ enum View_ToolActionType
 {
   View_ToolActionType_KeepViewId,    //!< Do not clear previously shown presentations
   View_ToolActionType_KeepViewOffId, //!< Do show only for new displayed presentation
-  View_ToolActionType_ClearViewId    //!< Erase all displayed presentations
+  View_ToolActionType_ClearViewId,   //!< Erase all displayed presentations
+  View_ToolActionType_Trihedron      //!< Display/Erase trihedron presentation
 };
 
 #endif
index 1ebff8d129924bae98efb60622fa7d811f22ad59..7887ebbed6f999214e98d8775322760af5d5d526 100644 (file)
@@ -32,7 +32,7 @@ const int DEFAULT_SPACING = 3;
 // purpose :
 // =======================================================================
 View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
-: QObject (theParent)
+: QObject (theParent), myDefaultContextType (-1)
 {
   myMainWindow = new QWidget (theParent);
 
@@ -63,6 +63,12 @@ View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
   myViewContexts[View_ContextType_Own] = Handle(AIS_InteractiveContext)();
   myViewContexts[View_ContextType_External] = Handle(AIS_InteractiveContext)();
 
+  myActionsMap[View_ToolActionType_Trihedron] = new QToolButton (theParent);
+  myActionsMap[View_ToolActionType_Trihedron]->setIcon (QIcon (":/icons/trihedron.png"));
+  myActionsMap[View_ToolActionType_Trihedron]->setToolTip (tr ("Trihedron display"));
+  myActionsMap[View_ToolActionType_Trihedron]->setCheckable (true);
+  myActionsMap[View_ToolActionType_Trihedron]->setChecked (false);
+
   if (isUseKeepView)
   {
     myActionsMap[View_ToolActionType_KeepViewId] = new QToolButton (theParent);
@@ -80,12 +86,12 @@ View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
     myActionsMap[View_ToolActionType_KeepViewOffId]->setToolTip (tr ("Keep View Off: clear previously shown presentation"));
     myActionsMap[View_ToolActionType_KeepViewOffId]->setCheckable (true);
     myActionsMap[View_ToolActionType_KeepViewOffId]->setChecked (true);
-  }
 
-  myActionsMap[View_ToolActionType_ClearViewId] = new QToolButton (theParent);
-  myActionsMap[View_ToolActionType_ClearViewId]->setIcon (QIcon (":/icons/view_clear.png"));
-  myActionsMap[View_ToolActionType_ClearViewId]->setText (tr ( "Clear View"));
-  myActionsMap[View_ToolActionType_ClearViewId]->setToolTip (tr ("Remove all visualized presentations from view context"));
+    myActionsMap[View_ToolActionType_ClearViewId] = new QToolButton (theParent);
+    myActionsMap[View_ToolActionType_ClearViewId]->setIcon (QIcon (":/icons/view_clear.png"));
+    myActionsMap[View_ToolActionType_ClearViewId]->setText (tr ( "Clear View"));
+    myActionsMap[View_ToolActionType_ClearViewId]->setToolTip (tr ("Remove all visualized presentations from view context"));
+  }
 
   for (QMap<View_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin(),
        anActionsLast = myActionsMap.end(); anActionsIt != anActionsLast; anActionsIt++)
@@ -97,26 +103,6 @@ View_ToolBar::View_ToolBar (QWidget* theParent, const bool isUseKeepView)
   aLay->addStretch (1);
 }
 
-TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
-{
-  std::ostringstream aPtrStr;
-  aPtrStr << thePointer.operator->();
-  if (!isShortInfo)
-    return aPtrStr.str().c_str();
-
-  TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
-  for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
-  {
-    if (anInfoPtr.Value(aSymbolId) != '0')
-    {
-      anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
-      anInfoPtr.Prepend("0x");
-      return anInfoPtr;
-    }
-  }
-  return aPtrStr.str().c_str();
-}
-
 // =======================================================================
 // function : SetContext
 // purpose :
@@ -128,28 +114,45 @@ void View_ToolBar::SetContext (View_ContextType theType, const Handle(AIS_Intera
   QString aViewContextName = myViewContextNames[theType];
   if (!theContext.IsNull())
     aViewContextName = QString ("%1 : [%2]").arg (myViewContextNames[theType])
-                                            .arg (getPointerInfo (theContext, true).ToCString());
+                                            .arg (Standard_Dump::GetPointerInfo (theContext, true).ToCString());
   // there are only "Own" and "None" items
   if (!theContext.IsNull() && theType == View_ContextType_External && myViewSelector->count() == 2)
     myViewSelector->insertItem (View_ContextType_External, aViewContextName);
   else
     myViewSelector->setItemText (theType, aViewContextName);
+
+  if (myDefaultContextType >= 0 && myViewSelector->count() > myDefaultContextType)
+  {
+    // using default type during the first setting the external context
+    myViewSelector->setCurrentIndex (myDefaultContextType);
+    myDefaultContextType = -1;
+  }
 }
 
 // =======================================================================
-// function : getCurrentContextType
+// function : CurrentContextType
 // purpose :
 // =======================================================================
-View_ContextType View_ToolBar::GetCurrentContextType() const
+View_ContextType View_ToolBar::CurrentContextType() const
 {
   return (View_ContextType)myViewSelector->currentIndex();
 }
 
 // =======================================================================
-// function : GetCurrentContext
+// function : SetCurrentContext
+// purpose :
+// =======================================================================
+void View_ToolBar::SetCurrentContextType (View_ContextType theType)
+{
+  myViewSelector->setCurrentIndex ((int)theType);
+  emit contextChanged();
+}
+
+// =======================================================================
+// function : CurrentContext
 // purpose :
 // =======================================================================
-Handle(AIS_InteractiveContext) View_ToolBar::GetCurrentContext() const
+Handle(AIS_InteractiveContext) View_ToolBar::CurrentContext() const
 {
   View_ContextType aCurrentType = (View_ContextType)myViewSelector->currentIndex();
   return myViewContexts[aCurrentType];
@@ -165,6 +168,35 @@ bool View_ToolBar::IsActionChecked (const int theActionId) const
   return myActionsMap.contains (anActionId) ? myActionsMap[anActionId]->isChecked() : false;
 }
 
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_ToolBar::SaveState (View_ToolBar* theToolBar,
+                              QMap<QString, QString>& theItems,
+                              const QString& thePrefix)
+{
+  theItems[thePrefix + "context_type"] = QString::number (theToolBar->CurrentContextType());
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_ToolBar::RestoreState (View_ToolBar* theToolBar,
+                                 const QString& theKey, const QString& theValue,
+                                 const QString& thePrefix)
+{
+  if (theKey == thePrefix + "context_type")
+  {
+    theToolBar->SetDefaultContextType ((View_ContextType)theValue.toInt());
+  }
+  else
+    return false;
+
+  return true;
+}
+
 // =======================================================================
 // function : onActionClicked
 // purpose :
index dca417ba0559cae58b9d07e8398230d66e8d70ea..0a6fac186914e9128b30008807550abf541743a7 100644 (file)
@@ -47,25 +47,50 @@ public:
   Standard_EXPORT View_ToolBar (QWidget* theParent, const bool isUseKeepView = true);
 
   //! Destructor
-  virtual ~View_ToolBar() Standard_OVERRIDE {}
+  virtual ~View_ToolBar() {}
 
   //! \returns parent widget of actions
   QWidget* GetControl() const { return myMainWindow; }
 
-  //! Append context for the given type
+  //! Appends context for the given type
   //! \param theType a context type
   //! \param theContext a context
   Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
 
   //! \returns type of active item of context selector
-  Standard_EXPORT View_ContextType GetCurrentContextType() const;
+  Standard_EXPORT View_ContextType CurrentContextType() const;
+
+  //! Sets current context type
+  //! \param theType a context type
+  Standard_EXPORT void SetCurrentContextType (View_ContextType theType);
+
+  //! Sets default context type
+  //! \param theType a context type
+  void SetDefaultContextType (const View_ContextType theType) { myDefaultContextType = (int)theType; }
 
   //! \returns an active context of context selector
-  Standard_EXPORT Handle(AIS_InteractiveContext) GetCurrentContext() const;
+  Standard_EXPORT Handle(AIS_InteractiveContext) CurrentContext() const;
 
   //! \returns whether the action is checked(toggled). Acceptable only if the action is checkable.
   Standard_EXPORT bool IsActionChecked (const int theActionId) const;
 
+  //! Saves state of tool bar actions
+  //! \param theToolBar a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  Standard_EXPORT static void SaveState (View_ToolBar* theToolBar,
+                                         QMap<QString, QString>& theItems,
+                                         const QString& thePrefix = QString());
+  //! Restores state of tool bar actions
+  //! \param theToolBar a view instance
+  //! \param theKey property key
+  //! \param theValue property value
+  //! \param thePrefix peference item prefix
+  //! \return boolean value whether the property is applied to the tree view
+  Standard_EXPORT static bool RestoreState (View_ToolBar* theToolBar,
+                                            const QString& theKey, const QString& theValue,
+                                            const QString& thePrefix = QString());
+
 signals:
 
   //! Signal about click on action of View_ToolActionType enumeration
@@ -83,6 +108,7 @@ private:
 
   QWidget* myMainWindow; //!< tool bar parent widget
   QComboBox* myViewSelector; //!< container of possible contexts
+  int myDefaultContextType; //!< type of context read from preferences
 
   QMap<View_ToolActionType, QToolButton*> myActionsMap; //!< tool actions
   QMap<View_ContextType, Handle(AIS_InteractiveContext)> myViewContexts; //!< contexts
diff --git a/tools/View/View_Tools.cxx b/tools/View/View_Tools.cxx
deleted file mode 100644 (file)
index 1699446..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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/View_Tools.hxx>
-#include <inspector/View_Viewer.hxx>
-#include <inspector/View_Widget.hxx>
-#include <inspector/View_Window.hxx>
-
-#include <V3d_View.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QAction>
-#include <QObject>
-#include <Standard_WarningsRestore.hxx>
-
-// =======================================================================
-// function : CreateAction
-// purpose :
-// =======================================================================
-QAction* View_Tools::CreateAction (const QString& theText, const char* theSlot, QObject* theParent, QObject* theContext)
-{
-  QAction* anAction = new QAction (theText, theParent);
-  QObject::connect (anAction, SIGNAL (triggered (bool)), theContext, theSlot);
-  return anAction;
-}
-
-// =======================================================================
-// function : SaveState
-// purpose :
-// =======================================================================
-void View_Tools::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
-                            const QString& thePrefix)
-{
-  QStringList aCameraDirection;
-  Standard_Real aVX, aVY, aVZ;
-  theView->GetView()->GetViewer()->GetView()->Proj (aVX, aVY, aVZ);
-  aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
-
-  theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
-}
-
-// =======================================================================
-// function : RestoreState
-// purpose :
-// =======================================================================
-bool View_Tools::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
-                               const QString& thePrefix)
-{
-  if (theKey == thePrefix + "view_camera_direction")
-  {
-    QStringList aValues = theValue.split (",");
-    if (aValues.size() == 3)
-    {
-      Standard_Real aVX = aValues.at (0).toDouble();
-      Standard_Real aVY = aValues.at (1).toDouble();
-      Standard_Real aVZ = aValues.at (2).toDouble();
-
-      theView->GetView()->SetInitProj (aVX, aVY, aVZ);
-    }
-  }
-  else
-    return false;
-  return true;
-}
diff --git a/tools/View/View_Tools.hxx b/tools/View/View_Tools.hxx
deleted file mode 100644 (file)
index 2c105f7..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// 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. 
-
-#ifndef View_Tools_H
-#define View_Tools_H
-
-#include <Standard.hxx>
-#include <Standard_Macro.hxx>
-
-#include <Standard_WarningsDisable.hxx>
-#include <QMap>
-#include <QString>
-#include <Standard_WarningsRestore.hxx>
-
-class View_Window;
-
-class QAction;
-class QObject;
-
-//! \class View_Tools
-//! \brief The tool that gives auxiliary methods for qt elements manipulation
-class View_Tools
-{
-public:
-
-  //! Creates an action with the given text connected to the slot
-  //! \param theText an action text value
-  //! \param theSlot a listener of triggered signal of the new action
-  //! \param theParent a parent object
-  //! \param theContext listener of the action toggle
-  //! \return a new action
-  Standard_EXPORT static QAction* CreateAction (const QString& theText, const char* theSlot,
-                                                QObject* theParent, QObject* theContext);
-
-  //! Save state of three view in a container in form: key, value. It saves:
-  //! - visibiblity of columns,
-  //! - columns width
-  //! \param theTreeView a view instance
-  //! \param theItems [out] properties
-  //! \param thePrefix peference item prefix
-  Standard_EXPORT static void SaveState (View_Window* theView, QMap<QString, QString>& theItems,
-                                         const QString& thePrefix = QString());
-  //! Restore state of three view by a container
-  //! \param theTreeView a view instance
-  //! \param theKey property key
-  //! \param theValue property value
-  //! \param thePrefix peference item prefix
-  //! \return boolean value whether the property is applyed to the tree view
-  Standard_EXPORT static bool RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
-                                            const QString& thePrefix = QString());
-};
-
-#endif
index 1b2ed6c1054ddc1a93c1588bd46ed75e3b0e80ae..f2d8dac73cf960bafd6f2446264cb1fb5763fa6f 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <OpenGl_GraphicDriver.hxx>
 #include <Standard_ExtString.hxx>
-#include <Standard_Version.hxx>
 
 // =======================================================================
 // function : CreateView
@@ -41,26 +40,31 @@ void View_Viewer::SetWindow(const Handle(Aspect_Window)& theWindow)
 }
 
 // =======================================================================
-// function : InitStandardViewer
+// function : InitViewer
 // purpose :
 // =======================================================================
-void View_Viewer::InitStandardViewer()
+void View_Viewer::InitViewer (const Handle(AIS_InteractiveContext)& theContext)
+{
+  myContext = theContext;
+  myViewer = myContext->CurrentViewer();
+}
+
+// =======================================================================
+// function : CreateStandardViewer
+// purpose :
+// =======================================================================
+Handle(AIS_InteractiveContext) View_Viewer::CreateStandardViewer()
 {
   Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
   static Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
 
-#if OCC_VERSION_HEX > 0x060901
-  myViewer = new V3d_Viewer (aGraphicDriver);
-#else
-  TCollection_AsciiString a3DName ("Visu3D");
-  myViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30,
-                             V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False);
-#endif
+  Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver);
+  aViewer->SetDefaultLights();
+  aViewer->SetLightOn();
+  aViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
 
-  myViewer->SetDefaultLights();
-  myViewer->SetLightOn();
-  myViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
+  Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (aViewer);
+  aContext->UpdateCurrentViewer();
 
-  myContext = new AIS_InteractiveContext (myViewer);
-  myContext->UpdateCurrentViewer();
+  return aContext;
 }
index b05550f76af679a16c46854395da3797c39e9cf0..9d88efa841fbfb6419c695a87f5a05d9bcc0b88c 100644 (file)
@@ -39,7 +39,7 @@ public:
   static Quantity_Color DefaultColor() { return Quantity_Color(Quantity_NOC_BLACK); }
 
   //! Returns the view default colors
-  static Quantity_Color DisabledColor() { return Quantity_Color(195 / 255., 195 / 255., 195 / 255., Quantity_TOC_RGB); }
+  static Quantity_Color DisabledColor() { return Quantity_Color(195 / 255., 195 / 255., 195 / 255., Quantity_TOC_sRGB); }
 
   //! Creates V3d view
   Standard_EXPORT void CreateView();
@@ -50,7 +50,11 @@ public:
 
   //! Creates OCC components on the window
   //! \param theWindowHandle an id of the application window
-  Standard_EXPORT void InitStandardViewer();
+  Standard_EXPORT void InitViewer (const Handle(AIS_InteractiveContext)& theContext);
+
+  //! Creates OCC components on the window
+  //! \param theWindowHandle an id of the application window
+  Standard_EXPORT static Handle(AIS_InteractiveContext) CreateStandardViewer();
 
   //! Returns an OCC viewer
   const Handle(V3d_Viewer)& GetViewer() { return myViewer; }
index 33230ef59d38353cc8de851ecf671b3695306a89..878b19f708739cf5dfbb29d119772a6615cb7d7a 100644 (file)
 
 #include <inspector/View_Widget.hxx>
 
-#include <AIS_Trihedron.hxx>
 #include <Geom_Axis2Placement.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
-#include <Standard_Version.hxx>
 
 #include <inspector/View_ToolButton.hxx>
 #include <inspector/View_ViewActionType.hxx>
 // function :  Constructor
 // purpose :
 // =======================================================================
-View_Widget::View_Widget (QWidget* theParent, const bool isFitAllActive)
+View_Widget::View_Widget (QWidget* theParent,
+                          const Handle(AIS_InteractiveContext)& theContext,
+                          const bool isFitAllActive)
 : QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
   myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
   myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0),
   myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
 {
   myViewer = new View_Viewer (View_Viewer::DefaultColor());
-  myViewer->InitStandardViewer();
-
-  myViewer->GetContext()->Display(new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())), Standard_True);
+  if (!theContext.IsNull())
+    myViewer->InitViewer (theContext);
+  else
+  {
+    myViewer->InitViewer (myViewer->CreateStandardViewer());
+  }
 
   setAttribute (Qt::WA_PaintOnScreen);
   setAttribute (Qt::WA_NoSystemBackground);
@@ -108,10 +111,6 @@ void View_Widget::Init()
 #ifdef _WIN32
   Aspect_Handle aWindowHandle = (Aspect_Handle)winId();
   Handle(Aspect_Window) aWnd = new WNT_Window (aWindowHandle);
-#if OCC_VERSION_HEX <= 0x060901
-  myViewer->GetView()->SetZClippingDepth (0.5);
-  myViewer->GetView()->SetZClippingWidth (0.5);
-#endif
 #elif defined (__APPLE__) && !defined (MACOSX_USE_GLX)
   NSView* aViewHandle = (NSView*)winId();
   Handle(Aspect_Window) aWnd = new Cocoa_Window (aViewHandle);
@@ -130,14 +129,23 @@ void View_Widget::Init()
 }
 
 // =======================================================================
-// function : GetDisplayMode
+// function : DisplayMode
 // purpose :
 // =======================================================================
-int View_Widget::GetDisplayMode() const
+int View_Widget::DisplayMode() const
 {
   return myViewActions[View_ViewActionType_DisplayModeId]->isChecked() ? AIS_Shaded : AIS_WireFrame;
 }
 
+// =======================================================================
+// function : SetDisplayMode
+// purpose :
+// =======================================================================
+void View_Widget::SetDisplayMode (const int theMode)
+{
+  myViewActions[View_ViewActionType_DisplayModeId]->setChecked ( theMode ? AIS_Shaded : AIS_WireFrame);
+}
+
 // =======================================================================
 // function : paintEvent
 // purpose :
@@ -197,7 +205,41 @@ void View_Widget::SetEnabledView (const bool theIsEnabled)
     myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
                                                           : View_Viewer::DisabledColor());
   for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
-    GetViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+    ViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_Widget::SaveState (View_Widget* theWidget,
+                             QMap<QString, QString>& theItems,
+                             const QString& thePrefix)
+{
+  theItems[thePrefix + "fitall"] = theWidget->ViewAction (View_ViewActionType_FitAllId)->isChecked();
+  theItems[thePrefix + "dispmode"] = QString::number (theWidget->DisplayMode());
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_Widget::RestoreState (View_Widget* theWidget,
+                                const QString& theKey, const QString& theValue,
+                                const QString& thePrefix)
+{
+  if (theKey == thePrefix + "fitall")
+  {
+    theWidget->SetActionChecked (View_ViewActionType_FitAllId, theValue.toInt() > 0);
+  }
+  else if (theKey == thePrefix + "dispmode")
+  {
+    theWidget->SetDisplayMode (theValue.toInt());
+  }
+  else
+    return false;
+
+  return true;
 }
 
 // =======================================================================
@@ -268,10 +310,10 @@ void View_Widget::initViewActions()
   if (!myViewActions.empty())
     return;
 
-  myFitAllAction = new View_ToolButton (this); //!< action for automatic fit all
+  myFitAllAction = new View_ToolButton (this); // action for automatic fit all
   connect (myFitAllAction, SIGNAL (checkedStateChanged(bool)), this, SLOT (onCheckedStateChanged(bool)));
   createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
-  myFitAllAction->setDefaultAction (GetViewAction (View_ViewActionType_FitAllId));
+  myFitAllAction->setDefaultAction (ViewAction (View_ViewActionType_FitAllId));
 
   createAction (View_ViewActionType_FitAreaId, ":/icons/view_fitarea.png", tr ("Fit Area"), SLOT (OnFitArea()), true);
   createAction (View_ViewActionType_ZoomId, ":/icons/view_zoom.png", tr ("Zoom"), SLOT (OnZoom()), true);
@@ -420,6 +462,7 @@ void View_Widget::processLeftButtonDown (const int theFlags, const QPoint thePoi
     }
   }
   activateCursor (myCurrentMode);
+  emit leftButtonDown(thePoint.x(), thePoint.y());
 }
 
 // =======================================================================
@@ -513,8 +556,8 @@ void View_Widget::processLeftButtonUp (const int theFlags, const QPoint thePoint
   myDragMultiButtonDownX = 0;
   myDragMultiButtonDownY = 0;
 
-  activateCursor (myCurrentMode);
   emit selectionChanged();
+  emit leftButtonUp(thePoint.x(), thePoint.y());
 }
 
 // =======================================================================
@@ -608,6 +651,7 @@ void View_Widget::processMouseMove (const int theFlags, const QPoint thePoint)
      else
       processMoveEvent (thePoint.x(), thePoint.y());
   }
+  emit moveTo (thePoint.x(), thePoint.y());
 }
 
 // =======================================================================
index 5e6ad9bacb42d76ff7870b0dda165412ccc19983..3fd7fdb069cfe32dd1505de6fcfc7811e0e9e06c 100644 (file)
@@ -66,15 +66,17 @@ protected:
   //! Enumeration defines drag mode
   enum View_DragMode
   {
-    View_DragMode_ButtonDown, // theState == -1  button down
-    View_DragMode_ButtonMove, // theState ==  0  move
-    View_DragMode_ButtonUp // theState ==  1  button up
+    View_DragMode_ButtonDown, //!< theState == -1  button down
+    View_DragMode_ButtonMove, //!< theState ==  0  move
+    View_DragMode_ButtonUp //< theState ==  1  button up
   };
 
 public:
 
   //! Constructor
-  Standard_EXPORT View_Widget (QWidget* theParent, const bool isFitAllActive);
+  Standard_EXPORT View_Widget (QWidget* theParent,
+                               const Handle(AIS_InteractiveContext)& theContext,
+                               const bool isFitAllActive);
 
   //! Destructor
   virtual ~View_Widget() {}
@@ -90,41 +92,83 @@ public:
 
   //! Returns an action for the given action type
   //! \param theActionId an action index
-  QAction* GetViewAction (const View_ViewActionType theActionId) const { return myViewActions[theActionId]; };
+  QAction* ViewAction (const View_ViewActionType theActionId) const { return myViewActions[theActionId]; };
 
   //! Retuns an action widget if exist. Implemented for fit all widget.
   //! \param theActionId an action index
   QWidget* GetWidget (const View_ViewActionType theActionId) const { return theActionId == View_ViewActionType_FitAllId ? myFitAllAction : 0; };
 
   //! \returns 0 - AIS_WireFrame, 1 - AIS_Shaded
-  Standard_EXPORT int GetDisplayMode() const;
+  Standard_EXPORT int DisplayMode() const;
 
-  //! Enable/disable view and tool bar actions depending on the parameter
+  //! Sets display mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+  Standard_EXPORT void SetDisplayMode (const int theMode);
+
+  //! Sets enable/disable view and tool bar actions depending on the parameter
   //! \param theIsEnabled boolean value
   Standard_EXPORT void SetEnabledView (const bool theIsEnabled);
 
-  //!< widget for fit all, processed double click to perform action automatically
+  //! Returns true if action is checked. It processes fit all action only.
+  //! \param theIsEnabled boolean value
+  bool IsActionChecked (const View_ViewActionType theActionId)
+    { return theActionId == View_ViewActionType_FitAllId && myFitAllAction->isChecked(); }
+
+  //! Sets checked fit all action. Double click on fit all action set the action checked automatically
   //! \param theIsEnabled boolean value
-  bool IsActionChecked (const View_ViewActionType theActionId) { if (theActionId == View_ViewActionType_FitAllId) return myFitAllAction->isChecked(); }
+  void SetActionChecked (const View_ViewActionType theActionId, const bool isChecked)
+  { if (theActionId == View_ViewActionType_FitAllId) myFitAllAction->setChecked(isChecked); }
 
-  //!< Setx initial camera position
+  //! Sets initial camera position
   //! \param theVx direction on Ox
   //! \param theVy direction on Oy
   //! \param theVz direction on Oz
   void SetInitProj (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
   { myHasInitProj = Standard_True; myInitVx = theVx; myInitVy = theVy; myInitVz = theVz; }
 
-  //! Get paint engine for the OpenGL viewer. Avoid default execution of Qt Widget.
+  //! Returns paint engine for the OpenGL viewer. Avoid default execution of Qt Widget.
   virtual QPaintEngine* paintEngine() const Standard_OVERRIDE { return 0; }
 
-  //! Recommended size for view. If default size exists, it returns the default size
+  //! Return the recommended size for view. If default size exists, it returns the default size
   Standard_EXPORT virtual QSize sizeHint() const Standard_OVERRIDE;
 
+  //! Saves state of widget actions
+  //! \param theParameters a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  Standard_EXPORT static void SaveState (View_Widget* theWidget,
+                                         QMap<QString, QString>& theItems,
+                                         const QString& thePrefix = QString());
+
+  //! Restores state of widget actions
+  //! \param theParameters a view instance
+  //! \param theKey property key
+  //! \param theValue property value
+  //! \param thePrefix peference item prefix
+  //! \return boolean value whether the property is applied to the tree view
+  Standard_EXPORT static bool RestoreState (View_Widget* theWidget,
+                                            const QString& theKey, const QString& theValue,
+                                            const QString& thePrefix = QString());
+
 signals:
 
   //! Sends a signal about selection change if the left mouse button is pressed and current action does not process it
   void selectionChanged();
 
+  //! Sends a signal about moving to the point in the view
+  //! \param theX X mouse position in pixels
+  //! \param theY Y mouse position in pixels
+  void  moveTo (const int theX, const int theY);
+
+  //! Sends a signal about up the left mouse button down
+  //! \param theX X mouse position in pixels
+  //! \param theY Y mouse position in pixels
+  void leftButtonDown (const int theX, const int theY);
+
+  //! Sends a signal about up the left mouse button up
+  //! \param theX X mouse position in pixels
+  //! \param theY Y mouse position in pixels
+  void leftButtonUp (const int theX, const int theY);
+
   //! Sends a signal about display mode change
   void displayModeClicked();
 
@@ -163,11 +207,11 @@ public slots:
 
 protected:
 
-  //! Avoid Qt standard execution of this method, redraw V3d view
+  //! Avoids Qt standard execution of this method, redraw V3d view
   //! \param an event
   virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE;
 
-  //! Avoid Qt standard execution of this method, do mustBeResized for V3d view, Init view if it is the first call
+  //! Avoids Qt standard execution of this method, do mustBeResized for V3d view, Init view if it is the first call
   //! \param an event
   virtual void resizeEvent (QResizeEvent* theEvent) Standard_OVERRIDE;
 
index 98edc7485c7abad7669e5f927ca50470e8329c81..f47cbeb9c2d9722cb183f2ebd27043af18f274b9 100644 (file)
 
 #include <inspector/View_Window.hxx>
 
-#include <inspector/TInspectorAPI_Version.hxx>
-
 #include <inspector/View_Displayer.hxx>
+#include <inspector/View_DisplayPreview.hxx>
+#include <inspector/View_PreviewParameters.hxx>
 #include <inspector/View_ToolBar.hxx>
-#include <inspector/View_Tools.hxx>
 #include <inspector/View_Viewer.hxx>
 #include <inspector/View_Widget.hxx>
 
@@ -43,14 +42,16 @@ const int DEFAULT_SPACING = 3;
 // function : Constructor
 // purpose :
 // =======================================================================
-View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bool isFitAllActive)
+View_Window::View_Window (QWidget* theParent,
+                          const Handle(AIS_InteractiveContext)& theContext,
+                          const bool isUseKeepView, const bool isFitAllActive)
 : QWidget (theParent)
 {
   QGridLayout* aViewLayout = new QGridLayout (this);
   aViewLayout->setContentsMargins (0, 0, 0, 0);
   aViewLayout->setSpacing (DEFAULT_SPACING);
 
-  myView = new View_Widget (this, isFitAllActive);
+  myView = new View_Widget (this, theContext, isFitAllActive);
   myViewToolBar = new View_ToolBar (this, isUseKeepView);
   aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
   connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
@@ -69,7 +70,7 @@ View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bo
 
   myActionsToolBar->addWidget (myView-> GetWidget (View_ViewActionType_FitAllId));
   for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
-    myActionsToolBar->addAction (myView->GetViewAction ((View_ViewActionType)anActionId));
+    myActionsToolBar->addAction (myView->ViewAction ((View_ViewActionType)anActionId));
 
   aViewLayout->addWidget (myActionsToolBar, 1, 0);
   aViewLayout->addWidget (myView, 1, 1);
@@ -92,7 +93,76 @@ View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bo
 // =======================================================================
 void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_InteractiveContext)& theContext)
 {
-  GetViewToolBar()->SetContext (View_ContextType_External, theContext);
+  ViewToolBar()->SetContext (View_ContextType_External, theContext);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_Window::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
+                             const QString& thePrefix)
+{
+  QStringList aCameraDirection;
+  Standard_Real aVX, aVY, aVZ;
+  Handle(V3d_View) aView = theView->ViewWidget()->GetViewer()->GetView();
+  if (aView.IsNull())
+    return;
+
+  aView->Proj (aVX, aVY, aVZ);
+  aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
+
+  theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
+
+  View_PreviewParameters::SaveState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(), theItems, "preview_parameters_");
+  View_ToolBar::SaveState (theView->ViewToolBar(), theItems, "view_toolbar_");
+  View_Widget::SaveState (theView->ViewWidget(), theItems, "view_widget_");
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool View_Window::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
+                                const QString& thePrefix)
+{
+  if (theKey == thePrefix + "view_camera_direction")
+  {
+    QStringList aValues = theValue.split (",");
+    if (aValues.size() == 3)
+    {
+      Standard_Real aVX = aValues.at (0).toDouble();
+      Standard_Real aVY = aValues.at (1).toDouble();
+      Standard_Real aVZ = aValues.at (2).toDouble();
+
+      theView->ViewWidget()->SetInitProj (aVX, aVY, aVZ);
+    }
+    return true;
+  }
+  else if (View_PreviewParameters::RestoreState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(),
+                                                 theKey, theValue, "preview_parameters_"))
+  {
+    return true;
+  }
+  else if (View_ToolBar::RestoreState (theView->ViewToolBar(), theKey, theValue, "view_toolbar_"))
+  {
+    return true;
+  }
+  else if (View_Widget::RestoreState (theView->ViewWidget(), theKey, theValue, "view_widget_"))
+  {
+    // display mode is restored
+    View_Displayer* aDisplayer = theView->Displayer();
+    if (theView->ViewWidget()->DisplayMode() != aDisplayer->DisplayMode())
+      aDisplayer->SetDisplayMode (theView->ViewWidget()->DisplayMode());
+
+    bool toFitAll = theView->ViewWidget()->IsActionChecked (View_ViewActionType_FitAllId);
+    if (toFitAll != aDisplayer->IsFitAllActive())
+      aDisplayer->SetFitAllActive (toFitAll);
+
+    return true;
+  }
+
+  return false;
 }
 
 // =======================================================================
@@ -101,12 +171,12 @@ void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_Int
 // =======================================================================
 void View_Window::onViewSelectorActivated()
 {
-  View_ContextType aType = myViewToolBar->GetCurrentContextType();
+  View_ContextType aType = myViewToolBar->CurrentContextType();
   bool isViewEnabled = aType == View_ContextType_Own;
 
   myView->SetEnabledView (isViewEnabled);
 
-  Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
+  Handle(AIS_InteractiveContext) aContext = myViewToolBar->CurrentContext();
   myDisplayer->EraseAllPresentations (true);
   emit eraseAllPerformed();
 
@@ -121,6 +191,11 @@ void View_Window::onToolBarActionClicked (const int theActionId)
 {
   switch (theActionId)
   {
+    case View_ToolActionType_Trihedron:
+    {
+      myDisplayer->DisplayDefaultTrihedron (myViewToolBar->IsActionChecked (theActionId), Standard_True);
+      break;
+    }
     case View_ToolActionType_KeepViewId:
     {
       myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
@@ -158,23 +233,22 @@ void View_Window::onCheckedStateChanged (int theActionId, bool theState)
 // =======================================================================
 void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
 {
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
   QMenu* aMenu = new QMenu (this);
   QMenu* anOrientationSubMenu = aMenu->addMenu ("Set View Orientation");
 
   for (int i = 0; i < (int)V3d_XnegYnegZneg; i++)
   {
     V3d_TypeOfOrientation anOrientationType = (V3d_TypeOfOrientation)i;
-    anOrientationSubMenu->addAction (View_Tools::CreateAction (V3d::TypeOfOrientationToString (anOrientationType),
-                                                               SLOT (onSetOrientation()), this, this));
+
+    QAction* anAction = new QAction (V3d::TypeOfOrientationToString (anOrientationType), this);
+    QObject::connect (anAction, SIGNAL (triggered (bool)), this, SLOT (onSetOrientation()));
+
+    anOrientationSubMenu->addAction (anAction);
   }
   aMenu->addMenu (anOrientationSubMenu);
 
   QPoint aPoint = myView->mapToGlobal (thePosition);
   aMenu->exec (aPoint);
-#else
-  (void)thePosition;
-#endif
 }
 
 // =======================================================================
@@ -183,7 +257,6 @@ void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
 // =======================================================================
 void View_Window::onSetOrientation()
 {
-#if TINSPECTORAPI_VERSION_HEX > 0x070200
   QAction* anAction = (QAction*)(sender());
 
   TCollection_AsciiString anOrientationStr (anAction->text().toStdString().c_str());
@@ -199,7 +272,6 @@ void View_Window::onSetOrientation()
   aView->SetProj (anOrientationType);
   aView->FitAll();
   aView->Redraw();
-#endif
 }
 
 // =======================================================================
@@ -208,7 +280,7 @@ void View_Window::onSetOrientation()
 // =======================================================================
 void View_Window::onDisplayModeChanged()
 {
-  int aDisplayMode = myView->GetDisplayMode();
+  int aDisplayMode = myView->DisplayMode();
   for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator
        anIterator(myDisplayer->GetDisplayed()); anIterator.More(); anIterator.Next())
     myDisplayer->SetDisplayMode (aDisplayMode, anIterator.Key(), false);
index 91eb8018c118a17bc0af01a88b652ae4d6d7d9ae..b270f816d339ac0c92567dc45b689867d050f1b7 100644 (file)
@@ -40,28 +40,48 @@ class View_Window : public QWidget
 public:
 
   //! Constructor
-  Standard_EXPORT View_Window (QWidget* theParent, const bool isUseKeepView = true, const bool isFitAllActive = true);
+  Standard_EXPORT View_Window (QWidget* theParent,
+                               const Handle(AIS_InteractiveContext)& theContext = Handle(AIS_InteractiveContext)(),
+                               const bool isUseKeepView = true, const bool isFitAllActive = true);
 
   //! Destructor
   virtual ~View_Window() {}
 
   //! Returns view displayer
-  View_Displayer* GetDisplayer() const { return myDisplayer; }
+  View_Displayer* Displayer() const { return myDisplayer; }
 
   //! Returns view widget
-  View_Widget* GetView() const { return myView; }
+  View_Widget* ViewWidget() const { return myView; }
 
   //! Returns actions tool bar
-  QToolBar* GetActionsToolBar() const { return myActionsToolBar; }
+  QToolBar* ActionsToolBar() const { return myActionsToolBar; }
 
   //! Returns window tool bar
-  View_ToolBar* GetViewToolBar() const { return myViewToolBar; }
+  View_ToolBar* ViewToolBar() const { return myViewToolBar; }
 
   //! Sets a new context for context type
   //! \param theType a type of context, will be selected in the tool bar combo box
   //! \param theContext an AIS context
   Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
 
+  //! Saves state of view window in a container in form: key, value. It saves:
+  //! - visibility of columns,
+  //! - columns width
+  //! \param theTreeView a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  Standard_EXPORT static void SaveState (View_Window* theView, QMap<QString, QString>& theItems,
+                                         const QString& thePrefix = QString());
+
+  //! Restores state of view window by a container
+  //! \param theTreeView a view instance
+  //! \param theKey property key
+  //! \param theValue property value
+  //! \param thePrefix peference item prefix
+  //! \return boolean value whether the property is applied to the tree view
+  Standard_EXPORT static bool RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
+                                            const QString& thePrefix = QString());
+
 signals:
   //! Signals about calling erasing all presentations in context
   void eraseAllPerformed();
diff --git a/tools/View/icons/trihedron.png b/tools/View/icons/trihedron.png
new file mode 100644 (file)
index 0000000..bc5894d
Binary files /dev/null and b/tools/View/icons/trihedron.png differ
index 432c6f8adf2d5effcd57cf18244ac69b5c4a5d7e..9fda7a71be65a026c13b8b0e5f8964df7ed89b31 100644 (file)
@@ -1,5 +1,14 @@
+ViewControl_EditType.hxx
 ViewControl_MessageDialog.cxx
 ViewControl_MessageDialog.hxx
+ViewControl_PropertyView.cxx
+ViewControl_PropertyView.hxx
+ViewControl_Table.cxx
+ViewControl_Table.hxx
+ViewControl_TableModel.cxx
+ViewControl_TableModel.hxx
+ViewControl_TableModelValues.cxx
+ViewControl_TableModelValues.hxx
 ViewControl_Tools.cxx
 ViewControl_Tools.hxx
-ViewControl_TreeView.hxx
\ No newline at end of file
+ViewControl_TreeView.hxx
diff --git a/tools/ViewControl/ViewControl_EditType.hxx b/tools/ViewControl/ViewControl_EditType.hxx
new file mode 100644 (file)
index 0000000..7d12ae0
--- /dev/null
@@ -0,0 +1,30 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_EditType_H
+#define ViewControl_EditType_H
+
+//! Type of context used in a tool library
+enum ViewControl_EditType
+{
+  ViewControl_EditType_None, //!< View widget is null
+  ViewControl_EditType_Bool, //!< check box widget
+  ViewControl_EditType_Double, //!< line edit widget used double validator
+  ViewControl_EditType_Line, //!< line edit widget
+  ViewControl_EditType_Spin, //!< spin box widget
+  ViewControl_EditType_DoAction //!< control to perform the row action
+};
+
+#endif
index 8c1e16eca09b9fe44f14721155c64acd2398d557..e8ae197a17c03e18a9f17d809b4842fe601557c7 100644 (file)
@@ -66,20 +66,20 @@ private slots:
   void onCancelClicked();
 
 private:
-  //! Change state of the dialog to message tool tip. Only information control will be shown in the dialog
+  //! Changes state of the dialog to message tool tip. Only information control will be shown in the dialog
   void setToolTipInfoMode();
 
 private:
-  bool myDoNotShowItAgain; //! state if the dialog should not be shown again, the latest result is used as answer
-  bool myPreviousAnswer; //! the previous cached result of the dialog
+  bool myDoNotShowItAgain; //!< state if the dialog should not be shown again, the latest result is used as answer
+  bool myPreviousAnswer; //!< the previous cached result of the dialog
 
-  QString myInformation; //! the information text
-  QString myQuestion; //! the question text
+  QString myInformation; //!< the information text
+  QString myQuestion; //!< the question text
 
-  QLabel* myInformationLabel; //! message control
-  QCheckBox* myDoNotShowCheckBox; //! choice whether the dialog will be shown again
-  QPushButton* myOkButton; //! accept button
-  QPushButton* myCancelButton; //! reject button
+  QLabel* myInformationLabel; //!< message control
+  QCheckBox* myDoNotShowCheckBox; //!< choice whether the dialog will be shown again
+  QPushButton* myOkButton; //!< accept button
+  QPushButton* myCancelButton; //!< reject button
 };
 
 
diff --git a/tools/ViewControl/ViewControl_PropertyView.cxx b/tools/ViewControl/ViewControl_PropertyView.cxx
new file mode 100644 (file)
index 0000000..215d44c
--- /dev/null
@@ -0,0 +1,208 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_PropertyView.hxx>
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/ViewControl_TableModelValues.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QHeaderView>
+#include <QStackedWidget>
+#include <QScrollArea>
+#include <QTableView>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+//! Class that uses parameter size as recommended size for the widget.
+//! If the control is placed in a dock widget of the main window, it will not be resized on free size by resizing the main window.
+class ViewControl_PredefinedSizeWidget : public QWidget
+{
+public:
+  //! Constructor
+  ViewControl_PredefinedSizeWidget (QWidget* theParent, const QSize& theSize) : QWidget (theParent) { SetPredefinedSize (theSize); }
+
+  //! Destructor
+  virtual ~ViewControl_PredefinedSizeWidget() {}
+
+  //! Sets default size of control, that is used by the first control show
+  //! \param theDefaultWidth the width value
+  //! \param theDefaultHeight the height value
+  void SetPredefinedSize (const QSize& theSize) { myDefaultSize = theSize;}
+
+  //! Returns predefined size if both values are positive, otherwise parent size hint
+  virtual QSize sizeHint() const Standard_OVERRIDE { return myDefaultSize.isValid() ? myDefaultSize : QWidget::sizeHint(); }
+
+private:
+  QSize myDefaultSize; //!< default size, empty size if it should not be used
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ViewControl_PropertyView::ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize)
+: QObject (theParent), myOwnSelectionChangeBlocked (false)
+{
+  myMainWidget = new ViewControl_PredefinedSizeWidget (theParent, QSize (1, 100));
+  if (!thePredefinedSize.isEmpty())
+    ((ViewControl_PredefinedSizeWidget*)myMainWidget)->SetPredefinedSize (thePredefinedSize);
+
+  QVBoxLayout* aLayout = new QVBoxLayout (myMainWidget);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+
+  QScrollArea* anArea = new QScrollArea (myMainWidget);
+
+  myAttributesStack = new QStackedWidget (myMainWidget);
+  anArea->setWidget (myAttributesStack);
+  anArea->setWidgetResizable( true );
+  aLayout->addWidget (anArea);
+
+  myEmptyWidget = new QWidget (myAttributesStack);
+  myAttributesStack->addWidget (myEmptyWidget);
+
+  myTableWidget = new QWidget (myAttributesStack);
+  myTableWidgetLayout = new QVBoxLayout (myTableWidget);
+  myTableWidgetLayout->setContentsMargins (0, 0, 0, 0);
+  myAttributesStack->addWidget (myTableWidget);
+
+  myAttributesStack->setCurrentWidget (myEmptyWidget);
+
+  // create table
+  ViewControl_Table* aTable = new ViewControl_Table (myMainWidget);
+  ViewControl_TableModel* aModel = new ViewControl_TableModel(aTable->TableView());
+  aTable->SetModel (aModel);
+
+  connect (aTable->TableView()->selectionModel(),
+          SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+          this, SLOT(onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+  connect (aModel, SIGNAL (dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)),
+           this, SIGNAL (propertyViewDataChanged()));
+
+  myTableWidgetLayout->addWidget (aTable->GetControl());
+  myTable = aTable;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Init (ViewControl_TableModelValues* theTableValues)
+{
+  ViewControl_Table* aTable = Table();
+  if (theTableValues)
+  {
+    aTable->Init (theTableValues);
+    ViewControl_Tools::SetDefaultHeaderSections (aTable->TableView(), Qt::Horizontal);
+  }
+  aTable->SetActive (theTableValues != 0);
+
+  if (theTableValues)
+    myAttributesStack->setCurrentWidget (myTableWidget);
+  else
+    myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Init (QWidget*)
+{
+}
+
+// =======================================================================
+// function : ClearActiveTablesSelection
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::ClearActiveTablesSelection()
+{
+  bool aWasBlocked = myOwnSelectionChangeBlocked;
+  myOwnSelectionChangeBlocked = true;
+
+  QList<ViewControl_Table*> aTables;
+  ViewControl_Table* aTable = Table();
+  if (aTable->IsActive())
+    aTable->TableView()->selectionModel()->clearSelection();
+
+  myOwnSelectionChangeBlocked = aWasBlocked;
+}
+
+// =======================================================================
+// function : Clear
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::Clear()
+{
+  ViewControl_Table* aTable = Table();
+  if (aTable->IsActive())
+  {
+    ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (aTable->TableView()->model());
+    aModel->SetModelValues (0);
+
+    aTable->SetActive (true);
+  }
+  myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::SaveState (ViewControl_PropertyView* thePropertyView,
+                                          QMap<QString, QString>& theItems,
+                                          const QString& thePrefix)
+{
+  ViewControl_Table* aTable = thePropertyView->Table();
+  int aColumnWidth = aTable->TableView()->columnWidth (0);
+  theItems[thePrefix + "column_width_0"] = QString::number (aColumnWidth);
+}
+
+// =======================================================================
+// function : RestoreState
+// purpose :
+// =======================================================================
+bool ViewControl_PropertyView::RestoreState (ViewControl_PropertyView* thePropertyView,
+                                             const QString& theKey,
+                                             const QString& theValue,
+                                             const QString& thePrefix)
+{
+  if (theKey == thePrefix + "column_width_0")
+  {
+    bool isOk;
+    int aWidth = theValue.toInt (&isOk);
+    if (isOk)
+      thePropertyView->Table()->TableView()->horizontalHeader()->setDefaultSectionSize (aWidth);
+  }
+  else
+    return false;
+  return true;
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void ViewControl_PropertyView::onTableSelectionChanged (const QItemSelection&, const QItemSelection&)
+{
+  if (myOwnSelectionChangeBlocked)
+    return;
+
+  emit propertyViewSelectionChanged();
+}
diff --git a/tools/ViewControl/ViewControl_PropertyView.hxx b/tools/ViewControl/ViewControl_PropertyView.hxx
new file mode 100644 (file)
index 0000000..f424245
--- /dev/null
@@ -0,0 +1,116 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_PropertyView_H
+#define TreeModel_PropertyView_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <inspector/ViewControl_Table.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QObject>
+#include <QList>
+#include <Standard_WarningsRestore.hxx>
+
+class QAbstractTableModel;
+class QStackedWidget;
+class QWidget;
+class QVBoxLayout;
+
+class ViewControl_TableModelValues;
+
+//! \class ViewControl_PropertyView
+//! \brief View widget where several tables are visualized in vertical layout.
+class ViewControl_PropertyView : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT ViewControl_PropertyView (QWidget* theParent, const QSize& thePredefinedSize = QSize());
+
+  //! Destructor
+  virtual ~ViewControl_PropertyView() {}
+
+  //! Fills the view content with values. Number of visible tables is size of container,
+  //! Each element of container is values of the corresponded table
+  //! \param theTableValues values
+  Standard_EXPORT void Init (ViewControl_TableModelValues* theTableValues);
+
+  //! Fills the view content with the parameter custom widget.
+  //! \param theWidget control
+  Standard_EXPORT void Init (QWidget* theWidget);
+
+  //! Clears layout of the view and tables models.
+  Standard_EXPORT void Clear();
+
+  //! \return the text edit control
+  QWidget* GetControl() const { return myMainWidget; }
+
+  //! Returns container an active table or NULL
+  ViewControl_Table* Table() { return myTable; }
+
+  //! Clears selection in active tables
+  Standard_EXPORT void ClearActiveTablesSelection();
+
+  //! Saves state of property view in a container in form: key, value. It saves:
+  //! - visibility of columns,
+  //! - columns width
+  //! \param theTreeView a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  Standard_EXPORT static void SaveState (ViewControl_PropertyView* theParameters,
+                                         QMap<QString, QString>& theItems,
+                                         const QString& thePrefix = QString());
+
+  //! Restores state of property view by a container
+  //! \param theTreeView a view instance
+  //! \param theKey property key
+  //! \param theValue property value
+  //! \param thePrefix peference item prefix
+  //! \return boolean value whether the property is applied to the tree view
+  Standard_EXPORT static bool RestoreState (ViewControl_PropertyView* theParameters,
+                                            const QString& theKey, const QString& theValue,
+                                            const QString& thePrefix = QString());
+
+signals:
+  //! Signal about selection change in property view table
+  void propertyViewSelectionChanged();
+
+  //! Signal about data change in property view table
+  void propertyViewDataChanged();
+
+protected slots:
+  //! Emits signal about selection is changed
+  //! \param theSelected container of selected table cells
+  //! \param theDeselected container of selected table cells
+  void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+private:
+  bool myOwnSelectionChangeBlocked; //!< blocking emit of selection changed signal
+
+  QWidget* myMainWidget; //!< parent of all controls
+
+  QStackedWidget* myAttributesStack; //!< container of already created panes
+  QWidget* myEmptyWidget; //!< an empty widget when nothing is selected in tree view
+
+  QWidget* myTableWidget; //!< widget of tables in vertical layout
+  QVBoxLayout* myTableWidgetLayout; //!< main view layout where tables or custom widgets are presented
+  ViewControl_Table* myTable; //!< table view, shown only first tables filled in Init method
+  QWidget* myCustomWidget; //!< custom view widget
+};
+#endif
diff --git a/tools/ViewControl/ViewControl_Table.cxx b/tools/ViewControl/ViewControl_Table.cxx
new file mode 100644 (file)
index 0000000..76269f2
--- /dev/null
@@ -0,0 +1,165 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_Table.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <inspector/TreeModel_Tools.hxx>
+
+#include <Standard_Dump.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAction>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QTableView>
+#include <QWidget>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ViewControl_Table::ViewControl_Table (QWidget* theParent)
+: QObject (theParent), myIsUseProperty (false)
+{
+  myMainWidget = new QWidget (theParent);
+  QGridLayout* aLayout = new QGridLayout (myMainWidget);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+
+  myTableView = new QTableView (myMainWidget);
+  myTableView->setVerticalScrollMode (QAbstractItemView::ScrollPerPixel);
+
+  QHeaderView* aVHeader = myTableView->verticalHeader();
+  int aDefCellSize = aVHeader->minimumSectionSize();
+  aVHeader->setDefaultSectionSize (aDefCellSize);
+
+  connect (myTableView->horizontalHeader(), SIGNAL (sectionResized (int, int, int)),
+           this, SLOT(onHeaderResized (int, int, int)));
+
+  aLayout->addWidget (myTableView);
+}
+
+// =======================================================================
+// function : SetModel
+// purpose :
+// =======================================================================
+void ViewControl_Table::SetModel (QAbstractTableModel* theModel)
+{
+  myTableView->setModel (theModel);
+
+  myTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  QItemSelectionModel* aSelectionModel = new QItemSelectionModel(theModel);
+  myTableView->setSelectionModel (aSelectionModel);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues)
+{
+  myTableView->selectionModel()->clearSelection();
+
+  ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (myTableView->model());
+  aModel->SetModelValues (theModelValues);
+
+  myTableView->horizontalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Horizontal));
+
+  myTableView->verticalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Vertical));
+  int aSectionSize;
+  if (theModelValues->DefaultSectionSize (Qt::Vertical, aSectionSize) )
+  {
+    myTableView->verticalHeader()->setDefaultSectionSize (aSectionSize);
+  }
+  else
+    myTableView->verticalHeader()->setDefaultSectionSize (myTableView->verticalHeader()->minimumSectionSize());
+
+  aModel->EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : SelectedIndices
+// purpose :
+// =======================================================================
+void ViewControl_Table::SelectedIndices (QMap<int, QList<int>>& theSelectedIndices) const
+{
+  QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
+
+  int aRow, aColumn;
+  for (QModelIndexList::const_iterator anIt = aSelected.begin(); anIt != aSelected.end(); anIt++)
+  {
+    QModelIndex anIndex = *anIt;
+    aRow = anIndex.row();
+    aColumn = anIndex.column();
+    if (!theSelectedIndices.contains (aRow))
+      theSelectedIndices.insert (aRow, QList<int>());
+    theSelectedIndices[aRow].append (aColumn);
+  }
+}
+
+// =======================================================================
+// function : SeparatorData
+// purpose :
+// =======================================================================
+QString ViewControl_Table::SeparatorData()
+{
+  return ViewControl_Tools::TableSeparator();
+}
+
+// =======================================================================
+// function : SelectedPointers
+// purpose :
+// =======================================================================
+void ViewControl_Table::SelectedPointers (QStringList& thePointers) const
+{
+  QMap<int, QList<int>> aSelectedIndices;
+  SelectedIndices (aSelectedIndices);
+
+  ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(TableView()->model());
+  ViewControl_TableModelValues* aTableValues = aTableModel->ModelValues();
+
+  for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+  {
+    int aRowId = aSelIt.key();
+    QList<int> aColIds = aSelIt.value();
+    for (int aColId = 0; aColId < aColIds.size(); aColId++)
+    {
+      int aSelectedColId = aColIds[aColId];
+      if (aSelectedColId != 1)
+        continue;
+
+      QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString();
+      if (aData.contains (Standard_Dump::GetPointerPrefix().ToCString()))
+        thePointers.append (aData);
+    }
+  }
+}
+
+// =======================================================================
+// function : onHeaderResized
+// purpose :
+// =======================================================================
+void ViewControl_Table::onHeaderResized (int theSectionId, int, int)
+{
+  if (theSectionId != 0)
+    return;
+
+  myTableView->horizontalHeader()->setDefaultSectionSize (myTableView->columnWidth (theSectionId));
+}
diff --git a/tools/ViewControl/ViewControl_Table.hxx b/tools/ViewControl/ViewControl_Table.hxx
new file mode 100644 (file)
index 0000000..47e81fc
--- /dev/null
@@ -0,0 +1,95 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_Table_H
+#define ViewControl_Table_H
+
+#include <NCollection_List.hxx>
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Transient.hxx>
+
+#include <inspector/TreeModel_ItemBase.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QItemSelection>
+#include <QObject>
+#include <QTableView>
+#include <Standard_WarningsRestore.hxx>
+
+class ViewControl_TableModelValues;
+
+class QAbstractTableModel;
+class QContextMenuEvent;
+class QWidget;
+
+//! \class ViewControl_Table
+//! \brief View to display table values with possibility to change table columns
+//! if the table has 1D dimension and Horizontal orientation
+class ViewControl_Table : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT ViewControl_Table (QWidget* theParent);
+
+  //! Destructor
+  virtual ~ViewControl_Table() {}
+
+  //! Sets model into table view, init selection model by the given model, connect to selection change
+  //! \param theModel table values model
+  void SetModel (QAbstractTableModel* theModel);
+
+  //! Fills table view and table size control by the model
+  //! \param theModel values model
+  Standard_EXPORT void Init (ViewControl_TableModelValues* theModelValues);
+
+  //! true if the table is used in property view and visible
+  bool IsActive() const { return myIsActive; }
+
+  //! Sets the table active and show the table
+  //! \param theState boolean value
+  void SetActive (const bool theState) { myIsActive = theState; TableView()->setVisible (theState); }
+
+  //! \return the text edit control
+  QWidget* GetControl() const { return myMainWidget; }
+
+  //! \return the table view
+  QTableView* TableView() const { return myTableView; }
+
+  //! Retuns model indices of the selected cells in table view
+  //! \param theSelectedIndices [out] a container of indices: row to list of columns
+  Standard_EXPORT void SelectedIndices (QMap<int, QList<int>>& aSelectedIndices) const;
+
+  //! Returns pointers from selected cells
+  Standard_EXPORT void SelectedPointers (QStringList& thePointers) const;
+
+  //! Returns text of separation row in table
+  //! \return string value
+  Standard_EXPORT static QString SeparatorData();
+
+protected slots:
+  void onHeaderResized (int theSectionId, int, int);
+
+private:
+  bool myIsActive; //!< true if the table is used in property view and visible
+
+  QWidget* myMainWidget; //!< parent of all controls
+  bool myIsUseProperty; //!< boolean value whether the property control should be shown/hidden
+  QTableView* myTableView; //!< table view
+};
+#endif
diff --git a/tools/ViewControl/ViewControl_TableModel.cxx b/tools/ViewControl/ViewControl_TableModel.cxx
new file mode 100644 (file)
index 0000000..fe6363f
--- /dev/null
@@ -0,0 +1,82 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_TableModel.hxx>
+
+// =======================================================================
+// function : SetModelValues
+// purpose :
+// =======================================================================
+void ViewControl_TableModel::SetModelValues (ViewControl_TableModelValues* theModelValues)
+{
+  if (myModelValues)
+    delete myModelValues;
+
+  myModelValues = theModelValues;
+}
+
+// =======================================================================
+// function : columnCount
+// purpose :
+// =======================================================================
+int ViewControl_TableModel::columnCount(const QModelIndex& theParent) const
+{
+  if (!myModelValues)
+    return 0;
+
+  return myModelValues->ColumnCount (theParent);
+}
+
+// =======================================================================
+// function : rowCount
+// purpose :
+// =======================================================================
+int ViewControl_TableModel::rowCount(const QModelIndex& theParent ) const
+{
+  if (!myModelValues)
+    return 0;
+
+  return myModelValues->RowCount (theParent);
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant ViewControl_TableModel::data (const QModelIndex& theIndex, int theRole) const
+{
+  if (!myModelValues)
+    return QVariant();
+
+  int aRow = theIndex.row(), aColumn = theIndex.column();
+  return myModelValues->Data (aRow, aColumn, theRole);
+}
+
+// =======================================================================
+// function : setData
+// purpose :
+// =======================================================================
+bool ViewControl_TableModel::setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole)
+{
+  if (!myModelValues)
+    return false;
+
+  int aRow = theIndex.row(), aColumn = theIndex.column();
+  bool aResult = myModelValues->SetData (aRow, aColumn, theValue, theRole);
+
+  emit dataChanged (theIndex, theIndex);
+
+  return aResult;
+}
diff --git a/tools/ViewControl/ViewControl_TableModel.hxx b/tools/ViewControl/ViewControl_TableModel.hxx
new file mode 100644 (file)
index 0000000..7971428
--- /dev/null
@@ -0,0 +1,100 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_TableModel_H
+#define ViewControl_TableModel_H
+
+#include <Standard.hxx>
+
+#include <inspector/ViewControl_TableModelValues.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+#include <vector>
+
+//! \class ViewControl_TableModel
+//! \brief This is an extension of table model to visualize a container of values
+//! It is possible to:
+//! - set orientation to interpretate the values.
+//! - set table view header values.
+//! Items of the view are enabled and selectable.
+class ViewControl_TableModel : public QAbstractTableModel
+{
+public:
+
+  //! Constructor
+  ViewControl_TableModel (QObject* theParent = 0) : myModelValues (0) { (void)theParent; }
+
+  //! Destructor
+  virtual ~ViewControl_TableModel() {}
+
+  //! Returns instance of interface for access totable values
+  //! \return interface or NULL
+  ViewControl_TableModelValues* ModelValues() const { return myModelValues; }
+
+  //! Sets interface to table values
+  //! \theModelValues instance of values
+  Standard_EXPORT void SetModelValues (ViewControl_TableModelValues* theModelValues);
+
+  //! Emits the layoutChanged signal from outside of this class
+  void EmitLayoutChanged() { emit layoutChanged(); }
+
+  //! Returns number of columns, 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 columnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+  //! 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 rowCount(const QModelIndex& theParent = QModelIndex()) 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 theIndex a model index
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+  //! Sets the new value of passed role to tree cell.
+  //! \param[in] index refers to item in tree.
+  //! \param[in] value the new value.
+  //! \param[in] role the role of value.
+  Standard_EXPORT virtual bool setData (const QModelIndex& theIndex, const QVariant& theValue, int theRole) Standard_OVERRIDE;
+
+  //! Returns content of the model index for the given role, it is obtainer from internal container of header values
+  //! It returns value only for DisplayRole.
+  //! \param theSection an index of value in the container 
+  //! \param theIndex a model index
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  virtual QVariant headerData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const Standard_OVERRIDE
+  { return myModelValues ? myModelValues->HeaderData (theSection, theOrientation, theRole) : QVariant(); }
+
+  //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
+  //! \param theIndex a model index
+  //! \return flags
+  Qt::ItemFlags flags (const QModelIndex& theIndex) const
+  { return myModelValues ? myModelValues->Flags (theIndex) : Qt::NoItemFlags; }
+
+private:
+  ViewControl_TableModelValues* myModelValues; //!< interface to table values
+};
+
+#endif
diff --git a/tools/ViewControl/ViewControl_TableModelValues.cxx b/tools/ViewControl/ViewControl_TableModelValues.cxx
new file mode 100644 (file)
index 0000000..80a70e3
--- /dev/null
@@ -0,0 +1,143 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_TableModelValues.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
+// =======================================================================
+// function : ColumnCount
+// purpose :
+// =======================================================================
+
+int ViewControl_TableModelValues::ColumnCount (const QModelIndex&) const
+{
+  if (!Properties().IsNull())
+    return Properties()->ColumnCount();
+
+  return 0;
+}
+
+
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int ViewControl_TableModelValues::RowCount (const QModelIndex&) const
+{
+  return !Properties().IsNull() ? Properties()->RowCount() : 0;
+}
+
+// =======================================================================
+// function : Data
+// purpose :
+// =======================================================================
+
+QVariant ViewControl_TableModelValues::Data (const int theRow, const int theColumn, int theRole) const
+{
+  if (!Properties().IsNull())
+  {
+    QVariant aValue = Properties()->Data (theRow, theColumn, theRole);
+    if (aValue.isValid())
+      return aValue;
+  }
+
+  if (theRole == Qt::TextAlignmentRole) // for multi-lines text, align it to the top
+    return Qt::AlignTop;
+
+  if ((theRole == Qt::FontRole || theRole == Qt::ForegroundRole) && isItalicHeader (theRow, theColumn))
+  {
+    if (theRole == Qt::FontRole)
+    {
+      QFont aFont = qApp->font();
+      aFont.setItalic (true);
+      return aFont;
+    }
+    else
+      return QColor (Qt::darkGray).darker (150);
+  }
+  return QVariant();
+}
+
+// =======================================================================
+// function : SetData
+// purpose :
+// =======================================================================
+
+bool ViewControl_TableModelValues::SetData (const int theRow, const int theColumn, const QVariant& theValue, int)
+{
+  if (!Properties().IsNull())
+    return Properties()->SetData (theRow, theColumn, theValue);
+
+  return false;
+}
+
+// =======================================================================
+// function : HeaderData
+// purpose :
+// =======================================================================
+
+QVariant ViewControl_TableModelValues::HeaderData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+  if (theRole == Qt::DisplayRole)
+    return myHeaderValues.contains (theOrientation) ? myHeaderValues[theOrientation][theSection].GetName()
+                                                    : QString::number (theSection + 1);
+  else if (theRole == Qt::ForegroundRole)
+    return QColor (Qt::darkGray);
+
+  return QVariant();
+}
+
+// =======================================================================
+// function : EditType
+// purpose :
+// =======================================================================
+ViewControl_EditType ViewControl_TableModelValues::EditType (const int theRow, const int theColumn) const
+{
+  if (!Properties().IsNull())
+  {
+    return Properties()->EditType (theRow, theColumn);
+  }
+  return ViewControl_EditType_None;
+}
+
+// =======================================================================
+// function : isItalicHeader
+// purpose :
+// =======================================================================
+Qt::ItemFlags ViewControl_TableModelValues::Flags (const QModelIndex& theIndex) const
+{
+  if (!Properties().IsNull())
+  {
+    return Properties()->TableFlags (theIndex.row(), theIndex.column());
+  }
+  return theIndex.isValid() ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags;
+}
+
+// =======================================================================
+// function : isItalicHeader
+// purpose :
+// =======================================================================
+bool ViewControl_TableModelValues::isItalicHeader (const int theRow, const int theColumn) const
+{
+  Qt::Orientation anOrientation = myOrientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical;
+  int aCell = anOrientation == Qt::Horizontal ? theColumn : theRow;
+
+  return HeaderItem (anOrientation, aCell).IsItalic();
+}
diff --git a/tools/ViewControl/ViewControl_TableModelValues.hxx b/tools/ViewControl/ViewControl_TableModelValues.hxx
new file mode 100644 (file)
index 0000000..058d008
--- /dev/null
@@ -0,0 +1,161 @@
+// Created on: 2020-01-25
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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_TableModelValues_H
+#define ViewControl_TableModelValues_H
+
+#include <Standard.hxx>
+
+#include <inspector/TreeModel_HeaderSection.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/ViewControl_EditType.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QAbstractTableModel>
+#include <QColor>
+#include <QList>
+#include <QModelIndexList>
+#include <QVariant>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class ViewControl_TableModelValues
+//! \brief This is an interace for ViewControl_TableModel to give real values of the model
+//! It should be filled or redefined.
+class ViewControl_TableModelValues
+{
+public:
+
+  //! Constructor
+  ViewControl_TableModelValues (const Qt::Orientation& theOrientation = Qt::Vertical) { SetOrientation (theOrientation); }
+
+  //! Destructor
+  virtual ~ViewControl_TableModelValues() {}
+
+  //! Returns item table properties builder
+  Handle(TreeModel_ItemProperties) Properties() const { return myProperties; }
+
+  //! Sets item table properties builder
+  void SetProperties (const Handle(TreeModel_ItemProperties)& theProperties) { myProperties = theProperties; }
+
+  //! Sets direction of the values applying, whether it should be placed by rows or by columns
+  //! \param theOrientation if horizontal, the values are applied by rows, otherwise by columns
+  void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
+
+  //! Fills the model header values for orientation.
+  //! \param theValues a container of header text values
+  //! \param theOrientation an orientation of header
+  void SetHeaderValues (const QList<TreeModel_HeaderSection>& theValues, const Qt::Orientation theOrientation)
+  { myHeaderValues.insert (theOrientation, theValues); }
+
+  //! Returns whether the column is hidden by default
+  //! \param theColumnId a column index
+  //! \return header section values container
+  TreeModel_HeaderSection HeaderItem (const Qt::Orientation theOrientation, const int theColumnId) const
+  { return myHeaderValues.contains(theOrientation) ? myHeaderValues[theOrientation][theColumnId] : TreeModel_HeaderSection(); }
+
+  //! Stores information about table view header visibility
+  //! \param theOrientation an orientation of header
+  //! \param theVisibility if true, header is visible
+  void SetHeaderVisible (const Qt::Orientation theOrientation, const bool theVisibility)
+  { myVisibleHeader.insert (theOrientation, theVisibility); }
+
+  //! Stores information about table view header visibility
+  //! \param theOrientation an orientation of header
+  //! \param theVisibility if true, header is visible
+  bool IsHeaderVisible (const Qt::Orientation theOrientation) const
+  { return myVisibleHeader.contains(theOrientation) ? myVisibleHeader[theOrientation] : true; }
+
+  //! Get default section size if defined
+  //! \param theOrientation an orientation of header
+  //! \param theVisibility if true, header is visible
+  bool DefaultSectionSize (const Qt::Orientation theOrientation, int& theSectionSize)
+  {
+    theSectionSize = myDefaultSectionSize.contains (theOrientation) ? myDefaultSectionSize[theOrientation] : -1;
+    return myDefaultSectionSize.contains (theOrientation);
+  }
+
+  //! Set default section size if defined
+  //! \param theOrientation an orientation of header
+  //! \param theVisibility if true, header is visible
+  void SetDefaultSectionSize (const Qt::Orientation theOrientation, const int& theSectionSize)
+  { myDefaultSectionSize.insert(theOrientation, theSectionSize); }
+
+  //! Returns number of columns, size of header values
+  //! \param theParent an index of the parent item
+  //! \return an integer value
+  Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const;
+
+  //! 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 RowCount (const QModelIndex& theParent = QModelIndex()) const;
+
+  //! 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 Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
+
+  //! Sets content of the model index for the given role, it is applied to internal container of values
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param theRole a view role
+  //! \return true if the value is changed
+  Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
+                                        int theRole = Qt::DisplayRole);
+
+  //! Returns content of the model index for the given role, it is obtainer from internal container of header values
+  //! It returns value only for DisplayRole.
+  //! \param theSection an index of value in the container 
+  //! \param theIndex a model index
+  //! \param theRole a view role
+  //! \return value intepreted depending on the given role
+  Standard_EXPORT virtual QVariant HeaderData (int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const;
+
+  //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
+  //! \param theIndex a model index
+  //! \return flags
+  Standard_EXPORT virtual Qt::ItemFlags Flags (const QModelIndex& theIndex) const;
+
+  //! Returns type of edit control for the model index. By default, it is an empty control
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \return edit type
+  Standard_EXPORT virtual ViewControl_EditType EditType (const int theRow, const int theColumn) const;
+
+  //! Returns default color for editable cell
+  //! \return color value
+  static QColor EditCellColor() { return QColor (Qt::darkBlue); }
+
+protected:
+  //! Returns true if the header item is italic of the parameter index
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \param boolean value
+  bool isItalicHeader (const int theRow, const int theColumn) const;
+
+protected:
+
+  Qt::Orientation myOrientation; //!< orientation how the values should fill the current table view
+  QMap<Qt::Orientation, QList<TreeModel_HeaderSection> > myHeaderValues; //!< table header values
+  QMap<Qt::Orientation, bool> myVisibleHeader; //!< table header visibility
+  QMap<Qt::Orientation, int> myDefaultSectionSize; //!< table section default size
+
+  Handle(TreeModel_ItemProperties) myProperties; //!< item properties
+};
+
+#endif
index 99d3e441ef2942ad52f9855a91b2d2a8a1834c96..1ad884d5d454caf8f71b3ec7ddceb80198d89ce9 100644 (file)
 
 #include <inspector/ViewControl_Tools.hxx>
 
+#include <inspector/ViewControl_TableModel.hxx>
+#include <inspector/TreeModel_ModelBase.hxx>
+
 #include <Standard_WarningsDisable.hxx>
 #include <QAction>
+#include <QHeaderView>
 #include <QObject>
 #include <QPalette>
+#include <QTableView>
 #include <QWidget>
 #include <Standard_WarningsRestore.hxx>
 
@@ -43,3 +48,61 @@ void ViewControl_Tools::SetWhiteBackground (QWidget* theControl)
   aPalette.setColor (QPalette::All, QPalette::Foreground, Qt::white);
   theControl->setPalette (aPalette);
 }
+
+// =======================================================================
+// function : SetDefaultHeaderSections
+// purpose :
+// =======================================================================
+void ViewControl_Tools::SetDefaultHeaderSections(QTableView* theTableView, const Qt::Orientation theOrientation)
+{
+  ViewControl_TableModel * aTableModel = dynamic_cast<ViewControl_TableModel*> (theTableView->model());
+  ViewControl_TableModelValues* aModelValues = aTableModel->ModelValues();
+  if (!aModelValues)
+    return;
+
+  int aSectionSize;
+  if (aModelValues->DefaultSectionSize (Qt::Horizontal, aSectionSize) )
+    theTableView->horizontalHeader()->setDefaultSectionSize (aSectionSize);
+  else {
+    bool isStretchLastSection = true;
+    for (int aColumnId = 0, aNbColumns = aTableModel->columnCount(); aColumnId < aNbColumns; aColumnId++)
+    {
+      TreeModel_HeaderSection aSection = aModelValues->HeaderItem (theOrientation, aColumnId);
+      if (aSection.IsEmpty())
+        continue;
+
+      int aColumnWidth = aSection.GetWidth();
+      if (aColumnWidth > 0)
+      {
+        theTableView->setColumnWidth (aColumnId, aColumnWidth);
+        if (aColumnId == aNbColumns - 1)
+          isStretchLastSection = false;
+      }
+      theTableView->setColumnHidden (aColumnId, aSection.IsHidden());
+    }
+    if (isStretchLastSection != theTableView->horizontalHeader()->stretchLastSection())
+      theTableView->horizontalHeader()->setStretchLastSection (isStretchLastSection);
+  }
+}
+
+// =======================================================================
+// function : CreateTableModelValues
+// purpose :
+// =======================================================================
+ViewControl_TableModelValues* ViewControl_Tools::CreateTableModelValues (QItemSelectionModel* theSelectionModel)
+{
+  ViewControl_TableModelValues* aTableValues = 0;
+
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (theSelectionModel->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+  if (!anItemBase)
+    return aTableValues;
+
+  const Handle(TreeModel_ItemProperties)& anItemProperties = anItemBase->Properties();
+  if (anItemProperties.IsNull())
+    return aTableValues;
+
+  aTableValues = new ViewControl_TableModelValues();
+  aTableValues->SetProperties (anItemProperties);
+  return aTableValues;
+}
index 7dd4bd4b39b2f5c1898f0934a03ea7d020bae74b..39994b6cbeb8f83aa5ee05249ebd330e7ce7344d 100644 (file)
 
 #include <Standard.hxx>
 #include <Standard_Macro.hxx>
+#include <TCollection_AsciiString.hxx>
 
 #include <Standard_WarningsDisable.hxx>
 #include <QString>
 #include <Standard_WarningsRestore.hxx>
 
+class ViewControl_TableModelValues;
+
 class QAction;
+class QItemSelectionModel;
 class QObject;
+class QTableView;
 class QWidget;
 
 //! \class ViewControl_Tools
@@ -32,6 +37,9 @@ class QWidget;
 class ViewControl_Tools
 {
 public:
+  //! Returns text of separation row in table
+  //! \return string value
+  static QString TableSeparator() { return "---------------------------"; }
 
   //! Creates an action with the given text connected to the slot
   //! \param theText an action text value
@@ -46,6 +54,15 @@ public:
   //! \param theControl a widget to be modified
   Standard_EXPORT static void SetWhiteBackground (QWidget* theControl);
 
+  //! Fills tree view by default sections parameters obtained in view's table model
+  //! \param theTableView table view instance
+  //! \param theOrientation header orientation
+  Standard_EXPORT static void SetDefaultHeaderSections (QTableView* theTableView, const Qt::Orientation theOrientation);
+
+  //! Create table of values on the current selection
+  //! It is created if the selection contains only one item and it has a property item
+  Standard_EXPORT static ViewControl_TableModelValues* CreateTableModelValues (QItemSelectionModel* theSelectionModel);
+
 };
 
 #endif
index 20db18fa5a36b2ccd5a24b321994fc6a30e91283..046ea406d10edbf2843117d6ec60c1090df04e4b 100644 (file)
@@ -45,7 +45,7 @@ public:
   virtual QSize sizeHint() const Standard_OVERRIDE { return myDefaultSize.isValid() ? myDefaultSize : QTreeView::sizeHint(); }
 
 private:
-  QSize myDefaultSize; //! default size, empty isze if it should not be used
+  QSize myDefaultSize; //!< default size, empty size if it should not be used
 };
 
 #endif