Frapper  1.0a
Node.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 NODE_H
36 #define NODE_H
37 
38 #include "FrapperPrerequisites.h"
39 #include "ParameterGroup.h"
40 #include "Parameter.h"
41 #include "NumberParameter.h"
42 #include "FilenameParameter.h"
43 #include "EnumerationParameter.h"
44 #include "SceneNodeParameter.h"
45 #include "Connection.h"
46 #include "InstanceCounterMacros.h"
47 #include <QtCore/QObject>
48 #include <QtCore/QThread>
49 #include <QtCore/QStringList>
50 #include "OgreVector3.h"
51 
52 namespace Frapper {
53 
71 class FRAPPER_CORE_EXPORT Node : public QThread
72 {
73 
74  Q_OBJECT
75 
76 public:
77 #pragma data_seg(".shared")
78  static int s_numberOfInstances;
80 #pragma data_seg()
81 
82 public: // constructors and destructors
83 
90  Node ( const QString &name, ParameterGroup *parameterRoot );
91 
99  virtual ~Node ();
100 
101 
102 public: // functions
103 
107  virtual void run ( const QString &parameterName );
108 
109  //########### obsolete - just for performance testing
119  virtual bool process ( const QString &parameterName );
120 
121  bool getTypeUnknown () const;
122 
128  Parameter *getTimeParameter () const;
129 
136  QString getName () const;
137 
144  void setName ( const QString &name );
145 
151  QString getTypeName () const;
152 
162  void setTypeName ( const QString &typeName );
163 
169  bool isTypeUnknown () const;
170 
177  void setTypeUnknown ( bool typeUnknown = true );
178 
184  bool isEvaluated () const;
185 
191  bool isSelected () const;
192 
198  virtual void setSelected ( bool selected );
199 
205  bool isSelfEvaluating () const;
206 
212  bool isSaveable () const;
213 
219  void setSelfEvaluating ( bool selfEvaluating );
220 
226  void setSaveable ( bool saveable );
227 
233  QString getSearchText () const;
234 
241  void setSearchText ( const QString &searchText );
242 
243 public: // parameter group functions
244 
251  ParameterGroup * getParameterRoot () const;
252 
259  ParameterGroup * getParameterGroup ( const QString &name ) const;
260 
269  void fillParameterLists ( AbstractParameter::List *inputParameters, AbstractParameter::List *outputParameters );
270 
281  void fillParameterLists ( AbstractParameter::List *connectedInputParameters, AbstractParameter::List *connectedOutputParameters, bool *unconnectedInputParametersAvailable, bool *unconnectedOutputParametersAvailable );
282 
292  AbstractParameter::List getParameters ( Parameter::PinType pinType, bool connected, ParameterGroup *parameterGroup = 0 );
293 
294 public: // parameter functions
295 
302  bool hasParameter ( const QString &name ) const;
303 
310  Parameter * getParameter ( const QString &name ) const;
311 
320  NumberParameter * getNumberParameter ( const QString &name ) const;
321 
330  FilenameParameter * getFilenameParameter ( const QString &name ) const;
331 
340  EnumerationParameter * getEnumerationParameter ( const QString &name ) const;
341 
350  GeometryParameter * getGeometryParameter ( const QString &name ) const;
351 
360  LightParameter * getLightParameter ( const QString &name ) const;
361 
370  CameraParameter * getCameraParameter ( const QString &name ) const;
371 
379  void setDirty ( const QString &name, bool dirty );
380 
386  void setDirty ( bool dirty );
387 
393  void setNodeDirty ( bool dirty );
394 
400  bool isNodeDirty ();
401 
407  void removeParameter ( const QString &name, bool diveInGroups = true );
408 
414  void removeParameter ( Parameter *parameter, bool diveInGroups = true );
415 
419  void addAffection ( const QString &parameterName, const QString &affectedParameterName );
420 
421 public: // value getter functions
422 
431  QVariant getValue ( const QString &name, bool triggerEvaluation = false );
432 
441  bool getBoolValue ( const QString &name, bool triggerEvaluation = false );
442 
451  int getIntValue ( const QString &name, bool triggerEvaluation = false );
452 
461  unsigned int getUnsignedIntValue ( const QString &name, bool triggerEvaluation = false );
462 
472  float getFloatValue ( const QString &name, bool triggerEvaluation = false );
473 
483  double getDoubleValue ( const QString &name, bool triggerEvaluation = false );
484 
493  QString getStringValue ( const QString &name, bool triggerEvaluation = false );
494 
503  QColor getColorValue ( const QString &name, bool triggerEvaluation = false );
504 
513  Ogre::Vector3 getVectorValue ( const QString &name, bool triggerEvaluation = false );
514 
523  Ogre::SceneNode * getSceneNodeValue ( const QString &name, bool triggerEvaluation = false );
524 
533  Ogre::TexturePtr getTextureValue ( const QString &name, bool triggerEvaluation = false );
534 
543  ParameterGroup * getGroupValue ( const QString &name, bool triggerEvaluation = false );
544 
545 public: // value setter functions
546 
547 
556  void setValue ( const QString &name, const QVariant &value, bool triggerDirtying = false );
557 
566  void setValue ( const QString &name, bool value, bool triggerDirtying = false );
567 
576  void setValue ( const QString &name, int value, bool triggerDirtying = false );
577 
586  void setValue ( const QString &name, unsigned int value, bool triggerDirtying = false );
587 
597  void setValue ( const QString &name, double value, bool triggerDirtying = false );
598 
607  void setValue ( const QString &name, char *value, bool triggerDirtying = false );
608 
617  void setValue ( const QString &name, const char *value, bool triggerDirtying = false );
618 
630  void setValue ( const QString &name, const QString &value, bool triggerDirtying = false );
631 
640  void setValue ( const QString &name, const QColor &value, bool triggerDirtying = false );
641 
650  void setValue ( const QString &name, const Ogre::Vector3 &value, bool triggerDirtying = false );
651 
660  void setValue ( const QString &name, Ogre::SceneNode *value, bool triggerDirtying = false );
661 
670  void setValue ( const QString &name, const Ogre::TexturePtr value, bool triggerDirtying = false );
671 
680  void setValue ( const QString &name, ParameterGroup *value, bool triggerDirtying = false );
681 
688  void setParameterEnabled ( const QString &name, bool enabled );
689 
690 public: // callback setter functions
691 
701  void setChangeFunction ( const QString &name, const char *changeFunction );
702 
712  void setProcessingFunction ( const QString &name, const char *processingFunction );
713 
723  void setAuxProcessingFunction ( const QString &name, const char *processingFunction );
724 
735  void setCommandFunction ( const QString &name, const char *commandFunction );
736 
743  void setOnConnectFunction ( const QString &name, const char *onConnectFunction );
744 
751  void setOnDisconnectFunction ( const QString &name, const char *onDisconnectFunction );
752 
753 public: // misc functions
754 
759  void notifyChange ();
760 
773  virtual void setUpTimeDependencies ( Parameter *timeParameter );
774 
782  virtual void evaluateConnection ( Connection *connection );
783 
789  void deleteConnection ( Connection *connection);
790 
794  void renderSingleFrame ();
795 
796  public slots: //
797 
803  virtual void setEvaluate ( bool evaluate );
804 
808  virtual void loadReady();
809 
813  virtual void saveStart();
814 
815 signals: //
816 
820  void frameChanged (int);
821 
826  void nodeChanged ();
827 
831  void nodeNameChanged (const QString &name);
832 
838  void selectedChanged ( bool selected );
839 
845  void sendDeleteConnection ( Connection *connection);
846 
850  void updateFrame ();
851 
853  void selectDeselectObject ( const QString &name );
854 
856  void loadSceneElementsReady();
857 
858 protected: // methods
859 
864  Ogre::String createUniqueName ( const QString &objectName );
865 
866  virtual void finalize(); // only virtual for solver release !!!
867 
868 protected: // data
869 
876  QString m_name;
877 
881  QString m_typeName;
882 
886  bool m_dirty;
887 
892 
897 
902 
907 
912 
917  QString m_searchText;
918 
923 
924 private: // data
925 
930 
931 };
932 
933 } // end namespace Frapper
934 
935 #endif