]> 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>
Mon, 2 Nov 2015 09:56:31 +0000 (12:56 +0300)
13 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_WidgetExprEditor.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h [changed mode: 0644->0755]
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 ed5ad0456ccfdb95215d5d0ef3bb7de62424e239..f4d547d43c92c91d7afbc527be8fa16ee6874849 100755 (executable)
@@ -196,6 +196,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 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 c7623e38759471da3d208178c2194dcb5d07679b..4dba405532d0d5c7bf0f1585eb2af4c75bc72517 100755 (executable)
@@ -1104,3 +1104,9 @@ void PartSet_Module::onViewCreated(ModuleBase_IViewWindow*)
     }
   }
 }
+
+//******************************************************
+void PartSet_Module::widgetStateChanged(int thePreviousState)
+{
+  mySketchMgr->widgetStateChanged(thePreviousState);
+}
old mode 100644 (file)
new mode 100755 (executable)
index 0624152..f879712
@@ -203,6 +203,10 @@ public:
   /// Returns list of granted operation indices
   virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
 
+  /// 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
@@ -247,7 +251,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 03d2cb29865f33adaa6cc572f731e14499a0d09a..97a5ce43c6021061ca2056f1d946d84429254494 100755 (executable)
@@ -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);
@@ -1200,19 +1184,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 3ea2f1fbf1069379fb852afca7cd52ff0f099890..577f9601d8a6006557fc23d42003e67a9f324566 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 b5749c7ae7bb46a5560fe6c9afa5f53b962cea1d..097d9145d8dd7679b6aa59e3b3f6d9eb09a6b26a 100755 (executable)
@@ -118,8 +118,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()));
   }
 }
 
@@ -331,4 +331,4 @@ void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
       theEvent->ignore();
   } else
     ModuleBase_IPropertyPanel::closeEvent(theEvent);
-}
\ No newline at end of file
+}
index ceb3f817d69fffa9f8bb3253088c05ee4f5629d3..cb519a9692fc5f39b590fd708b77aa152ff1f485 100755 (executable)
@@ -617,10 +617,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)));
       }
     }
   }
@@ -865,7 +865,7 @@ void XGUI_Workshop::onRebuild()
 }
 
 //******************************************************
-void XGUI_Workshop::onValueStateChanged()
+void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
 {
   ModuleBase_ModelWidget* anActiveWidget = 0;
   ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
@@ -876,6 +876,8 @@ void XGUI_Workshop::onValueStateChanged()
   }
   if (anActiveWidget)
     operationMgr()->onValidateOperation();
+
+  myModule->widgetStateChanged(thePreviousState);
 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 {
   QString libName = QString::fromStdString(library(theModule.toStdString()));
index 25a71105fdf0f5cd8d35fb85545fa68d96403eca..5aa9e7802f64b58ae1de8f4a26e866e5f887b688 100755 (executable)
@@ -299,8 +299,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);
 
   /// Show property panel
   void showPropertyPanel();