#include <QTimer>
+// the define to check the activated object as a sub-feature by argument of
+// the operation feature. E.g. rectangle feature(operation), line(in argument) to be not activated
+//#define DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+#include <ModelAPI_AttributeRefList.h>
+#endif
+
#ifdef _DEBUG
#include <QDebug>
#endif
if (theObj == (*aIt))
return true;
}
+#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE
+ FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObj);
+ std::list<AttributePtr> anAttributes = aFeature->data()->attributes(
+ ModelAPI_AttributeRefList::typeId());
+ std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
+ bool aFoundObject = false;
+ for (; anIt != aLast && !aFoundObject; anIt++) {
+ std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anIt);
+ for (int i = 0, aNb = aCurSelList->size(); i < aNb && !aFoundObject; i++) {
+ ObjectPtr anObject = aCurSelList->object(i);
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+ if (aFeature.get()) {
+ aFoundObject = anObjectFeature == aFeature;
+ }
+ }
+ }
+ return aFoundObject;
+#endif
}
return false;
}
if (theEvent->button() != Qt::LeftButton)
return;
+ bool isCoincidenceEnabled = MyFeaturesForCoincedence.contains(myFeature->getKind().c_str());
+
ModuleBase_ISelection* aSelection = myWorkshop->selection();
Handle(V3d_View) aView = theWnd->v3dView();
// TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
aSPFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
if ((!aSPFeature && !aShape.IsNull()) ||
(aSPFeature.get() && aSPFeature->isExternal())) {
- anExternal = true;
- ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
- if (!aFixedObject.get())
- aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
-
+ ResultPtr aFixedObject;
+ if (isCoincidenceEnabled) {
+ anExternal = true;
+ aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch);
+ if (!aFixedObject.get())
+ aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+ }
double aX, aY;
if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
// do not create a constraint to the point, which already used by the feature
}
}
}
-
- setConstraintWith(aFixedObject);
+ if (aFixedObject.get())
+ setConstraintWith(aFixedObject);
// fignal updated should be flushed in order to visualize possible created external objects
// e.g. selection of trihedron axis when input end arc point
updateObject(feature());
PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
}
else if (aShape.ShapeType() == TopAbs_EDGE) {
- if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str())) {
+ if (isCoincidenceEnabled) {
setConstraintWith(aObject);
setValueState(Stored); // in case of edge selection, Apply state should also be updated