Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_OperationSketch.cpp
index 8ce3b79589b82be90cfce5d7b7d2a8e33423ea04..b583c1e808eabb794953ee6385b88525504316fe 100644 (file)
@@ -8,6 +8,8 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -28,14 +30,12 @@ PartSet_OperationSketch::~PartSet_OperationSketch()
 {
 }
 
-bool PartSet_OperationSketch::isPerformedImmediately() const
+int PartSet_OperationSketch::getSelectionMode(boost::shared_ptr<ModelAPI_Feature> theFeature) const
 {
-  return false;
-}
-
-int PartSet_OperationSketch::getSelectionMode() const
-{
-  return TopAbs_FACE;
+  int aMode = TopAbs_FACE;
+  if (isEditMode())
+    aMode = TopAbs_VERTEX;
+  return aMode;
 }
 
 void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
@@ -43,6 +43,9 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   if (theList.IsEmpty())
     return;
 
+  if (isEditMode())
+    return;
+
   // get selected shape
   const TopoDS_Shape& aShape = theList.First();
   boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
@@ -57,14 +60,29 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   aPlane->coefficients(anA, aB, aC, aD);
 
   boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
-
+  /*
   aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA);
   aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB);
   aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
   aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
+  */
+  // temporary solution for main planes only
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  anOrigin->setValue(0, 0, 0);
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  aNormal->setValue(anA, aB, aC);
+  boost::shared_ptr<GeomDataAPI_Dir> aDirX = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+  aDirX->setValue(aB, aC, anA);
+  boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+  aDirY->setValue(aC, anA, aB);
 
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-  emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
+  emit planeSelected(aDir->x(), aDir->y(), aDir->z());
 
-  commit();
+  //commit();
+  //SketchPlugin_Sketch::setActive(myFeature);
 }