]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #205: Rotate view on selection of sketch plane and not rotate on selection...
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 5 Nov 2014 09:35:22 +0000 (12:35 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 5 Nov 2014 09:35:22 +0000 (12:35 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h

index ad9210e3fdb37a573d6c2ef9090970bbac241e2e..221dc5f161ce2b05cb58bf7da8b024fca840ad7b 100644 (file)
@@ -264,6 +264,10 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
 void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
 {
   myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
+}
+
+void PartSet_Module::onSketchLaunched()
+{
   xWorkshop()->actionsMgr()->update();
   // Set working plane
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
@@ -444,6 +448,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
       connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
               SLOT(onPlaneSelected(double, double, double)));
       connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
+      connect(aSketchOp, SIGNAL(launchSketch()), this, SLOT(onSketchLaunched()));
     }
   }
 
index f5851100ce749aa309c4dd6dc8367c7d74f60aee..a3a188ad0347ff9a10f376b7bc06d3f382f84928 100644 (file)
@@ -107,6 +107,9 @@ Q_OBJECT
   /// \param the attribute of the feature
   void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
+  /// Called when sketch is launched
+  void onSketchLaunched();
+
 protected slots:
   /// Called on selection changed event
   virtual void onSelectionChanged();
index 29889ab5d4453e1b6144904c1fbf985d6c136289..10f6a345d351f01055ee456844d9b3c3bd7f1674 100644 (file)
@@ -99,7 +99,9 @@ void PartSet_OperationSketch::selectionChanged(ModuleBase_ISelection* theSelecti
     // We have to select a plane before any operation
     TopoDS_Shape aShape = aPrs.shape();
     if (!aShape.IsNull()) {
-      setSketchPlane(aShape);
+      boost::shared_ptr<GeomAPI_Dir> aDir = setSketchPlane(aShape);
+      flushUpdated();
+      emit featureConstructed(feature(), FM_Hide);
       // If selection is not a sketcher presentation then it has to be stored as 
       // External shape
       if (feature() != aPrs.object()) {
@@ -117,7 +119,11 @@ void PartSet_OperationSketch::selectionChanged(ModuleBase_ISelection* theSelecti
             aSelAttr->setValue(aRes, aShapePtr);
           }
         }
+      } else {
+        // Turn viewer to the plane
+        emit planeSelected(aDir->x(), aDir->y(), aDir->z());
       }
+      emit launchSketch();
     }
   }
 }
@@ -222,10 +228,10 @@ bool PartSet_OperationSketch::hasSketchPlane() const
   return aHasPlane;
 }
 
-void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
+boost::shared_ptr<GeomAPI_Dir> PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
 {
   if (theShape.IsNull())
-    return;
+    return boost::shared_ptr<GeomAPI_Dir>();
 
   // get selected shape
   boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
@@ -266,11 +272,7 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
       aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
   aDirY->setValue(aYDir);
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-
-  flushUpdated();
-
-  emit featureConstructed(feature(), FM_Hide);
-  emit planeSelected(aDir->x(), aDir->y(), aDir->z());
+  return aDir;
 }
 
 
index 47601096f7b1af293facbb3c9fd3e2daf98aeb70..eb3fa84f4a182368c025a3d64b05881d1ea6ecfa 100644 (file)
@@ -86,7 +86,8 @@ Q_OBJECT
 
   /// Set the plane to the current sketch
   /// \param theShape the shape
-  void setSketchPlane(const TopoDS_Shape& theShape);
+  /// \return selected direction
+  boost::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
   
   /// Called on selection changed when the operation is active
   virtual void selectionChanged(ModuleBase_ISelection* theSelection);
@@ -104,6 +105,9 @@ signals:
   // signal about the viewer fit all perform
   void fitAllView();
 
+  /// Signal to define sketch mode
+  void launchSketch();
+
  protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.