Salome HOME
Issues #2173 Can't set length on several edges when property panel is undocked,
[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 //#define SALOME_PATCH_FOR_CTRL_WHEEL
51
52 extern "C" {
53 SHAPERGUI_EXPORT CAM_Module* createModule()
54 {
55   return new SHAPERGUI();
56 }
57
58 SHAPERGUI_EXPORT char* getModuleVersion()
59 {
60   return (char*)"0.0";
61 }
62 } // extern "C"
63
64 /** 
65 * Class for preferences management
66 */
67 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
68 {
69 public:
70   /// Constructor
71   /// \param theMgr preferences manager of SALOME
72   /// \param theModName name of the module
73   SHAPERGUI_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):
74     myMgr(theMgr), myModName(theModName) {}
75
76   virtual int addPreference(const QString& theLbl, int pId,
77                             SUIT_PreferenceMgr::PrefItemType theType,
78                             const QString& theSection, const QString& theName )
79   {
80     return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
81   }
82
83   virtual void setItemProperty(const QString& thePropName,
84                                const QVariant& theValue,
85                                const int theId = -1)
86   {
87     myMgr->setItemProperty(thePropName, theValue, theId);
88   }
89
90
91   virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
92
93 private:
94   LightApp_Preferences* myMgr;
95   QString myModName;
96 };
97
98
99
100
101 //******************************************************
102 SHAPERGUI::SHAPERGUI()
103     : LightApp_Module("SHAPER"),
104       mySelector(0), myIsOpened(0), myPopupMgr(0)
105 {
106   myWorkshop = new XGUI_Workshop(this);
107   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
108           this, SLOT(onUpdateCommandStatus()));
109
110   myProxyViewer = new SHAPERGUI_SalomeViewer(this);
111
112   ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
113   ModuleBase_Preferences::loadCustomProps();
114 }
115
116 //******************************************************
117 SHAPERGUI::~SHAPERGUI()
118 {
119 }
120
121 //******************************************************
122 void SHAPERGUI::initialize(CAM_Application* theApp)
123 {
124   LightApp_Module::initialize(theApp);
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 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
388     aViewer->setUseLocalSelection(true);
389 #endif
390     LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
391     QList<SUIT_Selector*> aList;
392     aMgr->selectors(aList);
393     foreach(SUIT_Selector* aSel, aList)
394     {
395       aSel->setEnabled(aSel == aSelector);
396     }
397     myProxyViewer->setSelector(aSelector);
398     return aSelector;
399   }
400   return 0;
401 }
402
403 //******************************************************
404 CAM_DataModel* SHAPERGUI::createDataModel()
405 {
406   return new SHAPERGUI_DataModel(this);
407 }
408
409 QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
410                                const bool isAddSeparator)
411 {
412   return addFeature(theWBName,
413                     theInfo.id,
414                     theInfo.text,
415                     //Issue #650: in the SALOME mode the tooltip should be same as text
416                     theInfo.text,
417                     theInfo.icon,
418                     theInfo.shortcut,
419                     theInfo.checkable,
420                     isAddSeparator,
421                     theInfo.toolTip);
422 }
423
424 //******************************************************
425 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
426                                const QString& theTitle, const QString& theTip,
427                                const QIcon& theIcon, const QKeySequence& theKeys,
428                                bool isCheckable, const bool isAddSeparator,
429                                const QString& theStatusTip)
430 {
431   static QString aLastTool = "";
432   static int aNb = 0;
433   if (aLastTool.isEmpty())
434     aLastTool = theWBName;
435   else if (theWBName != aLastTool) {
436     aLastTool = theWBName;
437     if (aNb > 20) {
438       desktop()->addToolBarBreak();
439       aNb = 0;
440     }
441   }
442   aNb++;
443
444   int aId = myActionsList.size();
445   myActionsList.append(theId);
446   SUIT_Desktop* aDesk = application()->desktop();
447   int aKeys = 0;
448   for (int i = 0; i < theKeys.count(); i++)
449     aKeys += theKeys[i];
450   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
451                                   isCheckable);
452   aAction->setStatusTip(theStatusTip);
453
454   aAction->setData(theId);
455
456   int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
457   int aItemId = createMenu(aId, aWBMenu);
458   if (isAddSeparator)
459     createMenu(separator(), aWBMenu);
460
461   int aWBTool = createTool(theWBName, theWBName);
462   int aToolId = createTool(aId, aWBTool);
463   if (isAddSeparator)
464     createTool(separator(), aWBTool);
465
466   return aAction;
467 }
468
469 bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
470 {
471   return dynamic_cast<const SHAPERGUI_NestedButton*>(theAction);
472 }
473
474 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
475                                        const ActionInfo& theInfo,
476                                        const QList<QAction*>& theNestedActions)
477 {
478   myActionsList.append(theInfo.id);
479   SUIT_Desktop* aDesk = application()->desktop();
480   SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
481   anAction->setData(theInfo.id);
482   anAction->setCheckable(theInfo.checkable);
483   anAction->setChecked(theInfo.checked);
484   anAction->setEnabled(theInfo.enabled);
485   anAction->setVisible(theInfo.visible);
486   anAction->setIcon(theInfo.icon);
487   anAction->setText(theInfo.text);
488   anAction->setToolTip(theInfo.toolTip);
489   anAction->setShortcut(theInfo.shortcut);
490   anAction->setFont(theInfo.font);
491
492   int aWBMenu = createMenu(theWBName, -1, -1, 30);
493   int aItemId = createMenu(anAction, aWBMenu);
494   createMenu(separator(), aWBMenu); /// nested action is always separated of others
495
496   int aWBTool = createTool(theWBName, theWBName);
497   int aToolId = createTool(anAction, aWBTool);
498   createTool(separator(), aWBTool); /// nested action is always separated of others
499
500   return anAction;
501 }
502
503
504 //******************************************************
505 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
506                                            const QString& theTip, const QIcon& theIcon,
507                                            const QKeySequence& theKeys, bool isCheckable,
508                                            const char* theMenuSourceText, const int theMenuPosition)
509 {
510   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
511
512   int aId = myActionsList.size();
513   myActionsList.append(theId);
514   SUIT_Desktop* aDesk = application()->desktop();
515   int aKeys = 0;
516   for (int i = 0; i < theKeys.count(); i++)
517     aKeys += theKeys[i];
518   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
519                                   isCheckable);
520   aAction->setStatusTip(theTip);
521   aAction->setData(theId);
522   createMenu(aId, aMenu, theMenuPosition);
523   return aAction;
524 }
525
526 //******************************************************
527 void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
528 {
529   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
530   createMenu(separator(), aMenu, -1, theMenuPosition);
531 }
532
533 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
534 {
535   if( !theAction )
536     return false;
537
538   SUIT_Desktop* aDesktop = application()->desktop();
539   if( !aDesktop )
540     return false;
541
542   QtxActionToolMgr* aToolMgr = aDesktop->toolMgr();
543   if( !aToolMgr )
544     return false;
545
546   aToolMgr->append( theAction, theToolBarTitle );
547   return true;
548 }
549
550 //******************************************************
551 QList<QAction*> SHAPERGUI::commandList() const
552 {
553   QList<QAction*> aActions;
554   for (int i = 0; i < myActionsList.size(); i++) {
555     QAction* aCmd = action(i);
556     if (aCmd && myActionsList.contains(aCmd->data().toString()))
557       aActions.append(aCmd);
558   }
559
560   return aActions;
561 }
562
563 //******************************************************
564 QMainWindow* SHAPERGUI::desktop() const
565 {
566   return application()->desktop();
567 }
568
569 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
570                                const std::shared_ptr<Config_FeatureMessage>& theMessage)
571 {
572   myFeaturesInfo.insert(theFeatureId, theMessage);
573 }
574
575 std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
576 {
577   std::shared_ptr<Config_FeatureMessage> aMessage;
578   if (myFeaturesInfo.contains(theFeatureId))
579     aMessage =  myFeaturesInfo[theFeatureId];
580   return aMessage;
581 }
582
583 //******************************************************
584 void SHAPERGUI::selectionChanged()
585 {
586   LightApp_Module::selectionChanged();
587   myWorkshop->salomeViewerSelectionChanged();
588 }
589
590 //******************************************************
591 void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
592 {
593   myWorkshop->contextMenuMgr()->updateViewerMenu();
594   myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
595   LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
596 }
597
598
599 //******************************************************
600 void SHAPERGUI::createPreferences()
601 {
602   LightApp_Preferences* pref = preferences();
603   if (!pref)
604     return;
605   ModuleBase_Preferences::updateConfigByResources();
606   QString aModName = moduleName();
607
608   QtxPreferenceItem* item = pref->findItem(aModName, true );
609   if ( item && (!item->isEmpty() )) {
610     item->parentItem()->removeItem(item);
611     delete item;
612   }
613
614   int catId = pref->addPreference(aModName, -1 );
615   if ( catId == -1 )
616     return;
617   SHAPERGUI_PrefMgr aMgr(pref, aModName);
618   ModuleBase_Preferences::createEditContent(&aMgr, catId);
619
620   int viewTab = pref->addItem(tr("Viewer"), catId);
621   // Create other parameters group in viewer tab
622   int otherGroup = pref->addItem(tr("Default selection"), viewTab);
623   pref->setItemProperty("columns", 3, otherGroup);
624   pref->addItem(tr("Faces"), otherGroup,
625                          SUIT_PreferenceMgr::Bool,
626                          ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
627   pref->addItem(tr("Edges"), otherGroup,
628                          SUIT_PreferenceMgr::Bool,
629                          ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
630   pref->addItem(tr("Vertices"), otherGroup,
631                          SUIT_PreferenceMgr::Bool,
632                          ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
633
634   int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
635   pref->setItemProperty("columns", 2, sensitivityGroup);
636   pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::Double,
637                 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
638   pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::Double,
639                 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
640   pref->retrieve();
641 }
642
643 //******************************************************
644 void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam)
645 {
646   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
647   QString aVal = aResMgr->stringValue(theSection, theParam);
648   Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
649                                                     theParam.toStdString());
650   std::string aValue = aVal.toStdString();
651   if (aValue.empty()) {
652     aValue = aProp->defaultValue();
653     aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
654
655     LightApp_Preferences* pref = preferences();
656     if (pref)
657       pref->retrieve();
658   }
659   aProp->setValue(aValue);
660
661   myWorkshop->displayer()->redisplayObjects();
662 }
663
664 void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
665 {
666   application()->putInfo(theInfo, theMSecs);
667 }
668
669 bool SHAPERGUI::abortAllOperations()
670 {
671   return workshop()->operationMgr()->abortAllOperations();
672 }
673
674 void SHAPERGUI::createFeatureActions()
675 {
676   myWorkshop->menuMgr()->createFeatureActions();
677 }