]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Tue, 20 May 2014 06:33:31 +0000 (10:33 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 20 May 2014 06:33:31 +0000 (10:33 +0400)
Set end point to the start point in created line at the beginning.

src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h

index c5ac31a6f277e4cb438cbaf290147ad0485ac639..e1c31afd1e00aa44f340f09507c08a93e6ef4143 100644 (file)
@@ -140,12 +140,13 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
   switch (myPointSelectionMode)
   {
     case SM_FirstPoint: {
-      setLinePoint(aX, anY, LINE_ATTR_START);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
       myPointSelectionMode = SM_SecondPoint;
     }
     break;
     case SM_SecondPoint: {
-      setLinePoint(aX, anY, LINE_ATTR_END);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
       commit();
       emit featureConstructed(feature(), FM_Deactivation);
       emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
@@ -217,11 +218,12 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature()
     aFeature->addSub(aNewFeature);
   }
   if (myInitPoint) {
+    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_START);
+    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_END);
+
     boost::shared_ptr<ModelAPI_Data> aData = aNewFeature->data();
     boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                                 (aData->attribute(LINE_ATTR_START));
-    aPoint->setValue(myInitPoint->x(), myInitPoint->y());
-
     createConstraint(myInitPoint, aPoint);
   }
 
@@ -320,10 +322,13 @@ boost::shared_ptr<GeomDataAPI_Point2D> PartSet_OperationSketchLine::findLinePoin
   return aPoint2D;
 }
 
-void PartSet_OperationSketchLine::setLinePoint(double theX, double theY,
+void PartSet_OperationSketchLine::setLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+                                               double theX, double theY,
                                                const std::string& theAttribute)
 {
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  if (!theFeature)
+    return;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
   aPoint->setValue(theX, theY);
index fa5f12938cc548f6eb9a32b3f37fa44d677312f4..e6cabaa88094279333330d2e6a6bf8ac42df1ce3 100644 (file)
@@ -115,10 +115,12 @@ protected:
                                                        double theX, double theY);
 
   /// \brief Save the point to the line.
+  /// \param theFeature the line feature
   /// \param theX the horizontal coordinate
   /// \param theY the vertical coordinate
   /// \param theAttribute the start or end attribute of the line
-  void setLinePoint(double theX, double theY, const std::string& theAttribute);
+  void setLinePoint(boost::shared_ptr<ModelAPI_Feature>, double theX, double theY,
+                    const std::string& theAttribute);
   /// \brief Save the point to the line.
   /// \param thePoint the 3D point in the viewer
   /// \param theAttribute the start or end attribute of the line