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