- CompositeFeaturePtr aCompFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
- if (aCompFeature->numberOfSubs() == 0)
- connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
-}
-
-void PartSet_WidgetSketchCreator::onStarted()
-{
- disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
-
- // Check that model already has bodies
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- XGUI_Displayer* aDisp = aWorkshop->displayer();
- QObjectPtrList aObjList = aDisp->displayedObjects();
- bool aHasBody = false;
- ResultBodyPtr aBody;
- foreach(ObjectPtr aObj, aObjList) {
- aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
- if (aBody.get() != NULL) {
- aHasBody = true;
- break;
+ AttributePtr anAttribute;
+ if (myIsCustomAttribute)
+ anAttribute = myFeature->attribute(myAttributeListID);
+ else
+ anAttribute = ModuleBase_WidgetSelector::attribute();
+
+ return anAttribute;
+}
+
+//********************************************************************
+void PartSet_WidgetSketchCreator::openExtrusionTransaction()
+{
+ 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_ViewerPrsPtr& theValue)
+{
+ bool aValid = false;
+ if (myIsCustomAttribute) {
+ // check only suiting of the value to custom attribute (myAttributeListID)
+ // do not cash of validation to avoid using states, stored for XML attribute
+ // there is an alternative is to call clearValidatedCash() in setSelection()
+ aValid = isValidSelectionForAttribute(theValue, attribute());
+ }
+ else { /// if the validated attribute is already custom
+ if (getValidState(theValue, aValid)) {
+ return aValid;
+ }
+ aValid = isValidSelectionCustom(theValue);
+ if (!aValid)
+ // check selection to create new sketh (XML current attribute)
+ aValid = isValidSelectionForAttribute(theValue, attribute());
+ if (!aValid) {
+ // check selection to fill list attribute (myAttributeListID)
+ bool isCustomAttribute = myIsCustomAttribute;
+ myIsCustomAttribute = true;
+ aValid = isValidSelectionForAttribute(theValue, attribute());
+ myIsCustomAttribute = isCustomAttribute;
+ }
+ }
+ storeValidState(theValue, aValid);
+ return aValid;
+}
+
+//********************************************************************
+bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue)
+{
+ return PartSet_WidgetSketchLabel::canFillSketch(theValue);
+}
+
+void PartSet_WidgetSketchCreator::activateSelectionControl()
+{
+ // reset previously set size of view needed on restart extrusion after Sketch
+ if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
+ myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
+
+ // we need to call activate here as the widget has no focus accepted controls
+ // if these controls are added here, activate will happens automatically after focusIn()
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
+ XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
+ aPanel->activateWidget(this, false);
+}
+
+void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
+{
+ // hide current widget, activate the next widget
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
+ XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
+ const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
+ foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (theSelectionControl) { // hide other controls
+ if (aWidget != this)
+ aWidget->setVisible(false);
+ }
+ else { // hide current control
+ if (aWidget == this)
+ aWidget->setVisible(false);
+ else {
+ aWidget->setVisible(true);
+ if (aWidget->attributeID() == myAttributeListID)
+ setEnabledModelWidget(aWidget, !hasSubObjects());
+ }