]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Fri, 16 May 2014 15:16:01 +0000 (19:16 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 16 May 2014 15:16:01 +0000 (19:16 +0400)
It is necessary to check the feature type before the data() method called, because there can be the feature, which do not contains the asked attribute(e.g. constraint).

src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationSketchLine.cpp

index 5486ffff028ff7ddc4aa93668172e25c2163746d..c9fbbfd8692b7f271fcf8ee81bfcf29301b66e29 100644 (file)
@@ -145,7 +145,7 @@ void  PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Featur
                                                double theDeltaX, double theDeltaY,
                                                const std::string& theAttribute)
 {
-  if (!theFeature)
+  if (!theFeature || theFeature->getKind() != "SketchLine")
     return;
 
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
index 5fb594a3264d2f03df6971fa6954e18f9fb79ecf..a4e09b856709ad111794076adcf63f58d1be2069 100644 (file)
@@ -68,7 +68,7 @@ std::list<int> PartSet_OperationSketchLine::getSelectionModes(boost::shared_ptr<
 void PartSet_OperationSketchLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
                                        const std::list<XGUI_ViewerPrs>& /*thePresentations*/)
 {
-  if (!theFeature)
+  if (!theFeature || theFeature->getKind() != "SketchLine")
     return;
   // use the last point of the previous feature as the first of the new one
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
@@ -284,7 +284,7 @@ void PartSet_OperationSketchLine::getLinePoint(boost::shared_ptr<ModelAPI_Featur
                                                const std::string& theAttribute,
                                                double& theX, double& theY)
 {
-  if (!theFeature)
+  if (!theFeature || theFeature->getKind() != "SketchLine")
     return;
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
@@ -298,10 +298,10 @@ boost::shared_ptr<GeomDataAPI_Point2D> PartSet_OperationSketchLine::findLinePoin
                                                double theX, double theY)
 {
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature)
+  if (!theFeature || theFeature->getKind() != "SketchLine")
     return aPoint2D;
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-
+  
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
   if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )