From: nds Date: Mon, 28 Mar 2016 07:22:37 +0000 (+0300) Subject: Issue #1343 Improvement of Extrusion and Revolution operations: extrusion by preselection X-Git-Tag: V_2.3.0~319 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22b9a67e18cbd5d8eabba1ab85f26f5bad963c30;p=modules%2Fshaper.git Issue #1343 Improvement of Extrusion and Revolution operations: extrusion by preselection --- diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 096adeea6..e0a84bc97 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -271,15 +271,6 @@ void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid) } } -//******************************************************************** -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& theValues, const bool theToValidate) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 69ab6e146..5dd0d1702 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -124,13 +124,6 @@ protected: /// \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 diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index e07b726b2..9d5b50a0a 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -45,8 +45,15 @@ void ModuleBase_WidgetSelector::getGeomSelection(const ModuleBase_ViewerPrs& the void ModuleBase_WidgetSelector::onSelectionChanged() { QList 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. @@ -59,7 +66,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged() // we need to forget about previous validation result as the current selection can influence on it clearValidatedCash(); - if (isDone) + if (theDone) updateFocus(); } @@ -135,6 +142,15 @@ bool ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate) 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() { diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index d095512a4..ec1dbfbee 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -58,13 +58,15 @@ Q_OBJECT /// 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() {}; @@ -88,7 +90,7 @@ protected slots: /// \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(); diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 2def57f66..b4b708367 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -107,12 +107,27 @@ bool ModuleBase_WidgetShapeSelector::storeValueCustom() const } //******************************************************************** -void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObject, - GeomShapePtr theShape) +bool ModuleBase_WidgetShapeSelector::setSelection(QList& 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; } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index c3e48ab25..ec1fe5f49 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -68,6 +68,15 @@ Q_OBJECT 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& theValues, + const bool theToValidate); + /// Returns list of widget controls /// \return a control list virtual QList getControls() const; @@ -100,13 +109,6 @@ Q_OBJECT /// \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; diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 645f27143..a5a639132 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -34,30 +34,6 @@ ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated() { } -//******************************************************************** -bool ModuleBase_WidgetValidated::setSelection(QList& 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 { @@ -67,6 +43,9 @@ ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& th //******************************************************************** void ModuleBase_WidgetValidated::clearValidatedCash() { +#ifdef DEBUG_VALID_STATE + qDebug("clearValidatedState"); +#endif myValidPrs.clear(); myInvalidPrs.clear(); } @@ -214,7 +193,7 @@ bool ModuleBase_WidgetValidated::activateFilters(const bool toActivate) aViewer->addSelectionFilter(aSelFilter); else { aViewer->removeSelectionFilter(aSelFilter); - clearValidState(); + clearValidatedCash(); } return aHasSelectionFilter; @@ -282,16 +261,6 @@ bool ModuleBase_WidgetValidated::getValidState(const ModuleBase_ViewerPrs& theVa return aValidPrs || anInvalidPrs; } -//******************************************************************** -void ModuleBase_WidgetValidated::clearValidState() -{ -#ifdef DEBUG_VALID_STATE - qDebug("clearValidState"); -#endif - myValidPrs.clear(); - myInvalidPrs.clear(); -} - //******************************************************************** QList ModuleBase_WidgetValidated::getFilteredSelected() { diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index b101e0517..0d31b0add 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -43,25 +43,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg 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& theValues, - const bool theToValidate); - //! Returns data object by AIS ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; @@ -69,6 +55,11 @@ class MODULEBASE_EXPORT ModuleBase_WidgetValidated : public ModuleBase_ModelWidg 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 @@ -89,6 +80,26 @@ protected: /// \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 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; @@ -107,14 +118,6 @@ protected: /// \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 getFilteredSelected(); - /// Applies AIS context filters to the parameter list. The not approved presentations are /// removed from the parameters. /// \param theValues a list of presentations. @@ -124,31 +127,16 @@ protected: /// \param theValues a list of presentations. void filterCompSolids(QList& 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 myValidPrs; - QList myInvalidPrs; + QList myValidPrs; /// cash of valid selection presentations + QList myInvalidPrs; /// cash of invalid selection presentations }; #endif /* MODULEBASE_WIDGETVALIDATED_H_ */ diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 2c44b55fd..5ac2cec98 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -243,18 +243,19 @@ bool PartSet_WidgetSketchCreator::isSelectionMode() const return !aHasValueInList; } -void PartSet_WidgetSketchCreator::onSelectionChanged() +bool PartSet_WidgetSketchCreator::setSelection(QList& theValues, + const bool theToValidate) { - QList aSelected = getFilteredSelected(); - - if (!startSketchOperation(aSelected)) { - QList::const_iterator anIt = aSelected.begin(), aLast = aSelected.end(); + bool aDone = false; + if (!startSketchOperation(theValues)) { + QList::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); @@ -264,17 +265,12 @@ void PartSet_WidgetSketchCreator::onSelectionChanged() 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& theValues) diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index 0936eff29..a9a479edd 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -52,6 +52,13 @@ public: /// 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& theValues, + const bool theToValidate); + /// Editing mode depends on mode of current operation. This value is defined by it. virtual void setEditingMode(bool isEditing); @@ -80,12 +87,9 @@ protected: /// \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 @@ -93,11 +97,6 @@ private: /// \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); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 9daed51e2..55753d22d 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -141,10 +142,9 @@ bool PartSet_WidgetSketchLabel::setSelection(QList& theVal 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; } @@ -162,8 +162,7 @@ void PartSet_WidgetSketchLabel::onSelectionChanged() 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); @@ -209,6 +208,26 @@ void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isF } } +bool PartSet_WidgetSketchLabel::setSelectionInternal(const QList& 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 @@ -324,7 +343,6 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t return fillSketchPlaneBySelection(feature(), thePrs); } -#include bool PartSet_WidgetSketchLabel::canFillSketch(const ModuleBase_ViewerPrs& thePrs) { bool aCanFillSketch = true; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 7ab807bd2..4e8ccd1b1 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -129,6 +129,15 @@ protected: 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& theValues, + const bool theToValidate); + /// Erase preview planes, disconnect widget, change the view projection /// \param thePrs a selected presentation void updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs); diff --git a/src/XGUI/XGUI_ErrorDialog.h b/src/XGUI/XGUI_ErrorDialog.h index 628495e2c..b6f53e6bc 100644 --- a/src/XGUI/XGUI_ErrorDialog.h +++ b/src/XGUI/XGUI_ErrorDialog.h @@ -25,7 +25,8 @@ Q_OBJECT 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