bool ModuleBase_Operation::activateByPreselection()
{
- if (!myPropertyPanel)
- return false;
- if (myPreSelection.empty())
+ if (!myPropertyPanel || myPreSelection.empty()) {
+ myPropertyPanel->activateNextWidget(NULL);
return false;
+ }
const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
- if (aWidgets.empty())
+ if (aWidgets.empty()) {
+ myPropertyPanel->activateNextWidget(NULL);
return false;
+ }
ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
aFilledWgt = aWgt;
}
}
- if (isSet && canBeCommitted()) {
- // if all widgets are filled with selection - commit
- // in order to commit the operation outside of starting procedure - use timer event
- QTimer::singleShot(50, this, SLOT(commit()));
+
+ if (aFilledWgt) {
+ myPropertyPanel->activateNextWidget(aFilledWgt);
+ emit activatedByPreselection();
return true;
}
- else {
- //activate next widget
- if (aFilledWgt) {
- myPropertyPanel->activateNextWidget(aFilledWgt);
- return true;
- }
- }
+ else
+ myPropertyPanel->activateNextWidget(NULL);
return false;
}
void stopped(); /// the operation is aborted or committed
void resumed(); /// the operation is resumed
void postponed(); /// the operation is postponed
+ void activatedByPreselection(); /// the operation is filled with existing preselection
public slots:
/// Starts operation
//QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations();
QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
- if (aSelected.size() > 0)
- setSelection(aSelected.first());
+ if (aSelected.size() > 0) {
+ if (setSelection(aSelected.first()))
+ emit focusOutWidget(this);
+ }
}
//********************************************************************
}
if (isValid(aObject, aShape)) {
setObject(aObject, aShape);
- emit focusOutWidget(this);
return true;
}
return false;
XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
+ connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
+ this, SLOT(onOperationActivatedByPreselection()));
connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
myRestartingMode = RM_EmptyFeatureUsed;
}
+void PartSet_Module::onOperationActivatedByPreselection()
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (!aOperation)
+ return;
+
+ // Set final definitions if they are necessary
+ //propertyPanelDefined(aOperation);
+
+ /// Commit sketcher operations automatically
+ FeaturePtr aFeature = aOperation->feature();
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSPFeature) {
+ aOperation->commit();
+ }
+}
+
void PartSet_Module::onNoMoreWidgets()
{
ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
/// Set a specific type of restarting the current operation
void onEnterReleased();
+ /// SLOT, that is called by the current operation filling with the preselection.
+ /// It commits the operation of it is can be committed
+ void onOperationActivatedByPreselection();
+
/// Launches the operation from current highlighting
void launchEditing();
connect(theOperation, SIGNAL(committed()), SLOT(onOperationComitted()));
connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
+ connect(theOperation, SIGNAL(activatedByPreselection()),
+ SIGNAL(operationActivatedByPreselection()));
theOperation->start();
onValidateOperation();
/// Signal is emitted after the validate methods calls.
void operationValidated(bool);
+ /// Signal is emitted after the current operation is filled with existing preselection.
+ void operationActivatedByPreselection();
+
/// Signal is emitted after the key released click.
void keyEnterReleased();
+
protected:
/// Commits the current operatin if it is valid
// Do not activate widgets by default if the current operation is editing operation
// Because we don't know which widget is going to be edited.
if ((!aOperation->isEditOperation())) {
- if (!aOperation->activateByPreselection())
- myPropertyPanel->activateNextWidget(NULL);
+ aOperation->activateByPreselection();
}
// Set final definitions if they are necessary
myModule->propertyPanelDefined(aOperation);