]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Switch off multi selection during line edit operation.
authornds <natalia.donis@opencascade.com>
Thu, 8 May 2014 13:31:29 +0000 (17:31 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 8 May 2014 13:31:29 +0000 (17:31 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.h

index 0939b57fe7a371673b623d07d00a56a11ed7d672..82321d023d8b9ebb84c3d9054372a530a172ea33 100644 (file)
@@ -120,6 +120,8 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
   if (!theOperation)
     return;
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
+  if (aPreviewOp) {
+  }
 }
 
 void PartSet_Module::onSelectionChanged()
@@ -209,6 +211,12 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<Mo
   sendOperation(anOperation);
 }
 
+void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
+{
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  aViewer->enableMultiselection(theEnabled);
+}
+
 void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
                                           int theMode)
 {
@@ -257,6 +265,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
             this, SLOT(onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature>, int)));
     connect(aPreviewOp, SIGNAL(launchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)),
             this, SLOT(onLaunchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)));
+    connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
+            this, SLOT(onMultiSelectionEnabled(bool)));
 
     PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
     if (aSketchOp) {
@@ -264,6 +274,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
               this, SLOT(onPlaneSelected(double, double, double)));
     }
   }
+
   return anOperation;
 }
 
index 03207f25273d751d8110922cf89607d0efe39706..75dbd306390625c6ae50b52cf6e1cb00b7226f5e 100644 (file)
@@ -46,8 +46,8 @@ public:
 
 public slots:
   void onFeatureTriggered();
-  /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
-  /// from the viewer selection and show the sketch preview.
+  /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
+  /// by the operation start
   void onOperationStopped(ModuleBase_Operation* theOperation);
 
   /// SLOT, that is called by the selection in the viewer is changed.
@@ -78,6 +78,10 @@ public slots:
 
   void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
 
+  /// SLOT, to switch on/off the multi selection in the viewer
+  /// \param theEnabled the enabled state
+  void onMultiSelectionEnabled(bool theEnabled);
+
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
   /// \param theMode the mode appeared on the feature
index 46f3b4056127880237f6253f3bbcaa76bea6f374..92ae140d2e630a8716f7b6f7d9fa1148a7fa5ed9 100644 (file)
@@ -94,6 +94,12 @@ void PartSet_OperationEditLine::setSelected(boost::shared_ptr<ModelAPI_Feature>
 void PartSet_OperationEditLine::startOperation()
 {
   // do nothing in order to do not create a new feature
+  emit multiSelectionEnabled(false);
+}
+
+void PartSet_OperationEditLine::stopOperation()
+{
+  emit multiSelectionEnabled(true);
 }
 
 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature()
index 01a705386ccaf5d89919cbd8d3c8f426a58cf238..646416f91aeb6eaa7003bba0390e111164c2caab 100644 (file)
@@ -64,9 +64,13 @@ public:
 protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
-  /// After the parent operation body perform, set sketch feature to the created line feature
+  /// Switch off the multi selection state
   virtual void startOperation();
 
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// Restore the multi selection state
+  virtual void stopOperation();
+
   /// Creates an operation new feature
   /// Returns NULL feature. This is an operation of edition, not creation.
   /// \returns the created feature
index 46b0c4ca2a70d4da3dd3389c596dbea623b2762e..b07fd0dff107d841cc110a82eeb1c8c7891ffca7 100644 (file)
@@ -60,6 +60,9 @@ void PartSet_OperationSketch::setSelected(boost::shared_ptr<ModelAPI_Feature> th
 
 void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
 {
+  if (theShape.IsNull())
+    return;
+
   // get selected shape
   boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
   aGShape->setImpl(new TopoDS_Shape(theShape));
index 45a6b77d4d0c18cdbe390610a4a5dc3f30ef2b3e..0fce89ea66d44db25da948913967aec24e61b25e 100644 (file)
@@ -86,6 +86,9 @@ signals:
   /// theName the operation name
   /// theFeature the operation argument
   void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// signal to enable/disable multi selection in the viewer
+  /// \param theEnabled the boolean state
+  void multiSelectionEnabled(bool theEnabled);
 
 protected:
   /// Creates an operation new feature