}
}
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theObject,
- GeomShapePtr theShape)
-{
- DataPtr aData = myFeature->data();
- ModuleBase_Tools::setObject(aData->attribute(attributeID()), theObject, theShape,
- myWorkshop, myIsInValidate);
-}
-
//********************************************************************
bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
const bool theToValidate)
/// \return a list of shapes
virtual QIntList getShapeTypes() const;
- /// Append the values to the model attribute of the widget. It casts this attribute to
- /// the specific type and set the given values
- /// \param theObject an object
- /// \param theShape a selected shape, which is used in the selection attribute
- /// \return true if it is succeed
- void setObject(ObjectPtr theObject, GeomShapePtr theShape);
-
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// parameters of the current attribute
void ModuleBase_WidgetSelector::onSelectionChanged()
{
QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
-
bool isDone = setSelection(aSelected, true/*false*/);
+
+ if (isDone)
+ updateOnSelectionChanged(isDone);
+}
+
+//********************************************************************
+void ModuleBase_WidgetSelector::updateOnSelectionChanged(const bool theDone)
+{
// "false" flag should be used here, it connects to the #26658 OCC bug, when the user click in
// the same place repeatedly without mouse moved. In the case validation by filters is not
// perfromed, so an invalid object is selected. E.g. distance constraint, selection of a point.
// we need to forget about previous validation result as the current selection can influence on it
clearValidatedCash();
- if (isDone)
+ if (theDone)
updateFocus();
}
return activateFilters(toActivate);
}
+//********************************************************************
+void ModuleBase_WidgetSelector::setObject(ObjectPtr theObject,
+ GeomShapePtr theShape)
+{
+ DataPtr aData = myFeature->data();
+ ModuleBase_Tools::setObject(aData->attribute(attributeID()), theObject, theShape,
+ myWorkshop, myIsInValidate);
+}
+
//********************************************************************
void ModuleBase_WidgetSelector::activateCustom()
{
/// The methiod called when widget is deactivated
virtual void deactivate();
-// NDS: protected is temporary
-protected slots:
+private slots:
/// Slot which is called on selection event
- // NDS: virtual is temporary
virtual void onSelectionChanged();
- protected:
+protected:
+ /// Emits model changed info, updates the current control by selection change
+ /// \param theDone a state whether the selection is set
+ virtual void updateOnSelectionChanged(const bool theDone);
+
/// Update focus after the attribute value change
// NDS: has body is temporary
virtual void updateFocus() {};
/// \param theSelectedObject an object
/// \param theShape a selected shape, which is used in the selection attribute
/// \return true if it is succeed
- virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) = 0;
+ void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
/// The methiod called when widget is activated
virtual void activateCustom();
}
//********************************************************************
-void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObject,
- GeomShapePtr theShape)
+bool ModuleBase_WidgetShapeSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate)
{
- DataPtr aData = myFeature->data();
- ModuleBase_Tools::setObject(aData->attribute(attributeID()), theObject, theShape,
- myWorkshop, myIsInValidate);
+ if (theValues.empty()) {
+ // In order to make reselection possible, set empty object and shape should be done
+ setSelectionCustom(ModuleBase_ViewerPrs());
+ return false;
+ }
+ // it removes the processed value from the parameters list
+ ModuleBase_ViewerPrs aValue = theValues.takeFirst();
+ bool isDone = false;
+
+ if (!theToValidate || isValidInFilters(aValue)) {
+ isDone = setSelectionCustom(aValue);
+ // updateObject - to update/redisplay feature
+ // it is commented in order to perfom it outside the method
+ //updateObject(myFeature);
+ // to storeValue()
+ //emit valuesChanged();
+ }
+ return isDone;
}
//********************************************************************
virtual ~ModuleBase_WidgetShapeSelector();
+ /// Set the given wrapped value to the current widget
+ /// 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 theValues the wrapped selection values
+ /// \param theToValidate a flag on validation of the values
+ virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate);
+
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
/// \return a list of shapes
virtual QIntList getShapeTypes() const;
- /// Store the values to the model attribute of the widget. It casts this attribute to
- /// the specific type and set the given values
- /// \param theObject an object
- /// \param theShape a selected shape, which is used in the selection attribute
- /// \return true if it is succeed
- virtual void setObject(ObjectPtr theObject, GeomShapePtr theShape);
-
/// Get the shape from the attribute if the attribute contains a shape, e.g. selection attribute
/// \return a shape
virtual GeomShapePtr getShape() const;
{
}
-//********************************************************************
-bool ModuleBase_WidgetValidated::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
- const bool theToValidate)
-{
- if (theValues.empty()) {
- // In order to make reselection possible, set empty object and shape should be done
- setSelectionCustom(ModuleBase_ViewerPrs());
- return false;
- }
- // it removes the processed value from the parameters list
- ModuleBase_ViewerPrs aValue = theValues.takeFirst();
- bool isDone = false;
-
- if (!theToValidate || isValidInFilters(aValue)) {
- isDone = setSelectionCustom(aValue);
- // updateObject - to update/redisplay feature
- // it is commented in order to perfom it outside the method
- //updateObject(myFeature);
- // to storeValue()
- //emit valuesChanged();
- }
- return isDone;
-}
-
//********************************************************************
ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& theAIS) const
{
//********************************************************************
void ModuleBase_WidgetValidated::clearValidatedCash()
{
+#ifdef DEBUG_VALID_STATE
+ qDebug("clearValidatedState");
+#endif
myValidPrs.clear();
myInvalidPrs.clear();
}
aViewer->addSelectionFilter(aSelFilter);
else {
aViewer->removeSelectionFilter(aSelFilter);
- clearValidState();
+ clearValidatedCash();
}
return aHasSelectionFilter;
return aValidPrs || anInvalidPrs;
}
-//********************************************************************
-void ModuleBase_WidgetValidated::clearValidState()
-{
-#ifdef DEBUG_VALID_STATE
- qDebug("clearValidState");
-#endif
- myValidPrs.clear();
- myInvalidPrs.clear();
-}
-
//********************************************************************
QList<ModuleBase_ViewerPrs> ModuleBase_WidgetValidated::getFilteredSelected()
{
const Config_WidgetAPI* theData);
virtual ~ModuleBase_WidgetValidated();
- /// Checks whether all active viewer filters validate the presentation
- /// \param thePrs a selected presentation in the view
- /// \return a boolean value
- bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
-
/// Checks all widget validator if the owner is valid
/// \param theValue a selected presentation in the view
/// \return a boolean value
bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
- /// Set the given wrapped value to the current widget
- /// 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 theValues the wrapped selection values
- /// \param theToValidate a flag on validation of the values
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
- const bool theToValidate);
-
//! Returns data object by AIS
ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
void clearValidatedCash();
protected:
+ /// Checks whether all active viewer filters validate the presentation
+ /// \param thePrs a selected presentation in the view
+ /// \return a boolean value
+ bool isValidInFilters(const ModuleBase_ViewerPrs& thePrs);
+
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// parameters of the current attribute
/// \param thePrs a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) = 0;
+ /// Returns a list of selected presentations in the viewer and object browser
+ /// The presentations from the object browser are filtered by the AIS context filters
+ /// \return a list of presentations
+ QList<ModuleBase_ViewerPrs> getFilteredSelected();
+
+ /// It obtains selection filters from the workshop and activates them in the active viewer
+ /// \param toActivate a flag about activation or deactivation the filters
+ /// \return true if the selection filter of the widget is activated in viewer context
+ bool activateFilters(const bool toActivate);
+
+ /// Block the model flush of update and intialization of attribute
+ /// \param theToBlock flag whether the model is blocked or unblocked
+ /// \param isActive out value if model is blocked, in value if model is unblocked
+ /// to be used to restore flush state when unblocked
+ /// \param isAttributeSetInitializedBlocked out value if model is blocked
+ /// in value if model is unblocked to be used to restore previous state when unblocked
+ virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
+ bool& isAttributeSetInitializedBlocked);
+
+private:
/// Checks the current attibute in all attribute validators
// \return true if all validators return that the attribute is valid
bool isValidAttribute() const;
/// \param theValid a valid state
void storeValidState(const ModuleBase_ViewerPrs& theValue, const bool theValid);
- /// Removes all presentations from internal maps.
- void clearValidState();
-
- /// Returns a list of selected presentations in the viewer and object browser
- /// The presentations from the object browser are filtered by the AIS context filters
- /// \return a list of presentations
- QList<ModuleBase_ViewerPrs> getFilteredSelected();
-
/// Applies AIS context filters to the parameter list. The not approved presentations are
/// removed from the parameters.
/// \param theValues a list of presentations.
/// \param theValues a list of presentations.
void filterCompSolids(QList<ModuleBase_ViewerPrs>& theValues);
- /// It obtains selection filters from the workshop and activates them in the active viewer
- /// \param toActivate a flag about activation or deactivation the filters
- /// \return true if the selection filter of the widget is activated in viewer context
- bool activateFilters(const bool toActivate);
-
- /// Block the model flush of update and intialization of attribute
- /// \param theToBlock flag whether the model is blocked or unblocked
- /// \param isActive out value if model is blocked, in value if model is unblocked
- /// to be used to restore flush state when unblocked
- /// \param isAttributeSetInitializedBlocked out value if model is blocked
- /// in value if model is unblocked to be used to restore previous state when unblocked
- virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
- bool& isAttributeSetInitializedBlocked);
-
protected:
/// Reference to workshop
- ModuleBase_IWorkshop* myWorkshop;
-
+ ModuleBase_IWorkshop* myWorkshop;
/// The widget is in validation mode: store is performed, restore is not
- bool myIsInValidate;
+ bool myIsInValidate;
private:
ObjectPtr myPresentedObject; /// back up of the filtered object
- QList<ModuleBase_ViewerPrs> myValidPrs;
- QList<ModuleBase_ViewerPrs> myInvalidPrs;
+ QList<ModuleBase_ViewerPrs> myValidPrs; /// cash of valid selection presentations
+ QList<ModuleBase_ViewerPrs> myInvalidPrs; /// cash of invalid selection presentations
};
#endif /* MODULEBASE_WIDGETVALIDATED_H_ */
return !aHasValueInList;
}
-void PartSet_WidgetSketchCreator::onSelectionChanged()
+bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate)
{
- QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
-
- if (!startSketchOperation(aSelected)) {
- QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
+ bool aDone = false;
+ if (!startSketchOperation(theValues)) {
+ QList<ModuleBase_ViewerPrs>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
bool aProcessed = false;
for (; anIt != aLast; anIt++) {
ModuleBase_ViewerPrs aValue = *anIt;
- if (isValidInFilters(aValue))
+ if (!theToValidate || isValidInFilters(aValue))
aProcessed = setBaseAttributeSelection(aValue) || aProcessed;
}
+ aDone = aProcessed;
if (aProcessed) {
emit valuesChanged();
updateObject(myFeature);
emit focusOutWidget(this);
}
}
+ return aDone;
}
//********************************************************************
-void PartSet_WidgetSketchCreator::setObject(ObjectPtr theObject,
- GeomShapePtr theShape)
+void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
{
- DataPtr aData = myFeature->data();
- ModuleBase_Tools::setObject(aData->attribute(attributeID()), theObject, theShape,
- myWorkshop, myIsInValidate);
-
- //::setObject(aData->attribute(attributeID()), theObject, theShape);
}
bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues)
/// 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 theToValidate a validation of the values flag
+ virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate);
+
/// Editing mode depends on mode of current operation. This value is defined by it.
virtual void setEditingMode(bool isEditing);
/// \return a list of shapes
virtual QIntList getShapeTypes() const;
- /// Store the values to the model attribute of the widget. It casts this attribute to
- /// the specific type and set the given values
- /// \param theObject an object
- /// \param theShape a selected shape, which is used in the selection attribute
- /// \return true if it is succeed
- virtual void setObject(ObjectPtr theObject, GeomShapePtr theShape);
+ /// Emits model changed info, updates the current control by selection change
+ /// \param theDone a state whether the selection is set
+ void updateOnSelectionChanged(const bool theDone);
private:
/// Returns true if the selection mode is active. This is when composition feature has no
/// \return boolean value
bool isSelectionMode() const;
-protected slots:
- /// Slot which is called on selection event
- // NDS: virtual is temporary
- virtual void onSelectionChanged();
-
private slots:
void onResumed(ModuleBase_Operation* theOp);
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Dir.h>
#include <GeomAPI_XYZ.h>
+#include <GeomAPI_Face.h>
#include <SketchPlugin_Sketch.h>
#include <SketcherPrs_Tools.h>
return true;
ModuleBase_ViewerPrs aPrs = theValues.first();
- bool aDone = ModuleBase_WidgetValidated::setSelection(theValues, theToValidate);
+ bool aDone = setSelectionInternal(theValues, theToValidate);
if (aDone)
updateByPlaneSelected(aPrs);
-
return aDone;
}
if (aSelected.empty())
return;
ModuleBase_ViewerPrs aPrs = aSelected.first();
-
- bool aDone = ModuleBase_WidgetValidated::setSelection(aSelected, false);
+ bool aDone = setSelectionInternal(aSelected, false);
if (aDone) {
updateByPlaneSelected(aPrs);
updateObject(myFeature);
}
}
+bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate)
+{
+ bool aDone = false;
+ ModuleBase_ViewerPrs aValue;
+ if (theValues.empty()) {
+ // In order to make reselection possible, set empty object and shape should be done
+ setSelectionCustom(ModuleBase_ViewerPrs());
+ aDone = false;
+ }
+ else {
+ // it removes the processed value from the parameters list
+ aValue = theValues.first();//.takeFirst();
+ if (!theToValidate || isValidInFilters(aValue))
+ aDone = setSelectionCustom(aValue);
+ }
+
+ return aDone;
+}
+
void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs)
{
// 1. hide main planes if they have been displayed
return fillSketchPlaneBySelection(feature(), thePrs);
}
-#include <GeomAPI_Face.h>
bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs)
{
bool aCanFillSketch = true;
virtual void blockAttribute(const bool& theToBlock, bool& isFlushesActived,
bool& isAttributeSetInitializedBlocked);
+ /// Set the given wrapped value to the current widget
+ /// 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 theValues the wrapped selection values
+ /// \param theToValidate a validation flag
+ bool setSelectionInternal(const QList<ModuleBase_ViewerPrs>& theValues,
+ const bool theToValidate);
+
/// Erase preview planes, disconnect widget, change the view projection
/// \param thePrs a selected presentation
void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs);
public:
/// Constructor
/// \param parent a parent widget
- XGUI_EXPORT XGUI_ErrorDialog(QWidget* parent);XGUI_EXPORT virtual ~XGUI_ErrorDialog();
+ XGUI_EXPORT XGUI_ErrorDialog(QWidget* parent);
+ XGUI_EXPORT virtual ~XGUI_ErrorDialog();
public slots:
/// Update dialog box