]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #145 behavior on edit constraint corrected
authorsbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 11:38:17 +0000 (15:38 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 19 Sep 2014 11:38:17 +0000 (15:38 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_Command.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp

index 211bc89cc2eb2f3c32eb8095375238d6d1b78a35..082c8cfa777ae913e113f45068a181ee2a545e61 100644 (file)
@@ -127,11 +127,6 @@ void PartSet_Module::featureCreated(QAction* theFeature)
   connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
 }
 
-QStringList PartSet_Module::nestedFeatures(QString)
-{
-  return QStringList();
-}
-
 std::string PartSet_Module::featureFile(const std::string& theFeatureId)
 {
   return myFeaturesInFiles[theFeatureId];
index 39ee6a763a40fc68d16900c91a1ed8b3e1c5da82..803015f38786d38701b1e26281598b8d4c960464 100644 (file)
@@ -41,8 +41,6 @@ Q_OBJECT
   /// Called on creation of menu item in desktop
   virtual void featureCreated(QAction* theFeature);
 
-  /// Returnc list of nested commands for the given feature
-  virtual QStringList nestedFeatures(QString theFeature);
   std::string featureFile(const std::string&);
 
   /// Creates an operation and send it to loop
index 294faab4b38f988fedeb4c52bd4618e9fadb2999..165d0457ece943c650770e30952c222a4eed4288 100644 (file)
@@ -61,7 +61,8 @@ void XGUI_ActionsMgr::update()
   if (myOperationMgr->hasOperation()) {
     setAllEnabled(false);
     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-    QString anOperationId = anOperation->id();
+    FeaturePtr aFeature = anOperation->feature();
+    QString anOperationId = QString::fromStdString(aFeature->getKind()); //anOperation->id();
     setActionEnabled(anOperationId, true);
     bool isNestedEnabled = anOperation->isNestedOperationsEnabled();
     setNestedCommandsEnabled(isNestedEnabled, anOperationId);
@@ -85,15 +86,13 @@ void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& t
 {
   QStringList ltNestedActions;
   if (theParent.isEmpty()) {  //Disable ALL nested
-    foreach(QString eachParent, myNestedActions.keys())
-    {
+    foreach(QString eachParent, myNestedActions.keys()) {
       ltNestedActions << myNestedActions[eachParent];
     }
   } else {
     ltNestedActions << myNestedActions[theParent];
   }
-  foreach(QString eachNested, ltNestedActions)
-  {
+  foreach(QString eachNested, ltNestedActions) {
     setActionEnabled(eachNested, theEnabled);
   }
 }
@@ -117,13 +116,11 @@ void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabl
 void XGUI_ActionsMgr::updateCheckState()
 {
   QString eachCommand = QString();
-  foreach(eachCommand, myActions.keys())
-  {
+  foreach(eachCommand, myActions.keys()) {
     setActionChecked(eachCommand, false);
   }
   QStringList ltActiveCommands = myOperationMgr->operationList();
-  foreach(eachCommand, ltActiveCommands)
-  {
+  foreach(eachCommand, ltActiveCommands) {
     setActionChecked(eachCommand, true);
   }
 }
index 59df312b1e3338caf61be7232afe89797af4c5da..07d0d310f8add811d55e7c3446d1f41b1423416e 100644 (file)
@@ -1,6 +1,8 @@
 #include "XGUI_Command.h"
 #include <QEvent>
 #include <QToolButton>
+#include <QVariant>
+#include <QDebug>
 
 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
     : QWidgetAction(parent),
@@ -65,4 +67,4 @@ const QStringList& XGUI_Command::nestedCommands() const
 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
 {
   this->myNestedCommands = myUnblockableCommands;
-}
+}
\ No newline at end of file
index b8e43d7ea0ac8d07bd6a8b61f81869643fc0485a..edb72cdb7c6ad7f5c96626483e0a7981d0148979 100644 (file)
@@ -41,9 +41,11 @@ int XGUI_OperationMgr::operationsCount() const
 QStringList XGUI_OperationMgr::operationList()
 {
   QStringList result;
-  foreach(ModuleBase_Operation* eachOperation, myOperations)
-  {
-    result << eachOperation->id();
+  foreach(ModuleBase_Operation* eachOperation, myOperations) {
+    FeaturePtr aFeature = eachOperation->feature();
+    if(aFeature) {
+      result << QString::fromStdString(aFeature->getKind());
+    }
   }
   return result;
 }
@@ -80,7 +82,9 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
 
 bool XGUI_OperationMgr::abortAllOperations()
 {
-  if (operationsCount() == 1) {
+  if(!hasOperation()) {
+    return true;
+  } else if (operationsCount() == 1) {
     onAbortOperation();
     return true;
   }
@@ -215,9 +219,6 @@ void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
 {
   // Let the manager decide what to do with the given key combination.
   ModuleBase_Operation* anOperation = currentOperation();
-  if(anOperation) {
-    anOperation->activateNextToCurrentWidget();
-  }
   bool isRestart = false;
   switch (theEvent->key()) {
     case Qt::Key_Escape: {
@@ -226,6 +227,9 @@ void XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
       break;
     case Qt::Key_Return:
     case Qt::Key_Enter: {
+      if(anOperation) {
+         anOperation->activateNextToCurrentWidget();
+      }
       commitOperation();
     }
       break;
index 69408d05c209cb849dc4ff1310c6551a5f79e697..dd3cc642da41886a793674850d7f4a41948837c4 100644 (file)
@@ -110,7 +110,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
       setTabOrder(anOkBtn, aCancelBtn);
     }
   }
-  onActivateNextWidget(NULL);
 }
 
 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
index f3c19f8b36a4e4db55e216769e36f14da068619e..4046ede8fb2408032129fd9c32c6e073c031d126 100644 (file)
@@ -475,6 +475,7 @@ void XGUI_Workshop::onOperationStarted()
     }
 
     myPropertyPanel->setModelWidgets(aWidgets);
+    myPropertyPanel->onActivateNextWidget(NULL);
     myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
   }
   updateCommandStatus();
@@ -574,11 +575,14 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
     aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
   } else {
     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
-    aCommand = aMenu->feature(theOperation->getDescription()->operationId());
+    FeaturePtr aFeature = theOperation->feature();
+    if(aFeature)
+      aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
   }
   //Abort operation on uncheck the command
-  if (aCommand)
+  if (aCommand) {
     connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
+  }
 }
 
 /*
@@ -858,8 +862,7 @@ void XGUI_Workshop::updateCommandStatus()
   if (aMgr->hasModuleDocument()) {
     QAction* aUndoCmd;
     QAction* aRedoCmd;
-    foreach(QAction* aCmd, aCommands)
-    {
+    foreach(QAction* aCmd, aCommands) {
       QString aId = aCmd->data().toString();
       if (aId == "UNDO_CMD")
         aUndoCmd = aCmd;
@@ -872,8 +875,7 @@ void XGUI_Workshop::updateCommandStatus()
     aUndoCmd->setEnabled(aMgr->canUndo());
     aRedoCmd->setEnabled(aMgr->canRedo());
   } else {
-    foreach(QAction* aCmd, aCommands)
-    {
+    foreach(QAction* aCmd, aCommands) {
       QString aId = aCmd->data().toString();
       if (aId == "NEW_CMD")
         aCmd->setEnabled(true);
@@ -1147,16 +1149,27 @@ void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
 //**************************************************************
 void XGUI_Workshop::updateCommandsOnViewSelection()
 {
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   XGUI_Selection* aSelection = mySelector->selection();
   if (aSelection->getSelected().size() == 0)
     return;
 
+  // Restrict validators to manage only nested (child) features
+  // of the current feature i.e. if current feature is Sketch -
+  // Sketch Features & Constraints can be validated.
+  QStringList aNestedIds;
+  if(myOperationMgr->hasOperation()) {
+    FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
+    if(aFeature) {
+      aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
+    }
+  }
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   QList<QAction*> aActions = getModuleCommands();
-  foreach(QAction* aAction, aActions)
-  {
+  foreach(QAction* aAction, aActions) {
     QString aId = aAction->data().toString();
+    if(!aNestedIds.contains(aId))
+      continue;
     std::list<ModelAPI_Validator*> aValidators;
     std::list<std::list<std::string> > anArguments;
     aFactory->validators(aId.toStdString(), aValidators, anArguments);