X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultField.cpp;h=985b66f2fccf03f200335e8af2073ea8cf48559f;hb=72b9423caaa48805589d6ab87d366f79ecde5bfe;hp=f10fe16af5149947712cb3342fee565672f09768;hpb=08203d89ebbd4b7d85b6fdfe6075cb4bfa9dc0d3;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultField.cpp b/src/Model/Model_ResultField.cpp index f10fe16af..985b66f2f 100644 --- a/src/Model/Model_ResultField.cpp +++ b/src/Model/Model_ResultField.cpp @@ -1,14 +1,30 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: Model_ResultField.cpp -// Created: 08 Jul 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2017 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 -#include #include + #include #include +#include +#include #include @@ -19,6 +35,14 @@ Model_ResultField::Model_ResultField(std::shared_ptr theOwnerData myOwnerData = theOwnerData; } +Model_ResultField::~Model_ResultField() +{ + while(mySteps.size() > 0) { + delete mySteps.back(); + mySteps.pop_back(); + } +} + void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault) { @@ -45,7 +69,7 @@ std::shared_ptr Model_ResultField::shape() for(int a = 0; a < aResults; a++) { ResultBodyPtr aBody = std::dynamic_pointer_cast( document()->object(ModelAPI_ResultBody::group(), a)); - if (!aBody.get()) + if (!aBody.get()) continue; // check that only results that were created before this field are used FeaturePtr aResultFeature = document()->feature(aBody); @@ -70,6 +94,57 @@ std::shared_ptr Model_ResultField::shape() aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs); } } + updateSteps(); } return aResult; } + +void Model_ResultField::updateSteps() +{ + // Update Array of steps + int aNbSteps = stepsSize(); + if (mySteps.size() != aNbSteps) { + while(mySteps.size() > aNbSteps) { + delete mySteps.back(); + mySteps.pop_back(); + } + while(mySteps.size() < aNbSteps) { + mySteps.push_back(new Model_ResultField::Model_FieldStep(this, mySteps.size())); + } + } +} + +int Model_ResultField::stepsSize() const +{ + if (myOwnerData) { + AttributeIntArrayPtr aArray = myOwnerData->intArray("stamps"); + if (aArray.get()) { + return aArray->size(); + } + } + return 0; +} + +std::string Model_ResultField::textLine(int theLine) const +{ + if (myOwnerData) { + AttributeIntArrayPtr aArray = myOwnerData->intArray("stamps"); + if (aArray.get()) { + if (theLine < aArray->size()) { + std::ostringstream aStream; + aStream << aArray->value(theLine); + return aStream.str(); + } + } + } + return ""; +} + + +ModelAPI_ResultField::ModelAPI_FieldStep* Model_ResultField::step(int theId) const +{ + if (theId < mySteps.size()) { + return mySteps[theId]; + } + return NULL; +}