From: mpv Date: Fri, 8 Apr 2022 16:57:15 +0000 (+0300) Subject: Option to create new part on study open X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34de42dc1899a23c3ee7a8d68ad306d67a6c9d94;p=modules%2Fshaper.git Option to create new part on study open --- diff --git a/doc/gui/General/Introduction.rst b/doc/gui/General/Introduction.rst index eea5fbf0f..e55324566 100644 --- a/doc/gui/General/Introduction.rst +++ b/doc/gui/General/Introduction.rst @@ -468,7 +468,7 @@ Other tabs are activated by click on tab header. General tab ^^^^^^^^^^^ -This tab defines what parts to be activated and what elements to be visible after opening a study or a script. +This tab defines behavior of Parts and displayed objects on creation or opening of a study, or loading python scripts. .. figure:: /images/general_preferences.png :align: center @@ -477,6 +477,8 @@ This tab defines what parts to be activated and what elements to be visible afte **Input fields**: +- **Create new part** flag. If it is enabled, an empty part is created on a study creation. + - **Activate** relates to activation of part when opening a HDF document. Its could be one of the following: - "Last part" - activate last part in the document (**default value**); diff --git a/doc/gui/images/general_preferences.png b/doc/gui/images/general_preferences.png index e7eee1721..0589e79d9 100644 Binary files a/doc/gui/images/general_preferences.png and b/doc/gui/images/general_preferences.png differ diff --git a/src/Events/CMakeLists.txt b/src/Events/CMakeLists.txt index 3ebeb8efd..183ffbd43 100644 --- a/src/Events/CMakeLists.txt +++ b/src/Events/CMakeLists.txt @@ -30,6 +30,7 @@ SET(PROJECT_HEADERS Events_Loop.h Events_LongOp.h Events_InfoMessage.h + Events_MessageBool.h ) SET(PROJECT_SOURCES @@ -39,6 +40,7 @@ SET(PROJECT_SOURCES Events_Loop.cpp Events_LongOp.cpp Events_InfoMessage.cpp + Events_MessageBool.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/Events/Events_MessageBool.cpp b/src/Events/Events_MessageBool.cpp new file mode 100644 index 000000000..eb79aaa29 --- /dev/null +++ b/src/Events/Events_MessageBool.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "Events_MessageBool.h" + +void Events_MessageBool::send() +{ + std::shared_ptr aMsg(new Events_MessageBool(*this)); + Events_Loop::loop()->send(aMsg); +} diff --git a/src/Events/Events_MessageBool.h b/src/Events/Events_MessageBool.h new file mode 100644 index 000000000..891b0815d --- /dev/null +++ b/src/Events/Events_MessageBool.h @@ -0,0 +1,62 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef Events_MessageBool_H_ +#define Events_MessageBool_H_ + +#include +#include +#include + +#include +#include + +/**\class Events_MessageBool + * \ingroup EventsLoop + * \brief An event message for sending a message with a boolean value. + * May be used for different where just a Boolean flag is needed to send. + */ +class Events_MessageBool: public Events_Message +{ +public: + + /// Constructor + /// \param theEventID an indentifier of the message + /// \param theValue a Boolean value to send + /// \param theSender a pointer on sender object + Events_MessageBool(const Events_ID theEventID, const bool theValue, const void* theSender = 0): + Events_Message(theEventID, theSender), myValue(theValue) {} + + /// Default destructor + virtual ~Events_MessageBool() {} + + /// Returns the value stored in this message. + const bool value() const { return myValue; } + + /// Sends the message + EVENTS_EXPORT void send(); + +private: + + /// The stored value + bool myValue; + +}; + +#endif diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index e8ffbc935..5c7305206 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -33,6 +33,7 @@ #include #include +#include #include @@ -40,14 +41,17 @@ static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = new InitializationPlugin_Plugin(); -InitializationPlugin_Plugin::InitializationPlugin_Plugin() +InitializationPlugin_Plugin::InitializationPlugin_Plugin() : + myCreatePartOnStart(false) // by default in TUI mode part is not created on start of PartSet { char* isUnitTest = getenv("SHAPER_UNIT_TEST_IN_PROGRESS"); myInitDataModel = (!isUnitTest || isUnitTest[0] != '1'); Events_Loop* aLoop = Events_Loop::loop(); - const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); + static const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); aLoop->registerListener(this, kDocCreatedEvent, NULL, true); + static const Events_ID kCreatePartEvent = Events_Loop::eventByName(EVENT_CREATE_PART_ON_START); + aLoop->registerListener(this, kCreatePartEvent, NULL, true); myEvalListener = std::shared_ptr(new InitializationPlugin_EvalListener()); @@ -55,7 +59,8 @@ InitializationPlugin_Plugin::InitializationPlugin_Plugin() void InitializationPlugin_Plugin::processEvent(const std::shared_ptr& theMessage) { - const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); + static const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); + static const Events_ID kCreatePartEvent = Events_Loop::eventByName(EVENT_CREATE_PART_ON_START); if (theMessage->eventID() == kDocCreatedEvent) { std::shared_ptr aMessage = std::dynamic_pointer_cast< ModelAPI_DocumentCreatedMessage>(theMessage); @@ -63,13 +68,15 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrmoduleDocument()) + SessionPtr aMgr = ModelAPI_Session::get(); + if (aDoc != aMgr->moduleDocument() || aMgr->isLoading()) return; if (myInitDataModel) myEvalListener->initDataModel(); std::list aFeatures; + aMgr->startOperation("Initialization"); // the viewer update should be blocked in order to avoid the features blinking before they are // hidden @@ -85,6 +92,8 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrflush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -100,13 +109,21 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrflush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - // the viewer update should be unblocked in order to avoid the features blinking before they are - // hidden + + aMgr->finishOperation(); // before last message flush to update the title, make it not-modified + aMgr->clearUndoRedo(); // to forbid undo of auxiliary elements and initial part + + // the viewer update should be unblocked to avoid the features blinking before they are hidden aMsg = std::shared_ptr( new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); Events_Loop::loop()->send(aMsg); } + else if (theMessage->eventID() == kCreatePartEvent) + { + std::shared_ptr aMsg = std::dynamic_pointer_cast(theMessage); + myCreatePartOnStart = aMsg->value(); + } } FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double theX, double theY, @@ -189,3 +206,10 @@ FeaturePtr InitializationPlugin_Plugin::createAxis(DocumentPtr theDoc, FeaturePt return aAxis; } + +void InitializationPlugin_Plugin::createPart(DocumentPtr thePartSet) +{ + std::shared_ptr aPart = thePartSet->addFeature("Part"); + if (aPart.get()) + aPart->execute(); // to initialize and activate this part document +} diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.h b/src/InitializationPlugin/InitializationPlugin_Plugin.h index cff630708..530586530 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.h +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.h @@ -70,9 +70,13 @@ class InitializationPlugin_Plugin : public Events_Listener FeaturePtr createAxis(DocumentPtr theDoc, FeaturePtr theOrigin, double theX, double theY, double theZ); + /// Creates and activates a new part in PartSet document. + void createPart(DocumentPtr thePartSet); + private: std::shared_ptr myEvalListener; bool myInitDataModel; + bool myCreatePartOnStart; }; #endif diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 505b77f36..c5732ba09 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1136,6 +1136,21 @@ void Model_Document::redo() // update the current features status setCurrentFeature(currentFeature(false), false); } + +void Model_Document::clearUndoRedo() +{ + myNestedNum.clear(); + myTransactions.clear(); + myRedos.clear(); + myTransactionSave = 0; + myDoc->ClearUndos(); + myDoc->ClearRedos(); + // clear for all subs + const std::set aSubs = subDocuments(); + for (std::set::iterator aSubIter = aSubs.begin(); aSubIter != aSubs.end(); aSubIter++) + subDoc(*aSubIter)->clearUndoRedo(); +} + // this is used for creation of undo/redo1-list by GUI // LCOV_EXCL_START std::list Model_Document::undoList() const diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 122d4439e..e7dcd1296 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -106,6 +106,8 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual bool canRedo(); //! Redoes last operation MODEL_EXPORT virtual void redo(); + //! Clears undo/redo lists + MODEL_EXPORT virtual void clearUndoRedo(); //! Adds to the document the new feature of the given feature id //! \param theID creates feature and puts it in the document diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 38ed84cfc..914912e08 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -60,7 +60,9 @@ static Model_Session* myImpl = new Model_Session(); bool Model_Session::load(const char* theFileName) { + myIsLoading = true; bool aRes = ROOT_DOC->load(theFileName, "root", ROOT_DOC); + myIsLoading = false; return aRes; } @@ -179,6 +181,11 @@ std::list Model_Session::redoList() return ROOT_DOC->redoList(); } +void Model_Session::clearUndoRedo() +{ + return ROOT_DOC->clearUndoRedo(); +} + bool Model_Session::checkLicense(const std::string& thePluginName) { return getPlugin(thePluginName); @@ -448,6 +455,7 @@ Model_Session::Model_Session() { myPluginsInfoLoaded = false; myCheckTransactions = true; + myIsLoading = false; ModelAPI_Session::setSession(std::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index 88397ec4c..b7be223a0 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -99,6 +99,8 @@ class Model_Session : public ModelAPI_Session, public Events_Listener MODEL_EXPORT virtual std::list undoList(); //! Returns stack of rolled back operations MODEL_EXPORT virtual std::list redoList(); + //! Clears undo and redo lists of all documents in the session + MODEL_EXPORT virtual void clearUndoRedo(); /// Returns the root document of the application (that may contains sub-documents) MODEL_EXPORT virtual std::shared_ptr moduleDocument(); diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index efab2fae1..0e7a2308a 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -129,6 +129,10 @@ MAYBE_UNUSED static const char * EVENT_REMOVE_CONSTRAINTS = "RemoveConstrains"; /// Event ID that license of specified features is checked and valid MAYBE_UNUSED static const char * EVENT_FEATURE_LICENSE_VALID = "FeaturesLicenseValid"; +/// To send preferences information: create part on init or not +MAYBE_UNUSED static const char * EVENT_CREATE_PART_ON_START = "CreatePartOnStart"; + + /// Message that feature was changed (used for Object Browser update): moved, updated and deleted class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup { diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 7a1b2f40d..962a05c89 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -45,6 +45,9 @@ class ModelAPI_FiltersFactory; class MODELAPI_EXPORT ModelAPI_Session { +protected: + bool myIsLoading; ///< keeps the state of the loading of the document + public: /// Returns the real implementation (the alone instance per application) of the plugin manager static std::shared_ptr get(); @@ -54,6 +57,9 @@ class MODELAPI_EXPORT ModelAPI_Session //! \returns true if file was loaded successfully virtual bool load(const char* theFileName) = 0; + //! Returns true if a loading process is performed (so, no need to react on a new part creation) + virtual bool isLoading() { return myIsLoading; }; + //! Saves the OCAF document to the file. //! \param theFileName full name of the file to store //! \param theResults the result full file names that were stored by "save" @@ -91,6 +97,8 @@ class MODELAPI_EXPORT ModelAPI_Session virtual std::list undoList() = 0; //! Returns stack of rolled back operations (from last rolled back to first) virtual std::list redoList() = 0; + //! Clears undo and redo lists of all documents in the session + virtual void clearUndoRedo() = 0; /// Registers the plugin that creates features. /// It is obligatory for each plugin to call this function on loading to be found by diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 763798c8b..c8e3dec91 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -111,7 +112,33 @@ void begin() static std::string anOperationPrefix(ModuleBase_Tools::translate("", "Operation").toStdString()); std::ostringstream aTransactionName; aTransactionName << anOperationPrefix << "_" << aTransactionID; - ModelAPI_Session::get()->startOperation(aTransactionName.str()); + + // check the first transaction and part, automatically created on start of PartSet + std::shared_ptr aSession = ModelAPI_Session::get(); + if (aSession->undoList().empty() && aSession->redoList().empty() && // no undo/redo available + aSession->moduleDocument()->size(ModelAPI_ResultPart::group()) == 1 && // only one part + aSession->moduleDocument()->size(ModelAPI_Feature::group()) == 1) // only part feature + { + ResultPartPtr aPartRes = std::dynamic_pointer_cast + (aSession->moduleDocument()->object(ModelAPI_ResultPart::group(), 0)); + if (aPartRes.get() && aPartRes->isActivated()) + { + DocumentPtr aPartDoc = aPartRes->partDoc(); + if (aPartDoc.get() && aPartDoc->size(ModelAPI_Feature::group()) == 0) // no features in part + { + // remove the automtically created part + aSession->startOperation("Delete automatic part"); + FeaturePtr aPartFeature = std::dynamic_pointer_cast( + aSession->moduleDocument()->object(ModelAPI_Feature::group(), 0)); + aSession->setActiveDocument(aSession->moduleDocument()); + aSession->moduleDocument()->removeFeature(aPartFeature); + aSession->finishOperation(); + aSession->clearUndoRedo(); + } + } + } + + aSession->startOperation(aTransactionName.str()); } void end() diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index 5be988134..0f4d2f121 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -160,57 +160,68 @@ void ModuleBase_Preferences::resetConfigPropPreferences(SUIT_PreferenceMgr* theP void ModuleBase_Preferences::createGeneralTab(ModuleBase_IPrefMgr* thePref, int thePageId) { int generalTab = thePref->addPreference(QObject::tr("General"), thePageId, - SUIT_PreferenceMgr::Auto, QString(), QString()); + SUIT_PreferenceMgr::Auto, QString(), QString()); thePref->setItemProperty("columns", 2, generalTab); QStringList actItemList; actItemList << QObject::tr("Last part") - << QObject::tr("All parts") - << QObject::tr("No activation"); + << QObject::tr("All parts") + << QObject::tr("No activation"); QList actIdList; actIdList << 0 << 1 << 2; - // Group related to opening a study - int group = thePref->addPreference(QObject::tr("Opening a study"), generalTab, + // Group related to creation of a study + int group = thePref->addPreference(QObject::tr("Creation a study"), generalTab, SUIT_PreferenceMgr::Auto, QString(), QString()); - int actId = thePref->addPreference(QObject::tr("Activate"), group, SUIT_PreferenceMgr::Selector, - ModuleBase_Preferences::GENERAL_SECTION, - "part_activation_study"); - thePref->setItemProperty("strings", actItemList, actId); - thePref->setItemProperty("indexes", actIdList, actId); + int actId = thePref->addPreference(QObject::tr("Create new part"), group, SUIT_PreferenceMgr::Bool, + ModuleBase_Preferences::GENERAL_SECTION, "create_init_part"); + if (!resourceMgr()->hasValue(ModuleBase_Preferences::GENERAL_SECTION, "create_init_part")) + { // set default value: true + resourceMgr()->setValue(ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); + } + + // Group related to running a python script + group = thePref->addPreference(QObject::tr("Launching a python script"), generalTab, + SUIT_PreferenceMgr::Auto, QString(), QString()); QStringList visuItemList; - visuItemList << QObject::tr("As stored in HDF") - << QObject::tr("Last item in each folder") + visuItemList << QObject::tr("Last item in each folder") << QObject::tr("All items") << QObject::tr("No visualization"); QList visuIdList; - visuIdList << 0 << 1 << 2 << 3; + visuIdList << 0 << 1 << 2; int visuId = thePref->addPreference(QObject::tr("Display"), group, SUIT_PreferenceMgr::Selector, ModuleBase_Preferences::GENERAL_SECTION, - "part_visualization_study"); + "part_visualization_script"); thePref->setItemProperty("strings", visuItemList, visuId); thePref->setItemProperty("indexes", visuIdList, visuId); - // Group related to running a python script - group = thePref->addPreference(QObject::tr("Launching a python script"), generalTab, + // Group related to opening a study + group = thePref->addPreference(QObject::tr("Opening a study"), generalTab, SUIT_PreferenceMgr::Auto, QString(), QString()); + actId = thePref->addPreference(QObject::tr("Activate"), group, SUIT_PreferenceMgr::Selector, + ModuleBase_Preferences::GENERAL_SECTION, + "part_activation_study"); + thePref->setItemProperty("strings", actItemList, actId); + thePref->setItemProperty("indexes", actIdList, actId); + visuItemList.clear(); - visuItemList << QObject::tr("Last item in each folder") + visuItemList << QObject::tr("As stored in HDF") + << QObject::tr("Last item in each folder") << QObject::tr("All items") << QObject::tr("No visualization"); visuIdList.clear(); - visuIdList << 0 << 1 << 2; + visuIdList << 0 << 1 << 2 << 3; visuId = thePref->addPreference(QObject::tr("Display"), group, SUIT_PreferenceMgr::Selector, ModuleBase_Preferences::GENERAL_SECTION, - "part_visualization_script"); + "part_visualization_study"); thePref->setItemProperty("strings", visuItemList, visuId); thePref->setItemProperty("indexes", visuIdList, visuId); } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 683173100..b4e9a0e1e 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -123,6 +123,7 @@ #include #include +#include #include #include @@ -286,6 +287,13 @@ PartSet_Module::~PartSet_Module() void PartSet_Module::createFeatures() { ModuleBase_IModule::createFeatures(); + + // send signal to initialization plugin about the state of the preferences: to create part or not + bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue( + ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); + Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate); + aCreateMsg.send(); + myRoot = new PartSet_RootNode(); myRoot->setWorkshop(workshop()); ModuleBase_IModule::loadProprietaryPlugins(); diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 8bb312a30..bcdcd5f81 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -76,6 +76,7 @@ #include #include +#include #if OCC_VERSION_HEX < 0x070400 #define SALOME_PATCH_FOR_CTRL_WHEEL @@ -991,6 +992,13 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the } } } + else if (theSection == ModuleBase_Preferences::GENERAL_SECTION && theParam == "create_init_part") { + bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue( + ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); + Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate); + aCreateMsg.send(); + } + myWorkshop->displayer()->redisplayObjects(); } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index fb55eef8b..bd4bc02b5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -1160,6 +1161,12 @@ void XGUI_Workshop::onPreferences() } else if (aSection == ModuleBase_Preferences::MENU_SECTION) { myMainWindow->menuObject()->updateFromResources(); } + else if (aSection == ModuleBase_Preferences::GENERAL_SECTION && aPref.second == "create_init_part") { + bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue( + ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true); + Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate); + aCreateMsg.send(); + } } std::vector aColor; try { diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index ff49e6bfd..d9201e3b0 100644 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -193,10 +193,14 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& if (aWidgetSelector) workshop()->selector()->setSelected(aWidgetSelector->getAttributeSelection()); } - } else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* || - theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/) - workshop()->facesPanel()->reset(false); // do not flush redisplay, it is flushed after event - + } + else if (theMessage->eventID() == Events_Loop::eventByName("FinishOperation")/* || + theMessage->eventID() == Events_Loop::eventByName("AbortOperation")*/) + { + XGUI_FacesPanel* aFacesPanel = workshop()->facesPanel(); + if (aFacesPanel) + aFacesPanel->reset(false); // do not flush redisplay, it is flushed after event + } //Update property panel on corresponding message. If there is no current operation (no //property panel), or received message has different feature to the current - do nothing. else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {