Salome HOME
Issue #394 Undo-ing a Sketch element
authornds <natalia.donis@opencascade.com>
Thu, 12 Feb 2015 12:02:27 +0000 (15:02 +0300)
committernds <natalia.donis@opencascade.com>
Thu, 12 Feb 2015 12:02:27 +0000 (15:02 +0300)
Using the valueChanged() signal of the model widget to update the sketch feature visibility on creation.

20 files changed:
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetChoice.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFileSelector.h
src/ModuleBase/ModuleBase_WidgetLabel.h
src/ModuleBase/ModuleBase_WidgetLineEdit.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/PartSet/PartSet_WidgetShapeSelector.h
src/PartSet/PartSet_WidgetSketchLabel.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 73a422d94a6a58a84b0d6cc42ff87202533f945c..f9e894085c34d2bc6c973178d6584be3ffbfebdc 100644 (file)
@@ -30,6 +30,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_
   myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty();
   myIsComputedDefault = false;
   myAttributeID = theData ? theData->widgetId() : "";
+
+  connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
 }
 
 bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
@@ -71,6 +73,13 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
   }
 }
 
+void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue)
+{
+  myFeature = theFeature;
+  if (theToStoreValue)
+    storeValue();
+}
+
 bool ModuleBase_ModelWidget::focusTo()
 {
   QList<QWidget*> aControls = getControls();
@@ -122,3 +131,9 @@ bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 
   return QObject::eventFilter(theObject, theEvent);
 }
+
+//**************************************************************
+void ModuleBase_ModelWidget::onWidgetValuesChanged()
+{
+  storeValue();
+}
index 87fcd1db749c2494f206f378505a80e7fb66f4cf..6a3e63894a6f429627cd907f80534c228fa390c6 100644 (file)
@@ -72,9 +72,6 @@ Q_OBJECT
     return false;
   }
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const = 0;
-
   /// Restore value from attribute data to the widget's control
   virtual bool restoreValue() = 0;
 
@@ -127,10 +124,8 @@ Q_OBJECT
   }
 
   /// Set feature which is processing by active operation
-  void setFeature(const FeaturePtr& theFeature)
-  {
-    myFeature = theFeature;
-  }
+  /// \param theToStoreValue a value about necessity to store the widget value to the feature
+  void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
 
   /// Editing mode depends on mode of current operation. This value is defined by it.
   void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
@@ -142,9 +137,6 @@ signals:
   /// The signal about widget values changed
   void valuesChanged();
 
-  /// The signal about widget values changed
-  void controlValuesChanged();
-
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
   void keyReleased(QKeyEvent* theEvent);
@@ -158,6 +150,10 @@ signals:
   void focusOutWidget(ModuleBase_ModelWidget* theWidget);
 
  protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const = 0;
+
   /// \brief Set the attribute name
   /// \param theAttribute the string value with attribute name
   void setAttributeID(const std::string& theAttribute)
@@ -176,6 +172,10 @@ signals:
   /// \param theObj is object for moving
   void moveObject(ObjectPtr theObj) const;
 
+protected slots:
+  /// Processing of values changed in model widget by store the current value to the feature
+  void onWidgetValuesChanged();
+
  protected:
 
   /// The attribute name of the model feature
index 37b15780d73760d05dccff2b9e064d807683dfe6..518d9a163698df418347103b689569e117be080d 100644 (file)
@@ -31,14 +31,17 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetBoolValue();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   virtual QList<QWidget*> getControls() const;
 
   QWidget* getControl() const;
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
  private:
    /// The check box
   QCheckBox* myCheckBox;
index 3f13cc4afdbfdea772f9190c4835bd14a12515c0..18fcb55bdadc55c6550681cd89f2685a5709afc7 100644 (file)
@@ -39,8 +39,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetChoice();
   
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   virtual bool focusTo();
@@ -56,6 +54,11 @@ Q_OBJECT
   /// \return a controls list
   virtual QList<QWidget*> getControls() const;
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
 private slots:
   /// Slot called on combo box index change
   void onCurrentIndexChanged(int theIndex);
index 6d17b4153dbb5bbeab749e80675a4eb708bcd218..6b1f52ed35d161e778ccf891a49872adacddc8fb 100644 (file)
@@ -94,7 +94,6 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
   aControlLay->setStretch(1, 1);
 
   connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
-  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
 }
 
 ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
index c9032e66a3943fd31541e0a1bc365ff59a004854..9c7804bf9f09850aabe79dea14dd659f8469831d 100644 (file)
@@ -37,10 +37,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetDoubleValue();
 
-  //! Saves the internal parameters to the given feature
-  // \return True in success
-  virtual bool storeValue() const;
-
   //! Read value of corresponded attribute from data model to the input control
   // \return True in success
   virtual bool restoreValue();
@@ -61,7 +57,12 @@ Q_OBJECT
  // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
 //  void onValueChanged();
 
- protected:
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+protected:
    /// Container for thw widget controls
   QWidget* myContainer;
 
index 3b183d7031a83f71c86059d3143d45d99fd09382..5a628286dde694aa8bc4a3dc1aefa176b95b366b 100644 (file)
@@ -46,8 +46,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW
                                 const std::string& theParentId);
   virtual ~ModuleBase_WidgetFileSelector();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   QWidget* getControl() const;
@@ -65,6 +63,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW
   /// Processing of path changing
   void onPathChanged();
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
  protected:
    /// Returns string containing formats
   QString formatsString() const;
index 8d7d4281f9e490cadf1808040be4ad266d3480c5..fd0112ff19b88c3b24a4ec8cd0d8e3a07daf0050 100644 (file)
@@ -33,11 +33,6 @@ Q_OBJECT
   /// It returns false because this is an info widget
   virtual bool canSetValue() const { return false; };
 
-  virtual bool storeValue() const
-  {
-    return true;
-  }
-
   virtual bool restoreValue()
   {
     return true;
@@ -50,6 +45,14 @@ Q_OBJECT
   /// This control doesn't accept focus
   virtual bool focusTo() { return false; }
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const
+  {
+    return true;
+  }
+
 private:
   /// A label control
   QLabel* myLabel;
index a5955f84c3ee86f606bccdd267f29c6d6bfd683d..657b22be05064ebbd4f867e7909c4d2aab363f60 100644 (file)
@@ -38,8 +38,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge
                                 const std::string& theParentId);
   virtual ~ModuleBase_WidgetLineEdit();
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   QWidget* getControl() const;
@@ -50,7 +48,12 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge
    /// A slot for processing text changed event
   void onTextChanged();
 
- private:
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+private:
    /// A line edit control
   QLineEdit* myLineEdit;
 
index 8d8c9e2c87bd0e71778bd3d9873ad9fbfec20853..3b092d424c0c7720e5a920743247ca4737e5c6c0 100644 (file)
@@ -62,9 +62,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model
                                  const std::string& theParentId);
   virtual ~ModuleBase_WidgetMultiSelector();
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
@@ -95,7 +92,11 @@ protected slots:
   void onListSelection();
 
  protected:
-   /// Provide filtering of selected shapes
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
+  /// Provide filtering of selected shapes
    /// \param theShapesToFilter source list of shapes
    /// \param theResult result list of shapes
   void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
index b4885d240a566e6c070aeb846f3bdee503c2dc8d..aa0c75f13f662a5c7ee5fdf01f9ee223a341f938 100644 (file)
@@ -71,9 +71,6 @@ Q_OBJECT
 
   virtual ~ModuleBase_WidgetShapeSelector();
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Defines if it is supposed that the widget should interact with the viewer.
@@ -116,6 +113,10 @@ Q_OBJECT
   void onSelectionChanged();
 
  protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index e1e18df38ca4d451e369bf84579e76e4278d637e..f3ccdf4f7d2dc0c570b1778f5f1d737252b2cfc4 100644 (file)
@@ -200,8 +200,7 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
 {
-  if (PartSet_SketcherMgr::isSketchOperation(theOperation) ||
-      PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+  if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->stopSketch(theOperation);
   }
   else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
index 70db7acc3661e2e2f71115d0ba899e48413c5ad1..d601d5a6f258baebc05fdcb4acb9d09198f525b3 100644 (file)
@@ -737,9 +737,9 @@ void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
     const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
     foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
       if (isToConnect)
-        connect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+        connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
       else
-        disconnect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+        disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
     }
   }
 }
index 34560cdc4713f53140e91604857c3568563658a2..ed4064004e2d96022409facd2a723067ae4972b0 100644 (file)
@@ -75,7 +75,6 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     aGroupLay->addWidget(myXSpin, 0, 1);
 
     connect(myXSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
-    connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
   }
   {
     QLabel* aLabel = new QLabel(myGroupBox);
@@ -90,7 +89,6 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     aGroupLay->addWidget(myYSpin, 1, 1);
 
     connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
-    connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
   }
 }
 
@@ -126,7 +124,7 @@ bool PartSet_WidgetPoint2D::setPoint(double theX, double theY)
   myYSpin->blockSignals(false);
   this->blockSignals(isBlocked);
 
-  emit valuesChanged();
+  storeValue();
   return true;
 }
 
index def3b2bb73e503ccfb416f05d9e691ae453aa167..a4e7323856d38073c4390954c4d8b7f8cb8f92e6 100644 (file)
@@ -52,8 +52,6 @@ Q_OBJECT
   /// \param theValue the wrapped widget value
   virtual bool setSelection(ModuleBase_ViewerPrs theValue);
 
-  virtual bool storeValue() const;
-
   virtual bool restoreValue();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
@@ -109,6 +107,10 @@ protected slots:
   void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index b32ba144362f34571c5c8f14cbc66c950ecb06aa..54887f018cc199c568914bd356ced275ec60ae39 100644 (file)
@@ -34,7 +34,6 @@ PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
   // Reconnect to local slot
   disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
   connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
-  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(controlValuesChanged()));
 }
 
 PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
@@ -57,7 +56,7 @@ void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
     mySpinBox->blockSignals(true);
     mySpinBox->setValue(aRadius);
     mySpinBox->blockSignals(false);
-    emit valuesChanged();
+    storeValue();
   }
 }
 
index 222bac774861dde14ece55b7fa51f81fe96a6433..f8e9d75b1d7915cc3d9c2326ed43141222c155a5 100644 (file)
@@ -35,8 +35,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetShapeSelector() {}
 
-  virtual bool storeValue() const;
-
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
@@ -45,6 +43,10 @@ Q_OBJECT
   CompositeFeaturePtr sketch() const { return mySketch; }
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
   /// Check the selected with validators if installed
   virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
 
@@ -73,9 +75,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetConstraintShapeSelector() {}
 
-  /// Saves the internal parameters to the given feature
-  virtual bool storeValue() const;
-
   /// Set sketcher
   /// \param theSketch a sketcher object
   void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
@@ -83,6 +82,11 @@ Q_OBJECT
   /// Retrurns installed sketcher
   CompositeFeaturePtr sketch() const { return mySketch; }
 
+protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const;
+
 private:
   /// Pointer to a sketch 
   CompositeFeaturePtr mySketch;
index d7b412f16b0024dffdfa9951693193d55c2595ca..0fa5c18f0372ca342b139a377c9a8ea5a94e4ffc 100644 (file)
@@ -48,11 +48,6 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetSketchLabel();
 
-  virtual bool storeValue() const
-  {
-    return true;
-  }
-
   virtual bool restoreValue()
   {
     return true;
@@ -82,6 +77,13 @@ signals:
   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
 protected:
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValue() const
+  {
+    return true;
+  }
+
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
index 84d3d6a10354f5d6d8f7117f623b79823ff0cfb5..f7b254deab7591aa2fa15b72d38409f8bff8c459 100644 (file)
@@ -651,13 +651,10 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
 
   QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-    aWidget->setFeature(theOperation->feature());
+    bool isStoreValue = !theOperation->isEditOperation() &&
+                        aWidget->isValueDefault() && !aWidget->isComputedDefault();
+    aWidget->setFeature(theOperation->feature(), isStoreValue);
     aWidget->enableFocusProcessing();
-    QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
-    // Init default values
-    if (!theOperation->isEditOperation() && aWidget->isValueDefault() && !aWidget->isComputedDefault()) {
-      aWidget->storeValue();
-    }
   }
   
   myPropertyPanel->setModelWidgets(aWidgets);
@@ -1258,24 +1255,6 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
   }
 }
 
-//**************************************************************
-void XGUI_Workshop::onWidgetValuesChanged()
-{
-  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-  FeaturePtr aFeature = anOperation->feature();
-
-  ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-
-  const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
-  QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
-  for (; anIt != aLast; anIt++) {
-    ModuleBase_ModelWidget* aCustom = *anIt;
-    if (aCustom && (aCustom == aSenderWidget)) {
-      aCustom->storeValue();
-    }
-  }
-}
-
 //**************************************************************
 void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
 {
index 1cf400d0f89a52956cf8e9d05516641cfea30c80..b492fa1134d3bf225c9ef7dd0b4a19d7feb88f15 100644 (file)
@@ -351,9 +351,6 @@ signals:
   /// \param isChecked a state of toggle if the action is checkable
   void onContextMenuCommand(const QString& theId, bool isChecked);
 
-  /// Processing of values changed in model widget
-  void onWidgetValuesChanged();
-
   /// Set waiting cursor
   void onStartWaiting();