From: nds Date: Thu, 30 Aug 2018 09:22:28 +0000 (+0300) Subject: 0030095: Inspectors - Standalone build - possibility to switch on/off some of plugins... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=0156fa89144843206478336021339a1383437277;p=occt-copy.git 0030095: Inspectors - Standalone build - possibility to switch on/off some of plugins in CMakeLists - flags of the issue - extending number of rows in trees(now, one root item always exists). In new implementation the model root item is not visible in tree view. Children of the root item are shown and the top items of the view. --- diff --git a/dox/user_guides/inspector/images/build_cmake_tools.png b/dox/user_guides/inspector/images/build_cmake_tools.png new file mode 100644 index 0000000000..871a49ac19 Binary files /dev/null and b/dox/user_guides/inspector/images/build_cmake_tools.png differ diff --git a/dox/user_guides/inspector/inspector.md b/dox/user_guides/inspector/inspector.md index 94430b69ea..e6bd87503b 100644 --- a/dox/user_guides/inspector/inspector.md +++ b/dox/user_guides/inspector/inspector.md @@ -557,6 +557,22 @@ When this option is switched ON, MS Visual Studio project has an additional tree @figure{VStudio_projects.png,"Inspector packages in MS Visual Studio",160} +@subsection occt_inspector_5_1 Building tools with CMake outside of OCCT + +To compile OCCT tools, run CMake and set the source directory into the "tools" folder of OCCT. +@figure{build_cmake_tools.png,"OCCT tools",160} + +"OpenCASCADE_Dir" should be defined and point into cmake directory of installed OCCT. (Please be sure that sources +of OCCT for compiled tools are the same as sources of installed OCCT, otherwise interface might be different and +you have compilation errors) + +After, define 3RDPARTY_QT_DIR + +Checked variables BUILD_PLUGIN_* define which plugins should be compiled. +If only BUILD_PLUGIN_TreeModel is checked, no plugins are compiled, only TreeModel library that might be used as an interface +of communication to Qt tree model by items implementation. + + @section occt_inspector_6 Sources and packaging OCCT sources are extended by the /tools directory. diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index e22c877da1..8cbf3cdf93 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -26,6 +26,23 @@ set (CMAKE_SUPPRESS_REGENERATION TRUE) set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE) +# build variables +macro (BUILD_TOOL_MESSAGE BUILD_TOOL_TARGET_VARIABLE BUILD_TOOL_TARGET_STRING) +set (${BUILD_TOOL_TARGET_VARIABLE}_DESCR +"Indicates whether ${BUILD_TOOL_TARGET_STRING} tool should be built or not. +It should be noted that some toolkits of the module can be built even if this module +is not checked (this happens if some other modules depend on these toolkits)") +set (${BUILD_TOOL_TARGET_VARIABLE} ON CACHE BOOL "${${BUILD_TOOL_TARGET_VARIABLE}_DESCR}") +endmacro() + +BUILD_TOOL_MESSAGE (BUILD_PLUGIN_TKTreeModel "TKTreeModel") +BUILD_TOOL_MESSAGE (BUILD_PLUGIN_TKDFBrowser "TKDFBrowser") +BUILD_TOOL_MESSAGE (BUILD_PLUGIN_TKVInspector "TKVInspector") +BUILD_TOOL_MESSAGE (BUILD_PLUGIN_TKShapeView "TKShapeView") +if (NOT BUILD_PLUGIN_TKDFBrowser AND NOT BUILD_PLUGIN_TKVInspector AND NOT BUILD_PLUGIN_TKShapeView) + set (BUILD_TREE_MODEL_ONLY ON) +endif() + # macro: include patched file if it exists macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE) if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake") @@ -333,9 +350,16 @@ endif() # list will contain all tools #if (BUILD_Inspector) OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS) - foreach (OCCT_TOOL ${OCCT_TOOLS}) - list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) - endforeach() + + if (DEFINED BUILD_TREE_MODEL_ONLY AND BUILD_TREE_MODEL_ONLY) + list (APPEND BUILD_TOOL_TOOLKITS "TKTreeModel") + else() + foreach (OCCT_TOOL ${OCCT_TOOLS}) + list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) + endforeach() + endif() + + message("Build: ${BUILD_TOOL_TOOLKITS}") # collect all the headers to /inc/inspector folder string(TIMESTAMP CURRENT_TIME "%H:%M:%S") @@ -363,9 +387,15 @@ if (3RDPARTY_LIBRARY_DIRS) endif() # include patched toolkit projects or original ones -if (BUILD_TOOL_TOOLKITS) +if (BUILD_TREE_MODEL_ONLY) + OCCT_ADD_SUBDIRECTORY ("tools/TKTreeModel") + message (STATUS "Info: TKTreeModel OCCT toolkits processed") +else() foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS}) - OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}") + if (NOT DEFINED BUILD_PLUGIN_${BUILD_TOOL_TOOLKIT} OR BUILD_PLUGIN_${BUILD_TOOL_TOOLKIT}) + OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}") + message (STATUS "Info: ${BUILD_TOOL_TOOLKIT} toolkits processed") + endif() endforeach() endif() diff --git a/tools/DFBrowser/DFBrowser_TreeModel.cxx b/tools/DFBrowser/DFBrowser_TreeModel.cxx index 16fe10485e..c5d25f1e5d 100644 --- a/tools/DFBrowser/DFBrowser_TreeModel.cxx +++ b/tools/DFBrowser/DFBrowser_TreeModel.cxx @@ -98,12 +98,12 @@ QModelIndex DFBrowser_TreeModel::FindIndex (const TDF_Label& theLabel) const } } bool aDocumentItemFound = false; - QModelIndex aParentIndex = index (0, 0); - TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // application item + QModelIndex aParentIndex; + TreeModel_ItemBasePtr aParentItem; // find document, where label of document item is equal to Root label - for (int aChildId = 0, aCount = aParentItem->rowCount(); aChildId < aCount; aChildId++) + for (int aChildId = 0, aCount = rowCount(); aChildId < aCount; aChildId++) { - QModelIndex anIndex = index (aChildId, 0, aParentIndex); + QModelIndex anIndex = index (aChildId, 0); TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); DFBrowser_ItemDocumentPtr anItem = itemDynamicCast (anItemBase); if (anItem->GetLabel() == aRoot) diff --git a/tools/ShapeView/ShapeView_TreeModel.cxx b/tools/ShapeView/ShapeView_TreeModel.cxx index bc29c119ae..48438dce35 100644 --- a/tools/ShapeView/ShapeView_TreeModel.cxx +++ b/tools/ShapeView/ShapeView_TreeModel.cxx @@ -107,11 +107,9 @@ void ShapeView_TreeModel::RemoveAllShapes() // ======================================================================= QModelIndex ShapeView_TreeModel::FindIndex (const TopoDS_Shape& theShape) const { - QModelIndex aParentIndex = index (0, 0); - TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // application item - for (int aChildId = 0, aCount = aParentItem->rowCount(); aChildId < aCount; aChildId++) + for (int aChildId = 0, aCount = rowCount(); aChildId < aCount; aChildId++) { - QModelIndex anIndex = index (aChildId, 0, aParentIndex); + QModelIndex anIndex = index (aChildId, 0); ShapeView_ItemShapePtr anItem = itemDynamicCast (TreeModel_ModelBase::GetItemByIndex (anIndex)); if (anItem && anItem->GetItemShape() == theShape) return anIndex; diff --git a/tools/TreeModel/TreeModel_ModelBase.cxx b/tools/TreeModel/TreeModel_ModelBase.cxx index 72acad8d01..dae10aded3 100644 --- a/tools/TreeModel/TreeModel_ModelBase.cxx +++ b/tools/TreeModel/TreeModel_ModelBase.cxx @@ -66,10 +66,6 @@ QModelIndex TreeModel_ModelBase::index (int theRow, int theColumn, const QModelI if (!hasIndex (theRow, theColumn, theParent)) return QModelIndex(); - // to create index on the root item - if (!theParent.isValid()) - return createIndex (theRow, theColumn, getIndexValue (RootItem (theColumn))); - TreeModel_ItemBasePtr aParentItem; if (!theParent.isValid()) aParentItem = RootItem (theColumn); @@ -164,10 +160,6 @@ QVariant TreeModel_ModelBase::headerData (int theSection, Qt::Orientation theOri // ======================================================================= int TreeModel_ModelBase::rowCount (const QModelIndex& theParent) const { - // to create index on the root item - if (!theParent.isValid()) - return 1; - TreeModel_ItemBasePtr aParentItem; if (!theParent.isValid()) aParentItem = RootItem (0); diff --git a/tools/VInspector/VInspector_ViewModel.cxx b/tools/VInspector/VInspector_ViewModel.cxx index d8f6c026a5..efa56f2675 100644 --- a/tools/VInspector/VInspector_ViewModel.cxx +++ b/tools/VInspector/VInspector_ViewModel.cxx @@ -105,11 +105,9 @@ void VInspector_ViewModel::SetContext (const Handle(AIS_InteractiveContext)& the QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers) { QModelIndexList anIndices; - QModelIndex aParentIndex = index (0, 0); - TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item - for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++) + for (int aRowId = 0, aCount = rowCount(); aRowId < aCount; aRowId++) { - QModelIndex anIndex = index (aRowId, 0, aParentIndex); + QModelIndex anIndex = index (aRowId, 0); TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast(anItemBase); if (!anItemPrs)