]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Sketch->circle creation, move to PP, input valid value, Enter ->nothing is visualized.
authornds <nds@opencascade.com>
Fri, 30 Oct 2015 15:27:08 +0000 (18:27 +0300)
committernds <nds@opencascade.com>
Fri, 30 Oct 2015 15:27:08 +0000 (18:27 +0300)
14 files changed:
src/ModuleBase/ModuleBase_DoubleSpinBox.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 94387b2eca027b7ad9b197b2694d13a0121ab9c0..114a27d6ca8f12a539ead1b8250152a8c2141512 100644 (file)
@@ -219,9 +219,9 @@ void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent)
 
 bool ModuleBase_DoubleSpinBox::focusNextPrevChild(bool theIsNext)
 {
-  myIsModified = false;
+  //myIsModified = false;
 
-  emit valueStored();
+  //emit valueStored();
   emit focusNextPrev();
   return QDoubleSpinBox::focusNextPrevChild(theIsNext);
 }
index 859b43fa6b6a441529c004fc12e729a15a37db52..3219da1fb3cd9bb3d517efe3d2194e51121f4a63 100644 (file)
@@ -193,6 +193,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param isToConnect a boolean value whether connect or disconnect\r
   virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {};\r
 \r
+  /// Validates the operation to change the "Apply" button state.\r
+  /// \param thePreviousState the previous state of the widget\r
+  virtual void widgetStateChanged(int thePreviousState) {};\r
+\r
 signals:\r
   /// Signal which is emitted when operation is launched\r
   void operationLaunched();\r
index db4a41f66e0d912ac4d8098d3af523f1cbb380b5..f0d33055320a9a9d21ef2fd36029e063aa75a5e1 100644 (file)
@@ -187,12 +187,12 @@ bool ModuleBase_ModelWidget::storeValue()
   return isDone;
 }
 
-ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ValueState& theState)
+ModuleBase_ModelWidget::ValueState ModuleBase_ModelWidget::setValueState(const ModuleBase_ModelWidget::ValueState& theState)
 {
   ValueState aState = myState;
   if (myState != theState && !myIsValueStateBlocked) {
     myState = theState;
-    emit valueStateChanged();
+    emit valueStateChanged(aState);
   }
   return aState;
 }
@@ -213,14 +213,6 @@ bool ModuleBase_ModelWidget::restoreValue()
   return isDone;
 }
 
-void ModuleBase_ModelWidget::storeValueByApply()
-{
-  // do not emit signal about update the currenty feature object
-  // in order to do not perform additional redisplay in the viewer.
-  // It should happens by finish operation of the apply action
-  storeValueCustom();
-}
-
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj)
 {
   blockUpdateViewer(true);
@@ -259,6 +251,17 @@ bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
       emit focusInWidget(this);
     }
   }
+  else if (theEvent->type() == QEvent::FocusOut) {
+    QFocusEvent* aFocusEvent = dynamic_cast<QFocusEvent*>(theEvent);
+
+    Qt::FocusReason aReason = aFocusEvent->reason();
+    bool aMouseOrKey = aReason == Qt::MouseFocusReason ||
+                        aReason == Qt::TabFocusReason ||
+                        aReason == Qt::BacktabFocusReason ||
+                        aReason == Qt::OtherFocusReason; // to process widget->setFocus()
+    if (aMouseOrKey && getControls().contains(aWidget) && getValueState() == ModifiedInPP)
+      storeValue();
+  }
   // pass the event on to the parent class
 
   return QObject::eventFilter(theObject, theEvent);
index f855496739a7a8efa6219502ffd84e56e6d2a2af..0942fcce77549ef74a33e33570da3ea53f7ec503 100644 (file)
@@ -102,10 +102,6 @@ Q_OBJECT
   /// \return True in success
   bool restoreValue();
 
-  /// Saves the internal parameters to the given feature. Emits signals before and after store
-  /// \return True in success
-  void storeValueByApply();
-
   /// Set focus to the first control of the current widget. The focus policy of the control is checked.
   /// If the widget has the NonFocus focus policy, it is skipped.
   /// \return the state whether the widget can accept the focus
@@ -206,7 +202,7 @@ signals:
   void focusOutWidget(ModuleBase_ModelWidget* theWidget);
 
   /// The signal about value state modification
-  void valueStateChanged();
+  void valueStateChanged(int theState);
 
   void focusNextPrev();
   void valueStored();
index 81c53126dcc5ccfe35c5d631593755e12ce6497e..734edb19b7fa94292c0db06de32946ae0565f564 100755 (executable)
@@ -268,8 +268,6 @@ bool ModuleBase_OperationFeature::commit()
     ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
     if (aPropertyPanel) {
       ModuleBase_ModelWidget* aWidget = aPropertyPanel->activeWidget();
-      if (aWidget)
-        aWidget->storeValueByApply();
       aPropertyPanel->cleanContent();
     }
     SessionPtr aMgr = ModelAPI_Session::get();
index 3e040c4d39e6a7a32c9df3ab58c697c141cb3300..624e047441564ae8cd918e649806cea5c2c8521a 100644 (file)
@@ -214,8 +214,8 @@ void ExpressionEditor::paintEvent( QPaintEvent* theEvent )
 
 bool ExpressionEditor::focusNextPrevChild(bool theIsNext)
 {
-  emit valueStored();
-  emit focusNextPrev();
+  //emit valueStored();
+  //emit focusNextPrev();
   return QPlainTextEdit::focusNextPrevChild(theIsNext);
 }
 
@@ -248,8 +248,8 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
   this->setLayout(aMainLay);
 
   connect(myEditor, SIGNAL(valueModified()), this, SIGNAL(valuesModified()));
-  connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged()));
-  connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
+  //connect(myEditor, SIGNAL(valueStored()), this, SLOT(onTextChanged()));
+  //connect(myEditor, SIGNAL(focusNextPrev()), this, SIGNAL(focusNextPrev()));
 
   connect(myEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
     /// The signal about key release on the control, that corresponds to the attribute
index 67d6453d64807eaf2d2cf00ce4eacc52b7dfb337..0e81242bb98b6859c1f0197bc1d71b1f3f984a41 100644 (file)
@@ -66,8 +66,8 @@ class ExpressionEditor: public QPlainTextEdit
 signals:
   void valueModified();
   /// A signal that is emitted by the "Tab" key event. It is emitted before the key is processed.
-  void valueStored();
-  void focusNextPrev();
+  //void valueStored();
+  //void focusNextPrev();
 
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
index 100b7ea3ef5fa4c75fb0ad5676faf04f39c09929..3b19b6b2e3820c4e7ad6aef9d7d63ccc475ca605 100755 (executable)
@@ -1067,3 +1067,9 @@ void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
     }
   }
 }
+
+//******************************************************
+void PartSet_Module::widgetStateChanged(int thePreviousState)
+{
+  mySketchMgr->widgetStateChanged(thePreviousState);
+}
index 79445f445da0913b4e189b083de1ec1a849bb26a..2a5cb017f7a994b6d416fac7e62a45abd350ceea 100644 (file)
@@ -200,6 +200,10 @@ public:
   //! \return string value
   virtual QString getFeatureError(const FeaturePtr& theFeature);
 
+  /// Validates the current operation and send the state change to sketch manager
+  /// \thePrevState the previous widget value state
+  virtual void widgetStateChanged(int thePreviousState);
+
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
@@ -244,7 +248,7 @@ protected slots:
   /// A slot called on view window creation
   void onViewCreated(ModuleBase_IViewWindow*);
 
- protected:
+protected:
   /// Register validators for this module
   virtual void registerValidators();
 
index 167fad75943ce7978e04d5d2b5f3560b8b6e6228..ac623b3c993c7ff1b59f69daab0650f00848fed8 100644 (file)
@@ -296,22 +296,6 @@ void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
   aDisplayer->updateViewer();
 }
 
-void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
-{
-  if (!isNestedCreateOperation(getCurrentOperation()))
-    return;
-
-  operationMgr()->onValidateOperation();
-  // the feature is to be erased here, but it is correct to call canDisplayObject because
-  // there can be additional check (e.g. editor widget in distance constraint)
-  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                           (getCurrentOperation());
-  if (aFOperation) {
-    FeaturePtr aFeature = aFOperation->feature();
-    visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
-  }
-}
-
 void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   get2dPoint(theWnd, theEvent, myClickedPoint);
@@ -1193,19 +1177,31 @@ void PartSet_SketcherMgr::connectToPropertyPanel(ModuleBase_ModelWidget* theWidg
   if (isToConnect) {
     connect(theWidget, SIGNAL(beforeValuesChanged()),
             this, SLOT(onBeforeValuesChangedInPropertyPanel()));
-    connect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
     connect(theWidget, SIGNAL(afterValuesChanged()),
             this, SLOT(onAfterValuesChangedInPropertyPanel()));
   }
   else {
     disconnect(theWidget, SIGNAL(beforeValuesChanged()),
                 this, SLOT(onBeforeValuesChangedInPropertyPanel()));
-    disconnect(theWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
     disconnect(theWidget, SIGNAL(afterValuesChanged()),
                 this, SLOT(onAfterValuesChangedInPropertyPanel()));
   }
 }
 
+void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
+{
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                           (getCurrentOperation());
+  if (aFOperation) {
+    if (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
+        PartSet_SketcherMgr::isNestedSketchOperation(aFOperation) &&
+        thePreviousState == ModuleBase_ModelWidget::ModifiedInPP) {
+      FeaturePtr aFeature = aFOperation->feature();
+      visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
+    }
+  }
+}
+
 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
 {
   return myModule->workshop()->currentOperation();
index 66666c1901228ae5da9b2f47ada0f004945522b0..b82f5a87156f5f4a3093680db93bffc240d4c2a9 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <ModuleBase_ViewerFilters.h>
 #include <ModuleBase_Definitions.h>
+#include <ModuleBase_ModelWidget.h>
 
 #include <GeomAPI_Pln.h>
 #include <SelectMgr_IndexedMapOfOwner.hxx>
@@ -196,6 +197,10 @@ public:
   /// \param isToConnect a boolean value whether connect or disconnect
   void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect);
 
+  /// Visualize the operation feature if the previous state is modified value in property panel
+  /// \thePrevState the previous widget value state
+  void widgetStateChanged(int thePreviousState);
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
@@ -212,8 +217,6 @@ private slots:
   void onLeaveViewPort();
   /// Listens to the value changed signal and display the current operation feature
   void onBeforeValuesChangedInPropertyPanel();
-  /// Listens to the signal about values are to be changed in the property panel
-  void onValuesChangedInPropertyPanel();
   /// Listens to the signal about the modification of the values have been done in the property panel
   void onAfterValuesChangedInPropertyPanel();
 
@@ -288,6 +291,7 @@ private:
   /// \param isToDisplay a flag about the display or erase the feature
   void visualizeFeature(const FeaturePtr& theFeature, const bool isEditOperation,
                         const bool isToDisplay, const bool isFlushRedisplay = true);
+
 private:
   XGUI_OperationMgr* operationMgr() const;
 
index 5a4dda830e05ee01dd39ce0643a46fec35611c8a..e75b441305deb9d9f7817d48cf0014c421cc4f92 100644 (file)
@@ -116,8 +116,8 @@ 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(focusNextPrev()),
-            this, SLOT(onFocusNextPrev()));
+    //connect(aWidget, SIGNAL(focusNextPrev()),
+    //        this, SLOT(onFocusNextPrev()));
   }
 }
 
index c09f7d58414d77ce39e6758901969b1c67eb527c..61d6b5021707ff7d7fefaa5eb32bdff27baa6452 100644 (file)
@@ -612,10 +612,10 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
     foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
        myModule->connectToPropertyPanel(aWidget, isToConnect);
       if (isToConnect) {
-        connect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged()));
+        connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
       }
       else {
-        disconnect(aWidget, SIGNAL(valueStateChanged()), this, SLOT(onValueStateChanged()));
+        disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
       }
     }
   }
@@ -856,7 +856,7 @@ void XGUI_Workshop::onPreferences()
 }
 
 //******************************************************
-void XGUI_Workshop::onValueStateChanged()
+void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
 {
   ModuleBase_ModelWidget* anActiveWidget = 0;
   ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
@@ -867,6 +867,8 @@ void XGUI_Workshop::onValueStateChanged()
   }
   if (anActiveWidget)
     operationMgr()->onValidateOperation();
+
+  myModule->widgetStateChanged(thePreviousState);
 }
 
 //******************************************************
index 6a72b02d5821db8c79f2780cac28df4cbdf40aa6..281a61f9f8f0a238c4dd5f09b1b0d1436e06445f 100644 (file)
@@ -304,8 +304,9 @@ signals:
   /// Rebuild data tree
   void onRebuild();
 
-  /// Validates the operation. Apply button is disabled if the widget value is in Modified state
-  void onValueStateChanged();
+  /// Validates the operation to change the "Apply" button state.
+  /// \param thePreviousState the previous state of the widget
+  void onWidgetStateChanged(int thePreviousState);
 
   /// Open preferences dialog box
   void onPreferences();