]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343. Improvement of Extrusion and Revolution operations: Bug correction:...
authornds <nds@opencascade.com>
Mon, 4 Apr 2016 12:16:39 +0000 (15:16 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:25:47 +0000 (13:25 +0300)
14 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h
src/ModuleBase/ModuleBase_WidgetSelectorStore.cpp [new file with mode: 0755]
src/ModuleBase/ModuleBase_WidgetSelectorStore.h [new file with mode: 0755]
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/ModuleBase/ModuleBase_WidgetValidated.cpp
src/ModuleBase/ModuleBase_WidgetValidated.h
src/PartSet/PartSet_WidgetMultiSelector.h

index 23c589611d9ee4ac67092d397055fd2bcbabb060..c7b2e215c0294fbcfcb9796a324a104be1a8c3cc 100644 (file)
@@ -53,6 +53,7 @@ SET(PROJECT_HEADERS
   ModuleBase_WidgetLineEdit.h
   ModuleBase_WidgetMultiSelector.h
   ModuleBase_WidgetSelector.h
+  ModuleBase_WidgetSelectorStore.h
   ModuleBase_WidgetShapeSelector.h
   ModuleBase_WidgetSwitch.h
   ModuleBase_WidgetToolbox.h
@@ -108,6 +109,7 @@ SET(PROJECT_SOURCES
   ModuleBase_WidgetLineEdit.cpp
   ModuleBase_WidgetMultiSelector.cpp
   ModuleBase_WidgetSelector.cpp
+  ModuleBase_WidgetSelectorStore.cpp
   ModuleBase_WidgetShapeSelector.cpp
   ModuleBase_WidgetSwitch.cpp
   ModuleBase_WidgetToolbox.cpp
index 1bc60c1edc122fec444043b8f043407c9a4972a8..250cff9ff5bbccb90ac0b7fc3f661d217c4e1933 100755 (executable)
@@ -490,6 +490,28 @@ void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
   }
 }
 
+GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
+{
+  GeomShapePtr aShape;
+  if (!theAttribute.get())
+    return aShape;
+
+  std::string aType = theAttribute->attributeType();
+  if (aType == ModelAPI_AttributeReference::typeId()) {
+  } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
+    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    if (aRefAttr.get() && !aRefAttr->isObject()) {
+      AttributePtr anAttribute = aRefAttr->attr();
+      aShape = theWorkshop->module()->findShape(anAttribute);
+    }
+  } else if (aType == ModelAPI_AttributeSelection::typeId()) {
+    AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+                                                                                 (theAttribute);
+    aShape = aSelectAttr->value();
+  }
+  return aShape;
+}
+
 } // namespace ModuleBase_Tools
 
 
index 594c5ed280761c424812e038e6a5e8a3ab72c960..b4687584fda75ccfba864767b672b9edfd9bbebe 100755 (executable)
@@ -191,6 +191,14 @@ MODULEBASE_EXPORT void setObject(const AttributePtr& theAttribute, const ObjectP
                                  const std::shared_ptr<GeomAPI_Shape>& theShape,
                                  ModuleBase_IWorkshop* theWorkshop,
                                  const bool theTemporarily = false);
+
+/// Returns the shape of the attribute. If the attribute is AttributeRefAttrPtr, the shape is found
+/// using current module of the given workshop.
+/// \param theAttribute an attribute where the shape is set
+/// \param theWorkshop to find a shape for the given attribute
+MODULEBASE_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(const AttributePtr& theAttribute,
+                                                          ModuleBase_IWorkshop* theWorkshop);
+
 }
 
 #endif
index e0a84bc97ffa465874229c90db1f5081f8163ca7..157eb4f9a8154fadc5608d32532c7177037e9e5b 100755 (executable)
@@ -86,8 +86,7 @@ protected:
 ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParent,
                                                                ModuleBase_IWorkshop* theWorkshop,
                                                                const Config_WidgetAPI* theData)
-: ModuleBase_WidgetSelector(theParent, theWorkshop, theData),
-  mySelectionCount(0)
+: ModuleBase_WidgetSelector(theParent, theWorkshop, theData)
 {
   QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
@@ -215,62 +214,6 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
   return true;
 }
 
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::storeAttributeValue()
-{
-  ModuleBase_WidgetValidated::storeAttributeValue();
-
-  DataPtr aData = myFeature->data();
-  AttributePtr anAttribute = aData->attribute(attributeID());
-  std::string aType = anAttribute->attributeType();
-  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
-    mySelectionType = aSelectionListAttr->selectionType();
-    mySelectionCount = aSelectionListAttr->size();
-  }
-  else if (aType == ModelAPI_AttributeRefList::typeId()) {
-    AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
-    mySelectionCount = aRefListAttr->size();
-  }
-  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
-    AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
-    mySelectionCount = aRefAttrListAttr->size();
-  }
-}
-
-//********************************************************************
-void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid)
-{
-  ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
-
-  DataPtr aData = myFeature->data();
-  AttributePtr anAttribute = aData->attribute(attributeID());
-  std::string aType = anAttribute->attributeType();
-  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
-    aSelectionListAttr->setSelectionType(mySelectionType);
-
-    // restore selection in the attribute. Indeed there is only one stored object
-    int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
-    for (int i = 0; i < aCountAppened; i++)
-      aSelectionListAttr->removeLast();
-  }
-  else if (aType == ModelAPI_AttributeRefList::typeId()) {
-    AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
-    // restore objects in the attribute. Indeed there is only one stored object
-    int aCountAppened = aRefListAttr->size() - mySelectionCount;
-    for (int i = 0; i < aCountAppened; i++)
-      aRefListAttr->removeLast();
-  }
-  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
-    AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
-    // restore objects in the attribute. Indeed there is only one stored object
-    int aCountAppened = aRefAttrListAttr->size() - mySelectionCount;
-    for (int i = 0; i < aCountAppened; i++)
-      aRefAttrListAttr->removeLast();
-  }
-}
-
 //********************************************************************
 bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
                                                   const bool theToValidate)
@@ -624,7 +567,7 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<in
       TopoDS_Shape aShape;
       AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
       if (anAttribute.get()) {
-        GeomShapePtr aGeomShape = myWorkshop->module()->findShape(anAttribute);
+        GeomShapePtr aGeomShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop);
         theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL));
       }
     }
index 5dd0d1702340cf56120272a3fec996196c4686e2..42e789bfd21071febee62286da6aabb0a997bcbd 100755 (executable)
@@ -109,11 +109,6 @@ protected:
 
   virtual bool restoreValueCustom();
 
-  /// 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
-  virtual void storeAttributeValue();
-
   /// Set the focus on the last item in  the list
   virtual void updateFocus();
 
@@ -124,12 +119,6 @@ protected:
   /// \return a list of shapes
   virtual QIntList getShapeTypes() const;
 
-  /// 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 theValid a boolean flag, if restore happens for valid parameters
-  virtual void restoreAttributeValue(const bool theValid);
-
   /// Set current shape type for selection
   void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
 
@@ -190,15 +179,6 @@ protected:
   QAction* myCopyAction;
   QAction* myDeleteAction;
 
-  /// backup parameters of the model attribute. The class processes three types of attribute:
-  /// Reference, RefAttr and Selection. Depending on the attribute type, only the attribute parameter
-  /// values are reserved in the backup
-  /// Variable of selection type
-  std::string mySelectionType;
-
-  /// Variable of GeomSelection
-  int mySelectionCount; // number of elements in the attribute selection list when store
-
   /// A flag to store use_choice parameter state
   bool myIsUseChoice;
 };
index 5443629a8ac39ffdb2d04defef73fcf2b8263e22..28f94ae02e80bcd47104e0c4247439f2ee7f3363 100755 (executable)
@@ -140,15 +140,6 @@ 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()
 {
@@ -184,7 +175,8 @@ bool ModuleBase_WidgetSelector::setSelectionCustom(const ModuleBase_ViewerPrs& t
   GeomShapePtr aShape;
   getGeomSelection(thePrs, anObject, aShape);
 
-  setObject(anObject, aShape);
+  AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+  ModuleBase_Tools::setObject(anAttribute, anObject, aShape, myWorkshop, false);
   return true;
 }
 
index 2099b0e99b2d11220cdbd4a85e748ac9e37e91a9..a470aa8759fd39564922bdbb8a253213c3a066cb 100755 (executable)
@@ -85,13 +85,6 @@ protected:
   // NDS: has body is temporary
   virtual void updateSelectionName() {};
 
-  /// Store the values to the model attribute of the widget. It casts this attribute to
-  /// the specific type and set the given values
-  /// \param theSelectedObject an object
-  /// \param theShape a selected shape, which is used in the selection attribute
-  /// \return true if it is succeed
-  void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
-
   /// The methiod called when widget is activated
   virtual void activateCustom();
 
diff --git a/src/ModuleBase/ModuleBase_WidgetSelectorStore.cpp b/src/ModuleBase/ModuleBase_WidgetSelectorStore.cpp
new file mode 100755 (executable)
index 0000000..2bf5195
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_WidgetSelectorStore.cpp
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+#include <ModuleBase_WidgetSelectorStore.h>
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_IWorkshop.h>
+
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeRefAttrList.h>
+
+ModuleBase_WidgetSelectorStore::ModuleBase_WidgetSelectorStore()
+: myIsObject(false), mySelectionType(""), mySelectionCount(0)
+{
+}
+
+void ModuleBase_WidgetSelectorStore::storeAttributeValue(const AttributePtr& theAttribute,
+                                                         ModuleBase_IWorkshop* theWorkshop)
+{
+  if (!theAttribute.get())
+    return;
+
+  std::string aType = theAttribute->attributeType();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr =
+                         std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    mySelectionType = aSelectionListAttr->selectionType();
+    mySelectionCount = aSelectionListAttr->size();
+  }
+  else if (aType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr =
+                         std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    mySelectionCount = aRefListAttr->size();
+  }
+  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+    AttributeRefAttrListPtr aRefAttrListAttr =
+                         std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
+    mySelectionCount = aRefAttrListAttr->size();
+  }
+  else {
+    myObject = ModuleBase_Tools::getObject(theAttribute);
+    myShape = ModuleBase_Tools::getShape(theAttribute, theWorkshop);
+    myRefAttribute = AttributePtr();
+    myIsObject = false;
+    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    if (aRefAttr) {
+      myIsObject = aRefAttr->isObject();
+      myRefAttribute = aRefAttr->attr();
+    }
+  }
+}
+
+//********************************************************************
+void ModuleBase_WidgetSelectorStore::restoreAttributeValue(const AttributePtr& theAttribute,
+                                                           ModuleBase_IWorkshop* theWorkshop)
+{
+  std::string aType = theAttribute->attributeType();
+  if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aSelectionListAttr = 
+                   std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    aSelectionListAttr->setSelectionType(mySelectionType);
+    // restore selection in the attribute. Indeed there is only one stored object
+    int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
+    for (int i = 0; i < aCountAppened; i++)
+      aSelectionListAttr->removeLast();
+  }
+  else if (aType == ModelAPI_AttributeRefList::typeId()) {
+    AttributeRefListPtr aRefListAttr = 
+                         std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    // restore objects in the attribute. Indeed there is only one stored object
+    int aCountAppened = aRefListAttr->size() - mySelectionCount;
+    for (int i = 0; i < aCountAppened; i++)
+      aRefListAttr->removeLast();
+  }
+  else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+    AttributeRefAttrListPtr aRefAttrListAttr =
+                     std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
+    // restore objects in the attribute. Indeed there is only one stored object
+    int aCountAppened = aRefAttrListAttr->size() - mySelectionCount;
+    for (int i = 0; i < aCountAppened; i++)
+      aRefAttrListAttr->removeLast();
+  }
+  else {
+    ModuleBase_Tools::setObject(theAttribute, myObject, myShape, theWorkshop, true);
+    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    if (aRefAttr) {
+      if (!myIsObject)
+        aRefAttr->setAttr(myRefAttribute);
+    }
+  }
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetSelectorStore.h b/src/ModuleBase/ModuleBase_WidgetSelectorStore.h
new file mode 100755 (executable)
index 0000000..a3584e3
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_WidgetSelectorStore.h
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModuleBase_WidgetSelectorStore_H
+#define ModuleBase_WidgetSelectorStore_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Attribute.h>
+#include <GeomAPI_Shape.h>
+
+class ModuleBase_IWorkshop;
+
+/**
+* \ingroup GUI
+  Provides for an attribute backup of values. It is possible to store/ restore the attribute values.
+*/
+class MODULEBASE_EXPORT ModuleBase_WidgetSelectorStore
+{
+ public:
+
+  /// Constructor
+  ModuleBase_WidgetSelectorStore();
+  /// Destructor
+  virtual ~ModuleBase_WidgetSelectorStore() {}
+
+  /// Creates a backup of the current values of the attribute
+  /// \param theAttribute a model attribute which parameters are to be stored
+  /// \param theWorkshop a current workshop
+  void storeAttributeValue(const AttributePtr& theAttribute,
+                           ModuleBase_IWorkshop* theWorkshop);
+
+  /// Creates a backup of the current values of the attribute
+  /// \param theAttribute a model attribute which parameters are to be restored
+  /// \param theWorkshop a current workshop
+  void restoreAttributeValue(const AttributePtr& theAttribute,
+                             ModuleBase_IWorkshop* theWorkshop);
+
+private:
+  /// backup parameters of the model attribute. The class processes three types of attribute:
+  /// Reference, RefAttr and Selection. Depending on the attribute type, only the attribute parameter
+  /// values are reserved in the backup
+  /// An attribute object
+  ObjectPtr myObject;
+  /// An attribute shape
+  GeomShapePtr myShape;
+  /// A reference of the attribute
+  AttributePtr myRefAttribute;
+  /// A boolean value whether refAttr uses reference of object
+  bool myIsObject;
+
+  /// Variable of selection type
+  std::string mySelectionType;
+  /// Variable of GeomSelection
+  int mySelectionCount; // number of elements in the attribute selection list when store
+
+};
+
+#endif
index b4b7083670b122fd6a5fda36f3c7eddce80b4cf8..1bcedc636d2b0f5b1aab86c694cf2c79e844104c 100644 (file)
@@ -184,22 +184,10 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const
 {
   GeomShapePtr aShape;
   DataPtr aData = myFeature->data();
-  if (!aData->isValid())
-    return aShape;
-
-  std::string aType = aData->attribute(attributeID())->attributeType();
-  if (aType == ModelAPI_AttributeReference::typeId()) {
-  } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
-    if (aRefAttr.get() && !aRefAttr->isObject()) {
-      AttributePtr anAttribute = aRefAttr->attr();
-      aShape = myWorkshop->module()->findShape(anAttribute);
-    }
-  } else if (aType == ModelAPI_AttributeSelection::typeId()) {
-    AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
-    aShape = aSelectAttr->value();
+  if (aData->isValid()) {
+    AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+    aShape = ModuleBase_Tools::getShape(anAttribute, myWorkshop);
   }
-
   return aShape;
 }
 
@@ -234,38 +222,3 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName()
     }
   }
 }
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::storeAttributeValue()
-{
-  ModuleBase_WidgetValidated::storeAttributeValue();
-
-  DataPtr aData = myFeature->data();
-  AttributePtr anAttribute = myFeature->attribute(attributeID());
-
-  myObject = ModuleBase_Tools::getObject(anAttribute);
-  myShape = getShape();
-  myRefAttribute = AttributePtr();
-  myIsObject = false;
-  AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
-  if (aRefAttr) {
-    myIsObject = aRefAttr->isObject();
-    myRefAttribute = aRefAttr->attr();
-  }
-}
-
-//********************************************************************
-void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid)
-{
-  ModuleBase_WidgetValidated::restoreAttributeValue(theValid);
-
-  DataPtr aData = myFeature->data();
-  AttributePtr anAttribute = myFeature->attribute(attributeID());
-
-  setObject(myObject, myShape);
-  AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
-  if (aRefAttr) {
-    if (!myIsObject)
-      aRefAttr->setAttr(myRefAttribute);
-  }
-}
index ec1fe5f4970ed4e78408241f2aceb0ade8a328e2..ca7f636ecd77cdfbfc6276e1d95edef20e703f2b 100644 (file)
@@ -88,17 +88,6 @@ Q_OBJECT
 
   virtual bool restoreValueCustom();
 
-  /// 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
-  virtual void storeAttributeValue();
-
-  /// 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 theValid a boolean flag, if restore happens for valid parameters
-  virtual void restoreAttributeValue(const bool theValid);
-
   /// Computes and updates name of selected object in the widget
   virtual void updateSelectionName();
 
@@ -128,18 +117,6 @@ Q_OBJECT
 
   /// List of accepting shapes types
   QStringList myShapeTypes;
-
-  /// backup parameters of the model attribute. The class processes three types of attribute:
-  /// Reference, RefAttr and Selection. Depending on the attribute type, only the attribute parameter
-  /// values are reserved in the backup
-  /// An attribute object
-  ObjectPtr myObject;
-  /// An attribute shape
-  GeomShapePtr myShape;
-  /// A reference of the attribute
-  AttributePtr myRefAttribute;
-  /// A boolean value whether refAttr uses reference of object
-  bool myIsObject;
 };
 
 #endif
index a5a639132c5b3621ad73458bc2d9163885d1a1b0..fd41a85f5ed8131942641cd40ec47e1570792d98 100644 (file)
@@ -4,6 +4,7 @@
 #include <ModuleBase_FilterFactory.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_ISelection.h>
+#include <ModuleBase_WidgetSelectorStore.h>
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
@@ -26,12 +27,14 @@ ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent,
                                                        ModuleBase_IWorkshop* theWorkshop,
                                                        const Config_WidgetAPI* theData)
 : ModuleBase_ModelWidget(theParent, theData),
-  myWorkshop(theWorkshop), myIsInValidate(false)
+  myWorkshop(theWorkshop)
 {
+  myAttributeStore = new ModuleBase_WidgetSelectorStore();
 }
 
 ModuleBase_WidgetValidated::~ModuleBase_WidgetValidated()
 {
+  delete myAttributeStore;
 }
 
 //********************************************************************
@@ -54,12 +57,21 @@ void ModuleBase_WidgetValidated::clearValidatedCash()
 void ModuleBase_WidgetValidated::storeAttributeValue()
 {
   myIsInValidate = true;
+  DataPtr aData = myFeature->data();
+  AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+  myAttributeStore->storeAttributeValue(anAttribute, myWorkshop);
 }
 
 //********************************************************************
 void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid)
 {
   myIsInValidate = false;
+
+  DataPtr aData = myFeature->data();
+  AttributePtr anAttribute = myFeature->attribute(attributeID());
+
+  myAttributeStore->restoreAttributeValue(anAttribute, myWorkshop);
 }
 
 //********************************************************************
index 0d31b0add9b0ec35f978c84c46c7320860556abb..5f8aae3b76815ae9c7c464e915d7fbfa06b4f211 100644 (file)
@@ -22,6 +22,7 @@
 class QWidget;
 class ModuleBase_IWorkshop;
 class ModuleBase_ISelection;
+class ModuleBase_WidgetSelectorStore;
 class ModelAPI_Validator;
 class Config_WidgetAPI;
 class Handle_SelectMgr_EntityOwner;
@@ -137,6 +138,9 @@ private:
   ObjectPtr myPresentedObject; /// back up of the filtered object
   QList<ModuleBase_ViewerPrs> myValidPrs; /// cash of valid selection presentations
   QList<ModuleBase_ViewerPrs> myInvalidPrs; /// cash of invalid selection presentations
+
+  /// store to backup parameters of the model
+  ModuleBase_WidgetSelectorStore* myAttributeStore;
 };
 
 #endif /* MODULEBASE_WIDGETVALIDATED_H_ */
index 2f94057a7bda524338c56b35e241a7ff4a77be0b..a69a78992b495c2e8fdca882474cdb03de9a7f90 100644 (file)
@@ -55,7 +55,7 @@ protected:
   /// It should be realized in the specific widget because of different
   /// parameters of the current attribute
   /// \param theValid a boolean flag, if restore happens for valid parameters
-  void restoreAttributeValue(const bool theValid);
+  virtual void restoreAttributeValue(const bool theValid);
 
   /// Return an object and geom shape by the viewer presentation
   /// \param thePrs a selection