Salome HOME
Movement group uses solids, which are defined in extrusion/revolution/boolean. So...
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plane.cpp
index c206ff4d55b1a24f7aee3ba87fcf686966f10815..549773ab7a2902a3b041d02770e09f5fc0697bbc 100644 (file)
@@ -13,6 +13,8 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
 
 #include <GeomAPI_Pnt2d.h>
@@ -32,6 +34,11 @@ void ConstructionPlugin_Plane::initAttributes()
   data()->addAttribute(ConstructionPlugin_Plane::B(),  ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(ConstructionPlugin_Plane::C(),  ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(ConstructionPlugin_Plane::D(),  ModelAPI_AttributeDouble::typeId());
+
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::A());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::B());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::C());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::D());
 }
 
 void ConstructionPlugin_Plane::execute()
@@ -88,6 +95,10 @@ std::shared_ptr<GeomAPI_Shape>  ConstructionPlugin_Plane::createPlaneByFaceAndDi
 
     double aDist = aDistAttr->value();
     GeomShapePtr aShape = aFaceAttr->value();
+    if (!aShape.get()) {
+      aShape = aFaceAttr->context()->shape();
+    }
+
     if (aShape.get() != NULL) {
       std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_FaceBuilder::plane(aShape);
       std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
@@ -142,7 +153,7 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createPlaneByGeneralEqu
     std::string kDefaultPlaneSize = "200";
     double aSize = Config_PropManager::integer("Sketch planes", "planes_size", kDefaultPlaneSize);
     aSize *= 4.;
-    aPlaneFace = GeomAlgoAPI_FaceBuilder::square(aPlane, aSize);
+    aPlaneFace = GeomAlgoAPI_FaceBuilder::square(aPlane, aSize, true);
   }
   return aPlaneFace;
 }