From: sbh Date: Thu, 22 May 2014 09:46:23 +0000 (+0400) Subject: Merge branch 'master' of newgeom:newgeom.git X-Git-Tag: V_0.2~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=503b5444d4a5fa95a3046a754f69f5b79e677e33;hp=0b636ffd42324731b8dba44ad3b9ace84a8c5d4f;p=modules%2Fshaper.git Merge branch 'master' of newgeom:newgeom.git Conflicts: src/XGUI/XGUI_Workshop.h --- diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index 9408522e6..7b0f60337 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -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; diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 99116d707..9328e0690 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -27,6 +27,7 @@ class Config_FeatureMessage: public Events_Message std::string myPluginLibrary; //Name of feature's library bool myUseInput; //Action is being checked until user commit the operation + bool myInternal; //Internal feature without GUI representation std::string myNestedFeatures; public: @@ -45,6 +46,7 @@ public: CONFIG_EXPORT const std::string& pluginLibrary() const; CONFIG_EXPORT const std::string& nestedFeatures() const; CONFIG_EXPORT bool isUseInput() const; + CONFIG_EXPORT bool isInternal() const; CONFIG_EXPORT void setIcon(const std::string& icon); CONFIG_EXPORT void setId(const std::string& id); @@ -56,6 +58,7 @@ public: CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary); CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures); CONFIG_EXPORT void setUseInput(bool isUseInput); + CONFIG_EXPORT void setInternal(bool isInternal); }; #endif // CONFIG_MESSAGE_H diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 78e485e91..6e6bbb85f 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -17,6 +17,7 @@ #include #include +#include #ifdef _DEBUG #include @@ -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; } diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index e4e7c63db..1add8438d 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -31,6 +31,7 @@ protected: bool processChildren(xmlNodePtr aNode); void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage); + bool isInternalFeature(xmlNodePtr theRoot); private: std::string myLastWorkbench; diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 281248f85..25433ffa9 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -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"; diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index e6fdeffde..c533e3e3e 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -84,9 +84,6 @@ std::list 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; diff --git a/src/ConstructionPlugin/plugin-Construction.xml b/src/ConstructionPlugin/plugin-Construction.xml index 912d04e0c..26a27bc83 100644 --- a/src/ConstructionPlugin/plugin-Construction.xml +++ b/src/ConstructionPlugin/plugin-Construction.xml @@ -4,8 +4,8 @@ - - + + diff --git a/src/ModelAPI/ModelAPI_PluginManager.cpp b/src/ModelAPI/ModelAPI_PluginManager.cpp index a8d497c7c..eb79b9d03 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ b/src/ModelAPI/ModelAPI_PluginManager.cpp @@ -49,9 +49,6 @@ void ModelAPI_PluginManager::SetPluginManager( boost::shared_ptr 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; diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 29cf61b04..5f100983e 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -5,12 +5,12 @@ - + - + diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 65450b189..9d064f210 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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(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(); } diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 21ee4a87b..8ffb703b8 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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 myIcons; };