Salome HOME
Copyright update 2020
[modules/shaper.git] / src / CollectionAPI / CollectionAPI_Field.cpp
index 4c8cd32649eda3e8cf93b0d369d3ffa4ed387eb4..c1333c060f22a39776b7f7296f06b18b0596d950 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        CollectionAPI_Field.cpp
-// Created:     16 Nov 2016
-// Author:      Mikhail Ponikarov
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "CollectionAPI_Field.h"
 
@@ -34,13 +47,6 @@ void CollectionAPI_Field::setSelection(const std::list<ModelHighAPI_Selection>&
   execute();
 }
 
-//=================================================================================================
-void CollectionAPI_Field::setComponentsNum(const ModelHighAPI_Integer& theNum)
-{
-  fillAttribute(theNum, mycomponentsNum);
-  execute();
-}
-
 //=================================================================================================
 void CollectionAPI_Field::setComponentsNames(const std::list<std::string>& theNames)
 {
@@ -51,7 +57,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();
 }
@@ -59,7 +64,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();
 }
@@ -77,8 +81,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, \
-    mycomponentsNum->value(), mystepsNum->value()); \
   mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \
   int aRowIndex = 0; \
   std::list<std::list<type> >::const_iterator \
@@ -108,9 +110,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()))<<"\", "
-    <<mycomponentsNum->value()<<", ";
+  theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<myvalues->tables()<<", \""
+    <<strByValueType(myvalues->type())<<"\", "<<mycomponentsNames->size()<<", ";
   theDumper<<mycomponentsNames<<", ";
   theDumper<<myselection<<")"<<std::endl;
   // set values step by step
@@ -123,7 +124,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;
@@ -144,6 +145,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,
@@ -156,9 +162,10 @@ FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
   std::shared_ptr<CollectionAPI_Field> aField(new CollectionAPI_Field(aFeature));
   aField->setStepsNum(theStepsNum);
   aField->setValuesType(theComponentType);
-  aField->setComponentsNum(theComponentsNum);
   aField->setComponentsNames(theComponentNames);
   aField->setSelection(theSelectionList);
+  aField->tableValues()->setSize(
+    int(theSelectionList.size() + 1), theComponentsNum, theStepsNum.intValue());
 
   return aField;
 }