2 // File : SALOMEDS_AttributeStudyProperties_i.cxx
3 // Created : Tue Oct 8 10:13:30 2002
4 // Author : Yves FRICAUD
8 // Copyright : Open CASCADE 2002
12 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
13 #include "SALOMEDS_SObject_i.hxx"
14 #include <TColStd_HSequenceOfExtendedString.hxx>
15 #include <TColStd_HSequenceOfInteger.hxx>
17 #define CREATION_MODE_NOTDEFINED 0
18 #define CREATION_MODE_SCRATCH 1
19 #define CREATION_MODE_COPY 2
21 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
23 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
24 CORBA::String_var Str = CORBA::string_dup(theName);
25 aProp->SetFirstName(TCollection_ExtendedString(Str));
28 char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
29 TCollection_ExtendedString S = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreatorName();
30 CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString());
34 void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute,
38 CORBA::Long theYear) {
40 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
42 if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
43 aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear);
46 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute,
49 CORBA::Long& theMonth,
50 CORBA::Long& theYear) {
51 Standard_Integer aMinute;
52 Standard_Integer aHour;
53 Standard_Integer aDay;
54 Standard_Integer aMonth;
55 Standard_Integer aYear;
56 if (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationDate(aMinute, aHour, aDay,
65 return Standard_False;
68 void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) {
70 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
71 if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH);
72 else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY);
73 else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED);
76 char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() {
77 CORBA::String_var c_s;
78 switch (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationMode()) {
79 case CREATION_MODE_SCRATCH: c_s = "from scratch"; break;
80 case CREATION_MODE_COPY: c_s = "copy from"; break;
86 void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) {
87 Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetModified(theModified);
90 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() {
91 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsModified();
94 CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() {
95 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetModified();
98 void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) {
99 Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetLocked(theLocked);
102 CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked() {
103 return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsLocked();
106 void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
107 CORBA::Long theMinute,
110 CORBA::Long theMonth,
111 CORBA::Long theYear) {
113 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
114 aProp->SetUserName(CORBA::string_dup(theName));
115 aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
117 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
118 SALOMEDS::LongSeq_out theMinutes,
119 SALOMEDS::LongSeq_out theHours,
120 SALOMEDS::LongSeq_out theDays,
121 SALOMEDS::LongSeq_out theMonths,
122 SALOMEDS::LongSeq_out theYears,
123 CORBA::Boolean theWithCreator) {
124 Handle(TColStd_HSequenceOfExtendedString) aNames;
125 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
126 Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
127 aNames = aProp->GetUserNames();
128 aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears);
129 int aLength = aNames->Length()-((theWithCreator)?0:1);
130 theNames = new SALOMEDS::StringSeq;
131 // SALOMEDS::LongSeq *maminute = new SALOMEDS::LongSeq;
132 // maminute->length(5);
133 theMinutes = new SALOMEDS::LongSeq;
134 theHours = new SALOMEDS::LongSeq;
135 theDays = new SALOMEDS::LongSeq;
136 theMonths = new SALOMEDS::LongSeq;
137 theYears = new SALOMEDS::LongSeq;
138 theNames->length(aLength);
139 theMinutes->length(aLength);
140 theHours->length(aLength);
141 theDays->length(aLength);
142 theMonths->length(aLength);
143 theYears->length(aLength);
145 for(a = 0; a < aLength; a++)
147 (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString());
148 (*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1));
149 (*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1));
150 (*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1));
151 (*theMonths)[a] = aMonths->Value(a + 1 + ((theWithCreator)?0:1));
152 (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1));