]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
createPoint2DResult() to be used in Circle/Translation/Rotation objects. May be Sketc...
authornds <natalia.donis@opencascade.com>
Fri, 24 Apr 2015 17:24:27 +0000 (20:24 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 24 Apr 2015 17:24:27 +0000 (20:24 +0300)
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_MultiRotation.cpp
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/plugin-Sketch.xml

index 623b6c62549757eaf2b35f54ff9ddb38437baebf..8625d578bb3508c5751b2f9a2cd20404d707a4ee 100644 (file)
@@ -51,12 +51,7 @@ void SketchPlugin_Circle::execute()
       std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
       //std::cout<<"Execute circle "<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
       // make a visible point
-      std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
-      std::shared_ptr<ModelAPI_ResultConstruction> 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<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
index 982524cf25939be974df8eb9fa7ed27d2a8aac08..866867051cff52d1de566fd1b74987cec1a01538 100644 (file)
@@ -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<ModelAPI_AttributeDouble>(
       attribute(ANGLE_ID()))->value();
   // Convert angle to radians
index 064b9336327876e2d02fca86f56deed9c1b79c55..71eca57ca89f10927d685525d7996c18a3e12c82 100644 (file)
@@ -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<GeomAPI_XY> 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();
 }
+
index 64b0c09f6f36f39ddaa0dd51a6c0f9071ec65e01..049d0e8c50abcf5da599fb5f91d7387cc9b07af7 100644 (file)
@@ -15,6 +15,9 @@
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
@@ -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<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+    theFeature->attribute(theAttributeID));
+
+  if (!aPoint || !aPoint->isInitialized())
+    return;
+
+  std::shared_ptr<GeomAPI_Pnt> aCenter(theSketch->to3D(aPoint->x(), aPoint->y()));
+  //std::cout<<"Execute circle "<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
+  // make a visible point
+  std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+  std::shared_ptr<ModelAPI_ResultConstruction> aResult = theFeature->document()->createConstruction(
+                     theFeature->data(), theIndex);
+  aResult->setShape(aCenterPointShape);
+  aResult->setIsInHistory(false);
+
+  theFeature->setResult(aResult, theIndex);
+}
index d7e65d5486ff8bcc8bbf6a0b08c4573e2c0e79ed..920ec399bb4e5a961c481511ef34fa540adafc07 100644 (file)
@@ -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
index 9e2021b9cc4195a9e2fe8e72ad451987aa3b0d05..0b8caf3c74b7b957b97c950eb58ee131495c0d66 100644 (file)
         <integervalue id="MultiTranslationCopies"
             label="Number of copies"
             tooltip="Number of copies" 
-            default="1" min="1">
+            default="1" min="1"
+            obligatory="0">
           <validator id="GeomValidators_Positive"/>
         </integervalue>
       </feature>
         <integervalue id="MultiRotationCopies"
             label="Number of copies"
             tooltip="Number of copies" 
-            default="1" min="1">
+            default="1" min="1"
+            obligatory="0">
           <validator id="GeomValidators_Positive"/>
         </integervalue>
       </feature>