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 # ------------------------------------------------------------------------ */
27 /*=========================================================================
29 Program: InstantPlayer
30 Module: $RCSfile: InstantPlayer_Txx.h,v $
32 Date: $Date: 2012/11/15 12:12:26 $
33 Version: $Revision: 1.2 $
34 Objective: it do the play methods as stop,pause, play, etc using an instant handler
35 Authot: Monica Maria Lozano Romero
40 This software is distributed WITHOUT ANY WARRANTY; without even
41 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
42 PURPOSE. See the above copyright notice for more information.
45 =========================================================================*/
61 //========= LYFECYCLE ==========
63 InstantPlayer<S>::InstantPlayer(SomeEnvironment<S>* environment)throw (ViewerNDimensionsException)
65 this->environment=environment;
67 this->instantHandler= new InstantHandler<S>(this->environment);
69 throw new ViewerNDimensionsException("ERROR ENVIRONMENT NULL");
70 //this->thingsOfInstant=NULL;
71 //this->timeReproduction=100;
75 InstantPlayer<S>::~InstantPlayer()
77 if(instantHandler) delete instantHandler;
81 //========= OPERATIONS =========
83 * When the user wants to play the dimensions selected by the user
84 * and are already defined
89 void InstantPlayer<S>::play()
91 //setTimeConceptToMode(REAL_TIME);
92 instantHandler->nextInstant();
95 * Paused the reproduction of the dimension played
99 void InstantPlayer<S>::pause()
101 //setTimeConceptToMode(PLUS_PLUS);
105 * Used for change to the next instant in the reproduction
106 * Note: next instant from the instant that's being reproduced
107 * @param loop , if want to do next instant with looping
108 * @return true if the player has changed of instant, false if not
113 bool InstantPlayer<S>::nextInstant(bool loop)throw (ViewerNDimensionsException)
115 //setTimeConceptToMode(PLUS_PLUS);
116 bool hasChanged=false;
117 bool hasNextInstant=instantHandler->hasNextInstant();
120 instantHandler->nextInstant();
124 instantHandler->set();
127 instantHandler->resetConceptsHandled();
128 //instantHandler->set();
134 * Used for change to the previous instant in the reproduction
135 * Note: previous instant from the instant that's being reproduced
136 * @return true if the player has changed of instant, false if not
139 bool InstantPlayer<S>::previousInstant()throw (ViewerNDimensionsException)
141 //setTimeConceptToMode(PLUS_PLUS);
142 bool hasChanged=false;
143 bool hasPreviousInstant=instantHandler->hasPreviousInstant();
144 if(hasPreviousInstant)
146 instantHandler->previousInstant();
150 instantHandler->set();
155 * Used for stops the reproductioN
160 void InstantPlayer<S>::stop()
162 //setTimeConceptToMode(REAL_TIME);
163 instantHandler->resetConceptsHandled();
167 * Removes all the concept handled
170 void InstantPlayer<S>::removeAllConcepts()
172 instantHandler->removeAllConcepts();
177 * Removes the concept with the name given
178 * @param nameConcept, name of the concept to remove
181 void InstantPlayer<S>::removeConceptToHandled(std::string nameConcept)
183 instantHandler->removeConceptToHandled(nameConcept);
185 //====== INQUIRY ========
188 * Returns the things of the actual instant
191 std::vector<S*>* InstantPlayer<S>::getThingsOfInstant() throw (ViewerNDimensionsException)
193 Instant* actualInstant= instantHandler->getActualInstant();
194 //load the things of the actual instant
195 return environment->getThings(actualInstant);
199 * return the actual instant in the instant handler
202 Instant* InstantPlayer<S>::getActualInstant()throw (ViewerNDimensionsException)
204 return instantHandler->getActualInstant();
207 * add new concept to handled
209 * @param mode= REAL_TIME,PLUS_PLUS
210 * @param position, position in the player
213 bool InstantPlayer<S>::addConceptToHandled(std::string nameConcept,int mode,int position)throw (ViewerNDimensionsException)
215 return instantHandler->addConceptToHandled(nameConcept,mode,position);
218 * Returns the things of the actual instants and its names in the
222 void InstantPlayer<S>::getThingsWithName(std::vector<std::string>& names,std::vector< S* >& thingsVector)throw (ViewerNDimensionsException)
224 Instant* actualInstant= instantHandler->getActualInstant();
225 environment->getThings(names,thingsVector,actualInstant);
228 * Returns the names of the concepts handled and its modes
232 void InstantPlayer<S>::getConceptsInfo(std::vector<std::string>& namesConcepts,std::vector<int>& modes)
234 instantHandler->getConceptsInfo(namesConcepts,modes);
237 * Returns the name of the concept that handled the real time
241 void InstantPlayer<S>::getTimeConcept(std::string& nameConcept)
243 instantHandler->getTimeConcept(nameConcept);
246 * get the number of instants that is playing
249 int InstantPlayer<S>::getNumInstantsPlaying()
251 return instantHandler->getNumOfInstants();
254 * Returns the names of the concept with its respectively actual value
255 * @param conceptsAndIndexes is where is going to be save the data searched
258 void InstantPlayer<S>::getConceptsActualIndexes(std::map<std::string,int>* conceptsAndIndexes)throw (ViewerNDimensionsException)
260 std::vector<std::string> conceptsNames;
261 environment->getConceptsNames(conceptsNames);
262 int instantIndex,i,size,index;
263 size=conceptsNames.size();
264 Instant* actualInstant= getActualInstant();
265 std::string conceptNamei;
268 conceptNamei=conceptsNames[i];
269 instantIndex=environment->getIndexConcept(conceptNamei);
270 index=actualInstant->getIndexInConcept(instantIndex);
271 conceptsAndIndexes->insert(std::pair<std::string,int>(conceptNamei,index));
272 conceptNamei.clear();
278 //========= ACCESS =========
280 * Sets the time of reproduction of the concept
281 * that managed the real time
284 void InstantPlayer<S>::setTimeReproduction(double time)
286 //this->timeReproduction=time;
287 instantHandler->setTimeReproduction(time);
290 * Sets the environment
293 void InstantPlayer<S>::setEnvironment(SomeEnvironment<S>* environmment)
295 this->environment=environmment;
301 void InstantPlayer<S>::setActualInstant(Instant* actualInstant)
303 instantHandler->setActualInstant(actualInstant);
309 void InstantPlayer<S>::setActualInstant(std::vector<int>* actualInstant)
311 Instant* instant=new Instant(actualInstant);
312 instantHandler->setActualInstant(instant);
316 * Set the increase Value for changing the instant
319 void InstantPlayer<S>::setIncreaseValue(int increase)
321 instantHandler->setIncreaseValue(increase);
324 * Set the decrease Value for changing the instant
327 void InstantPlayer<S>::setDecreaseValue(int decrease)
329 instantHandler->setDecreaseValue(decrease);
333 * Set the mode of a concept that's being handled
337 void InstantPlayer<S>::setModeOfConcept(std::string nameConcept,int mode)
339 instantHandler->setModeOfConcept(nameConcept,mode);
342 * Set actual time to the instant handler
346 void InstantPlayer<S>::setActualTime(double actualTime)
348 instantHandler->setActualTime(actualTime);
351 * set the modes of the concept that handled the time
352 * to the plus plus mode
356 void InstantPlayer<S>::setTimeConceptToMode(int mode)
358 std::string nameConcept;
359 getTimeConcept(nameConcept);
360 setModeOfConcept(nameConcept,mode);