/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
- /// \param theValue the wrapped widget value
- virtual bool setSelection(ModuleBase_ViewerPrs theValue)
+ /// \param theValues the wrapped selection values
+ /// \param thePosition an index in the list of values, the values should be get from the index
+ virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
{
return false;
}
ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
- QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
bool isSet = false;
// 1. apply the selection to controls
- for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
- (aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
- ++aWIt) {
+ int aCurrentPosition = 0;
+ for (aWIt = aWidgets.constBegin(); aWIt != aWidgets.constEnd(); ++aWIt) {
aWgt = (*aWIt);
- ModuleBase_ViewerPrs aValue = (*aPIt);
if (!aWgt->canSetValue())
continue;
- ++aPIt;
- if (!aWgt->setSelection(aValue)) {
+ if (!aWgt->setSelection(myPreSelection, aCurrentPosition/*aValue*/)) {
isSet = false;
break;
} else {
}
}
+//********************************************************************
+bool ModuleBase_WidgetMultiSelector::setSelection(const QList<ModuleBase_ViewerPrs>& theValues,
+ int& thePosition)
+{
+ if (thePosition < 0)
+ return false;
+
+ QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ bool isDone = false;
+ for (int i = thePosition; i < theValues.size(); i++) {
+ ModuleBase_ViewerPrs aValue = theValues[i];
+ thePosition++;
+ bool aProcessed = false;
+ if (isValidSelection(aValue)) {
+ aProcessed = setSelectionCustom(aValue);
+ }
+ // if there is at least one set, the result is true
+ isDone = isDone || aProcessed;
+ // when an object, which do not satisfy the validating process, stop set selection
+ if (!aProcessed)
+ break;
+ }
+ if (isDone) {
+ updateObject(myFeature);
+ emit valuesChanged();
+ }
+ return isDone;
+}
+
//********************************************************************
bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
/// The methiod called when widget is deactivated
virtual void deactivate();
+ /// Set the given wrapped value to the current widget
+ /// This value should be processed in the widget according to the needs
+ /// \param theValues the wrapped selection values
+ /// \param thePosition an index in the list of values, the values should be get from the index
+ virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
+
/// Fills the attribute with the value of the selected owner
/// \param theOwner a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
}
//********************************************************************
-bool ModuleBase_WidgetValidated::setSelection(ModuleBase_ViewerPrs theValue)
+bool ModuleBase_WidgetValidated::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
{
+ if (thePosition < 0 || thePosition >= theValues.size())
+ return false;
+ ModuleBase_ViewerPrs aValue = theValues[thePosition];
+ thePosition++;
+
bool isDone = false;
- if (isValidSelection(theValue)) {
- isDone = setSelectionCustom(theValue);
+ if (isValidSelection(aValue)) {
+ isDone = setSelectionCustom(aValue);
updateObject(myFeature);
emit valuesChanged();
}
/// This value should be processed in the widget according to the needs
/// The method is called by the current operation to process the operation preselection.
/// It is redefined to check the value validity and if it is, fill the attribute with by value
- /// \param theValue the wrapped widget value
- virtual bool setSelection(ModuleBase_ViewerPrs theValue);
+ /// \param theValues the wrapped selection values
+ /// \param thePosition an index in the list of values, the values should be get from the index
+ virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
protected:
/// Creates a backup of the current values of the attribute
{
}
-bool PartSet_WidgetPoint2D::setSelection(ModuleBase_ViewerPrs theValue)
+bool PartSet_WidgetPoint2D::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
{
+ if (thePosition < 0 || thePosition >= theValues.size())
+ return false;
+ ModuleBase_ViewerPrs aValue = theValues[thePosition];
+ thePosition++;
+
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
bool isDone = false;
- TopoDS_Shape aShape = theValue.shape();
+ TopoDS_Shape aShape = aValue.shape();
double aX, aY;
if (getPoint2d(aView, aShape, aX, aY)) {
isDone = setPoint(aX, aY);
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
/// \param theValue the wrapped widget value
- virtual bool setSelection(ModuleBase_ViewerPrs theValue);
+ virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
virtual bool restoreValue();
erasePreviewPlanes();
}
-bool PartSet_WidgetSketchLabel::setSelection(ModuleBase_ViewerPrs theValue)
+bool PartSet_WidgetSketchLabel::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
{
// do not use the given selection if the plane of the sketch has been already set.
// If this check is absent, a selected plane in the viewer can be set in the sketch
if (plane().get())
return true;
- return ModuleBase_WidgetValidated::setSelection(theValue);
+ return ModuleBase_WidgetValidated::setSelection(theValues, thePosition);
}
QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
/// This value should be processed in the widget according to the needs
/// The method is called by the current operation to process the operation preselection.
/// It is redefined to do nothing if the plane of the sketch has been already set.
- /// \param theValue the wrapped widget value
- virtual bool setSelection(ModuleBase_ViewerPrs theValue);
+ /// \param theValues the wrapped selection values
+ /// \param thePosition an index in the list of values, the values should be get from the index
+ virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
virtual bool restoreValue()
{