X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPartSet%2FPartSet_Module.cpp;h=97f253c6766468ff7f7dae10564be001c944d3e4;hb=0bf596dd0b3bb3cde5e14ed00efdf0565d460591;hp=ec21e026619bcc21858f88d50e4c5a3254956d19;hpb=8dc74f82810d5f597b78633b457efb0ef4f89f9f;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ec21e0266..97f253c67 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -49,6 +49,9 @@ #include #include +#include +#include + #include #include #include @@ -106,7 +109,7 @@ XGUI_Workshop* PartSet_Module::workshop() const void PartSet_Module::createFeatures() { //Registering of validators - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator); aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator); @@ -124,11 +127,6 @@ void PartSet_Module::featureCreated(QAction* theFeature) connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered())); } -QStringList PartSet_Module::nestedFeatures(QString) -{ - return QStringList(); -} - std::string PartSet_Module::featureFile(const std::string& theFeatureId) { return myFeaturesInFiles[theFeatureId]; @@ -283,24 +281,21 @@ void PartSet_Module::onFitAllView() myWorkshop->viewer()->fitAll(); } -void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject) +void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject) { FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - if (!aFeature) { - qDebug("Warning! Restart operation without feature!"); - return; - } - ModuleBase_Operation* anOperation = createOperation(theName.c_str(), - aFeature ? aFeature->getKind() : ""); - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (aPreviewOp) { + + std::string aKind = aFeature ? aFeature->getKind() : ""; + ModuleBase_Operation* anOperation = createOperation(theName, aKind); + PartSet_OperationSketchBase* aSketchOp = dynamic_cast(anOperation); + if (aSketchOp) { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); // Initialise operation with preliminary selection std::list aSelected = aSelection->getSelected(); std::list aHighlighted = aSelection->getHighlighted(); - aPreviewOp->initFeature(aFeature); - aPreviewOp->initSelection(aSelected, aHighlighted); - } else { + aSketchOp->initFeature(aFeature); + aSketchOp->initSelection(aSelected, aHighlighted); + } else if (aFeature) { anOperation->setEditingFeature(aFeature); //Deactivate result of current feature in order to avoid its selection XGUI_Displayer* aDisplayer = myWorkshop->displayer(); @@ -347,6 +342,7 @@ void PartSet_Module::onSetSelection(const QList& theFeatures) void PartSet_Module::onCloseLocalContext() { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->deactivateObjectsOutOfContext(); aDisplayer->closeLocalContexts(); } @@ -411,14 +407,16 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); FeaturePtr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); - if (aPrevOp) + if (aPrevOp) { aSketch = aPrevOp->sketch(); - if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) + } + if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) { anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch); - else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) + } else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) { anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch); - else if (theCmdId == PartSet_OperationFeatureEdit::Type()) + } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) { anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch); + } } if (!anOperation) { @@ -451,8 +449,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI if (aPreviewOp) { connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this, SLOT(onFeatureConstructed(ObjectPtr, int))); - connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), this, - SLOT(onLaunchOperation(std::string, ObjectPtr))); + connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this, + SLOT(onRestartOperation(std::string, ObjectPtr))); connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); @@ -477,8 +475,9 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI 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); + boost::shared_ptr aMessage = + boost::shared_ptr(new Config_PointerMessage(aModuleEvent, this)); + aMessage->setPointer(theOperation); Events_Loop::loop()->send(aMessage); } @@ -519,6 +518,13 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPreviewOp->getSelectionModes(theFeature); aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer); + + // If this is a Sketcher then activate objects (planar faces) outside of context + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp) { + Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane); + aDisplayer->activateObjectsOutOfContext(aModes, aFilter); + } } } @@ -577,7 +583,7 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) //} //if (aFeature) { - onLaunchOperation(theFeature->getKind(), theFeature); + onRestartOperation(theFeature->getKind(), theFeature); updateCurrentPreview(theFeature->getKind()); //} // }