From: nds Date: Fri, 24 Apr 2015 17:24:27 +0000 (+0300) Subject: createPoint2DResult() to be used in Circle/Translation/Rotation objects. May be Sketc... X-Git-Tag: V_1.2.0~180^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3aff80c29c53d203afe43bf6ce95cd5372a9f85e;p=modules%2Fshaper.git createPoint2DResult() to be used in Circle/Translation/Rotation objects. May be SketchPlugun tools should be created for the common functionality. --- diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index 623b6c625..8625d578b 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -51,12 +51,7 @@ void SketchPlugin_Circle::execute() std::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); //std::cout<<"Execute circle "<x()<<" "<y()<<" "<z()< aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); - std::shared_ptr aConstr1 = document()->createConstruction( - data(), 0); - aConstr1->setShape(aCenterPointShape); - aConstr1->setIsInHistory(false); - setResult(aConstr1, 0); + SketchPlugin_Sketch::createPoint2DResult(this, sketch(), CENTER_ID(), 0); // make a visible circle std::shared_ptr aNDir = std::dynamic_pointer_cast( diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index 982524cf2..866867051 100644 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -53,6 +53,9 @@ void SketchPlugin_MultiRotation::execute() attribute(CENTER_ID())); if (!aCenter || !aCenter->isInitialized()) return; + // make a visible points + SketchPlugin_Sketch::createPoint2DResult(this, sketch(), CENTER_ID(), 0); + double anAngle = std::dynamic_pointer_cast( attribute(ANGLE_ID()))->value(); // Convert angle to radians diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp index 064b93363..71eca57ca 100644 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -51,6 +51,11 @@ void SketchPlugin_MultiTranslation::execute() attribute(END_POINT_ID())); if (!aStart || !aEnd || !aStart->isInitialized() || !aEnd->isInitialized()) return; + + // make a visible points + SketchPlugin_Sketch::createPoint2DResult(this, sketch(), START_POINT_ID(), 0); + SketchPlugin_Sketch::createPoint2DResult(this, sketch(), END_POINT_ID(), 1); + std::shared_ptr aShiftVec(new GeomAPI_XY(aEnd->x() - aStart->x(), aEnd->y() - aStart->y())); // Wait all objects being created, then send update events @@ -208,3 +213,4 @@ ObjectPtr SketchPlugin_MultiTranslation::copyFeature(ObjectPtr theObject) } return ObjectPtr(); } + diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 64b0c09f6..049d0e8c5 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -15,6 +15,9 @@ #include +#include +#include + #include #include #include @@ -242,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); +} diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index d7e65d548..920ec399b 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -194,6 +194,13 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;} SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + + /// \brief Create a result for the point in the attribute if the attribute is initialized + /// \param theAttributeID an attribute string + /// \param theIndex an index of the result + static void createPoint2DResult(ModelAPI_Feature* theFeature, + SketchPlugin_Sketch* theSketch, + const std::string& theAttributeID, const int theIndex); }; #endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 9e2021b9c..0b8caf3c7 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -280,7 +280,8 @@ + default="1" min="1" + obligatory="0"> @@ -306,7 +307,8 @@ + default="1" min="1" + obligatory="0">