From 1f41d6c80d0f5caea5352b8ada08a07f6d5319a0 Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 20 Sep 2005 14:44:25 +0000 Subject: [PATCH] Fix some problems with Study Properties --- .../SALOMEDS_AttributeStudyProperties.cxx | 218 ++++++++-------- .../SALOMEDS_AttributeStudyProperties_i.cxx | 106 ++++---- .../SALOMEDSImpl_AttributeStudyProperties.cxx | 152 ++++++----- .../SALOMEDSImpl_AttributeStudyProperties.hxx | 81 +++--- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 240 +++++++++--------- .../SALOMEDSImpl_StudyManager.cxx | 190 +++++++------- 6 files changed, 505 insertions(+), 482 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx index 09bb75f94..8ba288b42 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx @@ -5,36 +5,42 @@ #include "SALOMEDS_AttributeStudyProperties.hxx" #include -#include +#include #include #include #include -SALOMEDS_AttributeStudyProperties -::SALOMEDS_AttributeStudyProperties(const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr) +SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties + (const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties(SALOMEDS::AttributeStudyProperties_ptr theAttr) +SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties + (SALOMEDS::AttributeStudyProperties_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties() { } - + void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetUserName((char*)theName.c_str()); - else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str()); + if (_isLocal) { + Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); + anImpl->ChangeCreatorName((char*)theName.c_str()); + } else + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str()); } std::string SALOMEDS_AttributeStudyProperties::GetUserName() { std::string aName; - if(_isLocal) { - TCollection_AsciiString N = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName(); - aName = N.ToCString(); + if (_isLocal) { + TCollection_ExtendedString S = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName(); + aName = TCollection_AsciiString(S).ToCString(); } #ifndef WNT else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName(); @@ -44,108 +50,123 @@ std::string SALOMEDS_AttributeStudyProperties::GetUserName() return aName; } -void SALOMEDS_AttributeStudyProperties::SetCreationDate(int theMinute, int theHour, int theDay, int theMonth, int theYear) +void SALOMEDS_AttributeStudyProperties::SetCreationDate + (int theMinute, int theHour, int theDay, int theMonth, int theYear) { - if(_isLocal) - Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModificationDate(theMinute, - theHour, - theDay, - theMonth, - theYear); - else - SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute, - theHour, - theDay, - theMonth, + if (_isLocal) { + Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); + int aTmp; + if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return; + TCollection_ExtendedString S; + anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear); + } else { + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute, + theHour, + theDay, + theMonth, theYear); + } } -bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute, - int& theHour, - int& theDay, - int& theMonth, +bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute, + int& theHour, + int& theDay, + int& theMonth, int& theYear) { bool ret; - if(_isLocal) - ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationDate(theMinute, - theHour, - theDay, - theMonth, - theYear); - else { + if (_isLocal) { + ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast + (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear); + } else { CORBA::Long aMinute, anHour, aDay, aMonth, anYear; - ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute, - anHour, - aDay, - aMonth, + ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute, + anHour, + aDay, + aMonth, anYear); - theMinute = (int)aMinute; theHour = (int)anHour; theDay = (int)aDay; theMonth = (int)aMonth; theYear = (int)anYear; + theMinute = (int)aMinute; + theHour = (int)anHour; + theDay = (int)aDay; + theMonth = (int)aMonth; + theYear = (int)anYear; } return ret; } - + void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode) { - if(_isLocal) { - if(theMode == "from scratch") + if (_isLocal) { + if (theMode == "from scratch") Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1); - else if(theMode == "copy from") + else if (theMode == "copy from") Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(2); else //Not defined Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(0); } else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str()); } - + std::string SALOMEDS_AttributeStudyProperties::GetCreationMode() { std::string aMode; - if(_isLocal) { + if (_isLocal) { int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode(); - if(mode == 1) aMode = "from scratch"; - if(mode == 2) aMode = "copy from"; + if (mode == 1) aMode = "from scratch"; + if (mode == 2) aMode = "copy from"; } - else aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode(); - return aMode; + else + aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode(); + return aMode; } void SALOMEDS_AttributeStudyProperties::SetModified(int theModified) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified); - else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified); + if (_isLocal) + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified); + else + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified); } - + bool SALOMEDS_AttributeStudyProperties::IsModified() { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified(); - else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified(); + if (_isLocal) + ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified(); + else + ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified(); return ret; } int SALOMEDS_AttributeStudyProperties::GetModified() { int isModified; - if(_isLocal) isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified(); - else isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified(); + if (_isLocal) + isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified(); + else + isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified(); return isModified; } void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked); - else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked); + if (_isLocal) + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked); + else + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked); } - + bool SALOMEDS_AttributeStudyProperties::IsLocked() { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked(); - else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked(); + if (_isLocal) + ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked(); + else + ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked(); return ret; } - + void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName, int theMinute, int theHour, @@ -153,20 +174,17 @@ void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theNa int theMonth, int theYear) { - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetUserName((char*)theName.c_str()); - Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModificationDate(theMinute, - theHour, - theDay, - theMonth, - theYear); - } - else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(), - theMinute, - theHour, - theDay, - theMonth, - theYear); + if (_isLocal) { + Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); + anImpl->SetModification((char*)theName.c_str(), theMinute, theHour, theDay, theMonth, theYear); + } else + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(), + theMinute, + theHour, + theDay, + theMonth, + theYear); } void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector& theNames, @@ -177,41 +195,36 @@ void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector& theYears, bool theWithCreator) { - int i, aLength; - - if(_isLocal) { + + if (_isLocal) { Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aNames = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetUserNames(); - Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModificationDates(aMinutes, - aHours, - aDays, - aMonths, - aYears); - aLength = aNames->Length()-((theWithCreator)?0:1); - for(i = 0; i < aLength; i++) - { - theNames.push_back(TCollection_AsciiString(aNames->Value(i + 1 + ((theWithCreator)?0:1))).ToCString()); - theMinutes.push_back(aMinutes->Value(i + 1 + ((theWithCreator)?0:1))); - theHours.push_back(aHours->Value(i + 1 + ((theWithCreator)?0:1))); - theDays.push_back(aDays->Value(i + 1 + ((theWithCreator)?0:1))); - theMonths.push_back(aMonths->Value(i + 1 + ((theWithCreator)?0:1))); - theYears.push_back(aYears->Value(i + 1 + ((theWithCreator)?0:1))); - } - } - else { + Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); + anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); + aLength = aNames->Length(); + i = ((theWithCreator) ? 1 : 2); + for (; i <= aLength; i++) { + theNames.push_back(TCollection_AsciiString(aNames->Value(i)).ToCString()); + theMinutes.push_back(aMinutes->Value(i)); + theHours.push_back(aHours->Value(i)); + theDays.push_back(aDays->Value(i)); + theMonths.push_back(aMonths->Value(i)); + theYears.push_back(aYears->Value(i)); + } + } else { SALOMEDS::StringSeq_var aNames; SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; - SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(), - aMinutes.out(), - aHours.out(), - aDays.out(), - aMonths.out(), + SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(), + aMinutes.out(), + aHours.out(), + aDays.out(), + aMonths.out(), aYears.out(), theWithCreator); aLength = aNames->length(); - for(i = 0; iSetFirstName((char*)theName); + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->ChangeCreatorName((char*)theName); } -char* SALOMEDS_AttributeStudyProperties_i::GetUserName() +char* SALOMEDS_AttributeStudyProperties_i::GetUserName() { SALOMEDS::Locker lock; - TCollection_ExtendedString S = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreatorName(); + TCollection_ExtendedString S = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreatorName(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); } @@ -34,21 +35,23 @@ void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute, CORBA::Long theHour, CORBA::Long theDay, CORBA::Long theMonth, - CORBA::Long theYear) + CORBA::Long theYear) { SALOMEDS::Locker lock; CheckLocked(); - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); int aTmp; if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return; - aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear); + TCollection_ExtendedString S; + aProp->SetModification(S, theMinute, theHour, theDay, theMonth, theYear); } CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute, CORBA::Long& theHour, CORBA::Long& theDay, CORBA::Long& theMonth, - CORBA::Long& theYear) + CORBA::Long& theYear) { SALOMEDS::Locker lock; Standard_Integer aMinute; @@ -56,30 +59,30 @@ CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& Standard_Integer aDay; Standard_Integer aMonth; Standard_Integer aYear; - if (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetCreationDate(aMinute, aHour, aDay, - aMonth, aYear)) - { - theMinute = aMinute; - theHour = aHour; - theDay = aDay; - theMonth = aMonth; - theYear = aYear; - return Standard_True; - } + if (Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast + (_impl)->GetCreationDate(aMinute, aHour, aDay, aMonth, aYear)) { + theMinute = aMinute; + theHour = aHour; + theDay = aDay; + theMonth = aMonth; + theYear = aYear; + return Standard_True; + } return Standard_False; } -void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) +void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) { SALOMEDS::Locker lock; CheckLocked(); - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH); else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY); else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED); } -char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() +char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() { SALOMEDS::Locker lock; CORBA::String_var c_s; @@ -91,25 +94,25 @@ char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() return c_s._retn(); } -void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) +void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) { SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetModified(theModified); } -CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() +CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() { SALOMEDS::Locker lock; return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->IsModified(); } -CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() +CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() { SALOMEDS::Locker lock; return Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->GetModified(); } -void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) +void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) { SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl)->SetLocked(theLocked); @@ -126,50 +129,51 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, CORBA::Long theHour, CORBA::Long theDay, CORBA::Long theMonth, - CORBA::Long theYear) + CORBA::Long theYear) { SALOMEDS::Locker lock; CheckLocked(); - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); - aProp->SetUserName((char*)theName); - aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); + aProp->SetModification((char*)theName, (int)theMinute, (int)theHour, + (int)theDay, (int)theMonth, (int)theYear); } + void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames, SALOMEDS::LongSeq_out theMinutes, SALOMEDS::LongSeq_out theHours, SALOMEDS::LongSeq_out theDays, SALOMEDS::LongSeq_out theMonths, SALOMEDS::LongSeq_out theYears, - CORBA::Boolean theWithCreator) + CORBA::Boolean theWithCreator) { SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); - aNames = aProp->GetUserNames(); - aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); - int aLength = aNames->Length()-((theWithCreator)?0:1); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_impl); + aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); + int aLength = aNames->Length(); + int aRetLength = aLength - ((theWithCreator) ? 0 : 1); theNames = new SALOMEDS::StringSeq; theMinutes = new SALOMEDS::LongSeq; theHours = new SALOMEDS::LongSeq; theDays = new SALOMEDS::LongSeq; theMonths = new SALOMEDS::LongSeq; theYears = new SALOMEDS::LongSeq; - theNames->length(aLength); - theMinutes->length(aLength); - theHours->length(aLength); - theDays->length(aLength); - theMonths->length(aLength); - theYears->length(aLength); - int a; - for(a = 0; a < aLength; a++) - { - (*theNames)[a]=CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString()); - (*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1)); - (*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1)); - (*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1)); - (*theMonths)[a] = aMonths->Value(a + 1 + ((theWithCreator)?0:1)); - (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1)); - } + theNames->length(aRetLength); + theMinutes->length(aRetLength); + theHours->length(aRetLength); + theDays->length(aRetLength); + theMonths->length(aRetLength); + theYears->length(aRetLength); + int a = 0, ind = ((theWithCreator) ? 1 : 2); + for (; ind <= aLength; a++, ind++) { + (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(ind)).ToCString()); + (*theMinutes)[a] = aMinutes->Value(ind); + (*theHours)[a] = aHours->Value(ind); + (*theDays)[a] = aDays->Value(ind); + (*theMonths)[a] = aMonths->Value(ind); + (*theYears)[a] = aYears->Value(ind); + } } - diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx index 3d7cc3d57..3093a7ae7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx @@ -11,13 +11,13 @@ using namespace std; IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_GenericAttribute ) IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_GenericAttribute ) -const Standard_GUID& SALOMEDSImpl_AttributeStudyProperties::GetID() +const Standard_GUID& SALOMEDSImpl_AttributeStudyProperties::GetID() { static Standard_GUID SALOMEDSImpl_AttributeStudyPropertiesID ("128371A2-8F52-11d6-A8A3-0001021E8C7F"); return SALOMEDSImpl_AttributeStudyPropertiesID; } -Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_AttributeStudyProperties::Set(const TDF_Label& label) +Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_AttributeStudyProperties::Set(const TDF_Label& label) { Handle(SALOMEDSImpl_AttributeStudyProperties) anAttr; if (!label.FindAttribute(SALOMEDSImpl_AttributeStudyProperties::GetID(),anAttr)) { @@ -47,54 +47,57 @@ void SALOMEDSImpl_AttributeStudyProperties::Init() myMode = 0; // none } -void SALOMEDSImpl_AttributeStudyProperties::SetUserName(const TCollection_ExtendedString& theName) +void SALOMEDSImpl_AttributeStudyProperties::SetModification(const TCollection_ExtendedString& theUserName, + const Standard_Integer theMinute, + const Standard_Integer theHour, + const Standard_Integer theDay, + const Standard_Integer theMonth, + const Standard_Integer theYear) { - CheckLocked(); - Backup(); - myUserName->Append(theName); -} + if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || + theDay<0 || theDay>31 || theMonth<0 || theMonth>12) + return; -void SALOMEDSImpl_AttributeStudyProperties::SetFirstName(const TCollection_ExtendedString& theName) -{ - CheckLocked(); + CheckLocked(); Backup(); - if (myUserName->Length() == 0) myUserName->Append(theName); - else myUserName->SetValue(1, theName); -} -TCollection_ExtendedString SALOMEDSImpl_AttributeStudyProperties::GetCreatorName() const -{ - if (myUserName->Length() == 0) return TCollection_ExtendedString(""); - return myUserName->Value(1); + myUserName->Append(theUserName); + myMinute->Append(theMinute); + myHour->Append(theHour); + myDay->Append(theDay); + myMonth->Append(theMonth); + myYear->Append(theYear); } -Handle(TColStd_HSequenceOfExtendedString) SALOMEDSImpl_AttributeStudyProperties::GetUserNames() const +void SALOMEDSImpl_AttributeStudyProperties::GetModifications + (Handle(TColStd_HSequenceOfExtendedString)& theUserNames, + Handle(TColStd_HSequenceOfInteger)& theMinutes, + Handle(TColStd_HSequenceOfInteger)& theHours, + Handle(TColStd_HSequenceOfInteger)& theDays, + Handle(TColStd_HSequenceOfInteger)& theMonths, + Handle(TColStd_HSequenceOfInteger)& theYears) const { - return myUserName; + theUserNames = myUserName; + theMinutes = myMinute; + theHours = myHour; + theDays = myDay; + theMonths = myMonth; + theYears = myYear; } -void SALOMEDSImpl_AttributeStudyProperties::SetModificationDate(const Standard_Integer theMinute, - const Standard_Integer theHour, - const Standard_Integer theDay, - const Standard_Integer theMonth, - const Standard_Integer theYear) +TCollection_ExtendedString SALOMEDSImpl_AttributeStudyProperties::GetCreatorName() const { - CheckLocked(); - Backup(); - if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || theDay<0 || theDay>31 || theMonth<0 || theMonth>12) - return; - myMinute->Append(theMinute); - myHour->Append(theHour); - myDay->Append(theDay); - myMonth->Append(theMonth); - myYear->Append(theYear); + if (myUserName->Length() == 0) + return TCollection_ExtendedString(""); + return myUserName->Value(1); } -Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::GetCreationDate(Standard_Integer& theMinute, - Standard_Integer& theHour, - Standard_Integer& theDay, - Standard_Integer& theMonth, - Standard_Integer& theYear) const +Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::GetCreationDate + (Standard_Integer& theMinute, + Standard_Integer& theHour, + Standard_Integer& theDay, + Standard_Integer& theMonth, + Standard_Integer& theYear) const { if (myMinute->Length() != 0) { theMinute = myMinute->Value(1); @@ -107,22 +110,18 @@ Standard_Boolean SALOMEDSImpl_AttributeStudyProperties::GetCreationDate(Standard return Standard_False; } -void SALOMEDSImpl_AttributeStudyProperties::GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes, - Handle(TColStd_HSequenceOfInteger)& theHours, - Handle(TColStd_HSequenceOfInteger)& theDays, - Handle(TColStd_HSequenceOfInteger)& theMonths, - Handle(TColStd_HSequenceOfInteger)& theYears) const +void SALOMEDSImpl_AttributeStudyProperties::ChangeCreatorName(const TCollection_ExtendedString& theName) { - theMinutes = myMinute; - theHours = myHour; - theDays = myDay; - theMonths = myMonth; - theYears = myYear; + if (myUserName->Length() > 0) { + CheckLocked(); + Backup(); + myUserName->SetValue(1, theName); + } } -void SALOMEDSImpl_AttributeStudyProperties::SetCreationMode(const Standard_Integer theMode) +void SALOMEDSImpl_AttributeStudyProperties::SetCreationMode(const Standard_Integer theMode) { - CheckLocked(); + CheckLocked(); Backup(); myMode = theMode; } @@ -132,7 +131,7 @@ Standard_Integer SALOMEDSImpl_AttributeStudyProperties::GetCreationMode() const return myMode; } -void SALOMEDSImpl_AttributeStudyProperties::SetModified(const Standard_Integer theModified) +void SALOMEDSImpl_AttributeStudyProperties::SetModified(const Standard_Integer theModified) { myModified = theModified; } @@ -147,7 +146,7 @@ Standard_Integer SALOMEDSImpl_AttributeStudyProperties::GetModified() const return myModified; } -void SALOMEDSImpl_AttributeStudyProperties::SetLocked(const Standard_Boolean theLocked) +void SALOMEDSImpl_AttributeStudyProperties::SetLocked(const Standard_Boolean theLocked) { // Backup(); if (myLocked != theLocked) { @@ -172,18 +171,17 @@ const Standard_GUID& SALOMEDSImpl_AttributeStudyProperties::ID() const return GetID(); } -void SALOMEDSImpl_AttributeStudyProperties::Restore(const Handle(TDF_Attribute)& with) +void SALOMEDSImpl_AttributeStudyProperties::Restore(const Handle(TDF_Attribute)& with) { - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(with); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(with); Init(); Standard_Integer i; - Handle(TColStd_HSequenceOfExtendedString) aNames = aProp->GetUserNames(); - for(i = aNames->Length(); i > 0; i--) { - myUserName->Prepend(aNames->Value(i)); - } + Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); - for(i = aMinutes->Length(); i > 0; i--) { + aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); + for (i = aNames->Length(); i > 0; i--) { + myUserName->Prepend(aNames->Value(i)); myMinute->Prepend(aMinutes->Value(i)); myHour->Prepend(aHours->Value(i)); myDay->Prepend(aDays->Value(i)); @@ -201,17 +199,17 @@ Handle(TDF_Attribute) SALOMEDSImpl_AttributeStudyProperties::NewEmpty() const } void SALOMEDSImpl_AttributeStudyProperties::Paste(const Handle(TDF_Attribute)& into, - const Handle(TDF_RelocationTable)&) const + const Handle(TDF_RelocationTable)&) const { - Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(into); + Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = + Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(into); aProp->Init(); Standard_Integer i; for(i = 1; i <= myUserName->Length(); i++) { - aProp->SetUserName(myUserName->Value(i)); - } - for(i = 1; i <= myMinute->Length(); i++) { - aProp->SetModificationDate(myMinute->Value(i), myHour->Value(i), myDay->Value(i), myMonth->Value(i), myYear->Value(i)); + aProp->SetModification(myUserName->Value(i), + myMinute->Value(i), myHour->Value(i), + myDay->Value(i), myMonth->Value(i), myYear->Value(i)); } aProp->SetCreationMode(myMode); @@ -220,15 +218,15 @@ void SALOMEDSImpl_AttributeStudyProperties::Paste(const Handle(TDF_Attribute)& i } -TCollection_AsciiString SALOMEDSImpl_AttributeStudyProperties::Save() +TCollection_AsciiString SALOMEDSImpl_AttributeStudyProperties::Save() { Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aNames = GetUserNames(); - GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); int aLength, anIndex; - for(aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) aLength += aNames->Value(anIndex).Length() + 1; + for (aLength = 0, anIndex = aNames->Length(); anIndex > 0; anIndex--) + aLength += aNames->Value(anIndex).Length() + 1; char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; @@ -238,7 +236,7 @@ TCollection_AsciiString SALOMEDSImpl_AttributeStudyProperties::Save() aLength = aNames->Length(); int a = 2; - for(anIndex = 1; anIndex <= aLength; anIndex++) { + for (anIndex = 1; anIndex <= aLength; anIndex++) { sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", (int)(aMinutes->Value(anIndex)), (int)(aHours->Value(anIndex)), @@ -250,13 +248,13 @@ TCollection_AsciiString SALOMEDSImpl_AttributeStudyProperties::Save() aProperty[a++] = 1; } aProperty[a] = 0; - TCollection_AsciiString prop(aProperty); + TCollection_AsciiString prop(aProperty); delete aProperty; return prop; } -void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& value) +void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& value) { char* aCopy = value.ToCString(); @@ -264,7 +262,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& SetCreationMode(crMode); int anIndex; - for(anIndex = 2; anIndex + 2 < value.Length() ;) { + for (anIndex = 2; anIndex + 2 < value.Length() ;) { char str[10]; Standard_Integer aMinute, aHour, aDay, aMonth, aYear; str[0] = aCopy[anIndex++]; @@ -286,14 +284,13 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& str[3] = aCopy[anIndex++]; str[4] = 0; aYear = atoi(str); - + int aNameSize; for(aNameSize = 0; aCopy[anIndex+aNameSize]!=1; aNameSize++); char *aName = new char[aNameSize+1]; strncpy(aName, &(aCopy[anIndex]), aNameSize); aName[aNameSize] = 0; - SetUserName(aName); - SetModificationDate(aMinute,aHour,aDay,aMonth,aYear); + SetModification(aName,aMinute,aHour,aDay,aMonth,aYear); delete(aName); anIndex += aNameSize + 1; } @@ -302,4 +299,3 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const TCollection_AsciiString& } SetModified(0); } - diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx index f9d3c1a16..19fc22d0e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -22,50 +22,61 @@ DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeStudyProperties, SALOMEDSImpl_Gene #include #include -class SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute +class SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute { - public: -Standard_EXPORT virtual TCollection_AsciiString Save(); -Standard_EXPORT virtual void Load(const TCollection_AsciiString&); -Standard_EXPORT static const Standard_GUID& GetID() ; -Standard_EXPORT static Handle_SALOMEDSImpl_AttributeStudyProperties Set(const TDF_Label& label) ; Standard_EXPORT SALOMEDSImpl_AttributeStudyProperties(); -Standard_EXPORT void Init() ; -Standard_EXPORT void SetUserName(const TCollection_ExtendedString& theName) ; -Standard_EXPORT void SetFirstName(const TCollection_ExtendedString& theName) ; +Standard_EXPORT ~SALOMEDSImpl_AttributeStudyProperties() {} + +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT const Standard_GUID& ID() const; + +Standard_EXPORT static Handle_SALOMEDSImpl_AttributeStudyProperties Set(const TDF_Label& label); + +Standard_EXPORT void Init(); + +Standard_EXPORT virtual TCollection_AsciiString Save(); +Standard_EXPORT virtual void Load(const TCollection_AsciiString&); + +Standard_EXPORT void SetModification(const TCollection_ExtendedString& theUserName, + const Standard_Integer theMinute, + const Standard_Integer theHour, + const Standard_Integer theDay, + const Standard_Integer theMonth, + const Standard_Integer theYear); +Standard_EXPORT void GetModifications(Handle(TColStd_HSequenceOfExtendedString)& theUserNames, + Handle(TColStd_HSequenceOfInteger)& theMinutes, + Handle(TColStd_HSequenceOfInteger)& theHours, + Handle(TColStd_HSequenceOfInteger)& theDays, + Handle(TColStd_HSequenceOfInteger)& theMonths, + Handle(TColStd_HSequenceOfInteger)& theYears) const; + Standard_EXPORT TCollection_ExtendedString GetCreatorName() const; -Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetUserNames() const; -Standard_EXPORT void SetModificationDate(const Standard_Integer theMinute, - const Standard_Integer theHour, - const Standard_Integer theDay, - const Standard_Integer theMonth, - const Standard_Integer theYear) ; -Standard_EXPORT Standard_Boolean GetCreationDate(Standard_Integer& theMinute, - Standard_Integer& theHour, - Standard_Integer& theDay, - Standard_Integer& theMonth, - Standard_Integer& theYear) const; -Standard_EXPORT void GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes, - Handle(TColStd_HSequenceOfInteger)& theHours, - Handle(TColStd_HSequenceOfInteger)& theDays, - Handle(TColStd_HSequenceOfInteger)& theMonths, - Handle(TColStd_HSequenceOfInteger)& theYears) const; -Standard_EXPORT void SetCreationMode(const Standard_Integer theMode) ; +Standard_EXPORT Standard_Boolean GetCreationDate(Standard_Integer& theMinute, + Standard_Integer& theHour, + Standard_Integer& theDay, + Standard_Integer& theMonth, + Standard_Integer& theYear) const; + +Standard_EXPORT void ChangeCreatorName(const TCollection_ExtendedString& theUserName); + +Standard_EXPORT void SetCreationMode(const Standard_Integer theMode); Standard_EXPORT Standard_Integer GetCreationMode() const; -Standard_EXPORT void SetModified(const Standard_Integer theModified) ; + +Standard_EXPORT void SetModified(const Standard_Integer theModified); Standard_EXPORT Standard_Boolean IsModified() const; Standard_EXPORT Standard_Integer GetModified() const; -Standard_EXPORT void SetLocked(const Standard_Boolean theLocked) ; + +Standard_EXPORT void SetLocked(const Standard_Boolean theLocked); Standard_EXPORT Standard_Boolean IsLocked() const; -Standard_EXPORT Standard_Boolean IsLockChanged(const Standard_Boolean theErase) ; -Standard_EXPORT const Standard_GUID& ID() const; -Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Standard_Boolean IsLockChanged(const Standard_Boolean theErase); + +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with); Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; -Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; -Standard_EXPORT ~SALOMEDSImpl_AttributeStudyProperties() {} +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const; -private: +private: Handle_TColStd_HSequenceOfExtendedString myUserName; Handle_TColStd_HSequenceOfInteger myMinute; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 0189a3c5c..40003fb24 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -24,7 +24,7 @@ using namespace std; #include "SALOMEDSImpl_ChildNodeIterator.hxx" #include "SALOMEDSImpl_Attributes.hxx" #include "SALOMEDSImpl_UseCaseIterator.hxx" -#include "SALOMEDSImpl_AttributeReference.hxx" +#include "SALOMEDSImpl_AttributeReference.hxx" #include "SALOMEDSImpl_StudyHandle.hxx" #include "SALOMEDSImpl_Tool.hxx" @@ -32,7 +32,7 @@ IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared ) IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_Study, MMgt_TShared ) #define DIRECTORYID 16661 -#define FILELOCALID 26662 +#define FILELOCALID 26662 #define FILEID "FILE: " //============================================================================ @@ -56,11 +56,11 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const Handle(TDocStd_Document)& doc, _useCaseBuilder = new SALOMEDSImpl_UseCaseBuilder(_doc); _builder = new SALOMEDSImpl_StudyBuilder(this); _cb = new SALOMEDSImpl_Callback(_useCaseBuilder); - //Put on the root label a StudyHandle attribute to store the address of this object + //Put on the root label a StudyHandle attribute to store the address of this object //It will be used to retrieve the study object by TDF_Label that belongs to the study SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this); } - + //============================================================================ /*! Function : ~SALOMEDSImpl_Study @@ -68,7 +68,7 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const Handle(TDocStd_Document)& doc, */ //============================================================================ SALOMEDSImpl_Study::~SALOMEDSImpl_Study() -{} +{} //============================================================================ /*! Function : GetPersistentReference @@ -99,7 +99,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetTransientReference() _errorCode = "IOR is empty"; } - return IOR; + return IOR; } void SALOMEDSImpl_Study::SetTransientReference(const TCollection_AsciiString& theIOR) @@ -146,10 +146,10 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::FindComponent (const TCollec name = SC->ComponentDataType(); if(aComponentName == name) { _find = true; - return SC; + return SC; } } - + if(!_find) { _errorCode = "No component was found"; @@ -168,7 +168,7 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::FindComponentID(const TColle _errorCode = ""; // Iterate on each components defined in the study - // Get the component ID and compare with aComponentID + // Get the component ID and compare with aComponentID bool _find = false; TCollection_AsciiString ID; Handle(SALOMEDSImpl_SComponent) compo; @@ -217,7 +217,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObject(const TCollection_As { _find = true; RefSO = SC; - + } if (!_find) RefSO = _FindObject(SC, anObjectName, _find); } @@ -238,12 +238,12 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectID(const TCollection_ // Convert aSO->GetID in TDF_Label. TDF_Label Lab; TDF_Tool::Label(_doc->Main().Data(), anObjectID, Lab); - + if (Lab.IsNull()) { _errorCode = "No label was found by ID"; return NULL; } - return GetSObject(Lab); + return GetSObject(Lab); } @@ -259,7 +259,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::CreateObjectID(const TCollectio // Convert aSO->GetID in TDF_Label. TDF_Label Lab; TDF_Tool::Label(_doc->Main().Data(), anObjectID, Lab, Standard_True); - + if (Lab.IsNull()) { _errorCode = "Can not create a label"; return NULL; @@ -280,7 +280,7 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindObjectByName(const _errorCode = ""; Handle(TColStd_HSequenceOfTransient) listSO = new TColStd_HSequenceOfTransient(); - + Handle(SALOMEDSImpl_SComponent) compo = FindComponent(aComponentName) ; if ( compo.IsNull() ) { _errorCode = "Can not find the component"; @@ -288,19 +288,19 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindObjectByName(const } // Iterate on each object and subobject of the component - // If objectName is found add it to the list of SObjects + // If objectName is found add it to the list of SObjects TCollection_AsciiString childName ; TCollection_AsciiString compoId = compo->GetID(); Handle(SALOMEDSImpl_ChildIterator) it = NewChildIterator(compo); for ( ; it->More(); it->Next() ) { - + Handle(SALOMEDSImpl_SObject) CSO = it->Value(); if ( CSO->GetName() == anObjectName ) { /* add to list */ listSO->Append(CSO) ; } - + /* looks also for eventual children */ bool found = false ; CSO = _FindObject( CSO, anObjectName, found ) ; @@ -308,7 +308,7 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindObjectByName(const listSO->Append(CSO) ; } } - + return listSO; } @@ -329,7 +329,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectIOR(const TCollection // 11 oct 2002: forbidden attributes must be checked here if (!aResult->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) { myIORLabels.UnBind(anObjectIOR); - } else + } else return aResult; } // Iterate to all components defined in the study @@ -345,7 +345,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectIOR(const TCollection { SC = it.Value(); TCollection_AsciiString ior = SC->GetIOR(); - if (ior != "") + if (ior != "") { if (ior == anObjectIOR) { @@ -353,11 +353,11 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectIOR(const TCollection RefSO = SC; } } - if (!_find) + if (!_find) RefSO = _FindObjectIOR(SC, anObjectIOR, _find); } } - + if(RefSO.IsNull()) _errorCode = "No object was found"; return RefSO; } @@ -380,7 +380,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect return GetSObject(_current); } - if(aPath.Value(1) != '/') //Relative path + if(aPath.Value(1) != '/') //Relative path isRelative = true; TDF_ChildIterator anIterator; @@ -388,7 +388,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect Handle(SALOMEDSImpl_AttributeName) anAttr; if(isRelative) { - if(_current.IsNull()) return NULL; + if(_current.IsNull()) return NULL; anIterator.Initialize(_current, Standard_False); } else { @@ -427,7 +427,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::FindObjectByPath(const TCollect //============================================================================ /*! Function : GetObjectPath - * Purpose : + * Purpose : */ //============================================================================ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPath(const Handle(SALOMEDSImpl_SObject)& theObject) @@ -439,7 +439,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPath(const Handle(SALOMEDSI _errorCode = "Null object"; return aPath.ToCString(); } - + TCollection_AsciiString aName = theObject->GetName(); if(!aName.IsEmpty() && aName != "" ) { TCollection_AsciiString aValue((char*)aName.ToCString()); @@ -456,7 +456,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPath(const Handle(SALOMEDSI } } - return aPath; + return aPath; } @@ -464,7 +464,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPath(const Handle(SALOMEDSI /*! Function : GetObjectPathByIOR * Purpose : */ -//============================================================================ +//============================================================================ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPathByIOR(const TCollection_AsciiString& theIOR) { _errorCode = ""; @@ -475,9 +475,9 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPathByIOR(const TCollection _errorCode = "No SObject was found by IOR"; return aPath; } - + return GetObjectPath(so); -} +} //============================================================================ @@ -485,7 +485,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetObjectPathByIOR(const TCollection * Purpose : Sets the current context */ //============================================================================ -bool SALOMEDSImpl_Study::SetContext(const TCollection_AsciiString& thePath) +bool SALOMEDSImpl_Study::SetContext(const TCollection_AsciiString& thePath) { _errorCode = ""; if(thePath.IsEmpty()) { @@ -496,15 +496,15 @@ bool SALOMEDSImpl_Study::SetContext(const TCollection_AsciiString& thePath) TCollection_AsciiString aPath(thePath), aContext(""); bool isInvalid = false; Handle(SALOMEDSImpl_SObject) aSO; - - if(aPath.Value(1) != '/') { //Relative path + + if(aPath.Value(1) != '/') { //Relative path aContext = GetContext(); aContext += '/'; aContext += aPath; } else aContext = aPath; - + try { aSO = FindObjectByPath(aContext.ToCString()); } @@ -533,7 +533,7 @@ bool SALOMEDSImpl_Study::SetContext(const TCollection_AsciiString& thePath) * Purpose : Gets the current context */ //============================================================================ -TCollection_AsciiString SALOMEDSImpl_Study::GetContext() +TCollection_AsciiString SALOMEDSImpl_Study::GetContext() { _errorCode = ""; @@ -542,7 +542,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetContext() return ""; } Handle(SALOMEDSImpl_SObject) so = GetSObject(_current); - return GetObjectPath(so); + return GetObjectPath(so); } //============================================================================ @@ -550,7 +550,7 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetContext() * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty) */ //============================================================================ -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetObjectNames(const TCollection_AsciiString& theContext) +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetObjectNames(const TCollection_AsciiString& theContext) { _errorCode = ""; @@ -583,7 +583,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetObjectNames(const * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty) */ //============================================================================ -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetDirectoryNames(const TCollection_AsciiString& theContext) +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetDirectoryNames(const TCollection_AsciiString& theContext) { _errorCode = ""; @@ -623,7 +623,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetDirectoryNames(con * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty) */ //============================================================================ -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetFileNames(const TCollection_AsciiString& theContext) +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetFileNames(const TCollection_AsciiString& theContext) { _errorCode = ""; @@ -665,7 +665,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetFileNames(const TC * Purpose : method to get all components names */ //============================================================================ -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetComponentNames(const TCollection_AsciiString& theContext) +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetComponentNames(const TCollection_AsciiString& theContext) { _errorCode = ""; @@ -719,7 +719,7 @@ Handle(SALOMEDSImpl_StudyBuilder) SALOMEDSImpl_Study::NewBuilder() return _builder; } - + //============================================================================ /*! Function : Name * Purpose : get study name @@ -802,7 +802,7 @@ void SALOMEDSImpl_Study::URL(const TCollection_AsciiString& url) _URL = url; /*jfa: Now name of SALOMEDS study will correspond to name of SalomeApp study - TCollection_AsciiString tmp(_URL); + TCollection_AsciiString tmp(_URL); char *aName = (char*)tmp.ToCString(); char *adr = strtok(aName, "/"); @@ -822,22 +822,22 @@ void SALOMEDSImpl_Study::URL(const TCollection_AsciiString& url) */ //============================================================================ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::_FindObject(const Handle(SALOMEDSImpl_SObject)& SO, - const TCollection_AsciiString& theObjectName, + const TCollection_AsciiString& theObjectName, bool& _find) { - if(SO.IsNull()) return NULL; + if(SO.IsNull()) return NULL; // Iterate on each objects and subobjects of the component // If objectName find, stop the loop and get the object reference Handle(SALOMEDSImpl_SObject) RefSO; - Handle(SALOMEDSImpl_AttributeName) anAttr; + Handle(SALOMEDSImpl_AttributeName) anAttr; TCollection_AsciiString soid = SO->GetID(); TDF_ChildIterator it(SO->GetLabel()); for (; it.More(); it.Next()){ if(!_find) { - if (it.Value().FindAttribute(SALOMEDSImpl_AttributeName::GetID(), anAttr)) + if (it.Value().FindAttribute(SALOMEDSImpl_AttributeName::GetID(), anAttr)) { TCollection_AsciiString Val(anAttr->Value()); if (Val == theObjectName) @@ -857,12 +857,12 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::_FindObject(const Handle(SALOME * Purpose : Find an Object with SALOMEDSImpl_IOR = anObjectIOR */ //============================================================================ -Handle(SALOMEDSImpl_SObject) +Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::_FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO, - const TCollection_AsciiString& theObjectIOR, + const TCollection_AsciiString& theObjectIOR, bool& _find) { - if(SO.IsNull()) return NULL; + if(SO.IsNull()) return NULL; // Iterate on each objects and subobjects of the component // If objectName find, stop the loop and get the object reference @@ -873,9 +873,9 @@ SALOMEDSImpl_Study::_FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO, for (; it.More();it.Next()){ if(!_find) { - if (it.Value().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) + if (it.Value().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), anAttr)) { - TCollection_AsciiString Val(anAttr->Value()); + TCollection_AsciiString Val(anAttr->Value()); if (Val == theObjectIOR) { RefSO = GetSObject(it.Value()); @@ -907,7 +907,7 @@ void SALOMEDSImpl_Study::StudyId(int id) _StudyId = id; } -void SALOMEDSImpl_Study::UpdateIORLabelMap(const TCollection_AsciiString& anIOR,const TCollection_AsciiString& anEntry) +void SALOMEDSImpl_Study::UpdateIORLabelMap(const TCollection_AsciiString& anIOR,const TCollection_AsciiString& anEntry) { _errorCode = ""; TDF_Label aLabel; @@ -918,12 +918,12 @@ void SALOMEDSImpl_Study::UpdateIORLabelMap(const TCollection_AsciiString& anIOR, myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel); } -Handle(SALOMEDSImpl_Study) SALOMEDSImpl_Study::GetStudy(const TDF_Label& theLabel) +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_Study::GetStudy(const TDF_Label& theLabel) { Handle(SALOMEDSImpl_StudyHandle) Att; if (theLabel.Root().FindAttribute(SALOMEDSImpl_StudyHandle::GetID(),Att)) { return Att->GetHandle(); - } + } return NULL; } @@ -938,68 +938,68 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::SComponent(const TDF_Label& } -void SALOMEDSImpl_Study::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR)& theAttribute) +void SALOMEDSImpl_Study::IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR)& theAttribute) { TCollection_AsciiString aString; TDF_Tool::Entry(theAttribute->Label(), aString); GetStudy(theAttribute->Label())->UpdateIORLabelMap(theAttribute->Value(), aString); } -Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject) +Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_Study::FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject) { _errorCode = ""; Handle(TColStd_HSequenceOfTransient) aSeq; - + Handle(SALOMEDSImpl_AttributeTarget) aTarget; if (anObject->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID(), aTarget)) { return aTarget->Get(); } - + return aSeq; } -Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties() +Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties() { _errorCode = ""; return SALOMEDSImpl_AttributeStudyProperties::Set(_doc->Main()); } -TCollection_AsciiString SALOMEDSImpl_Study::GetLastModificationDate() +TCollection_AsciiString SALOMEDSImpl_Study::GetLastModificationDate() { _errorCode = ""; Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = GetProperties(); Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aNames = aProp->GetUserNames(); - aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); int aLastIndex = aNames->Length(); char aResult[20]; - sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays->Value(aLastIndex)),(int)(aMonths->Value(aLastIndex)), - (int)(aYears->Value(aLastIndex)), (int)(aHours->Value(aLastIndex)), (int)(aMinutes->Value(aLastIndex))); - TCollection_AsciiString aResStr(aResult); + sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", + (int)(aDays->Value(aLastIndex)),(int)(aMonths->Value(aLastIndex)), (int)(aYears->Value(aLastIndex)), + (int)(aHours->Value(aLastIndex)), (int)(aMinutes->Value(aLastIndex))); + TCollection_AsciiString aResStr (aResult); return aResStr; } -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetModificationsDate() +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetModificationsDate() { _errorCode = ""; Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = GetProperties(); Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aNames = aProp->GetUserNames(); - aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); int anIndex, aLength = aNames->Length(); Handle(TColStd_HSequenceOfAsciiString) aDates = new TColStd_HSequenceOfAsciiString; - for(anIndex = 2; anIndex <= aLength; anIndex++) { + for (anIndex = 2; anIndex <= aLength; anIndex++) { char aDate[20]; - sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays->Value(anIndex)), (int)(aMonths->Value(anIndex)), - (int)(aYears->Value(anIndex)), (int)(aHours->Value(anIndex)), (int)(aMinutes->Value(anIndex))); + sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", + (int)(aDays->Value(anIndex)), (int)(aMonths->Value(anIndex)), (int)(aYears->Value(anIndex)), + (int)(aHours->Value(anIndex)), (int)(aMinutes->Value(anIndex))); aDates->Append(aDate); } return aDates; @@ -1012,7 +1012,7 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::GetModificationsDate( * Purpose : Returns a UseCase builder */ //============================================================================ -Handle(SALOMEDSImpl_UseCaseBuilder) SALOMEDSImpl_Study::GetUseCaseBuilder() +Handle(SALOMEDSImpl_UseCaseBuilder) SALOMEDSImpl_Study::GetUseCaseBuilder() { _errorCode = ""; return _useCaseBuilder; @@ -1021,7 +1021,7 @@ Handle(SALOMEDSImpl_UseCaseBuilder) SALOMEDSImpl_Study::GetUseCaseBuilder() //============================================================================ /*! Function : Close - * Purpose : + * Purpose : */ //============================================================================ void SALOMEDSImpl_Study::Close() @@ -1036,40 +1036,40 @@ void SALOMEDSImpl_Study::Close() //============================================================================ /*! Function : AddPostponed - * Purpose : + * Purpose : */ //============================================================================ -void SALOMEDSImpl_Study::AddPostponed(const TCollection_AsciiString& theIOR) +void SALOMEDSImpl_Study::AddPostponed(const TCollection_AsciiString& theIOR) { _errorCode = ""; if (!NewBuilder()->HasOpenCommand()) return; TCollection_AsciiString anIOR(theIOR); anIOR.Prepend("d"); myPostponedIORs.Append(anIOR); // add prefix: deleted - myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); } //============================================================================ /*! Function : AddCreatedPostponed - * Purpose : + * Purpose : */ //============================================================================ -void SALOMEDSImpl_Study::AddCreatedPostponed(const TCollection_AsciiString& theIOR) +void SALOMEDSImpl_Study::AddCreatedPostponed(const TCollection_AsciiString& theIOR) { _errorCode = ""; if (!NewBuilder()->HasOpenCommand()) return; TCollection_AsciiString anIOR(theIOR); anIOR.Prepend("c"); myPostponedIORs.Append(anIOR); // add prefix: created - myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); + myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1); } //============================================================================ /*! Function : RemovePostponed - * Purpose : + * Purpose : */ //============================================================================ -Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::RemovePostponed(const int theUndoLimit) +Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::RemovePostponed(const int theUndoLimit) { _errorCode = ""; @@ -1126,10 +1126,10 @@ Handle(TColStd_HSequenceOfAsciiString) SALOMEDSImpl_Study::RemovePostponed(const //============================================================================ /*! Function : UndoPostponed - * Purpose : + * Purpose : */ //============================================================================ -void SALOMEDSImpl_Study::UndoPostponed(const int theWay) +void SALOMEDSImpl_Study::UndoPostponed(const int theWay) { _errorCode = ""; @@ -1143,13 +1143,13 @@ void SALOMEDSImpl_Study::UndoPostponed(const int theWay) //============================================================================ /*! Function : GetSComponent - * Purpose : + * Purpose : */ //============================================================================ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TCollection_AsciiString& theEntry) { Handle(SALOMEDSImpl_SComponent) aSCO; - if(_mapOfSCO.IsBound(theEntry)) + if(_mapOfSCO.IsBound(theEntry)) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(_mapOfSCO.Find(theEntry)); else { TDF_Label aLabel; @@ -1163,7 +1163,7 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TCollect //============================================================================ /*! Function : GetSComponent - * Purpose : + * Purpose : */ //============================================================================ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TDF_Label& theLabel) @@ -1175,13 +1175,13 @@ Handle(SALOMEDSImpl_SComponent) SALOMEDSImpl_Study::GetSComponent(const TDF_Labe //============================================================================ /*! Function : GetSObject - * Purpose : + * Purpose : */ //============================================================================ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TCollection_AsciiString& theEntry) { Handle(SALOMEDSImpl_SObject) aSO; - if(_mapOfSO.IsBound(theEntry)) + if(_mapOfSO.IsBound(theEntry)) aSO = Handle(SALOMEDSImpl_SObject)::DownCast(_mapOfSO.Find(theEntry)); else { TDF_Label aLabel; @@ -1195,7 +1195,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TCollection_As //============================================================================ /*! Function : GetSObject - * Purpose : + * Purpose : */ //============================================================================ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TDF_Label& theLabel) @@ -1207,10 +1207,10 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_Study::GetSObject(const TDF_Label& the //============================================================================ /*! Function : GetAttribute - * Purpose : + * Purpose : */ //============================================================================ -Handle(TDF_Attribute) SALOMEDSImpl_Study::GetAttribute(const TCollection_AsciiString& theEntry, +Handle(TDF_Attribute) SALOMEDSImpl_Study::GetAttribute(const TCollection_AsciiString& theEntry, const TCollection_AsciiString& theType) { Handle(SALOMEDSImpl_SObject) aSO = GetSObject(theEntry); @@ -1221,11 +1221,11 @@ Handle(TDF_Attribute) SALOMEDSImpl_Study::GetAttribute(const TCollection_AsciiSt //============================================================================ /*! Function : DumpStudy - * Purpose : + * Purpose : */ //============================================================================ -bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, - const TCollection_AsciiString& theBaseName, +bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, + const TCollection_AsciiString& theBaseName, bool isPublished, SALOMEDSImpl_DriverFactory* theFactory) { @@ -1241,7 +1241,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, //Build a list of all components in the Study SALOMEDSImpl_SComponentIterator itcomponent = NewComponentIterator(); - + for (; itcomponent.More(); itcomponent.Next()) { Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); aCompType = sco->ComponentDataType(); @@ -1254,13 +1254,13 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("\\")+theBaseName+TCollection_AsciiString(".py"); #else TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("/")+theBaseName+TCollection_AsciiString(".py"); -#endif +#endif //Create a file that will contain a main Study script fstream fp; - fp.open(aFileName.ToCString(), ios::out); + fp.open(aFileName.ToCString(), ios::out); -#ifdef WIN32 +#ifdef WIN32 bool isOpened = fp.is_open(); #else bool isOpened = fp.rdbuf()->is_open(); @@ -1268,7 +1268,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, if(!isOpened) { _errorCode = TCollection_AsciiString("Can't create a file ")+aFileName; - return false; + return false; } TCollection_AsciiString aBatchModeScript = "salome"; @@ -1278,7 +1278,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, fp << "import sys" << endl; fp << "import " << aBatchModeScript << "\n" << endl; fp << "sys.path.insert( 0, \'" << thePath << "\')\n" << endl; - + Handle(TColStd_HSequenceOfAsciiString) aSeqOfFileNames = new TColStd_HSequenceOfAsciiString; //Iterate all components and create the componponents specific scripts. @@ -1294,9 +1294,9 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, try { if (!sco->ComponentIOR(IOREngine)) { if (!aCompType.IsEmpty()) { - + aDriver = theFactory->GetDriverByType(aCompType); - + if (aDriver != NULL) { Handle(SALOMEDSImpl_StudyBuilder) SB = NewBuilder(); cout << "Before SB" << endl; @@ -1315,7 +1315,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, } catch(...) { _errorCode = "Can not restore information to dump it"; return false; - } + } if(aDriver == NULL) continue; @@ -1331,18 +1331,18 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, aFileName=thePath+TCollection_AsciiString("\\"); #else aFileName=thePath+TCollection_AsciiString("/"); -#endif +#endif TCollection_AsciiString aScriptName; aScriptName += theBaseName; aScriptName += "_"; aScriptName += aCompType; - + aFileName += aScriptName+ TCollection_AsciiString(".py"); aSeqOfFileNames->Append(aFileName); - + fp2.open(aFileName.ToCString(), ios::out); -#ifdef WIN32 +#ifdef WIN32 isOpened = fp.is_open(); #else isOpened = fp.rdbuf()->is_open(); @@ -1351,8 +1351,8 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, if(!isOpened) { _errorCode = TCollection_AsciiString("Can't create a file ")+aFileName; SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false); - return false; - } + return false; + } //Output the Python script generated by the component in the newly created file. fp2 << aStream; @@ -1383,22 +1383,22 @@ TCollection_AsciiString SALOMEDSImpl_Study::GetDumpStudyComment(const char* theC return txt; } -void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, - fstream& fp, +void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, + fstream& fp, const TCollection_AsciiString& Tab, const Handle(SALOMEDSImpl_Study) theStudy); //============================================================================ /*! Function : dump - * Purpose : + * Purpose : */ //============================================================================ void SALOMEDSImpl_Study::dump(const TCollection_AsciiString& theFileName) { //Create a file that will contain a main Study script fstream fp; - fp.open(theFileName.ToCString(), ios::out); + fp.open(theFileName.ToCString(), ios::out); -#ifdef WIN32 +#ifdef WIN32 bool isOpened = fp.is_open(); #else bool isOpened = fp.rdbuf()->is_open(); @@ -1407,7 +1407,7 @@ void SALOMEDSImpl_Study::dump(const TCollection_AsciiString& theFileName) if(!isOpened) { _errorCode = TCollection_AsciiString("Can't create a file ")+theFileName; cout << "### SALOMEDSImpl_Study::dump Error: " << _errorCode << endl; - return; + return; } Handle(SALOMEDSImpl_SObject) aSO = FindObjectID("0:1"); @@ -1422,8 +1422,8 @@ void SALOMEDSImpl_Study::dump(const TCollection_AsciiString& theFileName) } -void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, - fstream& fp, +void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, + fstream& fp, const TCollection_AsciiString& Tab, const Handle(SALOMEDSImpl_Study) theStudy) { @@ -1432,7 +1432,7 @@ void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, TDF_AttributeIterator anItr(theSO->GetLabel()); for(; anItr.More(); anItr.Next()) { Handle(SALOMEDSImpl_GenericAttribute) anAttr = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anItr.Value()); - + if(anAttr.IsNull()) { fp << Tab << " -- " << anItr.Value()->DynamicType(); continue; @@ -1440,7 +1440,7 @@ void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, TCollection_AsciiString aType = anAttr->GetClassType(); fp << Tab << " -- " << aType; - + if(aType == "AttributeReal") { fp << " : " << Handle(SALOMEDSImpl_AttributeReal)::DownCast(anAttr)->Value(); } @@ -1471,6 +1471,6 @@ void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO, void SALOMEDSImpl_Study::Modify() { - _errorCode = ""; + _errorCode = ""; _doc->Modify(); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index fb784bda7..5822afedc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -41,7 +41,7 @@ IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared ) #define AUTO_SAVE_TAG "0:8" #define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200 -static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject); +static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject); static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* ); static void BuildTree (const Handle(SALOMEDSImpl_Study)&, HDFgroup*); static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)&, @@ -49,15 +49,15 @@ static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)&, //============================================================================ /*! Function : SALOMEDSImpl_StudyManager - * Purpose : SALOMEDSImpl_StudyManager constructor + * Purpose : SALOMEDSImpl_StudyManager constructor */ //============================================================================ -SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() -{ +SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() +{ _errorCode = ""; - _OCAFApp = new SALOMEDSImpl_OCAFApplication(); + _OCAFApp = new SALOMEDSImpl_OCAFApplication(); _IDcounter = 0; - _OCAFApp->NewDocument("SALOME_STUDY", _clipboard); + _OCAFApp->NewDocument("SALOME_STUDY", _clipboard); } //============================================================================ @@ -77,14 +77,14 @@ SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager() * Purpose : Create a New Study of name study_name */ //==================================================T========================== -Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection_AsciiString& study_name) +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection_AsciiString& study_name) { _errorCode = ""; Handle(TDocStd_Document) Doc; - _OCAFApp->NewDocument("SALOME_STUDY",Doc); + _OCAFApp->NewDocument("SALOME_STUDY",Doc); - Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, study_name); + Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, study_name); _IDcounter++; Study->StudyId( _IDcounter ); @@ -93,9 +93,9 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Study->GetProperties(); OSD_Process aProcess; Quantity_Date aDate = aProcess.SystemDate(); - aProp->SetModificationDate(aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); + aProp->SetModification(aProcess.UserName().ToCString(), + aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); aProp->SetCreationMode(1); //"from scratch" - aProp->SetUserName(aProcess.UserName().ToCString()); return Study; } @@ -109,8 +109,8 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_Asc { _errorCode = ""; - // open the HDFFile - HDFfile *hdf_file =0; + // open the HDFFile + HDFfile *hdf_file =0; HDFgroup *hdf_group_study_structure =0; char* aC_HDFUrl; @@ -146,13 +146,13 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_Asc #endif _errorCode = TCollection_AsciiString(eStr); return NULL; - } + } // Temporary aStudyUrl in place of study name Handle(TDocStd_Document) Doc; - _OCAFApp->NewDocument("SALOME_STUDY",Doc); + _OCAFApp->NewDocument("SALOME_STUDY",Doc); - Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, aUrl); + Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, aUrl); _IDcounter++; Study->StudyId( _IDcounter ); @@ -160,7 +160,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_Asc // Assign the value of the URL in the study object Study->URL (aUrl); - SALOMEDSImpl_AttributePersistentRef::Set(Doc->Main(), aUrl); + SALOMEDSImpl_AttributePersistentRef::Set(Doc->Main(), aUrl); if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) { _errorCode = "Study is empty"; @@ -184,7 +184,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_Asc sprintf(eStr,"Can't open file %s", aUrl.ToCString()); _errorCode = TCollection_AsciiString(eStr); return NULL; - } + } hdf_file->CloseOnDisk(); @@ -205,7 +205,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_Asc /*! Function : Close * Purpose : Close a study. * If the study hasn't been saved, ask the user to confirm the - * close action without saving + * close action without saving */ //============================================================================ @@ -217,7 +217,7 @@ void SALOMEDSImpl_StudyManager::Close(const Handle(SALOMEDSImpl_Study)& aStudy) _errorCode = "Study is null"; return; } - + aStudy->Close(); } @@ -226,7 +226,7 @@ void SALOMEDSImpl_StudyManager::Close(const Handle(SALOMEDSImpl_Study)& aStudy) * Purpose : Save a Study to it's persistent reference */ //============================================================================ -bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy, +bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile) { @@ -244,7 +244,7 @@ bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy, return false; } -bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy, +bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile) { @@ -267,8 +267,8 @@ bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStu * Purpose : Save a study to the persistent reference aUrl */ //============================================================================ -bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl, - const Handle(SALOMEDSImpl_Study)& aStudy, +bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile) { @@ -276,8 +276,8 @@ bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl, return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, false); } -bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl, - const Handle(SALOMEDSImpl_Study)& aStudy, +bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl, + const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile) { @@ -293,7 +293,7 @@ bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl, Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_StudyManager::GetOpenStudies() { _errorCode = ""; - Handle(TColStd_HSequenceOfTransient) aList = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aList = new TColStd_HSequenceOfTransient; int nbDocs = _OCAFApp->NbDocuments(); @@ -322,7 +322,7 @@ Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_StudyManager::GetOpenStudies() * Purpose : Get a study from its name */ //============================================================================ -Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName(const TCollection_AsciiString& aStudyName) +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName(const TCollection_AsciiString& aStudyName) { _errorCode = ""; @@ -344,7 +344,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName(const TColl if(aStudy->Name() == aStudyName) return aStudy; } } - + _errorCode = TCollection_AsciiString("Found no study with the name ")+aStudyName; return aStudy; } @@ -354,7 +354,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName(const TColl * Purpose : Get a study from its ID */ //============================================================================ -Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID) +Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID) { _errorCode = ""; Handle(SALOMEDSImpl_Study) aStudy; @@ -375,7 +375,7 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID) if(aStudy->StudyId() == aStudyID) return aStudy; } } - + _errorCode = "Found no study with the given ID"; return aStudy; } @@ -385,7 +385,8 @@ Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID) * Purpose : save the study properties in HDF file */ //============================================================================ -bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy, HDFgroup *hdf_group) +bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy, + HDFgroup *hdf_group) { _errorCode = ""; @@ -401,25 +402,24 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_St OSD_Process aProcess; Quantity_Date aDate = aProcess.SystemDate(); - aProp->SetUserName(aProcess.UserName().ToCString()); - aProp->SetModificationDate(aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); + aProp->SetModification(aProcess.UserName().ToCString(), + aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year()); if (aLocked) aProp->SetLocked(Standard_True); Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; - aNames = aProp->GetUserNames(); - aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears); int aLength = 0, anIndex, i; - for(i=1; i<=aNames->Length(); i++) + for(i=1; i<=aNames->Length(); i++) aLength += aNames->Value(i).Length() + 1; //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte char* aProperty = new char[3 + aLength + 12 * aNames->Length()]; - + sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u'); aLength = aNames->Length(); @@ -438,7 +438,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_St aProperty[a] = 0; name_len = (hdf_int32) a; - size[0] = name_len + 1 ; + size[0] = name_len + 1 ; hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1); hdf_dataset->CreateOnDisk(); hdf_dataset->WriteOnDisk(aProperty); @@ -455,7 +455,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_St * Purpose : save the study in HDF file */ //============================================================================ -bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, +bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile, @@ -469,7 +469,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, _errorCode = ""; - HDFfile *hdf_file=0; + HDFfile *hdf_file=0; HDFgroup *hdf_group_study_structure =0; HDFgroup *hdf_sco_group =0; HDFgroup *hdf_sco_group2 =0; @@ -526,7 +526,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, TCollection_AsciiString anOldName = aStudy->Name(); aStudy->URL(aUrl); - // To change for Save + // To change for Save // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? hdf_file = new HDFfile(aUrl.ToCString()); hdf_file->CreateOnDisk(); @@ -538,31 +538,31 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, hdf_group_datacomponent->CreateOnDisk(); SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator(); - + //SRN: Added 17 Nov, 2003 Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG); //SRN: End for (; itcomponent.More(); itcomponent.Next()) { Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); - + TCollection_AsciiString scoid = sco->GetID(); hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent); hdf_sco_group->CreateOnDisk(); TCollection_AsciiString componentDataType = sco->ComponentDataType(); - //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save - if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) { - + //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save + if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) { + Handle(SALOMEDSImpl_AttributeTableOfString) aTable; if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) { Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; - if(nbRows > 0 && aTable->GetNbColumns() > 1) { + if(nbRows > 0 && aTable->GetNbColumns() > 1) { - Handle(TColStd_HSequenceOfExtendedString) aRow; + Handle(TColStd_HSequenceOfExtendedString) aRow; for(k=1; k<=nbRows; k++) { - aRow = aTable->GetRowData(k); + aRow = aTable->GetRowData(k); if (aRow->Value(1) == componentDataType) { TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2)); Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry); @@ -570,17 +570,17 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, Handle(SALOMEDSImpl_AttributeInteger) anInteger; if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) { anInteger->SetValue(-1); - while(anInteger->Value() < 0) { + while(anInteger->Value() < 0) { #ifndef WNT - sleep(2); + sleep(2); #else Sleep(2); #endif - if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) - break; + if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) + break; } } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) - } // if(!CORBA::is_nil(aCompSpecificSO)) + } // if(!CORBA::is_nil(aCompSpecificSO)) } // if (strcmp(aRow[0], componentDataType) == 0) } // for @@ -596,7 +596,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, { SALOMEDSImpl_Driver* Engine = NULL; if(aMapTypeDriver.find(componentDataType.ToCString()) != aMapTypeDriver.end()) { - // we have found the associated engine to write the data + // we have found the associated engine to write the data Engine = aMapTypeDriver[componentDataType.ToCString()]; } else { @@ -608,20 +608,20 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, unsigned char* aStream; long length; - if (theASCII) aStream = Engine->SaveASCII(sco, - SALOMEDSImpl_Tool::GetDirFromPath(aUrl), + if (theASCII) aStream = Engine->SaveASCII(sco, + SALOMEDSImpl_Tool::GetDirFromPath(aUrl), length, theMultiFile); else aStream = Engine->Save(sco, - SALOMEDSImpl_Tool::GetDirFromPath(aUrl), + SALOMEDSImpl_Tool::GetDirFromPath(aUrl), length, theMultiFile); HDFdataset *hdf_dataset; hdf_size aHDFSize[1]; - if(length > 0) { //The component saved some auxiliary files, then put them into HDF file + if(length > 0) { //The component saved some auxiliary files, then put them into HDF file aHDFSize[0] = length; - + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); hdf_dataset->CreateOnDisk(); hdf_dataset->WriteOnDisk(aStream); //Save the stream in the HDF file @@ -634,14 +634,14 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, hdf_dataset->CreateOnDisk(); hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor // store ASCII state aHDFSize[0] = 2; hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); hdf_dataset->CreateOnDisk(); hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor // Creation of the persistance reference attribute Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII); @@ -661,7 +661,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, hdf_group_study_structure->CreateOnDisk(); // save component attributes SALOMEDSImpl_SComponentIterator itcomp = aStudy->NewComponentIterator(); - for (; itcomp.More(); itcomp.Next()) + for (; itcomp.More(); itcomp.Next()) { Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value(); TCollection_AsciiString scid = SC->GetID(); @@ -671,7 +671,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, // ComponentDataType treatment component_name = SC->ComponentDataType().ToCString(); name_len = (hdf_int32)strlen(component_name); - size[0] = name_len +1 ; + size[0] = name_len +1 ; hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); hdf_dataset->CreateOnDisk(); hdf_dataset->WriteOnDisk(component_name); @@ -700,7 +700,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, //5 - Write the Study Properties //----------------------------------------------------------------------- name_len = (hdf_int32) aStudy->Name().Length(); - size[0] = name_len +1 ; + size[0] = name_len +1 ; hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1); hdf_dataset->CreateOnDisk(); char* studid = aStudy->Name().ToCString(); @@ -734,18 +734,18 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl, * Purpose : */ //============================================================================ -bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC, +bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC, HDFgroup *hdf_group_datatype) { _errorCode = ""; // Write in group hdf_group_datatype all informations of SObject SC // Iterative function to parse all SObjects under a SComponent - + HDFgroup *hdf_group_sobject = 0; TDF_ChildIterator itchild(SC->GetLabel()); - for (; itchild.More(); itchild.Next()) + for (; itchild.More(); itchild.Next()) { // mpv: don't save empty labels @@ -796,10 +796,10 @@ TCollection_AsciiString SALOMEDSImpl_StudyManager::Impl_SubstituteSlash(const TC //============================================================================ /*! Function : GetDocumentOfStudy - * Purpose : + * Purpose : */ //============================================================================ -Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy) +Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy) { _errorCode = ""; return theStudy->_doc; @@ -807,11 +807,11 @@ Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Han //============================================================================ /*! Function : CanCopy - * Purpose : + * Purpose : */ //============================================================================ bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject, - SALOMEDSImpl_Driver* theEngine) + SALOMEDSImpl_Driver* theEngine) { _errorCode = ""; Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent(); @@ -825,14 +825,14 @@ bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theO //============================================================================ /*! Function : CopyLabel - * Purpose : + * Purpose : */ //============================================================================ bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy, SALOMEDSImpl_Driver* theEngine, const Standard_Integer theSourceStartDepth, const TDF_Label& theSource, - const TDF_Label& theDestinationMain) + const TDF_Label& theDestinationMain) { _errorCode = ""; @@ -852,7 +852,7 @@ bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theS Handle(TDF_Attribute) anAttr = anAttrIterator.Value(); if (!Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute if (!Handle(SALOMEDSImpl_AttributeTarget)::DownCast(anAttr).IsNull()) continue; // and target attribute - + if (!Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in aux tree TDF_Label aReferenced = Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr)->Get(); TCollection_AsciiString anEntry; @@ -866,7 +866,7 @@ bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theS SALOMEDSImpl_AttributeComment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry)); continue; } - + if (!Handle(SALOMEDSImpl_AttributeIOR)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine TCollection_AsciiString anEntry; TDF_Tool::Entry(theSource, anEntry); @@ -897,7 +897,7 @@ bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theS */ //============================================================================ bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObject, - SALOMEDSImpl_Driver* theEngine) + SALOMEDSImpl_Driver* theEngine) { _errorCode = ""; @@ -919,7 +919,7 @@ bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObje _clipboard->Main().Root().ForgetAllAttributes(Standard_True); _OCAFApp->Close(_clipboard); Handle(TDocStd_Document) aDoc; - _OCAFApp->NewDocument("SALOME_STUDY", aDoc); + _OCAFApp->NewDocument("SALOME_STUDY", aDoc); _clipboard = aDoc; // set component data type to the name attribute of root label @@ -932,7 +932,7 @@ bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObje // iterate all theObject's label children TDF_Label aStartLabel = theObject->GetLabel(); Standard_Integer aSourceStartDepth = aStartLabel.Depth(); - + // copy main source label CopyLabel(aStudy, theEngine, aSourceStartDepth, aStartLabel, _clipboard->Main()); @@ -949,8 +949,8 @@ bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObje * Purpose : */ //============================================================================ -bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject, - SALOMEDSImpl_Driver* theEngine) +bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject, + SALOMEDSImpl_Driver* theEngine) { _errorCode = ""; @@ -974,7 +974,7 @@ bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& the _errorCode = "Object doesn't belong to component"; return false; } - + TCollection_AsciiString IOREngine; if (!aComponent->ComponentIOR(IOREngine)) { _errorCode = "component has no IOR"; @@ -993,7 +993,7 @@ TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study) const TDF_Label& theSource, const TDF_Label& theDestinationStart, const int theCopiedStudyID, - const bool isFirstElement) + const bool isFirstElement) { _errorCode = ""; @@ -1039,10 +1039,10 @@ TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study) if (isFirstElement) { TCollection_AsciiString aDestEntry = theEngine->PasteInto(aStream, aLen, - anObjID->Value(), + anObjID->Value(), aPastedSO->GetFatherComponent()); TDF_Tool::Label(theDestinationStart.Data(), aDestEntry, aTargetLabel); - } else + } else theEngine->PasteInto(aStream, aLen, anObjID->Value(), aPastedSO); if(aStream != NULL) delete []aStream; @@ -1078,7 +1078,7 @@ TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study) TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel); SALOMEDSImpl_AttributeReference::Set(aTargetLabel, aRefLabel); // target attributes structure support - SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Add(SALOMEDSImpl_Study::SObject(aTargetLabel)); + SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Add(SALOMEDSImpl_Study::SObject(aTargetLabel)); } else { if (aNameStart) SALOMEDSImpl_AttributeName::Set(aTargetLabel, aNameStart); else SALOMEDSImpl_AttributeName::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry); @@ -1114,7 +1114,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOM // get copied study ID Handle(SALOMEDSImpl_AttributeInteger) aStudyIDAttribute; if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), aStudyIDAttribute)) { - _errorCode = "No study ID was found"; + _errorCode = "No study ID was found"; return NULL; } int aCStudyID = aStudyIDAttribute->Value(); @@ -1131,7 +1131,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOM // fill root inserted SObject TDF_Label aStartLabel; if (aStructureOnly) { - TDF_Label anObjectLabel; + TDF_Label anObjectLabel; TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel); aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), anObjectLabel, aCStudyID, false); } else { @@ -1158,7 +1158,7 @@ Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOM * Purpose : Save attributes for object */ //============================================================================ -static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group_sobject) +static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group_sobject) { hdf_size size[1]; TDF_AttributeIterator Itr(aSO->GetLabel()); @@ -1166,7 +1166,7 @@ static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group for(; Itr.More(); Itr.Next()) { anAttr = Itr.Value(); //The following attributes are not supposed to be written to the file - if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeIOR)) continue; //IOR attribute is not saved + if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeIOR)) continue; //IOR attribute is not saved Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr); TCollection_AsciiString aSaveStr = ga->Save(); //cout << "Saving: " << aSO->GetID() << " "<< ga->Type() << " value: " << aSaveStr << endl; @@ -1209,7 +1209,7 @@ static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy, Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr); ga->Load(current_string); //cout << "Reading: " << aSO->GetID() << " "<< ga->Type() << " value: " << current_string << endl; - } + } delete(current_string); hdf_dataset->CloseOnDisk(); @@ -1231,7 +1231,7 @@ static void BuildTree (const Handle(SALOMEDSImpl_Study)& theStudy, HDFgroup* hdf } char name[HDF_NAME_MAX_LEN+1]; - Standard_Integer nbsons = hdf_current_group->nInternalObjects(); + Standard_Integer nbsons = hdf_current_group->nInternalObjects(); for (Standard_Integer i=0; iInternalObjectIndentify(i,name); if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue; @@ -1239,7 +1239,7 @@ static void BuildTree (const Handle(SALOMEDSImpl_Study)& theStudy, HDFgroup* hdf if (type == HDF_DATASET) { HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group); - ReadAttributes(theStudy,aSO,new_dataset); + ReadAttributes(theStudy,aSO,new_dataset); new_dataset = 0; // will be deleted by father destructor } @@ -1269,7 +1269,7 @@ static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)& s Handle(SALOMEDSImpl_AttributeIOR) IOR; if (current->GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), IOR)) { ior_string = IOR->Value(); - + persistent_string = engine->IORToLocalPersistentID (current, ior_string, isMultiFile, isASCII); SALOMEDSImpl_AttributePersistentRef::Set(current->GetLabel(), persistent_string); } -- 2.39.2