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