#include <ModelAPI_Session.h>
#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
+
+#include <SketchPlugin_SketchEntity.h>
+#include <FeaturesPlugin_CompositeBoolean.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_Operation.h>
return aControls;
}
-bool PartSet_WidgetSketchCreator::restoreValue()
+bool PartSet_WidgetSketchCreator::restoreValueCustom()
{
CompositeFeaturePtr aCompFeature =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
if (aCompFeature->numberOfSubs() == 0)
return ModuleBase_ModelWidget::focusTo();
- CompositeFeaturePtr aSketchFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
- if (aSketchFeature->numberOfSubs() == 0) {
- connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
- }
+ 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;
void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
{
- // Abort operation
- SessionPtr aMgr = ModelAPI_Session::get();
- bool aIsOp = aMgr->isOperation();
- // Close transaction
- if (aIsOp)
- aMgr->abortOperation();
- theOp->abort();
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ CompositeFeaturePtr aSketchFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
+ if (aSketchFeature->numberOfSubs() == 0) {
+ // Abort operation
+ SessionPtr aMgr = ModelAPI_Session::get();
+ // Close transaction
+ /*
+ bool aIsOp = aMgr->isOperation();
+ if (aIsOp) {
+ const static std::string aNestedOpID("Parameters cancelation");
+ aMgr->startOperation(aNestedOpID, true);
+ }
+ */
+ theOp->abort();
+ } else {
+ // Hide sketcher result
+ std::list<ResultPtr> aResults = aSketchFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ (*aIt)->setDisplayed(false);
+ }
+ aSketchFeature->setDisplayed(false);
+
+ // Add Selected body were created the sketcher to list of selected objects
+ DataPtr aData = aSketchFeature->data();
+ AttributeSelectionPtr aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+ if (aSelAttr.get()) {
+ ResultPtr aRes = aSelAttr->context();
+ GeomShapePtr aShape = aSelAttr->value();
+ if (aRes.get()) {
+ AttributeSelectionListPtr aSelList =
+ aCompFeature->data()->selectionList(FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID());
+ aSelList->append(aRes, GeomShapePtr());
+ updateObject(aCompFeature);
+ }
+ }
+ }
}