Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / PartSet / PartSet_OperationConstraint.cpp
index 76c7db50e14cd9dc66f871d1be42d761f0cdf5e9..447f7a4d30b34bb094e5d087dc81876a627b4c3a 100644 (file)
@@ -45,7 +45,7 @@ using namespace std;
 
 PartSet_OperationConstraint::PartSet_OperationConstraint(const QString& theId,
                                                  QObject* theParent,
-                                              boost::shared_ptr<ModelAPI_Feature> theFeature)
+                                              FeaturePtr theFeature)
 : PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
 {
 }
@@ -59,18 +59,18 @@ bool PartSet_OperationConstraint::isGranted(ModuleBase_IOperation* theOperation)
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
 }
 
-void PartSet_OperationConstraint::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void PartSet_OperationConstraint::init(FeaturePtr theFeature,
                                        const std::list<XGUI_ViewerPrs>& /*theSelected*/,
                                        const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
-  //if (!theFeature || theFeature->getKind() != "SketchLine")
+  //if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
   //  return;
   // use the last point of the previous feature as the first of the new one
   //boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   //myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationConstraint::sketch() const
+FeaturePtr PartSet_OperationConstraint::sketch() const
 {
   return mySketch;
 }
@@ -99,7 +99,7 @@ void PartSet_OperationConstraint::mouseReleased(QMouseEvent* theEvent, Handle(V3
   }
   else {
     XGUI_ViewerPrs aPrs = theSelected.front();
-    boost::shared_ptr<ModelAPI_Feature> aFeature = aPrs.feature();
+    FeaturePtr aFeature = aPrs.feature();
 
     setFeature(aFeature);
     setValue(120);
@@ -120,12 +120,12 @@ void PartSet_OperationConstraint::mouseReleased(QMouseEvent* theEvent, Handle(V3
       }
       else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
       {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = aPrs.feature();
+        FeaturePtr aFeature = aPrs.feature();
         if (aFeature) {
           double X0, X1, X2, X3;
           double Y0, Y1, Y2, Y3;
-          getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
-          getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
+          PartSet_Tools::getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
+          PartSet_Tools::getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
           PartSet_Tools::convertTo2D(aPoint, sketch(), theView, X1, Y1);
 
           switch (myPointSelectionMode) {
@@ -133,7 +133,7 @@ void PartSet_OperationConstraint::mouseReleased(QMouseEvent* theEvent, Handle(V3
               PartSet_Tools::projectPointOnLine(X2, Y2, X3, Y3, X1, Y1, aX, anY);
             break;
             case SM_SecondPoint: {
-              getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
+              PartSet_Tools::getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
               PartSet_Tools::intersectLines(X0, Y0, X1, Y1, X2, Y2, X3, Y3, aX, anY);
             }
             break;
@@ -226,9 +226,9 @@ void PartSet_OperationConstraint::afterCommitOperation()
   emit featureConstructed(feature(), FM_Deactivation);
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationConstraint::createFeature(const bool theFlushMessage)
+FeaturePtr PartSet_OperationConstraint::createFeature(const bool theFlushMessage)
 {
-  boost::shared_ptr<ModelAPI_Feature> aNewFeature = ModuleBase_Operation::createFeature(false);
+  FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
   if (sketch()) {
     boost::shared_ptr<SketchPlugin_Feature> aFeature = 
                            boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
@@ -242,7 +242,7 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationConstraint::createFeature(c
     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));
-    createConstraint(myInitPoint, aPoint);
+    PartSet_Tools::createConstraint(myInitPoint, aPoint);
   }*/
 
   emit featureConstructed(aNewFeature, FM_Activation);
@@ -251,9 +251,9 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_OperationConstraint::createFeature(c
   return aNewFeature;
 }
 
-void PartSet_OperationConstraint::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void PartSet_OperationConstraint::setFeature(FeaturePtr theFeature)
 {
-  if (!theFeature || theFeature->getKind() != "SketchLine")
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
     return;
 
   boost::shared_ptr<ModelAPI_Data> aData = feature()->data();