- if (!theState) {
- abort();
- }
-}
-
-bool ModuleBase_Operation::activateByPreselection()
-{
- if (!myPropertyPanel)
- return false;
- if (myPreSelection.empty())
- return false;
- const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
- if (aWidgets.empty())
- return false;
-
- ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
- QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
- QList<ModuleBase_WidgetValueFeature*>::const_iterator aPIt;
- bool isSet = false;
- for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
- (aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
- ++aWIt) {
- aWgt = (*aWIt);
- ModuleBase_WidgetValueFeature* aValue = (*aPIt);
- if (!aWgt->canSetValue())
- continue;
-
- ++aPIt;
- if (!aWgt->setValue(aValue)) {
- isSet = false;
- break;
- } else {
- isSet = true;
- 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()));
- return true;
- }
- else {
- //activate next widget
- if (aFilledWgt) {
- myPropertyPanel->activateNextWidget(aFilledWgt);
- return true;
- }
- }
- return false;
-}
-
-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();
-
- 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();
-
- // 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);
- }
-}
-
-//void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-//{
-// //activateByPreselection();
-// //if (theWidget && myPropertyPanel) {
-// // myPropertyPanel->activateNextWidget();
-// //// //emit activateNextWidget(myActiveWidget);
-// //}
-//}
-
-//bool ModuleBase_Operation::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
-//{
-// ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-// if (!aActiveWgt)
-// return false;
-// ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-// aValue->setObject(theFeature);
-// aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-// bool isApplyed = aActiveWgt->setValue(aValue);
-//
-// delete aValue;
-// myIsModified = (myIsModified || isApplyed);
-// return isApplyed;
-//}
-
-bool ModuleBase_Operation::getViewerPoint(ModuleBase_ViewerPrs thePrs,
- ModuleBase_IViewer* theViewer,
- double& theX, double& theY)
-{
- return false;
-}
-
-void ModuleBase_Operation::clearPreselection()
-{
- while (!myPreSelection.isEmpty()) {
- delete myPreSelection.takeFirst();
- }