Frapper  1.0a
Parameter.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-2010 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 PARAMETER_H
36 #define PARAMETER_H
37 
38 #include "FrapperPrerequisites.h"
39 #include "AbstractParameter.h"
40 #include "Connection.h"
41 #include <QtCore/QString>
42 #include <QtCore/QVariant>
43 #include <QtCore/QVariantList>
44 #include <QtXml/QDomElement>
45 #include <QtCore/QStringList>
46 #include <QtCore/QMutex>
47 #include "InstanceCounterMacros.h"
48 
49 // OGRE
50 #include <Ogre.h>
51 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
52 #include <windows.h>
53 #endif
54 
55 // Declare Ogre Metatypes to be used with QVariant
56 Q_DECLARE_METATYPE(Ogre::Vector3)
57 Q_DECLARE_METATYPE(Ogre::TexturePtr)
59 
60 namespace Frapper {
61 
65  class ParameterGroup;
66 
71  {
72  friend class SceneModel;
73  Q_OBJECT
75 
76  public: // type definitions
77 
82  typedef unsigned int Size;
83 
84  public: // nested enumerations
85 
89  enum Type {
90  T_Unknown = -1,
108 
109  T_NumTypes
110  };
111 
116  M_Invalid = -1,
117  M_OneOrMore
118  };
119 
124  enum PinType {
125  PT_None = -1,
127  PT_Output
128  };
129 
130  public: // static functions
131 
138  static QString getTypeName ( Type type );
139 
146  static QColor getTypeColor ( Type type );
147 
154  static Type getTypeByName ( const QString &typeName );
155 
162  static QVariant getDefaultValue ( Type type );
163 
172  static QColor decodeIntColor ( const QString &color );
173 
182  static QColor decodeDoubleColor ( const QString &color );
183 
190  static Size decodeSize ( const QString &size );
191 
198  static int decodeMultiplicity ( const QString &multiplicity );
199 
206  static PinType decodePinType ( const QString &pinTypeString );
207 
219  static Parameter * create ( const QString &name, Type type, QVariant defaultValue = QVariant() );
220 
231  static Parameter * create ( const QDomElement &element );
232 
239  static Parameter * clone ( const Parameter &parameter );
240 
247  static QString extractFirstGroupName ( QString *path );
248 
256  static Parameter * createImageParameter ( const QString &name, Ogre::TexturePtr texturePointer = Ogre::TexturePtr(0) );
257 
265  static Parameter * createGroupParameter ( const QString &name, ParameterGroup *parameterGroup = 0 );
266 
267  public: // static data
268 
272  static const QString PathSeparator;
273 
277  static const QString EnumerationSeparator;
278 
279  public: // constructors and destructors
280 
288  Parameter ( const QString &name, Type type, const QVariant &value );
289 
295  Parameter ( const Parameter &parameter );
296 
300  virtual ~Parameter ();
301 
302  public: // functions
303 
309  virtual AbstractParameter * clone ();
310 
317  virtual bool isGroup () const;
318 
324  Type getType () const;
325 
332  Size getSize () const;
333 
340  void setSize ( Size size );
341 
348  int getMultiplicity () const;
349 
356  void setMultiplicity ( int multiplicity );
357 
363  int getNumberOfConnections () const;
364 
372  virtual QVariant getValue ( bool triggerEvaluation = false );
373 
380  virtual const QVariantList & getValueList () const;
381 
387  void setValue ( const QVariant &value, bool triggerDirtying = false );
388 
397  void setValue ( int index, const QVariant &value, bool triggerDirtying = false );
398 
404  bool hasDefaultValue () const;
405 
411  void setDefaultValue ( const QVariant &defaultValue );
412 
416  virtual void reset ();
417 
424  List getAffectedParameters () const;
425 
432  void addAffectedParameter ( Parameter *affectedParameter );
433 
440  void removeAffectedParameter ( Parameter *affectedParameter );
441 
448  List getAffectingParameters () const;
449 
456  void addAffectingParameter ( Parameter *affectingParameter );
457 
464  void removeAffectingParameter ( Parameter *affectingParameter );
465 
471  QString getDescription () const;
472 
478  void setDescription ( const QString &description );
479 
486  PinType getPinType () const;
487 
493  void setPinType ( PinType pinType );
494 
500  Connection::Map getConnectionMap () const;
501 
507  void addConnection ( Connection *connection );
508 
514  void removeConnection ( Connection::ID id );
515 
522  bool isConnected () const;
523 
529  Parameter * getConnectedParameter () const;
530 
536  bool isDirty ();
537 
543  virtual void setDirty ( bool dirty );
544 
550  bool isAuxDirty ();
551 
557  virtual void setAuxDirty ( bool dirty );
558 
564  bool isVisible () const;
565 
571  void setVisible ( bool visible );
572 
579  bool isReadOnly () const;
580 
587  void setReadOnly ( bool readOnly );
588 
594  void setSelfEvaluating ( bool selfEvaluating );
595 
600  bool isSelfEvaluating () const;
601 
606  void propagateDirty (bool setFirstTrue = true);
607 
612  void propagateAuxDirty ();
613 
619  void propagateEvaluation ();
620 
629  void setChangeFunction ( const char *changeFunction );
630 
639  void setProcessingFunction ( const char *processingFunction );
640 
649  void setAuxProcessingFunction ( const char *processingFunction );
650 
660  void setCommandFunction ( const char *commandFunction );
661 
668  void setOnConnectFunction ( const char *onConnectFunction );
669 
676  void setOnDisconnectFunction ( const char *onDisconnectFunction );
677 
682  void executeCommand ();
683 
689  QString getValueString ();
690 
691 signals: // signals
692 
696  void dirtied ();
697 
701  void valueChanged ();
702 
709  void valueChanged ( int index );
710 
715  void processingRequested ();
716 
721  void auxProcessingRequested ();
722 
726  void commandExecutionRequested ();
727 
731  void connectionEstablished();
732 
736  void connectionDestroyed();
737 
738  protected: // data
739 
743  QMutex m_mutex;
744  //NILZ: DEBUG:
745  QStringList m_mutexList;
746 
751 
756  int m_size;
757 
763 
767  QVariant m_defaultValue;
768 
772  QVariant m_value;
773 
777  QVariantList m_valueList;
778 
782  QString m_description;
783 
788 
794 
800 
805 
809  bool m_dirty;
810 
815 
820  bool m_visible;
821 
827 
832  };
833 
834 // Declare Frapper Metatypes to be used with QVariant
836 
837 } // end namespace Frapper
838 
839 #endif