]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update SketchPlugin_Projection
authorazv <azv@opencascade.com>
Fri, 22 Apr 2016 07:50:08 +0000 (10:50 +0300)
committerazv <azv@opencascade.com>
Fri, 22 Apr 2016 07:50:32 +0000 (10:50 +0300)
src/SketchPlugin/SketchPlugin_Projection.cpp
src/SketchPlugin/plugin-Sketch.xml

index de39ac7816b00a37d696b6492912c14b577e91d6..c4af99b80e70e34148bbe38c69067424be158264 100644 (file)
@@ -53,56 +53,14 @@ void SketchPlugin_Projection::execute()
     return;
   FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object());
 
-  bool hasResult = lastResult();
+  if (!lastResult()) {
+    ResultConstructionPtr aConstr = document()->createConstruction(data());
+    aConstr->setShape(std::shared_ptr<GeomAPI_Edge>());
+    aConstr->setIsInHistory(false);
+    setResult(aConstr);
 
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  if (aProjection->getKind() == SketchPlugin_Line::ID()) {
-    std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Line::START_ID()));
-    std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aProjection->attribute(SketchPlugin_Line::END_ID()));
-
-    // edge to store result
-    std::shared_ptr<GeomAPI_Pnt> aFirst = sketch()->to3D(aStartPnt->x(), aStartPnt->y());
-    std::shared_ptr<GeomAPI_Pnt> aLast = sketch()->to3D(aEndPnt->x(), aEndPnt->y());
-    anEdge = GeomAlgoAPI_EdgeBuilder::line(aFirst, aLast);
-  }
-  else {
-    std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
-    std::shared_ptr<GeomAPI_Dir> aNormal = aSketchPlane->direction();
-
-    if (aProjection->getKind() == SketchPlugin_Circle::ID()) {
-      std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
-
-      // edge to store result
-      std::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterPnt->x(), aCenterPnt->y());
-      double aRadius = aProjection->real(SketchPlugin_Circle::RADIUS_ID())->value();
-      anEdge = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
-    }
-    else if (aProjection->getKind() == SketchPlugin_Arc::ID()) {
-      std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aProjection->attribute(SketchPlugin_Arc::CENTER_ID()));
-      std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aProjection->attribute(SketchPlugin_Arc::START_ID()));
-      std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aProjection->attribute(SketchPlugin_Arc::END_ID()));
-
-      // edge to store result
-      std::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterPnt->x(), aCenterPnt->y());
-      std::shared_ptr<GeomAPI_Pnt> aFirst = sketch()->to3D(aStartPnt->x(), aStartPnt->y());
-      std::shared_ptr<GeomAPI_Pnt> aLast = sketch()->to3D(aEndPnt->x(), aEndPnt->y());
-      anEdge = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aFirst, aLast, aNormal);
-    }
-  }
-
-  std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
-  aConstr->setShape(anEdge);
-  aConstr->setIsInHistory(false);
-  setResult(aConstr);
-
-  if (!hasResult)
     aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+  }
 }
 
 void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY)
index 3a03d14740467c07c827b2e0bc60c1bfe09dc80c..f30753752e7a224eeaf9fb939e2df47170dce4e9 100644 (file)
       </feature>
     </group>
 
-    <!--<group id="Projection">-->
+    <group id="Projection">
       <!-- Intersection Point -->
       <!-- feature
         id="SketchIntersectionPoint"
       </feature -->
 
       <!-- Projected feature -->
-      <!--<feature
+      <feature
         id="SketchProjection"
         title="Projection"
         tooltip="Project feature onto sketch plane"
           <validator id="SketchPlugin_ProjectionValidator"/>
         </sketch_shape_selector>
         <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
-      </feature> -->
-    <!--</group>-->
+      </feature>
+    </group>
 
     <group id="Replication">
       <!--  SketchConstraintMirror  -->