2 // File : SALOMEDS_StudyPropertiesAttribute.cxx
3 // Created : Tue Oct 8 10:13:30 2002
4 // Author : Yves FRICAUD
7 // Copyright : Open CASCADE 2001
10 #include <SALOMEDS_StudyPropertiesAttribute.ixx>
12 const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::GetID()
14 static Standard_GUID SALOMEDS_StudyPropertiesAttributeID ("128371A2-8F52-11d6-A8A3-0001021E8C7F");
15 return SALOMEDS_StudyPropertiesAttributeID;
18 Handle(SALOMEDS_StudyPropertiesAttribute) SALOMEDS_StudyPropertiesAttribute::Set(const TDF_Label& label)
20 Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
21 if (!label.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(),anAttr)) {
22 anAttr = new SALOMEDS_StudyPropertiesAttribute();
23 label.AddAttribute(anAttr);
28 SALOMEDS_StudyPropertiesAttribute::SALOMEDS_StudyPropertiesAttribute()
30 myLocked = Standard_False;
31 myLockChanged = Standard_False;
35 void SALOMEDS_StudyPropertiesAttribute::Init()
37 myUserName = new TColStd_HSequenceOfExtendedString();
38 myMinute = new TColStd_HSequenceOfInteger();
39 myHour = new TColStd_HSequenceOfInteger();
40 myDay = new TColStd_HSequenceOfInteger();
41 myMonth = new TColStd_HSequenceOfInteger();
42 myYear = new TColStd_HSequenceOfInteger();
47 void SALOMEDS_StudyPropertiesAttribute::SetUserName(const TCollection_ExtendedString& theName)
50 myUserName->Append(theName);
53 void SALOMEDS_StudyPropertiesAttribute::SetFirstName(const TCollection_ExtendedString& theName)
56 if (myUserName->Length() == 0) myUserName->Append(theName);
57 else myUserName->SetValue(1, theName);
60 TCollection_ExtendedString SALOMEDS_StudyPropertiesAttribute::GetCreatorName() const
62 if (myUserName->Length() == 0) return TCollection_ExtendedString("");
63 return myUserName->Value(1);
66 Handle(TColStd_HSequenceOfExtendedString) SALOMEDS_StudyPropertiesAttribute::GetUserNames() const
71 void SALOMEDS_StudyPropertiesAttribute::SetModificationDate(const Standard_Integer theMinute,
72 const Standard_Integer theHour,
73 const Standard_Integer theDay,
74 const Standard_Integer theMonth,
75 const Standard_Integer theYear)
78 if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || theDay<0 || theDay>31 || theMonth<0 || theMonth>12)
80 myMinute->Append(theMinute);
81 myHour->Append(theHour);
82 myDay->Append(theDay);
83 myMonth->Append(theMonth);
84 myYear->Append(theYear);
87 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::GetCreationDate(Standard_Integer& theMinute,
88 Standard_Integer& theHour,
89 Standard_Integer& theDay,
90 Standard_Integer& theMonth,
91 Standard_Integer& theYear) const
93 if (myMinute->Length() != 0) {
94 theMinute = myMinute->Value(1);
95 theHour = myHour->Value(1);
96 theDay = myDay->Value(1);
97 theMonth = myMonth->Value(1);
98 theYear = myYear->Value(1);
101 return Standard_False;
104 void SALOMEDS_StudyPropertiesAttribute::GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes,
105 Handle(TColStd_HSequenceOfInteger)& theHours,
106 Handle(TColStd_HSequenceOfInteger)& theDays,
107 Handle(TColStd_HSequenceOfInteger)& theMonths,
108 Handle(TColStd_HSequenceOfInteger)& theYears) const
110 theMinutes = myMinute;
117 void SALOMEDS_StudyPropertiesAttribute::SetCreationMode(const Standard_Integer theMode)
123 Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetCreationMode() const
128 void SALOMEDS_StudyPropertiesAttribute::SetModified(const Standard_Integer theModified)
130 myModified = theModified;
133 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsModified() const
135 return (myModified != 0);
138 Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetModified() const
143 void SALOMEDS_StudyPropertiesAttribute::SetLocked(const Standard_Boolean theLocked)
146 if (myLocked != theLocked) {
147 myLockChanged = Standard_True;
148 myLocked = theLocked;
152 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLocked() const
157 Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLockChanged(const Standard_Boolean theErase) {
158 if (!myLockChanged) return Standard_False;
159 if (theErase) myLockChanged = Standard_False;
160 return Standard_True;
163 const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::ID() const
168 void SALOMEDS_StudyPropertiesAttribute::Restore(const Handle(TDF_Attribute)& with)
170 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(with);
173 Handle(TColStd_HSequenceOfExtendedString) aNames = aProp->GetUserNames();
174 for(i = aNames->Length(); i > 0; i--) {
175 myUserName->Prepend(aNames->Value(i));
177 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
178 aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
179 for(i = aMinutes->Length(); i > 0; i--) {
180 myMinute->Prepend(aMinutes->Value(i));
181 myHour->Prepend(aHours->Value(i));
182 myDay->Prepend(aDays->Value(i));
183 myMonth->Prepend(aMonths->Value(i));
184 myYear->Prepend(aYears->Value(i));
186 myMode = aProp->GetCreationMode();
187 // myModified = aProp->GetModified();
188 // myLocked = aProp->IsLocked();
191 Handle(TDF_Attribute) SALOMEDS_StudyPropertiesAttribute::NewEmpty() const
193 return new SALOMEDS_StudyPropertiesAttribute();
196 void SALOMEDS_StudyPropertiesAttribute::Paste(const Handle(TDF_Attribute)& into,
197 const Handle(TDF_RelocationTable)&) const
199 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(into);
203 for(i = 1; i <= myUserName->Length(); i++) {
204 aProp->SetUserName(myUserName->Value(i));
206 for(i = 1; i <= myMinute->Length(); i++) {
207 aProp->SetModificationDate(myMinute->Value(i), myHour->Value(i), myDay->Value(i), myMonth->Value(i), myYear->Value(i));
210 aProp->SetCreationMode(myMode);
211 // aProp->SetModified(myModified);
212 // aProp->SetLocked(myLocked);