ModelAPI_CompositeFeature::erase();
}
-//=================================================================================================
-void FeaturesPlugin_CompositeSketch::setSketchObjectToList()
-{
- AttributeSelectionListPtr aBaseObjectsSelectionList = selectionList(BASE_OBJECTS_ID());
- if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
- return;
- }
-
- AttributeReferencePtr aSketchLauncherRef = reference(SKETCH_ID());
- if(!aSketchLauncherRef.get() || !aSketchLauncherRef->isInitialized()) {
- return;
- }
-
- FeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aSketchLauncherRef->value());
-
- if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
- return;
- }
-
- ResultPtr aSketchRes = aSketchFeature->results().front();
- ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
- if(!aConstruction.get()) {
- return;
- }
-
- if(aBaseObjectsSelectionList->size() == 0) {
- aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
- }
-}
-
//=================================================================================================
void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesList,
const bool theIsMakeShells)
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_ResultConstruction.h>
#include <SketchPlugin_SketchEntity.h>
#include <FeaturesPlugin_CompositeBoolean.h>
return anAttribute;
}
+//********************************************************************
+void PartSet_WidgetSketchCreator::openTransaction()
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ bool aIsOp = aMgr->isOperation();
+ if (!aIsOp) {
+ const static std::string aNestedOpID("Parameters modification");
+ aMgr->startOperation(aNestedOpID, true);
+ }
+}
+
//********************************************************************
bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrs& theValue)
{
bool aIsOp = aMgr->isOperation();
if (!aIsOp)
aMgr->startOperation();
- aPCompositeFeature->execute(); // to fill attribute selection list
std::list<AttributePtr> aSelListAttributes = aParentFeature->data()->attributes(
ModelAPI_AttributeSelectionList::typeId());
if (aSelListAttributes.size() == 1) {
AttributePtr aFirstAttribute = aSelListAttributes.front();
+ /// Sub-feature of the composite should be set in the base list.
+ setSketchObjectToList(aPCompositeFeature, aFirstAttribute);
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
return aCanCommit;
}
+void PartSet_WidgetSketchCreator::setSketchObjectToList(const CompositeFeaturePtr& theCompositeFeature,
+ const AttributePtr& theAttribute)
+{
+ if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
+ return;
+
+ AttributeSelectionListPtr aBaseObjectsSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
+ return;
+ }
+
+ FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
+ if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
+ return;
+ }
+
+ ResultPtr aSketchRes = aSketchFeature->results().front();
+ ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
+ if(!aConstruction.get()) {
+ return;
+ }
+
+ if(aBaseObjectsSelectionList->size() == 0) {
+ aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
+ }
+}
+
bool PartSet_WidgetSketchCreator::isSelectionMode() const
{
AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
{
if (isSelectionMode()) {
activateSelectionControl();
-
- SessionPtr aMgr = ModelAPI_Session::get();
- bool aIsOp = aMgr->isOperation();
- if (!aIsOp)
- aMgr->startOperation(myFeature->getKind());
+ // Open transaction that is general for the previous nested one: it will be closed on nested commit
+ openTransaction();
return true;
}
else {
- //setVisibleSelectionControl(false);
-
connect(myModule, SIGNAL(resumed(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();
- if (!aIsOp) {
- const static std::string aNestedOpID("Parameters modification");
- aMgr->startOperation(aNestedOpID, true);
- }
+ openTransaction();
restoreValue();
}
return false;