1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOMEDS_AttributeStudyProperties.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDS_AttributeStudyProperties.hxx"
27 #include "SALOMEDS.hxx"
31 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
32 (SALOMEDSImpl_AttributeStudyProperties* theAttr)
33 :SALOMEDS_GenericAttribute(theAttr)
36 SALOMEDS_AttributeStudyProperties::SALOMEDS_AttributeStudyProperties
37 (SALOMEDS::AttributeStudyProperties_ptr theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
41 SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties()
45 void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName)
49 SALOMEDS::Locker lock;
50 SALOMEDSImpl_AttributeStudyProperties* anImpl =
51 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
52 anImpl->ChangeCreatorName(theName);
54 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetUserName(theName.c_str());
57 std::string SALOMEDS_AttributeStudyProperties::GetUserName()
61 SALOMEDS::Locker lock;
62 aName = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreatorName();
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)
77 SALOMEDS::Locker lock;
78 SALOMEDSImpl_AttributeStudyProperties* anImpl =
79 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
81 if (anImpl->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return;
83 anImpl->SetModification(S, theMinute, theHour, theDay, theMonth, theYear);
85 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationDate(theMinute,
93 bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute,
101 SALOMEDS::Locker lock;
102 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>
103 (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear);
105 CORBA::Long aMinute, anHour, aDay, aMonth, anYear;
106 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationDate(aMinute,
111 theMinute = (int)aMinute;
112 theHour = (int)anHour;
114 theMonth = (int)aMonth;
115 theYear = (int)anYear;
120 void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode)
124 SALOMEDS::Locker lock;
125 if (theMode == "from scratch")
126 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(1);
127 else if (theMode == "copy from")
128 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(2);
130 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetCreationMode(0);
132 else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetCreationMode(theMode.c_str());
135 std::string SALOMEDS_AttributeStudyProperties::GetCreationMode()
139 SALOMEDS::Locker lock;
140 int mode = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetCreationMode();
141 if (mode == 1) aMode = "from scratch";
142 if (mode == 2) aMode = "copy from";
145 aMode = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetCreationMode();
149 void SALOMEDS_AttributeStudyProperties::SetModified(int theModified)
152 SALOMEDS::Locker lock;
153 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetModified(theModified);
156 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified);
159 bool SALOMEDS_AttributeStudyProperties::IsModified()
163 SALOMEDS::Locker lock;
164 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsModified();
167 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified();
171 int SALOMEDS_AttributeStudyProperties::GetModified()
175 SALOMEDS::Locker lock;
176 isModified = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->GetModified();
179 isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified();
183 void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked)
186 SALOMEDS::Locker lock;
187 dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->SetLocked(theLocked);
190 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked);
193 bool SALOMEDS_AttributeStudyProperties::IsLocked()
197 SALOMEDS::Locker lock;
198 ret = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl)->IsLocked();
201 ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked();
205 void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theName,
214 SALOMEDS::Locker lock;
215 SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
216 anImpl->SetModification(theName, theMinute, theHour, theDay, theMonth, theYear);
218 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModification(theName.c_str(),
226 void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector<std::string>& theNames,
227 std::vector<int>& theMinutes,
228 std::vector<int>& theHours,
229 std::vector<int>& theDays,
230 std::vector<int>& theMonths,
231 std::vector<int>& theYears,
237 SALOMEDS::Locker lock;
238 vector<string> aNames;
239 vector<int> aMinutes, aHours, aDays, aMonths, aYears;
240 SALOMEDSImpl_AttributeStudyProperties* anImpl = dynamic_cast<SALOMEDSImpl_AttributeStudyProperties*>(_local_impl);
241 anImpl->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
242 aLength = aNames.size();
243 i = ((theWithCreator) ? 1 : 2);
244 for (; i <= aLength; i++) {
245 theNames.push_back(aNames[i-1]);
246 theMinutes.push_back(aMinutes[i-1]);
247 theHours.push_back(aHours[i-1]);
248 theDays.push_back(aDays[i-1]);
249 theMonths.push_back(aMonths[i-1]);
250 theYears.push_back(aYears[i-1]);
253 SALOMEDS::StringSeq_var aNames;
254 SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
255 SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModificationsList(aNames.out(),
262 aLength = aNames->length();
263 for (i = 0; i<aLength; i++) {
264 theNames.push_back(aNames[i].in());
265 theMinutes.push_back(aMinutes[i]);
266 theHours.push_back(aHours[i]);
267 theDays.push_back(aDays[i]);
268 theMonths.push_back(aMonths[i]);
269 theYears.push_back(aYears[i]);