X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=17be4e5309218cd94261291618e6ae54b8dc33ff;hb=08a596f683652d0694b58dbb14eadfe11163c803;hp=1e7e18aba3c1fa9a8fd4c90d8bdab0dcf0f968dc;hpb=189f03f2176ded8896ec9da89e5ecaca2f3e870d;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 1e7e18aba..17be4e530 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -55,6 +55,8 @@ #include #endif +#include + #include #include #include @@ -295,8 +297,7 @@ void XGUI_Workshop::startApplication() Config_PropManager::registerProp("Plugins", "default_path", "Default Path", Config_Prop::Directory, ""); - std::string aDir = getenv(QString("%1Resources").arg( - ModuleBase_Preferences::resourceMgr()->appName()).toLatin1()); + std::string aDir = Config_XMLReader::resourcesConfigFile(); Config_PropManager::registerProp("Plugins", "import_initial_path", "Import initial directory", Config_Prop::Directory, aDir); @@ -327,7 +328,7 @@ void XGUI_Workshop::startApplication() #ifdef _DEBUG bool aNewPart = Config_PropManager::boolean("Plugins", "create_part_by_start"); if (aNewPart) { - module()->launchOperation("Part", false); + module()->launchOperation("Part", false); // PartSetPlugin_Part::ID() } #endif } @@ -617,8 +618,6 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation) aWidget->restoreValue(); aWidget->enableFocusProcessing(); } - ModuleBase_Tools::flushUpdated(aFeature); - // update visible state of Preview button std::shared_ptr aFeatureInfo; #ifdef HAVE_SALOME @@ -647,6 +646,10 @@ void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation) new Events_Message(Events_Loop::eventByName(EVENT_PREVIEW_BLOCKED))); Events_Loop::loop()->send(aMsg); } + // if update happens after preview is blocked, it does nothing when blocked + // it improves performance for valid objects on feature start + ModuleBase_Tools::flushUpdated(aFeature); + myPropertyPanel->setModelWidgets(aWidgets); aFOperation->setPropertyPanel(myPropertyPanel); @@ -868,6 +871,22 @@ void XGUI_Workshop::openDirectory(const QString& theDirectory) #ifndef HAVE_SALOME myMainWindow->setCurrentDir(myCurrentDir, true); #endif + +#ifdef _DEBUG + bool aNewPart = Config_PropManager::boolean("Plugins", "create_part_by_start"); + if (aNewPart) { + + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); + int aSize = aRootDoc->size(ModelAPI_ResultPart::group()); + if (aSize > 0 ) { + ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), 0); + ResultPartPtr aPart = std::dynamic_pointer_cast(aObject); + if (aPart.get()) + aPart->activate(); + } + } +#endif + QApplication::restoreOverrideCursor(); } @@ -999,6 +1018,10 @@ bool XGUI_Workshop::onSaveAs() //****************************************************** void XGUI_Workshop::onUndo(int theTimes) { + ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget(); + if (anActiveWidget && anActiveWidget->processAction(ActionUndo)) + return; + objectBrowser()->treeView()->setCurrentIndex(QModelIndex()); SessionPtr aMgr = ModelAPI_Session::get(); std::list aUndoList = aMgr->undoList(); @@ -1022,6 +1045,10 @@ void XGUI_Workshop::onUndo(int theTimes) //****************************************************** void XGUI_Workshop::onRedo(int theTimes) { + ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget(); + if (anActiveWidget && anActiveWidget->processAction(ActionRedo)) + return; + // the viewer update should be blocked in order to avoid the features blinking. For the created // feature a results are created, the flush of the created signal caused the viewer redisplay for // each created result. After a redisplay signal is flushed. So, the viewer update is blocked @@ -1071,13 +1098,13 @@ void XGUI_Workshop::onRedo(int theTimes) //****************************************************** void XGUI_Workshop::onWidgetStateChanged(int thePreviousState) { - ModuleBase_ModelWidget* anActiveWidget = 0; - ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); - if (anOperation) { - ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); - if (aPanel) - anActiveWidget = aPanel->activeWidget(); - } + ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget(); + //ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); + //if (anOperation) { + // ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel(); + // if (aPanel) + // anActiveWidget = aPanel->activeWidget(); + //} if (anActiveWidget) operationMgr()->onValidateOperation(); @@ -1206,10 +1233,24 @@ void XGUI_Workshop::updateCommandStatus() if (aMgr->hasModuleDocument()) { foreach(QAction* aCmd, aCommands) { QString aId = aCmd->data().toString(); - if (aId == "UNDO_CMD") - aCmd->setEnabled(myModule->canUndo()); - else if (aId == "REDO_CMD") - aCmd->setEnabled(myModule->canRedo()); + if (aId == "UNDO_CMD") { + bool isActionEnabled = false; + // if ultimate is true -> using result of operation only, or using OR combination + ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget(); + if (anActiveWidget && anActiveWidget->canProcessAction(ActionUndo, isActionEnabled)) + aCmd->setEnabled(isActionEnabled); + else + aCmd->setEnabled(myModule->canUndo()); + } + else if (aId == "REDO_CMD") { + bool isActionEnabled = false; + // if ultimate is true -> using result of operation only, or using OR combination + ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget(); + if (anActiveWidget && anActiveWidget->canProcessAction(ActionRedo, isActionEnabled)) + aCmd->setEnabled(isActionEnabled); + else + aCmd->setEnabled(myModule->canRedo()); + } else // Enable all commands aCmd->setEnabled(true); @@ -2173,6 +2214,15 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible) aObj->setDisplayed(isVisible); } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); +#ifndef WIN32 + // Necessary for update icons in ObjectBrowser on Linux + QModelIndexList aIndexes = mySelector->selection()->selectedIndexes(); + foreach (QModelIndex aIdx, aIndexes) { + if (aIdx.column() == 0) { + myObjectBrowser->treeView()->update(aIdx); + } + } +#endif } //************************************************************** @@ -2198,6 +2248,15 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList) aObj->setDisplayed(true); } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); +#ifndef WIN32 + // Necessary for update icons in ObjectBrowser on Linux + QModelIndexList aIndexes = mySelector->selection()->selectedIndexes(); + foreach (QModelIndex aIdx, aIndexes) { + if (aIdx.column() == 0) { + myObjectBrowser->treeView()->update(aIdx); + } + } +#endif }