X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDSImpl%2FSALOMEDSImpl_AttributeIOR.cxx;h=ce6a63dbc6eba95954fbc3885930162f773eb32f;hb=a98a09635ad776cf8eb98664e0933760eb9edbe4;hp=85b8355a694a95b593e651aa01a6deab8d173b3c;hpb=35960e77d7f9f2a5cac7d6550c23f12943bc4378;p=modules%2Fkernel.git diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx index 85b8355a6..ce6a63dbc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -1,67 +1,58 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // 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. -// -// 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 +// 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 +// 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/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : SALOMEDSImpl_AttributeIOR.cxx // Author : Sergey RUIN // Module : SALOME - -#ifndef WNT -using namespace std; -#endif +// #include "SALOMEDSImpl_AttributeIOR.hxx" -#include #include "SALOMEDSImpl_Study.hxx" -#include - -IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeIOR, SALOMEDSImpl_GenericAttribute ) -IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeIOR, SALOMEDSImpl_GenericAttribute ) - //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeIOR::GetID () +const std::string& SALOMEDSImpl_AttributeIOR::GetID () { - static Standard_GUID SALOMEDSImpl_AttributeIORID ("92888E01-7074-11d5-A690-0800369C8A03"); + static std::string SALOMEDSImpl_AttributeIORID ("92888E01-7074-11d5-A690-0800369C8A03"); return SALOMEDSImpl_AttributeIORID; } - - //======================================================================= //function : Set //purpose : //======================================================================= -Handle(SALOMEDSImpl_AttributeIOR) SALOMEDSImpl_AttributeIOR::Set (const TDF_Label& L, - const TCollection_ExtendedString& S) +SALOMEDSImpl_AttributeIOR* SALOMEDSImpl_AttributeIOR::Set (const DF_Label& L, + const std::string& S) { - Handle(SALOMEDSImpl_AttributeIOR) A; - if (!L.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(),A)) { + SALOMEDSImpl_AttributeIOR* A = NULL; + if (!(A=(SALOMEDSImpl_AttributeIOR*)L.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) { A = new SALOMEDSImpl_AttributeIOR(); L.AddAttribute(A); } A->SetValue(S); - SALOMEDSImpl_Study::IORUpdated(A); return A; } @@ -69,27 +60,35 @@ Handle(SALOMEDSImpl_AttributeIOR) SALOMEDSImpl_AttributeIOR::Set (const TDF_Labe //function : SetValue //purpose : //======================================================================= -void SALOMEDSImpl_AttributeIOR::SetValue(const TCollection_ExtendedString& theValue) +void SALOMEDSImpl_AttributeIOR::SetValue(const std::string& theValue) { CheckLocked(); - Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(Label()); - aStudy->AddCreatedPostponed(theValue); - aStudy->AddPostponed(theValue); - Backup(); + //remove IOR entry in study + if(theValue != myString) + { + SALOMEDSImpl_Study* study=SALOMEDSImpl_Study::GetStudyImpl(Label()); + study->RegisterGenObj(theValue, Label()); + study->UnRegisterGenObj(myString, Label()); + study->DeleteIORLabelMapItem(myString); + } + myString = theValue; + //add IOR entry in study SALOMEDSImpl_Study::IORUpdated(this); - - //SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved + + //Reason = 5 means that IOR attribute updated + //Used in the gui module to detect that IOR attribure was assigned to the object + SetModifyFlag(5); } //======================================================================= //function : Value //purpose : //======================================================================= -TCollection_ExtendedString SALOMEDSImpl_AttributeIOR::Value() const +std::string SALOMEDSImpl_AttributeIOR::Value() const { return myString; } @@ -103,12 +102,17 @@ SALOMEDSImpl_AttributeIOR::SALOMEDSImpl_AttributeIOR() { } +SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR() +{ + SALOMEDSImpl_Study::UnRegisterGenObj(myString, Label()); +} + //======================================================================= //function : ID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeIOR::ID () const { return GetID(); } +const std::string& SALOMEDSImpl_AttributeIOR::ID () const { return GetID(); } //======================================================================= @@ -116,7 +120,7 @@ const Standard_GUID& SALOMEDSImpl_AttributeIOR::ID () const { return GetID(); } //purpose : //======================================================================= -Handle(TDF_Attribute) SALOMEDSImpl_AttributeIOR::NewEmpty () const +DF_Attribute* SALOMEDSImpl_AttributeIOR::NewEmpty () const { return new SALOMEDSImpl_AttributeIOR(); } @@ -126,9 +130,9 @@ Handle(TDF_Attribute) SALOMEDSImpl_AttributeIOR::NewEmpty () const //purpose : //======================================================================= -void SALOMEDSImpl_AttributeIOR::Restore(const Handle(TDF_Attribute)& with) +void SALOMEDSImpl_AttributeIOR::Restore( DF_Attribute* with) { - myString = Handle(SALOMEDSImpl_AttributeIOR)::DownCast (with)->Value(); + myString = dynamic_cast(with)->Value(); return; } @@ -137,9 +141,8 @@ void SALOMEDSImpl_AttributeIOR::Restore(const Handle(TDF_Attribute)& with) //purpose : //======================================================================= -void SALOMEDSImpl_AttributeIOR::Paste (const Handle(TDF_Attribute)& into, - const Handle(TDF_RelocationTable)& RT) const +void SALOMEDSImpl_AttributeIOR::Paste (DF_Attribute* into) { - Handle(SALOMEDSImpl_AttributeIOR)::DownCast (into)->SetValue(myString); + dynamic_cast(into)->SetValue(myString); }