X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Sketch.cpp;h=64b0c09f6f36f39ddaa0dd51a6c0f9071ec65e01;hb=af6247648ee46f0c5a829bc142b75b91254e410c;hp=624ac16ab6d48455065bc0c226959764e7b0483a;hpb=9e117aef205c7ee70ff7e6342c5b863726e58764;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 624ac16ab..64b0c09f6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -12,10 +12,7 @@ #include #include #include -#include -#include -#include #include #include @@ -29,6 +26,7 @@ #include #include +#include #include @@ -43,15 +41,14 @@ SketchPlugin_Sketch::SketchPlugin_Sketch() void SketchPlugin_Sketch::initAttributes() { - data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type()); - data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type()); - data()->addAttribute(SketchPlugin_Sketch::DIRY_ID(), GeomDataAPI_Dir::type()); - data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type()); - data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type()); + data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::typeId()); + data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::typeId()); + data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::typeId()); + data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::typeId()); // the selected face, base for the sketcher plane, not obligatory - data()->addAttribute(SketchPlugin_Feature::EXTERNAL_ID(), ModelAPI_AttributeSelection::type()); + data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory( - getKind(), SketchPlugin_Feature::EXTERNAL_ID()); + getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID()); } void SketchPlugin_Sketch::execute() @@ -65,8 +62,6 @@ void SketchPlugin_Sketch::execute() data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aDirX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aDirY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); std::shared_ptr aNorm = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::NORM_ID())); @@ -83,8 +78,13 @@ void SketchPlugin_Sketch::execute() if (!aFeature->sketch()) // on load document the back references are missed aFeature->setSketch(this); // do not include the external edges into the result - if (aFeature->data()->attribute(SketchPlugin_Feature::EXTERNAL_ID())) { - if (aFeature->data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value()) + if (aFeature->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())) { + if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value()) + continue; + } + // do not include the construction entities in the result + if (aFeature->data()->attribute(SketchPlugin_SketchEntity::AUXILIARY_ID())) { + if (aFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) continue; } @@ -111,13 +111,7 @@ void SketchPlugin_Sketch::execute() for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) { aBigWire->addEdge(*aShapeIt); } - aBigWire->setOrigin(anOrigin->pnt()); - aBigWire->setDirX(aDirX->dir()); - aBigWire->setDirY(aDirY->dir()); - aBigWire->setNorm(aNorm->dir()); - -// GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(), -// aFeaturesPreview, aLoops, aWires); + aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir()); std::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(aBigWire); setResult(aConstr); @@ -191,54 +185,6 @@ bool SketchPlugin_Sketch::isSub(ObjectPtr theObject) const return false; } -std::shared_ptr SketchPlugin_Sketch::to3D(const double theX, const double theY) -{ - std::shared_ptr aC = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - std::shared_ptr aX = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - - std::shared_ptr aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX)) - ->added(aY->dir()->xyz()->multiplied(theY)); - - return std::shared_ptr(new GeomAPI_Pnt(aSum)); -} - -std::shared_ptr SketchPlugin_Sketch::to2D( - const std::shared_ptr& thePnt) -{ - std::shared_ptr aC = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - std::shared_ptr aX = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - return thePnt->to2D(aC->pnt(), aX->dir(), aY->dir()); -} - - -bool SketchPlugin_Sketch::isPlaneSet() -{ - std::shared_ptr aNormal = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::NORM_ID())); - - return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); -} - -std::shared_ptr SketchPlugin_Sketch::plane() -{ - std::shared_ptr anOrigin = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - std::shared_ptr aNorm = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::NORM_ID())); - - if (!anOrigin || !aNorm) - return std::shared_ptr(); - - return std::shared_ptr(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir())); -} void SketchPlugin_Sketch::erase() { @@ -257,9 +203,9 @@ void SketchPlugin_Sketch::erase() } void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { - if (theID == SketchPlugin_Feature::EXTERNAL_ID()) { + if (theID == SketchPlugin_SketchEntity::EXTERNAL_ID()) { std::shared_ptr aSelection = - data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value(); + data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value(); if (aSelection) { // update arguments due to the selection value // update the sketch plane std::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aSelection); @@ -291,9 +237,6 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { std::shared_ptr aDirX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); aDirX->setValue(aXDir); - std::shared_ptr aDirY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - aDirY->setValue(aYDir); std::shared_ptr aDir = aPlane->direction(); } }