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();
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()));
}
}
/// \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();
// 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()) {
aSelAttr->setValue(aRes, aShapePtr);
}
}
+ } else {
+ // Turn viewer to the plane
+ emit planeSelected(aDir->x(), aDir->y(), aDir->z());
}
+ emit launchSketch();
}
}
}
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);
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;
}
/// 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);
// 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.