#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_ISelection.h"
#include "ModuleBase_IViewer.h"
+#include "ModuleBase_Tools.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
}*/
}
- if (theFlushMessage)
+ if (theFlushMessage) {
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ }
return myFeature;
}
return false;
}
-void ModuleBase_OperationFeature::activateByPreselection()
+ModuleBase_ModelWidget* ModuleBase_OperationFeature::activateByPreselection(
+ const std::string& theGreedAttributeId)
{
+ ModuleBase_ModelWidget* aWidget = 0;
if (myPreSelection.empty())
- return;
-
+ return aWidget;
+ // equal vertices should not be used here
ModuleBase_ISelection::filterSelectionOnEqualPoints(myPreSelection);
- ModuleBase_ModelWidget* aFilledWgt = 0;
ModuleBase_IPropertyPanel* aPropertyPanel = propertyPanel();
+ ModuleBase_ModelWidget* aFilledWgt = 0;
if (aPropertyPanel) {
const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+ QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+ ModuleBase_ModelWidget* aWgt = 0;
if (!aWidgets.empty()) {
- ModuleBase_ModelWidget* aWgt = 0;
- QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
- bool isSet = false;
- // 1. apply the selection to controls
- for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
- aWgt = (*aWIt);
- if (!aWgt->canSetValue())
- continue;
- aPropertyPanel->setPreselectionWidget(aWgt);
- if (!aWgt->setSelection(myPreSelection, true)) {
- isSet = false;
- break;
- } else {
- isSet = true;
- aFilledWgt = aWgt;
+ if (!theGreedAttributeId.empty()) {
+ // set preselection to greed widget
+ for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
+ aWgt = (*aWIt);
+ if (aWgt->attributeID() == theGreedAttributeId) {
+ aPropertyPanel->setPreselectionWidget(aWgt);
+ aWgt->setSelection(myPreSelection, true);
+ aPropertyPanel->setPreselectionWidget(NULL);
+ aFilledWgt = aWgt;
+ break;
+ }
+ }
+ }
+ else {
+ bool isSet = false;
+ // 1. apply the selection to controls
+ for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
+ aWgt = (*aWIt);
+ if (!aWgt->canAcceptFocus())
+ continue;
+ aPropertyPanel->setPreselectionWidget(aWgt);
+ if (!aWgt->setSelection(myPreSelection, true)) {
+ isSet = false;
+ break;
+ } else {
+ isSet = true;
+ aFilledWgt = aWgt;
+ }
}
}
aPropertyPanel->setPreselectionWidget(NULL);
// in order to redisplay object in the viewer, the update/redisplay signals should be flushed
// it is better to perform it not in setSelection of each widget, but do it here,
// after the preselection is processed
- ModuleBase_ModelWidget::updateObject(myFeature);
-
- // 3. a signal should be emitted before the next widget activation
- // because, the activation of the next widget will give a focus to the widget. As a result
- // the value of the widget is initialized. And commit may happens until the value is entered.
- if (aFilledWgt)
- emit activatedByPreselection();
+ ModuleBase_Tools::flushUpdated(myFeature);
}
- // 4. activate the next obligatory widget
- aPropertyPanel->activateNextWidget(aFilledWgt);
}
-
clearPreselection();
+
+ return aFilledWgt;
}
void ModuleBase_OperationFeature::setParentFeature(CompositeFeaturePtr theParent)
void ModuleBase_OperationFeature::initSelection(ModuleBase_ISelection* theSelection,
ModuleBase_IViewer* theViewer)
{
- clearPreselection();
-
- QList<ModuleBase_ViewerPrs> aPreSelected;
+ QList<ModuleBase_ViewerPrsPtr> aPreSelected;
// Check that the selected result are not results of operation feature
FeaturePtr aFeature = feature();
if (aFeature) {
- QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
+ QList<ModuleBase_ViewerPrsPtr> aSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
std::list<ResultPtr> aResults = aFeature->results();
QObjectPtrList aResList;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
aResList.append(*aIt);
- foreach (ModuleBase_ViewerPrs aPrs, aSelected) {
- if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature))
+ foreach (ModuleBase_ViewerPrsPtr aPrs, aSelected) {
+ if ((!aResList.contains(aPrs->object())) && (aPrs->object() != aFeature))
aPreSelected.append(aPrs);
}
} else
aPreSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
- myPreSelection = aPreSelected;
+ setPreselection(aPreSelected);
+}
+
+void ModuleBase_OperationFeature::setPreselection(const QList<ModuleBase_ViewerPrsPtr>& theValues)
+{
+ clearPreselection();
+ myPreSelection = theValues;
}
void ModuleBase_OperationFeature::clearPreselection()