From d09c80de35c59f76714c776b456ce436409f9a3c Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 5 Nov 2014 12:35:22 +0300 Subject: [PATCH] Issue #205: Rotate view on selection of sketch plane and not rotate on selection of a face --- src/PartSet/PartSet_Module.cpp | 5 +++++ src/PartSet/PartSet_Module.h | 3 +++ src/PartSet/PartSet_OperationSketch.cpp | 18 ++++++++++-------- src/PartSet/PartSet_OperationSketch.h | 6 +++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ad9210e3f..221dc5f16 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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())); } } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index f5851100c..a3a188ad0 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -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(); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 29889ab5d..10f6a345d 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -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 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 PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) { if (theShape.IsNull()) - return; + return boost::shared_ptr(); // get selected shape boost::shared_ptr 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 aDir = aPlane->direction(); - - flushUpdated(); - - emit featureConstructed(feature(), FM_Hide); - emit planeSelected(aDir->x(), aDir->y(), aDir->z()); + return aDir; } diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 47601096f..eb3fa84f4 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -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 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. -- 2.39.2