Salome HOME
Merge remote-tracking branch 'remotes/origin/occ/eliminateWarnings'
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
1 // Copyright (C) 2014-2020  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
18 //
19
20 #include "SHAPERGUI.h"
21 #include "SHAPERGUI_DataModel.h"
22 #include "SHAPERGUI_OCCSelector.h"
23 #include "SHAPERGUI_NestedButton.h"
24 #include "SHAPERGUI_ToolbarsMgr.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 #include <XGUI_SelectionActivate.h>
35 #include <XGUI_InspectionPanel.h>
36 #include <XGUI_ViewerProxy.h>
37
38 #include <ModuleBase_Operation.h>
39 #include <ModuleBase_Preferences.h>
40 #include <ModuleBase_ActionInfo.h>
41 #include <ModuleBase_IModule.h>
42
43 #include <ModelAPI_Tools.h>
44
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <LightApp_OCCSelector.h>
48 #include <LightApp_Study.h>
49
50 #include <OCCViewer_ViewModel.h>
51 #include <OCCViewer_ViewPort3d.h>
52
53 #include <SUIT_Selector.h>
54 #include <SUIT_Desktop.h>
55 #include <SUIT_ViewManager.h>
56 #include <SUIT_ViewWindow.h>
57 #include <SUIT_ResourceMgr.h>
58 #include <SUIT_DataBrowser.h>
59
60 #include <QtxPopupMgr.h>
61 #include <QtxActionMenuMgr.h>
62 #include <QtxActionToolMgr.h>
63 #include <QtxResourceMgr.h>
64
65 #include <Config_PropManager.h>
66 #include <Config_ModuleReader.h>
67
68 #include <AIS_ListOfInteractive.hxx>
69 #include <AIS_ListIteratorOfListOfInteractive.hxx>
70
71 #include <QDockWidget>
72 #include <QAction>
73 #include <QTimer>
74 #include <QMenu>
75 #include <QToolBar>
76
77 #if OCC_VERSION_HEX < 0x070400
78   #define SALOME_PATCH_FOR_CTRL_WHEEL
79 #endif
80
81 extern "C" {
82 SHAPERGUI_EXPORT CAM_Module* createModule()
83 {
84   return new SHAPERGUI();
85 }
86
87 SHAPERGUI_EXPORT char* getModuleVersion()
88 {
89   return (char*)"0.0";
90 }
91 } // extern "C"
92
93
94 static const QString ToolbarsSection("SHAPER_Toolbars");
95 static const QString FreeCommandsParam("OutOFToolbars");
96
97
98 /** 
99 * Class for preferences management
100 */
101 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
102 {
103 public:
104   /// Constructor
105   /// \param theMgr preferences manager of SALOME
106   /// \param theModName name of the module
107   SHAPERGUI_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):
108     myMgr(theMgr), myModName(theModName) {}
109
110   virtual int addPreference(const QString& theLbl, int pId,
111                             SUIT_PreferenceMgr::PrefItemType theType,
112                             const QString& theSection, const QString& theName )
113   {
114     return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
115   }
116
117   virtual void setItemProperty(const QString& thePropName,
118                                const QVariant& theValue,
119                                const int theId = -1)
120   {
121     myMgr->setItemProperty(thePropName, theValue, theId);
122   }
123
124
125   virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
126
127 private:
128   LightApp_Preferences* myMgr;
129   QString myModName;
130 };
131
132
133
134
135 //******************************************************
136 SHAPERGUI::SHAPERGUI()
137     : LightApp_Module("SHAPER"),
138       mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
139   myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false)
140 {
141   myWorkshop = new XGUI_Workshop(this);
142   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
143           this, SLOT(onUpdateCommandStatus()));
144
145   myProxyViewer = new SHAPERGUI_SalomeViewer(this);
146
147   ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
148
149   // It will be called in XGUI_Workshop::startApplication
150   // ModuleBase_Preferences::loadCustomProps();
151 }
152
153 //******************************************************
154 SHAPERGUI::~SHAPERGUI()
155 {
156   delete myWorkshop;
157   delete myProxyViewer;
158 }
159
160 //******************************************************
161 void SHAPERGUI::initialize(CAM_Application* theApp)
162 {
163   LightApp_Module::initialize(theApp);
164
165   myWorkshop->startApplication();
166   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
167   if (anApp)
168   {
169     connect(anApp, SIGNAL(preferenceResetToDefaults()), this, SLOT(onDefaultPreferences()));
170   }
171
172   int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
173   int aSubMenu = createMenu(tr("Information"), aMenu, -1, -1, 0);
174
175   int aId = getNextCommandId();
176   myActionsList.append(aId);
177   SUIT_Desktop* aDesk = application()->desktop();
178   QString aTip = tr("Show inspection window");
179   myWhatIsAction = createAction(aId, aTip, QIcon(":pictures/whatis.png"), tr("What Is"),
180     aTip, QKeySequence(), aDesk, true, this, SLOT(onWhatIs(bool)));
181   myWhatIsAction->setStatusTip(aTip);
182   myWhatIsAction->setData("INSPECTION_CMD");
183   createMenu(aId, aSubMenu, 0);
184
185   QString aToolName = tr("Inspection");
186   int aTool = createTool(aToolName);
187 #ifdef _DEBUG
188   int aToolId =
189 #endif
190     createTool(myWhatIsAction, aTool);
191   registerCommandToolbar(aToolName, aId);
192
193   // Define Edit toolbars command
194   aId = getNextCommandId();
195   //myActionsList.append(aId); Do not use it for editing of toolbars
196   aTip = tr("Edit toolbars of the module");
197 #ifdef _DEBUG
198   QAction* aAction =
199 #endif
200     createAction(aId, aTip, QIcon(":pictures/configure_toolbars.png"),
201     tr("Edit toolbars..."), aTip, QKeySequence(), aDesk, false, this, SLOT(onEditToolbars()));
202   int aEditMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1, 30);
203 #ifdef _DEBUG
204   int aEditItem =
205 #endif
206     createMenu(aId, aEditMenu);
207
208   // Initialize viewer proxy if OCC viewer is already exist
209   ViewManagerList aOCCViewManagers;
210   application()->viewManagers(OCCViewer_Viewer::Type(), aOCCViewManagers);
211   if (aOCCViewManagers.size() > 0) {
212     SUIT_ViewManager* aMgr = aOCCViewManagers.first();
213     SUIT_ViewWindow* aWnd = aMgr->getActiveView();
214     if (aWnd) {
215       OCCViewer_ViewWindow* aOccWnd = static_cast<OCCViewer_ViewWindow*>(aWnd);
216       OCCViewer_ViewPort3d* aViewPort = aOccWnd->getViewPort();
217       if (aViewPort) {
218         XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
219         aViewPort->installEventFilter(aViewer);
220         Handle(V3d_View) aView = aViewPort->getView();
221         aViewer->SetScale(aView, aView->Camera()->Scale());
222         // We can not create selector here because other modules will be deactivated later
223         //onViewManagerAdded(aMgr);
224       }
225     }
226   }
227 }
228
229 //******************************************************
230 void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
231 {
232   theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
233 }
234
235 //******************************************************
236 void SHAPERGUI::viewManagers(QStringList& theList) const
237 {
238   theList.append(OCCViewer_Viewer::Type());
239 }
240
241 //******************************************************
242 // We can not create selector in this method because it can be called when
243 // SHAPER module is not active. Take into account that creation of our selector
244 // leads to switching OFF all other selectors
245 //void SHAPERGUI::connectToStudy(CAM_Study* theStudy)
246 //{
247 //  // if there are created viewer managers, we should try to create viewer
248 //  // selector and initialize viewer with it. It sets interactive context to the
249 //  // proxy viewer. If study is opened, CAM application calls this method before the open()
250 //  // of data model
251 //  // the SHAPER data model is specific and during open(load) redisplay signals are flushed, so
252 //  // we need to connect to the viewer before it. Here,
253 //  // it seems the most appropriate place for this
254 //  // according to SALOME architecture.
255 //  if (!mySelector) {
256 //    ViewManagerList OCCViewManagers;
257 //    application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
258 //    if (OCCViewManagers.size() > 0) {
259 //      mySelector = createSelector(OCCViewManagers.first());
260 //    }
261 //  }
262 //  LightApp_Module::connectToStudy(theStudy);
263 //}
264
265 //******************************************************
266 bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
267 {
268   bool isDone = LightApp_Module::activateModule(theStudy);
269   loadToolbarsConfig();
270
271   SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
272   aDataModel->initRootObject();
273
274   if (isDone) {
275     setMenuShown(true);
276     setToolShown(true);
277
278     QObject* aObj = myWorkshop->objectBrowser()->parent();
279     QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
280     if (aObjDoc) {
281       myWorkshop->objectBrowser()->setVisible(true);
282       aObjDoc->setVisible(true);
283       desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
284       aObjDoc->toggleViewAction()->setVisible(true);
285     }
286
287     if (!myInspectionPanel) {
288       myInspectionPanel = myWorkshop->inspectionPanel();
289       connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
290               this, SLOT(onWhatIs(bool)));
291     }
292     myInspectionPanel->toggleViewAction()->setVisible(true);
293
294     myWorkshop->facesPanel()->toggleViewAction()->setVisible(true);
295     if (myIsFacesPanelVisible)
296       myWorkshop->facesPanel()->show();
297     myWorkshop->propertyPanel()->toggleViewAction()->setVisible(true);
298
299     if (!mySelector) {
300       ViewManagerList OCCViewManagers;
301       application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
302       if (OCCViewManagers.size() > 0) {
303         onViewManagerAdded(OCCViewManagers.first());
304       }
305     }
306     // it should be performed after the selector creation in order to have AISContext
307     myWorkshop->activateModule();
308     //action(myEraseAll)->setEnabled(false);
309
310     if (myIsOpened) {
311       myWorkshop->objectBrowser()->rebuildDataTree();
312       myWorkshop->updateCommandStatus();
313       myIsOpened = false;
314     }
315     else
316       myWorkshop->updateCommandStatus();
317   }
318   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
319   myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
320   myIsEditEnabled = getApp()->isEditEnabled();
321   getApp()->setEditEnabled(false);
322
323   // this following row is caused by #187 bug.
324   // SALOME saves the dock widget positions before deactivateModule() and
325   // load it after the module activation. So, if the panel is visible before
326   // deactivate, it becomes visible after activate.
327   // In order to avoid the visible property panel, the widget position save is
328   // switch off in this module
329   aResMgr->setValue("Study", "store_positions", false);
330
331   // Synchronize displayed objects
332   Handle(AIS_InteractiveContext) aContext;
333   if (mySelector && mySelector->viewer())
334     aContext = mySelector->viewer()->getAISContext();
335
336   if (!aContext.IsNull()) {
337     XGUI_Displayer* aDisp = myWorkshop->displayer();
338     QObjectPtrList aObjList = aDisp->displayedObjects();
339
340     //if (myHighlightPointAspect.IsNull()) {
341     //  Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
342     //  myHighlightPointAspect =
343     //    new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
344     //}
345     if (myOldSelectionColor.size() == 0)
346       myOldSelectionColor = aDisp->selectionColor();
347
348     AIS_ListOfInteractive aList;
349     aContext->DisplayedObjects(aList);
350     AIS_ListIteratorOfListOfInteractive aLIt;
351     Handle(AIS_InteractiveObject) anAISIO;
352     foreach (ObjectPtr aObj, aObjList) {
353       AISObjectPtr aPrs = aDisp->getAISObject(aObj);
354       Handle(AIS_InteractiveObject) aAIS = aPrs->impl<Handle(AIS_InteractiveObject)>();
355       bool aFound = false;
356       for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
357         anAISIO = aLIt.Value();
358         if (anAISIO.get() == aAIS.get()) {
359           aFound = true;
360           break;
361         }
362       }
363       if (!aFound) {
364         aObj->setDisplayed(false);
365         //aDisp->erase(aObj, false);
366       }
367     }
368     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
369   }
370   myProxyViewer->activateViewer(true);
371
372   // Post-processing for LoadScriptId to remove created(if it was created) SALOME Object Browser
373   connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
374           this, SLOT(onScriptLoaded()));
375
376   disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
377              getApp(), SLOT(onSaveDoc()));
378   disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
379              getApp(), SLOT(onSaveAsDoc()));
380
381   connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
382           this, SLOT(onSaveDocByShaper()));
383   connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
384           this, SLOT(onSaveAsDocByShaper()));
385
386   return isDone;
387 }
388
389 //******************************************************
390 bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
391 {
392   saveToolbarsConfig();
393
394   myProxyViewer->activateViewer(false);
395   setMenuShown(false);
396   setToolShown(false);
397
398   myWorkshop->deactivateModule();
399
400   QObject* aObj = myWorkshop->objectBrowser()->parent();
401   QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
402   if (aObjDoc) {
403     aObjDoc->setVisible(false);
404     myWorkshop->objectBrowser()->setVisible(false);
405     aObjDoc->toggleViewAction()->setVisible(false);
406   }
407
408   myIsInspectionVisible = myInspectionPanel->isVisible();
409   myInspectionPanel->hide();
410   myInspectionPanel->toggleViewAction()->setVisible(false);
411
412   myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
413   myWorkshop->facesPanel()->hide();
414   myWorkshop->facesPanel()->toggleViewAction()->setVisible(false);
415
416   myWorkshop->propertyPanel()->hide();
417   myWorkshop->propertyPanel()->toggleViewAction()->setVisible(false);
418
419   // the active operation should be stopped for the next activation.
420   // There should not be active operation and visualized preview.
421   // Abort operation should be performed before the selection's remove
422   // because the displayed objects should be removed from the viewer, but
423   // the AIS context is obtained from the selector.
424   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
425   while (anOperation) {
426     anOperation->abort();
427     anOperation = myWorkshop->operationMgr()->currentOperation();
428   }
429   // Delete selector because it has to be redefined on next activation
430   if (mySelector) {
431     //if (!myHighlightPointAspect.IsNull()) {
432     //  Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
433     //  aTrihedron->getHighlightPointAspect()->SetAspect(myHighlightPointAspect);
434     //  myHighlightPointAspect.Nullify();
435     //}
436     myWorkshop->displayer()->setSelectionColor(myOldSelectionColor);
437     myProxyViewer->setSelector(0);
438
439     LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
440     QList<SUIT_Selector*> aList;
441     aMgr->selectors(aList);
442     foreach(SUIT_Selector* aSel, aList) {
443       aSel->setEnabled(aSel != mySelector);
444     }
445
446     delete mySelector;
447     mySelector = 0;
448   }
449
450   myWorkshop->hidePanel(myWorkshop->facesPanel());
451   //myWorkshop->contextMenuMgr()->disconnectViewer();
452
453   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
454   aResMgr->setValue("Study", "store_positions", myIsStorePositions);
455   getApp()->setEditEnabled(myIsEditEnabled);
456
457   myOldSelectionColor.clear();
458
459   // Post-processing for LoadScriptId to remove created(if it was created) SALOME Object Browser
460   disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
461              this, SLOT(onScriptLoaded()));
462
463   disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
464              this, SLOT(onSaveDocByShaper()));
465   disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
466              this, SLOT(onSaveAsDocByShaper()));
467
468   connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
469           getApp(), SLOT(onSaveDoc()));
470   connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
471           getApp(), SLOT(onSaveAsDoc()));
472
473   publishToStudy();
474
475   return LightApp_Module::deactivateModule(theStudy);
476 }
477
478 //******************************************************
479 void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
480 {
481   if (!mySelector) {
482     mySelector = createSelector(theMgr);
483     myWorkshop->selectionActivate()->updateSelectionFilters();
484     myWorkshop->selectionActivate()->updateSelectionModes();
485     myWorkshop->synchronizeViewer();
486   }
487 }
488
489 //******************************************************
490 void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr)
491 {
492   if (mySelector) {
493     if (theMgr->getType() == OCCViewer_Viewer::Type()) {
494       OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
495       if (mySelector->viewer() == aViewer) {
496         XGUI_Displayer* aDisp = myWorkshop->displayer();
497         QObjectPtrList aObjects = aDisp->displayedObjects();
498         ResultPtr aRes;
499         foreach(ObjectPtr aObj, aObjects) {
500           aObj->setDisplayed(false);
501           aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
502           if (aRes.get()) {
503             while (aRes = ModelAPI_Tools::bodyOwner(aRes)) {
504               aRes->setDisplayed(false);
505             }
506           }
507         }
508         Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
509         myProxyViewer->setSelector(0);
510         delete mySelector;
511         mySelector = 0;
512
513         myWorkshop->module()->clearViewer();
514       }
515     }
516   }
517 }
518
519 //******************************************************
520 QtxPopupMgr* SHAPERGUI::popupMgr()
521 {
522   if (!myPopupMgr)
523     myPopupMgr = new QtxPopupMgr( 0, this );
524   return myPopupMgr;
525 }
526
527 //******************************************************
528 void SHAPERGUI::onDefaultPreferences()
529 {
530   // reset main resources
531   ModuleBase_Preferences::resetResourcePreferences(preferences());
532   // reset plugin's resources
533   ModuleBase_Preferences::resetConfigPropPreferences(preferences());
534
535   myWorkshop->displayer()->redisplayObjects();
536 }
537
538 //******************************************************
539 void SHAPERGUI::onScriptLoaded()
540 {
541   // this slot is called after processing of the LoadScriptId action of SalomeApp Application
542   // Each dumped script contains updateObjBrowser() that creates a new instance of Object
543   // Browser. When SHAPER module is active, this browser should not be used. It might be removed
544   // as hidden by means of updateWindows() of SalomeApp_Application or to remove
545   // it manually (because this method of application is protected)
546   SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
547   if (aBrowser)
548     delete aBrowser;
549   myWorkshop->displayer()->updateViewer();
550   myWorkshop->updateCommandStatus();
551 }
552
553 //******************************************************
554 void SHAPERGUI::onSaveDocByShaper()
555 {
556   if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
557     return;
558
559   getApp()->onSaveDoc();
560 }
561
562 //******************************************************
563 void SHAPERGUI::onSaveAsDocByShaper()
564 {
565   if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
566     return;
567
568   getApp()->onSaveAsDoc();
569 }
570
571 //******************************************************
572 void SHAPERGUI::onUpdateCommandStatus()
573 {
574   getApp()->updateActions();
575 }
576
577 //******************************************************
578 SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
579 {
580   if (theMgr->getType() == OCCViewer_Viewer::Type()) {
581     OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
582
583     //if (myHighlightPointAspect.IsNull()) {
584     //  Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
585     //  myHighlightPointAspect =
586     //    new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*());
587     //}
588     SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
589                                                                  getApp()->selectionMgr());
590 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
591     aViewer->setUseLocalSelection(true);
592 #endif
593     LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
594     QList<SUIT_Selector*> aList;
595     aMgr->selectors(aList);
596     foreach(SUIT_Selector* aSel, aList)
597     {
598       aSel->setEnabled(aSel == aSelector);
599     }
600     myProxyViewer->setSelector(aSelector);
601
602     if (myOldSelectionColor.size() == 0)
603       myOldSelectionColor = myWorkshop->displayer()->selectionColor();
604
605     std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
606     myWorkshop->displayer()->setSelectionColor(aColor);
607     return aSelector;
608   }
609   return 0;
610 }
611
612 //******************************************************
613 CAM_DataModel* SHAPERGUI::createDataModel()
614 {
615   return new SHAPERGUI_DataModel(this);
616 }
617
618 QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
619                                const bool isAddSeparator)
620 {
621   return addFeature(theWBName,
622                     theInfo.toolBar,
623                     theInfo.id,
624                     theInfo.text,
625                     //Issue #650: in the SALOME mode the tooltip should be same as text
626                     theInfo.text,
627                     theInfo.icon,
628                     theInfo.shortcut,
629                     theInfo.checkable,
630                     isAddSeparator,
631                     theInfo.toolTip);
632 }
633
634 //******************************************************
635 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBName,
636                                const QString& theId, const QString& theTitle, const QString& theTip,
637                                const QIcon& theIcon, const QKeySequence& theKeys,
638                                bool isCheckable, const bool isAddSeparator,
639                                const QString& theStatusTip)
640 {
641   static QString aLastTool = "";
642   static int aNb = 0;
643   if (aLastTool.isEmpty())
644     aLastTool = theWBName;
645   else if (theWBName != aLastTool) {
646     aLastTool = theWBName;
647     if (aNb > 20) {
648       desktop()->addToolBarBreak();
649       aNb = 0;
650     }
651   }
652   aNb++;
653
654   int aId = getNextCommandId();
655   myActionsList.append(aId);
656   SUIT_Desktop* aDesk = application()->desktop();
657   int aKeys = 0;
658   for (int i = 0; i < theKeys.count(); i++)
659     aKeys += theKeys[i];
660   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
661                                   isCheckable);
662   aAction->setStatusTip(theStatusTip);
663
664   aAction->setData(theId);
665
666   int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
667 #ifdef _DEBUG
668   int aItemId =
669 #endif
670     createMenu(aId, aWBMenu);
671   if (isAddSeparator)
672     createMenu(separator(), aWBMenu);
673
674   int aWBTool = createTool(theTBName, theTBName);
675 #ifdef _DEBUG
676   int aToolId =
677 #endif
678     createTool(aId, aWBTool);
679   registerCommandToolbar(theTBName, aId);
680   if (isAddSeparator) {
681     createTool(separator(), aWBTool);
682     registerCommandToolbar(theTBName, -1);
683   }
684   return aAction;
685 }
686
687 bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
688 {
689   return dynamic_cast<const SHAPERGUI_NestedButton*>(theAction);
690 }
691
692 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
693                                        const ActionInfo& theInfo,
694                                        const QList<QAction*>& theNestedActions)
695 {
696   SUIT_Desktop* aDesk = application()->desktop();
697   SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
698   anAction->setData(theInfo.id);
699   anAction->setCheckable(theInfo.checkable);
700   anAction->setChecked(theInfo.checked);
701   anAction->setEnabled(theInfo.enabled);
702   anAction->setVisible(theInfo.visible);
703   anAction->setIcon(theInfo.icon);
704   anAction->setText(theInfo.text);
705   anAction->setToolTip(theInfo.toolTip);
706   anAction->setShortcut(theInfo.shortcut);
707   anAction->setFont(theInfo.font);
708
709   int aWBMenu = createMenu(theWBName, -1, -1, 30);
710   int aItemId = createMenu(anAction, aWBMenu);
711   myActionsList.append(aItemId);
712   createMenu(separator(), aWBMenu); /// nested action is always separated of others
713
714   int aWBTool = createTool(theWBName, theWBName);
715 #ifdef _DEBUG
716   int aToolId =
717 #endif
718     createTool(anAction, aWBTool);
719   registerCommandToolbar(theWBName, aItemId);
720   createTool(separator(), aWBTool); /// nested action is always separated of others
721   registerCommandToolbar(theWBName, -1);
722
723   return anAction;
724 }
725
726
727 //******************************************************
728 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
729                                            const QString& theTip, const QIcon& theIcon,
730                                            const QKeySequence& theKeys, bool isCheckable,
731                                            const char* theMenuSourceText,
732                                            const QString& theSubMenu,
733                                            const int theMenuPosition,
734                                            const int theSuibMenuPosition)
735 {
736   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
737   if (!theSubMenu.isNull())
738     aMenu = createMenu(theSubMenu, aMenu, -1, theSuibMenuPosition);
739
740   int aId = getNextCommandId();
741   myActionsList.append(aId);
742   SUIT_Desktop* aDesk = application()->desktop();
743   int aKeys = 0;
744   for (int i = 0; i < theKeys.count(); i++)
745     aKeys += theKeys[i];
746   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
747                                   isCheckable);
748   aAction->setStatusTip(theTip);
749   aAction->setData(theId);
750   createMenu(aId, aMenu, theMenuPosition);
751   return aAction;
752 }
753
754 //******************************************************
755 void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
756 {
757   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
758   createMenu(separator(), aMenu, -1, theMenuPosition);
759 }
760
761 //******************************************************
762 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
763 {
764   if( !theAction )
765     return false;
766
767   SUIT_Desktop* aDesktop = application()->desktop();
768   if( !aDesktop )
769     return false;
770
771   QtxActionToolMgr* aToolMgr = aDesktop->toolMgr();
772   if( !aToolMgr )
773     return false;
774
775   aToolMgr->append( theAction, theToolBarTitle );
776   return true;
777 }
778
779 //******************************************************
780 QList<QAction*> SHAPERGUI::commandList() const
781 {
782   QList<QAction*> aActions;
783   foreach (int aId, myActionsList) {
784     QAction* aCmd = action(aId);
785     if (aCmd)
786       aActions.append(aCmd);
787   }
788
789   return aActions;
790 }
791
792 //******************************************************
793 QMainWindow* SHAPERGUI::desktop() const
794 {
795   return application()->desktop();
796 }
797
798 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
799                                const std::shared_ptr<Config_FeatureMessage>& theMessage)
800 {
801   myFeaturesInfo.insert(theFeatureId, theMessage);
802 }
803
804 std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
805 {
806   std::shared_ptr<Config_FeatureMessage> aMessage;
807   if (myFeaturesInfo.contains(theFeatureId))
808     aMessage =  myFeaturesInfo[theFeatureId];
809   return aMessage;
810 }
811
812 //******************************************************
813 void SHAPERGUI::selectionChanged()
814 {
815   LightApp_Module::selectionChanged();
816   myWorkshop->salomeViewerSelectionChanged();
817 }
818
819 //******************************************************
820 void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
821 {
822   myWorkshop->contextMenuMgr()->updateViewerMenu();
823   myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
824   LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
825 }
826
827
828 //******************************************************
829 void SHAPERGUI::createPreferences()
830 {
831   LightApp_Preferences* pref = preferences();
832   if (!pref)
833     return;
834   ModuleBase_Preferences::updateConfigByResources();
835   QString aModName = moduleName();
836
837   QtxPreferenceItem* item = pref->findItem(aModName, true );
838   if ( item && (!item->isEmpty() )) {
839     item->parentItem()->removeItem(item);
840     delete item;
841   }
842
843   int catId = pref->addPreference(aModName, -1 );
844   if ( catId == -1 )
845     return;
846   SHAPERGUI_PrefMgr aMgr(pref, aModName);
847   ModuleBase_Preferences::createEditContent(&aMgr, catId);
848
849   int viewTab = pref->addItem(tr("Viewer"), catId);
850   // Create other parameters group in viewer tab
851   int otherGroup = pref->addItem(tr("Default selection"), viewTab);
852   pref->setItemProperty("columns", 3, otherGroup);
853   pref->addItem(tr("Faces"), otherGroup,
854                          SUIT_PreferenceMgr::Bool,
855                          ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
856   pref->addItem(tr("Edges"), otherGroup,
857                          SUIT_PreferenceMgr::Bool,
858                          ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
859   pref->addItem(tr("Vertices"), otherGroup,
860                          SUIT_PreferenceMgr::Bool,
861                          ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
862
863   int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
864   pref->setItemProperty("columns", 2, sensitivityGroup);
865   pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
866                 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
867   pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
868                 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
869
870   int highlightGroup = pref->addItem(tr("Additional highlighting"), viewTab);
871   pref->setItemProperty("columns", 2, highlightGroup);
872   pref->addItem(tr("In 3d mode"), highlightGroup,
873     SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d");
874   pref->addItem(tr("In 2d mode"), highlightGroup,
875     SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d");
876
877   int colorScaleGroup = pref->addItem(tr("Color scale"), viewTab);
878   pref->setItemProperty("columns", 4, colorScaleGroup);
879   int aItem = aMgr.addPreference(tr("X position"), colorScaleGroup,
880     SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_x_position");
881   pref->setItemProperty("min", 0, aItem);
882   pref->setItemProperty("max", 1, aItem);
883
884   aItem = aMgr.addPreference(tr("Y position"), colorScaleGroup,
885     SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_y_position");
886   pref->setItemProperty("min", 0, aItem);
887   pref->setItemProperty("max", 1, aItem);
888
889   aItem = aMgr.addPreference(tr("Width"), colorScaleGroup,
890     SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_width");
891   pref->setItemProperty("min", 0, aItem);
892   pref->setItemProperty("max", 1, aItem);
893
894   aItem = aMgr.addPreference(tr("Height"), colorScaleGroup,
895     SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_height");
896   pref->setItemProperty("min", 0, aItem);
897   pref->setItemProperty("max", 1, aItem);
898
899   aItem = aMgr.addPreference(tr("Intervals number"), colorScaleGroup,
900     SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_nb_intervals");
901   pref->setItemProperty("min", 0, aItem);
902   pref->setItemProperty("max", 100, aItem);
903
904   aItem = aMgr.addPreference(tr("Text height"), colorScaleGroup,
905     SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_height");
906   pref->setItemProperty("min", 0, aItem);
907   pref->setItemProperty("max", 100, aItem);
908
909   aItem = aMgr.addPreference(tr("Text color"), colorScaleGroup,
910     SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color");
911
912   pref->retrieve();
913 }
914
915 //******************************************************
916 void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam)
917 {
918   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
919   QString aVal = aResMgr->stringValue(theSection, theParam);
920   Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
921                                                     theParam.toStdString());
922   std::string aValue = aVal.toStdString();
923   if (aValue.empty()) {
924     aValue = aProp->defaultValue();
925     aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
926
927     LightApp_Preferences* pref = preferences();
928     if (pref)
929       pref->retrieve();
930   }
931   aProp->setValue(aValue);
932
933   if ((theSection == "Visualization") && (theParam == "selection_color")) {
934     std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
935     myWorkshop->displayer()->setSelectionColor(aColor);
936   }
937
938   myWorkshop->displayer()->redisplayObjects();
939 }
940
941 void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
942 {
943   application()->putInfo(theInfo, theMSecs);
944 }
945
946 bool SHAPERGUI::abortAllOperations()
947 {
948   return workshop()->operationMgr()->abortAllOperations();
949 }
950
951 void SHAPERGUI::createFeatureActions()
952 {
953   myWorkshop->menuMgr()->createFeatureActions();
954 }
955
956 void SHAPERGUI::onWhatIs(bool isToggled)
957 {
958   if (sender() == myWhatIsAction) {
959     QAction* aViewAct = myInspectionPanel->toggleViewAction();
960     aViewAct->blockSignals(true);
961     aViewAct->setChecked(isToggled);
962     aViewAct->blockSignals(false);
963     myInspectionPanel->setVisible(isToggled);
964   }
965   else {
966     myWhatIsAction->blockSignals(true);
967     myWhatIsAction->setChecked(isToggled);
968     myWhatIsAction->blockSignals(false);
969     myInspectionPanel->setVisible(isToggled);
970   }
971 }
972
973 void SHAPERGUI::updateModuleVisibilityState()
974 {
975   LightApp_Module::updateModuleVisibilityState();
976   onWhatIs(myIsInspectionVisible);
977 }
978
979 void SHAPERGUI::onEditToolbars()
980 {
981   SHAPERGUI_ToolbarsDlg aDlg(this);
982   if (aDlg.exec() == QDialog::Accepted) {
983     if (aDlg.isReset())
984       resetToolbars();
985     else
986       updateToolbars(aDlg.result());
987   }
988 }
989
990 void SHAPERGUI::registerCommandToolbar(const QString& theToolName, int theCommandId)
991 {
992   if (!myToolbars.contains(theToolName))
993     myToolbars[theToolName] = QList<int>();
994   myToolbars[theToolName].append(theCommandId);
995 }
996
997 int SHAPERGUI::getNextCommandId() const
998 {
999   QtxActionMenuMgr* aMenuMgr = menuMgr();
1000   QIntList aIds = aMenuMgr->idList();
1001   int aId = aIds.count();
1002   while (action(aId) || myActionsList.contains(aId))
1003     aId++;
1004   return aId;
1005 }
1006
1007 void SHAPERGUI::updateToolbars(const QMap<QString, QIntList>& theNewToolbars)
1008 {
1009   // Store default toolbars
1010   if (myDefaultToolbars.size() == 0)
1011     myDefaultToolbars = myToolbars;
1012
1013   QtxActionToolMgr* aMgr = toolMgr();
1014   QStringList aToolbars = theNewToolbars.keys();
1015   QIntList aCommands, aOldCmd;
1016   int aToolbarId;
1017   QAction* aAction;
1018   int aActionId;
1019   foreach(QString aName, aToolbars) {
1020     aCommands = theNewToolbars[aName];
1021     // Find or create toolbar
1022     if (aMgr->hasToolBar(aName)) {
1023       aToolbarId = aMgr->find(aMgr->toolBar(aName));
1024       aOldCmd = myToolbars[aName];
1025     }
1026     else {
1027       aToolbarId = aMgr->createToolBar(aName);
1028     }
1029     int aPos = 0;
1030     foreach(int aCmd, aCommands) {
1031       // Find action
1032       if (aCmd == -1)
1033         aAction = separator();
1034       else
1035         aAction = action(aCmd);
1036       aActionId = aMgr->actionId(aAction);
1037       if (aActionId == -1) {
1038         // Add new action
1039         aMgr->insert(aAction, aToolbarId, aPos);
1040       }
1041       else {
1042         // Change position of action
1043         if (aMgr->index(aActionId, aToolbarId) != aPos) {
1044           if (aMgr->containsAction(aActionId, aToolbarId))
1045             aMgr->remove(aActionId, aToolbarId);
1046           aMgr->insert(aActionId, aToolbarId, aPos);
1047         }
1048       }
1049       aOldCmd.removeAll(aCmd);
1050       aPos++;
1051     }
1052     // remove extra actions
1053     foreach(int aCmd, aOldCmd) {
1054       aAction = action(aCmd);
1055       aActionId = aMgr->actionId(aAction);
1056       aMgr->remove(aActionId, aToolbarId);
1057     }
1058     myToolbars.remove(aName);
1059   }
1060   // Remove extra toolbars
1061   aToolbars = myToolbars.keys();
1062   foreach(QString aName, aToolbars) {
1063     aMgr->removeToolBar(aName);
1064   }
1065   // Set new toolbars structure
1066   myToolbars = theNewToolbars;
1067   myIsToolbarsModified = true;
1068 }
1069
1070 void SHAPERGUI::saveToolbarsConfig()
1071 {
1072   if (!myIsToolbarsModified)
1073     return;
1074   // Save toolbars configuration into map
1075   QMap<QString, QStringList> aToolbarsConfig;
1076 #ifdef _DEBUG
1077   QtxActionToolMgr* aMgr =
1078 #endif
1079     toolMgr();
1080   QStringList aToolbars = myToolbars.keys();
1081   QIntList aActionsIds;
1082   foreach(QString aName, aToolbars) {
1083     aActionsIds = myToolbars[aName];
1084     QStringList aContent;
1085     foreach(int aId, aActionsIds) {
1086       if (aId == -1)
1087         aContent.append("");
1088       else
1089         aContent.append(action(aId)->data().toString());
1090     }
1091     aToolbarsConfig[aName] = aContent;
1092   }
1093   // Store the configuration into resources
1094   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
1095   QStringList aNames = aToolbarsConfig.keys();
1096   QStringList aValues;
1097   foreach(QString aToolbar, aNames) {
1098     aResMgr->setValue(ToolbarsSection, aToolbar, aToolbarsConfig[aToolbar].join(","));
1099   }
1100   // Remove obsolete parameters from resources
1101   QStringList aOldParams = aResMgr->parameters(ToolbarsSection);
1102   foreach(QString aName, aOldParams) {
1103     if (!aToolbars.contains(aName))
1104       aResMgr->remove(ToolbarsSection, aName);
1105   }
1106   // Store current list of free commands
1107   QIntList aFreeCommands = getFreeCommands();
1108   QStringList aFreeList;
1109   foreach(int aId, aFreeCommands) {
1110     aFreeList.append(action(aId)->data().toString());
1111   }
1112   if (aFreeList.size() > 0)
1113     aResMgr->setValue(ToolbarsSection, FreeCommandsParam, aFreeList.join(","));
1114
1115   myIsToolbarsModified = false;
1116 }
1117
1118 void SHAPERGUI::loadToolbarsConfig()
1119 {
1120   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
1121   QStringList aToolbarNames = aResMgr->parameters(ToolbarsSection);
1122   if (aToolbarNames.size() == 0)
1123     return;
1124
1125   // Create commands map
1126   QMap<QString, int> aCommandsMap;
1127   QString aCmdIdStr;
1128   foreach(int aId, myActionsList) {
1129     aCmdIdStr = action(aId)->data().toString();
1130     aCommandsMap[aCmdIdStr] = aId;
1131   }
1132
1133   // Create new toolbars structure
1134   QMap<QString, QIntList> aToolbars;
1135   QStringList aCommands;
1136   QIntList aKnownCommands;
1137   QList<QAction*> aActions;
1138   foreach(QString aName, aToolbarNames) {
1139     aCommands = aResMgr->stringValue(ToolbarsSection, aName).split(",");
1140     if (aName == FreeCommandsParam) {
1141       // The value is a list of free commands
1142       foreach(QString aCommand, aCommands) {
1143         aKnownCommands.append(aCommandsMap[aCommand]);
1144       }
1145     }
1146     else {
1147       aToolbars[aName] = QIntList();
1148       if (aCommands.size() > 0) {
1149         foreach(QString aCommand, aCommands) {
1150           if (aCommand.isEmpty())
1151             aToolbars[aName].append(-1);
1152           else if (aCommandsMap.contains(aCommand)) {
1153             int aId = aCommandsMap[aCommand];
1154             aToolbars[aName].append(aId);
1155             aKnownCommands.append(aId);
1156           }
1157         }
1158       }
1159     }
1160   }
1161   // Find new and obsolete commands
1162   QIntList aNewCommands = myActionsList;
1163   foreach(int aId, myActionsList) {
1164     if (aKnownCommands.contains(aId)) {
1165       aKnownCommands.removeAll(aId);
1166       aNewCommands.removeAll(aId);
1167     }
1168   }
1169   if (aNewCommands.size() > 0) {
1170     // Add new commands to toolbars structure
1171     QStringList aKeys = myToolbars.keys();
1172     foreach(int aNewId, aNewCommands) {
1173       foreach(QString aName, aKeys) {
1174         if (myToolbars[aName].contains(aNewId)) {
1175           if (!aToolbars.contains(aName)) {
1176             aToolbars[aName] = QIntList();
1177           }
1178           aToolbars[aName].append(aNewId);
1179         }
1180       }
1181     }
1182   }
1183   if (aKnownCommands.size() > 0) {
1184     // Remove obsolete commands from the toolbars structure
1185     QStringList aKeys = aToolbars.keys();
1186     foreach(int aOldId, aKnownCommands) {
1187       foreach(QString aName, aKeys) {
1188         if (aToolbars[aName].contains(aOldId)) {
1189           aToolbars[aName].removeAll(aOldId);
1190           if (aToolbars[aName].size() == 0)
1191             aToolbars.remove(aName);
1192         }
1193       }
1194     }
1195   }
1196   updateToolbars(aToolbars);
1197   myIsToolbarsModified = false;
1198 }
1199
1200
1201 QIntList SHAPERGUI::getFreeCommands() const
1202 {
1203   QIntList aFreeCommands;
1204   QtxActionToolMgr* aMgr = toolMgr();
1205   QAction* anAction;
1206   int aId;
1207   QMap<QString, QIntList>::const_iterator aIt;
1208   QIntList aShaperActions = shaperActions();
1209   foreach(int aCmd, aShaperActions) {
1210     anAction = action(aCmd);
1211     aId = aMgr->actionId(anAction);
1212     if (!aMgr->containsAction(aId))
1213       aFreeCommands.append(aCmd);
1214   }
1215   return aFreeCommands;
1216 }
1217
1218 void SHAPERGUI::resetToolbars()
1219 {
1220   if (!myDefaultToolbars.isEmpty())
1221     updateToolbars(myDefaultToolbars);
1222   myIsToolbarsModified = false;
1223   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
1224   aResMgr->remove(ToolbarsSection);
1225 }
1226
1227 void SHAPERGUI::publishToStudy()
1228 {
1229   if (isActiveModule())
1230     myWorkshop->module()->launchOperation("PublishToStudy", false);
1231 }