From fdf05fdbacbddf319df9770cddafaaa09e8cd1a4 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 6 Jul 2015 11:52:23 +0300 Subject: [PATCH] Issue #725 - Translation with parameters - wrong coordinates --- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 7 +----- src/ModuleBase/ModuleBase_WidgetValidated.h | 1 - src/PartSet/PartSet_ExternalObjectsMgr.cpp | 22 ++++++++++++++----- src/PartSet/PartSet_ExternalObjectsMgr.h | 16 +++++++++++--- src/PartSet/PartSet_WidgetMultiSelector.cpp | 2 +- src/PartSet/PartSet_WidgetShapeSelector.cpp | 2 +- src/XGUI/XGUI_ContextMenuMgr.cpp | 21 ++++++++++++++++++ src/XGUI/XGUI_ContextMenuMgr.h | 4 ++++ src/XGUI/XGUI_Workshop.cpp | 13 ++++++----- src/XGUI/XGUI_Workshop.h | 8 +++---- 10 files changed, 69 insertions(+), 27 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index e00fd8094..49734b621 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -24,7 +24,7 @@ ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId), isValidateBlocked(false), +: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop) { } @@ -120,10 +120,6 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th return aValid; } - if (isValidateBlocked) - return true; - isValidateBlocked = true; - DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); @@ -160,7 +156,6 @@ bool ModuleBase_WidgetValidated::isValidSelection(const ModuleBase_ViewerPrs& th aLoop->flush(aRedispEvent); storeValidState(theValue, aValid); - isValidateBlocked = false; return aValid; } diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index bafc219aa..d53bbb705 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -130,7 +130,6 @@ private: ObjectPtr myPresentedObject; /// back up of the filtered object QList myValidPrs; QList myInvalidPrs; - bool isValidateBlocked; }; #endif /* MODULEBASE_WIDGETVALIDATED_H_ */ diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.cpp b/src/PartSet/PartSet_ExternalObjectsMgr.cpp index 9c3e4105d..e171f43b5 100644 --- a/src/PartSet/PartSet_ExternalObjectsMgr.cpp +++ b/src/PartSet/PartSet_ExternalObjectsMgr.cpp @@ -8,6 +8,7 @@ #include "PartSet_Tools.h" #include +#include #include @@ -75,7 +76,8 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& t //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end(); for (; anIt != aLast; anIt++) { @@ -94,7 +96,7 @@ void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSk // to delete this feature. Test case is creation of a constraint on external point, // use in this control after an external point, the point of the sketch. anIgnoredFeatures.insert(theFeature); - XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures); + workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); } } //removeExternalObject(anObject, theSketch, theFeature); @@ -126,16 +128,18 @@ void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrLis //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { // TODO(nds): unite with removeExternal(), remove parameters - removeExternalObject(myExternalObjectValidated, theSketch, theFeature); + removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop); myExternalObjectValidated = ObjectPtr(); } void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject, const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { if (theObject.get()) { DocumentPtr aDoc = theObject->document(); @@ -151,7 +155,13 @@ void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject // to delete this feature. Test case is creation of a constraint on external point, // use in this control after an external point, the point of the sketch. anIgnoredFeatures.insert(theFeature); - XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures); + workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); } } } + +XGUI_Workshop* PartSet_ExternalObjectsMgr::workshop(ModuleBase_IWorkshop* theWorkshop) +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); + return aConnector->workshop(); +} diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h index 03b809730..82f9dbfb0 100644 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -18,6 +18,9 @@ #include +class ModuleBase_IWorkshop; +class XGUI_Workshop; + /** * \ingroup Modules * Customosation of ModuleBase_WidgetShapeSelector in order to provide @@ -52,11 +55,14 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr // Removes the external presentation from the model /// \param theSketch a current sketch /// \param theFeature a current feature + /// \param theFeature a current workshop void removeExternal(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature); + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop); void removeExternalValidated(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature); + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop); void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects, const CompositeFeaturePtr& theSketch, @@ -65,7 +71,11 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr protected: void removeExternalObject(const ObjectPtr& theObject, const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature); + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop); + + /// Returns the workshop + static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop); protected: /// An external object diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp index 00b126e9c..0a5eb7f9e 100644 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -87,7 +87,7 @@ void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid) myIsInVaildate = false; ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid); - myExternalObjectMgr->removeExternalValidated(sketch(), myFeature); + myExternalObjectMgr->removeExternalValidated(sketch(), myFeature, myWorkshop); } void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs, diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp index 488a26568..4f8134e10 100644 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -122,7 +122,7 @@ GeomShapePtr PartSet_WidgetShapeSelector::getShape() const void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid) { ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid); - myExternalObjectMgr->removeExternal(sketch(), myFeature); + myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop); } //******************************************************************** diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index c3ee64886..dac0f4625 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -386,3 +386,24 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const } return aMenu; } + +QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName) +{ + QStringList aGroups; + + QMap::const_iterator anIt = myObjBrowserMenus.begin(), + aLast = myObjBrowserMenus.end(); + for (; anIt != aLast; anIt++) { + QString aGroupName(anIt.key().c_str()); + if (aGroups.contains(aGroupName)) + continue; + QActionsList anActions = anIt.value(); + QActionsList::const_iterator anAIt = anActions.begin(), anALast = anActions.end(); + bool aFound = false; + for (; anAIt != anALast && !aFound; anAIt++) + aFound = (*anAIt)->data().toString() == theName; + if (aFound) + aGroups.append(aGroupName); + } + return aGroups; +} diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index 80905f05a..254baf198 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -52,6 +52,10 @@ Q_OBJECT QMenu* objBrowserMenu() const; QMenu* viewerMenu() const; + /// Returns a list of object group names of the action + /// \param theName a name of the action + /// \return a list of group names + QStringList actionObjectGroups(const QString& theName); signals: /// Signal aabout triggered action diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e0ca916c5..25d0551e6 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1045,7 +1045,7 @@ void XGUI_Workshop::deleteObjects() //************************************************************** bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList, - std::set theIgnoredFeatures, + const std::set& theIgnoredFeatures, QWidget* theParent, const bool theAskAboutDeleteReferences) { @@ -1152,13 +1152,16 @@ These features will be deleted also. Would you like to continue?")).arg(aNames), anInfo.clear(); #endif + QString anId = QString::fromStdString("DELETE_CMD"); + QStringList anObjectGroups = contextMenuMgr()->actionObjectGroups(anId); // 4. remove the parameter features foreach (ObjectPtr aObj, theList) { - ResultPtr aResult = std::dynamic_pointer_cast(aObj); - if (aResult.get() != NULL) { // results could not be removed, - // they are removed by a corresponded feature remove + // features and parameters can be removed here, + // the results are removed only by a corresponded feature remove + std::string aGroupName = aObj->groupName(); + if (!anObjectGroups.contains(aGroupName.c_str())) continue; - } + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { // TODO: to learn the workshop to delegate the Part object deletion to the PartSet module diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index b41634aab..d10d3b729 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -218,10 +218,10 @@ Q_OBJECT //! \param theAskAboutDeleteReferences if true, the message box with a list of references to the //! objects features appear. If the user chose do not continue, the deletion is not performed //! \return the success of the delete - static bool deleteFeatures(const QObjectPtrList& theList, - std::set theIgnoredFeatures = std::set(), - QWidget* theParent = 0, - const bool theAskAboutDeleteReferences = false); + bool deleteFeatures(const QObjectPtrList& theList, + const std::set& theIgnoredFeatures, + QWidget* theParent = 0, + const bool theAskAboutDeleteReferences = false); /// Deactivates the object, if it is active and the module returns that the activation /// of selection for the object is not possible currently(the current operation uses it) -- 2.30.2