1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SALOMEDS_StudyPropertiesAttribute.cxx
8 // Author : Yves FRICAUD
13 #include <SALOMEDS_StudyPropertiesAttribute.ixx>
15 const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::GetID()
17 static Standard_GUID SALOMEDS_StudyPropertiesAttributeID ("128371A2-8F52-11d6-A8A3-0001021E8C7F");
18 return SALOMEDS_StudyPropertiesAttributeID;
21 Handle(SALOMEDS_StudyPropertiesAttribute) SALOMEDS_StudyPropertiesAttribute::Set(const TDF_Label& label)
23 Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
24 if (!label.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(),anAttr)) {
25 anAttr = new SALOMEDS_StudyPropertiesAttribute();
26 label.AddAttribute(anAttr);
31 SALOMEDS_StudyPropertiesAttribute::SALOMEDS_StudyPropertiesAttribute()
33 myLocked = Standard_False;
34 myLockChanged = Standard_False;
38 void SALOMEDS_StudyPropertiesAttribute::Init()
40 myUserName = new TColStd_HSequenceOfExtendedString();
41 myMinute = new TColStd_HSequenceOfInteger();
42 myHour = new TColStd_HSequenceOfInteger();
43 myDay = new TColStd_HSequenceOfInteger();
44 myMonth = new TColStd_HSequenceOfInteger();
45 myYear = new TColStd_HSequenceOfInteger();
50 void SALOMEDS_StudyPropertiesAttribute::SetUserName(const TCollection_ExtendedString& theName)
53 myUserName->Append(theName);
56 void SALOMEDS_StudyPropertiesAttribute::SetFirstName(const TCollection_ExtendedString& theName)
59 if (myUserName->Length() == 0) myUserName->Append(theName);
60 else myUserName->SetValue(1, theName);
63 TCollection_ExtendedString SALOMEDS_StudyPropertiesAttribute::GetCreatorName() const
65 if (myUserName->Length() == 0) return TCollection_ExtendedString("");
66 return myUserName->Value(1);
69 Handle(TColStd_HSequenceOfExtendedString) SALOMEDS_StudyPropertiesAttribute::GetUserNames() const
74 void SALOMEDS_StudyPropertiesAttribute::SetModificationDate(const Standard_Integer theMinute,
75 const Standard_Integer theHour,
76 const Standard_Integer theDay,
77 const Standard_Integer theMonth,
78 const Standard_Integer theYear)
81 if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || theDay<0 || theDay>31 || theMonth<0 || theMonth>12)
83 myMinute->Append(theMinute);
84 myHour->Append(theHour);
85 myDay->Append(theDay);
86 myMonth->Append(theMonth);
87 myYear->Append(theYear);
90 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::GetCreationDate(Standard_Integer& theMinute,
91 Standard_Integer& theHour,
92 Standard_Integer& theDay,
93 Standard_Integer& theMonth,
94 Standard_Integer& theYear) const
96 if (myMinute->Length() != 0) {
97 theMinute = myMinute->Value(1);
98 theHour = myHour->Value(1);
99 theDay = myDay->Value(1);
100 theMonth = myMonth->Value(1);
101 theYear = myYear->Value(1);
102 return Standard_True;
104 return Standard_False;
107 void SALOMEDS_StudyPropertiesAttribute::GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes,
108 Handle(TColStd_HSequenceOfInteger)& theHours,
109 Handle(TColStd_HSequenceOfInteger)& theDays,
110 Handle(TColStd_HSequenceOfInteger)& theMonths,
111 Handle(TColStd_HSequenceOfInteger)& theYears) const
113 theMinutes = myMinute;
120 void SALOMEDS_StudyPropertiesAttribute::SetCreationMode(const Standard_Integer theMode)
126 Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetCreationMode() const
131 void SALOMEDS_StudyPropertiesAttribute::SetModified(const Standard_Integer theModified)
133 myModified = theModified;
136 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsModified() const
138 return (myModified != 0);
141 Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetModified() const
146 void SALOMEDS_StudyPropertiesAttribute::SetLocked(const Standard_Boolean theLocked)
149 if (myLocked != theLocked) {
150 myLockChanged = Standard_True;
151 myLocked = theLocked;
155 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLocked() const
160 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLockChanged(const Standard_Boolean theErase) {
161 if (!myLockChanged) return Standard_False;
162 if (theErase) myLockChanged = Standard_False;
163 return Standard_True;
166 const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::ID() const
171 void SALOMEDS_StudyPropertiesAttribute::Restore(const Handle(TDF_Attribute)& with)
173 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(with);
176 Handle(TColStd_HSequenceOfExtendedString) aNames = aProp->GetUserNames();
177 for(i = aNames->Length(); i > 0; i--) {
178 myUserName->Prepend(aNames->Value(i));
180 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
181 aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
182 for(i = aMinutes->Length(); i > 0; i--) {
183 myMinute->Prepend(aMinutes->Value(i));
184 myHour->Prepend(aHours->Value(i));
185 myDay->Prepend(aDays->Value(i));
186 myMonth->Prepend(aMonths->Value(i));
187 myYear->Prepend(aYears->Value(i));
189 myMode = aProp->GetCreationMode();
190 // myModified = aProp->GetModified();
191 // myLocked = aProp->IsLocked();
194 Handle(TDF_Attribute) SALOMEDS_StudyPropertiesAttribute::NewEmpty() const
196 return new SALOMEDS_StudyPropertiesAttribute();
199 void SALOMEDS_StudyPropertiesAttribute::Paste(const Handle(TDF_Attribute)& into,
200 const Handle(TDF_RelocationTable)&) const
202 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(into);
206 for(i = 1; i <= myUserName->Length(); i++) {
207 aProp->SetUserName(myUserName->Value(i));
209 for(i = 1; i <= myMinute->Length(); i++) {
210 aProp->SetModificationDate(myMinute->Value(i), myHour->Value(i), myDay->Value(i), myMonth->Value(i), myYear->Value(i));
213 aProp->SetCreationMode(myMode);
214 // aProp->SetModified(myModified);
215 // aProp->SetLocked(myLocked);