-void ModuleBase_Operation::commitOperation()
-{
- if(!myPropertyPanel) {
- return;
- }
-}
-
-void ModuleBase_Operation::activateByPreselection()
-{
- if (myPreSelection.empty())
- return;
-
- ModuleBase_ModelWidget* aFilledWgt = 0;
- if (myPropertyPanel) {
- const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
- 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;
- myPropertyPanel->setPreselectionWidget(aWgt);
- if (!aWgt->setSelection(myPreSelection, true)) {
- isSet = false;
- break;
- } else {
- isSet = true;
- aFilledWgt = aWgt;
- }
- }
- myPropertyPanel->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();
- }
- // 4. activate the next obligatory widget
- myPropertyPanel->activateNextWidget(aFilledWgt);
- }
-
- clearPreselection();
-}
-
-void ModuleBase_Operation::setParentFeature(CompositeFeaturePtr theParent)
-{
- myParentFeature = theParent;
-}
-
-CompositeFeaturePtr ModuleBase_Operation::parentFeature() const
-{
- return myParentFeature;
-}
-
-void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection,
- ModuleBase_IViewer* theViewer)
-{
- clearPreselection();
-
- QList<ModuleBase_ViewerPrs> 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);
-
- std::list<ResultPtr> aResults = aFeature->results();
- QObjectPtrList aResList;
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
- aResList.append(*aIt);
-
- foreach (ModuleBase_ViewerPrs aPrs, aSelected) {
- if ((!aResList.contains(aPrs.object())) && (aPrs.object() != aFeature))
- aPreSelected.append(aPrs);
- }
- } else
- aPreSelected = theSelection->getSelected(ModuleBase_ISelection::AllControls);
-
- // convert the selection values to the values, which are set to the operation widgets
-
- //Handle(V3d_View) aView = theViewer->activeView();
- //foreach (ModuleBase_ViewerPrs aPrs, aPreSelected) {
- // ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
- // aValue->setObject(aPrs.object());
-
- // double aX, anY;
- // if (getViewerPoint(aPrs, theViewer, aX, anY))
- // aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
- // myPreSelection.append(aValue);
- //}
- myPreSelection = aPreSelected;
-}
-
-
-bool ModuleBase_Operation::getViewerPoint(ModuleBase_ViewerPrs thePrs,
- ModuleBase_IViewer* theViewer,
- double& theX, double& theY)
-{
- return false;
-}
-
-void ModuleBase_Operation::clearPreselection()
-{
- myPreSelection.clear();
-}
-