Frapper  1.0a
NumberParameter.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
34 
35 #ifndef NUMBERPARAMETER_H
36 #define NUMBERPARAMETER_H
37 
38 #include "FrapperPrerequisites.h"
39 #include "Parameter.h"
40 #include "Key.h"
41 
42 namespace Frapper {
43 
48 {
49 
50 public: // nested enumerations
51 
56  enum InputMethod {
57  IM_SpinBox = 0,
60 
61  IM_NumInputMethods
62  };
63 
64 public: // static functions
65 
72  static InputMethod decodeInputMethod ( const QString &inputMethodString );
73 
74 public: // constructors and destructors
75 
84  NumberParameter ( const QString &name, Type type, const QVariant &value );
85 
92  NumberParameter ( const NumberParameter &parameter, Node* node = 0 );
93 
97  virtual ~NumberParameter ();
98 
99 public: // functions
100 
106  virtual AbstractParameter * clone ();
107 
113  virtual void setDirty ( bool dirty );
114 
121  virtual void setEnabled ( bool enabled, bool propagate /*= true*/ );
122 
128  InputMethod getInputMethod () const;
129 
135  void setInputMethod ( InputMethod inputMethod );
136 
142  QVariant getMinValue () const;
143 
149  void setMinValue (const QVariant &minValue );
150 
156  QVariant getMaxValue () const;
157 
163  float getAbsMaxValue () const;
164 
170  void setMaxValue ( const QVariant &maxValue );
171 
177  QVariant getStepSize () const;
178 
184  void setStepSize ( const QVariant &stepSize );
185 
191  QString getUnit () const;
192 
198  void setUnitScale ( const float scale );
199 
205  float getUnitScale ( ) const;
206 
212  void setUnit ( const QString &unit );
213 
219  void setTime ( const QVariant &timeValue );
220 
224  void calculateExtrema ();
225 
231  void scaleValues( const float &scaleFactor);
232 
233 public: // animation functions
234 
240  bool isAnimated () const;
241 
247  void addKey ( Key *key );
248 
254  void addKey ( const int &time );
255 
261  void addKey ( const QVariant &value );
262 
268  void addKey ( const float &value );
269 
275  void addKeyPresorted ( Key *key );
276 
282  void setKeys ( const QList<float> *keys );
283 
289  unsigned int numKeys () const;
290 
296  bool isEmpty () const;
297 
303  void removeKey ( const float &time );
304 
310  void removeKey ( const int &index );
311 
318  void removeKeys ( const float &minTime, const float &maxTime );
319 
326  void removeKeys ( const int &minIndex, const int &maxIndex );
327 
331  void clearKeys ( );
332 
339  Key * getKey ( const float &time );
340 
347  Key * getKey ( const unsigned int &index );
348 
354  QList<Key *> * getKeys ();
355 
361  unsigned int getKeysSize () const;
362 
369  inline QVariant getKeyValueInterpol ( const QVariant &time );
370 
377  QVariant getKeyValuePos ( const float &time );
378 
385  QVariant getKeyValueIndex ( const unsigned int &index ) const;
386 
394  QVariant getValue ( bool triggerEvaluation = false ) ;
395 
396 
397 
398 protected: // functions
399 
406  inline QList<Key *>::iterator findIndex ( const float &time );
407 
414  inline QList<Key *>::iterator findIndex ( const Key *key );
415 
416 protected: // helper functions
417 
425  static inline bool lessThan ( const Key *k1, const Key *k2 );
426 
427 private: // data
428 
433 
437  QVariant m_minValue;
438 
442  QVariant m_maxValue;
443 
447  QVariant m_stepSize;
448 
452  QString m_unit;
453 
457  QList<Key *> m_keys;
458 
462  float m_unitScale;
463 };
464 
465 } // end namespace Frapper
466 
467 #endif