]> OCCT Git - occt-copy.git/commitdiff
0030095: Inspectors - Standalone build - possibility to switch on/off some of plugins... CR30095
authornds <nds@opencascade.com>
Thu, 30 Aug 2018 09:22:28 +0000 (12:22 +0300)
committernds <nds@opencascade.com>
Thu, 30 Aug 2018 09:22:28 +0000 (12:22 +0300)
- 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.

dox/user_guides/inspector/images/build_cmake_tools.png [new file with mode: 0644]
dox/user_guides/inspector/inspector.md
tools/CMakeLists.txt
tools/DFBrowser/DFBrowser_TreeModel.cxx
tools/ShapeView/ShapeView_TreeModel.cxx
tools/TreeModel/TreeModel_ModelBase.cxx
tools/VInspector/VInspector_ViewModel.cxx

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 (file)
index 0000000..871a49a
Binary files /dev/null and b/dox/user_guides/inspector/images/build_cmake_tools.png differ
index 94430b69ea9d83f6fd3f667271ae9e1c0bc3ad6a..e6bd87503b99928eb8b45de1a4d70c95dd4fe549 100644 (file)
@@ -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 <b>cmake</b> 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.
index e22c877da142d5d3b6890e6387a7dbeb34b48193..8cbf3cdf932791a94204fb0054103b9f7190f85a 100644 (file)
@@ -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 <OCCT_TOOLS> 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 <binary dir>/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()
 
index 16fe10485e71c1c7fc56920d81cc0d81c14f2926..c5d25f1e5d2f1aa7ee524d17f82baafb069d4edc 100644 (file)
@@ -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<DFBrowser_ItemDocument> (anItemBase);
     if (anItem->GetLabel() == aRoot)
index bc29c119aecfe89c4b92797cdfad0909188abf1e..48438dce358e2dc85f64e1118170146568d8bce8 100644 (file)
@@ -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<ShapeView_ItemShape> (TreeModel_ModelBase::GetItemByIndex (anIndex));
     if (anItem && anItem->GetItemShape() == theShape)
       return anIndex;
index 72acad8d01514a9419014454165921cb94519df9..dae10aded362be8a6825f329d7c41d3197cca94b 100644 (file)
@@ -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);
index d8f6c026a5b242be16d25a4dbbe6bead0e71f01b..efa56f26757073db25aaa0b101636c8173de74ad 100644 (file)
@@ -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<VInspector_ItemPresentableObject>(anItemBase);
     if (!anItemPrs)