]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#refs 77 - reported by Hervé Legrand: double click in 3D viewer leads to crash when...
authornds <natalia.donis@opencascade.com>
Fri, 30 May 2014 12:03:56 +0000 (16:03 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 30 May 2014 12:03:56 +0000 (16:03 +0400)
The main functionality is in OperationSketchLine::onMouseRelease

src/ModuleBase/ModuleBase_IOperation.cpp
src/ModuleBase/ModuleBase_IOperation.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/PartSet/PartSet_OperationSketchLine.h

index 4e339672b65edcac0e9924f165f1d4c7a146bf05..390cf96d2ae4fb6170b9c51bdefd99cb54b45caf 100644 (file)
@@ -74,6 +74,8 @@ void ModuleBase_IOperation::commit()
 
   document()->finishOperation();
   emit stopped();
+  
+  afterCommitOperation();
 }
 
 void ModuleBase_IOperation::setRunning(bool theState)
index b3373e4bf2764955aa3d8513df6a91a9500d3b48..ae10a849b99263eeae6e49c4d528628df4c7e204 100644 (file)
@@ -118,6 +118,9 @@ protected:
   virtual void abortOperation() = 0;
   /// Virtual method called when operation committed (see commit() method for more description)
   virtual void commitOperation() = 0;
+  /// Virtual method called after operation committed (see commit() method for more description)
+  /// it is important that the method is called after the stop() signal is emitted
+  virtual void afterCommitOperation() = 0;
 
   /// Returns pointer to the root document.
   boost::shared_ptr<ModelAPI_Document> document() const;
index c26eadb2a9e2d50b73ed90752ae33a91e51aebc0..8bf69185cea2baa2bb0260b6742d5d46aa98ab23 100644 (file)
@@ -98,6 +98,10 @@ void ModuleBase_Operation::commitOperation()
   if (myFeature) myFeature->execute();
 }
 
+void ModuleBase_Operation::afterCommitOperation()
+{
+}
+
 void ModuleBase_Operation::flushUpdated()
 {
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
index e66d58ab99c56ebfe6b6fe46bafa5c818693c568..833dbf57c80872c4234aafdf4a3191b3da4d0c68 100644 (file)
@@ -80,6 +80,8 @@ protected:
   virtual void abortOperation();
   /// Virtual method called when operation committed (see commit() method for more description)
   virtual void commitOperation();
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
 
   /// Send update message by loop
   void flushUpdated();
index d69aab8e0ab2793a2c05372cb97afcbdf7b9025b..fc034c7394c8eb83fc354f3371782c969b36c197 100644 (file)
@@ -108,7 +108,7 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V
         emit setSelection(aSelected);
       }
       else if (aFeature) {
-        emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+        restartOperation(PartSet_OperationEditLine::Type(), aFeature);
       }
     }
   }
index f50dcb41df200e73602dd1eac89418db885328f6..3270705d61af4f68d75d8ad4c06526a29c76bc0a 100644 (file)
@@ -85,7 +85,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
     if (theHighlighted.size() == 1) {
       boost::shared_ptr<ModelAPI_Feature> aFeature = theHighlighted.front().feature();
       if (aFeature)
-        emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+        restartOperation(PartSet_OperationEditLine::Type(), aFeature);
     }
     else
       myFeatures = theHighlighted;
@@ -101,7 +101,7 @@ void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View)
     boost::shared_ptr<ModelAPI_Feature> aFeature = PartSet_Tools::NearestFeature(theEvent->pos(),
                                                                 theView, feature(), myFeatures);
     if (aFeature)
-      emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+      restartOperation(PartSet_OperationEditLine::Type(), aFeature);
   }
 }
 
index 46b9a05411bad19924e4420dea5a8c7eedfbbe39..c14ab91896c46f2fc195459b27dbcba8ed299cdc 100644 (file)
@@ -95,3 +95,9 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th
 {
   keyReleased(theEvent->key());
 }
+
+void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
+                                                   boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  emit launchOperation(theType, theFeature);
+}
index 4da9b950332a2e00ea86e667bdc8d0c99fde2caf..0c10c6c1a9fb3b4074138b9b43f62e72f5d168fa 100644 (file)
@@ -94,6 +94,13 @@ public:
 
   virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
 
+  /// Emits a signal about the operation start. This signal has an information about the feature.
+  /// If the provided feature is empty, the current operation feature is used.
+  /// \param theType a type of an operation started
+  /// theFeature the operation argument
+  void restartOperation(const std::string& theType,
+         boost::shared_ptr<ModelAPI_Feature> theFeature = boost::shared_ptr<ModelAPI_Feature>());
+
 signals:
   /// signal about the request to launch operation
   /// theName the operation name
index ddd9bd7281857bdf1ab1d34ac2ebc7adb9e60068..fa16b1bf9c0b0b11496cb711ca6d26fbb37da8bc 100644 (file)
@@ -87,6 +87,15 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
                                                 const std::list<XGUI_ViewerPrs>& theSelected,
                                                 const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
+  if (myPointSelectionMode == SM_DonePoint)
+  {
+    // if the point creation is finished, the next mouse release should commit the modification
+    // the next release can happens by double click in the viewer
+    commit();
+    restartOperation(PartSet_OperationSketchLine::Type(), feature());
+    return;
+  }
+
   double aX, anY;
 
   bool isFoundPoint = false;
@@ -137,8 +146,6 @@ void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3
       }
     }
   }
-  //if (!isFoundPoint)
-  //  return;
 
   switch (myPointSelectionMode)
   {
@@ -187,8 +194,7 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V
     case SM_DonePoint:
     {
       commit();
-      emit featureConstructed(feature(), FM_Deactivation);
-      emit launchOperation(PartSet_OperationSketchLine::Type(), feature());
+      restartOperation(PartSet_OperationSketchLine::Type(), feature());
     }
     default:
       break;
@@ -216,8 +222,7 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey)
       if (myPointSelectionMode == SM_DonePoint)
       {
         commit();
-        emit featureConstructed(feature(), FM_Deactivation);
-        emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr<ModelAPI_Feature>());
+        restartOperation(PartSet_OperationSketchLine::Type(), feature());
       }
       //else
       //  abort();
@@ -228,7 +233,6 @@ void PartSet_OperationSketchLine::keyReleased(const int theKey)
       if (myPointSelectionMode == SM_DonePoint)
       {
         commit();
-        emit featureConstructed(feature(), FM_Deactivation);
       }
       else
         abort();
@@ -258,6 +262,12 @@ void PartSet_OperationSketchLine::stopOperation()
   emit multiSelectionEnabled(true);
 }
 
+void PartSet_OperationSketchLine::afterCommitOperation()
+{
+  PartSet_OperationSketchBase::afterCommitOperation();  
+  emit featureConstructed(feature(), FM_Deactivation);
+}
+
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature(const bool theFlushMessage)
 {
   boost::shared_ptr<ModelAPI_Feature> aNewFeature = ModuleBase_Operation::createFeature(false);
@@ -320,8 +330,12 @@ void PartSet_OperationSketchLine::setConstraints(double theX, double theY)
     case SM_SecondPoint:
       aPointArg = LINE_ATTR_END;
       break;
+    default:
+      break;
   }
 
+  boost::shared_ptr<ModelAPI_Feature> aSkFeature = feature();
+
   boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
                                                               (aData->attribute(aPointArg));
index d0c08e2865a923167bce06b6dfac85eb97d6dada..69a26936a3fb0def21c515dce94acfe4ac6d1379 100644 (file)
@@ -97,6 +97,9 @@ protected:
   /// Restore the multi selection state
   virtual void stopOperation();
 
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
+
   /// Creates an operation new feature
   /// In addition to the default realization it appends the created line feature to
   /// the sketch feature