0027398: Integrate Qt Browser Widget to Open CASCADE Technology IR-2017-07-27 IR-2017-07-28 TEST1
authornds <nds@opencascade.com>
Wed, 26 Jul 2017 13:40:36 +0000 (16:40 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 28 Jul 2017 12:35:16 +0000 (15:35 +0300)
The following implementation has been made:
- CMake procedure is extended to compile Qt tools. This is optional and is handled by USE_QT_TOOLS option(OFF by default)
- It is possible to build Qt tools using Qt5 or Qt4, it is settled with USE_QT4 option.
- Sample of DFBrowser tool is available in samples/tools/TInspectorEXE. It is build with tools, executable is placed in binaries. To start the sample, use dfbrowser.bat command.
- DFBrowser tool may be started from DRAW

445 files changed:
CMakeLists.txt
adm/TOOLS [new file with mode: 0644]
adm/cmake/3rdparty_macro.cmake
adm/cmake/occt_macros.cmake
adm/cmake/occt_toolkit_tool.cmake [new file with mode: 0644]
adm/cmake/qt5.cmake [new file with mode: 0644]
adm/cmake/qt5_macro.cmake [new file with mode: 0644]
adm/cmake/vardescr.cmake
adm/genproj.tcl
adm/templates/custom.build.bat.in
adm/templates/custom.build.sh.in
adm/templates/custom.install.bat.in
adm/templates/custom.install.sh.in
adm/templates/dfbrowser.bat [new file with mode: 0644]
adm/templates/dfbrowser.sh [new file with mode: 0644]
adm/templates/env.bat.in
adm/templates/env.sh.in
samples/tools/TInspectorEXE/CMakeLists.txt [new file with mode: 0644]
samples/tools/TInspectorEXE/EXTERNLIB [new file with mode: 0644]
samples/tools/TInspectorEXE/FILES [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE.cxx [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE.qrc [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx [new file with mode: 0644]
samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx [new file with mode: 0644]
samples/tools/TInspectorEXE/icons/folder_export.png [new file with mode: 0644]
samples/tools/TInspectorEXE/icons/folder_import.png [new file with mode: 0644]
samples/tools/TInspectorEXE/icons/folder_open.png [new file with mode: 0644]
samples/tools/TStandalone/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/adm/cmake/occt.cmake [new file with mode: 0644]
samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake [new file with mode: 0644]
samples/tools/TStandalone/adm/cmake/standalone_macros.cmake [new file with mode: 0644]
samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in [new file with mode: 0644]
samples/tools/TStandalone/adm/templates/header.in [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowser/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/ShapeView/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/ShapeView/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/TInspector/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/TInspector/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/TreeModel/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/TreeModel/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/VInspector/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/VInspector/EXTERNLIB [new file with mode: 0644]
samples/tools/TStandalone/src/View/CMakeLists.txt [new file with mode: 0644]
samples/tools/TStandalone/src/View/EXTERNLIB [new file with mode: 0644]
src/DrawResources/DrawPlugin
tests/tools/begin [new file with mode: 0644]
tests/tools/dfbrowser/A1 [new file with mode: 0644]
tests/tools/dfbrowser/A2 [new file with mode: 0644]
tests/tools/end [new file with mode: 0644]
tests/tools/grids.list [new file with mode: 0644]
tests/tools/parse.rules [new file with mode: 0644]
tools/DFBrowser/DFBrowser.qrc [new file with mode: 0644]
tools/DFBrowser/DFBrowser_AttributePaneStack.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_AttributePaneStack.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_AttributePaneType.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Communicator.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Communicator.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_DumpView.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_DumpView.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_HighlightDelegate.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_HighlightDelegate.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Item.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Item.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemApplication.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemApplication.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemBase.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemBase.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemDocument.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemDocument.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ItemRole.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Module.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Module.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_OpenApplication.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_OpenApplication.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_PropertyPanel.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_PropertyPanel.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchItemInfo.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchLine.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchLine.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchLineModel.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchLineModel.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchView.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_SearchView.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Shortcut.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Shortcut.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Thread.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Thread.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ThreadItem.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ThreadItemSearch.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ThreadItemSearch.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Tools.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Tools.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLine.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLine.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLineModel.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelLineModel.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelView.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelView.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelViewModel.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeLevelViewModel.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeModel.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeModel.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeView.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_TreeView.hxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Window.cxx [new file with mode: 0644]
tools/DFBrowser/DFBrowser_Window.hxx [new file with mode: 0644]
tools/DFBrowser/FILES [new file with mode: 0644]
tools/DFBrowser/icons/item_type_folder.png [new file with mode: 0644]
tools/DFBrowser/icons/item_type_folder_40x40.png [new file with mode: 0644]
tools/DFBrowser/icons/level_change.png [new file with mode: 0644]
tools/DFBrowser/icons/search.png [new file with mode: 0644]
tools/DFBrowser/icons/search_cancel.png [new file with mode: 0644]
tools/DFBrowser/icons/treeline_backward.png [new file with mode: 0644]
tools/DFBrowser/icons/treeline_forward.png [new file with mode: 0644]
tools/DFBrowser/icons/treeline_update.png [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane.qrc [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePane.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePane.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneAPI.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreator.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreator.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneCreatorAPI.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneModel.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneModel.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneSelector.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_AttributePaneSelector.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperExport.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperExport.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperGroupContent.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_HelperGroupContent.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_ItemDelegateButton.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_ItemDelegateButton.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_ItemRole.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_OcctEnumType.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_SelectionKind.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDFReference.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDFReference.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDFTagSource.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDFTagSource.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdAsciiString.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdAsciiString.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdBooleanArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdBooleanArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdBooleanList.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdBooleanList.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdByteArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdByteArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdComment.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdComment.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdCurrent.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdCurrent.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdDirectory.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdDirectory.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExpression.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExpression.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExtStringArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExtStringArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExtStringList.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdExtStringList.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntPackedMap.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntPackedMap.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdInteger.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdInteger.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntegerArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntegerArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntegerList.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdIntegerList.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdName.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdName.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdNamedData.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdNamedData.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdNoteBook.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdNoteBook.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReal.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReal.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRealArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRealArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRealList.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRealList.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReferenceArray.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReferenceArray.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReferenceList.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdReferenceList.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRelation.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdRelation.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTick.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTick.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNode.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeItem.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeItem.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdTreeNodeModel.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdUAttribute.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdUAttribute.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdVariable.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDataStdVariable.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdModified.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdModified.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdOwner.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdOwner.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdXLink.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdXLink.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdXLinkRoot.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TDocStdXLinkRoot.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionFunction.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionFunction.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionGraphNode.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionGraphNode.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionScope.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TFunctionScope.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingNamedShape.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingNamedShape.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingNaming.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingNaming.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingUsedShapes.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TNamingUsedShapes.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISPresentation.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISPresentation.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISViewer.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TPrsStdAISViewer.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TableView.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_TableView.hxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_Tools.cxx [new file with mode: 0644]
tools/DFBrowserPane/DFBrowserPane_Tools.hxx [new file with mode: 0644]
tools/DFBrowserPane/FILES [new file with mode: 0644]
tools/DFBrowserPane/icons/attribute.png [new file with mode: 0644]
tools/DFBrowserPane/icons/attribute_40x40.png [new file with mode: 0644]
tools/DFBrowserPane/icons/export_shape.png [new file with mode: 0644]
tools/DFBrowserPane/icons/folder_export.png [new file with mode: 0644]
tools/DFBrowserPane/icons/imageres_4.ico [new file with mode: 0644]
tools/DFBrowserPane/icons/imageres_5.ico [new file with mode: 0644]
tools/DFBrowserPane/icons/label.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_16x16.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_20x20.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_40x40.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_expand_16x16.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_expand_20x20.png [new file with mode: 0644]
tools/DFBrowserPane/icons/label_folder_expand_40x40.png [new file with mode: 0644]
tools/DFBrowserPane/icons/named_shape.png [new file with mode: 0644]
tools/DFBrowserPane/icons/named_shape_40x40.png [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributeCommonPane.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributeCommonPane.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributePaneCreator.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_AttributePaneCreator.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_Tools.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_Tools.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocArea.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocArea.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocCentroid.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocCentroid.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocColor.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocColor.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocColorTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocColorTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDatum.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDatum.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimTol.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimTol.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimTolTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimTolTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimension.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDimension.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDocumentTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocDocumentTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocGeomTolerance.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocGeomTolerance.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocGraphNode.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocGraphNode.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocLayerTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocLayerTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocLocation.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocLocation.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocMaterial.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocMaterial.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocMaterialTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocMaterialTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocShapeMapTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocShapeTool.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XCAFDocShapeTool.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XDEDRAW.cxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/DFBrowserPaneXDE_XDEDRAW.hxx [new file with mode: 0644]
tools/DFBrowserPaneXDE/FILES [new file with mode: 0644]
tools/ShapeView/FILES [new file with mode: 0644]
tools/ShapeView/ShapeView.qrc [new file with mode: 0644]
tools/ShapeView/ShapeView_Communicator.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_Communicator.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemBase.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemRoot.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemRoot.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemShape.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_ItemShape.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_OpenFileDialog.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_OpenFileDialog.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_OpenFileViewModel.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_OpenFileViewModel.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_Tools.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_Tools.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_TreeModel.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_TreeModel.hxx [new file with mode: 0644]
tools/ShapeView/ShapeView_Window.cxx [new file with mode: 0644]
tools/ShapeView/ShapeView_Window.hxx [new file with mode: 0644]
tools/ShapeView/icons/folder_import.png [new file with mode: 0644]
tools/ShapeView/icons/folder_open.png [new file with mode: 0644]
tools/TInspector/FILES [new file with mode: 0644]
tools/TInspector/TInspector.qrc [new file with mode: 0644]
tools/TInspector/TInspector_Communicator.cxx [new file with mode: 0644]
tools/TInspector/TInspector_Communicator.hxx [new file with mode: 0644]
tools/TInspector/TInspector_Window.cxx [new file with mode: 0644]
tools/TInspector/TInspector_Window.hxx [new file with mode: 0644]
tools/TInspector/icons/item_algo_folder.png [new file with mode: 0644]
tools/TInspectorAPI/FILES [new file with mode: 0644]
tools/TInspectorAPI/TInspectorAPI_Communicator.cxx [new file with mode: 0644]
tools/TInspectorAPI/TInspectorAPI_Communicator.hxx [new file with mode: 0644]
tools/TInspectorAPI/TInspectorAPI_PluginParameters.cxx [new file with mode: 0644]
tools/TInspectorAPI/TInspectorAPI_PluginParameters.hxx [new file with mode: 0644]
tools/TKDFBrowser/CMakeLists.txt [new file with mode: 0644]
tools/TKDFBrowser/EXTERNLIB [new file with mode: 0644]
tools/TKDFBrowser/FILES [new file with mode: 0644]
tools/TKDFBrowser/PACKAGES [new file with mode: 0644]
tools/TKShapeView/CMakeLists.txt [new file with mode: 0644]
tools/TKShapeView/EXTERNLIB [new file with mode: 0644]
tools/TKShapeView/FILES [new file with mode: 0644]
tools/TKShapeView/PACKAGES [new file with mode: 0644]
tools/TKTInspector/CMakeLists.txt [new file with mode: 0644]
tools/TKTInspector/EXTERNLIB [new file with mode: 0644]
tools/TKTInspector/FILES [new file with mode: 0644]
tools/TKTInspector/PACKAGES [new file with mode: 0644]
tools/TKTInspectorAPI/CMakeLists.txt [new file with mode: 0644]
tools/TKTInspectorAPI/EXTERNLIB [new file with mode: 0644]
tools/TKTInspectorAPI/FILES [new file with mode: 0644]
tools/TKTInspectorAPI/PACKAGES [new file with mode: 0644]
tools/TKToolsDraw/CMakeLists.txt [new file with mode: 0644]
tools/TKToolsDraw/EXTERNLIB [new file with mode: 0644]
tools/TKToolsDraw/FILES [new file with mode: 0644]
tools/TKToolsDraw/PACKAGES [new file with mode: 0644]
tools/TKTreeModel/CMakeLists.txt [new file with mode: 0644]
tools/TKTreeModel/EXTERNLIB [new file with mode: 0644]
tools/TKTreeModel/FILES [new file with mode: 0644]
tools/TKTreeModel/PACKAGES [new file with mode: 0644]
tools/TKVInspector/CMakeLists.txt [new file with mode: 0644]
tools/TKVInspector/EXTERNLIB [new file with mode: 0644]
tools/TKVInspector/FILES [new file with mode: 0644]
tools/TKVInspector/PACKAGES [new file with mode: 0644]
tools/TKView/CMakeLists.txt [new file with mode: 0644]
tools/TKView/EXTERNLIB [new file with mode: 0644]
tools/TKView/FILES [new file with mode: 0644]
tools/TKView/PACKAGES [new file with mode: 0644]
tools/ToolsDraw/FILES [new file with mode: 0644]
tools/ToolsDraw/ToolsDraw.cxx [new file with mode: 0644]
tools/ToolsDraw/ToolsDraw.hxx [new file with mode: 0644]
tools/TreeModel/FILES [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemBase.cxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemBase.hxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ItemRole.hxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ModelBase.cxx [new file with mode: 0644]
tools/TreeModel/TreeModel_ModelBase.hxx [new file with mode: 0644]
tools/VInspector/FILES [new file with mode: 0644]
tools/VInspector/VInspectorAPI_CallBack.cxx [new file with mode: 0644]
tools/VInspector/VInspectorAPI_CallBack.hxx [new file with mode: 0644]
tools/VInspector/VInspector_CallBack.cxx [new file with mode: 0644]
tools/VInspector/VInspector_CallBack.hxx [new file with mode: 0644]
tools/VInspector/VInspector_CallBackMode.hxx [new file with mode: 0644]
tools/VInspector/VInspector_Communicator.cxx [new file with mode: 0644]
tools/VInspector/VInspector_Communicator.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemBase.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemBase.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemContext.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemContext.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemEntityOwner.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemEntityOwner.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryElement.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryElement.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryRoot.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryRoot.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryType.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryType.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemHistoryTypeInfo.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemPresentableObject.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemPresentableObject.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemSelection.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemSelection.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemSensitiveEntity.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ItemSensitiveEntity.hxx [new file with mode: 0644]
tools/VInspector/VInspector_SelectionType.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ToolActionType.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ToolBar.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ToolBar.hxx [new file with mode: 0644]
tools/VInspector/VInspector_Tools.cxx [new file with mode: 0644]
tools/VInspector/VInspector_Tools.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ViewModel.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ViewModel.hxx [new file with mode: 0644]
tools/VInspector/VInspector_ViewModelHistory.cxx [new file with mode: 0644]
tools/VInspector/VInspector_ViewModelHistory.hxx [new file with mode: 0644]
tools/VInspector/VInspector_Window.cxx [new file with mode: 0644]
tools/VInspector/VInspector_Window.hxx [new file with mode: 0644]
tools/View/FILES [new file with mode: 0644]
tools/View/View.qrc [new file with mode: 0644]
tools/View/View_ContextType.hxx [new file with mode: 0644]
tools/View/View_Displayer.cxx [new file with mode: 0644]
tools/View/View_Displayer.hxx [new file with mode: 0644]
tools/View/View_PresentationType.hxx [new file with mode: 0644]
tools/View/View_ToolActionType.hxx [new file with mode: 0644]
tools/View/View_ToolBar.cxx [new file with mode: 0644]
tools/View/View_ToolBar.hxx [new file with mode: 0644]
tools/View/View_ViewActionType.hxx [new file with mode: 0644]
tools/View/View_Viewer.cxx [new file with mode: 0644]
tools/View/View_Viewer.hxx [new file with mode: 0644]
tools/View/View_Widget.cxx [new file with mode: 0644]
tools/View/View_Widget.hxx [new file with mode: 0644]
tools/View/View_Window.cxx [new file with mode: 0644]
tools/View/View_Window.hxx [new file with mode: 0644]
tools/View/icons/cursor_rotate.png [new file with mode: 0644]
tools/View/icons/cursor_zoom.png [new file with mode: 0644]
tools/View/icons/keep_view_off.png [new file with mode: 0644]
tools/View/icons/keep_view_off.svg [new file with mode: 0644]
tools/View/icons/keep_view_on.png [new file with mode: 0644]
tools/View/icons/keep_view_on.svg [new file with mode: 0644]
tools/View/icons/view_clear.png [new file with mode: 0644]
tools/View/icons/view_dm_shading.png [new file with mode: 0644]
tools/View/icons/view_dm_wireframe.png [new file with mode: 0644]
tools/View/icons/view_fitall.png [new file with mode: 0644]
tools/View/icons/view_fitarea.png [new file with mode: 0644]
tools/View/icons/view_pan.png [new file with mode: 0644]
tools/View/icons/view_rotate.png [new file with mode: 0644]
tools/View/icons/view_zoom.png [new file with mode: 0644]

index 772803d..e1b3bbe 100644 (file)
@@ -365,6 +365,9 @@ if (WIN32)
   set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
 endif()
 
+set (USE_QT_TOOLS OFF CACHE BOOL "${USE_QT_TOOLS_DESCR}")
+set (USE_QT4 ON CACHE BOOL "${USE_QT4}")
+
 # Enable/Disable the floating point exceptions (FPE) during runtime.
 if (NOT BUILD_ENABLE_FPE_SIGNAL_HANDLER)
   set (BUILD_ENABLE_FPE_SIGNAL_HANDLER OFF CACHE BOOL "${BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR}" FORCE)
@@ -691,7 +694,7 @@ if (3RDPARTY_INCLUDE_DIRS)
 endif()
 
 # include <cmake binary folder>/inc
-include_directories (${CMAKE_BINARY_DIR}/inc)
+include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE})
 
 if (3RDPARTY_LIBRARY_DIRS AND BUILD_SHARED_LIBS)
   list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
@@ -732,7 +735,7 @@ string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
 message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
 
 # collect all the headers to <binary dir>/inc folder
-COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
+COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CMAKE_SOURCE_DIR}/src" "${INSTALL_DIR_INCLUDE}")
 
 string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
 message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
@@ -749,6 +752,33 @@ else()
   set (SCRIPT_EXT sh)
 endif()
 
+# OCCT tools
+# include the patched or original list of tools
+# list <TOOLNAME>_TOOLKITS is created foreach tool and contains its toolkits
+# list <OCCT_TOOLS> will contain all tools
+if (NOT USE_QT_TOOLS)
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT")
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC")
+  OCCT_CHECK_AND_UNSET ("INSTALL_QT")
+else()
+  OCCT_TOOLS_AND_TOOLKITS (OCCT_TOOLS)
+  foreach (OCCT_TOOL ${OCCT_TOOLS})
+    list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS})
+  endforeach()
+
+  # collect all the headers to <binary dir>/inc folder
+  string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+  message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/tools/inc ...")
+  COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "tools")
+  include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/tools)
+
+
+  # check qt 3rdparty path
+  add_definitions (-DHAVE_QT)
+  OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5")
+  message (STATUS "Info: Qt is used by OCCT")
+endif()
+
 # OCCT samples
 # get absolute path from INSTALL_DIR
 set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}")
@@ -891,8 +921,14 @@ if (MSVC AND 3RDPARTY_DLL_DIRS)
   endif()
 endif()
 
-message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
+# include patched toolkit projects or original ones
+if (BUILD_TOOL_TOOLKITS)
+  foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS})
+    OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}")
+  endforeach()
+endif()
 
+message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
 # samples do not support patch usage
 if (BUILD_MODULE_MfcSamples)
   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
@@ -919,6 +955,22 @@ if (BUILD_MODULE_UwpSample)
   add_subdirectory(samples/xaml)
 endif()
 
+if (BUILD_TOOL_TOOLKITS)
+  # copy tinspector script to install script folder
+  if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/dfbrowser.${SCRIPT_EXT}")
+    install (FILES "${BUILD_PATCH}/adm/templates/dfbrowser.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
+            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
+  else()
+    install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/dfbrowser.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR_SCRIPT}"
+            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
+  endif()
+
+  set (BUILD_SAMPLE_TOOLKITS TInspectorEXE)
+  foreach (BUILD_SAMPLE_TOOL_TOOLKIT ${BUILD_SAMPLE_TOOLKITS})
+    OCCT_ADD_SUBDIRECTORY ("samples/tools/${BUILD_SAMPLE_TOOL_TOOLKIT}")
+  endforeach()
+endif()
+
 # Prepare variables for configuration of OpenCASCADE cmake config file
 set (OCCT_MODULES_ENABLED)
 set (OCCT_LIBRARIES)
diff --git a/adm/TOOLS b/adm/TOOLS
new file mode 100644 (file)
index 0000000..aa587f0
--- /dev/null
+++ b/adm/TOOLS
@@ -0,0 +1,4 @@
+TModelingData TKShapeView
+TVisualization TKView TKVInspector
+TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
+TTool TKTInspector TKToolsDraw
\ No newline at end of file
index b4975c9..7ac1d04 100644 (file)
@@ -139,6 +139,17 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
                                                                                 PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
                                                                                 CMAKE_FIND_ROOT_PATH_BOTH
                                                                                 NO_DEFAULT_PATH)
+          if ("${3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX}}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX}-NOTFOUND")
+            # find directory recursive
+            FIND_SUBDIRECTORY (${3RDPARTY_${PRODUCT_NAME}_DIR} "${${PRODUCT_NAME}_PATH_SUFFIXES}" SUBDIR_NAME)
+            if (NOT "${SUBDIR_NAME}" STREQUAL "")
+              find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME_SUFFIX}
+                                                           PATHS "${SUBDIR_NAME}"
+                                                           PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
+                                                           CMAKE_FIND_ROOT_PATH_BOTH
+                                                           NO_DEFAULT_PATH)
+            endif()
+          endif()
         else()
           find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME}
                                                                                 PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
@@ -175,6 +186,16 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
                                                                                PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}"
                                                                                PATH_SUFFIXES bin  win${COMPILER_BITNESS}/${COMPILER}/bin
                                                                                NO_DEFAULT_PATH)
+            if (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX}-NOTFOUND")
+              # find directory recursive
+              FIND_SUBDIRECTORY (${3RDPARTY_${PRODUCT_NAME}_DIR} bin SUBDIR_NAME)
+              if (NOT "${SUBDIR_NAME}" STREQUAL "")
+                find_library (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME_SUFFIX}
+                                                             PATHS "${SUBDIR_NAME}"
+                                                             PATH_SUFFIXES bin
+                                                             NO_DEFAULT_PATH)
+              endif()
+            endif()
           else()
             find_library (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME} PATH_SUFFIXES bin)
           endif()
@@ -206,6 +227,7 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
         string (REPLACE "." "" LIBRARY_NAME_SUFFIX "${LIBRARY_NAME}")
         if (WIN32)
           set (3RDPARTY_${PRODUCT_NAME}_DLL_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME_SUFFIX}};${3RDPARTY_${PRODUCT_NAME}_DLL_DIRS}")
+          set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_${LIBRARY_NAME_SUFFIX}}")
         else()
           set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_${LIBRARY_NAME_SUFFIX}}:${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS}")
         endif()
index 7c73c2c..65ac4d4 100644 (file)
@@ -106,6 +106,34 @@ function (SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
   set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
 endfunction()
 
+function (FIND_SUBDIRECTORY ROOT_DIRECTORY DIRECTORY_SUFFIX SUBDIRECTORY_NAME)
+  #message("Trying to find directory with suffix ${DIRECTORY_SUFFIX} in ${ROOT_DIRECTORY}")
+  SUBDIRECTORY_NAMES ("${ROOT_DIRECTORY}" SUBDIR_NAME_LIST)
+  #message("Subdirectories: ${SUBDIR_NAME_LIST}")
+
+  #set(${SUBDIRECTORY_NAME} "${SUBDIR_NAME_LIST}" PARENT_SCOPE)
+
+  foreach (SUBDIR_NAME ${SUBDIR_NAME_LIST})
+    #message("Subdir: ${SUBDIR_NAME}, ${DIRECTORY_SUFFIX}")
+    # REGEX failed if the directory name contains '++' combination, so we replace it
+    string(REPLACE "++" "\\+\\+" SUBDIR_NAME_ESCAPED ${SUBDIR_NAME})
+    string (REGEX MATCH "${SUBDIR_NAME_ESCAPED}" DOES_PATH_CONTAIN "${DIRECTORY_SUFFIX}")
+    if (DOES_PATH_CONTAIN)
+      set(${SUBDIRECTORY_NAME} "${ROOT_DIRECTORY}/${SUBDIR_NAME}" PARENT_SCOPE)
+      #message("Subdirectory is found: ${SUBDIRECTORY_NAME}")
+      BREAK()
+    else()
+      #message("Check directory: ${ROOT_DIRECTORY}/${SUBDIR_NAME}")
+      FIND_SUBDIRECTORY ("${ROOT_DIRECTORY}/${SUBDIR_NAME}" "${DIRECTORY_SUFFIX}" SUBDIR_REC_NAME)
+      if (NOT "${SUBDIR_REC_NAME}" STREQUAL "")
+        set(${SUBDIRECTORY_NAME} "${SUBDIR_REC_NAME}" PARENT_SCOPE)
+        #message("Subdirectory is found: ${SUBDIRECTORY_NAME}")
+        BREAK()
+      endif()
+    endif()
+  endforeach()
+endfunction()
+
 function (OCCT_ORIGIN_AND_PATCHED_FILES RELATIVE_PATH SEARCH_TEMPLATE RESULT)
 
   if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_PATH}")
@@ -194,7 +222,7 @@ macro (OCCT_CONFIGURE_AND_INSTALL BEING_CONGIRUGED_FILE BUILD_NAME INSTALL_NAME
   install(FILES "${OCCT_BINARY_DIR}/${BUILD_NAME}" DESTINATION  "${DESTINATION_PATH}" RENAME ${INSTALL_NAME})
 endmacro()
 
-macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOOLKITS)
+macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOOLKITS OCCT_COLLECT_SOURCE_DIR OCCT_INSTALL_DIR_PREFIX)
   set (OCCT_USED_PACKAGES)
 
   # consider patched header.in template
@@ -210,8 +238,8 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
     set (OCCT_TOOLKIT_PACKAGES)
     if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_USED_TOOLKIT}/PACKAGES")
       file (STRINGS "${BUILD_PATCH}/src/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
-    elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES")
-      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
+    elseif (EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_USED_TOOLKIT}/PACKAGES")
+      file (STRINGS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
     endif()
 
     list (APPEND OCCT_USED_PACKAGES ${OCCT_TOOLKIT_PACKAGES})
@@ -229,10 +257,10 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
   foreach (OCCT_PACKAGE ${OCCT_USED_PACKAGES})
     if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES")
       file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
-    elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
-      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
+    elseif (EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES")
+      file (STRINGS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
     else()
-      message (WARNING "FILES has not been found in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}")
+      message (WARNING "FILES has not been found in ${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}")
       continue()
     endif()
 
@@ -240,13 +268,13 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
     math (EXPR ALL_FILES_NB "${ALL_FILES_NB} - 1" )
 
     # emit warnings if there is unprocessed headers
-    file (GLOB OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/*.*")
+    file (GLOB OCCT_ALL_FILES_IN_DIR "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/*.*")
     file (GLOB OCCT_ALL_FILES_IN_PATCH_DIR "${BUILD_PATCH}/src/${OCCT_PACKAGE}/*.*")
 
     # use patched header files
     foreach (OCCT_FILE_IN_PATCH_DIR ${OCCT_ALL_FILES_IN_PATCH_DIR})
       get_filename_component (OCCT_FILE_IN_PATCH_DIR_NAME ${OCCT_FILE_IN_PATCH_DIR} NAME)
-      list (REMOVE_ITEM OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${OCCT_FILE_IN_PATCH_DIR_NAME}")
+      list (REMOVE_ITEM OCCT_ALL_FILES_IN_DIR "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/${OCCT_FILE_IN_PATCH_DIR_NAME}")
       list (APPEND OCCT_ALL_FILES_IN_DIR "${OCCT_FILE_IN_PATCH_DIR}")
     endforeach()
 
@@ -287,7 +315,7 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
       endforeach()
 
       if (NOT OCCT_FILE_IN_DIR_STATUS)
-        message (STATUS "Warning. File ${OCCT_FILE_IN_DIR} is not listed in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
+        message (STATUS "Warning. File ${OCCT_FILE_IN_DIR} is not listed in ${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES")
 
         string (REGEX MATCH ".+\\.[hlg]xx|.+\\.h$" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
         if (IS_HEADER_FOUND)
@@ -304,10 +332,10 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
   foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES_COMPLETE})
     get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
     set (OCCT_HEADER_FILE_CONTENT "#include \"${OCCT_HEADER_FILE}\"")
-    configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/inc/${HEADER_FILE_NAME}" @ONLY)
+    configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/${OCCT_INSTALL_DIR_PREFIX}/${HEADER_FILE_NAME}" @ONLY)
   endforeach()
   
-  install (FILES ${OCCT_HEADER_FILES_COMPLETE} DESTINATION "${INSTALL_DIR_INCLUDE}")
+  install (FILES ${OCCT_HEADER_FILES_COMPLETE} DESTINATION "${INSTALL_DIR}/${OCCT_INSTALL_DIR_PREFIX}")
   
   string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
   message (STATUS "Info: \(${CURRENT_TIME}\) Checking headers in inc folder...")
@@ -319,7 +347,7 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
     
     list (FIND OCCT_USED_PACKAGES ${PACKAGE_NAME} IS_HEADER_FOUND)
     if (NOT ${IS_HEADER_FOUND} EQUAL -1)
-      if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/${PACKAGE_NAME}/${HEADER_FILE_NAME}")
+      if (NOT EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${PACKAGE_NAME}/${HEADER_FILE_NAME}")
         message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is not presented in the sources and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
         file (REMOVE "${OCCT_HEADER_FILE_OLD}")
       else()
@@ -490,6 +518,24 @@ function (OCCT_MODULES_AND_TOOLKITS MODULE_LIST)
   set (${MODULE_LIST} ${${MODULE_LIST}} PARENT_SCOPE)
 endfunction()
 
+# Function to get list of tools and toolkits from file adm/TOOLS.
+# Creates list <$TOOL_LIST> to store list of TOOLS and
+# <NAME_OF_TOOL>_TOOLKITS foreach tool to store its toolkits.
+function (OCCT_TOOLS_AND_TOOLKITS TOOL_LIST)
+  FILE_TO_LIST ("adm/TOOLS" FILE_CONTENT)
+
+  foreach (CONTENT_LINE ${FILE_CONTENT})
+    string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE})
+    list (GET CONTENT_LINE 0 TOOL_NAME)
+    list (REMOVE_AT CONTENT_LINE 0)
+    list (APPEND ${TOOL_LIST} ${TOOL_NAME})
+    # (!) REMOVE THE LINE BELOW (implicit variables)
+    set (${TOOL_NAME}_TOOL_TOOLKITS ${CONTENT_LINE} PARENT_SCOPE)
+  endforeach()
+
+  set (${TOOL_LIST} ${${TOOL_LIST}} PARENT_SCOPE)
+endfunction()
+
 # Returns OCC version string from file Standard_Version.hxx (if available)
 function (OCC_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
 
diff --git a/adm/cmake/occt_toolkit_tool.cmake b/adm/cmake/occt_toolkit_tool.cmake
new file mode 100644 (file)
index 0000000..31f686c
--- /dev/null
@@ -0,0 +1,298 @@
+# script for each OCCT tool toolkit
+
+# Qt dependencies
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt5_macro)
+
+FIND_QT5_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+include_directories("${PROJECT_INCLUDES}"
+                    "${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/tools")
+
+FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
+# parce PACKAGES file
+
+if ("${PROJECT_NAME}" STREQUAL TInspectorEXE)
+  set (USED_PACKAGES ${PROJECT_NAME})
+  set (PACKAGE_PREFIX_DIR "samples/tools")
+  include_directories("${PROJECT_INCLUDES}"
+                      "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}")
+else()
+  FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
+  set (PACKAGE_PREFIX_DIR "tools")
+endif()
+
+
+SET (RCC_FILES)
+foreach (OCCT_PACKAGE ${USED_PACKAGES})
+  file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+
+  #message("Sources are ${SOURCE_FILES_C}")
+  FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES_C}")
+
+  #message("Dir is ${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc")
+  FIND_AND_WRAP_RESOURCE_FILE("${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc" RCC_FILES)
+endforeach()
+#message("RCC_FILES for ${PROJECT_NAME} are ${RCC_FILES}")
+
+set (PRECOMPILED_DEFS)
+
+if (NOT BUILD_SHARED_LIBS)
+  list (APPEND PRECOMPILED_DEFS "-DOCCT_NO_PLUGINS")
+endif()
+
+# Get all used packages from toolkit
+foreach (OCCT_PACKAGE ${USED_PACKAGES})
+
+  ADD_DEFINITIONS(-D${OCCT_PACKAGE}_EXPORTS)
+  
+  # TKService contains platform-dependent packages: Xw and WNT
+  if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT"))
+    # do nothing
+  else()
+
+    if (WIN32)
+      list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL")
+    endif()
+
+    set (SOURCE_FILES)
+    set (HEADER_FILES)
+
+    # Generate Flex and Bison files
+    if (${BUILD_YACCLEX})
+
+      # flex files
+      OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
+      list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
+
+      # bison files
+      OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
+      list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
+
+      if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
+      
+        list (SORT SOURCE_FILES_FLEX)
+        list (SORT SOURCE_FILES_BISON)
+
+        math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
+        foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
+
+          list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
+          get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
+
+          list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
+          get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
+          
+          string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
+
+          if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
+            set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
+            set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
+            BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
+            FLEX_TARGET  (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
+            ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
+           
+            list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
+          endif()
+        endforeach()
+      endif()
+    endif()
+
+    # header files
+    if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES")
+      file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_M   REGEX ".+[.]h")
+      file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
+      file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
+
+      file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+      if(APPLE)
+        file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
+      endif()
+    else()
+      file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES"     HEADER_FILES_M   REGEX ".+[.]h")
+      file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES"     HEADER_FILES_LXX REGEX ".+[.]lxx")
+      file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES"     HEADER_FILES_GXX REGEX ".+[.]gxx")
+
+      file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES"     SOURCE_FILES_C REGEX ".+[.]c")
+      if(APPLE)
+        file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES"   SOURCE_FILES_M REGEX ".+[.]mm")
+      endif()
+    endif()
+
+
+    
+    list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
+    list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
+    if(APPLE)
+      list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
+    endif()
+
+    foreach(HEADER_FILE ${HEADER_FILES})
+      if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
+        message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
+        list (APPEND USED_INCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
+        SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
+      else()
+        list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+        SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+      endif()
+    endforeach()
+
+
+    foreach(SOURCE_FILE ${SOURCE_FILES})
+      if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        list (APPEND USED_SRCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
+      else()
+        list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+      endif()
+    endforeach()
+  endif()
+endforeach()
+string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
+
+set (USED_RCFILE "")
+if (MSVC)
+  set (USED_RCFILE "${CMAKE_BINARY_DIR}/resources/${PROJECT_NAME}.rc")
+
+  if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in")
+    configure_file("${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
+  else()
+    configure_file("${CMAKE_SOURCE_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
+  endif()
+endif()
+
+set (CURRENT_MODULE)
+foreach (OCCT_MODULE ${OCCT_TOOLS})
+  list (FIND ${OCCT_MODULE}_TOOL_TOOLKITS ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
+  if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1)
+    set (CURRENT_MODULE ${OCCT_MODULE})
+  endif()
+endforeach()
+
+if (NOT SINGLE_GENERATOR)
+  OCCT_INSERT_CODE_FOR_TARGET ()
+endif()
+
+if ("${PROJECT_NAME}" STREQUAL TInspectorEXE)
+  add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES})
+
+  install (TARGETS ${PROJECT_NAME}
+           DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
+else()
+  add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES})
+
+  if (MSVC)
+    install (FILES  ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind/${PROJECT_NAME}.pdb
+             CONFIGURATIONS Debug
+             DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
+  endif()
+
+  if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
+    set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX})
+    set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+  endif()
+
+  install (TARGETS ${PROJECT_NAME}
+           EXPORT OpenCASCADE${CURRENT_MODULE}Targets
+           RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}"
+           ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}"
+           LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}")
+
+
+  if (NOT WIN32)
+    if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
+      set (LINK_NAME    "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}/tools")
+      set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}/tools")
+      OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME})
+    endif()
+  endif()
+endif()
+
+if (CURRENT_MODULE)
+  set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Tools/${CURRENT_MODULE}")
+  set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}")
+  if (APPLE)
+    if (NOT "${INSTALL_NAME_DIR}" STREQUAL "")
+      set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}")
+    endif()
+  endif()
+endif()
+
+get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR)
+get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR)
+get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE)
+
+if (ANDROID)
+  # do not append version to the filename
+  set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
+else()
+  set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
+                                                    SOVERSION     "${OCC_VERSION_MAJOR}"
+                                                    VERSION       "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
+endif()
+
+set (USED_TOOLKITS_BY_CURRENT_PROJECT)
+set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
+
+# parce EXTERNLIB file
+FILE_TO_LIST ("${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
+foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
+  string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
+  if (NOT COMMENT_FOUND)
+    string (REGEX MATCH "^TK" TK_FOUND ${USED_ITEM})
+    string (REGEX MATCH "^vtk" VTK_FOUND ${USED_ITEM})
+    
+    if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
+      list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
+    else()
+      string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
+      if ("${CSF_FOUND}" STREQUAL "")
+        message (STATUS "Info: ${USED_ITEM} from ${PROJECT_NAME} skipped due to it is empty")
+      else() # get CSF_ value
+        set (CURRENT_CSF ${${USED_ITEM}})
+        if (NOT "x${CURRENT_CSF}" STREQUAL "x")
+          # prepare a list from a string with whitespaces
+          separate_arguments (CURRENT_CSF)
+          list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF})
+        endif()
+      endif()
+    endif()
+  endif()
+endforeach()
+
+if (APPLE)
+  list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND)
+  if (NOT ${IS_X11_FOUND} EQUAL -1)
+    find_package (X11 COMPONENTS X11 Xext Xmu Xi)
+    if (NOT X11_FOUND)
+      message (STATUS "Warning: X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org")
+    endif()
+  endif()
+endif()
+
+# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
+# Add VTK_OPENGL2_BACKEND definition.
+if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
+  add_definitions(-DVTK_OPENGL2_BACKEND)
+  foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
+    list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
+    if (NOT ${IS_VTK_OPENGL_FOUND} EQUAL -1)
+      list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT ${VTK_EXCLUDE_LIBRARY})
+      if (${VTK_EXCLUDE_LIBRARY} STREQUAL vtkRenderingOpenGL)
+        list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingOpenGL2)
+      endif()
+    endif()
+  endforeach()
+endif()
+
+if (BUILD_SHARED_LIBS)
+  target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
+endif()
+
+# Set Qt dependencies
+target_link_libraries(${PROJECT_NAME} "${PROJECT_LIBRARIES}")
+
+target_link_libraries(${PROJECT_NAME} debug "${PROJECT_LIBRARIES_DEBUG}")
+target_link_libraries(${PROJECT_NAME} optimized "${PROJECT_LIBRARIES_RELEASE}")
+
diff --git a/adm/cmake/qt5.cmake b/adm/cmake/qt5.cmake
new file mode 100644 (file)
index 0000000..2776f50
--- /dev/null
@@ -0,0 +1,22 @@
+#qt
+
+#looking for 3RDPARTY_QT_DIR variable used later in qt5_macro.cmake
+if (${USE_QT4})
+  SET(CSF_QtCore "QtCore")
+  THIRDPARTY_PRODUCT("QT" "" "CSF_QtCore" "d")
+else()
+  SET(CSF_Qt5Core "Qt5Core")
+  THIRDPARTY_PRODUCT("QT" "" "CSF_Qt5Core" "d")
+endif()
+
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_INCLUDE_DIR")
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_LIBRARY_DIR")
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_DLL_DIR")
+
+UNSET (${3RDPARTY_QT_DLL} CACHE)
+UNSET (${3RDPARTY_QT_DLL_DIR} CACHE)
+UNSET (${3RDPARTY_QT_INCLUDE_DIR} CACHE)
+UNSET (${3RDPARTY_QT_LIBRARY} CACHE)
+UNSET (${3RDPARTY_QT_LIBRARY_DIR} CACHE)
+
+set (USED_3RDPARTY_QT_DIR "${3RDPARTY_QT_DIR}")
diff --git a/adm/cmake/qt5_macro.cmake b/adm/cmake/qt5_macro.cmake
new file mode 100644 (file)
index 0000000..aa33635
--- /dev/null
@@ -0,0 +1,68 @@
+#qt
+
+macro (FIND_QT5_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+
+  if ("${3RDPARTY_QT_DIR}" STREQUAL "")
+    message (FATAL_ERROR "Empty Qt dir")
+  endif()
+
+  # Now set CMAKE_PREFIX_PATH to point to local Qt installation.
+  # Without this setting find_package() will not work
+  set(CMAKE_PREFIX_PATH ${3RDPARTY_QT_DIR})
+  if (USE_QT4)
+    # Now we can apply standard CMake finder for Qt. We do this mostly
+    # to have qt5_wrap_cpp() function available
+    find_package(Qt4)
+    #message (STATUS "Qt cmake configuration at directory ${Qt4DIR}")
+
+    set(PROJECT_INCLUDES ${QT_INCLUDES})
+    if (WIN32)
+      set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/QtCored4.lib;${3RDPARTY_QT_DIR}/lib/QtGuid4.lib")
+      set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/QtCore4.lib;${3RDPARTY_QT_DIR}/lib/QtGui4.lib")
+    else()
+      set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
+      set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
+    endif(WIN32)
+  else()
+    # Now we can apply standard CMake finder for Qt4. We do this mostly
+    # to have qt5_wrap_cpp() function available
+    find_package(Qt5 REQUIRED COMPONENTS Widgets)
+    #message (STATUS "Qt cmake configuration at directory ${Qt5DIR}")
+
+    set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
+    set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}")
+    set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}")
+  endif()
+endmacro()
+
+
+macro (FIND_AND_WRAP_MOC_FILES SOURCE_FILES)
+  SET(CMAKE_AUTOMOC ON)
+
+  foreach (FILE ${SOURCE_FILES})
+    set (src_files ${src_files} ${FILE})
+    unset (MOC_FILE)
+    if (USE_QT4)
+      qt4_wrap_cpp(MOC_FILE ${FILE})
+    else()
+      qt5_wrap_cpp(MOC_FILE ${FILE})
+    endif()
+    #message (STATUS "... Info: next MOC file ${MOC_FILE}")
+
+  endforeach (FILE)
+
+endmacro()
+
+macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
+  if(EXISTS "${RESOURCE_FILE_NAME}")
+    if (USE_QT4)
+      qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
+      # suppress some GCC warnings coming from source files generated from .qrc resources
+      if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
+      endif()
+    else()
+      qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
+    endif()
+  endif()
+endmacro()
index 9e27add..9c4967e 100644 (file)
@@ -167,6 +167,11 @@ set (USE_GLX_DESCR "Indicates whether X11 OpenGl on OSX is used or not")
 
 set (USE_D3D_DESCR "Indicates whether optional Direct3D wrapper in OCCT visualization module should be build or not")
 
+set (BUILD_QT_TOOLS_DESCR "Indicates whether OCCT tools should be build or not")
+
+set (USE_QT_TOOLS_DESCR "Indicates whether OCCT tools should be used or not
+The tools will be searched in third-party directory or may be set manually")
+
 macro (BUILD_MODULE MODULE_NAME)
   set (ENABLE_MODULE TRUE)
   set (BUILD_MODULE_${MODULE_NAME} ${ENABLE_MODULE} CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}")
index b8e8240..c5ca942 100644 (file)
@@ -1354,6 +1354,7 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
       set aLibsMap(CSF_TclLibs)    ""
       set aFrmsMap(CSF_TclTkLibs)  "Tk"
       set aLibsMap(CSF_TclTkLibs)  ""
+      set aLibsMap(CSF_QT)         "QtCore QtGui"
     } else {
       if { "$theOS" == "qnx" } {
         # CSF_ThreadLibs - pthread API is part of libc on QNX
index 666d594..1d1eac8 100644 (file)
@@ -15,6 +15,9 @@ if /I "%VCVER%" == "@COMPILER@" (
     set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@"
     set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@"
 
+    if not "@3RDPARTY_QT_DIR@" == "" (
+      set "QTDIR=@3RDPARTY_QT_DIR@"
+    )
     set "TCL_VERSION_WITH_DOT=@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     set "TK_VERSION_WITH_DOT=@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
index bb31eda..b3887d0 100644 (file)
@@ -13,6 +13,10 @@ if [ "$1" == "@BIN_LETTER@" ]; then
     export TBB_DIR="@3RDPARTY_TBB_LIBRARY_DIR@"
     export VTK_DIR="@3RDPARTY_VTK_LIBRARY_DIR@"
 
+    if [ "x@3RDPARTY_QT_DIR" != "x" ]; then
+      export QTDIR="@3RDPARTY_QT_DIR@"
+    fi
+
     export TCL_VERSION_WITH_DOT="@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     export TK_VERSION_WITH_DOT="@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
index af2a81e..4699fe7 100644 (file)
@@ -17,6 +17,9 @@ if /I "%VCVER%" == "@COMPILER@" (
     set "TBB_DIR=@USED_3RDPARTY_TBB_DIR@"
     set "VTK_DIR=@USED_3RDPARTY_VTK_DIR@"
 
+    if not "@USED_3RDPARTY_QT_DIR@" == "" (
+      set "QTDIR=@USED_3RDPARTY_QT_DIR@"
+    )
     set "TCL_VERSION_WITH_DOT=@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     set "TK_VERSION_WITH_DOT=@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
index d383dff..d81a1b2 100644 (file)
@@ -13,6 +13,10 @@ if [ "$1" == "@BIN_LETTER@" ]; then
     export TBB_DIR="@USED_3RDPARTY_TBB_DIR@"
     export VTK_DIR="@USED_3RDPARTY_VTK_DIR@"
 
+    if [ "x@USED_3RDPARTY_QT_DIR@" != "x" ]; then
+      export QTDIR="@USED_3RDPARTY_QT_DIR@"
+    fi
+
     export TCL_VERSION_WITH_DOT="@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     export TK_VERSION_WITH_DOT="@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
diff --git a/adm/templates/dfbrowser.bat b/adm/templates/dfbrowser.bat
new file mode 100644 (file)
index 0000000..0d971e5
--- /dev/null
@@ -0,0 +1,7 @@
+@echo off
+
+rem Setup environment and launch TInspector
+call "%~dp0env.bat" %1 %2 %3
+
+TInspectorEXE.exe --dfbrowser
+
diff --git a/adm/templates/dfbrowser.sh b/adm/templates/dfbrowser.sh
new file mode 100644 (file)
index 0000000..2dde874
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+aCurrentPath="$PWD"
+aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
+
+source "${aScriptPath}/env.sh" "$1"
+
+cd ${aCurrentPath}
+TInspectorEXE --dfbrowser
index cbabb7c..aa41626 100644 (file)
@@ -115,6 +115,7 @@ if not ["%GLES2_DIR%"] == [""]         set "PATH=%GLES2_DIR%;%PATH%"
 if not ["%GL2PS_DIR%"] == [""]         set "PATH=%GL2PS_DIR%;%PATH%"
 if not ["%TBB_DIR%"] == [""]           set "PATH=%TBB_DIR%;%PATH%"
 if not ["%VTK_DIR%"] == [""]           set "PATH=%VTK_DIR%;%PATH%"
+if not ["%QTDIR%"] == [""]             set "PATH=%QTDIR%/bin;%PATH%"
 
 rem ----- Set path to 3rd party and OCCT libraries -----
 if not "%CSF_OCCTBinPath%" == "" (
index 613b32c..d38f0f0 100644 (file)
@@ -66,6 +66,10 @@ if [ "$VTK_DIR" != "" ]; then
   THRDPARTY_PATH="${VTK_DIR}:${THRDPARTY_PATH}"
 fi
 
+if [ "$QTDIR" != "" ]; then
+  THRDPARTY_PATH="${QTDIR}/lib:${THRDPARTY_PATH}"
+fi
+
 if [ "$TK_DIR" != "$TCL_DIR" ]; then
   if [ "$TK_DIR" != "" ]; then
     export TK_LIBRARY="${TK_DIR}/../lib/tk${TK_VERSION_WITH_DOT}"
diff --git a/samples/tools/TInspectorEXE/CMakeLists.txt b/samples/tools/TInspectorEXE/CMakeLists.txt
new file mode 100644 (file)
index 0000000..070c323
--- /dev/null
@@ -0,0 +1,5 @@
+project(TInspectorEXE)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+
+set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER Samples)
diff --git a/samples/tools/TInspectorEXE/EXTERNLIB b/samples/tools/TInspectorEXE/EXTERNLIB
new file mode 100644 (file)
index 0000000..8f800f2
--- /dev/null
@@ -0,0 +1 @@
+TKTInspector
\ No newline at end of file
diff --git a/samples/tools/TInspectorEXE/FILES b/samples/tools/TInspectorEXE/FILES
new file mode 100644 (file)
index 0000000..b1a2819
--- /dev/null
@@ -0,0 +1,5 @@
+TInspectorEXE.cxx
+TInspectorEXE_OpenFileDialog.cxx
+TInspectorEXE_OpenFileDialog.hxx
+TInspectorEXE_OpenFileViewModel.cxx
+TInspectorEXE_OpenFileViewModel.hxx
diff --git a/samples/tools/TInspectorEXE/TInspectorEXE.cxx b/samples/tools/TInspectorEXE/TInspectorEXE.cxx
new file mode 100644 (file)
index 0000000..8b85620
--- /dev/null
@@ -0,0 +1,134 @@
+// 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 <OSD_Environment.hxx>
+#include <TInspectorEXE_OpenFileDialog.hxx>
+#include <TInspector_Communicator.hxx>
+
+#include <QAction>
+#include <QApplication>
+#include <QDir>
+#include <QMainWindow>
+#include <QToolBar>
+
+#include <set>
+
+// =======================================================================
+// function : fileNameInDataDir
+// purpose :
+// =======================================================================
+TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir,
+                                              const TCollection_AsciiString& theName)
+{
+  OSD_Environment anEnvironment(theEnvironmentDir);
+  
+  TCollection_AsciiString aFileName = anEnvironment.Value();
+  aFileName += TCollection_AsciiString("/") + theName;
+
+  return aFileName;
+}
+
+// =======================================================================
+// function : setPluginSampleDirectory
+// purpose :
+// =======================================================================
+void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
+                               TInspectorEXE_OpenButton* theButtonControl)
+{
+  if (theName.IsEqual ("TKDFBrowser"))
+  {
+    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step"));
+    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step"));
+  }
+  else if (theName.IsEqual ("TKShapeView"))
+  {
+    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep"));
+    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
+  }
+  else if (theName.IsEqual ("TKVInspector"))
+  {
+    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"));
+    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep"));
+    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
+  }
+}
+
+// =======================================================================
+// function : main
+// purpose :
+// =======================================================================
+int main (int argc, char** argv)
+{
+  OSD_Environment anEnvironment ("QTDIR");
+  TCollection_AsciiString aPlugindsDirName = anEnvironment.Value();
+  if (aPlugindsDirName.IsEmpty())
+  {
+    std::cout << "QTDIR is not defined" << std::endl;
+    return 0;
+  }
+  aPlugindsDirName += "/plugins";
+  QApplication::addLibraryPath (aPlugindsDirName.ToCString());
+  QApplication anApp (argc, argv);
+
+  std::set<TCollection_AsciiString> aPlugins;
+  for (int anArgId = 1; anArgId < argc; anArgId++ )
+  {
+    if (!strcmp (argv[anArgId], "--dfbrowser"))
+      aPlugins.insert ("TKDFBrowser");
+
+    if (!strcmp (argv[anArgId], "--shapeview"))
+      aPlugins.insert ("TKShapeView");
+
+    if (!strcmp (argv[anArgId], "--vinspector"))
+      aPlugins.insert ("TKVInspector");
+  }
+  NCollection_List<Handle(Standard_Transient)> aParameters;
+
+  // Create tool communicator
+  TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator();
+  if (!aCommunicator)
+  {
+    std::cout << "Communicator can not be created" << std::endl;
+    return 0;
+  }
+
+  TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0);
+  TCollection_AsciiString anActivatedPluginName;
+  if (aPlugins.empty())
+  {
+    aPlugins.insert("TKDFBrowser");
+    aPlugins.insert("TKShapeView");
+    aPlugins.insert("TKVInspector");
+
+    anActivatedPluginName = "TKDFBrowser";
+  }
+  else
+    anActivatedPluginName = *aPlugins.rbegin();
+
+  for (std::set<TCollection_AsciiString>::const_iterator aPluginIt = aPlugins.begin(); aPluginIt != aPlugins.end(); aPluginIt++)
+  {
+    TCollection_AsciiString aName = *aPluginIt;
+    aCommunicator->RegisterPlugin (aName);
+    aCommunicator->Init (aName, aParameters);
+    setPluginSampleDirectory (aName, aCommunicator, aButtonControl);
+  }
+  aCommunicator->Activate (anActivatedPluginName);
+
+  aCommunicator->SetVisible (true);
+  aCommunicator->SetOpenButton (aButtonControl->StartButton());
+
+  return anApp.exec();
+}
diff --git a/samples/tools/TInspectorEXE/TInspectorEXE.qrc b/samples/tools/TInspectorEXE/TInspectorEXE.qrc
new file mode 100644 (file)
index 0000000..331296a
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+    <qresource>
+        <file>icons/folder_open.png</file>
+        <file>icons/folder_import.png</file>
+    </qresource>
+</RCC>
diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx b/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx
new file mode 100644 (file)
index 0000000..5aa234b
--- /dev/null
@@ -0,0 +1,311 @@
+// 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 <TInspectorEXE_OpenFileDialog.hxx>
+
+#include <TInspector_Communicator.hxx>
+#include <TInspectorEXE_OpenFileViewModel.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>
+
+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;
+
+TInspector_Communicator* MyCommunicator;
+
+// =======================================================================
+// function : StartButton
+// purpose :
+// =======================================================================
+QPushButton* TInspectorEXE_OpenButton::StartButton()
+{
+  if (!myStartButton)
+  {
+    myStartButton = new QPushButton();
+    myStartButton->setIcon (QIcon (":/icons/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;
+  
+  QString aDataDirName = QDir::currentPath();
+  if (myDefaultDirs.IsBound (aPluginName))
+    aDataDirName = myDefaultDirs.Find (aPluginName).ToCString();
+
+  QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName);
+  aFileName = QDir().toNativeSeparators (aFileName);
+  if (!aFileName.isEmpty()) {
+    QApplication::setOverrideCursor (Qt::WaitCursor);
+    TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
+    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 QString& theDataDirName)
+: QDialog(theParent), myDataDir (theDataDirName)
+{
+  setWindowTitle (theDataDirName);
+
+  QVBoxLayout* aDialogLay = new QVBoxLayout (this);
+  changeMargins (aDialogLay);
+
+  // Title label
+  QLabel* aTitleLabel = new QLabel (this);
+  aTitleLabel->setText (tr ("Open File"));
+  aDialogLay->addWidget (aTitleLabel);
+
+  // Samples View
+  QGroupBox* aSamplesBox = new QGroupBox (this);
+  aSamplesBox->setTitle (tr ("Samples"));
+  aDialogLay->addWidget (aSamplesBox);
+  QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
+  changeMargins (aSampleLay);
+  mySamplesView = createTableView (readSampleNames());
+  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 (":/icons/folder_open.png"));
+  aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
+
+  myFolderApplyOpen = new QToolButton (aSelectFileBox);
+  myFolderApplyOpen->setIcon (QIcon (":/icons/folder_import.png"));
+  myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE));
+  myFolderApplyOpen->setEnabled (false);
+  aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1);
+
+  connect (mySelectedName, SIGNAL (textChanged (const QString&)),
+           this, SLOT (onNameChanged (const QString&)));
+  connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
+  connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked()));
+
+  resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName)
+{
+  QString aFileName;
+  TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName);
+  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 : 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 : onNameChanged
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText)
+{
+  QFileInfo aFileInfo (theText);
+  bool anExists = aFileInfo.exists() && aFileInfo.isFile();
+  myFolderApplyOpen->setEnabled (anExists);
+}
+
+// =======================================================================
+// 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
+
+  mySelectedName->setText (aFileName);
+  onNameChanged (aFileName);
+}
+
+// =======================================================================
+// function : onApplySelectClicked
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
+{
+  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;
+}
+
+// =======================================================================
+// function : readSampleNames
+// purpose :
+// =======================================================================
+QStringList TInspectorEXE_OpenFileDialog::readSampleNames()
+{
+  QStringList aNames;
+
+  QDir aDir(myDataDir);
+  aDir.setSorting(QDir::Name);
+
+  QFileInfoList aDirEntries = aDir.entryInfoList();
+  for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId)
+  {
+    QFileInfo aFileInfo = aDirEntries.at(aDirId);
+    if (aFileInfo.isFile())
+      aNames.append (aFileInfo.absoluteFilePath());
+  }
+  return aNames;
+}
diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx b/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx
new file mode 100644 (file)
index 0000000..2c492d7
--- /dev/null
@@ -0,0 +1,143 @@
+// 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 <NCollection_DataMap.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QDialog>
+#include <QItemSelection>
+#include <QStringList>
+
+#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 SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir)
+  { myDefaultDirs.Bind (thePluginName, theDefaultDir); }
+
+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
+  NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> myDefaultDirs; //!< plugins default directories
+};
+
+//! \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
+  TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName);
+
+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
+  static QString OpenFile (QWidget* theParent, const QString& theDataDirName);
+
+  //! Returns selection name from the dialog
+  QString GetFileName() const { return myFileName; }
+
+  //! Returns communicator, if this is the first call, create a communicator instance
+  static TInspector_Communicator* Communicator();
+
+private slots:
+
+  //! Stores name of selected sample file
+  void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+  //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists
+  //! \param theText a file name text in line edit
+  void onNameChanged (const QString& theText);
+
+  //! 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);
+
+  //! Generates container of file names in samples directory
+  //! \return container of names
+  QStringList readSampleNames();
+
+private:
+
+  QString myDataDir; //!< samples directory
+  QString myFileName; //!< result file name
+  QTableView* mySamplesView; //! <view of sample file names
+  QLineEdit* mySelectedName; //!< alternative control to open file
+  QToolButton* myFolderApplyOpen; //! button to open file
+};
+
+#endif
diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx b/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx
new file mode 100644 (file)
index 0000000..104c492
--- /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 <TInspectorEXE_OpenFileViewModel.hxx>
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QIcon>
+#include <QPainter>
+
+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 (":/icons/folder_import.png");
+  QSize anIconSize (ICON_SIZE, ICON_SIZE);
+  int aWidth = theOption.rect.width();
+  int aCenter = aWidth / 2.;
+  int aHalf = anIconSize.width() / 2.;
+  int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
+  thePainter->drawPixmap (QRect (theOption.rect.left() + (aCenter - aHalf),
+                          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/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx b/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx
new file mode 100644 (file)
index 0000000..f71019e
--- /dev/null
@@ -0,0 +1,99 @@
+// 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>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QItemDelegate>
+
+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/samples/tools/TInspectorEXE/icons/folder_export.png b/samples/tools/TInspectorEXE/icons/folder_export.png
new file mode 100644 (file)
index 0000000..5f45f99
Binary files /dev/null and b/samples/tools/TInspectorEXE/icons/folder_export.png differ
diff --git a/samples/tools/TInspectorEXE/icons/folder_import.png b/samples/tools/TInspectorEXE/icons/folder_import.png
new file mode 100644 (file)
index 0000000..02743ab
Binary files /dev/null and b/samples/tools/TInspectorEXE/icons/folder_import.png differ
diff --git a/samples/tools/TInspectorEXE/icons/folder_open.png b/samples/tools/TInspectorEXE/icons/folder_open.png
new file mode 100644 (file)
index 0000000..b0a139e
Binary files /dev/null and b/samples/tools/TInspectorEXE/icons/folder_open.png differ
diff --git a/samples/tools/TStandalone/CMakeLists.txt b/samples/tools/TStandalone/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4708389
--- /dev/null
@@ -0,0 +1,127 @@
+cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
+project (TStandalone)
+
+set (CASROOT "" CACHE PATH "Third party OpenCascade dir" )
+set (3RDPARTY_DIR "" CACHE PATH "Third party dir" )
+set (INSTALL_DIR "" CACHE PATH "Where to install" )
+
+set (USE_QT4 ON CACHE BOOL "${USE_QT4}")
+
+if (NOT "$ENV{CASROOT}" STREQUAL "" AND EXISTS "$ENV{CASROOT}")
+  set (CASROOT "$ENV{CASROOT}")
+  #set (3RDPARTY_OCCT_DIR "${CASROOT}")
+  #message("Environment CASROOT: ${CASROOT}")
+  #message("Environment 3RDPARTY_OCCT_DIR: ${CASROOT}")
+endif()
+
+if (NOT "$ENV{THIRDPARTY_DIR}" STREQUAL ""  AND EXISTS "$ENV{THIRDPARTY_DIR}")
+  set (3RDPARTY_DIR "$ENV{THIRDPARTY_DIR}")
+  message("Environment THIRDPARTY_DIR: ${3RDPARTY_DIR}")
+endif()
+
+if (NOT "$ENV{INSTALL_DIR}" STREQUAL "")
+  set (INSTALL_DIR "$ENV{INSTALL_DIR}")
+  message("Environment INSTALL_DIR: ${INSTALL_DIR}")
+endif()
+
+# Define the next variable to has defined 3rdParties DLL dir variables
+set (BUILD_SHARED_LIBS ON)
+
+set (CASROOT_SOURCE_FILES "${CMAKE_SOURCE_DIR}/../../.."  CACHE PATH "OCCT sources dir to find tools packages" )
+if ("${CASROOT}" STREQUAL "")
+  set (CASROOT "${CASROOT_SOURCE_FILES}/work/install"  CACHE PATH "OCCT sources dir to find tools packages" )
+endif()
+
+macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
+  include (${CASROOT_SOURCE_FILES}/${BEING_INCLUDED_FILE}.cmake)
+endmacro()
+
+macro (OCCT_INCLUDE_CMAKE_FILE_STANDALONE BEING_INCLUDED_FILE)
+  include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
+endmacro()
+
+set (ADDITIONAL_DLL_DIR "" CACHE PATH "Additional paths that should be included into PATH" )
+if (NOT "$ENV{ADDITIONAL_DLL_DIR}" STREQUAL "")
+  set (ADDITIONAL_DLL_DIR "$ENV{ADDITIONAL_DLL_DIR}")
+  message("Environment ADDITIONAL_DLL_DIR: ${ADDITIONAL_DLL_DIR}")
+endif()
+
+set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
+
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE("adm/cmake/occt")
+if (OCCT_LIBRARY_NOT_FOUND)
+  message (FATAL_ERROR "Could NOT find OCCT Library in : ${3RDPARTY_OCCT_LIBRARY_DIR}" )
+endif()
+
+OCCT_MAKE_OS_WITH_BITNESS()
+OCCT_MAKE_COMPILER_SHORT_NAME()
+
+set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
+set (INSTALL_API_DIR "${INSTALL_DIR}/api" CACHE PATH "" FORCE)
+set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "" FORCE)
+set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "" FORCE)
+set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "")
+
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+
+#include (${CMAKE_SOURCE_DIR}/adm/cmake/3rdparty.cmake)
+
+set (3RDPARTY_DLL_PATH "${USED_3RDPARTY_OCCT_DIRS};\
+${USED_3RDPARTY_FREETYPE_DIR};\
+${USED_3RDPARTY_FREEIMAGE_DIRS};\
+${USED_3RDPARTY_GL2PS_DIRS};\
+${3RDPARTY_QT_DIR}/bin;\
+${3RDPARTY_TBB_DLL_DIR}")
+
+if (ADDITIONAL_DLL_DIR)
+  set (3RDPARTY_DLL_PATH "${3RDPARTY_DLL_PATH};\
+${ADDITIONAL_DLL_DIR}")
+endif()
+
+set (3RDPARTY_DLL_DEB_PATH "${3RDPARTY_DLL_PATH}")
+
+
+set (BUILD_TOOLKITS
+  TKTInspectorAPI
+  TKView
+  TKTreeModel
+  TKDFBrowser
+  TKVInspector
+  TKShapeView
+  TKTInspector
+  TKToolsDraw
+)
+
+string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all header files into ${CMAKE_BINARY_DIR}/inc ...")
+# collect all the headers to <binary dir>/inc folder
+COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CASROOT_SOURCE_FILES}/tools" "${INSTALL_DIR_INCLUDE}")
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/standalone_macros")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5_macro")
+
+set (BUILD_PROJECTS
+  TInspectorAPI
+  View
+  TreeModel
+  DFBrowserPane
+  DFBrowserPaneXDE
+  DFBrowser
+  ShapeView
+  VInspector
+  TInspector
+  TInspectorEXE
+  ToolsDraw
+)
+# include patched toolkit projects or original ones
+foreach (PROJECT_ITEM ${BUILD_PROJECTS})
+  OCCT_ADD_SUBDIRECTORY ("src/${PROJECT_ITEM}")
+endforeach()
diff --git a/samples/tools/TStandalone/adm/cmake/occt.cmake b/samples/tools/TStandalone/adm/cmake/occt.cmake
new file mode 100644 (file)
index 0000000..6bcf11b
--- /dev/null
@@ -0,0 +1,75 @@
+#freeimage
+
+if(NOT "${CASROOT}" STREQUAL "")
+  #message(FATAL_ERROR, "Empty OCCT dir")
+  #return()
+  #set("3RDPARTY_OCCT_DIR ${CASROOT}")
+endif()
+
+#set(3RDPARTY_OCC_DIR ${CASROOT})
+#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}")
+#set("3RDPARTY_OCC_DIR ${3RDPARTY_OCCT_DIR}")
+#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}")
+
+set(CSF_TKernel "TKernel")
+THIRDPARTY_PRODUCT("OCCT" "Standard.hxx" "CSF_TKernel" "")
+
+set(3RDPARTY_OCCT_DIR ${3RDPARTY_OCC_DIR} CACHE PATH "OCCT dir")
+
+OCCT_MAKE_OS_WITH_BITNESS()
+OCCT_MAKE_COMPILER_SHORT_NAME()
+
+SET(3RDPARTY_OCCT_INCLUDE_DIR "${3RDPARTY_OCC_INCLUDE_DIR}" CACHE PATH "OCCT include dir")
+SET(3RDPARTY_OCCT_LIBRARY_DIR "${3RDPARTY_OCC_LIBRARY_DIR}" CACHE PATH "OCCT library dir")
+SET(3RDPARTY_OCCT_DLL_DIR "${3RDPARTY_OCC_DLL_DIR}" CACHE PATH "OCCT dll dir")
+
+SET(CSF_StandardDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Standard Resource")
+SET(CSF_XCAFDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT XCAF Defaults")
+SET(CSF_PluginDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Plugin Defaults")
+
+message (STATUS "... OCCT dir: ${3RDPARTY_OCCT_DIR}")
+message (STATUS "... OCCT Include dirs: ${3RDPARTY_OCCT_INCLUDE_DIR}")
+message (STATUS "... OCCT Library dirs: ${3RDPARTY_OCCT_LIBRARY_DIRS}")
+message (STATUS "... OCCT Binary  dirs: ${3RDPARTY_OCCT_DLL_DIRS}")
+
+SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${3RDPARTY_OCCT_LIBRARY_DIRS}")
+
+find_library(TKernel TKernel PATHS "${3RDPARTY_OCCT_LIBRARY_DIRS}"
+                             PATH_SUFFIXES lib
+                             NO_DEFAULT_PATH)
+
+if ("${TKernel}" STREQUAL "TKernel-NOTFOUND")
+  set (OCCT_LIBRARY_NOT_FOUND ON)
+endif()
+
+find_library(TKMath TKMath)
+
+find_library(TKCAF TKCAF)
+find_library(TKCDF TKCDF)
+find_library(TKLCAF TKLCAF)
+find_library(TKVCAF TKVCAF)
+
+find_library(TKBRep TKBRep)
+find_library(TKService TKService)
+
+find_library(TKOpenGl TKOpenGl)
+find_library(TKV3d TKV3d)
+
+find_library(TKXCAF TKXCAF)
+find_library(TKXSBase TKXSBase)
+find_library(TKXDESTEP TKXDESTEP)
+find_library(TKXmlXCAF TKXmlXCAF)
+find_library(TKXml TKXml)
+
+find_library(TKBin TKBin)
+find_library(TKBinL TKBinL)
+find_library(TKBinXCAF TKBinXCAF)
+
+find_library(TKStd TKStd)
+find_library(TKXmlL TKXmlL)
+find_library(TKStdL TKStdL)
+# VInspector additionally:
+find_library(TKBO TKBO)
+# ShapeView additionally:
+find_library(TKGeomBase TKGeomBase)
+find_library(TKG3d TKG3d)
diff --git a/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake b/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake
new file mode 100644 (file)
index 0000000..a8245ae
--- /dev/null
@@ -0,0 +1,115 @@
+# script for each OCCT toolkit
+
+#Qt dependencies
+#message ("Project is ${PROJECT_NAME}")
+if (EXECUTABLE_PROJECT)
+  set (PACKAGE_PREFIX_DIR "samples/tools")
+  SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME})
+  include_directories("${SOURCE_DIR}")
+  #message("Inc dir: ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME}")
+else()
+  set (PACKAGE_PREFIX_DIR "tools")
+  SET(SOURCE_DIR ${CASROOT_SOURCE_FILES}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME})
+endif()
+
+FIND_SOURCES_AND_HEADERS_FILES(${SOURCE_DIR} SOURCE_FILES HEADER_FILES)
+
+#message ("Source dir is ${SOURCE_DIR}")
+#message ("Sources are ${SOURCE_FILES}")
+
+unset(RCC_FILES)
+if (USE_QT)
+  FIND_QT5_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+
+  FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES}")
+  FIND_AND_WRAP_RESOURCE_FILE("${SOURCE_DIR}/${PROJECT_NAME}.qrc" RCC_FILES)
+
+endif()
+
+if (TOOLKIT_NAME)
+  set(TARGET_NAME TK${PROJECT_NAME})
+else ()
+  set(TARGET_NAME ${PROJECT_NAME})
+endif()
+
+if (EXECUTABLE_PROJECT)
+  add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
+else()
+  add_library(${TARGET_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES})
+endif()
+
+
+include_directories(
+  ${PROJECT_INCLUDES}
+  ${SOURCE_DIR}
+  ${3RDPARTY_OCCT_INCLUDE_DIR}
+ "${CMAKE_BINARY_DIR}/inc")
+
+add_definitions(-D__WIN32__)
+add_definitions(-DWNT)
+add_definitions(-D${PROJECT_NAME}_EXPORTS)
+
+# parce EXTERNLIB file
+FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
+foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
+  string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
+  if (NOT COMMENT_FOUND)
+    set (LIB_ITEM ${USED_ITEM})
+    set (LIB_PARSED_ITEM ${${USED_ITEM}})
+
+    if (LIB_PARSED_ITEM)
+      list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${${USED_ITEM}})
+      #message("Append external lib: ${${USED_ITEM}}")
+    else ()
+      list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
+      #message("Append lib: ${USED_ITEM}")
+    endif()
+
+  endif()
+endforeach()
+
+
+target_link_libraries (${TARGET_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT})
+
+if (USE_QT)
+  target_link_libraries (${TARGET_NAME} debug ${PROJECT_LIBRARIES_DEBUG})
+  target_link_libraries (${TARGET_NAME} optimized ${PROJECT_LIBRARIES_RELEASE})
+
+  if (NOT "${RCC_FILES}" STREQUAL "")
+    #message("RCC files: ${RCC_FILES}")
+    target_sources(${TARGET_NAME} PRIVATE ${RCC_FILES})
+  endif()
+endif()
+
+if (EXECUTABLE_PROJECT)
+  INSTALL(TARGETS ${TARGET_NAME} DESTINATION "${INSTALL_DIR_BIN}")
+else()
+  if (MSVC)
+    install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
+             DESTINATION "${INSTALL_DIR_BIN}"
+             FILES_MATCHING PATTERN *.pdb)
+    if (INSTALL_API_DIR)
+      install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
+               DESTINATION "${INSTALL_API_DIR}/bin"
+               FILES_MATCHING PATTERN *.pdb)
+    endif()
+  endif()
+  install (TARGETS ${TARGET_NAME}
+           RUNTIME DESTINATION "${INSTALL_DIR_BIN}"
+           ARCHIVE DESTINATION "${INSTALL_DIR_LIB}"
+           LIBRARY DESTINATION "${INSTALL_DIR_LIB}")
+
+  if (INSTALL_API_DIR)
+    install (TARGETS ${TARGET_NAME}
+             RUNTIME DESTINATION "${INSTALL_API_DIR}/bin")
+
+    if (INSTALL_API)
+      INSTALL(FILES ${HEADER_FILES} DESTINATION "${INSTALL_API_DIR}/${INSTALL_DIR_INCLUDE}")
+    
+      install (DIRECTORY  ${PROJECT_BINARY_DIR}/Debug/
+               DESTINATION "${INSTALL_API_DIR}/lib"
+               FILES_MATCHING PATTERN *.lib)
+    endif()
+  endif()
+
+endif()
diff --git a/samples/tools/TStandalone/adm/cmake/standalone_macros.cmake b/samples/tools/TStandalone/adm/cmake/standalone_macros.cmake
new file mode 100644 (file)
index 0000000..531a0e3
--- /dev/null
@@ -0,0 +1,33 @@
+#freeimage
+
+macro (FIND_SOURCES_AND_HEADERS_FILES CURRENT_SOURCES_DIR SOURCE_FILES HEADER_FILES)
+  if (EXISTS "${CURRENT_SOURCES_DIR}/FILES")
+    file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" HEADER_FILES_H REGEX ".+[.]h")
+    file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+
+    if (NOT "${HEADER_FILES_H}" STREQUAL "")
+      foreach (ORIGIN_FILE ${HEADER_FILES_H})
+        list (APPEND HEADER_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE})
+      endforeach()
+
+      #message("${HEADER_FILES_}")
+      set(${HEADER_FILES} ${HEADER_FILES_})
+    endif()
+
+    if(NOT "${SOURCE_FILES_C}" STREQUAL "")
+      foreach (ORIGIN_FILE ${SOURCE_FILES_C})
+        list (APPEND SOURCE_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE})
+      endforeach()
+
+      #message("${SOURCE_FILES_}")
+      set(${SOURCE_FILES} ${SOURCE_FILES_})
+    endif()
+
+    #set(${HEADER_FILES} ${HEADER_FILES_H})
+    #set(${SOURCE_FILES} ${SOURCE_FILES_C})
+
+  else()
+    message(WARNING "file FILES is absent in $TARGET")
+  endif()
+
+endmacro()
diff --git a/samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in b/samples/tools/TStandalone/adm/templates/TInspectorEXE.vcxproj.user.in
new file mode 100644 (file)
index 0000000..b79bb66
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+    </LocalDebuggerEnvironment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+    </LocalDebuggerEnvironment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+CSF_ShadersDirectory=@CASROOT@/src/Shaders
+    </LocalDebuggerEnvironment>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="Configuration">
+  </PropertyGroup>
+</Project>
diff --git a/samples/tools/TStandalone/adm/templates/header.in b/samples/tools/TStandalone/adm/templates/header.in
new file mode 100644 (file)
index 0000000..80c75f9
--- /dev/null
@@ -0,0 +1 @@
+@OCCT_HEADER_FILE_CONTENT@
diff --git a/samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowser/CMakeLists.txt
new file mode 100644 (file)
index 0000000..629286c
--- /dev/null
@@ -0,0 +1,11 @@
+project(DFBrowser)
+
+ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
diff --git a/samples/tools/TStandalone/src/DFBrowser/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowser/EXTERNLIB
new file mode 100644 (file)
index 0000000..0a28f95
--- /dev/null
@@ -0,0 +1,29 @@
+DFBrowserPane
+DFBrowserPaneXDE
+TKBRep
+TKMath
+TKV3d
+TKBRep
+TKBin
+TKBinL
+TKBinXCAF
+TKCAF
+TKCDF
+TKernel
+TKLCAF
+TKMath
+TKOpenGl
+TKService
+TKStd
+TKStdL
+TKTInspector
+TKTInspectorAPI
+TKTreeModel
+TKV3d
+TKView
+TKXSBase
+TKXCAF
+TKXDESTEP
+TKXmlXCAF
+TKXml
+TKXmlL
diff --git a/samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowserPane/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e1b116a
--- /dev/null
@@ -0,0 +1,5 @@
+project(DFBrowserPane)
+
+set (USE_QT ON)
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+unset (USE_QT)
diff --git a/samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowserPane/EXTERNLIB
new file mode 100644 (file)
index 0000000..87ffbcc
--- /dev/null
@@ -0,0 +1,12 @@
+TKG3d
+TKTInspectorAPI
+TKTreeModel
+TKernel
+TKMath
+TKService
+TKV3d
+TKVCAF
+TKCDF
+TKCAF
+TKLCAF
+TKBRep
diff --git a/samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt b/samples/tools/TStandalone/src/DFBrowserPaneXDE/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3d26d54
--- /dev/null
@@ -0,0 +1,5 @@
+project(DFBrowserPaneXDE)
+
+set (USE_QT ON)
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+unset (USE_QT)
diff --git a/samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB b/samples/tools/TStandalone/src/DFBrowserPaneXDE/EXTERNLIB
new file mode 100644 (file)
index 0000000..768a730
--- /dev/null
@@ -0,0 +1,7 @@
+DFBrowserPane
+TKernel
+TKTInspectorAPI
+TKXSBase
+TKXDESTEP
+TKBRep
+TKXCAF
diff --git a/samples/tools/TStandalone/src/ShapeView/CMakeLists.txt b/samples/tools/TStandalone/src/ShapeView/CMakeLists.txt
new file mode 100644 (file)
index 0000000..110bcfe
--- /dev/null
@@ -0,0 +1,11 @@
+project(ShapeView)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
+
+
diff --git a/samples/tools/TStandalone/src/ShapeView/EXTERNLIB b/samples/tools/TStandalone/src/ShapeView/EXTERNLIB
new file mode 100644 (file)
index 0000000..ea9431e
--- /dev/null
@@ -0,0 +1,8 @@
+TKBRep
+TKGeomBase
+TKG3d
+TKMath
+TKTInspectorAPI
+TKTreeModel
+TKService
+TKView
diff --git a/samples/tools/TStandalone/src/TInspector/CMakeLists.txt b/samples/tools/TStandalone/src/TInspector/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4161561
--- /dev/null
@@ -0,0 +1,11 @@
+project(TInspector)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+set (INSTALL_API ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
+unset (INSTALL_API)
diff --git a/samples/tools/TStandalone/src/TInspector/EXTERNLIB b/samples/tools/TStandalone/src/TInspector/EXTERNLIB
new file mode 100644 (file)
index 0000000..5df40d3
--- /dev/null
@@ -0,0 +1,2 @@
+TKernel
+TKTInspectorAPI
diff --git a/samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt b/samples/tools/TStandalone/src/TInspectorAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1f2f7aa
--- /dev/null
@@ -0,0 +1,10 @@
+project(TInspectorAPI)
+
+set (TOOLKIT_NAME ON)
+set (INSTALL_API ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (TOOLKIT_NAME)
+unset (INSTALL_API)
+
diff --git a/samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB b/samples/tools/TStandalone/src/TInspectorAPI/EXTERNLIB
new file mode 100644 (file)
index 0000000..b15d5ec
--- /dev/null
@@ -0,0 +1,2 @@
+TKernel
+TKLCAF
diff --git a/samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt b/samples/tools/TStandalone/src/TInspectorEXE/CMakeLists.txt
new file mode 100644 (file)
index 0000000..eaa3ac2
--- /dev/null
@@ -0,0 +1,13 @@
+project(TInspectorEXE)
+
+set (USE_QT ON)
+set (EXECUTABLE_PROJECT ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (EXECUTABLE_PROJECT)
+
+configure_file(${CMAKE_SOURCE_DIR}/adm/templates/${PROJECT_NAME}.vcxproj.user.in 
+               ${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}.vcxproj.user @ONLY)
+
diff --git a/samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB b/samples/tools/TStandalone/src/TInspectorEXE/EXTERNLIB
new file mode 100644 (file)
index 0000000..dcd41c9
--- /dev/null
@@ -0,0 +1,8 @@
+TKBRep
+TKG3d
+TKService
+TKTInspector
+TKXCAF
+TKXDESTEP
+TKXSBase
+TKView
diff --git a/samples/tools/TStandalone/src/TreeModel/CMakeLists.txt b/samples/tools/TStandalone/src/TreeModel/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a3c9117
--- /dev/null
@@ -0,0 +1,10 @@
+project(TreeModel)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+
+
diff --git a/samples/tools/TStandalone/src/TreeModel/EXTERNLIB b/samples/tools/TStandalone/src/TreeModel/EXTERNLIB
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/samples/tools/TStandalone/src/VInspector/CMakeLists.txt b/samples/tools/TStandalone/src/VInspector/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c9b7c9c
--- /dev/null
@@ -0,0 +1,9 @@
+project(VInspector)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
diff --git a/samples/tools/TStandalone/src/VInspector/EXTERNLIB b/samples/tools/TStandalone/src/VInspector/EXTERNLIB
new file mode 100644 (file)
index 0000000..db9a903
--- /dev/null
@@ -0,0 +1,10 @@
+TKBO
+TKBRep
+TKG3d
+TKernel
+TKMath
+TKTInspectorAPI
+TKTreeModel
+TKService
+TKV3d
+TKView
diff --git a/samples/tools/TStandalone/src/View/CMakeLists.txt b/samples/tools/TStandalone/src/View/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ec98bc1
--- /dev/null
@@ -0,0 +1,9 @@
+project(View)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+
diff --git a/samples/tools/TStandalone/src/View/EXTERNLIB b/samples/tools/TStandalone/src/View/EXTERNLIB
new file mode 100644 (file)
index 0000000..2075d7c
--- /dev/null
@@ -0,0 +1,5 @@
+TKernel
+TKMath
+TKService
+TKOpenGl
+TKV3d
index d5034c3..722f756 100755 (executable)
@@ -48,3 +48,4 @@ TOBJ               : TKTObjDRAW
 DFBROWSER          : TKDFBrowser
 QAcommands         : TKQADraw
 VIS                : TKIVtkDraw
+TOOLS              : TKToolsDraw
diff --git a/tests/tools/begin b/tests/tools/begin
new file mode 100644 (file)
index 0000000..562c910
--- /dev/null
@@ -0,0 +1,3 @@
+if { [array get Draw_Groups "TOOLS Check commands"] == "" } {
+  pload TOOLS
+}
diff --git a/tests/tools/dfbrowser/A1 b/tests/tools/dfbrowser/A1
new file mode 100644 (file)
index 0000000..05ceb6c
--- /dev/null
@@ -0,0 +1,12 @@
+pload DCAF
+pload TOOLS
+
+NewDocument Doc BinOcaf
+
+set aSetAttr1 100
+set aLabel 0:2
+SetInteger Doc ${aLabel} ${aSetAttr1}
+
+tinspector -dfbrowser
+tinspector -update
+
diff --git a/tests/tools/dfbrowser/A2 b/tests/tools/dfbrowser/A2
new file mode 100644 (file)
index 0000000..ba9d9af
--- /dev/null
@@ -0,0 +1,53 @@
+pload DCAF
+pload VISUALIZATION
+pload TOOLS
+
+chrono qat start
+# Create a new document and set UndoLimit
+NewDocument D BinOcaf
+tinspector -dfbrowser
+
+#NewDocument D
+cpulimit 300
+UndoLimit D 100
+
+# Open a transaction
+NewCommand D
+
+#1 - create box using more flexible set of commands
+NewCommand D
+# add object
+set B2 [AddObject D]
+# add function
+set F2 [AddFunction D $B2 Box]
+# set argumets of this function
+BoxDX D $B2 190
+BoxDY D $B2 290
+BoxDZ D $B2 390
+# initialize (clean) internal maps of labels
+InitLogBook D
+AddDriver D Box Attach Cyl
+# compute the function
+ComputeFun D $F2
+
+# check result
+set IsDone [catch {GetShape D $F2:2 Box2} aResult]
+if { ${IsDone} != 0 } {
+    puts "Error: Get a value of TNaming_NamedShape attribute from restoring document"
+} else {
+    puts "OK: Value of TNaming_NamedShape attribute from restoring document was got"
+}
+if { [regexp "SOLID FORWARD" [whatis Box2] ] != 1 } {
+    puts "Error: Box2 is not a solid forward"
+} else {
+    puts "OK: Box2 is  a solid forward"
+}
+
+# referes to result NS
+GetReference D $B2;                    
+
+tinspector -update
+vinit
+vdisplay Box2
+vfit
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png
\ No newline at end of file
diff --git a/tests/tools/end b/tests/tools/end
new file mode 100644 (file)
index 0000000..57901e2
--- /dev/null
@@ -0,0 +1,2 @@
+# to end a test script
+puts "TEST COMPLETED"
diff --git a/tests/tools/grids.list b/tests/tools/grids.list
new file mode 100644 (file)
index 0000000..80a8f96
--- /dev/null
@@ -0,0 +1 @@
+001 dfbrowser
diff --git a/tests/tools/parse.rules b/tests/tools/parse.rules
new file mode 100644 (file)
index 0000000..95a9392
--- /dev/null
@@ -0,0 +1,2 @@
+FAILED /\bFaulty\b/ bad shape
+OK /Relative error of mass computation/ message from vprops
\ No newline at end of file
diff --git a/tools/DFBrowser/DFBrowser.qrc b/tools/DFBrowser/DFBrowser.qrc
new file mode 100644 (file)
index 0000000..9670e6a
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE RCC><RCC version="1.0">
+    <qresource>
+        <file>icons/item_type_folder.png</file>
+        <file>icons/item_type_folder_40x40.png</file>
+        <file>icons/level_change.png</file>
+        <file>icons/search.png</file>
+        <file>icons/search_cancel.png</file>
+        <file>icons/treeline_backward.png</file>
+        <file>icons/treeline_forward.png</file>
+        <file>icons/treeline_update.png</file>
+    </qresource>
+</RCC>
diff --git a/tools/DFBrowser/DFBrowser_AttributePaneStack.cxx b/tools/DFBrowser/DFBrowser_AttributePaneStack.cxx
new file mode 100644 (file)
index 0000000..1dd3d27
--- /dev/null
@@ -0,0 +1,142 @@
+// 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 <DFBrowser_AttributePaneStack.hxx>
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+#include <DFBrowserPane_AttributePaneSelector.hxx>
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <DFBrowser_SearchView.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <TDF_Attribute.hxx>
+
+#include <QItemSelectionModel>
+#include <QMap>
+#include <QStackedWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_AttributePaneStack::DFBrowser_AttributePaneStack (QObject* theParent)
+: QObject (theParent), myCurrentPane (0), myAttributesStack (0), myModule (0), myTreeLevelView (0),
+  mySearchView (0), myEmptyWidget (0), myPaneMode (DFBrowser_AttributePaneType_ItemView)
+{
+  myPaneSelector = new DFBrowserPane_AttributePaneSelector (theParent);
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::CreateWidget (QWidget* theParent)
+{
+  myAttributesStack = new QStackedWidget (theParent);
+  DFBrowser_Window::SetWhiteBackground (myAttributesStack);
+  myEmptyWidget = new QWidget (theParent);
+  DFBrowser_Window::SetWhiteBackground (myEmptyWidget);
+
+  myAttributesStack->addWidget (myEmptyWidget);
+
+  myTreeLevelView = new DFBrowser_TreeLevelView (theParent);
+  myAttributesStack->addWidget (myTreeLevelView->GetControl());
+
+  mySearchView = new DFBrowser_SearchView (theParent);
+  myAttributesStack->addWidget (mySearchView->GetControl());
+
+  myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : SetPaneMode
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::SetPaneMode (const DFBrowser_AttributePaneType& theMode)
+{
+  if (myPaneMode == theMode)
+    return;
+
+  myPaneMode = theMode;
+  if (myPaneMode == DFBrowser_AttributePaneType_SearchView)
+  {
+    //! clear highlight in tree model
+    DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+    if (aModel && aModel->HasHighlighted())
+      aModel->SetHighlighted (QModelIndexList());
+    myAttributesStack->setCurrentWidget (mySearchView->GetControl());
+  }
+  else
+  {
+    QItemSelectionModel* aSelectionModel = myModule->GetOCAFViewSelectionModel();
+    QModelIndex anIndex = DFBrowser_Window::SingleSelected (aSelectionModel->selectedIndexes(), 0);
+    SetCurrentItem (anIndex);
+  }
+}
+
+// =======================================================================
+// function : SetCurrentItem
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::SetCurrentItem (const QModelIndex& theIndex)
+{
+  if (myPaneMode != DFBrowser_AttributePaneType_ItemView)
+    return;
+
+  //! clear highlight in tree model
+  DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+  if (aModel && aModel->HasHighlighted())
+    aModel->SetHighlighted (QModelIndexList());
+
+  myCurrentPane = 0;
+  QWidget* aWidget = 0;
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
+  if (!anItemBase)
+    return;
+
+  if (DFBrowser_TreeLevelView::ProcessItem (theIndex))
+    aWidget = myTreeLevelView->GetControl();
+  else
+  {
+    DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+    if (!anItem)
+      return;
+
+    if (myAttributesStack->currentWidget() == myTreeLevelView->GetControl())
+      myTreeLevelView->ClearSelection();
+    Handle(TDF_Attribute) anAttribute = anItem->GetAttribute();
+    myCurrentPane = myModule->GetAttributePane (anAttribute);
+    
+    if (myCurrentPane)
+    {
+      aWidget = myCurrentPane->GetWidget (myAttributesStack, true);
+      if (aWidget)
+      {
+        int aWidgetIndex = myAttributesStack->indexOf (aWidget);
+        if (aWidgetIndex < 0)
+          myAttributesStack->addWidget (aWidget);
+      }
+      myCurrentPane->Init (anAttribute);
+
+      std::list<QItemSelectionModel*> aSelectionModels = myCurrentPane->GetSelectionModels();
+      myPaneSelector->SetCurrentSelectionModels (aSelectionModels);
+    }
+  }
+  myAttributesStack->setCurrentWidget (aWidget != NULL ? aWidget : myEmptyWidget);
+}
diff --git a/tools/DFBrowser/DFBrowser_AttributePaneStack.hxx b/tools/DFBrowser/DFBrowser_AttributePaneStack.hxx
new file mode 100644 (file)
index 0000000..ad1b461
--- /dev/null
@@ -0,0 +1,92 @@
+// 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 DFBrowser_AttributePaneStack_H
+#define DFBrowser_AttributePaneStack_H
+
+#include <DFBrowser_AttributePaneType.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QMap>
+#include <QItemSelection>
+#include <QStackedWidget>
+#include <QWidget>
+
+class DFBrowserPane_AttributePaneAPI;
+class DFBrowserPane_AttributePaneSelector;
+class DFBrowser_Module;
+class DFBrowser_SearchView;
+class DFBrowser_TreeLevelView;
+
+class QStackedWidget;
+class QWidget;
+
+//! \class DFBrowser_AttributePaneStack
+//! \brief Provides work to stacked widget where the current attribute pane is shown.
+class DFBrowser_AttributePaneStack : public QObject
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_AttributePaneStack (QObject* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_AttributePaneStack() {}
+
+  //! Creates a stacked widget
+  //! \param theParent a parent widget
+  Standard_EXPORT virtual void CreateWidget (QWidget* theParent);
+
+  //! \return the stacked widget
+  QWidget* GetWidget() const { return myAttributesStack; }
+
+  //! Fills stackk with the information
+  //! \param theAttributeTypes a map of attribute type name to information pane
+  void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+  //! Sets the current widget in the stacked control either attribute pane or search view
+  //! \param theMode an active mode
+  Standard_EXPORT void SetPaneMode (const DFBrowser_AttributePaneType& theMode);
+
+  //! \return an attribute pane, which corresponds the current widget of the stacked widget control
+  DFBrowserPane_AttributePaneAPI* GetCurrentPane() const { return myCurrentPane; }
+
+  //! \return tree level view
+  DFBrowser_TreeLevelView* GetTreeLevelView() const { return myTreeLevelView; }
+
+  //! \return the search view
+  DFBrowser_SearchView* GetSearchView() const { return mySearchView; }
+
+  //! \return the pane selector
+  DFBrowserPane_AttributePaneSelector* GetPaneSelector() const { return myPaneSelector; }
+
+  //! Sets an active widget of attribute pane if the pane mode is item view mode.
+  //! Gets selection models of this pane and set the models into pane selector
+  Standard_EXPORT void SetCurrentItem (const QModelIndex& theIndex);
+
+protected:
+
+  DFBrowserPane_AttributePaneAPI* myCurrentPane; //!< active pane if mode is item view mode
+  DFBrowserPane_AttributePaneSelector* myPaneSelector; //!< pane selector filled by the active pane
+  QStackedWidget* myAttributesStack; //!< container of already created panes
+  DFBrowser_Module* myModule; //!< the current module
+  DFBrowser_TreeLevelView* myTreeLevelView; //!< view of objects from one level of tree view
+  DFBrowser_SearchView* mySearchView; //!< view of search control
+  QWidget* myEmptyWidget; //!< an empty widget when nothing is selected in tree view
+  DFBrowser_AttributePaneType myPaneMode; //!< the current pane mode, either item view or search view
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_AttributePaneType.hxx b/tools/DFBrowser/DFBrowser_AttributePaneType.hxx
new file mode 100644 (file)
index 0000000..6ca5e56
--- /dev/null
@@ -0,0 +1,26 @@
+// 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 DFBrowser_AttributePaneType_H
+#define DFBrowser_AttributePaneType_H
+
+//! Type of view shown in attribute pane stack
+enum DFBrowser_AttributePaneType
+{
+  DFBrowser_AttributePaneType_ItemView, //!< attribute pane stack shows either TreeLevelView or attribute pane
+  DFBrowser_AttributePaneType_SearchView //!< attribute pane stack shows search view
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Communicator.cxx b/tools/DFBrowser/DFBrowser_Communicator.cxx
new file mode 100644 (file)
index 0000000..550c676
--- /dev/null
@@ -0,0 +1,50 @@
+// 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 <DFBrowser_Communicator.hxx>
+
+#include <CDF_Session.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Window.hxx>
+
+// =======================================================================
+// function : CreateCommunicator
+// purpose : Creates a communicator by the library loading
+// =======================================================================
+Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator()
+{
+  return new DFBrowser_Communicator();
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Communicator::DFBrowser_Communicator()
+ : TInspectorAPI_Communicator(), myWindow (0)
+{
+  myWindow = new DFBrowser_Window();
+}
+
+// =======================================================================
+// function : SetParameters
+// purpose :
+// =======================================================================
+void DFBrowser_Communicator::SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
+{
+  myWindow->SetParameters (theParameters);
+  myWindow->UpdateContent();
+}
diff --git a/tools/DFBrowser/DFBrowser_Communicator.hxx b/tools/DFBrowser/DFBrowser_Communicator.hxx
new file mode 100644 (file)
index 0000000..34bffde
--- /dev/null
@@ -0,0 +1,57 @@
+// 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 DFBrowser_Communicator_H
+#define DFBrowser_Communicator_H
+
+#include <DFBrowser_Window.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <TInspectorAPI_Communicator.hxx>
+
+#include <QObject>
+
+class DFBrowser_Window;
+
+//! \class DFBrowser_Communicator.
+//! \brief This is a connector from TInspector application to DFBrowser view
+class DFBrowser_Communicator : public QObject, public TInspectorAPI_Communicator
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_Communicator();
+
+  //! Destructor
+  virtual ~DFBrowser_Communicator() Standard_OVERRIDE {}
+
+  //! Provides the container with a parent where this container should be inserted.
+  //! If Qt implementation, it should be QWidget with QLayout set inside
+  //! \param theParent a parent class
+  virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); }
+
+  //! Sets parameters container, it should be used when the plugin is initialized or in update content
+  //! \param theParameters a parameters container
+  Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE;
+
+  //! Updates content of the current window
+  virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
+
+private:
+
+  DFBrowser_Window* myWindow; //!< the current window
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_DumpView.cxx b/tools/DFBrowser/DFBrowser_DumpView.cxx
new file mode 100644 (file)
index 0000000..8ef0f0d
--- /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 <DFBrowser_DumpView.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+#include <OSD_OpenFile.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QAbstractItemModel>
+#include <QDir>
+#include <QFile>
+#include <QPlainTextEdit>
+#include <QTextStream>
+#include <QWidget>
+
+// =======================================================================
+// function : onSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_DumpView::OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+                                                     const QItemSelection&)
+{
+  myTextEdit->setVisible (false);
+  myTextEdit->clear();
+
+  QModelIndexList aSelectedIndices = theSelected.indexes();
+  QModelIndexList aFirstColumnSelectedIndices;
+  for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+  {
+    QModelIndex anIndex = *aSelIt;
+    if (anIndex.column() == 0)
+      aFirstColumnSelectedIndices.append (anIndex);
+  }
+  if (aFirstColumnSelectedIndices.size() != 1)
+    return;
+
+  QString aDumpInfo;
+  const QModelIndex& anIndex = aFirstColumnSelectedIndices.first();
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+//#define REQUIRE_OCAF_REVIEW:18 : start
+  DFBrowser_ItemPtr anItem;
+  if (anItemBase)
+    anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+
+  if (!anItem)
+    return;
+
+  TCollection_AsciiString aFileName = DFBrowser_Window::TmpDirectory();
+  aFileName += "/dfbrowser.txt";
+  // print dump to file(not in a string stream because result might be too long)
+  std::ofstream aFileStream;
+  OSD_OpenStream(aFileStream, aFileName, ios::out);
+  if (anItem->HasAttribute())
+  {
+    Handle(TDF_Attribute) anAttribute = anItem->GetAttribute();
+    if (!anAttribute.IsNull())
+      anAttribute->Dump(aFileStream);
+  }
+  else if (anItem->HasLabel())
+    anItem->GetLabel().Dump(aFileStream);
+  aFileStream.close();
+
+  // read dumped file to fill view
+  QFile aFile (aFileName.ToCString());
+  if (!aFile.open (QIODevice::ReadOnly | QIODevice::Text))
+      return;
+  QTextStream aStream (&aFile);
+  while (!aStream.atEnd())
+  {
+    aDumpInfo.append (QString ("%1\n").arg (aStream.readLine()));
+  }
+  aFile.close();
+  QDir aDir;
+  aDir.remove (aFileName.ToCString());
+//#define REQUIRE_OCAF_REVIEW:18 : end
+  if (!aDumpInfo.isEmpty())
+  {
+    myTextEdit->setVisible (true);
+    myTextEdit->setPlainText (aDumpInfo);
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_DumpView.hxx b/tools/DFBrowser/DFBrowser_DumpView.hxx
new file mode 100644 (file)
index 0000000..395458d
--- /dev/null
@@ -0,0 +1,58 @@
+// 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 DFBrowser_DumpView_H
+#define DFBrowser_DumpView_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+#include <QItemSelection>
+#include <QPlainTextEdit>
+
+class QWidget;
+
+//! \class DFBrowser_DumpView
+//! \brief View to display result of Dump() method of a TDF_Attribute
+class DFBrowser_DumpView : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  DFBrowser_DumpView (QWidget* theParent) : QObject(theParent), myTextEdit( new QPlainTextEdit(theParent) ) {}
+
+  //! Destructor
+  virtual ~DFBrowser_DumpView() Standard_OVERRIDE {}
+
+  //! \return the text edit control
+  QWidget* GetControl() const { return myTextEdit; }
+
+public slots:
+
+  //! Slots listen 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);
+
+private:
+
+  QPlainTextEdit* myTextEdit; //!< information view
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_HighlightDelegate.cxx b/tools/DFBrowser/DFBrowser_HighlightDelegate.cxx
new file mode 100644 (file)
index 0000000..d06d1d8
--- /dev/null
@@ -0,0 +1,37 @@
+// 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 <DFBrowser_HighlightDelegate.hxx>
+
+#include <DFBrowser_Window.hxx>
+#include <QPainter>
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void DFBrowser_HighlightDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                                         const QModelIndex& theIndex) const
+{
+  // highlight cell
+  if (theOption.state & QStyle::State_MouseOver)
+  {
+    QColor aHighlightColor = DFBrowser_Window::LightHighlightColor();
+    thePainter->fillRect (theOption.rect, aHighlightColor);
+  }
+  // default paint
+  QItemDelegate::paint (thePainter, theOption, theIndex);
+}
+
diff --git a/tools/DFBrowser/DFBrowser_HighlightDelegate.hxx b/tools/DFBrowser/DFBrowser_HighlightDelegate.hxx
new file mode 100644 (file)
index 0000000..00b740a
--- /dev/null
@@ -0,0 +1,46 @@
+// 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 DFBrowser_HighlightDelegate_H
+#define DFBrowser_HighlightDelegate_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QItemDelegate>
+
+//! \class DFBrowser_HighlightDelegate
+//! \brief An item delegate to paint in highlight color the cell when the mouse cursor is over it
+class DFBrowser_HighlightDelegate : public QItemDelegate
+{
+public:
+
+  //! Constructor
+  DFBrowser_HighlightDelegate (QObject* theParent = 0) : QItemDelegate (theParent) {}
+
+  //! Destructor
+  virtual ~DFBrowser_HighlightDelegate() Standard_OVERRIDE {}
+
+  //! Redefine 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
+  Standard_EXPORT virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                                       const QModelIndex& theIndex) const Standard_OVERRIDE;
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Item.cxx b/tools/DFBrowser/DFBrowser_Item.cxx
new file mode 100644 (file)
index 0000000..fc4e101
--- /dev/null
@@ -0,0 +1,189 @@
+// 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 <DFBrowser_Item.hxx>
+
+#include <DFBrowser_ItemRole.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QIcon>
+#include <QObject>
+
+const int INFO_LENGHT = 60;
+
+//#define REQUIRE_OCAF_REVIEW:23
+// =======================================================================
+// function : hasAttribute
+// purpose :
+// =======================================================================
+bool DFBrowser_Item::HasAttribute() const
+{
+  initItem();
+  return myAttributeGUID != Standard_GUID();
+}
+
+// =======================================================================
+// function : getAttribute
+// purpose :
+// =======================================================================
+Handle(TDF_Attribute) DFBrowser_Item::GetAttribute() const
+{
+  initItem();
+  Handle(TDF_Attribute) anAttribute;
+  GetLabel().FindAttribute (myAttributeGUID, anAttribute);
+  return anAttribute;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_Item::Init()
+{
+  DFBrowser_ItemBasePtr aParentItem = itemDynamicCast<DFBrowser_ItemBase> (Parent());
+  if (!aParentItem)
+    return;
+  TDF_Label aParentLabel = aParentItem->GetLabel();
+  // items can exist only by items with not empty label
+  if (aParentLabel.IsNull())
+    return;
+
+  int aNbAttributes = aParentLabel.NbAttributes();
+  int aRowId = Row();
+  if (aRowId < aNbAttributes)
+  {
+    Handle(TDF_Attribute) anAttribute;
+    int anAttributeId = 0;
+    for (TDF_AttributeIterator anAttrIt (aParentLabel); anAttrIt.More(); anAttrIt.Next(), anAttributeId++)
+    {
+      if (anAttributeId == aRowId)
+        anAttribute = anAttrIt.Value();
+    }
+    SetAttribute (anAttribute);
+  }
+  else {
+    int aCurrentId = aRowId - aNbAttributes;
+    TDF_ChildIterator aLabelsIt (aParentLabel);
+    TDF_Label aLabel;
+    for (int aLabelId = 0; aLabelsIt.More(); aLabelsIt.Next(), aLabelId++)
+    {
+      if (aLabelId < aCurrentId)
+        continue;
+      aLabel = aLabelsIt.Value();
+      break;
+    }
+    if (!aLabel.IsNull())
+      setLabel (aLabel);
+  }
+  TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_Item::Reset()
+{
+  SetAttribute (Handle(TDF_Attribute)());
+
+  DFBrowser_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_Item::initRowCount() const
+{
+  return HasAttribute() ? 0 : DFBrowser_ItemBase::initRowCount();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Item::initValue (const int theItemRole) const
+{
+  if (!HasAttribute())
+    return DFBrowser_ItemBase::initValue (theItemRole);
+
+  if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended || theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+  {
+    int aRole = theItemRole == DFBrowserPane_ItemRole_DisplayExtended ? Qt::DisplayRole : Qt::ToolTipRole;
+    QVariant aValue = DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), aRole, Column());
+    QString anAdditionalInfo = DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(),
+                                                                    DFBrowser_ItemRole_AdditionalInfo, Column()).toString();
+    if (!anAdditionalInfo.isEmpty())
+    {
+      if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended && anAdditionalInfo.length() > INFO_LENGHT)
+        anAdditionalInfo = anAdditionalInfo.mid (0, INFO_LENGHT - 3) + "...";
+      if (!anAdditionalInfo.isEmpty())
+        aValue = QVariant (aValue.toString() + QString (" [%1]").arg (anAdditionalInfo));
+      //if (aRole == Qt::ToolTipRole)
+      //  aValue = wrapTextByWords(aValue.toString().toStdString(), INFO_LENGHT).c_str();
+    }
+    return aValue;
+  }
+
+  return DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), theItemRole, Column());
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Item::GetAttributeInfo (int theRole) const
+{
+  initItem();
+  return cachedValue (theRole);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void DFBrowser_Item::initItem() const
+{
+  if (IsInitialized())
+    return;
+  
+  const_cast<DFBrowser_Item*>(this)->Init();
+}
+
+// =======================================================================
+// function : SetAttribute
+// purpose :
+// =======================================================================
+void DFBrowser_Item::SetAttribute (Handle(TDF_Attribute) theAttribute)
+{
+  if (!theAttribute.IsNull())
+  {
+    setLabel (theAttribute->Label());
+    myAttributeGUID = theAttribute->ID();
+  }
+  else
+  {
+    setLabel (TDF_Label());
+    myAttributeGUID = Standard_GUID();
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_Item.hxx b/tools/DFBrowser/DFBrowser_Item.hxx
new file mode 100644 (file)
index 0000000..2a226c9
--- /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. 
+
+#ifndef DFBrowser_Item_H
+#define DFBrowser_Item_H
+
+#include <DFBrowser_ItemBase.hxx>
+
+#include <TDF_Attribute.hxx>
+#include <Standard.hxx>
+#include <Standard_GUID.hxx>
+
+#include <QMap>
+#include <QList>
+#include <QVariant>
+
+class DFBrowser_Item;
+typedef QExplicitlySharedDataPointer<DFBrowser_Item> DFBrowser_ItemPtr;
+
+//! \class DFBrowser_Item
+//! \brief Declaration of the tree model root item.
+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
+  //! \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 {};
+
+  //! \return true if the attribute is set in the item, otherwise it is initialized by a label
+  Standard_EXPORT bool HasAttribute() const;
+
+  //! \return the item attribute
+  Standard_EXPORT Handle(TDF_Attribute) GetAttribute() const;
+
+  //! Finds int parent item attribute or label by this item row and store it in a field of this item.
+  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+  //! 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
+  //! \param theItemRole a value role
+  //! \return the value
+  Standard_EXPORT QVariant GetAttributeInfo(int theRole) const;
+
+protected:
+
+  //! \return number of children.
+  virtual int initRowCount() const Standard_OVERRIDE;
+
+  //! Return 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;
+
+  //! 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
+  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
+  void initItem() const;
+
+  //! Sets the item attribute
+  //! \param theAttribute an item attribute
+  void SetAttribute (Handle(TDF_Attribute) theAttribute);
+
+private:
+
+  Standard_GUID myAttributeGUID; //!< if attribute, stores GUID of the attibute because label can contain only one attribute of a kind
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ItemApplication.cxx b/tools/DFBrowser/DFBrowser_ItemApplication.cxx
new file mode 100644 (file)
index 0000000..89ed532
--- /dev/null
@@ -0,0 +1,70 @@
+// 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 <DFBrowser_ItemApplication.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemDocument.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+
+#include <QObject>
+
+//#define REQUIRE_OCAF_REVIEW:21
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemApplication::createChild (int theRow, int theColumn)
+{
+  TreeModel_ItemBasePtr anItem = DFBrowser_ItemDocument::CreateItem (currentItem(), theRow, theColumn);
+  DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+  aBaseItem->SetModule (GetModule());
+
+  return anItem;
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_ItemApplication::initRowCount() const
+{
+  if (myApplication.IsNull())
+    return 0;
+
+  return myApplication->NbDocuments();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemApplication::initValue (const int theItemRole) const
+{
+  if (theItemRole == Qt::DisplayRole ||
+      theItemRole == Qt::EditRole ||
+      theItemRole == Qt::ToolTipRole ||
+      theItemRole == DFBrowserPane_ItemRole_DisplayExtended ||
+      theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+  {
+    return "TDocStd_Application";
+  }
+  return QVariant();
+}
diff --git a/tools/DFBrowser/DFBrowser_ItemApplication.hxx b/tools/DFBrowser/DFBrowser_ItemApplication.hxx
new file mode 100644 (file)
index 0000000..d817553
--- /dev/null
@@ -0,0 +1,77 @@
+// 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 DFBrowser_ItemApplication_H
+#define DFBrowser_ItemApplication_H
+
+#include <DFBrowser_ItemBase.hxx>
+#include <TDocStd_Application.hxx>
+
+class DFBrowser_ItemApplication;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemApplication> DFBrowser_ItemApplicationPtr;
+
+//! \class DFBrowser_ItemApplication
+//! \brief Declaration of the tree model root item.
+//! This item is connected to the main label of the document.
+class DFBrowser_ItemApplication : public DFBrowser_ItemBase
+{
+public:
+
+  //! Creates an item wrapped by a shared pointer
+  static DFBrowser_ItemApplicationPtr CreateItem (TreeModel_ItemBasePtr theParent)
+  { return DFBrowser_ItemApplicationPtr (new DFBrowser_ItemApplication (theParent)); }
+
+  //! Destructor
+  virtual ~DFBrowser_ItemApplication() Standard_OVERRIDE {};
+
+  //! Sets the item label
+  //! \param theLabel an object where the child items structure is found
+  void SetApplication (const Handle(TDocStd_Application)& theApplication) { myApplication = theApplication; }
+
+  //! Returns the current label
+  //! \return a label
+  const Handle(TDocStd_Application)& GetApplication() const { return myApplication; }
+
+protected:
+
+  //! Returns number of documents if the application is not NULL
+  //! \return rows count
+  virtual int initRowCount() const Standard_OVERRIDE;
+
+  //! Returns fixed item text or empty.
+  //! \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
+  DFBrowser_ItemApplication(TreeModel_ItemBasePtr theParent) : DFBrowser_ItemBase(theParent, 0, 0) {}
+
+private:
+
+  Handle(TDocStd_Application) myApplication; //!<! OCAF application
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ItemBase.cxx b/tools/DFBrowser/DFBrowser_ItemBase.cxx
new file mode 100644 (file)
index 0000000..ae4d0d6
--- /dev/null
@@ -0,0 +1,151 @@
+// 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 <DFBrowser_ItemBase.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Name.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QColor>
+#include <QIcon>
+#include <QVariant>
+
+//#define REQUIRE_OCAF_REVIEW:20
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_ItemBase::DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+: TreeModel_ItemBase (theParent, theRow, theColumn), myModule (0), myIsUseAdditionalInfo (true)
+{
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_ItemBase::Reset()
+{
+  setLabel (TDF_Label());
+  TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : GetLabel
+// purpose :
+// =======================================================================
+TDF_Label DFBrowser_ItemBase::GetLabel() const
+{
+  initItem();
+  return myLabel;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemBase::data (const QModelIndex& theIndex, int theRole) const
+{
+  int aRole = theRole;
+  if (Column() == 0 && useAdditionalInfo())
+  {
+    switch (theRole)
+    {
+      case Qt::DisplayRole: { aRole = DFBrowserPane_ItemRole_DisplayExtended; break; }
+      case Qt::ToolTipRole: { aRole = DFBrowserPane_ItemRole_ToolTipExtended; break; }
+    }
+  }
+  return TreeModel_ItemBase::data (theIndex, aRole);
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_ItemBase::initRowCount() const
+{
+  TDF_Label aLabel = GetLabel();
+  if (aLabel.IsNull())
+    return 0;
+
+  return aLabel.NbChildren() + aLabel.NbAttributes();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemBase::initValue (const int theItemRole) const
+{
+  switch (theItemRole)
+  {
+    case Qt::DisplayRole:
+    case Qt::EditRole:
+    case Qt::ToolTipRole:
+      return DFBrowser_Tools::GetLabelInfo (myLabel, false);
+    case DFBrowserPane_ItemRole_DisplayExtended:
+    case DFBrowserPane_ItemRole_ToolTipExtended:
+      return DFBrowser_Tools::GetLabelInfo (myLabel, true);
+    case Qt::ForegroundRole:
+    {
+      QVariant aValue = QColor (Qt::black);
+      if (DFBrowser_Tools::IsEmptyLabel(GetLabel()))
+        aValue = QColor (Qt::lightGray);
+      else
+      { //! 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);
+      }
+      return aValue;
+    }
+    case Qt::DecorationRole: return DFBrowser_Tools::GetLabelIcon (myLabel);
+    default: break;
+  }
+  return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemBase::createChild (int theRow, int theColumn)
+{
+  TreeModel_ItemBasePtr anItem = DFBrowser_Item::CreateItem (currentItem(), theRow, theColumn);
+  DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+  aBaseItem->SetModule (GetModule());
+
+  return anItem;
+}
+
+// =======================================================================
+// function : SetUseAdditionalInfo
+// purpose :
+// =======================================================================
+bool DFBrowser_ItemBase::SetUseAdditionalInfo (const bool theValue)
+{
+  bool aPreviousValue = myIsUseAdditionalInfo;
+  myIsUseAdditionalInfo = theValue;
+  return aPreviousValue;
+}
+
diff --git a/tools/DFBrowser/DFBrowser_ItemBase.hxx b/tools/DFBrowser/DFBrowser_ItemBase.hxx
new file mode 100644 (file)
index 0000000..d16eb93
--- /dev/null
@@ -0,0 +1,104 @@
+// 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 DFBrowser_ItemBase_H
+#define DFBrowser_ItemBase_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+#include <TDF_Label.hxx>
+
+class DFBrowser_ItemBase;
+class DFBrowser_Module;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemBase> DFBrowser_ItemBasePtr;
+
+//! \class DFBrowser_ItemBase
+//! \brief Declaration of the tree model base item.
+//! This item provide method to process a TDF label.
+class DFBrowser_ItemBase : public TreeModel_ItemBase
+{
+public:
+
+  //! Sets the module to have an access to attribute information
+  //! \param theModule a current loaded application module
+  void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+  //! Resets the cached item values
+  Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+  //! \return true if the current label is not null
+  bool HasLabel() const { return !GetLabel().IsNull(); }
+
+  //! \return the current label
+  Standard_EXPORT virtual TDF_Label GetLabel() const;
+
+  //! \return the current module
+  DFBrowser_Module* GetModule() const { return myModule; }
+
+  //! Change using of additional information in item. It it does not use additional info,
+  //! it will not return extended text in initValue().
+  //! \param theValue a new value
+  //! \return the previous value
+  Standard_EXPORT bool SetUseAdditionalInfo (const bool theValue);
+
+  //! Returns the data stored under the given role for the current item
+  //! \param theIndex the item model index
+  //! \param theRole the item model role
+  Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole) const Standard_OVERRIDE;
+
+protected:
+
+  //! Sets the item label
+  //! \param theLabel an object where the child items structure is found
+  void setLabel(TDF_Label theLabel) { myLabel = theLabel; }
+
+  //! Returns if additional information is shown in item for Display and ToolTip values
+  //! \return boolean value
+  bool useAdditionalInfo() const { return myIsUseAdditionalInfo; }
+
+  //! Returns sum of label children and attributes
+  //! \return rows count
+  virtual int initRowCount() const Standard_OVERRIDE;
+
+  //! Returns label information like text, icon or background(if it contains TDataStd_Name attribute)
+  //! \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;
+
+  //! Initialize 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
+  DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+
+private:
+
+  TDF_Label myLabel; //!< a label of the document, which contains child labels and attributes
+  DFBrowser_Module* myModule; //!< the current module
+  bool myIsUseAdditionalInfo; //!< if true, additional item info is shown in square brackets
+};
+
+#endif
\ No newline at end of file
diff --git a/tools/DFBrowser/DFBrowser_ItemDocument.cxx b/tools/DFBrowser/DFBrowser_ItemDocument.cxx
new file mode 100644 (file)
index 0000000..dcefc48
--- /dev/null
@@ -0,0 +1,148 @@
+// 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 <DFBrowser_ItemDocument.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemApplication.hxx>
+#include <DFBrowser_ItemDocument.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+
+#include <QIcon>
+#include <QLabel>
+#include <QObject>
+
+//#define REQUIRE_OCAF_REVIEW:22
+
+// =======================================================================
+// function : GetLabel
+// purpose :
+// =======================================================================
+TDF_Label DFBrowser_ItemDocument::GetLabel() const
+{
+  TDF_Label aLabel;
+  if (myDocument.IsNull())
+    getDocument();
+
+  if (!myDocument.IsNull())
+    aLabel = myDocument->Main().Root();
+
+  if (!aLabel.IsNull())
+    aLabel = aLabel.Root();
+
+  return aLabel;
+}
+
+// =======================================================================
+// function : getDocument
+// purpose :
+// =======================================================================
+const Handle(TDocStd_Document)& DFBrowser_ItemDocument::getDocument() const
+{
+  initItem();
+  return myDocument;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemDocument::initValue (const int theItemRole) const
+{
+  if (theItemRole == Qt::DisplayRole ||
+      theItemRole == Qt::EditRole ||
+      theItemRole == DFBrowserPane_ItemRole_DisplayExtended ||
+      theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+    return DFBrowser_Tools::GetLabelInfo (GetLabel());
+  if (theItemRole == Qt::DecorationRole)
+    return DFBrowser_Tools::GetLabelIcon (GetLabel());
+
+  return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemDocument::createChild (int theRow, int theColumn)
+{
+  TreeModel_ItemBasePtr anItem = DFBrowser_Item::CreateItem (currentItem(), theRow, theColumn);
+  DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+  aBaseItem->SetModule (GetModule());
+
+  return anItem;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::Init()
+{
+  DFBrowser_ItemApplicationPtr aParentItem = itemDynamicCast<DFBrowser_ItemApplication> (Parent());
+  if (!aParentItem)
+    return;
+
+  const Handle(TDocStd_Application)& anApplication = aParentItem->GetApplication();
+  // items can exist only by items with not empty label
+  if (anApplication.IsNull())
+    return;
+
+  int aRowId = Row();
+
+  int aDocumentId = -1;
+  for (Standard_Integer aDocId = 1, aNbDoc = anApplication->NbDocuments(); aDocId <= aNbDoc && aDocumentId < 0; aDocId++)
+  {
+    if (aDocId - 1 == aRowId)
+      aDocumentId = aDocId;
+  }
+  if (aDocumentId > 0)
+  {
+    Handle(TDocStd_Document) aDocument;
+    anApplication->GetDocument (aDocumentId, aDocument);
+    setDocument (aDocument);
+  }
+  else
+    setDocument (Handle(TDocStd_Document)());
+
+  TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::Reset()
+{
+  Handle(TDocStd_Document) aDocument;
+  setDocument (aDocument);
+
+  DFBrowser_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::initItem() const
+{
+  if (IsInitialized())
+    return;
+
+  const_cast<DFBrowser_ItemDocument*>(this)->Init();
+}
diff --git a/tools/DFBrowser/DFBrowser_ItemDocument.hxx b/tools/DFBrowser/DFBrowser_ItemDocument.hxx
new file mode 100644 (file)
index 0000000..4338369
--- /dev/null
@@ -0,0 +1,93 @@
+// 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 DFBrowser_ItemDocument_H
+#define DFBrowser_ItemDocument_H
+
+#include <DFBrowser_ItemBase.hxx>
+#include <Standard.hxx>
+#include <TDocStd_Document.hxx>
+
+class DFBrowser_ItemDocument;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemDocument> DFBrowser_ItemDocumentPtr;
+
+//! \class DFBrowser_ItemDocument
+//! \brief Declaration of the tree model document item.
+//! This item is connected to the OCAF document. Parent item is application, children are either labels or attributes
+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
+  //! \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 {};
+
+  //! Returns the current label
+  //! \return a label
+  Standard_EXPORT virtual TDF_Label GetLabel() const Standard_OVERRIDE;
+
+  //! Sets the item document
+  //! \param theLabel an object where the child items structure is found
+  void setDocument (const Handle(TDocStd_Document)& theDocument) { myDocument = theDocument; }
+
+  //! Returns true if the current document is not null
+  //! \return a boolean value
+  bool hasDocument() const { return !getDocument().IsNull(); }
+
+  //! Returns the current document
+  //! \return a label
+  Standard_EXPORT const Handle(TDocStd_Document)& getDocument() const;
+
+  //! Inits the item, fills internal containers
+  Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+  //! Resets the cached item 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;
+
+  //!
+  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
+  DFBrowser_ItemDocument(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+    : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
+
+private:
+
+  Handle(TDocStd_Document) myDocument; //!< cached application document by the row index of the item
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ItemRole.hxx b/tools/DFBrowser/DFBrowser_ItemRole.hxx
new file mode 100644 (file)
index 0000000..96b09a4
--- /dev/null
@@ -0,0 +1,27 @@
+// 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 DFBrowser_ItemRole_H
+#define DFBrowser_ItemRole_H
+
+#include <Qt>
+
+//! Additional data item role for DFBrowser tree item
+enum DFBrowser_ItemRole
+{
+  DFBrowser_ItemRole_AdditionalInfo = Qt::UserRole + 1 //!< an attribute additional information 
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Module.cxx b/tools/DFBrowser/DFBrowser_Module.cxx
new file mode 100644 (file)
index 0000000..404c6f4
--- /dev/null
@@ -0,0 +1,231 @@
+// 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 <DFBrowser_Module.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemApplication.hxx>
+#include <DFBrowser_ItemBase.hxx>
+#include <DFBrowser_ItemRole.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_AttributePaneCreator.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <DFBrowserPaneXDE_AttributePaneCreator.hxx>
+#include <DFBrowserPaneXDE_Tools.hxx>
+
+#include <XCAFApp_Application.hxx>
+
+#include <QItemSelectionModel>
+#include <QMessageBox>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Module::DFBrowser_Module()
+: myOCAFViewModel (0)
+{
+  RegisterPaneCreator (new DFBrowserPane_AttributePaneCreator());
+}
+
+// =======================================================================
+// function : CreateViewModel
+// purpose :
+// =======================================================================
+void DFBrowser_Module::CreateViewModel (void* theParent)
+{
+  myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+}
+
+// =======================================================================
+// function : SetApplication
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetApplication (const Handle(TDocStd_Application)& theApplication)
+{
+  myOCAFViewModel->Init (theApplication);
+
+  myPaneCreators.clear();
+  RegisterPaneCreator (new DFBrowserPane_AttributePaneCreator());
+  if (!theApplication.IsNull() && DFBrowserPaneXDE_Tools::IsXDEApplication (theApplication))
+    RegisterPaneCreator (new DFBrowserPaneXDE_AttributePaneCreator (myPaneCreators[0]));
+}
+
+// =======================================================================
+// function : SetExternalContext
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetExternalContext (const Handle(Standard_Transient)& theContext)
+{
+  myExternalContext = Handle(AIS_InteractiveContext)::DownCast (theContext);
+}
+
+// =======================================================================
+// function : GetTDocStdApplication
+// purpose :
+// =======================================================================
+Handle(TDocStd_Application) DFBrowser_Module::GetTDocStdApplication() const
+{
+  return myOCAFViewModel->GetTDocStdApplication();
+}
+
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void DFBrowser_Module::UpdateTreeModel()
+{
+  QAbstractItemModel* aModel = GetOCAFViewModel();
+  QItemSelectionModel* aSelectionModel = GetOCAFViewSelectionModel();
+  if (!aModel || !aSelectionModel)
+    return;
+  aSelectionModel->clearSelection();
+
+  emit beforeUpdateTreeModel();
+  myOCAFViewModel->Reset();
+  myOCAFViewModel->EmitLayoutChanged();
+
+  SetInitialTreeViewSelection();
+}
+
+// =======================================================================
+// function : SetInitialTreeViewSelection
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetInitialTreeViewSelection()
+{
+  QAbstractItemModel* aModel = GetOCAFViewModel();
+  QItemSelectionModel* aSelectionModel = GetOCAFViewSelectionModel();
+  if (!aModel || !aSelectionModel)
+    return;
+
+  // select a parent(aplication) item
+  aSelectionModel->select (aModel->index (0, 0), QItemSelectionModel::ClearAndSelect);
+}
+
+// =======================================================================
+// function : FindAttribute
+// purpose :
+// =======================================================================
+Handle(TDF_Attribute) DFBrowser_Module::FindAttribute (const QModelIndex& theIndex)
+{
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
+  if (!anItemBase)
+    return Handle(TDF_Attribute)();
+
+  DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+  return (anItem && anItem->HasAttribute()) ? anItem->GetAttribute() : Handle(TDF_Attribute)();
+}
+
+// =======================================================================
+// function : GetAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Handle(TDF_Attribute) theAttribute)
+{
+  DFBrowserPane_AttributePaneAPI* aPane = 0;
+  if (theAttribute.IsNull())
+    return aPane;
+  return GetAttributePane (theAttribute->DynamicType()->Name());
+}
+
+// =======================================================================
+// function : GetAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (const Standard_CString& theAttributeName)
+{
+  DFBrowserPane_AttributePaneAPI* aPane = 0;
+
+  if (!myAttributeTypes.contains (theAttributeName))
+  {
+    aPane = CreateAttributePane (theAttributeName);
+    if (aPane)
+      myAttributeTypes[theAttributeName] = aPane;
+  }
+  else
+    aPane = myAttributeTypes[theAttributeName];
+
+  return aPane;
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Module::GetAttributeInfo (Handle(TDF_Attribute) theAttribute, DFBrowser_Module* theModule,
+                                             int theRole, int theColumnId)
+{
+  DFBrowserPane_AttributePane* anAttributePane = 0;
+  if (!theAttribute.IsNull())
+  {
+    DFBrowserPane_AttributePaneAPI* anAPIPane = theModule->GetAttributePane (theAttribute);
+    if (anAPIPane)
+      anAttributePane = dynamic_cast<DFBrowserPane_AttributePane*> (anAPIPane);
+  }
+
+  QVariant aValue;
+  if (anAttributePane)
+    aValue = anAttributePane->GetAttributeInfo (theAttribute,
+               theRole == DFBrowser_ItemRole_AdditionalInfo ? DFBrowserPane_ItemRole_ShortInfo : theRole,
+               theColumnId);
+  else
+    aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute->DynamicType()->Name(), theRole, theColumnId);
+  return aValue;
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+                                             int theRole, int theColumnId)
+{
+  DFBrowserPane_AttributePane* anAttributePane = 0;
+  DFBrowserPane_AttributePaneAPI* anAPIPane = theModule->GetAttributePane (theAttributeName);
+  if (anAPIPane)
+    anAttributePane = dynamic_cast<DFBrowserPane_AttributePane*> (anAPIPane);
+
+  QVariant aValue;
+  if (anAttributePane)
+  {
+    Handle(TDF_Attribute) anAttribute;
+    aValue = anAttributePane->GetAttributeInfo (anAttribute,
+               theRole == DFBrowser_ItemRole_AdditionalInfo ? DFBrowserPane_ItemRole_ShortInfo : theRole, theColumnId);
+  }
+  else
+    aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttributeName, theRole, theColumnId);
+  return aValue;
+
+}
+
+// =======================================================================
+// function : CreateAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (const Standard_CString& theAttributeName)
+{
+  DFBrowserPane_AttributePaneAPI* aPane = 0;
+  // iteration should be performed from the tail of the list, as latest added creator has
+  // larger priority
+  for (int aPaneCreatorId = myPaneCreators.size()-1; aPaneCreatorId >= 0 && !aPane; aPaneCreatorId--)
+    aPane = myPaneCreators[aPaneCreatorId]->CreateAttributePane (theAttributeName);
+  return aPane;
+}
diff --git a/tools/DFBrowser/DFBrowser_Module.hxx b/tools/DFBrowser/DFBrowser_Module.hxx
new file mode 100644 (file)
index 0000000..b151276
--- /dev/null
@@ -0,0 +1,150 @@
+// 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 DFBrowser_Module_H
+#define DFBrowser_Module_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <NCollection_Map.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QObject>
+
+class DFBrowserPane_AttributePaneAPI;
+class DFBrowserPane_AttributePaneCreatorAPI;
+
+class QAbstractItemModel;
+class QItemSelectionModel;
+
+//! \class DFBrowser_Module
+//! The class is a container of current components of DFBrowser:
+//! - OCAF view model
+//! - OCAF selection model
+//! - container of attribute panes into attribute name
+//! - acceptable attribute pane creators
+//! - external AIS interactive context
+//! It has general attribute pane creator, if the application is XDE, it uses XDE attribute pane creator.
+//! It fills container of created attribute pane.
+class DFBrowser_Module : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_Module();
+
+  //! Destructor
+  virtual ~DFBrowser_Module() Standard_OVERRIDE {};
+
+  //! Creates tree model for OCAF application
+  Standard_EXPORT void CreateViewModel (void* theParent);
+
+  //! Fills tree model by the application and register pane creator
+  //! \param theApplication a current application
+  Standard_EXPORT void SetApplication (const Handle(TDocStd_Application)& theApplication);
+
+  //! Fills viewer by the context
+  //! \param theContext a current context where presentations should be visualized
+  Standard_EXPORT void SetExternalContext (const Handle(Standard_Transient)& theContext);
+
+  //! Returns external context or NULL
+  const Handle(AIS_InteractiveContext)& GetExternalContext() const { return myExternalContext; }
+
+  //! Returns a view model with the OCAF structure content
+  QAbstractItemModel* GetOCAFViewModel() { return myOCAFViewModel; }
+
+  //! Sets selection model of tree view
+  void SetOCAFViewSelectionModel(QItemSelectionModel* theSelectionModel)
+  { myOCAFViewSelectionModel = theSelectionModel; }
+
+  //! Returns selection model of tree view
+  QItemSelectionModel* GetOCAFViewSelectionModel() const { return myOCAFViewSelectionModel; }
+
+  //! Returns an OCAF application or NULL
+  //! \return an application instance
+  Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
+
+  //! Rebuild an OCAF tree view model
+  Standard_EXPORT void UpdateTreeModel();
+
+  //! Sets initial selection in OCAF tree view, it is an application(root) item
+  Standard_EXPORT void SetInitialTreeViewSelection();
+
+  //! Returns attibute placed on the parameter index in the OCAF tree view or NULL
+  //! \param theIndex an index in OCAF tree view.
+  //! \return an attribute
+  Standard_EXPORT Handle(TDF_Attribute) FindAttribute (const QModelIndex& theIndex);
+
+  //! Append creator of a pane by attribute type
+  //! \param thePaneCreator
+  void RegisterPaneCreator (DFBrowserPane_AttributePaneCreatorAPI* thePaneCreator)
+  { myPaneCreators.append (thePaneCreator); }
+
+  //! Returns an attribute pane for the attribute: create a new if it is not exist in
+  //! internal map and the module processes this kind of attribute
+  //! \param theAttributeGUID an attribute key
+  //! \return attribute pane
+  Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (Handle(TDF_Attribute) theAttribute);
+
+  //! Returns an attribute pane for the attribute GUID: create a new if it is not exist in
+  //! 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);
+
+  //! Finds the attribute pane according to the give attribute and returns its information
+  //! \param theAttribute a source attribute
+  //! \param theModule to provide a map of attribute id to attribute pane
+  //! \param theRole an attribute role in the tree view, includes: text, icon, color roles
+  //! \param theColumnId a column index
+  Standard_EXPORT static QVariant GetAttributeInfo (Handle(TDF_Attribute) theAttribute, DFBrowser_Module* theModule,
+                                                    int theRole, int theColumnId);
+
+  //! Returns information for the given attribute type name
+  //! \param theAttributeName a current attribute type name
+  //! \param theModule a current module
+  //! \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,
+                                                    int theRole, int theColumnId);
+signals:
+
+  //! Emits signal about updating tree model
+  void beforeUpdateTreeModel();
+
+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);
+
+private:
+
+  DFBrowser_TreeModel* myOCAFViewModel; //!< the tree view abstract model
+  QItemSelectionModel* myOCAFViewSelectionModel; //!< selection model over OCAF tree view
+  QMap<TCollection_AsciiString, DFBrowserPane_AttributePaneAPI*> myAttributeTypes; //!< container of created panes
+  QList<DFBrowserPane_AttributePaneCreatorAPI*> myPaneCreators; //!< pane creators
+  Handle(AIS_InteractiveContext) myExternalContext; //!< context that comes in initialize parameters
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_OpenApplication.cxx b/tools/DFBrowser/DFBrowser_OpenApplication.cxx
new file mode 100644 (file)
index 0000000..39b919d
--- /dev/null
@@ -0,0 +1,107 @@
+// 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 <DFBrowser_OpenApplication.hxx>
+
+#include <BinDrivers.hxx>
+#include <BinLDrivers.hxx>
+#include <BinXCAFDrivers.hxx>
+#include <PCDM_ReadWriter.hxx>
+#include <Standard_Version.hxx>
+#include <StdDrivers.hxx>
+#include <StdLDrivers.hxx>
+#include <STEPCAFControl_Reader.hxx>
+#include <STEPCAFControl_Controller.hxx>
+#include <TPrsStd_DriverTable.hxx>
+#include <XCAFApp_Application.hxx>
+#include <XCAFPrs_Driver.hxx>
+#include <XmlDrivers.hxx>
+#include <XmlLDrivers.hxx>
+#include <XmlXCAFDrivers.hxx>
+#include <UTL.hxx>
+
+//#define REQUIRE_OCAF_REVIEW:24
+namespace DFBrowser_OpenApplication
+{
+
+  // =======================================================================
+  // function : OpenApplication
+  // purpose :
+  // =======================================================================
+  Handle(TDocStd_Application) OpenApplication (const TCollection_AsciiString& theFileName, bool& isSTEPFile)
+  {
+    Handle(TDocStd_Application) anApplication = CreateApplicationBySTEPFile (theFileName);
+    if (!anApplication.IsNull())
+    {
+      isSTEPFile = true;
+      return anApplication;
+    }
+
+#if OCC_VERSION_HEX > 0x060901
+    // Load static variables for STEPCAF (ssv; 16.08.2012)
+    STEPCAFControl_Controller::Init();
+
+    anApplication = new TDocStd_Application();
+    // Initialize standard document formats at creation - they should
+    // be available even if this DRAW plugin is not loaded by pload command
+    StdLDrivers::DefineFormat (anApplication);
+    BinLDrivers::DefineFormat (anApplication);
+    XmlLDrivers::DefineFormat (anApplication);
+    StdDrivers::DefineFormat (anApplication);
+    BinDrivers::DefineFormat (anApplication);
+    XmlDrivers::DefineFormat (anApplication);
+
+    // Initialize XCAF formats
+    BinXCAFDrivers::DefineFormat (anApplication);
+    XmlXCAFDrivers::DefineFormat (anApplication);
+
+    // Register driver in global table for displaying XDE documents 
+    // in 3d viewer using OCAF mechanics
+    TPrsStd_DriverTable::Get()->AddDriver (XCAFPrs_Driver::GetID(), new XCAFPrs_Driver);
+
+    Handle(TDocStd_Document) aDocument;
+    PCDM_ReaderStatus aStatus = anApplication->Open (theFileName, aDocument);
+    if (aStatus != PCDM_RS_OK)
+      return Handle(TDocStd_Application)();
+#endif
+    return anApplication;
+  }
+
+  // =======================================================================
+  // function : CreateApplicationBySTEPFile
+  // purpose :
+  // =======================================================================
+  Handle(TDocStd_Application) CreateApplicationBySTEPFile (const TCollection_AsciiString& theFileName)
+  {
+    if (!theFileName.EndsWith (".step") && !theFileName.EndsWith (".stp"))
+      return Handle(TDocStd_Application)();
+
+    Handle(TDocStd_Application) aTmpApplication = XCAFApp_Application::GetApplication();
+    STEPCAFControl_Reader aStepReader;
+
+    const TCollection_AsciiString aStr (theFileName);
+    IFSelect_ReturnStatus aStatus = aStepReader.ReadFile (aStr.ToCString());
+    if (aStatus != IFSelect_RetDone)
+      return Handle(TDocStd_Application)();
+
+    aStepReader.SetColorMode (Standard_True);
+    aStepReader.SetLayerMode (Standard_True);
+    aStepReader.SetNameMode (Standard_True);
+
+    Handle(TDocStd_Document) aDocument;
+    aTmpApplication->NewDocument ("BinOcaf", aDocument);
+    return aStepReader.Transfer (aDocument) ? aTmpApplication : Handle(TDocStd_Application)();
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_OpenApplication.hxx b/tools/DFBrowser/DFBrowser_OpenApplication.hxx
new file mode 100644 (file)
index 0000000..ccff708
--- /dev/null
@@ -0,0 +1,41 @@
+// 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 DFBrowser_OpenApplication_H
+#define DFBrowser_OpenApplication_H
+
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDocStd_Application.hxx>
+
+//! \namespace DFBrowser_OpenApplication
+namespace DFBrowser_OpenApplication
+{
+
+  //! Open 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
+  Standard_EXPORT Handle(TDocStd_Application) OpenApplication (const TCollection_AsciiString& theFileName,
+                                                               bool& isSTEPFile);
+
+  //! Creates a new application if the name contains "stp" or "step" extension. The application is "BinOcaf",
+  //! STEP reader transfers the file into the application
+  //! \param theFileName a name of the file initialized the application
+  //! \return a new application
+  Standard_EXPORT Handle(TDocStd_Application) CreateApplicationBySTEPFile (const TCollection_AsciiString& theFileName);
+}
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_PropertyPanel.cxx b/tools/DFBrowser/DFBrowser_PropertyPanel.cxx
new file mode 100644 (file)
index 0000000..4ec0e9c
--- /dev/null
@@ -0,0 +1,58 @@
+// 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 <DFBrowser_PropertyPanel.hxx>
+
+#include <DFBrowser_AttributePaneStack.hxx>
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_SearchView.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+
+#include <QAbstractItemModel>
+#include <QGridLayout>
+#include <QItemSelectionModel>
+#include <QWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_PropertyPanel::DFBrowser_PropertyPanel (QWidget* theParent)
+: QObject (theParent), myAttributesStack (0)
+{
+  myMainWindow = new QWidget (theParent);
+  DFBrowser_Window::SetWhiteBackground (myMainWindow);
+
+  QGridLayout* aLayout = new QGridLayout (myMainWindow);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+
+  myAttributesStack = new DFBrowser_AttributePaneStack (this);
+  myAttributesStack->CreateWidget (myMainWindow);
+  aLayout->addWidget (myAttributesStack->GetWidget(), 0, 0);
+}
+
+// =======================================================================
+// function : UpdateBySelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_PropertyPanel::UpdateBySelectionChanged (const QItemSelection& theSelected,
+                                                        const QItemSelection&)
+{
+  GetAttributesStack()->GetSearchView()->Reset();
+
+  QModelIndex anIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0);
+  myAttributesStack->SetCurrentItem (anIndex);
+}
diff --git a/tools/DFBrowser/DFBrowser_PropertyPanel.hxx b/tools/DFBrowser/DFBrowser_PropertyPanel.hxx
new file mode 100644 (file)
index 0000000..baa10ad
--- /dev/null
@@ -0,0 +1,60 @@
+// 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 DFBrowser_PropertyPanel_H
+#define DFBrowser_PropertyPanel_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+
+class DFBrowser_AttributePaneStack;
+
+class QAbstractItemModel;
+class QWidget;
+
+//! \class DFBrowser_PropertyPanel
+//! Control that contains attribute pane stack
+class DFBrowser_PropertyPanel : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_PropertyPanel (QWidget* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_PropertyPanel() Standard_OVERRIDE {}
+
+  //! Returns main control
+  QWidget* GetControl() const { return myMainWindow; }
+
+  //! Returns instance of attributes stack
+  //! \return stack
+  DFBrowser_AttributePaneStack* GetAttributesStack() { return myAttributesStack; }
+
+  //! Fills attributes stack by selected index
+  //! \param theSelected selected items
+  //! \param theDeselected deselected items
+  Standard_EXPORT void UpdateBySelectionChanged (const QItemSelection& theSelected,
+                                                 const QItemSelection& theDeselected);
+private:
+
+  QWidget* myMainWindow; //! < parent of attribute stack control
+  DFBrowser_AttributePaneStack* myAttributesStack; //! < panes stack
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_SearchItemInfo.hxx b/tools/DFBrowser/DFBrowser_SearchItemInfo.hxx
new file mode 100644 (file)
index 0000000..e6e62e8
--- /dev/null
@@ -0,0 +1,60 @@
+// 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 DFBrowser_SearchItemInfo_H
+#define DFBrowser_SearchItemInfo_H
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QVariant>
+#include <QStringList>
+#include <QString>
+
+//! \class DFBrowser_SearchItemInfo
+//! Information of item in search model
+class DFBrowser_SearchItemInfo
+{
+public:
+
+  //! Constructor
+  DFBrowser_SearchItemInfo() {}
+
+  //! Constructor
+  DFBrowser_SearchItemInfo (const QVariant& theIcon, const QString& theName,
+                            const QStringList& thePath, const QString& theSeparator)
+  : myIcon (theIcon), myPath (thePath)
+  { myPathUnited = QString ("%1 \n%2").arg (theName).arg (myPath.join (theSeparator)); }
+
+  //! Destructor
+  virtual ~DFBrowser_SearchItemInfo() {}
+
+  //! Returns the item icon
+  const QVariant& Icon() const { return myIcon; }
+
+  //! Returns path to the item.
+  const QStringList& Path() const { return myPath; }
+
+  //! Returns united path to the item.
+  const QString& PathUnited() const { return myPathUnited; }
+
+private:
+
+  QVariant myIcon; //!< item icon
+  QStringList myPath; //!< item path
+  QString myPathUnited; //!< item name and item path
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_SearchLine.cxx b/tools/DFBrowser/DFBrowser_SearchLine.cxx
new file mode 100644 (file)
index 0000000..0b89cf9
--- /dev/null
@@ -0,0 +1,180 @@
+// 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 <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_SearchLineModel.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+#include <DFBrowser_Module.hxx>
+
+#include <TDocStd_Application.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QStringList>
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QCompleter>
+#include <QIcon>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QStyle>
+
+//! class DFBrowser_LineEdit
+//! Extension of Qt line edit to visualize help text until the line edit control has not been filled yet
+class DFBrowser_LineEdit : public QLineEdit
+{
+public:
+
+  //! Constructor
+  DFBrowser_LineEdit (QWidget* theParent) : QLineEdit(theParent) {}
+
+  //! Destructor
+  virtual ~DFBrowser_LineEdit() {}
+
+  //! Sets text that is shown in line edit it the text of this control is empty
+  //! \param theText a string value
+  void setPlaneHolder (const QString& theText) { myPlaceHolder = theText; }
+
+  //! Draws the line edit context, put plane holder if text is empty
+  //! \param theEvent a paint event
+  virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE
+  {
+    QLineEdit::paintEvent (theEvent);
+    if (!text().isEmpty())
+      return;
+
+    QPainter aPainter (this);
+    QFontMetrics aFontMetrics = fontMetrics();
+    QRect aLineRect = rect();
+    Qt::Alignment anAlignment = QStyle::visualAlignment (layoutDirection(), Qt::AlignLeft);
+
+    QColor aColor = palette().text().color();
+    aColor.setAlpha (128);
+    QPen anOldpen = aPainter.pen();
+    aPainter.setPen (aColor);
+    aLineRect.adjust (4, 4, 0, 0);
+    QString anElidedText = aFontMetrics.elidedText (myPlaceHolder, Qt::ElideRight, aLineRect.width());
+    aPainter.drawText (aLineRect, anAlignment, anElidedText);
+    aPainter.setPen (anOldpen);
+  }
+
+private:
+
+  QString myPlaceHolder; //!< text of filling line edit content if the text is empty
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchLine::DFBrowser_SearchLine (QWidget* theParent)
+: QFrame (theParent)
+{
+  QHBoxLayout* aLayout = new QHBoxLayout (this);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+  aLayout->setSpacing (0);
+
+  myLineControl = new DFBrowser_LineEdit (this);
+  ((DFBrowser_LineEdit*)myLineControl)->setPlaneHolder (QString (tr ("Scanning application ...")));
+  mySearchButton = new QToolButton (this);
+  mySearchButton->setIcon (QIcon (":/icons/search.png"));
+
+  QCompleter* aCompleter = new QCompleter (this);
+  aCompleter->setCaseSensitivity (Qt::CaseInsensitive);
+  myLineControl->setCompleter (aCompleter);
+
+  aLayout->addWidget (myLineControl);
+  aLayout->addWidget (mySearchButton);
+
+  connect (myLineControl, SIGNAL (textChanged (const QString&)), this, SLOT (onTextChanged (const QString&)));
+  connect (myLineControl, SIGNAL (returnPressed()), this, SLOT (onReturnPressed()));
+  connect (mySearchButton, SIGNAL (clicked()), this, SLOT (onSearchButtonClicked()));
+
+  DFBrowser_Window::SetWhiteBackground (this);
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::SetModule (DFBrowser_Module* theModule)
+{
+  DFBrowser_SearchLineModel* aModel = new DFBrowser_SearchLineModel (myLineControl, theModule);
+  myLineControl->completer()->setModel (aModel);
+}
+
+// =======================================================================
+// function : GetModule
+// purpose :
+// =======================================================================
+DFBrowser_Module* DFBrowser_SearchLine::GetModule()
+{
+  DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+  return aModel->GetModule();
+}
+
+// =======================================================================
+// function : SetValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+                                      const QMap<int, QStringList>& theDocumentInfoValues)
+{
+  DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+  aModel->SetValues (theDocumentValues, theDocumentInfoValues);
+
+  QString aFirstValue = !theDocumentInfoValues.empty() ? theDocumentInfoValues.begin().value().first() : "";
+  DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
+  aLineEdit->setPlaneHolder (QString (tr ("Search : %1")).arg (aFirstValue));
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::ClearValues()
+{
+  DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+  aModel->ClearValues();
+
+  DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
+  aLineEdit->setPlaneHolder(QString (tr ("Scanning application ...")));
+}
+
+// =======================================================================
+// function : onTextChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::onTextChanged (const QString& theText)
+{
+  mySearchButton->setIcon (theText.isEmpty() ? QIcon (":/icons/search.png")
+                                             : QIcon (":/icons/search_cancel.png"));
+  emit searchActivated();
+}
+
+// =======================================================================
+// function : onSearchButtonClicked
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::onSearchButtonClicked()
+{
+  if (!Text().isEmpty())
+    SetText (QString());
+}
diff --git a/tools/DFBrowser/DFBrowser_SearchLine.hxx b/tools/DFBrowser/DFBrowser_SearchLine.hxx
new file mode 100644 (file)
index 0000000..9ce3744
--- /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 DFBrowser_SearchLine_H
+#define DFBrowser_SearchLine_H
+
+#include <DFBrowser_SearchLineModel.hxx> // to include DFBrowser_SearchItemInfo
+#include <Standard.hxx>
+#include <TDocStd_Application.hxx>
+#include <TDF_Label.hxx>
+
+#include <QCompleter>
+#include <QFrame>
+#include <QLineEdit>
+
+class DFBrowser_Module;
+class DFBrowser_SearchLineModel;
+
+class QAbstractItemModel;
+class QLineEdit;
+class QToolButton;
+class QStringList;
+
+//! \class DFBrowser_SearchLine
+//! It contains a line edit control with auto completion and search button
+class DFBrowser_SearchLine : public QFrame
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_SearchLine (QWidget* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_SearchLine() Standard_OVERRIDE {}
+
+  //! Creates search line model filled by the module. It is necessary for auto completion of line edit
+  //! \param theModule a current module
+  Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
+  //! Returns the current module
+  Standard_EXPORT DFBrowser_Module* GetModule();
+
+  //! Fills the search line model by OCAF document values
+  //! \param theDocumentValues container of document index to container of entry/attribute name to item information
+  //! \param theDocumentInfoValues container of a document index to entry/attribute name
+  Standard_EXPORT void SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+                                  const QMap<int, QStringList>& theDocumentInfoValues);
+
+  //! Clears cache of values in search line model
+  Standard_EXPORT void ClearValues();
+
+  //! Returns completer model
+  Standard_EXPORT QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
+
+  //! Returns completion completer model
+  Standard_EXPORT QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
+
+  //! Returns the current line edit text
+  QString Text() const { return myLineControl->text(); }
+
+  //! Sets the current text value
+  //! \param theValue a string value
+  void SetText (const QString& theValue) { myLineControl->setText (theValue); }
+
+signals:
+
+  //! Signals that is emitted by text changed in line edit control
+  void searchActivated();
+
+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
+  void onReturnPressed() { myLineControl->completer()->setCompletionPrefix (myLineControl->text()); }
+  //! Set 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
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_SearchLineModel.cxx b/tools/DFBrowser/DFBrowser_SearchLineModel.cxx
new file mode 100644 (file)
index 0000000..052acc7
--- /dev/null
@@ -0,0 +1,201 @@
+// 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 <DFBrowser_SearchLineModel.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QDir>
+#include <QIcon>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchLineModel::DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule)
+: QAbstractTableModel (theParent), myModule (theModule), myRowCount (0)
+{
+}
+
+// =======================================================================
+// function : SetValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+                                           const QMap<int, QStringList>& theDocumentInfoValues)
+{
+  myAdditionalValues = theDocumentValues;
+  myDocumentInfoValues = theDocumentInfoValues;
+
+  myRowCount = 0;
+  for (QMap<int, QStringList>::const_iterator aValuesIt = myDocumentInfoValues.begin();
+       aValuesIt != myDocumentInfoValues.end(); aValuesIt++)
+    myRowCount += aValuesIt.value().size();
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::ClearValues()
+{
+  myAdditionalValues.clear();
+  myDocumentInfoValues.clear();
+  myRowCount = 0;
+}
+
+// =======================================================================
+// function : GetPath
+// purpose :
+// =======================================================================
+QStringList DFBrowser_SearchLineModel::GetPath (const QModelIndex& theIndex) const
+{
+  int aRowInDocument;
+  int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+  if (aDocumentId < 0)
+    return QStringList();
+
+  const QMap<QString, DFBrowser_SearchItemInfo>& anAdditionalValues = myAdditionalValues[aDocumentId];
+  const QStringList& anInfoValues = myDocumentInfoValues[aDocumentId];
+
+  return anAdditionalValues[anInfoValues[aRowInDocument] ].Path();
+}
+
+// =======================================================================
+// function : GetValue
+// purpose :
+// =======================================================================
+QString DFBrowser_SearchLineModel::GetValue (const QModelIndex& theIndex) const
+{
+  int aRowInDocument;
+  int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+  if (aDocumentId < 0)
+    return QString();
+  QString aValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+  return aValue.mid (0, aValue.indexOf (SplitSeparator()));
+}
+
+// =======================================================================
+// function : index
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_SearchLineModel::index (int theRow, int theColumn, const QModelIndex& theParent) const
+{
+  if (!hasIndex (theRow, theColumn, theParent))
+    return QModelIndex();
+  return createIndex (theRow, theColumn);
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_SearchLineModel::data (const QModelIndex& theIndex, int theRole) const
+{
+  switch (theIndex.column())
+  {
+    case 0:
+    {
+      if (theRole == Qt::DisplayRole || theRole == Qt::EditRole || theRole == Qt::ToolTipRole)
+      {
+        int aRowInDocument;
+        int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+        if (aDocumentId < 0)
+          return QVariant();
+        return myDocumentInfoValues[aDocumentId][aRowInDocument];
+      }
+      break;
+    }
+    case 1:
+    {
+      if (theRole == Qt::DecorationRole)
+      {
+        int aRowInDocument;
+        int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+        if (aDocumentId < 0)
+          return QVariant();
+        QString anInfoValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+        QVariant anIcon = myAdditionalValues[aDocumentId][anInfoValue].Icon();
+        if (anIcon.isNull())
+        {
+          QString anAttributeName = anInfoValue.mid (0, anInfoValue.indexOf (SplitSeparator()));
+          anIcon = DFBrowser_Module::GetAttributeInfo (anAttributeName.toUtf8().data(),
+                                                       myModule, DFBrowserPane_ItemRole_Decoration_40x40, 0);
+        }
+        return anIcon;
+      }
+      if (theRole == Qt::SizeHintRole) return QSize (80, 80);
+      break;
+    }
+    case 2:
+    {
+      if (theRole == Qt::DisplayRole || theRole == Qt::EditRole)
+      {
+        int aRowInDocument;
+        int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+        if (aDocumentId < 0)
+          return QVariant();
+        QString anInfoValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+        return myAdditionalValues[aDocumentId][anInfoValue].PathUnited();
+      }
+      break;
+    }
+    default:
+      break;
+  }
+  return QVariant();
+}
+
+// =======================================================================
+// function : emitLayoutChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::EmitLayoutChanged()
+{
+  emit layoutChanged();
+}
+
+// =======================================================================
+// function : getDocumentId
+// purpose :
+// =======================================================================
+int DFBrowser_SearchLineModel::getDocumentId (const int theRow, int& theRowInDocument) const
+{
+  theRowInDocument = 0;
+  int aDocumentId = -1;
+
+  int aCurrentRow = theRow;
+  for (int aValueId = 0, aSize = myDocumentInfoValues.size(); aValueId < aSize; aValueId++)
+  {
+    int aValueIndex = aValueId+1;
+    if (!myDocumentInfoValues.contains (aValueIndex))
+      continue;
+    QStringList aValues = myDocumentInfoValues[aValueIndex];
+    int aValuesSize = aValues.size();
+    if (aCurrentRow < aValuesSize)
+    {
+      aDocumentId = aValueIndex;
+      theRowInDocument= aCurrentRow;
+    }
+    else
+      aCurrentRow = aCurrentRow - aValuesSize;
+  }
+  return aDocumentId;
+}
diff --git a/tools/DFBrowser/DFBrowser_SearchLineModel.hxx b/tools/DFBrowser/DFBrowser_SearchLineModel.hxx
new file mode 100644 (file)
index 0000000..dde4894
--- /dev/null
@@ -0,0 +1,121 @@
+// 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 DFBrowser_SearchLineModel_H
+#define DFBrowser_SearchLineModel_H
+
+#include <DFBrowser_SearchItemInfo.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QMap>
+#include <QStringList>
+#include <QVariant>
+
+class QObject;
+class DFBrowser_Module;
+
+//! \class DFBrowser_SearchLineModel
+//! Table view model filled by OCAF labels and attributes. It contain information in the next form:
+//! <document index> into <document values container>
+//! <document values container> is key(attribute name or label entry) into item information
+//! The model contains 3 columns:
+//! - 0: information text
+//! - 1: icon size is [80, 80]
+//! - 2: information text that contains united path
+class DFBrowser_SearchLineModel : public QAbstractTableModel
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule);
+
+  //! Destructor
+  virtual ~DFBrowser_SearchLineModel() Standard_OVERRIDE {}
+
+  //! Separator as attribute name is divided from the label entry in information text
+  static QString SplitSeparator() { return ": "; }
+
+  //! Returns the current module
+  DFBrowser_Module* GetModule() const { return myModule; }
+
+  //! Fills internal containers by the OCAF values. Updates number of rows value
+  //! \param theDocumentValues container of document index to container of entry/attribute name to item information
+  //! \param theDocumentInfoValues container of a document index to entry/attribute name
+  Standard_EXPORT void SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+                                  const QMap<int, QStringList>& theDocumentInfoValues);
+
+  //! Clears cache of values
+  Standard_EXPORT void ClearValues();
+
+  //! Returns path to attribute or label element of OCAF by the index.
+  //! \param theIndex a tree model index
+  Standard_EXPORT QStringList GetPath (const QModelIndex& theIndex) const;
+
+  //! Returns value(attribute name or label entry) of OCAF by the index
+  Standard_EXPORT QString GetValue (const QModelIndex& theIndex) const;
+
+  //! Emits the layoutChanged signal from outside of this class
+  Standard_EXPORT void EmitLayoutChanged();
+
+  //! Creates new model index
+  //! \param theRow the index row position
+  //! \param theColummn the index column position
+  //! \param theParent the parent index
+  //! \return the model index
+  Standard_EXPORT virtual QModelIndex index (int theRow, int theColumn,
+                                             const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+  //! 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.
+  //! \param theParent a parent model index
+  //! \return the number of rows
+
+  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; }
+
+protected:
+
+  //! Returns document index by a row index in table model
+  //! \param theRow a row index of a QModelIndex
+  //! \param theRowInDocument an output index, to obtain information from myDocumentInfoValues
+  int getDocumentId (const int theRow, int& theRowInDocument) const;
+
+private:
+
+  DFBrowser_Module* myModule; //!< the current module
+   //! a document index to container of entry/attribute name to item information
+  QMap<int, QMap<QString, DFBrowser_SearchItemInfo> > myAdditionalValues;
+  QMap<int, QStringList> myDocumentInfoValues; //!< a document index to entry/attribute name
+  int myRowCount; //!< number of rows in the model: summ of row counts in all documents
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_SearchView.cxx b/tools/DFBrowser/DFBrowser_SearchView.cxx
new file mode 100644 (file)
index 0000000..6da5a5f
--- /dev/null
@@ -0,0 +1,118 @@
+// 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 <DFBrowser_SearchView.hxx>
+
+#include <DFBrowser_HighlightDelegate.hxx>
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_SearchLineModel.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QAbstractProxyModel>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QTableView>
+#include <QWidget>
+
+const int DEFAULT_COLUMN_WIDTH = 500;
+const int DEFAULT_ICON_SIZE = 40;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchView::DFBrowser_SearchView (QWidget* theParent)
+: QObject (theParent)
+{
+  myMainWindow = new QWidget (theParent);
+  QGridLayout* aLayout = new QGridLayout (myMainWindow);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+
+  myTableView = new QTableView (myMainWindow);
+  myTableView->verticalHeader()->setVisible (false);
+  myTableView->verticalHeader()->setDefaultSectionSize (DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
+  myTableView->setIconSize (QSize (DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
+  myTableView->horizontalHeader()->setVisible (false);
+  myTableView->horizontalHeader()->setStretchLastSection (true);
+
+  myTableView->viewport()->setAttribute (Qt::WA_Hover);
+  myTableView->setItemDelegate (new DFBrowser_HighlightDelegate (myTableView));
+
+  aLayout->addWidget (myTableView);
+
+  DFBrowser_Window::SetWhiteBackground (myTableView);
+  myTableView->setGridStyle (Qt::NoPen);
+}
+
+// =======================================================================
+// function : InitModels
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::InitModels()
+{
+  QAbstractItemModel* aModel = mySearchLine->GetCompletionModel();
+  myTableView->setModel (aModel);
+  myTableView->setColumnWidth (0, 0); // to hide column
+  myTableView->setColumnWidth (1, DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
+
+  QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel);
+  myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
+  myTableView->setSelectionModel (aSelectionModel);
+  connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+          this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+  connect (myTableView, SIGNAL (doubleClicked (const QModelIndex&)),
+          this, SLOT (onTableDoubleClicked (const QModelIndex&)));
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::onTableSelectionChanged (const QItemSelection& theSelected,
+                                                   const QItemSelection&)
+{
+  QModelIndexList aSelectedIndices = theSelected.indexes();
+  QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 2);
+  if (!aSelectedIndex.isValid())
+    return;
+  QAbstractProxyModel* aTableModel = dynamic_cast<QAbstractProxyModel*> (myTableView->model());
+  if (!aTableModel)
+    return;
+  DFBrowser_SearchLineModel* aSourceModel = dynamic_cast<DFBrowser_SearchLineModel*> (aTableModel->sourceModel());
+  if (!aSourceModel)
+    return;
+
+  QModelIndex aSourceSelectedIndex = aTableModel->mapToSource(aSelectedIndex);
+  emit pathSelected(aSourceModel->GetPath (aSourceSelectedIndex), aSourceModel->GetValue (aSourceSelectedIndex));
+}
+
+// =======================================================================
+// function : onTableDoubleClicked
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::onTableDoubleClicked (const QModelIndex& theIndex)
+{
+  QAbstractProxyModel* aTableModel = dynamic_cast<QAbstractProxyModel*> (myTableView->model());
+  if (!aTableModel)
+    return;
+  DFBrowser_SearchLineModel* aSourceModel = dynamic_cast<DFBrowser_SearchLineModel*> (aTableModel->sourceModel());
+  if (!aSourceModel)
+    return;
+
+  QModelIndex aSourceSelectedIndex = aTableModel->mapToSource(theIndex);
+  emit pathDoubleClicked (aSourceModel->GetPath (aSourceSelectedIndex), aSourceModel->GetValue (aSourceSelectedIndex));
+}
diff --git a/tools/DFBrowser/DFBrowser_SearchView.hxx b/tools/DFBrowser/DFBrowser_SearchView.hxx
new file mode 100644 (file)
index 0000000..5126b5d
--- /dev/null
@@ -0,0 +1,86 @@
+// 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 DFBrowser_SearchView_H
+#define DFBrowser_SearchView_H
+
+#include <DFBrowser_SearchLine.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+
+class DFBrowser_SearchLine;
+class QTableView;
+class QWidget;
+
+//! \class DFBrowser_SearchView
+//! Container of search result. It has a table of values
+class DFBrowser_SearchView : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_SearchView (QWidget* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_SearchView() Standard_OVERRIDE {}
+
+  //! Returns search parent control
+  QWidget* GetControl() const { return myMainWindow; }
+
+  //! Sets search line to connect to the search line completion model
+  void SetSearchLine (DFBrowser_SearchLine* theSearchLine) { mySearchLine = theSearchLine; }
+
+  //! Fills the table by values of search line completion model. The zero column of the table is hidden,
+  //! so it visualizes values of 1st and 2nd columns of this model. It creates selection model and connects
+  //! to selectionChanged and doubleClicked signals
+  Standard_EXPORT void InitModels();
+
+  //! Resets search line
+  void Reset() { mySearchLine->SetText (""); }
+
+signals:
+
+  //! Signal about selecting of an item in the view.
+  //! \param thePath path to the selected item (e.g. 0, 0:1, 0:1:1)
+  //! \param theValue value of the selected item (e.g. TDataStd_Name)
+  void pathSelected (const QStringList& thePath, const QString& theValue);
+
+  //! Signal about double click on an item in the view.
+  //! \param thePath path to the selected item (e.g. 0, 0:1, 0:1:1)
+  //! \param theValue value of the selected item (e.g. TDataStd_Name)
+  void pathDoubleClicked (const QStringList& thePath, const QString& theValue);
+
+protected slots:
+
+  //! Listens selection change and emits the pathSelected signal
+  //! \param theSelected selected items
+  //! \param theDeselected deselected items
+  void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+  //! Listens double click signal on table view
+  //! \theIndex a model index of double clicked item
+  void onTableDoubleClicked (const QModelIndex& theIndex);
+
+private:
+
+  QWidget* myMainWindow; //!< control where table view is placed
+  QTableView* myTableView; //!< table view to visualize search values
+  DFBrowser_SearchLine* mySearchLine; //!< search line to have access to search model completor
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Shortcut.cxx b/tools/DFBrowser/DFBrowser_Shortcut.cxx
new file mode 100644 (file)
index 0000000..2fb7f3a
--- /dev/null
@@ -0,0 +1,53 @@
+// 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 <DFBrowser_Shortcut.hxx>
+
+#include <DFBrowser_Module.hxx>
+
+#include <QApplication>
+#include <QKeyEvent>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Shortcut::DFBrowser_Shortcut (QObject* theParent)
+: QObject (theParent), myModule (0)
+{
+  qApp->installEventFilter (this);
+}
+
+// =======================================================================
+// function : eventFilter
+// purpose :
+// =======================================================================
+bool DFBrowser_Shortcut::eventFilter (QObject* theObject, QEvent* theEvent)
+{
+  if (!myModule || theEvent->type() != QEvent::KeyRelease)
+    return QObject::eventFilter (theObject, theEvent);
+
+  QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*> (theEvent);
+  switch (aKeyEvent->key())
+  {
+    case Qt::Key_F5:
+    {
+      myModule->UpdateTreeModel();
+      return true;
+    }
+    default: break;
+  }
+  return QObject::eventFilter (theObject, theEvent);
+}
diff --git a/tools/DFBrowser/DFBrowser_Shortcut.hxx b/tools/DFBrowser/DFBrowser_Shortcut.hxx
new file mode 100644 (file)
index 0000000..26c0d81
--- /dev/null
@@ -0,0 +1,55 @@
+// 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 DFBrowser_Shortcut_H
+#define DFBrowser_Shortcut_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+
+class DFBrowser_Module;
+class QEvent;
+
+//! \class DFBrowser_Shortcut
+//! Listens application KeyRelease event. Processes key event:
+//! - <Key_F5>: updates tree view model
+class DFBrowser_Shortcut : public QObject
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_Shortcut (QObject* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_Shortcut() {}
+
+  //! Sets the current module
+  //! \param theModule a module
+  void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+  //! Processes key release event to update view model, otherwise do usual QObject functionality
+  Standard_EXPORT virtual bool eventFilter (QObject *theObject, QEvent* theEvent) Standard_OVERRIDE;
+
+private:
+  DFBrowser_Module* myModule; //!< the current module
+};
+
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Thread.cxx b/tools/DFBrowser/DFBrowser_Thread.cxx
new file mode 100644 (file)
index 0000000..757ff8a
--- /dev/null
@@ -0,0 +1,152 @@
+// 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 <DFBrowser_Thread.hxx>
+#include <DFBrowser_ThreadItemSearch.hxx>
+#include <DFBrowser_ThreadItemUsedShapesMap.hxx>
+#include <DFBrowser_TreeLevelLine.hxx>
+#include <DFBrowser_SearchLine.hxx>
+
+#include <DFBrowser_Window.hxx>
+
+#include <QThread>
+
+//! \class DFBrowser_QThread
+//! Internal class to cover QThread in order to process ThreadItem.
+class DFBrowser_QThread : public QThread
+{
+public:
+
+  //! Constructor
+  DFBrowser_QThread (QObject* theParent) : QThread (theParent), myItem (0) {}
+
+  //! Destructor
+  virtual ~DFBrowser_QThread() Standard_OVERRIDE {}
+
+  //! Sets thread item to be processed
+  //! \param theItem a thread item
+  void setItem (DFBrowser_ThreadItem* theItem) { myItem = theItem; }
+
+  //! Returns the current processing thread item
+  DFBrowser_ThreadItem* getItem() const { return myItem; }
+
+protected:
+
+  //! Starts thread item
+  virtual void run() Standard_OVERRIDE
+  {
+    if (myItem)
+      myItem->Run();
+  }
+
+private:
+
+  DFBrowser_ThreadItem* myItem;
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Thread::DFBrowser_Thread (DFBrowser_Window* theWindow)
+: QObject (theWindow), myPostponedItem (0), myIsFinishProcessing (false)
+{
+  DFBrowser_SearchLine* aSearchLine = theWindow->GetTreeLevelLine()->GetSearchLine();
+  myItems.append (new DFBrowser_ThreadItemSearch(aSearchLine));
+  myItems.append (new DFBrowser_ThreadItemUsedShapesMap());
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::SetModule (DFBrowser_Module* theModule)
+{
+  for (int anItemId = 0, aSize = myItems.size(); anItemId < aSize; anItemId++)
+  {
+    DFBrowser_ThreadItemUsedShapesMap* aShapesItem = dynamic_cast<DFBrowser_ThreadItemUsedShapesMap*> (myItems[anItemId]);
+    if (aShapesItem)
+      aShapesItem->SetModule (theModule);
+  }
+}
+
+// =======================================================================
+// function : ProcessApplication
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::ProcessApplication()
+{
+  for (int anItemId = 0, aSize = myItems.size(); anItemId < aSize; anItemId++)
+    startThread (myItems[anItemId]);
+}
+
+// =======================================================================
+// function : startThread
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::startThread (DFBrowser_ThreadItem* theItem)
+{
+  DFBrowser_QThread* aThread = new DFBrowser_QThread (this);
+  aThread->setItem (theItem);
+  aThread->start();
+  connect (aThread, SIGNAL (finished()), this, SLOT (onFinished()), Qt::QueuedConnection);
+  myStartedThreads.append (aThread);
+}
+
+// =======================================================================
+// function : TerminateThread
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::TerminateThread()
+{
+  for (int aThreadsId = 0, aCount = myStartedThreads.size(); aThreadsId < aCount; aThreadsId++)
+  {
+    QThread* aThread = myStartedThreads[aThreadsId];
+    if (aThread->isRunning())
+      aThread->terminate();
+  }
+}
+
+// =======================================================================
+// function : onFinished
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::onFinished()
+{
+  DFBrowser_QThread* aThread = (DFBrowser_QThread*)(sender());
+  if (myIsFinishProcessing)
+  {
+    // if thread send signal when other finished signal is processed
+    if (aThread)
+      myPostponedItem = aThread->getItem();
+    return;
+  }
+
+  myIsFinishProcessing = true;
+  if (aThread)
+  {
+    myStartedThreads.removeAll (aThread);
+    DFBrowser_ThreadItem* anItem = aThread->getItem();
+    if (anItem)
+      anItem->ApplyValues();
+  }
+
+  myIsFinishProcessing = false;
+  if (myPostponedItem)
+  {
+    myPostponedItem->ApplyValues();
+    myPostponedItem = 0;
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_Thread.hxx b/tools/DFBrowser/DFBrowser_Thread.hxx
new file mode 100644 (file)
index 0000000..56cf9c6
--- /dev/null
@@ -0,0 +1,78 @@
+// 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 DFBrowser_Thread_H
+#define DFBrowser_Thread_H
+
+#include <Standard.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QList>
+#include <QObject>
+
+class DFBrowser_Module;
+class DFBrowser_ThreadItem;
+class DFBrowser_Window;
+
+class QThread;
+
+//! /class DFBrowser_Thread
+//! Starts algorithm item in a separate thread and perform some functionality by the algorithm(thread) is finished
+class DFBrowser_Thread : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_Thread (DFBrowser_Window* theWindow);
+
+  //! Destructor
+  virtual ~DFBrowser_Thread() {}
+
+  //! Sets module to the started thread items
+  //! \param theModule a current module
+  Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
+  //! Starts all candidate thread items
+  Standard_EXPORT void ProcessApplication();
+
+  //! Terminates all started threads.
+  Standard_EXPORT void TerminateThread();
+
+protected:
+
+  //! Creates new Qt thread and starts the item. Connects to finished signal of thread.
+  //! \param theItem a thread item
+  void startThread (DFBrowser_ThreadItem* theItem);
+
+protected slots:
+
+  //! Removes finished thread from the thread items and apply values of this thread
+  //! If this signal is come when another thread is processed, the current thread is stored in a cache and
+  //! is processed after the previous thread is processed.
+  void onFinished();
+
+private:
+
+  QList<DFBrowser_ThreadItem*> myItems; //!< candidates to be processed in a thread
+  QList<QThread*> myStartedThreads; //!< container of started threads
+  DFBrowser_ThreadItem* myPostponedItem; //!< currently processed item in onFinished()
+  bool myIsFinishProcessing; //!< blocking state if onFinished() is started but has not been finished yet
+};
+
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ThreadItem.hxx b/tools/DFBrowser/DFBrowser_ThreadItem.hxx
new file mode 100644 (file)
index 0000000..c066ca8
--- /dev/null
@@ -0,0 +1,42 @@
+// 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 DFBrowser_ThreadItem_H
+#define DFBrowser_ThreadItem_H
+
+#include <Standard_Macro.hxx>
+
+//! \class DFBrowser_ThreadItem
+//! An abstract interface for candidates to be processed in a separate thread.
+//! To do this, new thread item should inherit this interface and be started in DFBrowser_Thread.
+class DFBrowser_ThreadItem
+{
+public:
+
+  //! Constructor
+  DFBrowser_ThreadItem() {}
+
+  //! Destructor
+  virtual ~DFBrowser_ThreadItem() {}
+
+  //! Algorithm of this item work. It will be performed only once
+  virtual void Run() = 0;
+
+  //! Applying values accepted by algorithm
+  virtual void ApplyValues() = 0;
+};
+
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ThreadItemSearch.cxx b/tools/DFBrowser/DFBrowser_ThreadItemSearch.cxx
new file mode 100644 (file)
index 0000000..fd973dc
--- /dev/null
@@ -0,0 +1,174 @@
+// 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 <DFBrowser_ThreadItemSearch.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QDir>
+
+// =======================================================================
+// function : Run
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::Run()
+{
+  DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (mySearchLine->GetModule()->GetOCAFViewModel());
+  Handle(TDocStd_Application) anApplication = aModel->GetTDocStdApplication();
+  if (anApplication.IsNull())
+    return;
+
+  myDocumentValues.clear();
+  myDocumentInfoValues.clear();
+
+  //#define REQUIRE_OCAF_REVIEW:25 : start
+  QMap<QString, DFBrowser_SearchItemInfo> anAdditionalValues;
+  QStringList anInfoValues;
+  QStringList aCurrentPath;
+  for (Standard_Integer aDocId = 1, aNbDoc = anApplication->NbDocuments(); aDocId <= aNbDoc; aDocId++)
+  {
+    Handle(TDocStd_Document) aDocument;
+    anApplication->GetDocument (aDocId, aDocument);
+    if (aDocument.IsNull())
+      continue;
+
+    anAdditionalValues.clear();
+    anInfoValues.clear();
+    aCurrentPath.clear();
+    getLabelLines (aDocument->Main().Root(), aCurrentPath, anAdditionalValues, anInfoValues);
+
+    myDocumentValues[aDocId] = anAdditionalValues;
+    myDocumentInfoValues[aDocId] = anInfoValues;
+  }
+  //#define REQUIRE_OCAF_REVIEW:25 : end
+}
+
+// =======================================================================
+// function : ApplyValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::ApplyValues()
+{
+  mySearchLine->SetValues (myDocumentValues, myDocumentInfoValues);
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::ClearValues (DFBrowser_SearchLine* theSearchLine)
+{
+  theSearchLine->ClearValues();
+}
+
+// =======================================================================
+// function : getLabelLines
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::getLabelLines (const TDF_Label& theLabel, QStringList& theCurrentPath,
+                                                QMap<QString, DFBrowser_SearchItemInfo >& theValues,
+                                                QStringList& theInfoValues)
+{
+  addLabel (theLabel, theCurrentPath, theValues, theInfoValues);
+  theCurrentPath.append (DFBrowserPane_Tools::GetEntry (theLabel).ToCString());
+
+  int anId = 0;
+  for (TDF_AttributeIterator anAttrIt (theLabel); anAttrIt.More(); anAttrIt.Next(), anId++)
+    addAttribute(anAttrIt.Value(), theCurrentPath, theValues, theInfoValues);
+
+  for (TDF_ChildIterator aChildIt (theLabel); aChildIt.More(); aChildIt.Next())
+    getLabelLines(aChildIt.Value(), theCurrentPath, theValues, theInfoValues);
+
+  theCurrentPath.removeLast();
+}
+
+// =======================================================================
+// function : addLabel
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::addLabel (const TDF_Label& theLabel, const QStringList& theCurrentPath,
+                                           QMap<QString, DFBrowser_SearchItemInfo>& theValues,
+                                           QStringList& theInfoValues)
+{
+  QString anEntry = DFBrowserPane_Tools::GetEntry (theLabel).ToCString();
+  if (!theValues.contains (anEntry))
+  {
+    theInfoValues.append (anEntry);
+    theValues[anEntry] = DFBrowser_SearchItemInfo (DFBrowser_Tools::GetLabelIcon (theLabel, false),
+                                                   anEntry, theCurrentPath, QDir::separator());
+  }
+}
+
+// =======================================================================
+// function : addAttribute
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::addAttribute (const Handle(TDF_Attribute)& theAttribute,
+                                               const QStringList& theCurrentPath,
+                                               QMap<QString, DFBrowser_SearchItemInfo >& theValues,
+                                               QStringList& theInfoValues)
+{
+  Standard_CString anAttributeKind = theAttribute->DynamicType()->Name();
+  // add element of attribute kind
+  QString anAttributeName = QString ("%1%2%3").arg (anAttributeKind)
+                            .arg (DFBrowser_SearchLineModel::SplitSeparator())
+                            .arg (DFBrowserPane_Tools::GetEntry (theAttribute->Label()).ToCString());
+
+  if (!theInfoValues.contains (anAttributeName))
+  {
+    theInfoValues.append (anAttributeName);
+    theValues[anAttributeName] = DFBrowser_SearchItemInfo (QVariant(), anAttributeName, theCurrentPath,
+                                                           QDir::separator());
+  }
+
+  // add element of attribute value, e.g. Name or Comment string
+  QString anAttributeValue;
+  if (anAttributeKind == STANDARD_TYPE (TDataStd_Name)->Name())
+  {
+    Handle(TDataStd_Name) anAttribute = Handle(TDataStd_Name)::DownCast (theAttribute);
+    anAttributeValue = DFBrowserPane_Tools::ToString (anAttribute->Get());
+  }
+  else if (anAttributeKind == STANDARD_TYPE (TDataStd_Comment)->Name())
+  {
+    Handle(TDataStd_Comment) anAttribute = Handle(TDataStd_Comment)::DownCast (theAttribute);
+    anAttributeValue = DFBrowserPane_Tools::ToString (anAttribute->Get());
+  }
+  else
+    return;
+
+  if (anAttributeValue == "")
+    return;
+
+  // using attribute value in the name
+  QString anAttributeValueExt = QString ("%1%2%3").arg (anAttributeValue)
+                                          .arg (DFBrowser_SearchLineModel::SplitSeparator())
+                                          .arg (DFBrowserPane_Tools::GetEntry (theAttribute->Label()).ToCString());
+  if (!theInfoValues.contains (anAttributeValueExt))
+  {
+    theInfoValues.append (anAttributeValueExt);
+    theValues[anAttributeValueExt] = DFBrowser_SearchItemInfo (QVariant(), anAttributeValueExt,
+                                                               theCurrentPath, QDir::separator());
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_ThreadItemSearch.hxx b/tools/DFBrowser/DFBrowser_ThreadItemSearch.hxx
new file mode 100644 (file)
index 0000000..6640089
--- /dev/null
@@ -0,0 +1,90 @@
+// 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 DFBrowser_ThreadItemSearch_H
+#define DFBrowser_ThreadItemSearch_H
+
+#include <DFBrowser_ThreadItem.hxx>
+#include <DFBrowser_SearchLineModel.hxx> // to include DFBrowser_SearchItemInfo
+#include <Standard.hxx>
+#include <TDF_Label.hxx>
+
+#include <QAbstractItemModel>
+#include <QMap>
+#include <QStringList>
+
+class DFBrowser_Module;
+class DFBrowser_SearchLine;
+class DFBrowser_SearchLineModel;
+
+//! \class DFBrowser_ThreadItemSearch
+//! Iterates by OCAF application to fill internal containers with information necessary for search
+class DFBrowser_ThreadItemSearch : public DFBrowser_ThreadItem
+{
+public:
+
+  //! Constructor
+  DFBrowser_ThreadItemSearch (DFBrowser_SearchLine* theSearchLine) : mySearchLine (theSearchLine) {}
+
+  //! Destructor
+  virtual ~DFBrowser_ThreadItemSearch() {}
+
+  //! Obtains the curent OCAF application from the current module, iterates by all documents to fill
+  //! internal containers for search functionality
+  Standard_EXPORT virtual void Run() Standard_OVERRIDE;
+
+  //! Set filled containers into search line
+  Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
+
+  //! Clear search line values
+  Standard_EXPORT static void ClearValues (DFBrowser_SearchLine* theSearchLine);
+
+private:
+
+  //! Fills information containers by iterating through sub-labels and attributes
+  //! The method is recursive by labels.
+  //! \parm theLabel a current label, the label information is got and children and attributes information
+  //! \param theCurrentPath it contains the current path to the label (stores in container)
+  //! \param theValues container of document item values
+  //! \param theInfoValues container of document item values
+  void getLabelLines (const TDF_Label& theLabel, QStringList& theCurrentPath,
+                      QMap<QString, DFBrowser_SearchItemInfo >& theValues, QStringList& theInfoValues);
+
+  //! Adds label information into container: search will be performed by label entry
+  //! \parm theLabel a current label
+  //! \param theCurrentPath it contains the current path to the label (stores in container)
+  //! \param theValues container of document item values
+  //! \param theInfoValues container of document item values
+  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
+  //! \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
+  //! \param theInfoValues container of document item values
+  void addAttribute (const Handle(TDF_Attribute)& theAttribute, const QStringList& theCurrentPath,
+                     QMap<QString, DFBrowser_SearchItemInfo>& theValues, QStringList& theInfoValues);
+
+private:
+
+  DFBrowser_SearchLine* mySearchLine; //!< class that should be filled by apply of the thread item
+  //!< a document index to container of entry/attribute name to item information
+  QMap<int, QMap<QString, DFBrowser_SearchItemInfo > > myDocumentValues;
+  QMap<int, QStringList> myDocumentInfoValues; //!< a document index to entry/attribute name
+};
+
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.cxx b/tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.cxx
new file mode 100644 (file)
index 0000000..4b5eb78
--- /dev/null
@@ -0,0 +1,222 @@
+// 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 <DFBrowser_ThreadItemUsedShapesMap.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+
+#include <DFBrowserPane_TNamingUsedShapes.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
+#include <TNaming_PtrRefShape.hxx>
+#include <TNaming_RefShape.hxx>
+#include <TNaming_UsedShapes.hxx>
+
+#include <Standard_Type.hxx>
+#include <TDocStd_Document.hxx>
+
+// =======================================================================
+// function : Run
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::Run()
+{
+  if (!myModule)
+    return;
+  DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+  if (!aDFBrowserModel)
+    return;
+
+  Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
+  if (anApplication.IsNull())
+    return;
+
+  for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
+  {
+    Handle(TDocStd_Document) aDocument;
+    anApplication->GetDocument (aDocId, aDocument);
+    if (aDocument.IsNull())
+      continue;
+
+    TDF_Label aLabel = aDocument->Main().Root();
+
+    Handle(TNaming_UsedShapes) anAttribute;
+    if (!aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
+      continue;
+
+    std::list<TCollection_AsciiString> aReferences;
+    findReferences (anAttribute, aReferences);
+    if (!aReferences.empty())
+      myAttributeRefs.Bind (anAttribute, aReferences);
+  }
+}
+
+// =======================================================================
+// function : ApplyValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::ApplyValues()
+{
+ if (myAttributeRefs.IsEmpty())
+    return;
+
+  DFBrowserPane_AttributePaneAPI* aPane = myModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
+  if (aPane)
+  {
+    DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
+    aUsedShapesPane->SetSortedReferences (myAttributeRefs);
+  }
+  // update
+  DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+  for (NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> >::Iterator aRefIt (myAttributeRefs);
+       aRefIt.More(); aRefIt.Next())
+  {
+    TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex
+                                                   (aDFBrowserModel->FindIndexByAttribute (aRefIt.Key()));
+    if (anItemBase)
+      anItemBase->Init();
+  }
+  // clear cache
+  myAttributeRefs.Clear();
+}
+
+// =======================================================================
+// function : ClearSortedReferences
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::ClearSortedReferences (DFBrowser_Module* theModule)
+{
+  DFBrowserPane_AttributePaneAPI* aPane = theModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
+  if (!aPane)
+    return;
+
+  DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
+  aUsedShapesPane->ClearSortedReferences();
+
+  // update tree item state
+  DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (theModule->GetOCAFViewModel());
+  if (!aDFBrowserModel)
+    return;
+  Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
+  if (anApplication.IsNull())
+    return;
+
+  for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
+  {
+    Handle(TDocStd_Document) aDocument;
+    anApplication->GetDocument (aDocId, aDocument);
+    if (aDocument.IsNull())
+      continue;
+    TDF_Label aLabel = aDocument->Main().Root();
+    Handle(TNaming_UsedShapes) anAttribute;
+    if (aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
+    {
+      TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(
+                                                              aDFBrowserModel->FindIndexByAttribute (anAttribute));
+      if (anItemBase)
+        anItemBase->Init();
+    }
+  }
+}
+
+// =======================================================================
+// function : isLessThan
+// purpose :
+// =======================================================================
+bool DFBrowser_ThreadItemUsedShapesMap::isLessThan (const QStringList& theLeft, const QStringList& theRight)
+{
+  int aState = 1; //! where 0 - less, 1 - equal, 2 - larger
+  int aLeftSize = theLeft.size();
+  int aRightSize = theRight.size();
+
+  for (int anItemId = 0; anItemId < aRightSize && anItemId < aLeftSize && aState == 1; anItemId++)
+  {
+    int aRightId = theRight[anItemId].toInt();
+    int aLeftId = theLeft[anItemId].toInt();
+    if (aLeftId == aRightId)
+      continue;
+    else if (aLeftId < aRightId)
+      aState = 0; // less
+    else if (aLeftId > aRightId)
+      aState = 2; // less
+  }
+  if (aState == 1)
+  { // equal in similar parts
+    if (aLeftSize < aRightSize)
+      aState = 0;
+    else if (aLeftSize > aRightSize)
+      aState = 2;
+  }
+  return aState == 0;
+}
+
+// =======================================================================
+// function : addValue
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::addValue (const TCollection_AsciiString& theEntry,
+                                                  QList<QPair<TCollection_AsciiString, QStringList > >& theEntries)
+{
+  QStringList aSplit = QString (theEntry.ToCString()).split (":");
+
+  int aLessIndex = -1;
+  bool isInserted = false;
+  // looking for nearest smaller value from the end of the list
+  for (int anEntryId = theEntries.size() - 1; anEntryId >= 0 && !isInserted; anEntryId--)
+  {
+    if (isLessThan(aSplit, theEntries[anEntryId].second))
+      aLessIndex = anEntryId;
+    else
+    {
+      // if less than was found and now, the entry is greater than current entry
+      if (aLessIndex != -1)
+      {
+        theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
+        isInserted = true;
+      }
+      break;
+    }
+  }
+  if (!isInserted)
+  {
+    if (aLessIndex != -1) // less than all, insert at this position
+      theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
+    else
+      theEntries.append (qMakePair (theEntry, aSplit));
+  }
+}
+
+// =======================================================================
+// function : findReferences
+// purpose :
+// =======================================================================
+//#define REQUIRE_OCAF_REVIEW:26 : start
+void DFBrowser_ThreadItemUsedShapesMap::findReferences (Handle(TDF_Attribute) theAttribute,
+                                                        std::list<TCollection_AsciiString>& theReferences)
+{
+  Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
+
+  QList<QPair<TCollection_AsciiString, QStringList> > anEntries;
+  for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aDataIt(anAttribute->Map()); aDataIt.More(); aDataIt.Next())
+    addValue(DFBrowserPane_Tools::GetEntry (aDataIt.Value()->Label()), anEntries);
+
+  for (QList<QPair<TCollection_AsciiString, QStringList> >::const_iterator anEntryIt = anEntries.begin();
+       anEntryIt != anEntries.end(); anEntryIt++)
+    theReferences.push_back (anEntryIt->first);
+}
+//#define REQUIRE_OCAF_REVIEW:26 : end
diff --git a/tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.hxx b/tools/DFBrowser/DFBrowser_ThreadItemUsedShapesMap.hxx
new file mode 100644 (file)
index 0000000..d363589
--- /dev/null
@@ -0,0 +1,81 @@
+// 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 DFBROWSER_ThreadItemUsedShapesMap_H
+#define DFBROWSER_ThreadItemUsedShapesMap_H
+
+#include <DFBrowser_ThreadItem.hxx>
+#include <NCollection_DataMap.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QStringList>
+#include <QPair>
+
+class DFBrowser_Module;
+
+//! \class DFBrowser_ThreadItemUsedShapesMap
+//! Collects and sorts map values of TNaming_UsedShape attributes. Applies values to the OCAF tree view model
+class DFBrowser_ThreadItemUsedShapesMap : public DFBrowser_ThreadItem
+{
+public:
+
+  //! Constructor
+  DFBrowser_ThreadItemUsedShapesMap() : myModule (0) {}
+
+  //! Destructor
+  virtual ~DFBrowser_ThreadItemUsedShapesMap() {}
+
+  //! Sets the current module
+  void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+  //! Iterates by application documents and for TNaming_UsedShape attribute collects container of sorted values.
+  Standard_EXPORT virtual void Run() Standard_OVERRIDE;
+
+  //! Initialize tree view model of OCAF by internal container of sorted values.
+  Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
+
+  //! Set empty cache into tree view model of OCAF. Calls Init of these item by usual values (not sorted)
+  Standard_EXPORT static void ClearSortedReferences (DFBrowser_Module* theModule);
+
+private:
+
+  //! Collects sorted values of the attribute if the attribute has TNaming_UsedShape type
+  //! \param theAttribute a processed attribute
+  //! \param theReferences a output container of sorted references
+  void findReferences (Handle(TDF_Attribute) theAttribute, std::list<TCollection_AsciiString>& theReferences);
+
+  //! Checks whether the left path is less than the right path
+  //! \param theLeft path to label
+  //! \param theRight path to label
+  //! \returns true if the left path is less(not equal) than right path
+  static bool isLessThan (const QStringList& theLeft, const QStringList& theRight);
+
+  //! Insert entry into container of entries using sorting. It is split by ":" separator to perform soring
+  //! \param theEntry a label entry
+  //! \param theEntries a result container
+  void addValue (const TCollection_AsciiString& theEntry, QList<QPair<TCollection_AsciiString, QStringList > >& theEntries);
+
+private:
+
+  DFBrowser_Module* myModule; //!< the current module
+  NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> > myAttributeRefs; //!< sorted references
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_Tools.cxx b/tools/DFBrowser/DFBrowser_Tools.cxx
new file mode 100644 (file)
index 0000000..71a57d0
--- /dev/null
@@ -0,0 +1,105 @@
+// 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 <DFBrowser_Tools.hxx>
+
+#include <DFBrowser_ItemBase.hxx>
+
+#include <DFBrowserPane_AttributePaneCreator.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Tool.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <Standard_GUID.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_Name.hxx>
+
+#include <QColor>
+#include <QDir>
+#include <QPalette>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:27
+
+namespace DFBrowser_Tools
+{
+  // =======================================================================
+  // function : IsEmptyLabel
+  // purpose :
+  // =======================================================================
+  bool IsEmptyLabel (const TDF_Label& theLabel)
+  {
+    if (theLabel.IsNull())
+      return true;
+
+    if (theLabel.IsRoot())
+      return false;
+
+    if (theLabel.NbAttributes() > 0)
+      return false;
+
+    for (TDF_ChildIterator aChildIt (theLabel); aChildIt.More(); aChildIt.Next())
+    {
+      if (!IsEmptyLabel (aChildIt.Value()))
+        return false;
+    }
+    return true;
+  }
+
+  // =======================================================================
+  // function : GetLabelInfo
+  // purpose :
+  // =======================================================================
+  QString GetLabelInfo (const TDF_Label& theLabel, const bool isUseShortInfo)
+  {
+    QString aValue = DFBrowserPane_Tools::GetEntry (theLabel).ToCString();
+    if (!isUseShortInfo)
+      return aValue;
+
+    Handle(TDataStd_Name) aName;
+    if (!theLabel.FindAttribute (TDataStd_Name::GetID(), aName))
+      return aValue;
+
+    aValue += " ";
+    aValue += DFBrowserPane_Tools::ToString (aName->Get());
+
+    return aValue;
+  }
+
+
+  enum DFBrowser_IconType
+  {
+    DFBrowser_IconType_16x16,
+    DFBrowser_IconType_40x40
+  };
+  static QMap<DFBrowser_IconType, QIcon> MyLabelIcons;
+
+  // =======================================================================
+  // function : GetLabelIcon
+  // purpose :
+  // =======================================================================
+  QIcon GetLabelIcon (const TDF_Label& theLabel, bool isStandard16x16)
+  {
+    (void)theLabel;
+    if (MyLabelIcons.empty())
+    {
+      MyLabelIcons[DFBrowser_IconType_16x16] = QIcon (":/icons/label_folder_16x16.png");
+      MyLabelIcons[DFBrowser_IconType_40x40] = QIcon (":/icons/label_folder_40x40.png");
+    }
+    return MyLabelIcons[isStandard16x16 ? DFBrowser_IconType_16x16 : DFBrowser_IconType_40x40];
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_Tools.hxx b/tools/DFBrowser/DFBrowser_Tools.hxx
new file mode 100644 (file)
index 0000000..3753c50
--- /dev/null
@@ -0,0 +1,56 @@
+// 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 DFBrowser_Tools_H
+#define DFBrowser_Tools_H
+
+#include <Standard.hxx>
+#include <Standard_GUID.hxx>
+#include <TreeModel_ItemBase.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_Attribute.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QAbstractItemModel>
+#include <QColor>
+#include <QMap>
+#include <QModelIndex>
+#include <QPixmap>
+#include <QString>
+#include <QIcon>
+
+class DFBrowserPane_AttributePaneAPI;
+
+//! \namespace DFBrowser_Tools
+//! The namespace that gives auxiliary methods for TDF elements manipulation
+namespace DFBrowser_Tools
+{
+
+  //! Returns true if the label is not root, has attribute or at least one sub-label with attribute
+  //! \param theLabel a label
+  //! \return boolean result
+  Standard_EXPORT bool IsEmptyLabel (const TDF_Label& theLabel);
+
+  //! Returns the label entry
+  //! \param isUseShortInfo boolean value if value of name attribute should be included to result
+  //! \return string value
+  Standard_EXPORT QString GetLabelInfo (const TDF_Label& theLabel, const bool isUseShortInfo = true);
+
+  //! Returns the label icon
+  Standard_EXPORT QIcon GetLabelIcon (const TDF_Label& theLabel, bool isStandard16x16 = true);
+}
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLine.cxx b/tools/DFBrowser/DFBrowser_TreeLevelLine.cxx
new file mode 100644 (file)
index 0000000..c1be576
--- /dev/null
@@ -0,0 +1,250 @@
+// 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 <DFBrowser_TreeLevelLine.hxx>
+
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelLineDelegate.hxx>
+#include <DFBrowser_TreeLevelLineModel.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QAbstractItemModel>
+#include <QFrame>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QPainter>
+#include <QScrollBar>
+#include <QTableView>
+#include <QToolButton>
+#include <QWidget>
+
+const int HISTORY_SIZE = 10;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeLevelLine::DFBrowser_TreeLevelLine (QWidget* theParent)
+: QObject (theParent), mySelectionProcessingBlocked (false), myCurrentHistoryIndex (-1)
+{
+  myMainWindow = new QWidget (theParent);
+  QGridLayout* aLayout = new QGridLayout (myMainWindow);
+  aLayout->setContentsMargins (0, 0, 0, 0);
+
+  myBackwardButton = new QToolButton (myMainWindow);
+  myBackwardButton->setIcon (QIcon (":/icons/treeline_backward.png"));
+  myBackwardButton->setToolTip (tr ("Backward"));
+  connect (myBackwardButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+  aLayout->addWidget (myBackwardButton, 0, 0);
+
+  myForwardButton = new QToolButton (myMainWindow);
+  myForwardButton->setIcon (QIcon (":/icons/treeline_forward.png"));
+  myForwardButton->setToolTip (tr ("Forward"));
+  connect (myForwardButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+  aLayout->addWidget (myForwardButton, 0, 1);
+
+  myTableView = new QTableView (myMainWindow);
+  myTableView->horizontalHeader()->setVisible (false);
+  QHeaderView* aVHeader = myTableView->verticalHeader();
+  aVHeader->setVisible (false);
+  int aDefCellSize = aVHeader->minimumSectionSize() + DFBrowserPane_Tools::HeaderSectionMargin();
+  aVHeader->setDefaultSectionSize (aDefCellSize);
+  aLayout->addWidget (myTableView, 0, 2, 2, 1);
+
+  int aScrollHeight = myTableView->horizontalScrollBar()->sizeHint().height();
+  myTableView->setFixedHeight (aDefCellSize + aScrollHeight);
+  myTableView->horizontalHeader()->setMinimumSectionSize (5); // it will be resized by context
+  myTableView->setHorizontalScrollMode (QAbstractItemView::ScrollPerItem);
+  myTableView->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn); //! TEMPORARY
+  myTableView->setShowGrid (false);
+
+  DFBrowser_TreeLevelLineModel* aHModel = new DFBrowser_TreeLevelLineModel (myTableView);
+  myTableView->setModel (aHModel);
+
+  QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHModel);
+  myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
+  myTableView->setSelectionModel (aSelectionModel);
+  connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+           this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+  // highlight for items
+  myTableView->viewport()->setAttribute (Qt::WA_Hover);
+  myTableView->setItemDelegate (new DFBrowser_TreeLevelLineDelegate (myTableView));
+
+  aLayout->setColumnStretch (2, 1);
+
+  myUpdateButton = new QToolButton (myMainWindow);
+  myUpdateButton->setIcon (QIcon (":/icons/treeline_update.png"));
+  myUpdateButton->setToolTip (tr ("Update Tree Model"));
+  connect (myUpdateButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+  aLayout->addWidget (myUpdateButton, 0, 3);
+
+  mySearchLine = new DFBrowser_SearchLine (myMainWindow);
+  aLayout->addWidget (mySearchLine, 0, 4);
+
+  updateActionsState();
+}
+
+// =======================================================================
+// function : clear
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::ClearHistory()
+{
+  myHistoryIndices.clear();
+  setCurrentHistoryIndex (-1);
+}
+
+// =======================================================================
+// function : onSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+                                                          const QItemSelection&)
+{
+  QModelIndexList aSelectedIndices = theSelected.indexes();
+  QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
+
+  if (!mySelectionProcessingBlocked) // we're processing action click
+    setForwardIndex (aSelectedIndex);
+
+  bool isBlocked = mySelectionProcessingBlocked;
+  // block selection processing in order to avoid circling by processing table selection changing
+  mySelectionProcessingBlocked = true;
+  DFBrowser_TreeLevelLineModel* aModel = dynamic_cast<DFBrowser_TreeLevelLineModel*> (myTableView->model());
+  aModel->Init (aSelectedIndex);
+  myTableView->selectionModel()->clearSelection();
+  myTableView->resizeColumnsToContents();
+
+  myTableView->scrollTo (myTableView->model()->index (0, myTableView->model()->columnCount()-1));
+
+  mySelectionProcessingBlocked = isBlocked;
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::onTableSelectionChanged (const QItemSelection& theSelected,
+                                                       const QItemSelection&)
+{
+  if (mySelectionProcessingBlocked)
+    return;
+
+  DFBrowser_TreeLevelLineModel* aTableModel = dynamic_cast<DFBrowser_TreeLevelLineModel*> (myTableView->model());
+  if (!aTableModel)
+    return;
+
+  QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0, Qt::Vertical);
+  emit indexSelected (aTableModel->GetTreeViewIndex (aSelectedIndex));
+}
+
+// =======================================================================
+// function : onActionClicked
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::onActionClicked()
+{
+  QToolButton* aSender = (QToolButton*)sender();
+  if (aSender == myBackwardButton || aSender == myForwardButton)
+  {
+    bool aBlocked = mySelectionProcessingBlocked;
+    mySelectionProcessingBlocked = true;
+    QModelIndex anIndex;
+    if (aSender == myBackwardButton)
+    {
+      anIndex = getBackwardIndex();
+      if (anIndex.isValid())
+        setCurrentHistoryIndex (myCurrentHistoryIndex - 1);
+    }
+    else
+    {
+      anIndex = getForwardIndex();
+      if (anIndex.isValid())
+        setCurrentHistoryIndex (myCurrentHistoryIndex + 1);
+    }
+    if (anIndex.isValid())
+      emit indexSelected (anIndex);
+    mySelectionProcessingBlocked = aBlocked;
+  }
+  else if (aSender == myUpdateButton)
+    emit updateClicked();
+}
+
+// =======================================================================
+// function : getBackwardIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelLine::getBackwardIndex()
+{
+  return myCurrentHistoryIndex > 0 ? myHistoryIndices[myCurrentHistoryIndex-1] : QModelIndex();
+}
+
+// =======================================================================
+// function : getForwardIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelLine::getForwardIndex()
+{
+  return (myCurrentHistoryIndex >= 0 && myCurrentHistoryIndex + 1 < myHistoryIndices.count())
+     ? myHistoryIndices[myCurrentHistoryIndex + 1] : QModelIndex();
+}
+
+// =======================================================================
+// function : setForwardIndex
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::setForwardIndex (const QModelIndex& theIndex)
+{
+  while (myCurrentHistoryIndex != myHistoryIndices.count() - 1)
+    myHistoryIndices.removeLast();
+
+  myHistoryIndices.append (theIndex);
+  if (myHistoryIndices.size() > HISTORY_SIZE)
+    myHistoryIndices.removeFirst();
+
+  setCurrentHistoryIndex (myHistoryIndices.count() - 1);
+}
+
+// =======================================================================
+// function : setCurrentHistoryIndex
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::setCurrentHistoryIndex (const int theIndexId)
+{
+  myCurrentHistoryIndex = theIndexId;
+  updateActionsState();
+}
+
+// =======================================================================
+// function : updateActionsState
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::updateActionsState()
+{
+  if (myCurrentHistoryIndex < 0)
+  {
+    myBackwardButton->setEnabled (false);
+    myForwardButton->setEnabled (false);
+  }
+  else
+  {
+    myBackwardButton->setEnabled (myCurrentHistoryIndex > 0);
+    myForwardButton->setEnabled (myCurrentHistoryIndex < myHistoryIndices.size() - 1);
+  }
+}
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLine.hxx b/tools/DFBrowser/DFBrowser_TreeLevelLine.hxx
new file mode 100644 (file)
index 0000000..bcd4b07
--- /dev/null
@@ -0,0 +1,128 @@
+// 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 DFBrowser_TreeLevelLine_H
+#define DFBrowser_TreeLevelLine_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+#include <QMap>
+#include <QModelIndex>
+
+class DFBrowser_SearchLine;
+
+class QAbstractItemModel;
+class QToolButton;
+class QTableView;
+class QWidget;
+
+//! \class DFBrowser_TreeLevelLine
+//! This is a control to visualize the current selected item of OCAF tree view.
+//! It contains history of previous selected items.
+//! The structure of this control is the next:
+//! <back button> <forward button> <selected item line> <update button> <search line>
+//! - <back button> allows moving to previously selected item (if it exists)
+//! - <forward button> allows moving to next selected item (if it exists)
+//! - <selected item line> path to currently selected item in OCAF tree view. Click on any level will
+//! select the clicked item in tree view.
+//! - <update button> will update content of OCAF tree model
+//! - <search line> allows type label entry or attribute name and see in search view the available elements
+class DFBrowser_TreeLevelLine : public QObject
+{
+  Q_OBJECT
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
+
+  //! Destructor
+  virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
+
+  //! Clears history of selected items
+  Standard_EXPORT void ClearHistory();
+
+  //! Returns parent control
+  QWidget* GetControl() const { return myMainWindow; }
+
+  //! Returns current search line
+  DFBrowser_SearchLine* GetSearchLine() const { return mySearchLine; };
+
+signals:
+
+  //! Signal about selection of an item in tree level line
+  //! \param theIndex a tree view model index of selected item
+  void indexSelected (const QModelIndex& theIndex);
+
+  //! Signal about necessity to update OCAF tree model
+  void updateClicked();
+
+public slots:
+
+  //! Listens tree view selection model. Update tree level line by selected item. Stores
+  //! \param theSelected a list of selected items
+  //! \param theDeselected a list of deselected items
+  Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+                                                   const QItemSelection& theDeselected);
+
+private slots:
+
+  //! Listens table view selection model. Gets selected tree view model index and emit indexSelected signal.
+  //! \param theSelected a list of selected items
+  //! \param theDeselected a list of deselected items
+  void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+  //! Listens actions and do the following:
+  //! - <backward>: moves history to the previous selection item, emits indexSelected signal
+  //! - <forward>: moves history to the next selection item, emits indexSelected signal
+  //! - <update>: emits updateClicked signal to update OCAF tree model
+  void onActionClicked();
+
+private:
+
+  //! Returns the previous index of history selection
+  QModelIndex getBackwardIndex();
+
+  //! Returns the next index of history selection
+  QModelIndex getForwardIndex();
+
+  //! Appends new history index, set it active, remove the first history index if the cache is out of range
+  //! \param theIndex a selected OCAF tree model index
+  void setForwardIndex (const QModelIndex& theIndex);
+
+  //! Updates enable state of backward/forward actions depending on the current item index
+  void updateActionsState();
+
+  //! Sets the current index and update actions state
+  //! \param theIndexId an item index, should be in range of history of indices
+  void setCurrentHistoryIndex (const int theIndexId);
+
+private:
+
+  bool mySelectionProcessingBlocked; //!< if true, table view selection is started but has not been finished yet
+  QList<QModelIndex> myHistoryIndices; //!< cached selected OCAF tree model indices
+  int myCurrentHistoryIndex; //!< an index of the current history selected index from myHistoryIndices
+
+  QWidget* myMainWindow; //!< parent widget for controls
+  QToolButton* myBackwardButton; //!< backward button, to select previous selected item
+  QToolButton* myForwardButton; //!< forward button, to select next selected item
+  QToolButton* myUpdateButton; //!< update button, like F5, to update OCAF tree model content
+  QTableView* myTableView; //!< container of path values to selected item, a path value is a label entry
+
+  DFBrowser_SearchLine* mySearchLine; //!< line of search
+};
+#endif
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.cxx b/tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.cxx
new file mode 100644 (file)
index 0000000..1395845
--- /dev/null
@@ -0,0 +1,52 @@
+// 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 <DFBrowser_TreeLevelLineDelegate.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <QPainter>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeLevelLineDelegate::DFBrowser_TreeLevelLineDelegate (QObject* theParent)
+: QItemDelegate (theParent)
+{
+}
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLineDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                                             const QModelIndex& theIndex) const
+{
+  // highlight cell
+  if (theOption.state & QStyle::State_MouseOver)
+    thePainter->fillRect (theOption.rect, DFBrowser_Window::LightHighlightColor());
+
+  // action icon for all indices before the last one
+  if (theIndex.column() < theIndex.model()->columnCount()-1)
+  {
+    QIcon anIcon (":/icons/level_change.png");
+    QSize anIconSize (10, 20);
+    thePainter->drawPixmap (QRect (theOption.rect.right() - anIconSize.width(), theOption.rect.top(),
+                                   anIconSize.width(), anIconSize.height()),
+                            anIcon.pixmap (anIconSize.width(), anIconSize.height()));
+  }
+  // default paint
+  QItemDelegate::paint (thePainter, theOption, theIndex);
+}
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.hxx b/tools/DFBrowser/DFBrowser_TreeLevelLineDelegate.hxx
new file mode 100644 (file)
index 0000000..d8b0cf1
--- /dev/null
@@ -0,0 +1,50 @@
+// 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 DFBrowser_TreeLevelLineDelegate_H
+#define DFBrowser_TreeLevelLineDelegate_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QItemDelegate>
+
+//! \class DFBrowser_TreeLevelLineDelegate
+//! Extending standard item delegate by:
+//! - <level change.png> icon. It exists for all columns excepting the last column.
+//! - highlight cell by mouse move over the cell
+class DFBrowser_TreeLevelLineDelegate : public QItemDelegate
+{
+
+public:
+
+  //! Constructor
+  Standard_EXPORT DFBrowser_TreeLevelLineDelegate (QObject* theParent = 0);
+
+  //! Destructor
+  virtual ~DFBrowser_TreeLevelLineDelegate() {}
+
+  //! Draw 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
+  Standard_EXPORT virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+                                      const QModelIndex& theIndex) const Standard_OVERRIDE;
+};
+
+#endif
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLineModel.cxx b/tools/DFBrowser/DFBrowser_TreeLevelLineModel.cxx
new file mode 100644 (file)
index 0000000..c1c0a4e
--- /dev/null
@@ -0,0 +1,93 @@
+// 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 <DFBrowser_TreeLevelLineModel.hxx>
+
+#include <DFBrowser_ItemBase.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QIcon>
+#include <QWidget>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLineModel::Init (const QModelIndex& theTreeIndex)
+{
+  myTreeIndex = theTreeIndex;
+  myLevelItems.clear();
+
+  if (theTreeIndex.isValid())
+  {
+    myLevelItems.prepend (theTreeIndex);
+    QModelIndex aParent = theTreeIndex.parent();
+    while (aParent.isValid())
+    {
+      myLevelItems.prepend (aParent);
+      aParent = aParent.parent();
+    }
+  }
+  emit layoutChanged();
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelLineModel::data (const QModelIndex& theIndex, int theRole) const
+{
+  QVariant aValue;
+  int aColumns = theIndex.column();
+  if (aColumns < myLevelItems.size())
+  {
+    QModelIndex aTreeIndex = myLevelItems[aColumns];
+    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 (theRole == Qt::DisplayRole)
+      aValue = aValue.toString() + "  "; //! TEMPORARY to leave place for the action icon
+  }
+  return aValue;
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelLineModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+  QVariant aValue;
+  if (theOrientation == Qt::Horizontal && theSection < myLevelItems.size())
+  {
+    QModelIndex aTreeIndex = myLevelItems[theSection];
+    if (!aTreeIndex.isValid()) // level change action
+    {
+      if (theRole == Qt::SizeHintRole)
+        aValue = QSize (2, 2);
+      else if (theRole == Qt::DisplayRole)
+        aValue = "";
+    }
+  }
+  return aValue;
+}
diff --git a/tools/DFBrowser/DFBrowser_TreeLevelLineModel.hxx b/tools/DFBrowser/DFBrowser_TreeLevelLineModel.hxx
new file mode 100644 (file)
index 0000000..b486e36
--- /dev/null
@@ -0,0 +1,85 @@
+// 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 DFBrowser_TreeLevelLineModel_H
+#define DFBrowser_TreeLevelLineModel_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QAbstractTableModel>
+#include <QObject>
+#include <QList>
+
+//! \class DFBrowser_TreeLevelLineModel
+//! Tree Model of tree line items. It is initialized by OCAF tree model index. Each element of the current model
+//! is an item of hierarchy of OCAF tree model index. So, on each level a label is presented, the last element may be
+//! an attribute. Information, presented for the item has no additional information (not as in OCAF tree model)
+class DFBrowser_TreeLevelLineModel : public QAbstractTableModel
+{
+public:
+
+  //! Constructor
+  DFBrowser_TreeLevelLineModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+  //! Destructor
+  virtual ~DFBrowser_TreeLevelLineModel() {}
+
+  //!
+  void Reset() { myLevelItems.clear(); }
+
+  //! Inits the model by the index
+  //! \param theTreeIndex an OCAF tree model index
+  Standard_EXPORT void Init (const QModelIndex& theTreeIndex);
+
+  //! 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
+  //! \param theIndex a tree level view model index
+  //! \return model index
+  const QModelIndex& GetTreeViewIndex (const QModelIndex& theIndex) const
+  { return myLevelItems[theIndex.column()]; }
+
+  //! Returns item information(short) for display role.
+  //! \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;
+
+  //! Returns the header data for the given role and section in the header with the specified orientation.