X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDSImpl%2FSALOMEDSImpl_AttributeTreeNode.cxx;h=1b4d5167f784da2761f7ac87aef03b52c8458c79;hb=15a97ac169f8acd9cfcb6c4f9ef236d79c9d6a32;hp=7bcc8e66cfeed78b713caff5c0902491db3039fe;hpb=288dc1c84630e521220d796b7c88c518f34856d5;p=modules%2Fkernel.git diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx index 7bcc8e66c..1b4d5167f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// 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 @@ -64,8 +64,9 @@ const std::string& SALOMEDSImpl_AttributeTreeNode::ID() const //======================================================================= //function : Append //purpose : Add as last child of me +//return : index of TN under this, in C mode //======================================================================= -bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN) +bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN, int* childIndex) { CheckLocked(); @@ -76,6 +77,7 @@ bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN) TN->SetNext(NULL); // Deconnects from next. // Find the last + int index = 0; if (!HasFirst()) { SetFirst(TN); TN->SetPrevious(NULL); // Deconnects from previous. @@ -84,15 +86,20 @@ bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN) SALOMEDSImpl_AttributeTreeNode* Last = GetFirst(); while (Last && Last->HasNext()) { Last = Last->GetNext(); + ++index; } Last->SetNext(TN); TN->SetPrevious(Last); + ++index; } // Set Father TN->SetFather(this); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved - + + if ( childIndex ) + *childIndex = index; + return (TN); } @@ -457,7 +464,7 @@ std::string SALOMEDSImpl_AttributeTreeNode::Save() if (HasFirst()) aFirst = GetFirst()->Label().Entry(); else aFirst = "!"; int aLength = 4; - aLength += aFather.size() + aPrevious.size() + aNext.size() + aFirst.size(); + aLength += (int)(aFather.size() + aPrevious.size() + aNext.size() + aFirst.size()); //!< TODO: conversion from size_t to int char* aResult = new char[aLength]; sprintf(aResult, "%s %s %s %s", aFather.c_str(), aPrevious.c_str(), aNext.c_str(), aFirst.c_str()); std::string ret(aResult);