Salome HOME
Remove not needed attributes from the field feature: they are duplicated in the Table...
authormpv <mpv@opencascade.com>
Wed, 23 Nov 2016 13:08:52 +0000 (16:08 +0300)
committermpv <mpv@opencascade.com>
Wed, 23 Nov 2016 13:08:52 +0000 (16:08 +0300)
src/CollectionAPI/CollectionAPI_Field.cpp
src/CollectionAPI/CollectionAPI_Field.h
src/CollectionPlugin/CollectionPlugin_Field.cpp
src/CollectionPlugin/CollectionPlugin_Field.h
src/CollectionPlugin/Test/TestField.py

index 98110e8614372fb272e78498ad9f7d00b2f000c8..072041e7715dda237b384f4140f5b15dd009227d 100644 (file)
@@ -44,7 +44,6 @@ void CollectionAPI_Field::setComponentsNames(const std::list<std::string>& theNa
 //=================================================================================================
 void CollectionAPI_Field::setValuesType(const std::string& theType)
 {
-  fillAttribute(int(valueTypeByStr(theType)), myvaluesType);
   myvalues->setType(valueTypeByStr(theType));
   execute();
 }
@@ -52,7 +51,6 @@ void CollectionAPI_Field::setValuesType(const std::string& theType)
 //=================================================================================================
 void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps)
 {
-  fillAttribute(theSteps, mystepsNum);
   mystamps->setSize(theSteps.intValue());
   execute();
 }
@@ -70,8 +68,6 @@ void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, \
   const ModelHighAPI_Integer& theStamp, \
   const std::list<std::list<type> >& theComponents) \
 { \
-  myvalues->setSize(myselection->size() + 1, \
-    mycomponentsNames->size(), mystepsNum->value()); \
   mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \
   int aRowIndex = 0; \
   std::list<std::list<type> >::const_iterator \
@@ -101,9 +97,8 @@ void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const
   FeaturePtr aBase = feature();
   const std::string& aDocName = theDumper.name(aBase->document());
 
-  theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<mystepsNum->value()<<", \""
-    <<strByValueType(ModelAPI_AttributeTables::ValueType(myvaluesType->value()))<<"\", "
-    <<mycomponentsNames->size()<<", ";
+  theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<myvalues->tables()<<", \""
+    <<strByValueType(myvalues->type())<<"\", "<<mycomponentsNames->size()<<", ";
   theDumper<<mycomponentsNames<<", ";
   theDumper<<myselection<<")"<<std::endl;
   // set values step by step
@@ -116,7 +111,7 @@ void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const
       for(int aCol = 0; aCol < myvalues->columns(); aCol++) {
         if (aCol != 0)
           theDumper<<", ";
-        switch(myvaluesType->value()) {
+        switch(myvalues->type()) {
         case ModelAPI_AttributeTables::BOOLEAN:
           theDumper<<myvalues->value(aRow, aCol, aStep).myBool;
           break;
@@ -137,6 +132,11 @@ void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const
   }
 }
 
+std::shared_ptr<ModelAPI_AttributeTables> CollectionAPI_Field::tableValues()
+{
+  return myvalues;
+}
+
 //=================================================================================================
 FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const ModelHighAPI_Integer& theStepsNum,
@@ -151,6 +151,8 @@ FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
   aField->setValuesType(theComponentType);
   aField->setComponentsNames(theComponentNames);
   aField->setSelection(theSelectionList);
+  aField->tableValues()->setSize(
+    int(theSelectionList.size() + 1), theComponentsNum, theStepsNum.intValue());
 
   return aField;
 }
index d7eef3ee58e4596a1cc5a0517f1c26dd931fae7a..302dff44ade2b52c0d6ca2425fc61c0d4a8cc057 100644 (file)
@@ -33,15 +33,11 @@ public:
   COLLECTIONAPI_EXPORT
   virtual ~CollectionAPI_Field();
 
-  INTERFACE_6(CollectionPlugin_Field::ID(),
+  INTERFACE_4(CollectionPlugin_Field::ID(),
     selection, CollectionPlugin_Field::SELECTED_ID(),
     ModelAPI_AttributeSelectionList, /** Field selection list*/,
     componentsNames, CollectionPlugin_Field::COMPONENTS_NAMES_ID(),
     ModelAPI_AttributeStringArray, /** Names of components list of strings */,
-    valuesType, CollectionPlugin_Field::VALUES_TYPE_ID(),
-    ModelAPI_AttributeInteger, /** Type of the values enumeration */,
-    stepsNum, CollectionPlugin_Field::STEPS_NB_ID(),
-    ModelAPI_AttributeInteger, /** Number of steps integer */,
     stamps, CollectionPlugin_Field::STAMPS_ID(),
     ModelAPI_AttributeIntArray, /** Identifiers of stamps */,
     values, CollectionPlugin_Field::VALUES_ID(), ModelAPI_AttributeTables /** Table of values */,
@@ -82,6 +78,11 @@ public:
   /// Dump wrapped feature
   COLLECTIONAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+
+  /// Returns the internal values tables
+  COLLECTIONAPI_EXPORT
+  std::shared_ptr<ModelAPI_AttributeTables> tableValues();
+
 };
 
 /// Pointer on Field object.
index 55fefb6a587e32da05f43fd2cbad17258aecc645..e1921c0b693073480fbbce76a3cdde76277d09a2 100644 (file)
@@ -23,8 +23,6 @@ void CollectionPlugin_Field::initAttributes()
 {
   data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray::typeId());
-  //data()->addAttribute(VALUES_TYPE_ID(), ModelAPI_AttributeInteger::typeId());
-  //data()->addAttribute(STEPS_NB_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(STAMPS_ID(), ModelAPI_AttributeIntArray::typeId());
   data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId());
 }
index 2025c5b51508aad3fbd193710bbe2e236120c8d7..11b8deb5455fe89dca6728aaddc3cdc0c65dd420 100644 (file)
@@ -47,18 +47,6 @@ class CollectionPlugin_Field : public ModelAPI_Feature
     static const std::string MY_COMPONENTS_NAMES_ID("components_names");
     return MY_COMPONENTS_NAMES_ID;
   }
-  /// attribute name of values types integer identifier
-  inline static const std::string& VALUES_TYPE_ID()
-  {
-    static const std::string MY_VALUES_TYPE_ID("type");
-    return MY_VALUES_TYPE_ID;
-  }
-  /// attribute name of number of steps
-  inline static const std::string& STEPS_NB_ID()
-  {
-    static const std::string MY_STEPS_NB_ID("steps_nb");
-    return MY_STEPS_NB_ID;
-  }
   /// attribute name of stamps integer array
   inline static const std::string& STAMPS_ID()
   {
index 5bf10bdacc3a4cda80eb05ffe06b6e999839dd43..d6ae47a5667fce2a0e33e1194a2da4a641a8bc98 100644 (file)
@@ -66,8 +66,8 @@ anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0])
 anExtrusionFt.string("CreationMethod").setValue("BySizes")
 anExtrusionFt.real("to_size").setValue(50)
 anExtrusionFt.real("from_size").setValue(50)
-anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
-anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("to_offset").setValue(0)
+anExtrusionFt.real("from_offset").setValue(0)
 anExtrusionFt.execute()
 aSession.finishOperation()
 anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
@@ -85,13 +85,11 @@ aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(2) # two components
 aComponentNames.setValue(0, "temperatue")
 aComponentNames.setValue(1, "porosity")
-aField.integer("type").setValue(2) # double
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 10)
 aTables = aField.tables("values")
-aTables.setType(2)
+aTables.setType(2) # double
 aTables.setSize(1 + 3, 2, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(20, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(35, 1, 0, 0)
@@ -113,14 +111,12 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(3) # string
-aField.integer("steps_nb").setValue(2) # two steps
 aStamps = aField.intArray("stamps")
-aStamps.setSize(2)
+aStamps.setSize(2) # two steps
 aStamps.setValue(0, 1)
 aStamps.setValue(1, 3)
 aTables = aField.tables("values")
-aTables.setType(3)
+aTables.setType(3) # string
 aTables.setSize(1 + 1, 1, 2) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue("-default-", 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue("-default-", 0, 0, 1)
@@ -141,13 +137,11 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(1) # integer
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 0)
 aTables = aField.tables("values")
-aTables.setType(1)
+aTables.setType(1) # integer
 aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(0, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(2, 1, 0, 0)
@@ -167,13 +161,11 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(0) # boolean
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 0)
 aTables = aField.tables("values")
-aTables.setType(0)
+aTables.setType(0) # boolean
 aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(True, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(False, 1, 0, 0)