]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Mon, 23 Jun 2014 16:11:13 +0000 (20:11 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 23 Jun 2014 16:11:13 +0000 (20:11 +0400)
Undoes the modification of the isEdit state of operation using. The default value of the feature is set after the operation is started
Edit for a second line creation. This is not edit operation, but the property widget value should not be applyed to the line.

src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/PartSet/PartSet_OperationEditConstraint.cpp
src/PartSet/PartSet_OperationEditFeature.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/XGUI/XGUI_Workshop.cpp

index 089b1e637a89e989d1df8849aa76c5768d74b87e..dbac446a1adcfc19a752cfa477488e2147f4f7eb 100644 (file)
@@ -9,7 +9,7 @@
 #include <QWidget>
 
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData)
- : QObject(theParent)
+ : QObject(theParent), myHasDefaultValue(false)
 {
   myAttributeID = theData ? theData->widgetId() : "";
 }
@@ -36,3 +36,8 @@ std::string ModuleBase_ModelWidget::attributeID() const
 {
   return myAttributeID;
 }
+
+void ModuleBase_ModelWidget::setHasDefaultValue(const bool& theHasDefaultValue)
+{
+  myHasDefaultValue = theHasDefaultValue;
+}
index 286d16f06b2baeeda38fc5875ce3b8789ff915e9..0f2cd543f8f3424cd0fe73b05652a039c3d11227 100644 (file)
@@ -54,6 +54,10 @@ public:
   /// \return a control list
   virtual QList<QWidget*> getControls() const = 0;
 
+  /// Returns whether the control has a default value
+  /// \return a boolean value
+  bool hasDefaultValue() const { return myHasDefaultValue; }
+
 signals:
   /// The signal about widget values changed
   void valuesChanged();
@@ -67,7 +71,12 @@ protected:
   /// \returns the string value
   std::string attributeID() const;
 
+  /// Sets the has default value state to the widget
+  /// \param theHasDefaultValue the boolean value
+  void setHasDefaultValue(const bool& theHasDefaultValue);
+
 private:
+  bool myHasDefaultValue; /// the boolean state whether the control has a default value
   std::string myAttributeID; /// the attribute name of the model feature
 };
 
index 4b7e3c78ccb1285010f50f907e8dc8ec1127f8ff..64fb18e77f0df0ff03ce60b555b8d5c6017a6770 100644 (file)
@@ -123,6 +123,6 @@ void ModuleBase_Operation::setFeature(FeaturePtr theFeature)
 
 void ModuleBase_Operation::setEditingFeature(FeaturePtr theFeature)
 {
-  myFeature = theFeature;
+  setFeature(theFeature);
   myIsEditing = true;
 }
index 6e5830bd750d981de6b53af10284800e5e0d4097..37fd95892d5afa183584deefbd68ef452baf78e4 100644 (file)
@@ -96,6 +96,7 @@ protected:
   /// \returns the created feature
   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
+private:
   /// Sets the operation feature
   void setFeature(FeaturePtr theFeature);
 
index b17b98f1174225e48e157020ae6beff95d4f617b..aac859c49515f8be1d024e298783868cef4f2bcd 100644 (file)
@@ -67,6 +67,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, c
 
   aProp = theData->getProperty(DOUBLE_WDG_DFLT);
   double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
+  setHasDefaultValue(isOk);
   if (isOk) {
     mySpinBox->setValue(aDefVal);
   }
index 0c3fae21691910550e0c4813280dea58cda67fd6..82732d95430e55a074ffbad4cdeb3ab0b2abfb18 100644 (file)
@@ -69,7 +69,7 @@ void PartSet_OperationEditConstraint::init(FeaturePtr theFeature,
                                      const std::list<XGUI_ViewerPrs>& theSelected,
                                      const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
-  setFeature(theFeature);
+  setEditingFeature(theFeature);
   myFeaturePrs->init(theFeature);
 
   /*
@@ -196,7 +196,7 @@ void PartSet_OperationEditConstraint::mouseDoubleClick(QMouseEvent* theEvent, Ha
 
 void PartSet_OperationEditConstraint::startOperation()
 {
-  // do nothing in order to do not create a new feature
+  PartSet_OperationSketchBase::startOperation();
   emit multiSelectionEnabled(false);
 
   //if (myFeatures.size() > 1)
index e0d52827d5ddb3d97dd99dc372e6791400190f2b..5f53b18126e790fd28de32ceb57954230a5d8a49 100644 (file)
@@ -57,7 +57,7 @@ void PartSet_OperationEditFeature::init(FeaturePtr theFeature,
                                      const std::list<XGUI_ViewerPrs>& theSelected,
                                      const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
-  setFeature(theFeature);
+  setEditingFeature(theFeature);
 
   if (!theHighlighted.empty()) {
     // if there is highlighted object, we check whether it is in the list of selected objects
@@ -171,7 +171,7 @@ void PartSet_OperationEditFeature::mouseReleased(QMouseEvent* theEvent, Handle(V
 
 void PartSet_OperationEditFeature::startOperation()
 {
-  // do nothing in order to do not create a new feature
+  PartSet_OperationSketchBase::startOperation();
   emit multiSelectionEnabled(false);
 
   if (myFeatures.size() > 1)
index 2da18786e8835ea8c220f5dd8cbe9143270a03bb..dcce1c5fbe655d4b68068272086aa9accc9176aa 100644 (file)
@@ -62,7 +62,8 @@ void PartSet_OperationSketch::init(FeaturePtr theFeature,
                                    const std::list<XGUI_ViewerPrs>& /*theSelected*/,
                                    const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
-  setFeature(theFeature);
+  if (theFeature)
+    setEditingFeature(theFeature);
 }
 
 FeaturePtr PartSet_OperationSketch::sketch() const
@@ -167,10 +168,9 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const
 
 void PartSet_OperationSketch::startOperation()
 {
-  if (!feature()) {
-    setFeature(createFeature());
+  PartSet_OperationSketchBase::startOperation();
+  if (!isEditOperation())
     emit fitAllView();
-  }
 }
 
 bool PartSet_OperationSketch::hasSketchPlane() const
index 00446f23b3a6b27ecd8f8ddc700de89199ae0432..81f91c8ce33007d891ff4faeff8b60141fb5f05b 100644 (file)
@@ -324,7 +324,7 @@ void XGUI_Workshop::onOperationStarted()
       aWidget = *anIt;
       QObject::connect(aWidget, SIGNAL(valuesChanged()),  aOperation, SLOT(storeCustomValue()));
       // Init default values
-      if (!aOperation->isEditOperation()) {
+      if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
         aWidget->storeValue(aOperation->feature());
       }
     }