+ AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Plane::METHOD());
+ std::string aMethodType = aMethodTypeAttr->value();
+ std::shared_ptr<GeomAPI_Shape> aPlaneFace;
+ if (aMethodType == "PlaneByFaceAndDistance") {
+ aPlaneFace = createPlaneByFaceAndDistance();
+ } else if (aMethodType == "PlaneByGeneralEquation") {
+ aPlaneFace = createPlaneByGeneralEquation();
+ }
+ if (!aPlaneFace.get())
+ return;
+ ResultConstructionPtr aConstr = document()->createConstruction(data());
+ aConstr->setShape(aPlaneFace);
+ setResult(aConstr);
+}
+
+bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+ std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+{
+ std::vector<int> aColor;
+ // get color from the attribute of the result
+ if (theResult.get() != NULL && theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
+ AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColorAttr.get() && aColorAttr->size()) {
+ aColor.push_back(aColorAttr->value(0));
+ aColor.push_back(aColorAttr->value(1));
+ aColor.push_back(aColorAttr->value(2));
+ }
+ }
+ if (aColor.empty())
+ aColor = Config_PropManager::color("Visualization", "construction_plane_color",
+ ConstructionPlugin_Plane::DEFAULT_COLOR());
+
+ bool isCustomized = false;
+ if (aColor.size() == 3)
+ isCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+ isCustomized = thePrs->setTransparensy(0.6) || isCustomized;
+
+ return isCustomized;
+}
+
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createPlaneByFaceAndDistance()
+{
+ AttributeSelectionPtr aFaceAttr = data()->selection(ConstructionPlugin_Plane::FACE());
+ AttributeDoublePtr aDistAttr = data()->real(ConstructionPlugin_Plane::DISTANCE());
+ std::shared_ptr<GeomAPI_Shape> aPlane;
+ if ((aFaceAttr.get() != NULL) &&
+ (aDistAttr.get() != NULL) &&
+ aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {