X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchPlugin%2FSketchPlugin_Sketch.cpp;h=049d0e8c50abcf5da599fb5f91d7387cc9b07af7;hb=e2c1d6fb594fe1234fa7a0786801d8c1c92d7ac6;hp=365db4ca69b59d5d4aca8311afa65980b1aca50a;hpb=b5f5aaabb45923b4964fcf6bdae979fae9d1bfb9;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 365db4ca6..049d0e8c5 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -12,12 +12,12 @@ #include #include #include -#include -#include -#include #include +#include +#include + #include #include #include @@ -44,12 +44,12 @@ 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::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_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::type()); + data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID()); } @@ -115,9 +115,6 @@ void SketchPlugin_Sketch::execute() aBigWire->addEdge(*aShapeIt); } aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir()); - -// GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(), -// aFeaturesPreview, aLoops, aWires); std::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(aBigWire); setResult(aConstr); @@ -191,69 +188,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 aNorm = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::NORM_ID())); - std::shared_ptr aX = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); - - std::shared_ptr aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX)) - ->added(aY->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 aNorm = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::NORM_ID())); - std::shared_ptr aX = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); - return thePnt->to2D(aC->pnt(), aX->dir(), aY); -} - - -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())); -} - -std::shared_ptr SketchPlugin_Sketch::coordinatePlane() const -{ - DataPtr aData = data(); - std::shared_ptr aC = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - std::shared_ptr aX = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aNorm = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::NORM_ID())); - - return std::shared_ptr(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aNorm->dir())); -} void SketchPlugin_Sketch::erase() { @@ -311,3 +245,25 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { } } } + +void SketchPlugin_Sketch::createPoint2DResult(ModelAPI_Feature* theFeature, + SketchPlugin_Sketch* theSketch, + const std::string& theAttributeID, const int theIndex) +{ + std::shared_ptr aPoint = std::dynamic_pointer_cast( + theFeature->attribute(theAttributeID)); + + if (!aPoint || !aPoint->isInitialized()) + return; + + std::shared_ptr aCenter(theSketch->to3D(aPoint->x(), aPoint->y())); + //std::cout<<"Execute circle "<x()<<" "<y()<<" "<z()< aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); + std::shared_ptr aResult = theFeature->document()->createConstruction( + theFeature->data(), theIndex); + aResult->setShape(aCenterPointShape); + aResult->setIsInHistory(false); + + theFeature->setResult(aResult, theIndex); +}