X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCollectionAPI%2FCollectionAPI_Field.cpp;h=13204418ade6b2e0010ee8b7dfc5b7adb09864c7;hb=refs%2Fheads%2FCR35150;hp=b0441e4859231c540113c2bc819f4f5064669e42;hpb=266f5a5c2132719049c303265adee362d0e702b4;p=modules%2Fshaper.git diff --git a/src/CollectionAPI/CollectionAPI_Field.cpp b/src/CollectionAPI/CollectionAPI_Field.cpp index b0441e485..13204418a 100644 --- a/src/CollectionAPI/CollectionAPI_Field.cpp +++ b/src/CollectionAPI/CollectionAPI_Field.cpp @@ -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-2023 CEA, EDF +// +// 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" @@ -10,7 +23,6 @@ #include #include #include -#include #include #include @@ -35,13 +47,6 @@ void CollectionAPI_Field::setSelection(const std::list& execute(); } -//================================================================================================= -void CollectionAPI_Field::setComponentsNum(const ModelHighAPI_Integer& theNum) -{ - fillAttribute(theNum, mycomponentsNum); - execute(); -} - //================================================================================================= void CollectionAPI_Field::setComponentsNames(const std::list& theNames) { @@ -52,14 +57,14 @@ void CollectionAPI_Field::setComponentsNames(const std::list& theNa //================================================================================================= void CollectionAPI_Field::setValuesType(const std::string& theType) { - fillAttribute(int(valueTypeByStr(theType)), myvaluesType); + myvalues->setType(valueTypeByStr(theType)); execute(); } //================================================================================================= void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps) { - fillAttribute(theSteps, mystepsNum); + mystamps->setSize(theSteps.intValue()); execute(); } @@ -71,37 +76,42 @@ void CollectionAPI_Field::setStamps(const std::list& theSt } //================================================================================================= -void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, - const ModelHighAPI_Integer& theStamp, - const std::list >& theComponents) -{ - // set the table size to be sure the values are up to date - myvalues->setSize(myselection->size() + 1 /* with defaults */, - mycomponentsNum->value(), mystepsNum->value()); - - // set values one by one - int aRowIndex = 0; - std::list >::const_iterator - aRowsIter = theComponents.begin(); - for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) { - int aColIndex = 0; - std::list::const_iterator aColIter = aRowsIter->begin(); - for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) { - aColIter->fill(myvalues, theStepNum.intValue(), aColIndex, aRowIndex); - } - } - execute(); +#define addStepImplementation(type, fieldType, type2, fieldType2, type3, fieldType3) \ +void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, \ + const ModelHighAPI_Integer& theStamp, \ + const std::list >& theComponents) \ +{ \ + mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \ + int aRowIndex = 0; \ + std::list >::const_iterator \ + aRowsIter = theComponents.begin(); \ + for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) { \ + int aColIndex = 0; \ + std::list::const_iterator aColIter = aRowsIter->begin(); \ + for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) { \ + ModelAPI_AttributeTables::Value aVal; \ + aVal.fieldType = *aColIter; \ + aVal.fieldType2 = type2(*aColIter); \ + aVal.fieldType3 = type3(*aColIter); \ + myvalues->setValue(aVal, aRowIndex, aColIndex, theStepNum.intValue()); \ + } \ + } \ + execute(); \ } +addStepImplementation(double, myDouble, int, myInt, bool, myBool); +addStepImplementation(int, myInt, double, myDouble, bool, myBool); +addStepImplementation(bool, myBool, int, myInt, double, myDouble); +addStepImplementation(std::string, myStr, std::string, myStr, std::string, myStr); + //================================================================================================= void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const { FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - theDumper<value()))<<", " - <value()<<", "; + theDumper<tables()<<", \"" + <type())<<"\", "<size()<<", "; theDumper<value(aRow, aCol, aStep).myDouble; break; case ModelAPI_AttributeTables::STRING: - theDumper<value(aRow, aCol, aStep).myStr; + theDumper<<'"'<value(aRow, aCol, aStep).myStr<<'"'; break; } } theDumper<<"]"; } - theDumper<<")"< CollectionAPI_Field::tableValues() +{ + return myvalues; +} + //================================================================================================= FieldPtr addField(const std::shared_ptr& thePart, const ModelHighAPI_Integer& theStepsNum, - std::string& theComponentType, + const std::string& theComponentType, const int theComponentsNum, const std::list& theComponentNames, const std::list& theSelectionList) @@ -147,9 +162,10 @@ FieldPtr addField(const std::shared_ptr& thePart, std::shared_ptr 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; }