+bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
+ const FeaturePtr& theNewFeature,
+ const CompositeFeaturePtr& theSketch,
+ const bool isTemporary)
+{
+ bool aChanged = false;
+ if (!theSourceFeature.get() || !theSourceFeature->data().get() ||
+ !theSourceFeature->data()->isValid())
+ return aChanged;
+
+ std::string aFeatureKind = theSourceFeature->getKind();
+ if (aFeatureKind == SketchPlugin_Line::ID()) {
+ // Initialize new line with first point equal to end of previous
+ std::shared_ptr<ModelAPI_Data> aSFData = theSourceFeature->data();
+ std::shared_ptr<GeomDataAPI_Point2D> aSPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aSFData->attribute(SketchPlugin_Line::END_ID()));
+ std::shared_ptr<ModelAPI_Data> aNFData = theNewFeature->data();
+ std::shared_ptr<GeomDataAPI_Point2D> aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aNFData->attribute(SketchPlugin_Line::START_ID()));
+ aNPoint->setValue(aSPoint->x(), aSPoint->y());
+ PartSet_Tools::createConstraint(theSketch, aSPoint, aNPoint);
+
+ aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aSFData->attribute(SketchPlugin_Line::END_ID()));
+ aNPoint->setValue(aSPoint->x(), aSPoint->y());
+ }
+ else if (aFeatureKind == SketchPlugin_Circle::ID()) {
+ // set circle type
+ std::string aTypeAttributeId = SketchPlugin_Circle::CIRCLE_TYPE();
+ AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
+ AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
+ aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
+ //ModuleBase_Tools::flushUpdated(theNewFeature);
+ aChanged = true;
+ }
+ else if (aFeatureKind == SketchPlugin_Arc::ID()) {
+ // set arc type
+ std::string aTypeAttributeId = SketchPlugin_Arc::ARC_TYPE();
+ AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
+ AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
+ aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
+
+ // if the arc is tangent, set coincidence to end point of the previous arc
+ std::string anArcType = aSourceFeatureTypeAttr->value();
+ if (anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT()) {
+ // get the last point of the previuos arc feature(geom point 2d)
+ std::shared_ptr<ModelAPI_Data> aSData = theSourceFeature->data();
+ std::shared_ptr<GeomDataAPI_Point2D> aSPointAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aSData->attribute(SketchPlugin_Arc::END_ID()));
+ // get point attribute on the current feature
+ AttributeRefAttrPtr aTangentPointAttr = theNewFeature->data()->refattr(
+ SketchPlugin_Arc::TANGENT_POINT_ID());
+ aTangentPointAttr->setAttr(aSPointAttr);
+
+ std::shared_ptr<GeomDataAPI_Point2D> aNPointAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theNewFeature->data()->attribute(SketchPlugin_Arc::END_ID()));
+ aNPointAttr->setValue(aSPointAttr->x(), aSPointAttr->y());
+
+ }
+ //ModuleBase_Tools::flushUpdated(theNewFeature);
+ aChanged = true;
+ }
+ return aChanged;
+}
+
+bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation,
+ const CompositeFeaturePtr& /*theSketch*/) const
+{
+ bool aTangentArc = false;
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (theOperation);
+ if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
+ FeaturePtr aFeature = aFOperation->feature();
+ if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
+ std::string anArcType = aTypeAttr.get() ? aTypeAttr->value() : "";
+ aTangentArc = anArcType == SketchPlugin_Arc::ARC_TYPE_TANGENT();
+ }
+ }
+ return aTangentArc;
+}
+
+void PartSet_SketcherReetntrantMgr::updateAcceptAllAction()
+{
+ CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+ if (aSketch.get())
+ workshop()->errorMgr()->updateAcceptAllAction(aSketch);
+}
+