]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SALOME mode correction for dimension constraints editor.
authornds <nds@opencascade.com>
Wed, 18 Nov 2015 12:01:38 +0000 (15:01 +0300)
committernds <nds@opencascade.com>
Wed, 18 Nov 2015 12:01:38 +0000 (15:01 +0300)
1. The enter is processed by enterClicked() only because operation manager do not receive this signal in SALOME mode
2. Sketcher Renetrant manager should not restart internal edit and create new feature if it is started.

src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/ModuleBase/ModuleBase_WidgetEditor.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index 3a2f19961939c97e78a9c8d0b559230cee0e0dfb..25ccc5aa1abcf8d967e09a4791cef9d9fcc22969 100644 (file)
@@ -200,6 +200,9 @@ signals:
   /// \param theEvent key release event
   void keyReleased(QKeyEvent* theEvent);
 
+  /// The signal is emitted if the enter is clicked in the control of the widget
+  void enterClicked();
+
   /// The signal about the widget is get focus
   /// \param theWidget the model base widget
   void focusInWidget(ModuleBase_ModelWidget* theWidget);
index 87bb57ff1e23e5fb23737b7d5f76eb9f8810493c..20e83607242da69c1ed71c729f31b6bf67318fbd 100644 (file)
@@ -35,7 +35,8 @@
 ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
                                                  const Config_WidgetAPI* theData,
                                                  const std::string& theParentId)
-    : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
+: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId),
+  myIsKeyReleasedEmitted(false)
 {
 }
 
@@ -52,7 +53,7 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
   ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
   anEditor->enableKeyPressEvent(true);
   if (!myIsEditing) {
-    connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+    connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
   }
 
   anEditor->setMinimum(0);
@@ -72,7 +73,7 @@ void ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
   aDlg.exec();
 
   if (!myIsEditing) {
-    disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+    disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
   }
 
   outText = anEditor->text();
@@ -99,6 +100,8 @@ bool ModuleBase_WidgetEditor::focusTo()
 
 void ModuleBase_WidgetEditor::showPopupEditor()
 {
+  myIsKeyReleasedEmitted = false;
+
   // we need to emit the focus in event manually in order to save the widget as an active
   // in the property panel before the mouse leave event happens in the viewer. The module
   // ask an active widget and change the feature visualization if the widget is not the current one.
@@ -122,4 +125,12 @@ void ModuleBase_WidgetEditor::showPopupEditor()
   // the focus leaves the control automatically by the Enter/Esc event
   // it is processed in operation manager
   //emit focusOutWidget(this);
+
+  if (myIsKeyReleasedEmitted)
+    emit enterClicked();
+}
+
+void ModuleBase_WidgetEditor::onKeyReleased(QKeyEvent* theEvent)
+{
+  myIsKeyReleasedEmitted = true;
 }
index 5f26a60cc1dae3b96841998102e6933eb81b719e..8f494b366decf324104319c0fbc82f85658b219c 100644 (file)
@@ -46,6 +46,9 @@ Q_OBJECT
    /// Shous popup window under cursor for data editing
    void showPopupEditor();
 
+protected slots:
+  void onKeyReleased(QKeyEvent* theEvent);
+
 private:
    void editedValue(double& outValue, QString& outText);
 
@@ -55,6 +58,8 @@ private:
 
    ///< the kinds of possible features
    QStringList myFeatureKinds;  
+
+   bool myIsKeyReleasedEmitted;
 };
 
 #endif
index 63fa9c9b131af0966aeaa8da374d802bc5d65b8c..5e45abfee7253fc32f55e81d05e6249d43b70d1c 100755 (executable)
@@ -274,6 +274,12 @@ bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
 bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID)
 {
   bool isDone = false;
+  /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter
+  /// event comes two times, so we should not start another internal edit operation
+  /// the Apply button becomes disabled becase the second additional internal feature is created
+  if (myIsInternalEditOperation)
+    return true;
+
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                      (myWorkshop->currentOperation());
 
index d441258e806a1f7e0a7bea31c2c309d129dca3c6..5d89fcab12801482af4688fbfb3b834f38e40623 100644 (file)
@@ -546,7 +546,8 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
   switch (theEvent->key()) {
     case Qt::Key_Return:
     case Qt::Key_Enter: {
-      ModuleBase_Operation* aOperation = currentOperation();
+      isAccepted = onProcessEnter();
+      /*ModuleBase_Operation* aOperation = currentOperation();
       ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
       ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
       if (!aActiveWgt || !aActiveWgt->processEnter()) {
@@ -559,7 +560,7 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
           else
             isAccepted = false;
         }
-      }
+      }*/
     }
     break;
     case Qt::Key_N:
@@ -589,6 +590,26 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
   return isAccepted;
 }
 
+bool XGUI_OperationMgr::onProcessEnter()
+{
+  bool isAccepted = true;
+  ModuleBase_Operation* aOperation = currentOperation();
+  ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+  ModuleBase_ModelWidget* aActiveWgt = aPanel->activeWidget();
+  if (!aActiveWgt || !aActiveWgt->processEnter()) {
+    if (!myWorkshop->module()->processEnter(aActiveWgt ? aActiveWgt->attributeID() : "")) {
+      ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
+      if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
+        emit keyEnterReleased();
+        commitOperation();
+      }
+      else
+        isAccepted = false;
+    }
+  }
+  return isAccepted;
+}
+
 XGUI_Workshop* XGUI_OperationMgr::workshop() const
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
index 0cda5543cac21bd86caa7adc9ea582a2ee03585a..d6172b8946225cd29f414203d68ac9b4dd266ca0 100755 (executable)
@@ -176,6 +176,11 @@ protected: // TEMPORARY
   /// \param theEvent the mouse event
   bool onKeyReleased(QKeyEvent* theEvent);
 
+  /// The functionaly, that should be done by enter click
+  /// Fistly the active widget processes it, then module. If no one do not
+  /// process it, the current operation is committed
+  bool onProcessEnter();
+
   protected slots:
   /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
   /// If there is a suspended operation, restart it.
index 57f55e9d9c7a1becebae3622b9248a86c3768726..c91596ec1cf14702b339cad8ff32e52b0aa080fe 100755 (executable)
@@ -121,6 +121,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
             this,    SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
             this,    SIGNAL(keyReleased(QKeyEvent*)));
+    connect(aWidget, SIGNAL(enterClicked()),
+            this,    SIGNAL(enterClicked()));
+
   }
 }
 
index 2d2b8e29ca59a749c29c8bd07fb656bd24c421b0..a40ff085b2ca961b14718c56c870afba7a61adef 100644 (file)
@@ -119,6 +119,9 @@ public slots:
   */
   virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
 
+signals:
+  void enterClicked();
+
 protected:
   /// Makes the widget active, deactivate the previous, activate and hightlight the given one
   /// \param theWidget a widget
index da722f6dfce93efe92542d9d8e098c82c1c85cfa..3e1eff31c320ec4fdf51f7022522796bb920e683 100755 (executable)
@@ -1048,6 +1048,9 @@ void XGUI_Workshop::createDockWidgets()
   connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation()));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)),
           myOperationMgr,  SLOT(onKeyReleased(QKeyEvent*)));
+
+  connect(myPropertyPanel, SIGNAL(enterClicked()),
+          myOperationMgr,  SLOT(onProcessEnter()));
   //connect(myOperationMgr,  SIGNAL(validationStateChanged(bool)),
   //        this, SLOT(onValidationStateChanged(bool)));
 }