]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #394 Undo-ing a Sketch element
authornds <natalia.donis@opencascade.com>
Mon, 16 Feb 2015 13:33:43 +0000 (16:33 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 16 Feb 2015 13:33:43 +0000 (16:33 +0300)
Compute default value by moving the mouse of the viewer. Check that the default value for the creation a constraint by preselection is computed.

14 files changed:
src/ModelAPI/ModelAPI_Feature.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_Workshop.cpp

index 183077f4fff6e55b47067a7430f0f83b4226ab38..c7a57a01b3e62738ba9fd576a6d8975ba35c4f3d 100644 (file)
@@ -55,6 +55,11 @@ class ModelAPI_Feature : public ModelAPI_Object
   /// Computes or recomputes the results
   virtual void execute() = 0;
 
+  /// Computes the attribute value on the base of other attributes if the value can be computed
+  /// \param theAttributeId an attribute index to be computed
+  /// \return a boolean value about it is computed
+  virtual bool compute(const std::string& theAttributeId) { return false; };
+
   /// Registers error during the execution, causes the ExecutionFailed state
   virtual void setError(const std::string& theError) {
     data()->setError(theError);
index 4c672c5b67086f02a9d06be9c11df9e8c1ae219f..d332eedc76e0d5dccb92ae34e667c469a391a3ef 100644 (file)
@@ -28,7 +28,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_
       myParentId(theParentId)
 {
   myDefaultValue = theData->getProperty(ATTR_DEFAULT);
-  myIsComputedDefault = false;
+  myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
   myAttributeID = theData ? theData->widgetId() : "";
 
   connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
@@ -96,11 +96,18 @@ bool ModuleBase_ModelWidget::focusTo()
 
 void ModuleBase_ModelWidget::activate()
 {
-  if (!isEditingMode()) {
-    // the control value is stored to the mode by the focus in on the widget
-    // we need the value is initialized in order to enable the apply button in the property panel
-    // it should happens only in the creation mode because during edition all fields are filled
-    storeValue();
+  // the control value is stored to the mode by the focus in on the widget
+  // we need the value is initialized in order to enable the apply button in the property panel.
+  // It should happens in the creation mode only because all fields are filled in the edition mode
+  if (!isEditingMode()/* && !myFeature->data()->attribute(myAttributeID)->isInitialized()*/) {
+    if (isComputedDefault()) {
+      if (myFeature->compute(myAttributeID)) {
+        restoreValue();
+      }      
+    }
+    else {
+      storeValue();
+    }
   }
   activateCustom();
 }
index 70679303575ee4c8cd30824d69e884184a2bacc2..a6830788e9282ea5dd00d629797068200507ab85 100644 (file)
@@ -53,12 +53,12 @@ Q_OBJECT
 
   /// Returns true, if default value of the widget should be computed
   /// on operation's execute, like radius for circle's constraint (can not be zero)
-  bool isComputedDefault() { return myIsComputedDefault; }
+  bool isComputedDefault() const { return myIsComputedDefault; }
 
   /// Returns true, if default value of the widget is defined in the XML and it is not the
   /// computed value
   /// \return the boolean result
-  bool isValueDefault() { return !myDefaultValue.empty(); }
+  std::string getDefaultValue() const { return myDefaultValue; }
 
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return false; }
@@ -190,14 +190,15 @@ protected slots:
   /// A feature which is processing by active operation
   FeaturePtr myFeature;      
 
+  /// Flag which shows that current operation is in editing mode
+  bool myIsEditing; 
+
+private:
   /// Value should be computed on execute, like radius for circle's constraint (can not be zero)
   bool myIsComputedDefault; 
                         
   /// the default value, which is defined in the XML for this attribute    
   std::string myDefaultValue; 
-
-  /// Flag which shows that current operation is in editing mode
-  bool myIsEditing; 
 };
 
 #endif
index 8e8843af938c20af03295be7e04edd644742d20a..2b5437e46910ab5df783ff68054e89ec6303a9a7 100644 (file)
@@ -79,11 +79,9 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
     mySpinBox->setSingleStep(aStepVal);
   }
 
-  double aDefVal = QString::fromStdString(myDefaultValue).toDouble(&isOk);
+  double aDefVal = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
   if (isOk) {
     mySpinBox->setValue(aDefVal);
-  } else if (theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED){
-    myIsComputedDefault = true;
   }
 
   QString aTTip = QString::fromStdString(theData->widgetTooltip());
@@ -101,12 +99,16 @@ ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
 
 void ModuleBase_WidgetDoubleValue::reset()
 {
-  if (myIsComputedDefault)
+  if (isComputedDefault()) {
     return;
-
-  bool isOk;
-  double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
-  ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
+    //if (myFeature->compute(myAttributeID))
+    //  restoreValue();
+  }
+  else {
+    bool isOk;
+    double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
+    ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
+  }
 }
 
 bool ModuleBase_WidgetDoubleValue::storeValue() const
index 034d063da131b3a7c6fd3376fa809097e58fd43e..60b644e08275e0192a206554bc56506a3ea3cdb5 100644 (file)
@@ -94,12 +94,19 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
 
 void PartSet_WidgetPoint2D::reset()
 {
-  bool isOk;
-  double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
-  // it is important to block the spin box control in order to do not through out the
-  // locking of the validating state.
-  ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
-  ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
+  if (isComputedDefault()) {
+    //return;
+    if (myFeature->compute(myAttributeID))
+      restoreValue();
+  }
+  else {
+    bool isOk;
+    double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
+    // it is important to block the spin box control in order to do not through out the
+    // locking of the validating state.
+    ModuleBase_Tools::setSpinValue(myXSpin, isOk ? aDefValue : 0.0);
+    ModuleBase_Tools::setSpinValue(myYSpin, isOk ? aDefValue : 0.0);
+  }
 }
 
 PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
index 756e9a8a91fb38bc694a42bfcd828b455df38830..14ac4592178c9bb0adae1f0cc05e963d1551ec2d 100644 (file)
@@ -44,7 +44,7 @@ PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
 void PartSet_WidgetPoint2dDistance::reset()
 {
   bool isOk;
-  double aDefValue = QString::fromStdString(myDefaultValue).toDouble(&isOk);
+  double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
 
   ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
 }
index bdd410ec06de64bf7fb35e2f163e16f8c3de869b..b8ce8c1820afa1122ea1c5b62589217dda888087 100644 (file)
@@ -47,6 +47,57 @@ void SketchPlugin_ConstraintDistance::execute()
   }
 }
 
+bool SketchPlugin_ConstraintDistance::compute(const std::string& theAttributeId)
+{
+  if (theAttributeId != SketchPlugin_Constraint::FLYOUT_VALUE_PNT())
+    return false;
+
+  if (!sketch())
+    return false;
+
+  DataPtr aData = data();
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+      aData, SketchPlugin_Constraint::ENTITY_A());
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+      aData, SketchPlugin_Constraint::ENTITY_B());
+
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
+
+  if (aPoint_A && aPoint_B) {
+    aPnt_A = aPoint_A->pnt();
+    aPnt_B = aPoint_B->pnt();
+  } else if (!aPoint_A && aPoint_B) {
+    std::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+        aData, SketchPlugin_Constraint::ENTITY_A());
+    if (aLine) {
+      aPnt_B = aPoint_B->pnt();
+      aPnt_A = getProjectionPoint(aLine, aPnt_B);
+    }
+  } else if (aPoint_A && !aPoint_B) {
+    std::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+        aData, SketchPlugin_Constraint::ENTITY_B());
+    if (aLine) {
+      aPnt_A = aPoint_A->pnt();
+      aPnt_B = getProjectionPoint(aLine, aPnt_A);
+    }
+  }
+  if (!aPnt_A || !aPnt_B)
+    return false;
+
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
+                           GeomDataAPI_Point2D>(aData->attribute(theAttributeId));
+
+  std::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
+  std::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
+  std::shared_ptr<GeomAPI_Lin2d> aLine = std::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aPnt_A, aPnt_B));
+  double aDist = aPoint1->distance(aPoint2)/5.;
+  std::shared_ptr<GeomAPI_Pnt2d> aFPnt = aLine->shiftedLocation(aDist);
+  aFlyOutAttr->setValue(aFPnt);
+
+  return true;
+}
+
 //*************************************************************************************
 AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevious)
 {
@@ -90,16 +141,10 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
 
   std::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
   std::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
-  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = std::shared_ptr<GeomAPI_Pnt>();
-  if(aFlyOutAttr->isInitialized()) {
-    aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
-  } else {
-    std::shared_ptr<GeomAPI_Lin2d> aLine = std::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aPnt_A, aPnt_B));
-    double aDist = aPoint1->distance(aPoint2)/5.;
-    std::shared_ptr<GeomAPI_Pnt2d> aFPnt = aLine->shiftedLocation(aDist);
-    aFlyOutAttr->setValue(aFPnt);
-    aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y());
-  }
+  if(!aFlyOutAttr->isInitialized())
+    compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()/*aFPnt->x(), aFPnt->y()*/);
+
   // value calculation
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
index 69f31879811b9586ed7f8d993d355af027c43206..99281efdb4ed724a4e7d065174e552ff5f2a8c66 100644 (file)
@@ -47,6 +47,11 @@ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
+  /// Computes the attribute value on the base of other attributes if the value can be computed
+  /// \param theAttributeId an attribute index to be computed
+  /// \return a boolean value about it is computed
+  SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
+
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
index 224ea32b5239cb53b2c8bc06a945a1f17b2aaca6..ea50c3850d38a66e61b00f7a074a6b3416ea1b20 100644 (file)
@@ -53,6 +53,28 @@ void SketchPlugin_ConstraintLength::execute()
   }
 }
 
+bool SketchPlugin_ConstraintLength::compute(const std::string& theAttributeId)
+{
+  if (theAttributeId != SketchPlugin_Constraint::FLYOUT_VALUE_PNT())
+    return false;
+
+  std::shared_ptr<GeomAPI_Pnt> aPoint1, aPoint2;
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint, anEndPoint;
+  if (!getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint))
+    return false;
+
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(theAttributeId));
+
+  std::shared_ptr<GeomAPI_Lin2d> aLine = 
+    std::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aStartPoint->pnt(), anEndPoint->pnt()));
+  double aDist = aPoint1->distance(aPoint2)/5.;
+  std::shared_ptr<GeomAPI_Pnt2d> aFPnt = aLine->shiftedLocation(aDist);
+  aFlyOutAttr->setValue(aFPnt);
+
+  return true;
+}
+
 bool SketchPlugin_ConstraintLength::getPoints(
   std::shared_ptr<GeomAPI_Pnt>& thePoint1, std::shared_ptr<GeomAPI_Pnt>& thePoint2,
   std::shared_ptr<GeomDataAPI_Point2D>& theStartPoint,
@@ -85,20 +107,14 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
   if (!getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint))
     return thePrevious; // not possible to show length because points are not defined
 
-  std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
-      GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = std::shared_ptr<GeomAPI_Pnt>();
-  if (aFlyOutAttr->isInitialized()) {
-    aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
-  } else {
-    std::shared_ptr<GeomAPI_Lin2d> aLine = 
-      std::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aStartPoint->pnt(), anEndPoint->pnt()));
-    double aDist = aPoint1->distance(aPoint2)/5.;
-    std::shared_ptr<GeomAPI_Pnt2d> aFPnt = aLine->shiftedLocation(aDist);
-    aFlyOutAttr->setValue(aFPnt);
-    aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y());
+  AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+  if (!aFlyOutAttribute->isInitialized()) {
+    if (!compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()))
+      return thePrevious; // not possible to show length because points are not defined
   }
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
+                                                          GeomDataAPI_Point2D>(aFlyOutAttribute);
+  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
   // value calculation
   // TODO: has to be calculated on definition of reference object
   double aDistance = aPoint1->distance(aPoint2);
@@ -114,6 +130,7 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS)
     anAIS = AISObjectPtr(new GeomAPI_AISObject);
+  std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
 
   // Set color from preferences
index 98ef62511e619b47eb56a68815e70916e2962af6..5d36f051e99eabdcd2e2cdd8e12de635914a2d35 100644 (file)
@@ -43,6 +43,11 @@ class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
+  /// Computes the attribute value on the base of other attributes if the value can be computed
+  /// \param theAttributeId an attribute index to be computed
+  /// \return a boolean value about it is computed
+  SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
+
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
index 135b6bbdb285d2b66a5671251c11866f814a2869..0a2115dbccc475ed660878cc3306e2b94332c6c8 100644 (file)
@@ -63,6 +63,36 @@ void SketchPlugin_ConstraintRadius::execute()
   }
 }
 
+bool SketchPlugin_ConstraintRadius::compute(const std::string& theAttributeId)
+{
+  if (theAttributeId != SketchPlugin_Constraint::FLYOUT_VALUE_PNT())
+    return false;
+
+  std::shared_ptr<ModelAPI_Feature> aCyrcFeature;
+  double aRadius = circleRadius(aCyrcFeature);
+  if (aRadius < 0)
+    return false;
+
+  // Flyout point
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(theAttributeId));
+  // Prepare a circle
+  if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
+    std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+    double aShift = aRadius * 1.1;
+    std::shared_ptr<GeomAPI_Pnt2d> aPnt = aCenterAttr->pnt();
+    std::shared_ptr<GeomAPI_Pnt2d> aFPnt = 
+      std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aPnt->x() + aShift, aPnt->y() + aShift));
+    aFlyoutAttr->setValue(aFPnt);
+  } else { // arc
+    std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(aCyrcFeature->data()->attribute(SketchPlugin_Arc::START_ID()));      
+    aFlyoutAttr->setValue(aStartAttr->pnt());
+  }
+  return true;
+}
+
 double SketchPlugin_ConstraintRadius::circleRadius(std::shared_ptr<ModelAPI_Feature>& theCirc)
 {
   static const double kErrorResult = -1.;
@@ -105,35 +135,19 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou
   // Flyout point
   std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
       GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt;
-  if (aFlyoutAttr->isInitialized()) {
-    aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
-  } 
+  if (!aFlyoutAttr->isInitialized() && !compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()))
+    return thePrevious; // can not create a good presentation
+  std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
 
   // Prepare a circle
   std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
   if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
     aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
-    if (!aFlyoutPnt) {
-      double aShift = aRadius * 1.1;
-      std::shared_ptr<GeomAPI_Pnt2d> aPnt = aCenterAttr->pnt();
-      std::shared_ptr<GeomAPI_Pnt2d> aFPnt = 
-        std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aPnt->x() + aShift, aPnt->y() + aShift));
-      aFlyoutAttr->setValue(aFPnt);
-      aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y());
-    }
   } else { // arc
     aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aCyrcFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()));
-    if (!aFlyoutPnt) {
-      std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
-        GeomDataAPI_Point2D>(aCyrcFeature->data()->attribute(SketchPlugin_Arc::START_ID()));      
-      aFlyoutAttr->setValue(aStartAttr->pnt());
-      aFlyoutPnt = sketch()->to3D(aStartAttr->pnt()->x(), aStartAttr->pnt()->y());
-    }
   }
-
   std::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterAttr->x(), aCenterAttr->y());
   std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
index 84c2043c422f715722191e5918522cc7524cbaa6..4d6b9a3be763140fdb3f60e6cf49fa7784c7ff31 100644 (file)
@@ -40,6 +40,11 @@ class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
+  /// Computes the attribute value on the base of other attributes if the value can be computed
+  /// \param theAttributeId an attribute index to be computed
+  /// \return a boolean value about it is computed
+  SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
+
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
index 5018b9fd36a1886a7fe18a66ad53f171123423b2..7447a8fa7624e93f210ba13279cd4901b652e5d4 100644 (file)
@@ -63,7 +63,7 @@
       <selection_filter id="MultiFilter" parameters="line,vertex"/>
     </sketch_shape_selector>
                
-        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         
                <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed" min="0">
           <validator id="GeomValidators_Positive"/>
@@ -79,7 +79,7 @@
                        <validator id="SketchPlugin_ResultLine"/>
       <selection_filter id="EdgeFilter" parameters="line"/>
     </shape_selector>
-        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
@@ -93,7 +93,7 @@
                        <validator id="SketchPlugin_ResultArc"/>
                        <selection_filter id="EdgeFilter" parameters="circle"/>
                </shape_selector>
-        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed"/>
         <validator id="PartSet_RadiusValidator"/>
       </feature>
index ded693fcf6894aace0670d1b8a44ae95c3594fae..9f5a0083ddfbbc457964cf667cf9937a01b90346 100644 (file)
@@ -653,7 +653,7 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
   QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
     bool isStoreValue = !theOperation->isEditOperation() &&
-                        aWidget->isValueDefault() && !aWidget->isComputedDefault();
+                        !aWidget->getDefaultValue().empty() && !aWidget->isComputedDefault();
     aWidget->setFeature(theOperation->feature(), isStoreValue);
     aWidget->enableFocusProcessing();
   }