]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #725 - Translation with parameters - wrong coordinates
authornds <natalia.donis@opencascade.com>
Mon, 6 Jul 2015 08:52:23 +0000 (11:52 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 6 Jul 2015 08:58:31 +0000 (11:58 +0300)
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_ExternalObjectsMgr.cpp
src/PartSet/PartSet_ExternalObjectsMgr.h
src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index e00fd80941614a75dfb4002a1c2bb32f7e5cd11d..49734b6216a553fa2c7d2ce814537f8d9ead7bae 100644 (file)
@@ -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;
 }
 
index bafc219aa349590fcf8d34a12720ebfd576c5172..d53bbb705beee95affa492329f44bbea9b49cb8c 100644 (file)
@@ -130,7 +130,6 @@ private:
   ObjectPtr myPresentedObject; /// back up of the filtered object
   QList<ModuleBase_ViewerPrs> myValidPrs;
   QList<ModuleBase_ViewerPrs> myInvalidPrs;
-  bool isValidateBlocked;
 };
 
 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */
index 9c3e4105d942d5a35b2e153c57763e75881b8aa5..e171f43b5e8189444b015d49792d39c4eb6e6c70 100644 (file)
@@ -8,6 +8,7 @@
 #include "PartSet_Tools.h"
 
 #include <XGUI_Workshop.h>
+#include <XGUI_ModuleConnector.h>
 
 #include <SketchPlugin_Feature.h>
 
@@ -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<XGUI_ModuleConnector*>(theWorkshop);
+  return aConnector->workshop();
+}
index 03b8097301c22bb44a5697b1288adb47623d50be..82f9dbfb0f789beb596d0a55488b4b783da31f1d 100644 (file)
@@ -18,6 +18,9 @@
 
 #include <string>
 
+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
index 00b126e9ccf434124f1c455b7bead941a65a7e28..0a5eb7f9e0b69e2eab62ea99afdec3e1d7a93dc2 100644 (file)
@@ -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,
index 488a265680a1bd4a756d938ac269666d245cd000..4f8134e10732b1c58b7f4bc418628003ac263936 100644 (file)
@@ -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);
 }
 
 //********************************************************************
index c3ee64886b9fcb2b123362174f4d738d85009c67..dac0f4625ee444c6b1e152026576d778e892021c 100644 (file)
@@ -386,3 +386,24 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const
   }
   return aMenu;
 }
+
+QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
+{
+  QStringList aGroups;
+
+  QMap<std::string, QActionsList>::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;
+}
index 80905f05a8818b21ac76ac2a0a6222916fd9da58..254baf198169cff0f603300662c548539fc91439 100644 (file)
@@ -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
index e0ca916c532cb488a60997ca9d0675efc9577431..25d0551e65bc29cdc22686ec4f5a2a21b5f3440b 100644 (file)
@@ -1045,7 +1045,7 @@ void XGUI_Workshop::deleteObjects()
 
 //**************************************************************
 bool XGUI_Workshop::deleteFeatures(const QObjectPtrList& theList,
-                                   std::set<FeaturePtr> theIgnoredFeatures,
+                                   const std::set<FeaturePtr>& 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<ModelAPI_Result>(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
index b41634aab7a05d6875fd78169f70b281bfabe01a..d10d3b729ea6cf7b6cac98f8c3f257d70c351d49 100644 (file)
@@ -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<FeaturePtr> theIgnoredFeatures = std::set<FeaturePtr>(),
-                             QWidget* theParent = 0,
-                             const bool theAskAboutDeleteReferences = false);
+  bool deleteFeatures(const QObjectPtrList& theList,
+                      const std::set<FeaturePtr>& 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)