X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchCreator.cpp;h=34762063035f07a42ddf357d035d7845ab6a4564;hb=04dcca50b319e65e5141be7f6c329a2e1cf94718;hp=c93c585168ca2800627b4d90a8a265956f4d1ae5;hpb=c878326ca3cbca11878476015e2ef3607461a0a5;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index c93c58516..347620630 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -7,6 +7,8 @@ #include "PartSet_WidgetSketchCreator.h" #include "PartSet_Module.h" +#include + #include #include #include @@ -39,7 +41,7 @@ PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule, const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId), myModule(theModule) +: ModuleBase_ModelWidget(theParent, theData, theParentId), myModule(theModule), myUseBody(true) { QFormLayout* aLayout = new QFormLayout(this); ModuleBase_Tools::adjustMargins(aLayout); @@ -57,6 +59,11 @@ PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent, myTextLine->setToolTip(aToolTip); myTextLine->installEventFilter(this); + QString aUseBody = QString::fromStdString(theData->getProperty(USE_BODY)); + if(!aUseBody.isEmpty()) { + myUseBody = QVariant(aUseBody).toBool(); + } + aLayout->addRow(myLabel, myTextLine); } @@ -104,13 +111,15 @@ void PartSet_WidgetSketchCreator::onStarted() XGUI_Workshop* aWorkshop = aConnector->workshop(); XGUI_Displayer* aDisp = aWorkshop->displayer(); QObjectPtrList aObjList = aDisp->displayedObjects(); - bool aHasBody = false; + bool aHasBody = !myUseBody; ResultBodyPtr aBody; - foreach(ObjectPtr aObj, aObjList) { - aBody = std::dynamic_pointer_cast(aObj); - if (aBody.get() != NULL) { - aHasBody = true; - break; + if(!aHasBody) { + foreach(ObjectPtr aObj, aObjList) { + aBody = std::dynamic_pointer_cast(aObj); + if (aBody.get() != NULL) { + aHasBody = true; + break; + } } } @@ -184,24 +193,27 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) } 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 - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - if (aSelAttr.get()) { - ResultPtr aRes = aSelAttr->context(); - GeomShapePtr aShape = aSelAttr->value(); - if (aRes.get()) { - 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; - if (aFactory->validate(anAttribute, aValidatorID, anError)) { + if(myUseBody) { + // Add Selected body were created the sketcher to list of selected objects + DataPtr aData = aSketchFeature->data(); + AttributeSelectionPtr aSelAttr = + std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + if (aSelAttr.get()) { + ResultPtr aRes = aSelAttr->context(); + GeomShapePtr aShape = aSelAttr->value(); + if (aRes.get()) { + 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(); } } }