+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
/*
* ModuleBase_Operation.cpp
*
#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_ModelWidget.h"
-#include "ModuleBase_WidgetValueFeature.h"
#include "ModuleBase_ViewerPrs.h"
#include "ModuleBase_IPropertyPanel.h"
#include "ModuleBase_ISelection.h"
void ModuleBase_Operation::resume()
{
- if (myPropertyPanel)
- connect(myPropertyPanel, SIGNAL(noMoreWidgets()), SLOT(commit()));
// connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
// this, SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
emit resumed();
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;
- QList<ModuleBase_WidgetValueFeature*>::const_iterator aPIt;
+ QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
bool isSet = false;
for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
(aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
- ++aWIt, ++aPIt) {
+ ++aWIt) {
aWgt = (*aWIt);
- ModuleBase_WidgetValueFeature* aValue = (*aPIt);
- if (!aWgt->setValue(aValue)) {
+ ModuleBase_ViewerPrs aValue = (*aPIt);
+ if (!aWgt->canSetValue())
+ continue;
+
+ ++aPIt;
+ if (!aWgt->setSelection(aValue)) {
isSet = false;
break;
} else {
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;
}
// 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);
- }
+ //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;
}
//void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
void ModuleBase_Operation::clearPreselection()
{
- while (!myPreSelection.isEmpty()) {
- delete myPreSelection.takeFirst();
- }
+ myPreSelection.clear();
}
void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
myPropertyPanel->setEditingMode(isEditOperation());
//connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
// SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
- if (myPropertyPanel) {
- connect(myPropertyPanel, SIGNAL(noMoreWidgets()), SLOT(commit()));
- }
}
bool ModuleBase_Operation::isGranted(QString theId) const