return aFPoint;
}
-void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr theFeature,
- const std::string& theAttribute, double theClickedX,
- double theClickedY)
+std::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findFirstEqualPointInSketch(
+ const CompositeFeaturePtr& theSketch,
+ const std::shared_ptr<GeomDataAPI_Point2D>& theFeaturePoint,
+ const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
- if (!theFeature.get())
- return;
-
- std::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = std::shared_ptr<GeomAPI_Pnt2d>(
- new GeomAPI_Pnt2d(theClickedX, theClickedY));
-
- // find a feature point by the selection mode
- std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint;
- if (theFeature->isMacro()) {
- // the macro feature will be removed after the operation is stopped, so we need to build
- // coicidence to possible sub-features
- aFeaturePoint = PartSet_Tools::findFirstEqualPointInArgumentFeatures(theFeature, aClickedPoint);
- }
- else {
- aFeaturePoint = std::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
- }
- if (!aFeaturePoint)
- return;
-
// get all sketch features. If the point with the given coordinates belong to any sketch feature,
// the constraint is created between the feature point and the found sketch point
std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
std::list<ObjectPtr> aFeatures = aRefList->list();
std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
std::list<std::shared_ptr<ModelAPI_Attribute> > anAttiributes;
+
+ FeaturePtr aFeatureOfPoint = ModelAPI_Feature::feature(theFeaturePoint->owner());
+ std::shared_ptr<GeomDataAPI_Point2D> aFPoint;
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
- if (!aFeature.get() || (theFeature == aFeature) || (aFeaturePoint->owner() == aFeature))
+ if (!aFeature.get() || aFeatureOfPoint == aFeature)
continue;
- std::shared_ptr<GeomDataAPI_Point2D> aFPoint = PartSet_Tools::findFirstEqualPoint(aFeature,
- aClickedPoint);
- if (aFPoint)
- PartSet_Tools::createConstraint(theSketch, aFPoint, aFeaturePoint);
+ aFPoint = PartSet_Tools::findFirstEqualPoint(aFeature, thePoint);
+ if (aFPoint.get())
+ break;
}
+ return aFPoint;
}
std::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(CompositeFeaturePtr theSketch)
//if (!theTemporary) {
aMyFeature->execute();
- // fix this edge
- FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
- aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
- setObject(aMyFeature->lastResult());
- // we need to flush created signal in order to fixed constraint is processed by solver
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ // // fix this edge
+ // FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+ // aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+ // setObject(aMyFeature->lastResult());
+ // // we need to flush created signal in order to fixed constraint is processed by solver
+ // Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
//}
return aMyFeature->lastResult();
}
//if (theTemporary) {
aMyFeature->execute();
- // fix this edge
- FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
- aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
- setObject(aMyFeature->lastResult());
- // we need to flush created signal in order to fixed constraint is processed by solver
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ // // fix this edge
+ // FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+ // aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+ // setObject(aMyFeature->lastResult());
+ // // we need to flush created signal in order to fixed constraint is processed by solver
+ // Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
//}
return aMyFeature->lastResult();
}
bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrsPtr& thePrs, FeaturePtr theSketch,
- Handle_V3d_View theView, double& theX, double& theY)
+ Handle(V3d_View) theView, double& theX, double& theY)
{
bool aHasVertex = false;