1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "SHAPERGUI.h"
22 #include "SHAPERGUI_DataModel.h"
23 #include "SHAPERGUI_OCCSelector.h"
24 #include "SHAPERGUI_NestedButton.h"
25 #include "SHAPERGUI_ToolbarsMgr.h"
27 #include <XGUI_Workshop.h>
28 #include <XGUI_PropertyPanel.h>
29 #include <XGUI_ContextMenuMgr.h>
30 #include <XGUI_ObjectsBrowser.h>
31 #include <XGUI_OperationMgr.h>
32 #include <XGUI_Displayer.h>
33 #include <XGUI_MenuMgr.h>
34 #include <XGUI_FacesPanel.h>
35 #include <XGUI_SelectionActivate.h>
36 #include <XGUI_InspectionPanel.h>
38 #include <ModuleBase_Operation.h>
39 #include <ModuleBase_Preferences.h>
40 #include <ModuleBase_ActionInfo.h>
41 #include <ModuleBase_IModule.h>
43 #include <LightApp_Application.h>
44 #include <LightApp_SelectionMgr.h>
45 #include <LightApp_OCCSelector.h>
46 #include <LightApp_Study.h>
47 #include <OCCViewer_ViewModel.h>
49 #include <SUIT_Selector.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_ViewManager.h>
52 #include <SUIT_ResourceMgr.h>
53 #include <SUIT_DataBrowser.h>
55 #include <QtxPopupMgr.h>
56 #include <QtxActionMenuMgr.h>
57 #include <QtxActionToolMgr.h>
58 #include <QtxResourceMgr.h>
60 #include <Config_PropManager.h>
61 #include <Config_ModuleReader.h>
63 #include <AIS_ListOfInteractive.hxx>
64 #include <AIS_ListIteratorOfListOfInteractive.hxx>
66 #include <QDockWidget>
71 #define SALOME_PATCH_FOR_CTRL_WHEEL
74 SHAPERGUI_EXPORT CAM_Module* createModule()
76 return new SHAPERGUI();
79 SHAPERGUI_EXPORT char* getModuleVersion()
86 * Class for preferences management
88 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
92 /// \param theMgr preferences manager of SALOME
93 /// \param theModName name of the module
94 SHAPERGUI_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):
95 myMgr(theMgr), myModName(theModName) {}
97 virtual int addPreference(const QString& theLbl, int pId,
98 SUIT_PreferenceMgr::PrefItemType theType,
99 const QString& theSection, const QString& theName )
101 return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
104 virtual void setItemProperty(const QString& thePropName,
105 const QVariant& theValue,
106 const int theId = -1)
108 myMgr->setItemProperty(thePropName, theValue, theId);
112 virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
115 LightApp_Preferences* myMgr;
122 //******************************************************
123 SHAPERGUI::SHAPERGUI()
124 : LightApp_Module("SHAPER"),
125 mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
128 myWorkshop = new XGUI_Workshop(this);
129 connect(myWorkshop, SIGNAL(commandStatusUpdated()),
130 this, SLOT(onUpdateCommandStatus()));
132 myProxyViewer = new SHAPERGUI_SalomeViewer(this);
134 ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
135 ModuleBase_Preferences::loadCustomProps();
138 //******************************************************
139 SHAPERGUI::~SHAPERGUI()
142 delete myProxyViewer;
145 //******************************************************
146 void SHAPERGUI::initialize(CAM_Application* theApp)
148 LightApp_Module::initialize(theApp);
150 myWorkshop->startApplication();
151 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
154 connect(anApp, SIGNAL(preferenceResetToDefaults()), this, SLOT(onDefaultPreferences()));
157 int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
158 int aSubMenu = createMenu(tr("Information"), aMenu);
160 int aId = getNextCommandId();
161 myActionsList.append(aId);
162 SUIT_Desktop* aDesk = application()->desktop();
163 QString aTip = tr("Show inspection window");
164 myWhatIsAction = createAction(aId, aTip, QIcon(":pictures/whatis.png"), tr("What Is"),
165 aTip, QKeySequence(), aDesk, true, this, SLOT(onWhatIs(bool)));
166 myWhatIsAction->setStatusTip(aTip);
167 myWhatIsAction->setData("INSPECTION_CMD");
168 createMenu(aId, aSubMenu, 0);
170 QString aToolName = tr("Inspection tool");
171 int aTool = createTool(aToolName);
172 int aToolId = createTool(myWhatIsAction, aTool);
173 registerCommandToolbar(aToolName, aId);
175 // Define Edit toolbars command
176 aId = getNextCommandId();
177 myActionsList.append(aId);
178 aTip = tr("Edit toolbars of the module");
179 QAction* aAction = createAction(aId, aTip, QIcon(), tr("Edit toolbars..."),
180 aTip, QKeySequence(), aDesk, false, this, SLOT(onEditToolbars()));
181 int aEditMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1, 30);
182 int aEditItem = createMenu(aId, aEditMenu);
185 //******************************************************
186 void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
188 theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
191 //******************************************************
192 void SHAPERGUI::viewManagers(QStringList& theList) const
194 theList.append(OCCViewer_Viewer::Type());
197 //******************************************************
198 // We can not create selector in this method because it can be called when
199 // SHAPER module is not active. Take into account that creation of our selector
200 // leads to switching OFF all other selectors
201 //void SHAPERGUI::connectToStudy(CAM_Study* theStudy)
203 // // if there are created viewer managers, we should try to create viewer
204 // // selector and initialize viewer with it. It sets interactive contect to the
205 // // proxy viewer. If study is opened, CAM application calls this method before the open()
207 // // the SHAPER data model is specific and during open(load) redisplay signals are flushed, so
208 // // we need to connect to the viewer before it. Here,
209 // // it seems the most appropriate place for this
210 // // according to SALOME architecture.
211 // if (!mySelector) {
212 // ViewManagerList OCCViewManagers;
213 // application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
214 // if (OCCViewManagers.size() > 0) {
215 // mySelector = createSelector(OCCViewManagers.first());
218 // LightApp_Module::connectToStudy(theStudy);
221 //******************************************************
222 bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
224 bool isDone = LightApp_Module::activateModule(theStudy);
225 SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
226 aDataModel->initRootObject();
232 QObject* aObj = myWorkshop->objectBrowser()->parent();
233 QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
235 QAction* aViewAct = aObjDoc->toggleViewAction();
236 aViewAct->setEnabled(true);
237 myWorkshop->objectBrowser()->setVisible(true);
238 aObjDoc->setVisible(true);
239 desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
242 if (!myInspectionPanel) {
243 myInspectionPanel = myWorkshop->inspectionPanel();
244 QAction* aViewAct = myInspectionPanel->toggleViewAction();
245 connect(aViewAct, SIGNAL(toggled(bool)), this, SLOT(onWhatIs(bool)));
247 myInspectionPanel->toggleViewAction()->setEnabled(true);
250 ViewManagerList OCCViewManagers;
251 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
252 if (OCCViewManagers.size() > 0) {
253 mySelector = createSelector(OCCViewManagers.first());
256 // it should be pefromed after the selector creation in order to have AISContext
257 myWorkshop->activateModule();
258 //action(myEraseAll)->setEnabled(false);
261 myWorkshop->objectBrowser()->rebuildDataTree();
262 myWorkshop->updateCommandStatus();
266 myWorkshop->updateCommandStatus();
268 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
269 myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
270 myIsEditEnabled = getApp()->isEditEnabled();
271 getApp()->setEditEnabled(false);
273 // this following row is caused by #187 bug.
274 // SALOME saves the dock widget positions before deactivateModule() and
275 // load it after the module activation. So, if the panel is visible before
276 // deactivate, it becomes visible after activate.
277 // In order to avoid the visible property panel, the widget position save is
278 // switch off in this module
279 aResMgr->setValue("Study", "store_positions", false);
281 // Synchronize displayed objects
282 Handle(AIS_InteractiveContext) aContext;
283 if (mySelector && mySelector->viewer())
284 aContext = mySelector->viewer()->getAISContext();
286 if (!aContext.IsNull()) {
287 XGUI_Displayer* aDisp = myWorkshop->displayer();
288 QObjectPtrList aObjList = aDisp->displayedObjects();
290 AIS_ListOfInteractive aList;
291 aContext->DisplayedObjects(aList);
292 AIS_ListIteratorOfListOfInteractive aLIt;
293 Handle(AIS_InteractiveObject) anAISIO;
294 foreach (ObjectPtr aObj, aObjList) {
295 AISObjectPtr aPrs = aDisp->getAISObject(aObj);
296 Handle(AIS_InteractiveObject) aAIS = aPrs->impl<Handle(AIS_InteractiveObject)>();
298 for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
299 anAISIO = aLIt.Value();
300 if (anAISIO.get() == aAIS.get()) {
306 aObj->setDisplayed(false);
307 //aDisp->erase(aObj, false);
310 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
312 myProxyViewer->activateViewer(true);
314 // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
315 connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
316 this, SLOT(onScriptLoaded()));
318 disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
319 getApp(), SLOT(onSaveDoc()));
320 disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
321 getApp(), SLOT(onSaveAsDoc()));
323 connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
324 this, SLOT(onSaveDocByShaper()));
325 connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
326 this, SLOT(onSaveAsDocByShaper()));
331 //******************************************************
332 bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
334 myProxyViewer->activateViewer(false);
338 myWorkshop->deactivateModule();
340 QObject* aObj = myWorkshop->objectBrowser()->parent();
341 QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
343 aObjDoc->setVisible(false);
344 myWorkshop->objectBrowser()->setVisible(false);
345 QAction* aViewAct = aObjDoc->toggleViewAction();
346 aViewAct->setEnabled(false);
349 myIsInspectionVisible = myInspectionPanel->isVisible();
350 myInspectionPanel->hide();
351 QAction* aViewAct = myInspectionPanel->toggleViewAction();
352 aViewAct->setEnabled(false);
354 // the active operation should be stopped for the next activation.
355 // There should not be active operation and visualized preview.
356 // Abort operation should be performed before the selection's remove
357 // because the displayed objects should be removed from the viewer, but
358 // the AIS context is obtained from the selector.
359 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
360 while (anOperation) {
361 anOperation->abort();
362 anOperation = myWorkshop->operationMgr()->currentOperation();
364 // Delete selector because it has to be redefined on next activation
366 myProxyViewer->setSelector(0);
371 myWorkshop->hidePanel(myWorkshop->facesPanel());
372 //myWorkshop->contextMenuMgr()->disconnectViewer();
374 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
375 aResMgr->setValue("Study", "store_positions", myIsStorePositions);
376 getApp()->setEditEnabled(myIsEditEnabled);
378 // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
379 disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
380 this, SLOT(onScriptLoaded()));
382 disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
383 this, SLOT(onSaveDocByShaper()));
384 disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
385 this, SLOT(onSaveAsDocByShaper()));
387 connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
388 getApp(), SLOT(onSaveDoc()));
389 connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
390 getApp(), SLOT(onSaveAsDoc()));
393 return LightApp_Module::deactivateModule(theStudy);
396 //******************************************************
397 void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
400 mySelector = createSelector(theMgr);
401 myWorkshop->selectionActivate()->updateSelectionFilters();
402 myWorkshop->selectionActivate()->updateSelectionModes();
403 myWorkshop->synchronizeViewer();
407 //******************************************************
408 void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr)
411 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
412 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
413 if (mySelector->viewer() == aViewer) {
414 XGUI_Displayer* aDisp = myWorkshop->displayer();
415 QObjectPtrList aObjects = aDisp->displayedObjects();
416 foreach(ObjectPtr aObj, aObjects)
417 aObj->setDisplayed(false);
418 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
419 myProxyViewer->setSelector(0);
423 myWorkshop->module()->clearViewer();
429 //******************************************************
430 QtxPopupMgr* SHAPERGUI::popupMgr()
433 myPopupMgr = new QtxPopupMgr( 0, this );
437 //******************************************************
438 void SHAPERGUI::onDefaultPreferences()
440 // reset main resources
441 ModuleBase_Preferences::resetResourcePreferences(preferences());
442 // reset plugin's resources
443 ModuleBase_Preferences::resetConfigPropPreferences(preferences());
445 myWorkshop->displayer()->redisplayObjects();
448 //******************************************************
449 void SHAPERGUI::onScriptLoaded()
451 // this slot is called after processing of the LoadScriptId action of SalomeApp Application
452 // Each dumped script contains updateObjBrowser() that creates a new instance of Object
453 // Browser. When SHAPER module is active, this browser should not be used. It might be removed
454 // as hidden by means of updateWindows() of SalomeApp_Application or to remove
455 // it manually (because this method of application is protected)
456 SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
461 //******************************************************
462 void SHAPERGUI::onSaveDocByShaper()
464 if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
467 getApp()->onSaveDoc();
470 //******************************************************
471 void SHAPERGUI::onSaveAsDocByShaper()
473 if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
476 getApp()->onSaveAsDoc();
479 //******************************************************
480 void SHAPERGUI::onUpdateCommandStatus()
482 getApp()->updateActions();
485 //******************************************************
486 SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
488 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
489 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
490 SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
491 getApp()->selectionMgr());
492 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
493 aViewer->setUseLocalSelection(true);
495 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
496 QList<SUIT_Selector*> aList;
497 aMgr->selectors(aList);
498 foreach(SUIT_Selector* aSel, aList)
500 aSel->setEnabled(aSel == aSelector);
502 myProxyViewer->setSelector(aSelector);
508 //******************************************************
509 CAM_DataModel* SHAPERGUI::createDataModel()
511 return new SHAPERGUI_DataModel(this);
514 QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
515 const bool isAddSeparator)
517 return addFeature(theWBName,
521 //Issue #650: in the SALOME mode the tooltip should be same as text
530 //******************************************************
531 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBName,
532 const QString& theId, const QString& theTitle, const QString& theTip,
533 const QIcon& theIcon, const QKeySequence& theKeys,
534 bool isCheckable, const bool isAddSeparator,
535 const QString& theStatusTip)
537 static QString aLastTool = "";
539 if (aLastTool.isEmpty())
540 aLastTool = theWBName;
541 else if (theWBName != aLastTool) {
542 aLastTool = theWBName;
544 desktop()->addToolBarBreak();
550 int aId = getNextCommandId();
551 myActionsList.append(aId);
552 SUIT_Desktop* aDesk = application()->desktop();
554 for (int i = 0; i < theKeys.count(); i++)
556 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
558 aAction->setStatusTip(theStatusTip);
560 aAction->setData(theId);
562 int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
563 int aItemId = createMenu(aId, aWBMenu);
565 createMenu(separator(), aWBMenu);
567 int aWBTool = createTool(theTBName, theTBName);
568 int aToolId = createTool(aId, aWBTool);
569 registerCommandToolbar(theTBName, aId);
570 if (isAddSeparator) {
571 createTool(separator(), aWBTool);
572 registerCommandToolbar(theTBName, -1);
578 bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
580 return dynamic_cast<const SHAPERGUI_NestedButton*>(theAction);
583 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
584 const ActionInfo& theInfo,
585 const QList<QAction*>& theNestedActions)
587 SUIT_Desktop* aDesk = application()->desktop();
588 SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
589 anAction->setData(theInfo.id);
590 anAction->setCheckable(theInfo.checkable);
591 anAction->setChecked(theInfo.checked);
592 anAction->setEnabled(theInfo.enabled);
593 anAction->setVisible(theInfo.visible);
594 anAction->setIcon(theInfo.icon);
595 anAction->setText(theInfo.text);
596 anAction->setToolTip(theInfo.toolTip);
597 anAction->setShortcut(theInfo.shortcut);
598 anAction->setFont(theInfo.font);
600 int aWBMenu = createMenu(theWBName, -1, -1, 30);
601 int aItemId = createMenu(anAction, aWBMenu);
602 myActionsList.append(aItemId);
603 createMenu(separator(), aWBMenu); /// nested action is always separated of others
605 int aWBTool = createTool(theWBName, theWBName);
606 int aToolId = createTool(anAction, aWBTool);
607 registerCommandToolbar(theWBName, aItemId);
608 createTool(separator(), aWBTool); /// nested action is always separated of others
609 registerCommandToolbar(theWBName, -1);
615 //******************************************************
616 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
617 const QString& theTip, const QIcon& theIcon,
618 const QKeySequence& theKeys, bool isCheckable,
619 const char* theMenuSourceText, const int theMenuPosition)
621 int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
623 int aId = getNextCommandId();
624 myActionsList.append(aId);
625 SUIT_Desktop* aDesk = application()->desktop();
627 for (int i = 0; i < theKeys.count(); i++)
629 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
631 aAction->setStatusTip(theTip);
632 aAction->setData(theId);
633 createMenu(aId, aMenu, theMenuPosition);
637 //******************************************************
638 void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
640 int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
641 createMenu(separator(), aMenu, -1, theMenuPosition);
644 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
649 SUIT_Desktop* aDesktop = application()->desktop();
653 QtxActionToolMgr* aToolMgr = aDesktop->toolMgr();
657 aToolMgr->append( theAction, theToolBarTitle );
661 //******************************************************
662 QList<QAction*> SHAPERGUI::commandList() const
664 QList<QAction*> aActions;
665 foreach (int aId, myActionsList) {
666 QAction* aCmd = action(aId);
668 aActions.append(aCmd);
674 //******************************************************
675 QMainWindow* SHAPERGUI::desktop() const
677 return application()->desktop();
680 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
681 const std::shared_ptr<Config_FeatureMessage>& theMessage)
683 myFeaturesInfo.insert(theFeatureId, theMessage);
686 std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
688 std::shared_ptr<Config_FeatureMessage> aMessage;
689 if (myFeaturesInfo.contains(theFeatureId))
690 aMessage = myFeaturesInfo[theFeatureId];
694 //******************************************************
695 void SHAPERGUI::selectionChanged()
697 LightApp_Module::selectionChanged();
698 myWorkshop->salomeViewerSelectionChanged();
701 //******************************************************
702 void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
704 myWorkshop->contextMenuMgr()->updateViewerMenu();
705 myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
706 LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
710 //******************************************************
711 void SHAPERGUI::createPreferences()
713 LightApp_Preferences* pref = preferences();
716 ModuleBase_Preferences::updateConfigByResources();
717 QString aModName = moduleName();
719 QtxPreferenceItem* item = pref->findItem(aModName, true );
720 if ( item && (!item->isEmpty() )) {
721 item->parentItem()->removeItem(item);
725 int catId = pref->addPreference(aModName, -1 );
728 SHAPERGUI_PrefMgr aMgr(pref, aModName);
729 ModuleBase_Preferences::createEditContent(&aMgr, catId);
731 int viewTab = pref->addItem(tr("Viewer"), catId);
732 // Create other parameters group in viewer tab
733 int otherGroup = pref->addItem(tr("Default selection"), viewTab);
734 pref->setItemProperty("columns", 3, otherGroup);
735 pref->addItem(tr("Faces"), otherGroup,
736 SUIT_PreferenceMgr::Bool,
737 ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
738 pref->addItem(tr("Edges"), otherGroup,
739 SUIT_PreferenceMgr::Bool,
740 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
741 pref->addItem(tr("Vertices"), otherGroup,
742 SUIT_PreferenceMgr::Bool,
743 ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
745 int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
746 pref->setItemProperty("columns", 2, sensitivityGroup);
747 pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
748 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
749 pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
750 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
754 //******************************************************
755 void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam)
757 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
758 QString aVal = aResMgr->stringValue(theSection, theParam);
759 Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
760 theParam.toStdString());
761 std::string aValue = aVal.toStdString();
762 if (aValue.empty()) {
763 aValue = aProp->defaultValue();
764 aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
766 LightApp_Preferences* pref = preferences();
770 aProp->setValue(aValue);
772 myWorkshop->displayer()->redisplayObjects();
775 void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
777 application()->putInfo(theInfo, theMSecs);
780 bool SHAPERGUI::abortAllOperations()
782 return workshop()->operationMgr()->abortAllOperations();
785 void SHAPERGUI::createFeatureActions()
787 myWorkshop->menuMgr()->createFeatureActions();
790 void SHAPERGUI::onWhatIs(bool isToggled)
792 if (sender() == myWhatIsAction) {
793 QAction* aViewAct = myInspectionPanel->toggleViewAction();
794 aViewAct->blockSignals(true);
795 aViewAct->setChecked(isToggled);
796 aViewAct->blockSignals(false);
797 myInspectionPanel->setVisible(isToggled);
800 myWhatIsAction->blockSignals(true);
801 myWhatIsAction->setChecked(isToggled);
802 myWhatIsAction->blockSignals(false);
803 myInspectionPanel->setVisible(isToggled);
807 void SHAPERGUI::updateModuleVisibilityState()
809 LightApp_Module::updateModuleVisibilityState();
810 onWhatIs(myIsInspectionVisible);
813 void SHAPERGUI::onEditToolbars()
815 SHAPERGUI_ToolbarsDlg aDlg(this, myActionsList, myToolbars);
819 void SHAPERGUI::registerCommandToolbar(const QString& theToolName, int theCommandId)
821 if (!myToolbars.contains(theToolName))
822 myToolbars[theToolName] = QList<int>();
823 myToolbars[theToolName].append(theCommandId);
826 int SHAPERGUI::getNextCommandId() const
828 QtxActionMenuMgr* aMenuMgr = menuMgr();
829 QIntList aIds = aMenuMgr->idList();
830 int aId = aIds.count();
831 while (aIds.contains(aId))