Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_OperationFeatureEdit.cpp
index 4d3edb9e917ea7362bed23aa90faa4e73151ff67..16e2b44370ae89345e43b8faf42c09064ad472c9 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_IPropertyPanel.h>
 
 #include <ModelAPI_Events.h>
 
 
 using namespace std;
 
-PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent,
-                                                           FeaturePtr theFeature)
-    : PartSet_OperationSketchBase(theId, theParent),
-      mySketch(theFeature),
+PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId,
+                                                           QObject* theParent,
+                                                           CompositeFeaturePtr theFeature)
+    : PartSet_OperationFeatureBase(theId, theParent, theFeature),
       myIsBlockedSelection(false)
 {
+  myIsEditing = true;
 }
 
 PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
 {
 }
 
-std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
-{
-  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
-}
-
-void PartSet_OperationFeatureEdit::initFeature(FeaturePtr theFeature)
-{
-  setEditingFeature(theFeature);
-}
 
-FeaturePtr PartSet_OperationFeatureEdit::sketch() const
-{
-  return mySketch;
-}
-
-void PartSet_OperationFeatureEdit::mousePressed(
-    QMouseEvent* theEvent, Handle(V3d_View) theView,
-    const std::list<ModuleBase_ViewerPrs>& theSelected,
-    const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
+  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+  if(aActiveWgt && aActiveWgt->isViewerSelector()) {
+    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
+    PartSet_OperationFeatureBase::mousePressed(theEvent, theView, theSelected, theHighlighted);
+    return;
+  }
   ObjectPtr aObject;
   if (!theHighlighted.empty())
     aObject = theHighlighted.front().object();
@@ -80,20 +73,21 @@ void PartSet_OperationFeatureEdit::mousePressed(
     if (commit()) {
       emit featureConstructed(feature(), FM_Deactivation);
 
-      bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-      if (aHasShift && !theHighlighted.empty()) {
-        QList<ObjectPtr> aSelected;
-        std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
-        for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
-          aSelected.append((*aIt).object());
+      //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+      //if (aHasShift && !theHighlighted.empty()) {
+      //  QList<ObjectPtr> aSelected;
+      //  std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
+      //  for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
+      //    aSelected.append((*aIt).object());
         /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
          if (!aSelected.contains((*aIt).object()))
          aSelected.append((*aIt).object());
          }*/
         //aSelected.push_back(feature());
         //aSelected.push_back(theHighlighted.front().object());
-        emit setSelection(aSelected);
-      } else if (aFeature) {
+        //emit setSelection(aSelected);
+      //} else 
+      if (aFeature) {
         restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
       }
     }
@@ -120,9 +114,12 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_
 
     boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = boost::dynamic_pointer_cast<
         SketchPlugin_Feature>(feature());
-    aSketchFeature->move(aDeltaX, aDeltaY);
-    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
-    ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent);
+    // MPV: added condition because it could be external edge of some object, not sketch
+    if (aSketchFeature && aSketchFeature->sketch() == sketch().get()) {
+      aSketchFeature->move(aDeltaX, aDeltaY);
+      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent);
+    }
   }
   sendFeatures();
 
@@ -131,10 +128,18 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_
 
 void PartSet_OperationFeatureEdit::mouseReleased(
     QMouseEvent* theEvent, Handle(V3d_View) theView,
-    const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
-    const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+    const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  blockSelection(false);
+  ModuleBase_ModelWidget* aActiveWgt = 0;
+  if (myPropertyPanel)
+    aActiveWgt = myPropertyPanel->activeWidget();
+  if(aActiveWgt && aActiveWgt->isViewerSelector()) {
+    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
+    PartSet_OperationFeatureBase::mouseReleased(theEvent, theView, theSelected, theHighlighted);
+  } else {
+    blockSelection(false);
+  }
 }
 
 void PartSet_OperationFeatureEdit::mouseDoubleClick(
@@ -161,14 +166,6 @@ void PartSet_OperationFeatureEdit::mouseDoubleClick(
   }
 }
 
-void PartSet_OperationFeatureEdit::keyReleased(const int theKey)
-{
-  if (theKey == Qt::Key_Return) {
-    commit();
-  } else
-    PartSet_OperationSketchBase::keyReleased(theKey);
-}
-
 void PartSet_OperationFeatureEdit::startOperation()
 {
   PartSet_OperationSketchBase::startOperation();
@@ -203,7 +200,8 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR
   }
 }
 
-FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool /*theFlushMessage*/)
+FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool theFlushMessage,
+  CompositeFeaturePtr theCompositeFeature)
 {
   // do nothing in order to do not create a new feature
   return FeaturePtr();