Salome HOME
updated copyright message
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Validators.cpp
index 50047dd6951d0c3ca7bb767df066018e4d3abfce..1031bf76ff592172b58ea27a4d7be5f256f6a6b6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "ConstructionPlugin_Validators.h"
@@ -55,7 +54,7 @@ bool ConstructionPlugin_ValidatorPointLines::isValid(const AttributePtr& theAttr
   GeomShapePtr aLineShape1 = aLineAttribute1->value();
   ResultPtr aContext1 = aLineAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aLineShape1.get()) {
@@ -121,7 +120,7 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid(
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aShape1.get()) {
@@ -137,14 +136,11 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid(
     aShape2 = aContext2->shape();
   }
 
-  bool isPlaneFirst = false;
   anEdge = getEdge(aShape1);
-
   aFace = getFace(aShape2);
   if(!anEdge.get() || !aFace.get()) {
     anEdge = getEdge(aShape2);
     aFace = getFace(aShape1);
-    isPlaneFirst = true;
   }
 
   if(!anEdge.get() || !aFace.get()) {
@@ -175,7 +171,7 @@ bool ConstructionPlugin_ValidatorPlaneThreePoints::isValid(const AttributePtr& t
   GeomShapePtr aPointShape1 = aPointAttribute1->value();
   ResultPtr aContext1 = aPointAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aPointShape1.get()) {
@@ -253,7 +249,7 @@ bool ConstructionPlugin_ValidatorPlaneLinePoint::isValid(
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aShape1.get()) {
@@ -311,7 +307,7 @@ bool ConstructionPlugin_ValidatorPlaneTwoParallelPlanes::isValid(
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aShape1.get()) {
@@ -364,7 +360,7 @@ bool ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes::isValid(
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
   if(!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if(!aShape1.get()) {
@@ -415,7 +411,7 @@ bool ConstructionPlugin_ValidatorPointThreeNonParallelPlanes::isValid(
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
   if (!aContext1.get()) {
-    theError = "One of the attribute not initialized.";
+    theError = "One of the attribute is not initialized.";
     return false;
   }
   if (!aShape1.get()) {
@@ -474,6 +470,29 @@ bool ConstructionPlugin_ValidatorPointThreeNonParallelPlanes::isValid(
   return true;
 }
 
+//==================================================================================================
+bool ConstructionPlugin_ValidatorNotFeature::isValid(
+    const AttributePtr& theAttribute,
+    const std::list<std::string>& /*theArguments*/,
+    Events_InfoMessage& theError) const
+{
+  AttributeSelectionPtr aSelAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+  if (!aSelAttr) {
+    theError = "Wrong attribute";
+    return false;
+  }
+
+  FeaturePtr aContextFeature = aSelAttr->contextFeature();
+  if (aContextFeature) {
+    theError = "Feature should not be selected";
+    return false;
+  }
+  return true;
+}
+
+//==================================================================================================
+
 std::shared_ptr<GeomAPI_Edge> getEdge(const GeomShapePtr theShape)
 {
   GeomEdgePtr anEdge;
@@ -547,7 +566,7 @@ std::shared_ptr<GeomAPI_Pln> getPln(const GeomShapePtr theShape)
     return aPln;
   }
 
-  if(!aFace->isPlanar()) {
+  if(!aFace || !aFace->isPlanar()) {
     return aPln;
   }