]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'origin/BR_PORTING_CENTOS_6_3'
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Apr 2014 12:40:30 +0000 (16:40 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 11 Apr 2014 12:40:30 +0000 (16:40 +0400)
Conflicts:
CMakeCommon/FindPython.cmake
CMakeCommon/FindQt.cmake
CMakeCommon/XMLProcessing.cmake
src/Config/CMakeLists.txt
src/Event/CMakeLists.txt
src/Model/CMakeLists.txt
src/ModelAPI/CMakeLists.txt
src/ModuleBase/CMakeLists.txt
src/PartSet/CMakeLists.txt
src/PartSetPlugin/CMakeLists.txt
src/XGUI/CMakeLists.txt

47 files changed:
CMakeCommon/FindPython.cmake
CMakeCommon/FindQt.cmake
CMakeCommon/XMLProcessing.cmake
centos6_env.sh [deleted file]
eclipse.sh
linux_env.sh [new file with mode: 0644]
msvc10_env.bat
src/Config/CMakeLists.txt
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_ModuleReader.cpp
src/Config/Config_ModuleReader.h
src/Event/CMakeLists.txt
src/Event/Event_Message.h
src/Model/CMakeLists.txt
src/Model/Model_Application.cxx
src/Model/Model_Application.h
src/Model/Model_Document.cxx
src/Model/Model_Events.cxx
src/Model/Model_Events.h
src/Model/Model_PluginManager.cxx
src/Model/Model_PluginManager.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_PluginManager.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSetPlugin/CMakeLists.txt
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Command.h
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_MainMenu.cpp
src/XGUI/XGUI_MainMenu.h
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MainWindow.h
src/XGUI/XGUI_MenuGroupPanel.cpp
src/XGUI/XGUI_MenuGroupPanel.h
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_PartDataModel.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Workbench.cpp
src/XGUI/XGUI_Workbench.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 5b8f5f04dd34e8de71ed7a21edfda0011b5ef412..364fc028b0920080d2500a38c506d25faa494d9c 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 
 IF(WIN32)
     IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
index 426cd05816d1a7867d75a89d97afee101dc23c4b..77376576553c712a1ebec373436938388e82abd3 100644 (file)
@@ -1,5 +1,4 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 IF(WIN32)
     SET(QT_USE_QTMAIN ON)
 ENDIF()
index 7a512165b919924ea7d88342e4c71fe5cd790943..5e38c02ec11bba25b3e3a0716796954a36059a00 100644 (file)
@@ -1,7 +1,11 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 SET(LIBXMLDIR $ENV{LIBXML2_ROOT_DIR})
-INCLUDE_DIRECTORIES(${LIBXMLDIR}/include/libxml2)
+
+IF(WIN32)
+  INCLUDE_DIRECTORIES(${LIBXMLDIR}/include)
+ELSE()
+  INCLUDE_DIRECTORIES(${LIBXMLDIR}/include/libxml2)
+ENDIF(WIN32)
+
 LINK_DIRECTORIES (${LIBXMLDIR}/lib)
 IF(WIN32)
     SET(LIBXML2_LIBRARIES ${LIBXMLDIR}/lib/libxml2.lib)
diff --git a/centos6_env.sh b/centos6_env.sh
deleted file mode 100644 (file)
index f9ec06d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#------ Setting products installation directory ------
-export INST_ROOT=/misc/dn21/hdfeditor/sbh/NewGeom/products
-
-#------ Python ------
-export PYTHON_ROOT_DIR=${INST_ROOT}/Python-2.7.3
-export PYTHONHOME=${PYTHON_ROOT_DIR}
-export PYTHON_INCLUDE=${PYTHON_ROOT_DIR}/include/python2.7
-export PYTHON_VERSION=2.7
-export PATH=${PYTHON_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${PYTHON_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-export PYTHONPATH=${PYTHON_ROOT_DIR}/lib/python2.7
-#For cmake
-export PYTHON_LIB_DIR=${PYTHON_ROOT_DIR}/lib
-export PYTHON_INC_DIR=${PYTHON_INCLUDE}
-##
-#------ Qt ------
-export QT4_ROOT_DIR=${INST_ROOT}/qt-4.8.4
-export QT_PLUGIN_PATH=${QT4_ROOT_DIR}/plugins
-export PATH=${QT4_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${QT4_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ boost ------
-#export BOOST_ROOT_DIR=${INST_ROOT}/boost-1.52.0
-#export LD_LIBRARY_PATH ${BOOST_ROOT_DIR}/lib
-##
-#------ swig ------
-export SWIG_ROOT_DIR=${INST_ROOT}/swig-2.0.8
-export SWIG_LIB=${SWIG_ROOT_DIR}/share/swig/2.0.8
-export PATH=${SWIG_ROOT_DIR}/bin:${PATH}
-##
-#------ cmake ------
-export CMAKE_ROOT_DIR=${INST_ROOT}/cmake-2.8.10.2
-export PATH=${CMAKE_ROOT_DIR}/bin:${PATH}
-##
-#------ freetype ------
-export FREETYPE_ROOT_DIR=${INST_ROOT}/freetype-2.4.11
-export LD_LIBRARY_PATH=${FREETYPE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ freeimage ------
-export FREEIMAGE_ROOT_DIR=${INST_ROOT}/freeimage-3.15.4
-export PATH=${FREEIMAGE_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${FREEIMAGE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ gl2ps ------
-export GL2PS_ROOT_DIR=${INST_ROOT}/gl2ps-1.3.8
-export PATH=${GL2PS_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${GL2PS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ tbb ------
-export TBB_ROOT_DIR=${INST_ROOT}/tbb-30_018oss
-export PATH=${TBB_ROOT_DIR}/bin/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${PATH}
-export LD_LIBRARY_PATH=${TBB_ROOT_DIR}/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${LD_LIBRARY_PATH}
-##
-#------ libxml2 ------
-export LIBXML2_ROOT_DIR=${INST_ROOT}/libxml2-2.9.0
-export PATH=${LIBXML2_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${LIBXML2_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-# DO NOT rename following 3 variables, \r
-# they are required by CMake "find(Libxml2)" procedure\r
-export LIBXML2_INCLUDE_DIR=${LIBXML2_ROOT_DIR}/include/libxml2\r
-export LIBXML2_LIB_DIR=${LIBXML2_ROOT_DIR}/lib\r
-export LIBXML2_BIN_DIR=${LIBXML2_ROOT_DIR}/bin
-##
-#------ OCCT ------
-export CAS_ROOT_DIR=${INST_ROOT}/OCCT-6.7.0
-
-export PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-# Variable for Foundation Classes : 
-export CSF_UnitsLexicon=${CAS_ROOT_DIR}/src/UnitsAPI/Lexi_Expr.dat 
-export CSF_UnitsDefinition=${CAS_ROOT_DIR}/src/UnitsAPI/Units.dat 
-# Variable for DataExchange : 
-export CSF_SHMessage=${CAS_ROOT_DIR}/src/SHMessage
-export CSF_XSMessage=${CAS_ROOT_DIR}/src/XSMessage 
-# Variable for Font : 
-export CSF_MDTVFontDirectory=${CAS_ROOT_DIR}/src/FontMFT 
-export CSF_MDTVTexturesDirectory=${CAS_ROOT_DIR}/src/Textures 
-# Activation of OCCT Kernel multithreading :
-export MMGT_REENTRANT=1
-# this variable only needed for DRAWEXE
-export CASROOT=${CAS_ROOT_DIR}
-##
-export LIB=${LD_LIBRARY_PATH}
-
-
index dc910dae35cf778eba36f2cf53aecec15794975f..3f1c9c83218fb8c9f1dcf761fefb0f71473a973f 100644 (file)
@@ -5,7 +5,7 @@ export ROOT_DIR=`cd "${ROOT_DIR}";pwd`
 
 SRC_DIR=${ROOT_DIR}/sources
 
-source ${SRC_DIR}/centos6_env.sh
+source ${SRC_DIR}/linux_env.sh
 mkdir -p ${ROOT_DIR}/build
 cd ${ROOT_DIR}/build
 
diff --git a/linux_env.sh b/linux_env.sh
new file mode 100644 (file)
index 0000000..889f5e4
--- /dev/null
@@ -0,0 +1,85 @@
+#------ Setting products installation directory ------
+export INST_ROOT=/misc/dn21/hdfeditor/sbh/NewGeom/products
+
+#------ Python ------
+export PYTHON_ROOT_DIR=${INST_ROOT}/Python-2.7.3
+export PYTHONHOME=${PYTHON_ROOT_DIR}
+export PYTHON_INCLUDE=${PYTHON_ROOT_DIR}/include/python2.7
+export PYTHON_VERSION=2.7
+export PATH=${PYTHON_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${PYTHON_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+export PYTHONPATH=${PYTHON_ROOT_DIR}/lib/python2.7
+#For cmake
+export PYTHON_LIB_DIR=${PYTHON_ROOT_DIR}/lib
+export PYTHON_INC_DIR=${PYTHON_INCLUDE}
+##
+#------ Qt ------
+export QT4_ROOT_DIR=${INST_ROOT}/qt-4.8.4
+export QT_PLUGIN_PATH=${QT4_ROOT_DIR}/plugins
+export PATH=${QT4_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${QT4_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ boost ------
+#export BOOST_ROOT_DIR=${INST_ROOT}/boost-1.52.0
+#export LD_LIBRARY_PATH ${BOOST_ROOT_DIR}/lib
+##
+#------ swig ------
+export SWIG_ROOT_DIR=${INST_ROOT}/swig-2.0.8
+export SWIG_LIB=${SWIG_ROOT_DIR}/share/swig/2.0.8
+export PATH=${SWIG_ROOT_DIR}/bin:${PATH}
+##
+#------ cmake ------
+export CMAKE_ROOT_DIR=${INST_ROOT}/cmake-2.8.10.2
+export PATH=${CMAKE_ROOT_DIR}/bin:${PATH}
+##
+#------ freetype ------
+export FREETYPE_ROOT_DIR=${INST_ROOT}/freetype-2.4.11
+export LD_LIBRARY_PATH=${FREETYPE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ freeimage ------
+export FREEIMAGE_ROOT_DIR=${INST_ROOT}/freeimage-3.15.4
+export PATH=${FREEIMAGE_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${FREEIMAGE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ gl2ps ------
+export GL2PS_ROOT_DIR=${INST_ROOT}/gl2ps-1.3.8
+export PATH=${GL2PS_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${GL2PS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ tbb ------
+export TBB_ROOT_DIR=${INST_ROOT}/tbb-30_018oss
+export PATH=${TBB_ROOT_DIR}/bin/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${PATH}
+export LD_LIBRARY_PATH=${TBB_ROOT_DIR}/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${LD_LIBRARY_PATH}
+##
+#------ libxml2 ------
+export LIBXML2_ROOT_DIR=${INST_ROOT}/libxml2-2.9.0
+export PATH=${LIBXML2_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${LIBXML2_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+# DO NOT rename following 3 variables, 
+# they are required by CMake "find(Libxml2)" procedure
+export LIBXML2_INCLUDE_DIR=${LIBXML2_ROOT_DIR}/include/libxml2
+export LIBXML2_LIB_DIR=${LIBXML2_ROOT_DIR}/lib
+export LIBXML2_BIN_DIR=${LIBXML2_ROOT_DIR}/bin
+##
+#------ OCCT ------
+export CAS_ROOT_DIR=${INST_ROOT}/OCCT-6.7.0
+
+export PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+# Variable for Foundation Classes : 
+export CSF_UnitsLexicon=${CAS_ROOT_DIR}/src/UnitsAPI/Lexi_Expr.dat 
+export CSF_UnitsDefinition=${CAS_ROOT_DIR}/src/UnitsAPI/Units.dat 
+# Variable for DataExchange : 
+export CSF_SHMessage=${CAS_ROOT_DIR}/src/SHMessage
+export CSF_XSMessage=${CAS_ROOT_DIR}/src/XSMessage 
+# Variable for Font : 
+export CSF_MDTVFontDirectory=${CAS_ROOT_DIR}/src/FontMFT 
+export CSF_MDTVTexturesDirectory=${CAS_ROOT_DIR}/src/Textures 
+# Activation of OCCT Kernel multithreading :
+export MMGT_REENTRANT=1
+# this variable only needed for DRAWEXE
+export CASROOT=${CAS_ROOT_DIR}
+##
+export LIB=${LD_LIBRARY_PATH}
+
+
index 6b774f930deed9815a2e6dafe47eb80758e221ad..670d4400c5c2d6b24da7445622daa52672b66ff7 100644 (file)
@@ -20,7 +20,7 @@ if "%PDIR%" == "" (
 
 rem --------------- cmake 2.8.7 --------------
 if "%CMAKEDIR%" == "" (
-  set CMAKEDIR=%PDIR%\cmake-2.8.12.1
+  set CMAKEDIR=%PDIR%\cmake-2.8.10.2
 )
 set PATH=%CMAKEDIR%\bin;%PATH%
 
@@ -32,9 +32,9 @@ set PATH=%CMAKEDIR%\bin;%PATH%
 
 @REM -------------------------
 @REM CASCADE
-@SET PATH=%CASROOT%;%CASROOT%\win32\bind;%PATH%
-@SET LIB=%CASROOT%\win32\libd;%LIB%
-@set CSF_GraphicShr=%CASROOT%\win32\bind\TKOpenGl.dll
+@SET PATH=%CASROOT%;%CASROOT%\win32\bin%OCC_LIB_PREFIX%;%PATH%
+@SET LIB=%CASROOT%\win32\lib%OCC_LIB_PREFIX%;%LIB%
+@set CSF_GraphicShr=%CASROOT%\win32\bin%OCC_LIB_PREFIX%\TKOpenGl.dll
 @set CSF_MDTVFontDirectory=%CASROOT%\src\FontMFT
 @set CSF_LANGUAGE=us
 @set MMGT_CLEAR=1
index ef109088788eaee1822765031d7e4bfc640d307e..f4f98b9d791d9f8090ba6f387f8f2dff3d3710fd 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 INCLUDE(XMLProcessing)
 
index 1cb2ef83da1768002d6d7df81ad528b8c6e61bea..204c83487bd2454e4bf0349bff205004eb2ce1f1 100644 (file)
 
 
 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
-                                           const std::string& theLibraryName)
+                                           const std::string& theLibraryName,
+                                           const char* theEventGenerated)
     : Config_XMLReader(theXmlFile),
-      myLibraryName(theLibraryName)
+      myLibraryName(theLibraryName),
+      myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
 {
 }
 
@@ -35,7 +37,7 @@ Config_FeatureReader::~Config_FeatureReader()
 
 void Config_FeatureReader::processNode(xmlNodePtr theNode)
 {
-  static Event_ID aMenuItemEvent = Event_Loop::eventByName("FeatureEvent");
+  Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
   if (isNode(theNode, NODE_FEATURE, NULL)) {
     Event_Loop* aEvLoop = Event_Loop::loop();
     Config_FeatureMessage aMessage(aMenuItemEvent, this);
index da5fa77fea93a188d7db3ca6b4ffe831dffee718..7b5322bba036468272244794f370455f610c1fdb 100644 (file)
@@ -20,7 +20,8 @@ class Config_FeatureReader: public Config_XMLReader
 {
 public:
   Config_FeatureReader(const std::string& theXmlFile,
-                       const std::string& theLibraryName = "");
+                       const std::string& theLibraryName = "",
+                       const char* theEventGenerated = 0);
   virtual ~Config_FeatureReader();
 
 protected:
@@ -33,6 +34,8 @@ private:
   std::string myLastWorkbench;
   std::string myLastGroup;
   std::string myLibraryName;
+  /// event generated on feature data sending, by default it is "FeatureEvent"
+  const char* myEventGenerated;
 };
 
 #endif /* CONFIG_FEATUREREADER_H_ */
index d77e6b830fd7ee091cf6d1ab7b5083c768d65de9..54c12d1d51e7119136e2452db9d966f274fb72e9 100644 (file)
@@ -18,8 +18,8 @@
 
 
 
-Config_ModuleReader::Config_ModuleReader()
-    : Config_XMLReader("plugins.xml"), myIsAutoImport(false)
+Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated)
+    : Config_XMLReader("plugins.xml"), myIsAutoImport(false), myEventGenerated(theEventGenerated)
 {
 }
 
@@ -63,7 +63,7 @@ void Config_ModuleReader::importPlugin(const std::string& thePluginName,
   if(thePluginLibrary.empty()) {
     aReader = new Config_FeatureReader(thePluginName);
   } else {
-    aReader = new Config_FeatureReader(thePluginName, thePluginLibrary);
+    aReader = new Config_FeatureReader(thePluginName, thePluginLibrary, myEventGenerated);
   }
   aReader->readAll();
 }
index 33567bdd27aa495af8caad59436d0c9ba8a0fbed..7083315b1426b42a3bbedfd57e521c2d7081a503 100644 (file)
@@ -19,7 +19,7 @@ class Config_ModuleReader: public Config_XMLReader
 {
 
 public:
-  CONFIG_EXPORT Config_ModuleReader();
+  CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
   CONFIG_EXPORT virtual ~Config_ModuleReader();
 
   CONFIG_EXPORT void setAutoImport(bool enabled);
@@ -37,7 +37,7 @@ protected:
 private:
   bool myIsAutoImport;
   std::map<std::string, std::string> myPluginsMap;
-
+  const char* myEventGenerated;
 
 };
 
index 3e458d5b48c3c862c617af26e7f038c1843fedb4..5b727db7c4b9fde0c76da817d5eec509ad9b7f30 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index e07621af75f692e7045c558d065d88706bbd7164..0c2702072962c479e0ad55d341d5a98dbdbdc4b8 100644 (file)
@@ -51,7 +51,7 @@ public:
   const Event_ID& eventID() const {return myEventId;}
 
   //! Returns sender of the message or NULL if it is anonymous message
-  void* sender() {return mySender;}
+  void* sender() const {return mySender;}
 };
 
 #endif
index fae97837133983c5becba00d974e53459c03f766..1d56def92f083d5a2b9b87a24002378e0e427514 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 INCLUDE(FindCAS)
 
index a8c8966b3962cb43eb08f6e3e72faea022fc9ffa..40704967e8de9cef5e8a568dac24330bd0fc5f37 100644 (file)
@@ -12,18 +12,12 @@ using namespace std;
 
 static Handle_Model_Application TheApplication = new Model_Application;
 
-//=======================================================================
-//function : getApplication
-//purpose  : 
 //=======================================================================
 Handle(Model_Application) Model_Application::getApplication()
 {
   return TheApplication;
 }
 
-//=======================================================================
-//function : getDocument
-//purpose  : 
 //=======================================================================
 const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
 {
@@ -41,8 +35,11 @@ void Model_Application::deleteDocument(string theDocID)
 }
 
 //=======================================================================
-//function : OCAFApp_Application
-//purpose  : 
+bool Model_Application::hasDocument(std::string theDocID)
+{
+  return myDocs.find(theDocID) != myDocs.end();
+}
+
 //=======================================================================
 Model_Application::Model_Application()
 {
@@ -51,18 +48,12 @@ Model_Application::Model_Application()
   TheKeepHandle = this;
 }
 
-//=======================================================================
-//function : Formats
-//purpose  : 
 //=======================================================================
 void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
 {
   theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
 }
 
-//=======================================================================
-//function : ResourcesName
-//purpose  : 
 //=======================================================================
 Standard_CString Model_Application::ResourcesName()
 {
index c4f578f0443e755afdbd314578199f3d91457f94..3865434796cad755f7869adb96677e18fb41d2f4 100644 (file)
@@ -31,6 +31,8 @@ public:
   MODEL_EXPORT static Handle_Model_Application getApplication();
   //! Returns the main document (on first call creates it) by the string identifier
   MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
+  //! Returns true if document has been created
+  MODEL_EXPORT bool hasDocument(std::string theDocID);
   //! Deletes the document from the application
   MODEL_EXPORT void deleteDocument(std::string theDocID);
 
index 0e976420c45652ec8dd63448b16428dce0790e84..03a497213a70ee1d715857eeccb4a9514e7f29bc 100644 (file)
@@ -222,7 +222,8 @@ void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> theFeatu
   TDF_Label anObjLab = aGroupLab.NewChild();
   std::shared_ptr<Model_Data> aData(new Model_Data);
   aData->setLabel(anObjLab);
-  aData->setDocument(Model_Application::getApplication()->getDocument(myID));
+  shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+  aData->setDocument(aThis);
   theFeature->setData(aData);
   setUniqueName(theFeature);
   theFeature->initAttributes();
@@ -234,7 +235,7 @@ void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> theFeatu
 
   // event: feature is added
   static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
-  ModelAPI_FeatureUpdatedMessage aMsg(theFeature, anEvent);
+  ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
   Event_Loop::loop()->send(aMsg);
 }
 
@@ -349,6 +350,7 @@ void Model_Document::setUniqueName(
 
 void Model_Document::synchronizeFeatures()
 {
+  shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
   // iterate groups labels
   TDF_ChildIDIterator aGroupsIter(myDoc->Main().FindChild(TAG_OBJECTS),
     TDataStd_Comment::GetID(), Standard_False);
@@ -400,8 +402,7 @@ void Model_Document::synchronizeFeatures()
       if (aDSTag > aFeatureTag) { // feature is removed
         aFIter = aFeatures.erase(aFIter);
         // event: model is updated
-        ModelAPI_FeatureDeletedMessage aMsg(
-          Model_Application::getApplication()->getDocument(myID), aGroupName);
+        ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
         Event_Loop::loop()->send(aMsg);
       } else if (aDSTag < aFeatureTag) { // a new feature is inserted
         // create a feature
@@ -417,7 +418,7 @@ void Model_Document::synchronizeFeatures()
         aFeature->initAttributes();
         // event: model is updated
         static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
-        ModelAPI_FeatureUpdatedMessage aMsg(aFeature, anEvent);
+        ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
         Event_Loop::loop()->send(aMsg);
 
         if (aFIter == aFeatures.end()) {
index f9ddb0f110f31bb1d391bbcc6b90ed055c136277..dc35573ebae8a405ab2eab7f77800ebcdb2d41f0 100644 (file)
@@ -6,8 +6,9 @@
 #include <Event_Loop.h>
 
 ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+  const std::shared_ptr<ModelAPI_Document>& theDoc,
   const std::shared_ptr<ModelAPI_Feature>& theFeature, const Event_ID& theEvent)
-  : Event_Message(theEvent, 0), myFeature(theFeature)
+  : Event_Message(theEvent, 0), myFeature(theFeature), myDoc(theDoc)
 {}
 
 ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage(
index e969458d69291573f8fe47fab8ef7fba80e78acd..c4af9f5279248d6423bec10de83b7d63eb638cfc 100644 (file)
@@ -22,14 +22,19 @@ static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
 
 /// Message that feature was changed (used for Object Browser update)
 class ModelAPI_FeatureUpdatedMessage : public Event_Message {
+  std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
   std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
 public:
   /// sender is not important, all information is located in the feature
-  ModelAPI_FeatureUpdatedMessage(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  ModelAPI_FeatureUpdatedMessage(
+    const std::shared_ptr<ModelAPI_Document>& theDoc,
+    const std::shared_ptr<ModelAPI_Feature>& theFeature,
     const Event_ID& theEvent);
 
   /// Returns the feature that has been updated
-  std::shared_ptr<ModelAPI_Feature> feature() {return myFeature;}
+  std::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
+  /// Returns the document that has been updated
+  std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
 };
 
 /// Message that feature was deleted (used for Object Browser update)
@@ -45,10 +50,10 @@ public:
   static const Event_ID messageId();
 
   /// Returns the feature that has been updated
-  std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
+  std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
 
   /// Returns the group where the feature was deleted
-  const std::string& group() {return myGroup;}
+  const std::string& group() const {return myGroup;}
 };
 
 #endif
index ea0b826a646015a0606057a963dbf1d6848248c7..eb279208afff32ba365016d136eac30c71cb7297 100644 (file)
@@ -43,6 +43,11 @@ std::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
     Model_Application::getApplication()->getDocument("root"));
 }
 
+bool Model_PluginManager::hasRootDocument()
+{
+  return Model_Application::getApplication()->hasDocument("root");
+}
+
 shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
 {
   if (!myCurrentDoc)
@@ -59,7 +64,7 @@ Model_PluginManager::Model_PluginManager()
 {
   myPluginsInfoLoaded = false;
   //TODO(sbh): Implement static method to extract event id [SEID]
-  static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureEvent");
+  static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureRegisterEvent");
 
   ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
   // register the configuration reading listener
@@ -87,7 +92,7 @@ void Model_PluginManager::LoadPluginsInfo()
     return;
 
   // Read plugins information from XML files
-  Config_ModuleReader aXMLReader;
+  Config_ModuleReader aXMLReader("FeatureRegisterEvent");
   aXMLReader.setAutoImport(true);
   aXMLReader.readAll();
 }
index 6da805cfa54e5aa27dad46dda311f96ec9cd944c..8fc49bdf2c6e9ccb84c136360b34c33a91bd933b 100644 (file)
@@ -30,6 +30,9 @@ public:
   /// Returns the root document of the application (that may contains sub-documents)
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> rootDocument();
 
+  /// Return true if root document has been already created
+  MODEL_EXPORT virtual bool hasRootDocument();
+
   /// Returns the current document that used for current work in the application
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> currentDocument();
 
index bfe828ea849a7b89b3b186e9f006e173eb3e2ecf..fa372271f25fbe99e936bdbab6f31dabbfe22446 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
index 8aab3f6f40d8525510612b61cad659634794ed61..90e1ca81d1bd91a138b987ddde6fe3bc3be451b7 100644 (file)
@@ -34,6 +34,9 @@ public:
   /// Returns the root document of the application (that may contains sub-documents)
   virtual std::shared_ptr<ModelAPI_Document> rootDocument() = 0;
 
+  /// Return true if root document has been already created
+  virtual bool hasRootDocument() = 0;
+
   /// Returns the current document that used for current work in the application
   virtual std::shared_ptr<ModelAPI_Document> currentDocument() = 0;
 
index dd8b1cb03f65de64c5e8779d6cc322aa28768d5d..efd8db9c13e77cf4357a430c2753ebf1cd4d9643 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 SET(CMAKE_AUTOMOC ON)
 
index 9def6b185607c528fcff46672bad7f21df07ecef..2c0e7d9d7e79514d353401e80d8e9e75f15a30dd 100644 (file)
@@ -289,7 +289,8 @@ void ModuleBase_Operation::startOperation()
 {
   std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
   myFeature = aDoc->addFeature(myOperationId.toStdString());
-  myFeature->execute();
+  if (myFeature) // TODO: generate an error if feature was not created
+    myFeature->execute();
   //emit callSlot();
   //commit();
 }
@@ -319,7 +320,7 @@ void ModuleBase_Operation::abortOperation()
  */
 void ModuleBase_Operation::commitOperation()
 {
-  myFeature->execute();
+  if (myFeature) myFeature->execute();
 }
 
 /*!
index 25b8d89baeabec3f43af450c04865488aef7472f..0300761e69687bea5b337f0eb2ef4dd57707b84e 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 SET(CMAKE_AUTOMOC ON)
 
index 409e38484871b43be35dd85042f6c838a0fc099f..3a24568f49a2bd9d81e75632b0a6d2bd93364cff 100644 (file)
@@ -40,7 +40,7 @@ void PartSet_Module::createFeatures()
 
 void PartSet_Module::featureCreated(XGUI_Command* theFeature)
 {
-  QString aFtId = theFeature->getId();
+  QString aFtId = theFeature->id();
   theFeature->connectTo(this, SLOT(onFeatureTriggered()));
 }
 
@@ -53,7 +53,7 @@ void PartSet_Module::onFeatureTriggered()
   Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginName);
   aWdgReader.readAll();
   XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
-  QString aCmdId = aCmd->getId();
+  QString aCmdId = aCmd->id();
   std::string aXmlCfg = aWdgReader.featureWidgetCfg(aCmdId.toStdString());
   //TODO(sbh): Implement static method to extract event id [SEID]
   static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
index 9a7e1ba0a03667f0e2f07155b514476cb7fdf607..c27034c10ddd19dc4800fef8917a2da49f786138 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index 3e4556b6204667b91707963b361f0100acd822d1..652965fc1c905b20fc5e3029f8bc957dc8d2c66e 100644 (file)
@@ -1,5 +1,3 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
 INCLUDE(FindCAS)
 
 SET(CMAKE_AUTOMOC ON)
index 1bef9e0db1be7a0dc491ed15ff600baa1d6721f3..b1227ba2e88335a0636ee9c3416141477ddf516d 100644 (file)
@@ -28,7 +28,7 @@ public:
   virtual void disable();
 
   //! Returns Id of the command
-  virtual QString getId() const
+  virtual QString id() const
   {
     return myId;
   }
index 3be26bd2a53c0f1200c99c7e84cd8c5efaff32c1..8f0ffd8d32303cf2a29cc6229b070d21a520f14b 100644 (file)
@@ -22,6 +22,9 @@ public:
   //! Returns 0 if the given index is not index of a feature
   virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
 
+  //! Returns parent index of the given feature
+  virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+
 protected:
   std::shared_ptr<ModelAPI_Document> myDocument;
 };
@@ -37,7 +40,10 @@ public:
   XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
       XGUI_FeaturesModel(theDocument, theParent) {}
 
-      void setPartId(int theId) { myId = theId; }
+  void setPartId(int theId) { myId = theId; }
+
+  //! Returns true if the given document is a sub-document of this tree
+  virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
 
 protected:
   //! Id of the current part object in the document
index b7f65b746b688082973d6bbb776a807edd10385e..a17b618eedc163ca2113eac9ab8e63c634398e74 100644 (file)
@@ -12,6 +12,7 @@
 
 
 #include <QIcon>
+#include <QString>
 
 
 XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent)
@@ -38,21 +39,66 @@ XGUI_DocumentDataModel::~XGUI_DocumentDataModel()
 
 void XGUI_DocumentDataModel::processEvent(const Event_Message* theMessage)
 {
-  beginResetModel();
-  int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft();
-  if (myPartModels.size() != aNbParts) { // resize internal models
-    while (myPartModels.size() > aNbParts) {
-      delete myPartModels.last();
-      myPartModels.removeLast();
+  if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_CREATED) {
+    const ModelAPI_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
+    std::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
+    std::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
+
+    if (aDoc == myDocument) {
+      if (aFeature->getGroup().compare(PARTS_GROUP) == 0) {
+        // Add a new part
+        int aStart = myModel->rowCount(QModelIndex()) + myPartModels.size();
+        beginInsertRows(QModelIndex(), aStart, aStart + 1);
+        XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this);
+        aModel->setPartId(myPartModels.count());
+        myPartModels.append(aModel);
+        endInsertRows();
+      } else {
+        QModelIndex aIndex = myModel->findParent(aFeature);
+        int aStart = myModel->rowCount(aIndex);
+        aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+        beginInsertRows(aIndex, aStart-1, aStart);
+        endInsertRows();
+        if (aStart == 1) // Update parent if this is a first child in order to update node decoration
+          emit dataChanged(aIndex, aIndex);
+      }
+    } else {
+      XGUI_PartModel* aPartModel = 0;
+      QList<XGUI_PartModel*>::const_iterator aIt;
+      for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
+        if ((*aIt)->hasDocument(aDoc)) {
+          aPartModel = (*aIt);
+          break;
+        }
+      }
+      if (aPartModel) {
+        QModelIndex aIndex = aPartModel->findParent(aFeature);
+        int aStart = aPartModel->rowCount(aIndex);
+        aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+        beginInsertRows(aIndex, aStart-1, aStart);
+        endInsertRows();
+        if (aStart == 1) // Update parent if this is a first child in order to update node decoration
+          emit dataChanged(aIndex, aIndex);
+      }
     }
-    while (myPartModels.size() < aNbParts) {
-      myPartModels.append(new XGUI_PartDataModel(myDocument, this));
+  } else {
+    // Reset whole tree
+    beginResetModel();
+    int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft();
+    if (myPartModels.size() != aNbParts) { // resize internal models
+      while (myPartModels.size() > aNbParts) {
+        delete myPartModels.last();
+        myPartModels.removeLast();
+      }
+      while (myPartModels.size() < aNbParts) {
+        myPartModels.append(new XGUI_PartDataModel(myDocument, this));
+      }
+      for (int i = 0; i < myPartModels.size(); i++)
+        myPartModels.at(i)->setPartId(i);
     }
-    for (int i = 0; i < myPartModels.size(); i++)
-      myPartModels.at(i)->setPartId(i);
+    clearModelIndexes();
+    endResetModel();
   }
-  clearModelIndexes();
-  endResetModel();
 }
 
 QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const
index efce9ab2c0bca4aacc50089f752d041dd8094ab4..7d8e81f351779bb8b9ffa40c29b44deccf5dfd11 100644 (file)
@@ -6,12 +6,15 @@
 #include <QTabWidget>
 #include <QLabel>
 #include <QDockWidget>
+#include <QEvent>
 
 XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent)
     : QObject(parent), myDesktop(parent)
 {
   parent->setTabPosition(Qt::TopDockWidgetArea, QTabWidget::North);
   myGeneralPage = addWorkbench(tr("General"));
+  myGeneralPage->parentWidget()->setMaximumWidth(200);
+  myGeneralPage->installEventFilter(this);
 }
 
 XGUI_MainMenu::~XGUI_MainMenu(void)
@@ -51,3 +54,38 @@ XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName)
 {
   return myDesktop->findChild<XGUI_Workbench*>(theObjName);
 }
+
+
+bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent)
+{
+  if (theWatched == myGeneralPage) {
+    if (theEvent->type() == QEvent::Show) {
+      myGeneralPage->parentWidget()->setMaximumWidth(16777215);
+      myGeneralPage->removeEventFilter(this);
+    }
+  }
+  return QObject::eventFilter(theWatched, theEvent);
+}
+
+XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const
+{
+  QList<QDockWidget*>::const_iterator aIt;
+  for (aIt = myMenuTabs.constBegin(); aIt != myMenuTabs.constEnd(); ++aIt) {
+    XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>((*aIt)->widget());
+    XGUI_Command* aCmd = aWbn->feature(theId);
+    if (aCmd)
+      return aCmd;
+  }
+  return 0;
+}
+
+QList<XGUI_Command*> XGUI_MainMenu::features() const
+{
+  QList<XGUI_Command*> aList;
+  QList<QDockWidget*>::const_iterator aIt;
+  for (aIt = myMenuTabs.constBegin(); aIt != myMenuTabs.constEnd(); ++aIt) {
+    XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>((*aIt)->widget());
+    aList.append(aWbn->features());
+  }
+  return aList;
+}
\ No newline at end of file
index 028f73b12a87c24c5225017196633afc41044f08..b683fc99edbafab754a041947c2bcf25472a15b2 100644 (file)
@@ -13,6 +13,7 @@ class QTabWidget;
 class QLabel;
 class QAction;
 class QDockWidget;
+class QEvent;
 
 /**\class XGUI_MainMenu
  * \ingroup GUI
@@ -37,6 +38,15 @@ public:
   //! Rerturns last created workbench in dock widget container
   QDockWidget* getLastDockWindow() const { return myMenuTabs.last(); }
 
+  //! Returns already created command by its ID
+  XGUI_Command* feature(const QString& theId) const;
+
+  //! Returns list of created commands
+  QList<XGUI_Command*> features() const;
+
+protected:
+  virtual bool eventFilter(QObject *theWatched, QEvent *theEvent);
+
 private:
   XGUI_MainWindow* myDesktop;
   QList<QDockWidget*> myMenuTabs;
index 25ea218c9519b3771d8e7507805341737061f50f..25516792e88563d54928306cbc6864767f5c9de3 100644 (file)
@@ -28,9 +28,9 @@
 
 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
     : QMainWindow(parent), 
-    myObjectBrowser(NULL),
-    myPythonConsole(NULL),
-    myPropertyPanelDock(NULL)
+    myObjectBrowser(0),
+    myPythonConsole(0),
+    myPropertyPanelDock(0)
 {
   setWindowTitle(tr("New Geom"));
   myMenuBar = new XGUI_MainMenu(this);
@@ -40,7 +40,7 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
 
   myViewer = new XGUI_Viewer(this);
 
-  createDockWidgets();
+  //createDockWidgets();
 }
 
 XGUI_MainWindow::~XGUI_MainWindow(void)
@@ -75,11 +75,7 @@ void XGUI_MainWindow::showPythonConsole()
     aDoc->setMinimumHeight(0);
     aDoc->setWindowTitle("Console");
     myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
-    //myPythonConsole = new QTextEdit(aDoc);
-    //myPythonConsole->setGeometry(0,0,200, 50);
-    //myPythonConsole->setText(">>>");
     aDoc->setWidget(myPythonConsole);
-    //myPythonConsole->setMinimumHeight(0);
     addDockWidget(Qt::TopDockWidgetArea, aDoc);
     tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
   }
index 4cdbba52c77782110b8287065eea657d2632afec..4f99979c998549fbc9e5f10abf037217bd08cc3c 100644 (file)
@@ -43,6 +43,9 @@ public:
     return myViewer;
   }
 
+  // Creates Dock widgets: Object broewser and Property panel
+  void createDockWidgets();
+
 public slots:
   void showPythonConsole();
   void hidePythonConsole();
@@ -52,7 +55,6 @@ public slots:
   void hideObjectBrowser();
 
 private:
-  void createDockWidgets();
   QDockWidget* createObjectBrowser();
   QDockWidget* createPropertyPanel();
 
index 4f447117c97e1c6021f99d2aee9ba0a5777762e3..00d131278ca54b0036977d42da2d37a1bac2587f 100644 (file)
@@ -71,3 +71,13 @@ XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QStrin
   addCommand(aCommand);
   return aCommand;
 }
+
+
+XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
+{
+  QList<XGUI_Command*>::const_iterator aIt;
+  for (aIt = myActions.constBegin(); aIt != myActions.constEnd(); ++aIt)
+    if ((*aIt)->id() == theId)
+      return (*aIt);
+  return 0;
+}
\ No newline at end of file
index 58fd7a7975550847c69a2e14110e38ca98a49c73..fa3152ec075867fea4cf6ea51245fad28e65dca2 100644 (file)
@@ -21,6 +21,12 @@ public:
   XGUI_Command* addFeature(const QString& theId, const QString& theTitle, const QString& theTip,
                            const QIcon& theIcon, const QKeySequence& theKeys = QKeySequence());
 
+  //! Returns already created command by its ID
+  XGUI_Command* feature(const QString& theId) const;
+
+  //! Returns list of created commands
+  QList<XGUI_Command*> features() const { return myActions; }
+
 protected:
   virtual void resizeEvent(QResizeEvent *theEvent);
 
index f68b5fc4a0bc80549363786452244953ecbde345..e58d06ef0206a69e733f21d4d36f8451a9614aae 100644 (file)
@@ -30,14 +30,16 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const
     case ParamObject:
       {
         std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
-        return aFeature->data()->getName().c_str();
+        if (aFeature)
+          return aFeature->data()->getName().c_str();
       } 
     case ConstructFolder:
         return tr("Constructions");
     case ConstructObject:
       {
         std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
-        return aFeature->data()->getName().c_str();
+        if (aFeature)
+          return aFeature->data()->getName().c_str();
       }
     }
     break;
@@ -139,6 +141,18 @@ FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
 }
 
 
+QModelIndex XGUI_TopDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+  QString aGroup(theFeature->getGroup().c_str());
+
+  if (theFeature->getGroup().compare(PARAMETERS_GROUP) == 0)
+    return createIndex(0, 0, (quintptr) ParamsFolder);
+  if (theFeature->getGroup().compare(CONSTRUCTIONS_GROUP) == 0)
+    return createIndex(1, 0, (quintptr) ConstructFolder);
+  return QModelIndex();
+}
+
+
 //******************************************************************
 //******************************************************************
 //******************************************************************
@@ -161,7 +175,8 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
     case MyRoot:
       {
         std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
-        return aFeature->data()->getName().c_str();
+        if (aFeature)
+          return aFeature->data()->getName().c_str();
       }
     case ParamsFolder:
       return tr("Parameters");
@@ -171,13 +186,15 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
       {
         std::shared_ptr<ModelAPI_Feature> aFeature = 
           featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
-        return aFeature->data()->getName().c_str();
+        if (aFeature)
+          return aFeature->data()->getName().c_str();
       }
     case ConstructObject:
       {
         std::shared_ptr<ModelAPI_Feature> aFeature = 
           featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
-        return aFeature->data()->getName().c_str();
+        if (aFeature)
+          return aFeature->data()->getName().c_str();
       }
     }
     break;
@@ -294,3 +311,20 @@ FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
   }
   return 0;
 }
+
+bool XGUI_PartDataModel::hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const
+{
+  return (featureDocument() == theDoc);
+}
+
+
+QModelIndex XGUI_PartDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+  QString aGroup(theFeature->getGroup().c_str());
+
+  if (theFeature->getGroup().compare(PARAMETERS_GROUP) == 0)
+    return createIndex(0, 0, (quintptr) ParamsFolder);
+  if (theFeature->getGroup().compare(CONSTRUCTIONS_GROUP) == 0)
+    return createIndex(1, 0, (quintptr) ConstructFolder);
+  return QModelIndex();
+}
\ No newline at end of file
index 559f007329ec32dbb8c2037854234aa73c65492a..1b3b069bf1c1d152cf9a85c41f4d30d3a579a57d 100644 (file)
@@ -35,6 +35,8 @@ public:
   //! Returns 0 if the given index is not index of a feature
   virtual FeaturePtr feature(const QModelIndex& theIndex) const;
 
+  virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+
 private:
   //! Types of QModelIndexes
   enum DataIds {
@@ -78,6 +80,12 @@ public:
   //! Returns 0 if the given index is not index of a feature
   virtual FeaturePtr feature(const QModelIndex& theIndex) const;
 
+  //! Returns true if the given document is a sub-document of this tree
+  virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const;
+
+  //! Returns parent index of the given feature
+  virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+
 private: 
   std::shared_ptr<ModelAPI_Document> featureDocument() const;
 
index cbff6377398b64164fa5c3d27defa3bfa5d0195d..510fb1b4062b2776e50862ecd83e4f812ef8044f 100644 (file)
 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
   QObject(theParent), myWorkshop(theParent)
 {
-  XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
-
-  connect(aObjBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
 }
 
+void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
+{
+  myObjectBrowser = theOB;
+  connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
 
 XGUI_SelectionMgr::~XGUI_SelectionMgr()
 {
index 58af58ea0515878ba974481329f58e539ec0a8f4..23849befe8930785c3c23d381e1c0990badff671 100644 (file)
@@ -5,6 +5,7 @@
 #include <QObject>
 
 class XGUI_Workshop;
+class XGUI_ObjectsBrowser;
 
 /**\class XGUI_SelectionMgr
  * \ingroup GUI
@@ -21,6 +22,8 @@ public:
   //! Returns list of currently selected objects
   QFeatureList selectedData() const { return mySelectedData; }
 
+  void connectObjectBrowser(XGUI_ObjectsBrowser* theOB);
+
 signals:
   //! Emited when selection in a one of viewers was changed
   void selectionChanged();
@@ -30,6 +33,7 @@ public slots:
 
 private:
   XGUI_Workshop* myWorkshop;
+  XGUI_ObjectsBrowser* myObjectBrowser;
 
   //! List of selected features
   QFeatureList mySelectedData;
index 996d5a7aeffe9df3245cb776321c6d244a430dd2..468d8d0ce1f1fdfa4732aedf1243355e605bcca2 100644 (file)
@@ -170,4 +170,24 @@ bool XGUI_Workbench::eventFilter(QObject *theObj, QEvent *theEvent)
     }
   }
   return QWidget::eventFilter(theObj, theEvent);
+}
+
+XGUI_Command* XGUI_Workbench::feature(const QString& theId) const
+{
+  QList<XGUI_MenuGroupPanel*>::const_iterator aIt;
+  for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) {
+    XGUI_Command* aCmd = (*aIt)->feature(theId);
+    if (aCmd)
+      return aCmd;
+  }
+  return 0;
+}
+
+QList<XGUI_Command*> XGUI_Workbench::features() const
+{
+  QList<XGUI_Command*> aList;
+  QList<XGUI_MenuGroupPanel*>::const_iterator aIt;
+  for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) 
+    aList.append((*aIt)->features());
+  return aList;
 }
\ No newline at end of file
index 57b17d3bea7a58a963685c8737058d4508b7078a..3c7443b3bf0c2495c1acf06cce7a1dc7918fad4d 100644 (file)
@@ -21,6 +21,12 @@ public:
   XGUI_MenuGroupPanel* addGroup(const QString& theId);
   XGUI_MenuGroupPanel* findGroup(const QString& theName);
 
+  //! Returns already created command by its ID
+  XGUI_Command* feature(const QString& theId) const;
+
+  //! Returns list of created commands
+  QList<XGUI_Command*> features() const;
+
 private slots:
   void onLeftScroll();
   void onRightScroll();
@@ -29,6 +35,7 @@ protected:
   virtual void resizeEvent(QResizeEvent * theEvent);
   virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
 
+
 private:
   void addSeparator();
   bool isExceedsLeft();
index 0aa5bde710846343163a4df7c4d99633bf027d40..284332eed3ceefd757fcb002492adcdd67e66812 100644 (file)
@@ -66,6 +66,7 @@ void XGUI_Workshop::startApplication()
   activateModule();
   myMainWindow->show();
 
+  updateCommandStatus();
   // Testing of document creation
   //std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   //std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
@@ -96,9 +97,11 @@ void XGUI_Workshop::initMenu()
 
   aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
                                 QIcon(":pictures/undo.png"), QKeySequence::Undo);
+  aCommand->connectTo(this, SLOT(onUndo()));
 
   aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
                                 QIcon(":pictures/redo.png"), QKeySequence::Redo);
+  aCommand->connectTo(this, SLOT(onRedo()));
 
   aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
                                 QIcon(":pictures/rebuild.png"));
@@ -132,9 +135,10 @@ XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
 //******************************************************
 void XGUI_Workshop::processEvent(const Event_Message* theMessage)
 {
-  const Config_FeatureMessage* aFeatureMsg =
-      dynamic_cast<const Config_FeatureMessage*>(theMessage);
-  if (aFeatureMsg) {
+  static Event_ID aFeatureId = Event_Loop::loop()->eventByName("FeatureEvent");
+  if (theMessage->eventID() == aFeatureId) {
+    const Config_FeatureMessage* aFeatureMsg =
+        dynamic_cast<const Config_FeatureMessage*>(theMessage);
     addFeature(aFeatureMsg);
     return;
   }
@@ -146,6 +150,7 @@ void XGUI_Workshop::processEvent(const Event_Message* theMessage)
     if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
       myCurrentOperation->start();
       myCurrentOperation->commit();
+      updateCommandStatus();
     } else {
       fillPropertyPanel(aOperation);
     }
@@ -247,30 +252,57 @@ void XGUI_Workshop::onExit()
 void XGUI_Workshop::onNew()
 {
   QApplication::setOverrideCursor(Qt::WaitCursor);
+  if (myMainWindow->objectBrowser() == 0) {
+    myMainWindow->createDockWidgets();
+    mySelector->connectObjectBrowser(myMainWindow->objectBrowser());
+  }
   myMainWindow->showObjectBrowser();
   myMainWindow->showPythonConsole();
   QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
   aWnd->showMaximized();
+  updateCommandStatus();
   QApplication::restoreOverrideCursor();
 }
 
 //******************************************************
 void XGUI_Workshop::onOpen()
 {
-  QString aFileName = QFileDialog::getOpenFileName(mainWindow());
+  //QString aFileName = QFileDialog::getOpenFileName(mainWindow());
+  updateCommandStatus();
 }
 
 //******************************************************
 void XGUI_Workshop::onSave()
 {
+  updateCommandStatus();
 }
 
 //******************************************************
 void XGUI_Workshop::onSaveAs()
 {
-  QString aFileName = QFileDialog::getSaveFileName(mainWindow());
+  //QString aFileName = QFileDialog::getSaveFileName(mainWindow());
+  updateCommandStatus();
+}
+
+//******************************************************
+void XGUI_Workshop::onUndo()
+{
+  std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+  std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+  aDoc->undo();
+  updateCommandStatus();
 }
 
+//******************************************************
+void XGUI_Workshop::onRedo()
+{
+  std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+  std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+  aDoc->redo();
+  updateCommandStatus();
+}
+
+
 //******************************************************
 XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
 {
@@ -340,3 +372,38 @@ bool XGUI_Workshop::activateModule()
   myPartSetModule->createFeatures();
   return true;
 }
+
+//******************************************************
+void XGUI_Workshop::updateCommandStatus()
+{
+  XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+
+  QList<XGUI_Command*> aCommands = aMenuBar->features();
+  QList<XGUI_Command*>::const_iterator aIt;
+
+  std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+  if (aMgr->hasRootDocument()) {
+    XGUI_Command* aUndoCmd;
+    XGUI_Command* aRedoCmd;
+    for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
+      if ((*aIt)->id() == "UNDO_CMD")
+        aUndoCmd = (*aIt);
+      else if ((*aIt)->id() == "REDO_CMD")
+        aRedoCmd = (*aIt);
+      else // Enable all commands
+        (*aIt)->enable();
+    }
+    std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+    aUndoCmd->setEnabled(aDoc->canUndo());
+    aRedoCmd->setEnabled(aDoc->canRedo());
+  } else {
+    for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
+      if ((*aIt)->id() == "NEW_CMD")
+        (*aIt)->enable();
+      else if ((*aIt)->id() == "EXIT_CMD")
+        (*aIt)->enable();
+      else 
+        (*aIt)->disable();
+    }
+  }
+}
\ No newline at end of file
index 16c5425431e84a38f96446511712afededd8fe71..31d87bbbc4d0a522b3d5a4520deb4c8898b78f09 100644 (file)
@@ -50,11 +50,15 @@ public:
   virtual void processEvent(const Event_Message* theMessage);
 
 public slots:
+  void updateCommandStatus();
+
   void onNew();
   void onOpen();
   void onSave();
   void onSaveAs();
   void onExit();
+  void onUndo();
+  void onRedo();
 
 protected:
   //Event-loop processing methods: