Salome HOME
refs #156: Behavior of the Sketch during edition
[modules/shaper.git] / src / PartSet / PartSet_OperationSketchBase.cpp
index 85c0a2c30297b796bc0e6f4b7dcce66843cbf2c9..1f7550403123cabec03ac0a7ad79dacf3d6a482b 100644 (file)
@@ -3,10 +3,22 @@
 // Author:      Natalia ERMOLAEVA
 
 #include <PartSet_OperationSketchBase.h>
+#include <PartSet_Tools.h>
+#include <ModelAPI_ResultBody.h>
 
-#include <SketchPlugin_Feature.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_IViewer.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_WidgetValueFeature.h>
 
+#include <SketchPlugin_Feature.h>
 #include <V3d_View.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
+
+#include <QKeyEvent>
+#include <QMessageBox>
+#include <QApplication>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -14,9 +26,8 @@
 
 using namespace std;
 
-PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
-                                                            QObject* theParent)
-: ModuleBase_Operation(theId, theParent)
+PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent)
+    : ModuleBase_Operation(theId, theParent)
 {
 }
 
@@ -24,29 +35,64 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
 {
 }
 
-boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
-                                      boost::shared_ptr<ModelAPI_Feature> theFeature) const
+boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
 {
-  boost::shared_ptr<SketchPlugin_Feature> aFeature = 
-                              boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
-  return aFeature->preview();
+  boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
+      SketchPlugin_Feature>(theFeature);
+  if (aFeature) {
+    ResultPtr aRes = aFeature->firstResult();
+    ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
+    if (aBody)
+      return aBody->shape();
+  }
+  return boost::shared_ptr<GeomAPI_Shape>();
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature()
+std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = ModuleBase_Operation::createFeature();
-  emit featureConstructed(aFeature, FM_Activation);
-  return aFeature;
+  return std::list<FeaturePtr>();
 }
 
+FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
+{
+  ModuleBase_Operation::createFeature(theFlushMessage);
+  if (myFeature)
+    emit featureConstructed(myFeature, FM_Activation);
+  return myFeature;
+}
 
-void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView)
+void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
+{
+}
+void PartSet_OperationSketchBase::mouseReleased(
+    QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
+    ModuleBase_ISelection* theSelection)
 {
 }
-void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected)
+void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
 {
 }
-void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+void PartSet_OperationSketchBase::mouseDoubleClick(
+    QMouseEvent* theEvent, Handle_V3d_View theView,
+    ModuleBase_ISelection* theSelection)
 {
 }
+
+void PartSet_OperationSketchBase::selectionChanged(ModuleBase_ISelection* theSelection)
+{
+}
+
+void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
+{
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
+  if (aFeature) {
+    QStringList aNested = this->nestedFeatures();
+    if (!aNested.isEmpty()) {
+      if (!aNested.contains(QString(aFeature->getKind().c_str())))
+        return;
+    }
+  }
+  emit restartRequired(theType, theFeature);
+}
+
+