1 // File : SALOMEDS_AttributeStudyProperties.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDS_AttributeStudyProperties.hxx"
8 #include <TCollection_AsciiString.hxx>
9 #include <TCollection_ExtendedString.hxx>
10 #include <TColStd_HSequenceOfExtendedString.hxx>
11 #include <TColStd_HSequenceOfInteger.hxx>
13 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
14 (const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr)
15 :SALOMEDS_GenericAttribute(theAttr)
18 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
19 (SALOMEDS::AttributeStudyProperties_ptr theAttr)
20 :SALOMEDS_GenericAttribute(theAttr)
23 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
27 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
30 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
31 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
32 anImpl->ChangeCreatorName((char*)theName.c_str());
34 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str());
37 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
41 TCollection_ExtendedString S =
42 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName();
43 aName = TCollection_AsciiString(S).ToCString();
46 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName();
48 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserNameA();
53 void SALOMEDS_AttributeStudyProperties::SetCreationDate
54 (int theMinute, int theHour, int theDay, int theMonth, int theYear)
57 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
58 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
60 if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
61 TCollection_ExtendedString S;
62 anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
64 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute,
72 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
80 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast
81 (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
83 CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
84 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute,
89 theMinute = (int)aMinute;
90 theHour = (int)anHour;
92 theMonth = (int)aMonth;
93 theYear = (int)anYear;
98 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
101 if (theMode == "from scratch")
102 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1);
103 else if (theMode == "copy from")
104 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(2);
106 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(0);
108 else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str());
111 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
115 int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode();
116 if (mode == 1) aMode = "from scratch";
117 if (mode == 2) aMode = "copy from";
120 aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode();
124 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
127 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified);
129 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified);
132 bool SALOMEDS_AttributeStudyProperties::IsModified()
136 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified();
138 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified();
142 int SALOMEDS_AttributeStudyProperties::GetModified()
146 isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified();
148 isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified();
152 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
155 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked);
157 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked);
160 bool SALOMEDS_AttributeStudyProperties::IsLocked()
164 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked();
166 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked();
170 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
178 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
179 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
180 anImpl->SetModification((char*)theName.c_str(), theMinute, theHour, theDay, theMonth, theYear);
182 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(),
190 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
191 std::vector<int>& theMinutes,
192 std::vector<int>& theHours,
193 std::vector<int>& theDays,
194 std::vector<int>& theMonths,
195 std::vector<int>& theYears,
201 Handle(TColStd_HSequenceOfExtendedString) aNames;
202 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
203 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
204 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
205 anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
206 aLength = aNames->Length();
207 i = ((theWithCreator) ? 1 : 2);
208 for (; i <= aLength; i++) {
209 theNames.push_back(TCollection_AsciiString(aNames->Value(i)).ToCString());
210 theMinutes.push_back(aMinutes->Value(i));
211 theHours.push_back(aHours->Value(i));
212 theDays.push_back(aDays->Value(i));
213 theMonths.push_back(aMonths->Value(i));
214 theYears.push_back(aYears->Value(i));
217 SALOMEDS::StringSeq_var aNames;
218 SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
219 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(),
226 aLength = aNames->length();
227 for (i = 0; i<aLength; i++) {
228 theNames.push_back(aNames[i].in());
229 theMinutes.push_back(aMinutes[i]);
230 theHours.push_back(aHours[i]);
231 theDays.push_back(aDays[i]);
232 theMonths.push_back(aMonths[i]);
233 theYears.push_back(aYears[i]);