libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moParam.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moParam.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29  Gustavo Lado?(donde mas?)
30 
31 *******************************************************************************/
32 
33 #ifndef __MO_PARAM_H__
34 #define __MO_PARAM_H__
35 
36 #include "moTypes.h"
37 #include "moText.h"
38 #include "moValue.h"
39 
75 };
76 
78  public:
80  reference=-1;
81  }
82 
84  reference= i;
85  }
87  reference = (MOlong)i;
88  }
89 
91  (*this) = src;
92  }
94  reference = src.reference;
95  return (*this);
96  }
97 
99 };
100 
102 
103  public:
104 
106  index=-1;
107  }
109  index= i;
110  }
112  index = (MOlong)i;
113  }
114 
115  moParamIndex( const moParamIndex& src) {
116  (*this) = src;
117  }
119  index = src.index;
120  return (*this);
121  }
122 
123 
125 };
126 
129 
131 
132 //==========================================================
133 // CONFIG DEFINITION
134 //==========================================================
135 
136 //check CSS3
173 };
174 
175 
177 
178  public:
179 
182  virtual ~moParamInterpolation();
183 
185 
186  void StartInterpolation( const moData& p_data_in, const moData& p_data_out );
187  void StartInterpolation( const moValue& p_value_in, const moValue& p_value_out );
188  void StopInterpolation();
189  const moTimer& GetTimer() const;
190  bool IsOn() const;
191  void Activate();
192 
193  void SetInterpolationFunction( const moText& p_interpol_fun );
194  void SetInterpolation( const moText& p_interpol_fun,
195  const moText& p_fun_duration = moText(1000),
196  const moText& p_fun_expression = moText() );
197  void SetInterpolation( moParamInterpolationFunction p_interpol_fun,
198  const moText& p_fun_duration = moText("1000"),
199  const moText& p_fun_expression = moText("") );
200  void SetDuration( MOlong p_fun_duration );
201  MOlong GetDuration();
202 
203  moText GetFunctionToText();
204 
205  moData* InterpolateData( moData& pParamData );
206 
207  moValue* InterpolateValue( moValue& pParamValue );
208 
209  const moText& ToJSON() {
210 
211  moText fieldseparation = ",";
212 
213  m_FullJSON = "{";
214  m_FullJSON+= "'interpolation': '" + GetFunctionToText() + "'";
215  m_FullJSON+= fieldseparation + "'duration': '" + IntToStr(GetDuration())+ "'";
216  m_FullJSON+= fieldseparation + "'on': '" + IntToStr(IsOn())+ "'";
217  m_FullJSON+= "}";
218 
219  return m_FullJSON;
220  }
221 
222  double bezier_x( double t, double Ax, double Bx, double Cx);
223 
224  double bezier_y( double t, double Ay, double By, double Cy);
225 
226  double bezier_x_der( double t, double Ax, double Bx, double Cx);
227 
228  double find_x_for( double t, double Ax, double Bx, double Cx );
229 
230  double cubic_bezier( double t, double p1, double p2, double p3, double p4 );
231 
232  private:
233  bool m_bIsOn;
234  moTimer m_Timer;
235  MOlong m_Duration; //in milliseconds
236  moParamInterpolationFunction m_Function;
237 
238  moData m_DataIn;
239  moData m_DataOut;
240  moData m_DataInterpolated;
241 
242  moValue m_ValueIn;
243  moValue m_ValueOut;
244  moValue m_ValueInterpolated;
245 
246  moText m_FullJSON;
247 };
248 
249 
251 {
252 
253  public:
254 
257  moParamDefinition( const moText& p_name, moParamType p_type );
258  moParamDefinition( const moText& p_name, const moText& p_type, const moText& p_property=moText(""), const moText& p_group=moText(""), const moText& p_interpolation=moText(""), const moText& p_duration=moText(""), const moText& p_optionsstr=moText("") );
259  moParamDefinition( const moText& p_name, const moText& p_type, const moText& p_property, const moText& p_group, const moText& p_interpolation, const moText& p_duration, const moTextArray& p_Options );
260  virtual ~moParamDefinition();
261 
263 
264  bool IsValid() const;
265 
266  const moText& GetName() const {
267  return m_Name;
268  }
269 
270  void SetName( const moText& p_Name) {
271  m_Name = p_Name;
272  }
273 
274 
275  static moParamType ParamTypeFromStr( const moText& p_type );
276 
278  return m_Type;
279  }
280  moText GetTypeStr() const;
281  void SetType( moParamType p_paramType );
282 
283 
284  MOint GetIndex() const {
285  return m_Index;
286  }
287  void SetIndex( MOint p_index ) {
288  m_Index = p_index;
289  }
290 
291  const moText& GetProperty() const {
292  return m_Property;
293  }
294 
295  void SetProperty( const moText& p_Property) {
296  m_Property = p_Property;
297  }
298 
299  const moText& GetGroup() const {
300  return m_Group;
301  }
302 
303  void SetGroup( const moText& p_Group ) {
304  m_Group = p_Group;
305  }
306 
307  void SetDefault( const moValue& p_defaultvalue);
308 
310  return m_DefaultValue;
311  }
312 
313 
314  void SetOptions( const moTextArray& p_options );
315  void SetOptions( const moText& p_OptionsStr );
316 
317  moTextArray& GetOptions() {
318  return m_Options;
319  }
320 
322  return m_OptionsStr;
323  }
324 
325  void SetInterpolation( moParamInterpolation& p_Interpolation ) {
326  m_Interpolation = p_Interpolation;
327  }
328 
330  return m_Interpolation;
331  }
332 
333  int Set( const moText& p_XmlText );
334 
335  const moText& ToJSON();
336  const moText& ToXML();
337 
338  private:
339 
340  moText m_Name;
341  moParamType m_Type;//type of parameter ()
342  MOint m_Index;//index of this parameter on moConfig parameters array
343 
344  moText m_Property;//published or not
345  moText m_Group;
346  moValue m_DefaultValue;
347  moTextArray m_Options;
348  moText m_OptionsStr;
349  moParamInterpolation m_Interpolation;
350 
351  moText m_FullJSON;
352  moText m_FullXML;
353 
354 };
355 
357 
358 
360 {
361  public:
362  moParam();
363  moParam(const moParam &src);
364  moParam( moParamDefinition &p_paramdefinition);
365  virtual ~moParam();
366 
367  moParam &operator = (const moParam &src);
368 
370  return GetValue( i );
371  }
372 
373  moValues& GetValues();
374  MOuint GetValuesCount() const;
375 
376  void AddValue( moValue &value );
377  void DeleteValue( MOint i );
378  moValue& GetValue( MOint i = -1 );
379  void SetDefaultValue();
380 
381  void SetParamDefinition( moParamDefinition &p_paramdefinition );
382  moParamDefinition& GetParamDefinition();
383 
384  void SetIndexValue( int indexvalue );
385  int GetIndexValue() const;
386 
387  void NextValue();
388  void PrevValue();
389  void FirstValue();
390 
391  moParam* GetPtr();
392  moData* GetData();
393  void Update();
394  void SetExternData( moData* p_pExternData);
395  const moText& ToJSON();
396 
397  bool FixType( moParamType m_NewType = MO_PARAM_UNDEFINED );
398  bool FixOptions( moTextArray& m_NewOptions );
399 
400  private:
401  moParamDefinition m_ParamDefinition;
402  moValues m_Values;
403  int m_CurrentIndexValue;
404 
405  moData* m_pExternData;//Definido cuando el valor del parámetro es intervenido por un Inlet o un Outlet
406  MOboolean m_bExternDataUpdated;//Marcado cuando un Inlet actualiza este parámetro
407 
408  moText m_fullJSON;
409 
410 };
411 
413 typedef std::map< std::string, moParam* > moParamsMap;
414 
415 
416 #endif
417 
value type: TXT or LNK
Definition: moParam.h:69
Valor de un Parámetro.
Definition: moValue.h:501
value type: TXT or LNK
Definition: moParam.h:74
moParamInterpolationFunction
Definition: moParam.h:159
value type: NUM
Definition: moParam.h:58
moTextArray & GetOptions()
Definition: moParam.h:317
moParamIndex moP
Definition: moParam.h:128
value type: NUM or FUNCTION
Definition: moParam.h:59
moParamType
Definition: moParam.h:40
moParamReference moR
Definition: moParam.h:127
value type: NUM or FUNCTION
Definition: moParam.h:66
value type: NUM or FUNCTION
Definition: moParam.h:47
void SetGroup(const moText &p_Group)
Definition: moParam.h:303
value type: NUM or FUNCTION
Definition: moParam.h:65
value type: TXT or LNK
Definition: moParam.h:56
const moText & GetProperty() const
Definition: moParam.h:291
#define MOboolean
Definition: moTypes.h:385
MOlong index
Definition: moParam.h:124
value type: NUM or FUNCTION
Definition: moParam.h:60
MOint GetIndex() const
Definition: moParam.h:284
value type: NUM or FUNCTION
Definition: moParam.h:68
value type: NUM or FUNCTION
Definition: moParam.h:64
const moText & GetGroup() const
Definition: moParam.h:299
moParamIndex(MOint i)
Definition: moParam.h:108
value type: NUM or FUNCTION
Definition: moParam.h:46
moValue & GetDefaultValue()
Definition: moParam.h:309
value type: TXT or LNK, or XML
Definition: moParam.h:54
value type: TXT or LNK
Definition: moParam.h:70
moParamReference & operator=(const moParamReference &src)
Definition: moParam.h:93
#define LIBMOLDEO_API
Definition: moTypes.h:180
const moText & GetName() const
Definition: moParam.h:266
moParamReference(MOuint i)
Definition: moParam.h:86
std::map< std::string, moParam * > moParamsMap
Definition: moParam.h:413
value type: TXT or LNK, or XML
Definition: moParam.h:55
value type: TXT or LNK
Definition: moParam.h:57
clase de para manejar textos
Definition: moText.h:75
#define MOlong
Definition: moTypes.h:391
vector of one type
Definition: moParam.h:72
moParamReference(MOint i)
Definition: moParam.h:83
void SetProperty(const moText &p_Property)
Definition: moParam.h:295
moText0 moText
Definition: moText.h:291
any composition of types
Definition: moParam.h:71
moDeclareExportedDynamicArray(moParamIndex, moParamIndexes)
#define MOint
Definition: moTypes.h:388
value type: TXT or LNK
Definition: moParam.h:49
value type: NUM[4] or FUNCTION[4] or
Definition: moParam.h:43
moParamIndex(const moParamIndex &src)
Definition: moParam.h:115
moParamInterpolation & GetInterpolation()
Definition: moParam.h:329
void SetInterpolation(moParamInterpolation &p_Interpolation)
Definition: moParam.h:325
moParamType GetType() const
Definition: moParam.h:277
value type: TXT or LNK
Definition: moParam.h:50
value type: NUM or FUNCTION
Definition: moParam.h:42
value type: NUM or FUNCTION
Definition: moParam.h:63
moParamIndex & operator=(const moParamIndex &src)
Definition: moParam.h:118
moParamReference(const moParamReference &src)
Definition: moParam.h:90
value type: NUM or FUNCTION
Definition: moParam.h:61
MOlong reference
Definition: moParam.h:98
value type: NUM or FUNCTION
Definition: moParam.h:67
value type: NUM or TEXT ( 0:FILL 1:LINE 2:POINT)
Definition: moParam.h:45
Clase para el control de un temporizador (relativo) con identificación
Definition: moTimer.h:321
void SetIndex(MOint p_index)
Definition: moParam.h:287
value type: TXT or LNK
Definition: moParam.h:51
moMatrix3 & operator=(const moMatrix3 &rkM)
const moText & ToJSON()
Definition: moParam.h:209
void SetName(const moText &p_Name)
Definition: moParam.h:270
#define MOuint
Definition: moTypes.h:387
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
value type: TXT or LNK
Definition: moParam.h:52
moParamIndex()
Definition: moParam.h:105
value type: TXT or LNK
Definition: moParam.h:73
moParamIndex(MOuint i)
Definition: moParam.h:111
value type: TXT or LNK
Definition: moParam.h:53
const moText & GetOptionsStr()
Definition: moParam.h:321
value type: NUM or FUNCTION
Definition: moParam.h:62
value type: NUM or TEXT (to script or shader for chroma???)
Definition: moParam.h:44
value type: TXT or LNK
Definition: moParam.h:48
const Real * operator[](int iRow) const