Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_OperationSketch.cpp
index 4ff87cae1414d760c31a3e2f7bcddacf5b8df636..6deab5b2801ddc8ff68401fefd96e418e62be863 100644 (file)
@@ -48,27 +48,9 @@ PartSet_OperationSketch::~PartSet_OperationSketch()
 {
 }
 
-std::list<int> PartSet_OperationSketch::getSelectionModes(ObjectPtr theFeature) const
+CompositeFeaturePtr PartSet_OperationSketch::sketch() const
 {
-  std::list<int> aModes;
-  if (!hasSketchPlane())
-    aModes.push_back(TopAbs_FACE);
-  else
-    aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
-
-  return aModes;
-}
-
-/// Initializes the operation with previously created feature. It is used in sequental operations
-void PartSet_OperationSketch::initFeature(FeaturePtr theFeature)
-{
-  if (theFeature)
-    setEditingFeature(theFeature);
-}
-
-FeaturePtr PartSet_OperationSketch::sketch() const
-{
-  return feature();
+  return boost::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
 }
 
 void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
@@ -113,9 +95,10 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     /// It is empty and we have to use the process mouse release to start edition operation
     /// for these objects
     if (theSelected.size() == 1) {
-      ObjectPtr aFeature = theSelected.front().object();
-      if (aFeature)
-        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+      ObjectPtr aObject = theSelected.front().object();
+      if (aObject) {
+        restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
+      }
     }
   }
 }
@@ -160,17 +143,18 @@ void PartSet_OperationSketch::stopOperation()
 {
   PartSet_OperationSketchBase::stopOperation();
   emit featureConstructed(feature(), FM_Hide);
-  emit closeLocalContext();
+}
 
+void PartSet_OperationSketch::afterCommitOperation()
+{
   FeaturePtr aFeature = feature();
   std::list<ResultPtr> aResults = aFeature->results();
   std::list<ResultPtr>::const_iterator aIt;
+  Events_ID anEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW);
   for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-    ModelAPI_EventCreator::get()->sendUpdated(
-        *aIt, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+    ModelAPI_EventCreator::get()->sendUpdated(*aIt, anEvent);
   }
-  //ModelAPI_EventCreator::get()->sendUpdated(aFeature, 
-  //  Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  Events_Loop::loop()->flush(anEvent);
 }
 
 bool PartSet_OperationSketch::isNestedOperationsEnabled() const
@@ -247,6 +231,13 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   flushUpdated();
 
   emit featureConstructed(feature(), FM_Hide);
-  emit closeLocalContext();
   emit planeSelected(aDir->x(), aDir->y(), aDir->z());
 }
+
+
+bool PartSet_OperationSketch::isGranted(ModuleBase_Operation* theOperation) const
+{
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
+  return aPreviewOp != NULL;
+}
+