2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
41 #include "ConceptInstantHandler.h"
48 //====== LIFECYCLE ========
49 ConceptInstantHandler::ConceptInstantHandler(std::string name,int mode,int positionInReproduction)
53 this->positionInReproduction=positionInReproduction;
54 this->increaseValue=1;
55 this->decreaseValue=1;
58 //timeReproduction=intervalTimer*maximumValue
59 this->timeReproduction=100;
64 ConceptInstantHandler::~ConceptInstantHandler()
68 //====== OPERATIONS =======
70 * change the actual index by increasing
71 * the index until the maximum by the increaseValue
73 void ConceptInstantHandler::nextIndex()
78 actualIndex+=increaseValue;
82 time_t seconds=time(NULL);
84 initialTime=seconds*1000;
85 int time=seconds*1000;
86 actualTime=time-initialTime;
87 actualIndex=(int)actualTime*scaleTime;
91 if(actualIndex>=maximumIndex)
92 actualIndex=maximumIndex-1;
95 * change the actual index by decreasing
96 * the index until zero by the decreaseValue
98 void ConceptInstantHandler::previousIndex()
102 actualIndex-=decreaseValue;
105 actualIndex=(int)actualTime*scaleTime;
112 //====== INQUIRY =========
116 std::string ConceptInstantHandler::getName()
121 * @return PositionInReproduction
123 int ConceptInstantHandler::getPosition()
125 return this->positionInReproduction;
130 int ConceptInstantHandler::getMode()
135 * @return increaseValue
137 int ConceptInstantHandler::getIncreaseValue()
139 return this->increaseValue;
143 * @return decreaseValue
145 int ConceptInstantHandler::getDecreaseValue()
147 return this->decreaseValue;
151 * @return indexInInstant
153 int ConceptInstantHandler::getIndexInInstant()
155 return this->indexInInstant;
158 * @return actualIndex
160 int ConceptInstantHandler::geActualIndex()
165 * @return maximumIndex
168 int ConceptInstantHandler::getMaximumIndex()
173 * @return timeReproduction
175 double ConceptInstantHandler::getTimeReproduction()
177 return timeReproduction;
182 double ConceptInstantHandler::getScale()
187 * if the actual index is not the maximum index
189 bool ConceptInstantHandler::hasNextIndex()
191 if(actualIndex<maximumIndex-1)
196 * if the actual index is not zero
198 bool ConceptInstantHandler::hasPreviousIndex()
207 double ConceptInstantHandler::getInitialTime()
209 return this->initialTime;
212 //====== ACCESS ==========
214 * Sets the name of the concept
215 * @param name, new name
217 void ConceptInstantHandler::setName(std::string name)
222 * Sets the position of the concept
223 * @param position, position
225 void ConceptInstantHandler::setPosition(int position)
227 this->positionInReproduction=position;
230 * Sets the mode of the concept
231 * @param mode, new mode= REAL_TIME or
234 void ConceptInstantHandler::setMode(int mode)
236 if(this->mode==PLUS_PLUS)
238 time_t seconds=time(NULL);
239 int time=seconds*1000;
240 actualTime=actualIndex/scaleTime;
241 initialTime=time-actualTime;
246 * Set Increase of the instant
248 void ConceptInstantHandler::setIncreaseValue(int increaseValue)
250 this->increaseValue=increaseValue;
254 * Set decrease of the instant
256 void ConceptInstantHandler::setDecreaseValue(int decreaseValue)
258 this->decreaseValue=decreaseValue;
261 * Sets the index of the concept in the instant
262 * @param indexInInstant
264 void ConceptInstantHandler::setIndexInInstant(int indexInInstant)
266 this->indexInInstant=indexInInstant;
269 * Sets sets the maximum value
270 * @param maximumIndex
272 void ConceptInstantHandler::setMaximumIndex(int maximumIndex)
274 this->maximumIndex=maximumIndex;
275 scaleTime=(maximumIndex-1)/timeReproduction;
279 * set the actualIndex
281 void ConceptInstantHandler::setActualIndex(int index)
283 if(index<=maximumIndex-1)
285 //TODO else thow exception of out of bounds
288 * set the timeReproduction
289 * @param timeReproduction
291 void ConceptInstantHandler::setTimeReproduction(double time)
293 this->timeReproduction=(this->maximumIndex-1)*time;
294 scaleTime=(maximumIndex-1)/timeReproduction;
300 void ConceptInstantHandler::setScale(double scale)
302 this->scaleTime=scale;
308 void ConceptInstantHandler::setActualTime(double actualTime)
310 this->actualTime=actualTime;
313 * reset the initial time
315 void ConceptInstantHandler::resetInitialTime()
320 * Sets the initial time
322 void ConceptInstantHandler::setInitialTime(double time)
324 this->initialTime=time;