ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
- double aX = myXSpin->value();
- double aY = myYSpin->value();
aPoint->setValue(myXSpin->value(), myYSpin->value());
updateObject(myFeature);
that->blockSignals(isBlocked);
AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aData->attribute(SketchPlugin_Constraint::VALUE()));
- if (!anAttr_Value->isInitialized()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_B());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_B());
- if (aPoint_A && aPoint_B) { // both points
- anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
- } else {
- if (!aPoint_A && aPoint_B) { //Line and point
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
- } else if (aPoint_A && !aPoint_B) { // Point and line
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
- }
+ if (aPoint_A && aPoint_B) { // both points
+ anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+ } else {
+ if (!aPoint_A && aPoint_B) { //Line and point
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
+ } else if (aPoint_A && !aPoint_B) { // Point and line
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
}
}
}
void SketchPlugin_ConstraintLength::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
-
- double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aLenght);
- }
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ // set length value
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+ double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aLenght);
}
}
void SketchPlugin_ConstraintRadius::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- double aRadius = 0;
- boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
- if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
- AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
- if (anAttribute)
- aRadius = anAttribute->value();
- } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
- if (aCenterAttr && aStartAttr)
- aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
- }
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aRadius);
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ double aRadius = 0;
+ boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+ if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ if (anAttribute)
+ aRadius = anAttribute->value();
+ } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ if (aCenterAttr && aStartAttr)
+ aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
}
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aRadius);
}
}