-void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
-{
- static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
- Config_PointerMessage aMessage(aModuleEvent, this);
- aMessage.setPointer(theOperation);
- Events_Loop::loop()->send(aMessage);
-}
-
-boost::shared_ptr<GeomAPI_Shape> getPlane(double theX, double theY, double theZ)
-{
- boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
- boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
- return GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
-}
-
-void PartSet_Module::showPlanes()
-{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- // Show selection planes
- if (!myXPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneX = getPlane(1, 0, 0);
- myXPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myXPlane->createShape(aPlaneX);
- myXPlane->setColor(Colors::COLOR_RED);
- myXPlane->setWidth(SKETCH_WIDTH);
- }
- if (!myYPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneY = getPlane(0, 1, 0);
- myYPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myYPlane->createShape(aPlaneY);
- myYPlane->setColor(Colors::COLOR_GREEN);
- myYPlane->setWidth(SKETCH_WIDTH);
- }
- if (!myZPlane) {
- boost::shared_ptr<GeomAPI_Shape> aPlaneZ = getPlane(0, 0, 1);
- myZPlane = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
- myZPlane->createShape(aPlaneZ);
- myZPlane->setColor(Colors::COLOR_BLUE);
- myZPlane->setWidth(SKETCH_WIDTH);
- }
- aDisplayer->display(myXPlane, false);
- aDisplayer->display(myYPlane, false);
- aDisplayer->display(myZPlane, false);
- aDisplayer->updateViewer();
-}
-
-void PartSet_Module::erasePlanes()
-{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->erase(myXPlane, false);
- aDisplayer->erase(myYPlane, false);
- aDisplayer->erase(myZPlane, false);
- aDisplayer->updateViewer();
-}
-
-void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
- const bool isUpdateViewer)
-{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- if (!anOperation)
- return;
-
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (!aPreviewOp)
- return;
-
- ResultPtr aResult = theFeature->firstResult();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- if (isDisplay) {
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
- if (aSPFeature) {
- PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (aSketchOp && !aSketchOp->hasSketchPlane())
- showPlanes();
- }
- }
- else
- aDisplayer->erase(aResult, false);
-
- if (isUpdateViewer)
- aDisplayer->updateViewer();
-}
-
-void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
-{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
- PartSet_OperationSketch* aOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
- if (!aOp) {
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
- isUpdateViewer);
- }
- }
-}