+bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbPoints == 0 && (aShapes[GeomAbs_Line] == aNbEdges && aNbEdges == 1);
+ }
+}
+
+bool PartSet_FilletSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aCount = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aCount > 1 && aNbEdges == 0;
+ }
+}
+
+bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbPoints == 0 && (aNbEdges == 1 || (aNbEdges == 2 && aShapes[GeomAbs_Line] == 1));
+ }
+}
+
+bool PartSet_AngleSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbPoints == 0 && aShapes[GeomAbs_Line] == aNbEdges && aNbEdges > 0 && aNbEdges < 3;
+ }
+}
+
+bool PartSet_EqualSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbPoints == 0 && (aNbEdges > 0 && aNbEdges < 3) &&
+ (aShapes[GeomAbs_Line] == aNbEdges ||
+ aShapes[GeomAbs_Circle] == aNbEdges ||
+ aShapes[GeomAbs_Ellipse] == aNbEdges);
+ }
+}
+
+bool PartSet_CollinearSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbPoints == 0 && aShapes[GeomAbs_Line] == aNbEdges && aNbEdges > 0 && aNbEdges < 3;
+ }
+}
+
+bool PartSet_MiddlePointSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0)
+ return isEmptySelectionValid(theOperation);
+ else {
+ int aNbPoints = shapesNbPoints(theSelection);
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return (aNbPoints >= 0 && aNbPoints < 3) && (aNbEdges >= 0 && aNbEdges < 2);
+ }
+}
+
+bool PartSet_MultyTranslationSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbEdges > 0;
+ }
+}
+
+bool PartSet_SplitSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ ShapeQuantity aShapes;
+ int aNbEdges = shapesNbEdges(theSelection, aShapes);
+ return aNbEdges > 0;
+ }
+}
+
+bool PartSet_ProjectionSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ return theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0 &&
+ isEmptySelectionValid(theOperation);
+}
+
+bool PartSet_IntersectionSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ return theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0 &&
+ isEmptySelectionValid(theOperation);
+}
+
+
+std::string PartSet_DifferentObjectsValidator::errorMessage(
+ const PartSet_DifferentObjectsValidator::ErrorType& theType,
+ const std::string& thEqualObject, const std::string& theFirstAttribute,
+ const std::string& theSecondAttribute) const
+{
+ std::string anError;
+ switch (theType) {
+ case EqualObjects:
+ anError = "The feature uses one " + thEqualObject + " object in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EqualAttributes:
+ anError = "The feature uses reference to one " + thEqualObject + " attribute in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EqualShapes:
+ anError = "The feature uses one shape in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ case EmptyShapes:
+ anError = "The feature uses empty shapes in " +
+ theFirstAttribute + " and " + theSecondAttribute + " attributes.";
+ break;
+ break;
+ default:
+ break;
+ }
+ return anError;
+}
+
+bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const