#include "SketchPlugin_Ellipse.h"
#include "SketchPlugin_EllipticArc.h"
#include "SketchPlugin_Fillet.h"
+#include "SketchPlugin_CurveFitting.h"
#include "SketchPlugin_Line.h"
#include "SketchPlugin_MacroArc.h"
#include "SketchPlugin_MacroCircle.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefAttrList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
ObjectPtr aSelObject = aSelAttr->object(anInd);
+
+ // B-splines are not supported in Mirror yet
+ FeaturePtr aSelFeature = ModelAPI_Feature::feature(aSelObject);
+ if (aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() ||
+ aSelFeature->getKind() == SketchPlugin_BSplinePeriodic::ID())) {
+ theError = "Not supported";
+ return false;
+ }
+
std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
std::list<ObjectPtr>::iterator aMirIter = aMirroredObjects.begin();
for (; aMirIter != aMirroredObjects.end(); aMirIter++)
break;
if (anObjIter != anInitialObjects.end())
continue;
+
+ // B-splines are not supported in Copying features
+ FeaturePtr aSelFeature = ModelAPI_Feature::feature(aSelObject);
+ if (aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() ||
+ aSelFeature->getKind() == SketchPlugin_BSplinePeriodic::ID())) {
+ theError = "Not supported";
+ return false;
+ }
+
anObjIter = aCopiedObjects.begin();
for (; anObjIter != aCopiedObjects.end(); anObjIter++)
if (aSelObject == *anObjIter) {
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId() &&
+ theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
theError = "The attribute with the %1 type is not processed";
theError.arg(theAttribute->attributeType());
return false;
}
// check the attribute refers to a sketch feature
+ bool isSketchFeature = false;
AttributeRefAttrPtr aRefAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- bool isSketchFeature = aRefAttr->isObject();
- if (isSketchFeature) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
- isSketchFeature = aFeature.get() != NULL;
+ if (aRefAttr) {
+ isSketchFeature = aRefAttr->isObject();
if (isSketchFeature) {
- std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- isSketchFeature = aSketchFeature.get() != NULL;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
+ isSketchFeature = aFeature.get() != NULL;
+ if (isSketchFeature) {
+ std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ isSketchFeature = aSketchFeature.get() != NULL;
+ }
+ }
+ }
+ else {
+ AttributeReferencePtr aReference =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+ if (aReference) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aReference->value());
+ isSketchFeature = aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID();
}
}
- if (isSketchFeature)
- return true;
-
- theError = "The object selected is not a sketch feature";
- return false;
+ if (!isSketchFeature)
+ theError = "The object selected is not a sketch feature";
+ return isSketchFeature;
}
bool SketchPlugin_MultiRotationAngleValidator::isValid(const AttributePtr& theAttribute,
return true;
}
+
+bool SketchPlugin_CurveFittingValidator::isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ AttributeRefAttrListPtr aRefAttrList =
+ theFeature->refattrlist(SketchPlugin_CurveFitting::POINTS_ID());
+ AttributeBooleanPtr aPeriodicAttr =
+ theFeature->boolean(SketchPlugin_CurveFitting::PERIODIC_ID());
+
+ // check number of selected entities
+ int aMinNbPoints = aPeriodicAttr->value() ? 3 : 2;
+ if (aRefAttrList->size() < aMinNbPoints) {
+ theError = "Not enough points selected. Need at least %1 points.";
+ theError.arg(aMinNbPoints);
+ return false;
+ }
+ return true;
+}