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>
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>
37 #include <ModuleBase_Operation.h>
38 #include <ModuleBase_Preferences.h>
39 #include <ModuleBase_ActionInfo.h>
40 #include <ModuleBase_IModule.h>
42 #include <LightApp_Application.h>
43 #include <LightApp_SelectionMgr.h>
44 #include <LightApp_OCCSelector.h>
45 #include <LightApp_Study.h>
46 #include <OCCViewer_ViewModel.h>
48 #include <SUIT_Selector.h>
49 #include <SUIT_Desktop.h>
50 #include <SUIT_ViewManager.h>
51 #include <SUIT_ResourceMgr.h>
52 #include <SUIT_DataBrowser.h>
54 #include <QtxPopupMgr.h>
55 #include <QtxActionMenuMgr.h>
56 #include <QtxActionToolMgr.h>
57 #include <QtxResourceMgr.h>
59 #include <Config_PropManager.h>
60 #include <Config_ModuleReader.h>
62 #include <AIS_ListOfInteractive.hxx>
63 #include <AIS_ListIteratorOfListOfInteractive.hxx>
65 #include <QDockWidget>
70 #define SALOME_PATCH_FOR_CTRL_WHEEL
73 SHAPERGUI_EXPORT CAM_Module* createModule()
75 return new SHAPERGUI();
78 SHAPERGUI_EXPORT char* getModuleVersion()
85 * Class for preferences management
87 class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
91 /// \param theMgr preferences manager of SALOME
92 /// \param theModName name of the module
93 SHAPERGUI_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):
94 myMgr(theMgr), myModName(theModName) {}
96 virtual int addPreference(const QString& theLbl, int pId,
97 SUIT_PreferenceMgr::PrefItemType theType,
98 const QString& theSection, const QString& theName )
100 return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
103 virtual void setItemProperty(const QString& thePropName,
104 const QVariant& theValue,
105 const int theId = -1)
107 myMgr->setItemProperty(thePropName, theValue, theId);
111 virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
114 LightApp_Preferences* myMgr;
121 //******************************************************
122 SHAPERGUI::SHAPERGUI()
123 : LightApp_Module("SHAPER"),
124 mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
127 myWorkshop = new XGUI_Workshop(this);
128 connect(myWorkshop, SIGNAL(commandStatusUpdated()),
129 this, SLOT(onUpdateCommandStatus()));
131 myProxyViewer = new SHAPERGUI_SalomeViewer(this);
133 ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
134 ModuleBase_Preferences::loadCustomProps();
137 //******************************************************
138 SHAPERGUI::~SHAPERGUI()
141 delete myProxyViewer;
144 //******************************************************
145 void SHAPERGUI::initialize(CAM_Application* theApp)
147 LightApp_Module::initialize(theApp);
149 myWorkshop->startApplication();
150 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
153 connect(anApp, SIGNAL(preferenceResetToDefaults()), this, SLOT(onDefaultPreferences()));
156 int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
157 int aSubMenu = createMenu(tr("Information"), aMenu);
159 int aId = myActionsList.size();
160 myActionsList.append("INSPECTION_CMD");
161 SUIT_Desktop* aDesk = application()->desktop();
162 QString aTip = tr("Show inspection window");
163 myWhatIsAction = createAction(aId, aTip, QIcon(":pictures/whatis.png"), tr("What Is"),
164 aTip, QKeySequence(), aDesk, true, this, SLOT(onWhatIs(bool)));
165 myWhatIsAction->setStatusTip(aTip);
166 myWhatIsAction->setData("INSPECTION_CMD");
167 createMenu(aId, aSubMenu, 0);
169 int aTool = createTool(tr("Inspection tool"));
170 int aToolId = createTool(myWhatIsAction, aTool);
173 //******************************************************
174 void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
176 theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
179 //******************************************************
180 void SHAPERGUI::viewManagers(QStringList& theList) const
182 theList.append(OCCViewer_Viewer::Type());
185 //******************************************************
186 // We can not create selector in this method because it can be called when
187 // SHAPER module is not active. Take into account that creation of our selector
188 // leads to switching OFF all other selectors
189 //void SHAPERGUI::connectToStudy(CAM_Study* theStudy)
191 // // if there are created viewer managers, we should try to create viewer
192 // // selector and initialize viewer with it. It sets interactive contect to the
193 // // proxy viewer. If study is opened, CAM application calls this method before the open()
195 // // the SHAPER data model is specific and during open(load) redisplay signals are flushed, so
196 // // we need to connect to the viewer before it. Here,
197 // // it seems the most appropriate place for this
198 // // according to SALOME architecture.
199 // if (!mySelector) {
200 // ViewManagerList OCCViewManagers;
201 // application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
202 // if (OCCViewManagers.size() > 0) {
203 // mySelector = createSelector(OCCViewManagers.first());
206 // LightApp_Module::connectToStudy(theStudy);
209 //******************************************************
210 bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
212 bool isDone = LightApp_Module::activateModule(theStudy);
213 SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
214 aDataModel->initRootObject();
220 QObject* aObj = myWorkshop->objectBrowser()->parent();
221 QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
223 QAction* aViewAct = aObjDoc->toggleViewAction();
224 aViewAct->setEnabled(true);
225 myWorkshop->objectBrowser()->setVisible(true);
226 aObjDoc->setVisible(true);
227 desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
230 if (!myInspectionPanel) {
231 myInspectionPanel = myWorkshop->inspectionPanel();
232 QAction* aViewAct = myInspectionPanel->toggleViewAction();
233 connect(aViewAct, SIGNAL(toggled(bool)), this, SLOT(onWhatIs(bool)));
235 myInspectionPanel->toggleViewAction()->setEnabled(true);
238 ViewManagerList OCCViewManagers;
239 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
240 if (OCCViewManagers.size() > 0) {
241 mySelector = createSelector(OCCViewManagers.first());
244 // it should be pefromed after the selector creation in order to have AISContext
245 myWorkshop->activateModule();
246 //action(myEraseAll)->setEnabled(false);
249 myWorkshop->objectBrowser()->rebuildDataTree();
250 myWorkshop->updateCommandStatus();
254 myWorkshop->updateCommandStatus();
256 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
257 myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
258 myIsEditEnabled = getApp()->isEditEnabled();
259 getApp()->setEditEnabled(false);
261 // this following row is caused by #187 bug.
262 // SALOME saves the dock widget positions before deactivateModule() and
263 // load it after the module activation. So, if the panel is visible before
264 // deactivate, it becomes visible after activate.
265 // In order to avoid the visible property panel, the widget position save is
266 // switch off in this module
267 aResMgr->setValue("Study", "store_positions", false);
269 // Synchronize displayed objects
270 Handle(AIS_InteractiveContext) aContext;
271 if (mySelector && mySelector->viewer())
272 aContext = mySelector->viewer()->getAISContext();
274 if (!aContext.IsNull()) {
275 XGUI_Displayer* aDisp = myWorkshop->displayer();
276 QObjectPtrList aObjList = aDisp->displayedObjects();
278 AIS_ListOfInteractive aList;
279 aContext->DisplayedObjects(aList);
280 AIS_ListIteratorOfListOfInteractive aLIt;
281 Handle(AIS_InteractiveObject) anAISIO;
282 foreach (ObjectPtr aObj, aObjList) {
283 AISObjectPtr aPrs = aDisp->getAISObject(aObj);
284 Handle(AIS_InteractiveObject) aAIS = aPrs->impl<Handle(AIS_InteractiveObject)>();
286 for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
287 anAISIO = aLIt.Value();
288 if (anAISIO.get() == aAIS.get()) {
294 aObj->setDisplayed(false);
295 //aDisp->erase(aObj, false);
298 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
300 myProxyViewer->activateViewer(true);
302 // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
303 connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
304 this, SLOT(onScriptLoaded()));
306 disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
307 getApp(), SLOT(onSaveDoc()));
308 disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
309 getApp(), SLOT(onSaveAsDoc()));
311 connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
312 this, SLOT(onSaveDocByShaper()));
313 connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
314 this, SLOT(onSaveAsDocByShaper()));
319 //******************************************************
320 bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
322 myProxyViewer->activateViewer(false);
326 myWorkshop->deactivateModule();
328 QObject* aObj = myWorkshop->objectBrowser()->parent();
329 QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
331 aObjDoc->setVisible(false);
332 myWorkshop->objectBrowser()->setVisible(false);
333 QAction* aViewAct = aObjDoc->toggleViewAction();
334 aViewAct->setEnabled(false);
337 myIsInspectionVisible = myInspectionPanel->isVisible();
338 myInspectionPanel->hide();
339 QAction* aViewAct = myInspectionPanel->toggleViewAction();
340 aViewAct->setEnabled(false);
342 // the active operation should be stopped for the next activation.
343 // There should not be active operation and visualized preview.
344 // Abort operation should be performed before the selection's remove
345 // because the displayed objects should be removed from the viewer, but
346 // the AIS context is obtained from the selector.
347 ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
348 while (anOperation) {
349 anOperation->abort();
350 anOperation = myWorkshop->operationMgr()->currentOperation();
352 // Delete selector because it has to be redefined on next activation
354 myProxyViewer->setSelector(0);
359 myWorkshop->hidePanel(myWorkshop->facesPanel());
360 //myWorkshop->contextMenuMgr()->disconnectViewer();
362 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
363 aResMgr->setValue("Study", "store_positions", myIsStorePositions);
364 getApp()->setEditEnabled(myIsEditEnabled);
366 // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
367 disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
368 this, SLOT(onScriptLoaded()));
370 disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
371 this, SLOT(onSaveDocByShaper()));
372 disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
373 this, SLOT(onSaveAsDocByShaper()));
375 connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
376 getApp(), SLOT(onSaveDoc()));
377 connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
378 getApp(), SLOT(onSaveAsDoc()));
381 return LightApp_Module::deactivateModule(theStudy);
384 //******************************************************
385 void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
388 mySelector = createSelector(theMgr);
389 myWorkshop->selectionActivate()->updateSelectionFilters();
390 myWorkshop->selectionActivate()->updateSelectionModes();
391 myWorkshop->synchronizeViewer();
395 //******************************************************
396 void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr)
399 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
400 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
401 if (mySelector->viewer() == aViewer) {
402 XGUI_Displayer* aDisp = myWorkshop->displayer();
403 QObjectPtrList aObjects = aDisp->displayedObjects();
404 foreach(ObjectPtr aObj, aObjects)
405 aObj->setDisplayed(false);
406 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
407 myProxyViewer->setSelector(0);
411 myWorkshop->module()->clearViewer();
417 //******************************************************
418 QtxPopupMgr* SHAPERGUI::popupMgr()
421 myPopupMgr = new QtxPopupMgr( 0, this );
425 //******************************************************
426 void SHAPERGUI::onDefaultPreferences()
428 // reset main resources
429 ModuleBase_Preferences::resetResourcePreferences(preferences());
430 // reset plugin's resources
431 ModuleBase_Preferences::resetConfigPropPreferences(preferences());
433 myWorkshop->displayer()->redisplayObjects();
436 //******************************************************
437 void SHAPERGUI::onScriptLoaded()
439 // this slot is called after processing of the LoadScriptId action of SalomeApp Application
440 // Each dumped script contains updateObjBrowser() that creates a new instance of Object
441 // Browser. When SHAPER module is active, this browser should not be used. It might be removed
442 // as hidden by means of updateWindows() of SalomeApp_Application or to remove
443 // it manually (because this method of application is protected)
444 SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
449 //******************************************************
450 void SHAPERGUI::onSaveDocByShaper()
452 if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
455 getApp()->onSaveDoc();
458 //******************************************************
459 void SHAPERGUI::onSaveAsDocByShaper()
461 if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
464 getApp()->onSaveAsDoc();
467 //******************************************************
468 void SHAPERGUI::onUpdateCommandStatus()
470 getApp()->updateActions();
473 //******************************************************
474 SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr)
476 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
477 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
478 SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
479 getApp()->selectionMgr());
480 #ifdef SALOME_PATCH_FOR_CTRL_WHEEL
481 aViewer->setUseLocalSelection(true);
483 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
484 QList<SUIT_Selector*> aList;
485 aMgr->selectors(aList);
486 foreach(SUIT_Selector* aSel, aList)
488 aSel->setEnabled(aSel == aSelector);
490 myProxyViewer->setSelector(aSelector);
496 //******************************************************
497 CAM_DataModel* SHAPERGUI::createDataModel()
499 return new SHAPERGUI_DataModel(this);
502 QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
503 const bool isAddSeparator)
505 return addFeature(theWBName,
509 //Issue #650: in the SALOME mode the tooltip should be same as text
518 //******************************************************
519 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBName,
520 const QString& theId, const QString& theTitle, const QString& theTip,
521 const QIcon& theIcon, const QKeySequence& theKeys,
522 bool isCheckable, const bool isAddSeparator,
523 const QString& theStatusTip)
525 static QString aLastTool = "";
527 if (aLastTool.isEmpty())
528 aLastTool = theWBName;
529 else if (theWBName != aLastTool) {
530 aLastTool = theWBName;
532 desktop()->addToolBarBreak();
538 int aId = myActionsList.size();
539 myActionsList.append(theId);
540 SUIT_Desktop* aDesk = application()->desktop();
542 for (int i = 0; i < theKeys.count(); i++)
544 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
546 aAction->setStatusTip(theStatusTip);
548 aAction->setData(theId);
550 int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
551 int aItemId = createMenu(aId, aWBMenu);
553 createMenu(separator(), aWBMenu);
555 int aWBTool = createTool(theTBName, theTBName);
556 int aToolId = createTool(aId, aWBTool);
558 createTool(separator(), aWBTool);
563 bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
565 return dynamic_cast<const SHAPERGUI_NestedButton*>(theAction);
568 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
569 const ActionInfo& theInfo,
570 const QList<QAction*>& theNestedActions)
572 myActionsList.append(theInfo.id);
573 SUIT_Desktop* aDesk = application()->desktop();
574 SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
575 anAction->setData(theInfo.id);
576 anAction->setCheckable(theInfo.checkable);
577 anAction->setChecked(theInfo.checked);
578 anAction->setEnabled(theInfo.enabled);
579 anAction->setVisible(theInfo.visible);
580 anAction->setIcon(theInfo.icon);
581 anAction->setText(theInfo.text);
582 anAction->setToolTip(theInfo.toolTip);
583 anAction->setShortcut(theInfo.shortcut);
584 anAction->setFont(theInfo.font);
586 int aWBMenu = createMenu(theWBName, -1, -1, 30);
587 int aItemId = createMenu(anAction, aWBMenu);
588 createMenu(separator(), aWBMenu); /// nested action is always separated of others
590 int aWBTool = createTool(theWBName, theWBName);
591 int aToolId = createTool(anAction, aWBTool);
592 createTool(separator(), aWBTool); /// nested action is always separated of others
598 //******************************************************
599 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
600 const QString& theTip, const QIcon& theIcon,
601 const QKeySequence& theKeys, bool isCheckable,
602 const char* theMenuSourceText, const int theMenuPosition)
604 int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
606 int aId = myActionsList.size();
607 myActionsList.append(theId);
608 SUIT_Desktop* aDesk = application()->desktop();
610 for (int i = 0; i < theKeys.count(); i++)
612 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
614 aAction->setStatusTip(theTip);
615 aAction->setData(theId);
616 createMenu(aId, aMenu, theMenuPosition);
620 //******************************************************
621 void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
623 int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
624 createMenu(separator(), aMenu, -1, theMenuPosition);
627 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
632 SUIT_Desktop* aDesktop = application()->desktop();
636 QtxActionToolMgr* aToolMgr = aDesktop->toolMgr();
640 aToolMgr->append( theAction, theToolBarTitle );
644 //******************************************************
645 QList<QAction*> SHAPERGUI::commandList() const
647 QList<QAction*> aActions;
648 for (int i = 0; i < myActionsList.size(); i++) {
649 QAction* aCmd = action(i);
650 if (aCmd && myActionsList.contains(aCmd->data().toString()))
651 aActions.append(aCmd);
657 //******************************************************
658 QMainWindow* SHAPERGUI::desktop() const
660 return application()->desktop();
663 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
664 const std::shared_ptr<Config_FeatureMessage>& theMessage)
666 myFeaturesInfo.insert(theFeatureId, theMessage);
669 std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
671 std::shared_ptr<Config_FeatureMessage> aMessage;
672 if (myFeaturesInfo.contains(theFeatureId))
673 aMessage = myFeaturesInfo[theFeatureId];
677 //******************************************************
678 void SHAPERGUI::selectionChanged()
680 LightApp_Module::selectionChanged();
681 myWorkshop->salomeViewerSelectionChanged();
684 //******************************************************
685 void SHAPERGUI::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
687 myWorkshop->contextMenuMgr()->updateViewerMenu();
688 myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
689 LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
693 //******************************************************
694 void SHAPERGUI::createPreferences()
696 LightApp_Preferences* pref = preferences();
699 ModuleBase_Preferences::updateConfigByResources();
700 QString aModName = moduleName();
702 QtxPreferenceItem* item = pref->findItem(aModName, true );
703 if ( item && (!item->isEmpty() )) {
704 item->parentItem()->removeItem(item);
708 int catId = pref->addPreference(aModName, -1 );
711 SHAPERGUI_PrefMgr aMgr(pref, aModName);
712 ModuleBase_Preferences::createEditContent(&aMgr, catId);
714 int viewTab = pref->addItem(tr("Viewer"), catId);
715 // Create other parameters group in viewer tab
716 int otherGroup = pref->addItem(tr("Default selection"), viewTab);
717 pref->setItemProperty("columns", 3, otherGroup);
718 pref->addItem(tr("Faces"), otherGroup,
719 SUIT_PreferenceMgr::Bool,
720 ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
721 pref->addItem(tr("Edges"), otherGroup,
722 SUIT_PreferenceMgr::Bool,
723 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
724 pref->addItem(tr("Vertices"), otherGroup,
725 SUIT_PreferenceMgr::Bool,
726 ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
728 int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
729 pref->setItemProperty("columns", 2, sensitivityGroup);
730 pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
731 ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
732 pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
733 ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
737 //******************************************************
738 void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& theParam)
740 SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
741 QString aVal = aResMgr->stringValue(theSection, theParam);
742 Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
743 theParam.toStdString());
744 std::string aValue = aVal.toStdString();
745 if (aValue.empty()) {
746 aValue = aProp->defaultValue();
747 aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
749 LightApp_Preferences* pref = preferences();
753 aProp->setValue(aValue);
755 myWorkshop->displayer()->redisplayObjects();
758 void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
760 application()->putInfo(theInfo, theMSecs);
763 bool SHAPERGUI::abortAllOperations()
765 return workshop()->operationMgr()->abortAllOperations();
768 void SHAPERGUI::createFeatureActions()
770 myWorkshop->menuMgr()->createFeatureActions();
773 void SHAPERGUI::onWhatIs(bool isToggled)
775 if (sender() == myWhatIsAction) {
776 QAction* aViewAct = myInspectionPanel->toggleViewAction();
777 aViewAct->blockSignals(true);
778 aViewAct->setChecked(isToggled);
779 aViewAct->blockSignals(false);
780 myInspectionPanel->setVisible(isToggled);
783 myWhatIsAction->blockSignals(true);
784 myWhatIsAction->setChecked(isToggled);
785 myWhatIsAction->blockSignals(false);
786 myInspectionPanel->setVisible(isToggled);
790 void SHAPERGUI::updateModuleVisibilityState()
792 LightApp_Module::updateModuleVisibilityState();
793 onWhatIs(myIsInspectionVisible);