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