Salome HOME
Issue #1664 In the Sketcher, add the function Split a segment - correction for arc...
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index ef44ec327d7d42b5ee8ccc38b71e84e78493bbd7..9210b66ee468227f1b6194d210345e739a299bbf 100644 (file)
@@ -12,6 +12,7 @@
 #include <XGUI_ObjectsBrowser.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_Displayer.h>
+#include <XGUI_MenuMgr.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Preferences.h>
@@ -373,22 +374,26 @@ CAM_DataModel* SHAPERGUI::createDataModel()
   return new SHAPERGUI_DataModel(this);
 }
 
-QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo)
+QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theInfo,
+                               const bool isAddSeparator)
 {
   return addFeature(theWBName,
                     theInfo.id,
                     theInfo.text,
-                    theInfo.toolTip,
+                    theInfo.text, //Issue #650: in the SALOME mode the tooltip should be same as text
                     theInfo.icon,
                     theInfo.shortcut,
-                    theInfo.checkable);
+                    theInfo.checkable,
+                    isAddSeparator,
+                    theInfo.toolTip);
 }
 
 //******************************************************
 QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
-                                    const QString& theTitle, const QString& theTip,
-                                    const QIcon& theIcon, const QKeySequence& theKeys,
-                                    bool isCheckable)
+                               const QString& theTitle, const QString& theTip,
+                               const QIcon& theIcon, const QKeySequence& theKeys,
+                               bool isCheckable, const bool isAddSeparator,
+                               const QString& theStatusTip)
 {
   static QString aLastTool = "";
   static int aNb = 0;
@@ -403,9 +408,6 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
   }
   aNb++;
 
-  int aMenu = createMenu(theWBName, -1, -1, 50);
-  int aTool = createTool(theWBName, theWBName);
-
   int aId = myActionsList.size();
   myActionsList.append(theId);
   SUIT_Desktop* aDesk = application()->desktop();
@@ -414,9 +416,19 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
     aKeys += theKeys[i];
   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
                                   isCheckable);
+  aAction->setStatusTip(theStatusTip);
+
   aAction->setData(theId);
-  int aItemId = createMenu(aId, aMenu, -1, 10);
-  int aToolId = createTool(aId, aTool);
+
+  int aWBMenu = createMenu(theWBName, -1, -1, 50/*10-Window, 1000 - Help*/);
+  int aItemId = createMenu(aId, aWBMenu);
+  if (isAddSeparator)
+    createMenu(separator(), aWBMenu);
+
+  int aWBTool = createTool(theWBName, theWBName);
+  int aToolId = createTool(aId, aWBTool);
+  if (isAddSeparator)
+    createTool(separator(), aWBTool);
 
   return aAction;
 }
@@ -427,13 +439,9 @@ bool SHAPERGUI::isFeatureOfNested(const QAction* theAction)
 }
 
 QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
-                                            const ActionInfo& theInfo,
-                                            const QList<QAction*>& theNestedActions)
+                                       const ActionInfo& theInfo,
+                                       const QList<QAction*>& theNestedActions)
 {
-  int aMenu = createMenu(theWBName, -1, -1, 50);
-  int aTool = createTool(theWBName, theWBName);
-
-  int aId = myActionsList.size();
   myActionsList.append(theInfo.id);
   SUIT_Desktop* aDesk = application()->desktop();
   SHAPERGUI_NestedButton* anAction = new SHAPERGUI_NestedButton(aDesk, theNestedActions);
@@ -448,8 +456,13 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
   anAction->setShortcut(theInfo.shortcut);
   anAction->setFont(theInfo.font);
 
-  //int aItemId = createMenu(aId, aMenu, -1, 10);
-  int aToolId = createTool(anAction, aTool, aId);
+  int aWBMenu = createMenu(theWBName, -1, -1, 50);
+  int aItemId = createMenu(anAction, aWBMenu);
+  createMenu(separator(), aWBMenu); /// nested action is always separated of others
+
+  int aWBTool = createTool(theWBName, theWBName);
+  int aToolId = createTool(anAction, aWBTool);
+  createTool(separator(), aWBTool); /// nested action is always separated of others
 
   return anAction;
 }
@@ -471,6 +484,7 @@ QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTi
     aKeys += theKeys[i];
   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
                                   isCheckable);
+  aAction->setStatusTip(theTip);
   aAction->setData(theId);
   createMenu(aId, aMenu, theMenuPosition);
   return aAction;
@@ -509,13 +523,8 @@ QList<QAction*> SHAPERGUI::commandList() const
     if (aCmd && myActionsList.contains(aCmd->data().toString()))
       aActions.append(aCmd);
   }
-  return aActions;
-}
 
-//******************************************************
-QStringList SHAPERGUI::commandIdList() const
-{
-  return myActionsList;
+  return aActions;
 }
 
 //******************************************************
@@ -524,34 +533,18 @@ QMainWindow* SHAPERGUI::desktop() const
   return application()->desktop();
 }
 
-//******************************************************
-QString SHAPERGUI::commandId(const QAction* theCmd) const
-{
-  int aId = actionId(theCmd);
-  if (aId < myActionsList.size())
-    return myActionsList[aId];
-  return QString();
-}
-
-//******************************************************
-QAction* SHAPERGUI::command(const QString& theId) const
-{
-  int aId = myActionsList.indexOf(theId);
-  if ((aId != -1) && (aId < myActionsList.size())) {
-    return action(aId);
-  }
-  return 0;
-}
-
 void SHAPERGUI::setFeatureInfo(const QString& theFeatureId,
                                const std::shared_ptr<Config_FeatureMessage>& theMessage)
 {
   myFeaturesInfo.insert(theFeatureId, theMessage);
 }
 
-const std::shared_ptr<Config_FeatureMessage>& SHAPERGUI::featureInfo(const QString& theFeatureId)
+std::shared_ptr<Config_FeatureMessage> SHAPERGUI::featureInfo(const QString& theFeatureId)
 {
-  return myFeaturesInfo.contains(theFeatureId) ? myFeaturesInfo[theFeatureId] : NULL;
+  std::shared_ptr<Config_FeatureMessage> aMessage;
+  if (myFeaturesInfo.contains(theFeatureId))
+    aMessage =  myFeaturesInfo[theFeatureId];
+  return aMessage;
 }
 
 //******************************************************
@@ -593,25 +586,24 @@ void SHAPERGUI::createPreferences()
 
   int viewTab = pref->addItem(tr("Viewer"), catId);
   // Create other parameters group in viewer tab
-  int otherGroup = pref->addItem(tr("Other parameters"), viewTab);
-  int selId = pref->addItem(tr("Default selection type"), otherGroup, 
-                                     SUIT_PreferenceMgr::Selector,
-                                     ModuleBase_Preferences::VIEWER_SECTION, "selection");
-  QStringList aSelectionList;
-  aSelectionList.append( tr("Vertices") );
-  aSelectionList.append( tr("Edges") );
-  aSelectionList.append( tr("Faces") );
-  aSelectionList.append( tr("Results") );
-
-  QList<QVariant> anIndexesList;
-  anIndexesList.append(TopAbs_VERTEX);
-  anIndexesList.append(TopAbs_EDGE);
-  anIndexesList.append(TopAbs_FACE);
-  anIndexesList.append(-1);
-
-  pref->setItemProperty( "strings", aSelectionList, selId );
-  pref->setItemProperty( "indexes", anIndexesList, selId );
+  int otherGroup = pref->addItem(tr("Default selection"), viewTab);
+  pref->setItemProperty("columns", 3, otherGroup);
+  pref->addItem(tr("Faces"), otherGroup, 
+                         SUIT_PreferenceMgr::Bool,
+                         ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
+  pref->addItem(tr("Edges"), otherGroup, 
+                         SUIT_PreferenceMgr::Bool,
+                         ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
+  pref->addItem(tr("Vertices"), otherGroup, 
+                         SUIT_PreferenceMgr::Bool,
+                         ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
   
+  int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
+  pref->setItemProperty("columns", 2, sensitivityGroup);
+  pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::Double,
+                ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
+  pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::Double,
+                ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
   pref->retrieve();
 }
 
@@ -635,6 +627,11 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the
   myWorkshop->displayer()->redisplayObjects();
 }
 
+void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
+{
+  application()->putInfo(theInfo, theMSecs);
+}
+
 void SHAPERGUI::inspectSalomeModules()
 {
   QStringList aModuleNames;
@@ -648,3 +645,8 @@ bool SHAPERGUI::abortAllOperations()
 {
   return workshop()->operationMgr()->abortAllOperations();
 }
+
+void SHAPERGUI::createFeatureActions()
+{
+  myWorkshop->menuMgr()->createFeatureActions();
+}