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/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_AttributeStudyProperties.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeStudyProperties.hxx"
25 #include "SALOMEDS.hxx"
28 #include <TCollection_AsciiString.hxx>
29 #include <TCollection_ExtendedString.hxx>
30 #include <TColStd_HSequenceOfExtendedString.hxx>
31 #include <TColStd_HSequenceOfInteger.hxx>
33 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
34 (const Handle(SALOMEDSImpl_AttributeStudyProperties)& theAttr)
35 :SALOMEDS_GenericAttribute(theAttr)
38 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
39 (SALOMEDS::AttributeStudyProperties_ptr theAttr)
40 :SALOMEDS_GenericAttribute(theAttr)
43 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
47 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
51 SALOMEDS::Locker lock;
52 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
53 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
54 anImpl->ChangeCreatorName((char*)theName.c_str());
56 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str());
59 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
63 SALOMEDS::Locker lock;
64 TCollection_ExtendedString S =
65 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName();
66 aName = TCollection_AsciiString(S).ToCString();
69 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName();
71 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserNameA();
76 void SALOMEDS_AttributeStudyProperties::SetCreationDate
77 (int theMinute, int theHour, int theDay, int theMonth, int theYear)
81 SALOMEDS::Locker lock;
82 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
83 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
85 if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
86 TCollection_ExtendedString S;
87 anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
89 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute,
97 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
105 SALOMEDS::Locker lock;
106 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast
107 (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
109 CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
110 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute,
115 theMinute = (int)aMinute;
116 theHour = (int)anHour;
118 theMonth = (int)aMonth;
119 theYear = (int)anYear;
124 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
128 SALOMEDS::Locker lock;
129 if (theMode == "from scratch")
130 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1);
131 else if (theMode == "copy from")
132 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(2);
134 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(0);
136 else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str());
139 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
143 SALOMEDS::Locker lock;
144 int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode();
145 if (mode == 1) aMode = "from scratch";
146 if (mode == 2) aMode = "copy from";
149 aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode();
153 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
156 SALOMEDS::Locker lock;
157 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified);
160 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified);
163 bool SALOMEDS_AttributeStudyProperties::IsModified()
167 SALOMEDS::Locker lock;
168 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified();
171 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified();
175 int SALOMEDS_AttributeStudyProperties::GetModified()
179 SALOMEDS::Locker lock;
180 isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified();
183 isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified();
187 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
190 SALOMEDS::Locker lock;
191 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked);
194 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked);
197 bool SALOMEDS_AttributeStudyProperties::IsLocked()
201 SALOMEDS::Locker lock;
202 ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked();
205 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked();
209 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
218 SALOMEDS::Locker lock;
219 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
220 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
221 anImpl->SetModification((char*)theName.c_str(), theMinute, theHour, theDay, theMonth, theYear);
223 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(),
231 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
232 std::vector<int>& theMinutes,
233 std::vector<int>& theHours,
234 std::vector<int>& theDays,
235 std::vector<int>& theMonths,
236 std::vector<int>& theYears,
242 SALOMEDS::Locker lock;
243 Handle(TColStd_HSequenceOfExtendedString) aNames;
244 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
245 Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl =
246 Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl);
247 anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
248 aLength = aNames->Length();
249 i = ((theWithCreator) ? 1 : 2);
250 for (; i <= aLength; i++) {
251 theNames.push_back(TCollection_AsciiString(aNames->Value(i)).ToCString());
252 theMinutes.push_back(aMinutes->Value(i));
253 theHours.push_back(aHours->Value(i));
254 theDays.push_back(aDays->Value(i));
255 theMonths.push_back(aMonths->Value(i));
256 theYears.push_back(aYears->Value(i));
259 SALOMEDS::StringSeq_var aNames;
260 SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
261 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(),
268 aLength = aNames->length();
269 for (i = 0; i<aLength; i++) {
270 theNames.push_back(aNames[i].in());
271 theMinutes.push_back(aMinutes[i]);
272 theHours.push_back(aHours[i]);
273 theDays.push_back(aDays[i]);
274 theMonths.push_back(aMonths[i]);
275 theYears.push_back(aYears[i]);