Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Thu, 22 May 2014 09:46:23 +0000 (13:46 +0400)
committersbh <sergey.belash@opencascade.com>
Thu, 22 May 2014 09:46:23 +0000 (13:46 +0400)
Conflicts:
src/XGUI/XGUI_Workshop.h

src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_Keywords.h
src/Config/Config_ModuleReader.cpp
src/ConstructionPlugin/plugin-Construction.xml
src/ModelAPI/ModelAPI_PluginManager.cpp
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 9408522e6a9f90c4ce1fcbead4f96ff3cf7217b8..7b0f603371f6c7823df85b0e33fb086efefe7322 100644 (file)
@@ -14,6 +14,11 @@ Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void*
 
   myGroupId = "";
   myWorkbenchId = "";
+  myPluginLibrary = "";
+
+  myInternal = false;
+  myUseInput = false;
+  myNestedFeatures = "";
 }
 
 const std::string& Config_FeatureMessage::icon() const
@@ -101,11 +106,21 @@ bool Config_FeatureMessage::isUseInput() const
   return myUseInput;
 }
 
+bool Config_FeatureMessage::isInternal() const
+{
+  return myInternal;
+}
+
 void Config_FeatureMessage::setUseInput(bool isUseInput)
 {
   myUseInput = isUseInput;
 }
 
+void Config_FeatureMessage::setInternal(bool isInternal)
+{
+  myInternal = isInternal;
+}
+
 const std::string& Config_FeatureMessage::nestedFeatures() const
 {
   return myNestedFeatures;
index 99116d707e0f9be53ace04483b9d9c3b627d5dc8..9328e0690775df4e1fb7bdc44ba625477bb3a846 100644 (file)
@@ -27,6 +27,7 @@ class Config_FeatureMessage: public Events_Message
   std::string myPluginLibrary;  //Name of feature's library\r
 \r
   bool myUseInput; //Action is being checked until user commit the operation\r
+  bool myInternal; //Internal feature without GUI representation\r
   std::string myNestedFeatures;\r
 \r
 public:\r
@@ -45,6 +46,7 @@ public:
   CONFIG_EXPORT const std::string& pluginLibrary() const;\r
   CONFIG_EXPORT const std::string& nestedFeatures() const;\r
   CONFIG_EXPORT bool isUseInput() const;\r
+  CONFIG_EXPORT bool isInternal() const;\r
 \r
   CONFIG_EXPORT void setIcon(const std::string& icon);\r
   CONFIG_EXPORT void setId(const std::string& id);\r
@@ -56,6 +58,7 @@ public:
   CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
   CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
   CONFIG_EXPORT void setUseInput(bool isUseInput);\r
+  CONFIG_EXPORT void setInternal(bool isInternal);\r
 };\r
 \r
 #endif // CONFIG_MESSAGE_H\r
index 78e485e912d1b5e294d160c57b380e57273aff39..6e6bbb85f6f7abdbb656619f58b35bce114f308c 100644 (file)
@@ -17,6 +17,7 @@
 #include <libxml/xmlstring.h>
 
 #include <string>
+#include <algorithm>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -72,12 +73,28 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
 void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
 {
   outFtMessage.setId(getProperty(theRoot, _ID));
+  outFtMessage.setPluginLibrary(myLibraryName);
+  outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+  bool isFtInternal = isInternalFeature(theRoot);
+  outFtMessage.setInternal(isFtInternal);
+  if(isFtInternal) {
+    //Internal feature has no visual representation.
+    return;
+  }
   outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
   outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
   outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
   outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
   outFtMessage.setGroupId(myLastGroup);
   outFtMessage.setWorkbenchId(myLastWorkbench);
-  outFtMessage.setPluginLibrary(myLibraryName);
-  outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+}
+
+bool Config_FeatureReader::isInternalFeature(xmlNodePtr theRoot)
+{
+  std::string prop = getProperty(theRoot, FEATURE_INTERNAL);
+  std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
+  if(prop.empty() || prop == "false" || prop == "0") {
+    return false;
+  }
+  return true;
 }
index e4e7c63db8590674f4feb7c61fe0688083a1c7e8..1add8438d464da227b792435783df3907af2ce2c 100644 (file)
@@ -31,6 +31,7 @@ protected:
   bool processChildren(xmlNodePtr aNode);
 
   void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
+  bool isInternalFeature(xmlNodePtr theRoot);
 
 private:
   std::string myLastWorkbench;
index 281248f858314326cc871cef581e3d655f054355..25433ffa9ad55ca8143bb309167cb368645e9919 100644 (file)
@@ -39,6 +39,7 @@ const static char* FEATURE_TOOLTIP = "tooltip";
 const static char* FEATURE_ICON = "icon";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
+const static char* FEATURE_INTERNAL = "internal";
 const static char* SOURCE_FILE = "path";
 
 
index e6fdeffdeb9414aa9b37c72e6b8191c7b611fd45..c533e3e3e92b69565f2a5494ee1bbdb9aeaef5d6 100644 (file)
@@ -84,9 +84,6 @@ std::list<std::string> Config_ModuleReader::importPlugin(const std::string& theP
 
 void Config_ModuleReader::loadLibrary(const std::string theLibName)
 {
-#ifdef _DEBUG
-  std::cout << "Config_ModuleReader::loading library... "  << theLibName.c_str() << std::endl;
-#endif
   std::string aFileName = library(theLibName);
   if (aFileName.empty())
     return;
index 912d04e0ca636ce6e2acd9dfd7598ccde8300029..26a27bc83ef32f3b901e92ccc6d691dbe96bd10b 100644 (file)
@@ -4,8 +4,8 @@
       <feature id="Point" text="Point" tooltip="Create a new point" icon=":icons/point.png">
         <source path="point_widget.xml"/>
       </feature>
-      <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence=""/>
-      <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence=""/>
+      <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
+      <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
     </group>
   </workbench>  
 </plugin>
index a8d497c7c6986d6146148f7d525e83c54b09374d..eb79b9d03d3a7e0c32e119be73a8b43204bc353c 100644 (file)
@@ -49,9 +49,6 @@ void ModelAPI_PluginManager::SetPluginManager(
 boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
 {
   if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
-    #ifdef _DEBUG
-    std::cout << "ModelAPI_PluginManager::get: " << "Model library has not been loaded from xml." << std::endl;
-    #endif
     Config_ModuleReader::loadLibrary("Model");
   }
   return MY_MANAGER;
index 29cf61b04a16a7c8ad45c3e60295d10fdf4c4dcf..5f100983e57b9645a43805fb5f94d5269709c26b 100644 (file)
@@ -5,12 +5,12 @@
         <label text="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
-      <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png" />
+      <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png"/>
       <feature id="SketchLine" text="Line" tooltip="Create a new line" icon=":icons/line.png">
         <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
         <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
-      <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" icon="" />
+      <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
     </group>
   </workbench>
 </plugin>
index 65450b189a2bc6bb7968684516f3ddc3ac732f41..9d064f210bbe9500ad01613bbf22880196a9efcd 100644 (file)
@@ -70,7 +70,7 @@ QString XGUI_Workshop::featureIcon(const std::string& theId)
 
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   : QObject(),
-  myCurrentFile(QString()),
+  myCurrentDir(QString()),
   myPartSetModule(NULL),
   mySalomeConnector(theConnector),
   myPropertyPanel(0),
@@ -204,7 +204,9 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
   if (theMessage->eventID() == aFeatureLoadedId) {
     const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
-    addFeature(aFeatureMsg);
+    if(!aFeatureMsg->isInternal()) {
+      addFeature(aFeatureMsg);
+    }
     return;
   }
   // Process creation of Part
@@ -440,21 +442,21 @@ void XGUI_Workshop::onOpen()
       return;
     }
     aDoc->close();
-    myCurrentFile = "";
+    myCurrentDir = "";
   }
 
   //show file dialog, check if readable and open
-  myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
-  if(myCurrentFile.isEmpty())
+  myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
+  if(myCurrentDir.isEmpty())
     return;
-  QFileInfo aFileInfo(myCurrentFile);
+  QFileInfo aFileInfo(myCurrentDir);
   if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
     QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
-    myCurrentFile = "";
+    myCurrentDir = "";
     return;
   }
   QApplication::setOverrideCursor(Qt::WaitCursor);
-  aDoc->load(myCurrentFile.toLatin1().constData());
+  aDoc->load(myCurrentDir.toLatin1().constData());
   QApplication::restoreOverrideCursor();
   updateCommandStatus();
 }
@@ -462,28 +464,38 @@ void XGUI_Workshop::onOpen()
 //******************************************************
 void XGUI_Workshop::onSave()
 {
-  if(myCurrentFile.isEmpty()) {
+  if(myCurrentDir.isEmpty()) {
     onSaveAs();
     return;
   }
-  saveDocument(myCurrentFile);
+  saveDocument(myCurrentDir);
   updateCommandStatus();
 }
 
 //******************************************************
 void XGUI_Workshop::onSaveAs()
 {
-  QString aTemp = myCurrentFile;
-  myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
-  if(myCurrentFile.isEmpty()) {
-    myCurrentFile = aTemp;
+  QFileDialog dialog(mainWindow());
+  dialog.setWindowTitle(tr("Select directory to save files..."));
+  dialog.setFileMode(QFileDialog::Directory);
+  dialog.setFilter(tr("Folders (*)"));
+  dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
+  dialog.setViewMode(QFileDialog::Detail);
+
+  if(!dialog.exec()) {
     return;
   }
-  QFileInfo aFileInfo(myCurrentFile);
-  if(aFileInfo.exists() && !aFileInfo.isWritable()) {
-    QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
-    return;
+  QString aTempDir = dialog.selectedFiles().first();
+  QDir aDir(aTempDir);
+  if(aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).isEmpty()) {
+    int answer = QMessageBox::question(myMainWindow,
+                                       QString(),
+                                       tr("The folder already contains some files, save anyway?"),
+                                       QMessageBox::Save|QMessageBox::Cancel);
+    if(answer == QMessageBox::Cancel)
+      return;
   }
+  myCurrentDir = aTempDir;
   onSave();
 }
 
index 21ee4a87b6cd86f755b56630bcc2a7c42b231648..8ffb703b82a02815e36e2deeae0e7f1a46cecec6 100644 (file)
@@ -158,7 +158,6 @@ private:
   // Creates Dock widgets: Object browser and Property panel
   void createDockWidgets();
 
-  QString myCurrentFile;
   XGUI_MainWindow* myMainWindow;
   XGUI_Module* myPartSetModule;
   XGUI_ObjectsBrowser* myObjectBrowser;
@@ -172,6 +171,7 @@ private:
   XGUI_ViewerProxy* myViewerProxy;
   XGUI_ContextMenuMgr* myContextMenuMgr;
 
+  QString myCurrentDir;
   static QMap<QString, QString> myIcons;
 
 };