1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 // File : SALOMEDS_AttributeStudyProperties.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeStudyProperties.hxx"
27 #include <TCollection_AsciiString.hxx>
28 #include <TCollection_ExtendedString.hxx>
29 #include <TColStd_HSequenceOfExtendedString.hxx>
30 #include <TColStd_HSequenceOfInteger.hxx>
32 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
33 (const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr)
34 :SALOMEDS_GenericAttribute(theAttr)
37 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
38 (SALOMEDS::AttributeStudyProperties_ptr theAttr)
39 :SALOMEDS_GenericAttribute(theAttr)
42 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
46 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
49 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
50 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
51 anImpl->ChangeCreatorName((char*)theName.c_str());
53 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str());
56 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
60 TCollection_ExtendedString S =
61 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName();
62 aName = TCollection_AsciiString(S).ToCString();
65 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName();
67 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserNameA();
72 void SALOMEDS_AttributeStudyProperties::SetCreationDate
73 (int theMinute, int theHour, int theDay, int theMonth, int theYear)
76 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
77 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
79 if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
80 TCollection_ExtendedString S;
81 anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
83 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute,
91 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
99 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast
100 (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
102 CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
103 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute,
108 theMinute = (int)aMinute;
109 theHour = (int)anHour;
111 theMonth = (int)aMonth;
112 theYear = (int)anYear;
117 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
120 if (theMode == "from scratch")
121 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1);
122 else if (theMode == "copy from")
123 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(2);
125 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(0);
127 else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str());
130 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
134 int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode();
135 if (mode == 1) aMode = "from scratch";
136 if (mode == 2) aMode = "copy from";
139 aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode();
143 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
146 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified);
148 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified);
151 bool SALOMEDS_AttributeStudyProperties::IsModified()
155 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified();
157 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified();
161 int SALOMEDS_AttributeStudyProperties::GetModified()
165 isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified();
167 isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified();
171 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
174 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked);
176 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked);
179 bool SALOMEDS_AttributeStudyProperties::IsLocked()
183 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked();
185 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked();
189 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
197 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
198 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
199 anImpl->SetModification((char*)theName.c_str(), theMinute, theHour, theDay, theMonth, theYear);
201 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(),
209 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
210 std::vector<int>& theMinutes,
211 std::vector<int>& theHours,
212 std::vector<int>& theDays,
213 std::vector<int>& theMonths,
214 std::vector<int>& theYears,
220 Handle(TColStd_HSequenceOfExtendedString) aNames;
221 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
222 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
223 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
224 anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
225 aLength = aNames->Length();
226 i = ((theWithCreator) ? 1 : 2);
227 for (; i <= aLength; i++) {
228 theNames.push_back(TCollection_AsciiString(aNames->Value(i)).ToCString());
229 theMinutes.push_back(aMinutes->Value(i));
230 theHours.push_back(aHours->Value(i));
231 theDays.push_back(aDays->Value(i));
232 theMonths.push_back(aMonths->Value(i));
233 theYears.push_back(aYears->Value(i));
236 SALOMEDS::StringSeq_var aNames;
237 SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
238 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(),
245 aLength = aNames->length();
246 for (i = 0; i<aLength; i++) {
247 theNames.push_back(aNames[i].in());
248 theMinutes.push_back(aMinutes[i]);
249 theHours.push_back(aHours[i]);
250 theDays.push_back(aDays[i]);
251 theMonths.push_back(aMonths[i]);
252 theYears.push_back(aYears[i]);