From 5c0a5d1054fc9d185ab08b77583aa7cc4453d41a Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 24 Mar 2016 11:49:22 +0300 Subject: [PATCH] Issue #1343 Improvement of Extrusion and Revolution operations: removeFeature is corrected to remove Sketch from reference; extrusion/revolution sketches are hidden; display is flushed after sketch hide in the sketch operation widget. --- .../FeaturesPlugin_CompositeSketch.cpp | 2 + src/FeaturesPlugin/plugin-Features.xml | 8 +- src/FeaturesPlugin/revolution_widget.xml | 14 --- .../GeomValidators_FeatureKind.cpp | 2 +- src/PartSet/PartSet_WidgetSketchCreator.cpp | 89 ++++++++++--------- 5 files changed, 53 insertions(+), 62 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 3d8ce83ef..57a711e0c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -88,6 +88,8 @@ void FeaturesPlugin_CompositeSketch::removeFeature(std::shared_ptrsize() > 0) aFacesSelectionList->clear(); + + data()->reference(SKETCH_OBJECT_ID())->setValue(ObjectPtr()); } //================================================================================================= diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index fe897b2a5..9f5cbd74e 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -6,9 +6,9 @@ - + @@ -20,9 +20,9 @@ - + diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index 73ed217c7..a7a5b82d2 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -18,13 +18,6 @@ - - - - - - #include -//#define DEBUG_EXTRUSION_INVALID_SKETCH +#define DEBUG_EXTRUSION_INVALID_SKETCH #ifdef DEBUG_EXTRUSION_INVALID_SKETCH #include #endif diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 8243a253a..2c44b55fd 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -202,8 +202,6 @@ bool PartSet_WidgetSketchCreator::canCommitCurrentSketch(ModuleBase_IWorkshop* t if (!aIsOp) aMgr->startOperation(); aPCompositeFeature->execute(); // to fill attribute selection list - if (!aIsOp) - aMgr->finishOperation(); std::list aSelListAttributes = aParentFeature->data()->attributes( ModelAPI_AttributeSelectionList::typeId()); @@ -226,6 +224,12 @@ bool PartSet_WidgetSketchCreator::canCommitCurrentSketch(ModuleBase_IWorkshop* t aCanCommit = false; } } + if (!aIsOp) { + if (aCanCommit) + aMgr->finishOperation(); + else + aMgr->abortOperation(); + } } } return aCanCommit; @@ -383,49 +387,48 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) // do nothing, selection control should be shown activateSelectionControl(); - return; - } - // do nothing, selection control should be hidden - setVisibleSelectionControl(false); - // Update value in attribute selection list - XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel(); - const QList& aWidgets = aPanel->modelWidgets(); - foreach(ModuleBase_ModelWidget* aWidget, aWidgets) { - if (aWidget->attributeID() == myAttributeListID) - aWidget->restoreValue(); - } - - // Hide sketcher result - CompositeFeaturePtr aSketchFeature = - std::dynamic_pointer_cast(aCompFeature->subFeature(0)); - std::list aResults = aSketchFeature->results(); - std::list::const_iterator aIt; - for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { - (*aIt)->setDisplayed(false); } - aSketchFeature->setDisplayed(false); - - // restore value in the selection control - + else { + setVisibleSelectionControl(false); + // Update value in attribute selection list + XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel(); + const QList& aWidgets = aPanel->modelWidgets(); + foreach(ModuleBase_ModelWidget* aWidget, aWidgets) { + if (aWidget->attributeID() == myAttributeListID) + aWidget->restoreValue(); + } - // Add Selected body were created the sketcher to list of selected objects - std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); - AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); - if (aSelList.get()) { - DataPtr aData = aSketchFeature->data(); - AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr(); - if (aRes.get()) { - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); - std::string aValidatorID, anError; - aSelList->append(aRes, GeomShapePtr()); - if (aFactory->validate(anAttribute, aValidatorID, anError)) - updateObject(aCompFeature); - else - aSelList->clear(); + // Hide sketcher result + CompositeFeaturePtr aSketchFeature = + std::dynamic_pointer_cast(aCompFeature->subFeature(0)); + std::list aResults = aSketchFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + (*aIt)->setDisplayed(false); + } + aSketchFeature->setDisplayed(false); + static Events_Loop* aLoop = Events_Loop::loop(); + aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + + // Add Selected body were created the sketcher to list of selected objects + std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); + AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); + if (aSelList.get()) { + DataPtr aData = aSketchFeature->data(); + AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr(); + if (aRes.get()) { + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); + std::string aValidatorID, anError; + aSelList->append(aRes, GeomShapePtr()); + if (aFactory->validate(anAttribute, aValidatorID, anError)) + updateObject(aCompFeature); + else + aSelList->clear(); + } } } } -- 2.39.2