Salome HOME
Issue #1005: To improve user-friendship of error-messages for features and attributes
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #include "SHAPERGUI.h"
5 #include "SHAPERGUI_DataModel.h"
6 #include "SHAPERGUI_OCCSelector.h"
7 #include <SHAPERGUI_NestedButton.h>
8
9 #include <XGUI_Workshop.h>
10 #include <XGUI_PropertyPanel.h>
11 #include <XGUI_ContextMenuMgr.h>
12 #include <XGUI_ObjectsBrowser.h>
13 #include <XGUI_OperationMgr.h>
14 #include <XGUI_Displayer.h>
15 #include <XGUI_MenuMgr.h>
16
17 #include <ModuleBase_Operation.h>
18 #include <ModuleBase_Preferences.h>
19 #include <ModuleBase_ActionInfo.h>
20 #include <ModuleBase_IModule.h>
21
22 #include <LightApp_Application.h>
23 #include <LightApp_SelectionMgr.h>
24 #include <LightApp_OCCSelector.h>
25 #include <LightApp_Study.h>
26 #include <OCCViewer_ViewModel.h>
27
28 #include <SUIT_Selector.h>
29 #include <SUIT_Desktop.h>
30 #include <SUIT_ViewManager.h>
31 #include <SUIT_ResourceMgr.h>
32 #include <SUIT_DataBrowser.h>
33
34 #include <QtxPopupMgr.h>
35 #include <QtxActionMenuMgr.h>
36 #include <QtxActionToolMgr.h>
37 #include <QtxResourceMgr.h>
38
39 #include <Config_PropManager.h>
40 #include <Config_ModuleReader.h>
41
42 #include <AIS_ListOfInteractive.hxx>
43 #include <AIS_ListIteratorOfListOfInteractive.hxx>
44
45 #include <QDockWidget>
46 #include <QAction>
47 #include <QTimer>
48 #include <QMenu>
49
50
51 extern "C" {
52 SHAPERGUI_EXPORT CAM_Module* createModule()
53 {
54   return new SHAPERGUI();
55 }
56
57 SHAPERGUI_EXPORT char* getModuleVersion()
58 {
59   return (char*)"0.0";
60 }
61 } // extern "C"
62
63 /** 
64 * Class for preferences management
65 */
66 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
67 {
68 public:
69   /// Constructor
70   /// \param theMgr preferences manager of SALOME
71   /// \param theModName name of the module
72   SHAPERGUI_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):
73     myMgr(theMgr), myModName(theModName) {}
74
75   virtual int addPreference(const QString& theLbl, int pId,
76                             SUIT_PreferenceMgr::PrefItemType theType,
77                             const QString& theSection, const QString& theName )
78   {
79     return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
80   }
81
82   virtual void setItemProperty(const QString& thePropName,
83                                const QVariant& theValue,
84                                const int theId = -1)
85   {
86     myMgr->setItemProperty(thePropName, theValue, theId);
87   }
88
89
90   virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
91
92 private:
93   LightApp_Preferences* myMgr;
94   QString myModName;
95 };
96
97
98
99
100 //******************************************************
101 SHAPERGUI::SHAPERGUI()
102     : LightApp_Module("SHAPER"),
103       mySelector(0), myIsOpened(0), myPopupMgr(0)
104 {
105   myWorkshop = new XGUI_Workshop(this);
106   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
107           this, SLOT(onUpdateCommandStatus()));
108
109   myProxyViewer = new SHAPERGUI_SalomeViewer(this);
110
111   ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
112   ModuleBase_Preferences::loadCustomProps();
113 }
114
115 //******************************************************
116 SHAPERGUI::~SHAPERGUI()
117 {
118 }
119
120 //******************************************************
121 void SHAPERGUI::initialize(CAM_Application* theApp)
122 {
123   LightApp_Module::initialize(theApp);
124   inspectSalomeModules();
125
126   myWorkshop->startApplication();
127   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
128   if (anApp)
129   {
130     connect(anApp, SIGNAL(preferenceResetToDefaults()), this, SLOT(onDefaultPreferences()));
131   }
132 }
133
134 //******************************************************
135 void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
136 {
137   theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
138 }
139
140 //******************************************************
141 void SHAPERGUI::viewManagers(QStringList& theList) const
142 {
143   theList.append(OCCViewer_Viewer::Type());
144 }
145
146 //******************************************************
147 void SHAPERGUI::connectToStudy(CAM_Study* theStudy)
148 {
149   // if there are created viewer managers, we should try to create viewer
150   // selector and initialize viewer with it. It sets interactive contect to the
151   // proxy viewer. If study is opened, CAM application calls this method before the open()
152   // of data model
153   // the SHAPER data model is specific and during open(load) redisplay signals are flushed, so
154   // we need to connect to the viewer before it. Here, it seems the most appropriate place for this
155   // according to SALOME architecture.
156   if (!mySelector) {
157     ViewManagerList OCCViewManagers;
158     application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
159     if (OCCViewManagers.size() > 0) {
160       mySelector = createSelector(OCCViewManagers.first());
161     }
162   }
163   LightApp_Module::connectToStudy(theStudy);
164 }
165
166 //******************************************************
167 bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
168 {
169   bool isDone = LightApp_Module::activateModule(theStudy);
170   SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
171   aDataModel->initRootObject();
172
173   if (isDone) {
174     setMenuShown(true);
175     setToolShown(true);
176
177     QObject* aObj = myWorkshop->objectBrowser()->parent();
178     QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
179     if (aObjDoc) {
180       QAction* aViewAct = aObjDoc->toggleViewAction();
181       aViewAct->setEnabled(true);
182       myWorkshop->objectBrowser()->setVisible(true);
183       aObjDoc->setVisible(true);
184       desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
185     }
186
187     if (!mySelector) {
188       ViewManagerList OCCViewManagers;
189       application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
190       if (OCCViewManagers.size() > 0) {
191         mySelector = createSelector(OCCViewManagers.first());
192       }
193     }
194     // it should be pefromed after the selector creation in order to have AISContext
195     myWorkshop->activateModule();
196     //action(myEraseAll)->setEnabled(false);
197
198     if (myIsOpened) {
199       myWorkshop->objectBrowser()->rebuildDataTree();
200       myWorkshop->updateCommandStatus();
201       myIsOpened = false;
202     }
203     else
204       myWorkshop->updateCommandStatus();
205   }
206   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
207   myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
208   myIsEditEnabled = getApp()->isEditEnabled();
209   getApp()->setEditEnabled(false);
210
211   // this following row is caused by #187 bug.
212   // SALOME saves the dock widget positions before deactivateModule() and
213   // load it after the module activation. So, if the panel is visible before
214   // deactivate, it becomes visible after activate.
215   // In order to avoid the visible property panel, the widget position save is
216   // switch off in this module
217   aResMgr->setValue("Study", "store_positions", false);
218
219   // Synchronize displayed objects
220   Handle(AIS_InteractiveContext) aContext;
221   if (mySelector && mySelector->viewer())
222     aContext = mySelector->viewer()->getAISContext();
223
224   if (!aContext.IsNull()) {
225     XGUI_Displayer* aDisp = myWorkshop->displayer();
226     QObjectPtrList aObjList = aDisp->displayedObjects();
227
228     AIS_ListOfInteractive aList;
229     aContext->DisplayedObjects(aList);
230     AIS_ListIteratorOfListOfInteractive aLIt;
231     Handle(AIS_InteractiveObject) anAISIO;
232     foreach (ObjectPtr aObj, aObjList) {
233       AISObjectPtr aPrs = aDisp->getAISObject(aObj);
234       Handle(AIS_InteractiveObject) aAIS = aPrs->impl<Handle(AIS_InteractiveObject)>();
235       bool aFound = false;
236       for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
237         anAISIO = aLIt.Value();
238         if (anAISIO.Access() == aAIS.Access()) {
239           aFound = true;
240           break;
241         }
242       }
243       if (!aFound) {
244         aObj->setDisplayed(false);
245         //aDisp->erase(aObj, false);
246       }
247     }
248     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
249   }
250   myProxyViewer->activateViewer(true);
251
252   // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
253   connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
254           this, SLOT(onScriptLoaded()));
255   return isDone;
256 }
257
258 //******************************************************
259 bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
260 {
261   myProxyViewer->activateViewer(false);
262   setMenuShown(false);
263   setToolShown(false);
264
265   myWorkshop->deactivateModule();
266
267   QObject* aObj = myWorkshop->objectBrowser()->parent();
268   QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
269   if (aObjDoc) {
270     aObjDoc->setVisible(false);
271     myWorkshop->objectBrowser()->setVisible(false);
272     QAction* aViewAct = aObjDoc->toggleViewAction();
273     aViewAct->setEnabled(false);
274   }
275
276   // the active operation should be stopped for the next activation.
277   // There should not be active operation and visualized preview.
278   // Abort operation should be performed before the selection's remove
279   // because the displayed objects should be removed from the viewer, but
280   // the AIS context is obtained from the selector.
281   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
282   while (anOperation) {
283     anOperation->abort();
284     anOperation = myWorkshop->operationMgr()->currentOperation();
285   }
286   // Delete selector because it has to be redefined on next activation
287   if (mySelector) {
288     myProxyViewer->setSelector(0);
289     delete mySelector;
290     mySelector = 0;
291   }
292
293   //myWorkshop->contextMenuMgr()->disconnectViewer();
294
295   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
296   aResMgr->setValue("Study", "store_positions", myIsStorePositions);
297   getApp()->setEditEnabled(myIsEditEnabled);
298
299   // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
300   disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
301              this, SLOT(onScriptLoaded()));
302
303   return LightApp_Module::deactivateModule(theStudy);
304 }
305
306 //******************************************************
307 void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
308 {
309   if (!mySelector) {
310     mySelector = createSelector(theMgr);
311     myWorkshop->module()->activateSelectionFilters();
312     myWorkshop->synchronizeViewer();
313   }
314 }
315
316 //******************************************************
317 void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr)
318 {
319   if (mySelector) {
320     if (theMgr->getType() == OCCViewer_Viewer::Type()) {
321       OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
322       if (mySelector->viewer() == aViewer) {
323         XGUI_Displayer* aDisp = myWorkshop->displayer();
324         QObjectPtrList aObjects = aDisp->displayedObjects();
325         foreach(ObjectPtr aObj, aObjects)
326           aObj->setDisplayed(false);
327         Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
328         myProxyViewer->setSelector(0);
329         delete mySelector;
330         mySelector = 0;
331
332         myWorkshop->module()->clearViewer();
333       }
334     }
335   }
336 }
337
338 //******************************************************
339 QtxPopupMgr* SHAPERGUI::popupMgr()
340 {
341   if (!myPopupMgr)
342     myPopupMgr = new QtxPopupMgr( 0, this );
343   return myPopupMgr;
344 }
345
346 //******************************************************
347 void SHAPERGUI::onDefaultPreferences()
348 {
349   // reset main resources
350   ModuleBase_Preferences::resetResourcePreferences(preferences());
351   // reset plugin's resources
352   ModuleBase_Preferences::resetConfigPropPreferences(preferences());
353
354   myWorkshop->displayer()->redisplayObjects();
355 }
356
357 //******************************************************
358 void SHAPERGUI::onScriptLoaded()
359 {
360   // this slot is called after processing of the LoadScriptId action of SalomeApp Application
361   // Each dumped script contains updateObjBrowser() that creates a new instance of Object
362   // Browser. When SHAPER module is active, this browser should not be used. It might be removed
363   // as hidden by means of updateWindows() of SalomeApp_Application or to remove
364   // it manually (because this method of application is protected)
365   SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
366   if (aBrowser)
367     delete aBrowser;
368 }
369
370 //******************************************************
371 void SHAPERGUI::onUpdateCommandStatus()
372 {
373   getApp()->updateActions();
374 }
375
376 //******************************************************
377 SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
378 {
379   if (theMgr->getType() == OCCViewer_Viewer::Type()) {
380     OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
381     SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
382                                                                  getApp()->selectionMgr());
383     LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
384     QList<SUIT_Selector*> aList;
385     aMgr->selectors(aList);
386     foreach(SUIT_Selector* aSel, aList)
387     {
388       aSel->setEnabled(aSel == aSelector);
389     }
390     myProxyViewer->setSelector(aSelector);
391     return aSelector;
392   }
393   return 0;
394 }
395
396 //******************************************************
397 CAM_DataModel* SHAPERGUI::createDataModel()
398 {
399   return new SHAPERGUI_DataModel(this);
400 }
401
402 QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
403                                const bool isAddSeparator)
404 {
405   return addFeature(theWBName,
406                     theInfo.id,
407                     theInfo.text,
408                     //Issue #650: in the SALOME mode the tooltip should be same as text
409                     theInfo.text,
410                     theInfo.icon,
411                     theInfo.shortcut,
412                     theInfo.checkable,
413                     isAddSeparator,
414                     theInfo.toolTip);
415 }
416
417 //******************************************************
418 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
419                                const QString& theTitle, const QString& theTip,
420                                const QIcon& theIcon, const QKeySequence& theKeys,
421                                bool isCheckable, const bool isAddSeparator,
422                                const QString& theStatusTip)
423 {
424   static QString aLastTool = "";
425   static int aNb = 0;
426   if (aLastTool.isEmpty())
427     aLastTool = theWBName;
428   else if (theWBName != aLastTool) {
429     aLastTool = theWBName;
430     if (aNb > 20) {
431       desktop()->addToolBarBreak();
432       aNb = 0;
433     }
434   }
435   aNb++;
436
437   int aId = myActionsList.size();
438   myActionsList.append(theId);
439   SUIT_Desktop* aDesk = application()->desktop();
440   int aKeys = 0;
441   for (unsigned int i = 0; i < theKeys.count(); i++)
442     aKeys += theKeys[i];
443   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
444                                   isCheckable);
445   aAction->setStatusTip(theStatusTip);
446
447   aAction->setData(theId);
448
449   int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
450   int aItemId = createMenu(aId, aWBMenu);
451   if (isAddSeparator)
452     createMenu(separator(), aWBMenu);
453
454   int aWBTool = createTool(theWBName, theWBName);
455   int aToolId = createTool(aId, aWBTool);
456   if (isAddSeparator)
457     createTool(separator(), aWBTool);
458
459   return aAction;
460 }
461
462 bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
463 {
464   return dynamic_cast<const SHAPERGUI_NestedButton*>(theAction);
465 }
466
467 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
468                                        const ActionInfo& theInfo,
469                                        const QList<QAction*>& theNestedActions)
470 {
471   myActionsList.append(theInfo.id);
472   SUIT_Desktop* aDesk = application()->desktop();
473   SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
474   anAction->setData(theInfo.id);
475   anAction->setCheckable(theInfo.checkable);
476   anAction->setChecked(theInfo.checked);
477   anAction->setEnabled(theInfo.enabled);
478   anAction->setVisible(theInfo.visible);
479   anAction->setIcon(theInfo.icon);
480   anAction->setText(theInfo.text);
481   anAction->setToolTip(theInfo.toolTip);
482   anAction->setShortcut(theInfo.shortcut);
483   anAction->setFont(theInfo.font);
484
485   int aWBMenu = createMenu(theWBName, -1, -1, 30);
486   int aItemId = createMenu(anAction, aWBMenu);
487   createMenu(separator(), aWBMenu); /// nested action is always separated of others
488
489   int aWBTool = createTool(theWBName, theWBName);
490   int aToolId = createTool(anAction, aWBTool);
491   createTool(separator(), aWBTool); /// nested action is always separated of others
492
493   return anAction;
494 }
495
496
497 //******************************************************
498 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
499                                            const QString& theTip, const QIcon& theIcon,
500                                            const QKeySequence& theKeys, bool isCheckable,
501                                            const char* theMenuSourceText, const int theMenuPosition)
502 {
503   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
504
505   int aId = myActionsList.size();
506   myActionsList.append(theId);
507   SUIT_Desktop* aDesk = application()->desktop();
508   int aKeys = 0;
509   for (unsigned int i = 0; i < theKeys.count(); i++)
510     aKeys += theKeys[i];
511   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
512                                   isCheckable);
513   aAction->setStatusTip(theTip);
514   aAction->setData(theId);
515   createMenu(aId, aMenu, theMenuPosition);
516   return aAction;
517 }
518
519 //******************************************************
520 void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
521 {
522   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
523   createMenu(separator(), aMenu, -1, theMenuPosition);
524 }
525
526 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
527 {
528   if( !theAction )
529     return false;
530
531   SUIT_Desktop* aDesktop = application()->desktop();
532   if( !aDesktop )
533     return false;
534
535   QtxActionToolMgr* aToolMgr = aDesktop->toolMgr();
536   if( !aToolMgr )
537     return false;
538
539   aToolMgr->append( theAction, theToolBarTitle );
540   return true;
541 }
542
543 //******************************************************
544 QList<QAction*> SHAPERGUI::commandList() const
545 {
546   QList<QAction*> aActions;
547   for (int i = 0; i < myActionsList.size(); i++) {
548     QAction* aCmd = action(i);
549     if (aCmd && myActionsList.contains(aCmd->data().toString()))
550       aActions.append(aCmd);
551   }
552
553   return aActions;
554 }
555
556 //******************************************************
557 QMainWindow* SHAPERGUI::desktop() const
558 {
559   return application()->desktop();
560 }
561
562 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
563                                const std::shared_ptr<Config_FeatureMessage>& theMessage)
564 {
565   myFeaturesInfo.insert(theFeatureId, theMessage);
566 }
567
568 std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
569 {
570   std::shared_ptr<Config_FeatureMessage> aMessage;
571   if (myFeaturesInfo.contains(theFeatureId))
572     aMessage =  myFeaturesInfo[theFeatureId];
573   return aMessage;
574 }
575
576 //******************************************************
577 void SHAPERGUI::selectionChanged()
578 {
579   LightApp_Module::selectionChanged();
580   myWorkshop->salomeViewerSelectionChanged();
581 }
582
583 //******************************************************
584 void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
585 {
586   myWorkshop->contextMenuMgr()->updateViewerMenu();
587   myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
588   LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
589 }
590
591
592 //******************************************************
593 void SHAPERGUI::createPreferences()
594 {
595   LightApp_Preferences* pref = preferences();
596   if (!pref)
597     return;
598   ModuleBase_Preferences::updateConfigByResources();
599   QString aModName = moduleName();
600
601   QtxPreferenceItem* item = pref->findItem(aModName, true );
602   if ( item && (!item->isEmpty() )) {
603     item->parentItem()->removeItem(item);
604     delete item;
605   }
606
607   int catId = pref->addPreference(aModName, -1 );
608   if ( catId == -1 )
609     return;
610   SHAPERGUI_PrefMgr aMgr(pref, aModName);
611   ModuleBase_Preferences::createEditContent(&aMgr, catId);
612
613   int viewTab = pref->addItem(tr("Viewer"), catId);
614   // Create other parameters group in viewer tab
615   int otherGroup = pref->addItem(tr("Default selection"), viewTab);
616   pref->setItemProperty("columns", 3, otherGroup);
617   pref->addItem(tr("Faces"), otherGroup,
618                          SUIT_PreferenceMgr::Bool,
619                          ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
620   pref->addItem(tr("Edges"), otherGroup,
621                          SUIT_PreferenceMgr::Bool,
622                          ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
623   pref->addItem(tr("Vertices"), otherGroup,
624                          SUIT_PreferenceMgr::Bool,
625                          ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
626
627   int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
628   pref->setItemProperty("columns", 2, sensitivityGroup);
629   pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::Double,
630                 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
631   pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::Double,
632                 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
633   pref->retrieve();
634 }
635
636 //******************************************************
637 void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam)
638 {
639   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
640   QString aVal = aResMgr->stringValue(theSection, theParam);
641   Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
642                                                     theParam.toStdString());
643   std::string aValue = aVal.toStdString();
644   if (aValue.empty()) {
645     aValue = aProp->defaultValue();
646     aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
647
648     LightApp_Preferences* pref = preferences();
649     if (pref)
650       pref->retrieve();
651   }
652   aProp->setValue(aValue);
653
654   myWorkshop->displayer()->redisplayObjects();
655 }
656
657 void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
658 {
659   application()->putInfo(theInfo, theMSecs);
660 }
661
662 void SHAPERGUI::inspectSalomeModules()
663 {
664   QStringList aModuleNames;
665   getApp()->modules(aModuleNames, false);
666   foreach(QString eachModule, aModuleNames) {
667     Config_ModuleReader::addDependencyModule(eachModule.toStdString());
668   }
669 }
670
671 bool SHAPERGUI::abortAllOperations()
672 {
673   return workshop()->operationMgr()->abortAllOperations();
674 }
675
676 void SHAPERGUI::createFeatureActions()
677 {
678   myWorkshop->menuMgr()->createFeatureActions();
679 }