X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchCreator.cpp;h=f7a52416e4597dfd8c20d04e28b7ab0743378680;hb=857b1f72d9703c46c6c8c9bb239821d314344c86;hp=a5d9cddb13958f9ebfd58a3aad2afd58ea5f32a2;hpb=ed4ac37cbf8f2c8e5665ff6251c9e21e4b8c497e;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index a5d9cddb1..f7a52416e 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include @@ -69,7 +71,7 @@ QList PartSet_WidgetSketchCreator::getControls() const return aControls; } -bool PartSet_WidgetSketchCreator::restoreValue() +bool PartSet_WidgetSketchCreator::restoreValueCustom() { CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast(myFeature); @@ -118,13 +120,17 @@ void PartSet_WidgetSketchCreator::onStarted() std::dynamic_pointer_cast(myFeature); FeaturePtr aSketch = aCompFeature->addFeature("Sketch"); - ModuleBase_Operation* anOperation = myModule->createOperation("Sketch"); - anOperation->setFeature(aSketch); - myModule->sendOperation(anOperation); + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (myModule->createOperation("Sketch")); + if (aFOperation) + aFOperation->setFeature(aSketch); + myModule->sendOperation(aFOperation); //connect(anOperation, SIGNAL(aborted()), aWorkshop->operationMgr(), SLOT(abortAllOperations())); } else { // Break current operation - QMessageBox::warning(this, tr("Extrusion Cut"), + std::string anOperationName = feature()->getKind(); + QString aTitle = tr( anOperationName.c_str() ); + QMessageBox::warning(this, aTitle, tr("There are no bodies found. Operation aborted."), QMessageBox::Ok); ModuleBase_Operation* aOp = myModule->workshop()->currentOperation(); aOp->abort(); @@ -140,10 +146,12 @@ bool PartSet_WidgetSketchCreator::focusTo() connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*))); SessionPtr aMgr = ModelAPI_Session::get(); + // Open transaction that is general for the previous nested one: it will be closed on nested commit bool aIsOp = aMgr->isOperation(); - // Open transaction if it was closed before - if (!aIsOp) - aMgr->startOperation(); + if (!aIsOp) { + const static std::string aNestedOpID("Parameters modification"); + aMgr->startOperation(aNestedOpID, true); + } restoreValue(); return false; @@ -158,10 +166,14 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) if (aSketchFeature->numberOfSubs() == 0) { // Abort operation SessionPtr aMgr = ModelAPI_Session::get(); - bool aIsOp = aMgr->isOperation(); // Close transaction - if (aIsOp) - aMgr->abortOperation(); + /* + bool aIsOp = aMgr->isOperation(); + if (aIsOp) { + const static std::string aNestedOpID("Parameters cancelation"); + aMgr->startOperation(aNestedOpID, true); + } + */ theOp->abort(); } else { // Hide sketcher result @@ -181,10 +193,17 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) ResultPtr aRes = aSelAttr->context(); GeomShapePtr aShape = aSelAttr->value(); if (aRes.get()) { - AttributeSelectionListPtr aSelList = - aCompFeature->data()->selectionList(FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID()); + std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); + std::string aValidatorID, anError; + AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); aSelList->append(aRes, GeomShapePtr()); - updateObject(aCompFeature); + if (aFactory->validate(anAttribute, aValidatorID, anError)) + updateObject(aCompFeature); + else + aSelList->clear(); } } }