1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of MayaDataModel. 5 6 Licensed under the MIT Open Source License, 7 for details please see LICENSE file or the website 8 http://www.opensource.org/licenses/mit-license.php 9 */ 10 #ifndef __MayaDM_DRAGFIELD_H__ 11 #define __MayaDM_DRAGFIELD_H__ 12 #include "MayaDMTypes.h" 13 #include "MayaDMConnectables.h" 14 #include "MayaDMField.h" 15 namespace MayaDM 16 { 17 class DragField : public Field 18 { 19 public: 20 struct Direction{ 21 double directionX; 22 double directionY; 23 double directionZ; writeDirection24 void write(FILE* file) const 25 { 26 fprintf(file,"%f ", directionX); 27 fprintf(file,"%f ", directionY); 28 fprintf(file,"%f", directionZ); 29 } 30 }; 31 public: 32 DragField()33 DragField():Field(){} 34 DragField(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true) 35 :Field(file, name, parent, "dragField", shared, create){} ~DragField()36 virtual ~DragField(){} 37 setDirection(const Direction & d)38 void setDirection(const Direction& d) 39 { 40 fprintf(mFile,"\tsetAttr \".d\" "); 41 d.write(mFile); 42 fprintf(mFile,";\n"); 43 } setDirectionX(double dx)44 void setDirectionX(double dx) 45 { 46 if(dx == 0.0) return; 47 fprintf(mFile,"\tsetAttr \".d.dx\" %f;\n", dx); 48 } setDirectionY(double dy)49 void setDirectionY(double dy) 50 { 51 if(dy == 0.0) return; 52 fprintf(mFile,"\tsetAttr \".d.dy\" %f;\n", dy); 53 } setDirectionZ(double dz)54 void setDirectionZ(double dz) 55 { 56 if(dz == 0.0) return; 57 fprintf(mFile,"\tsetAttr \".d.dz\" %f;\n", dz); 58 } setUseDirection(bool ud)59 void setUseDirection(bool ud) 60 { 61 if(ud == false) return; 62 fprintf(mFile,"\tsetAttr \".ud\" %i;\n", ud); 63 } setInheritVelocity(double iv)64 void setInheritVelocity(double iv) 65 { 66 if(iv == 0) return; 67 fprintf(mFile,"\tsetAttr \".iv\" %f;\n", iv); 68 } setMotionAttenuation(double mna)69 void setMotionAttenuation(double mna) 70 { 71 if(mna == 0.0) return; 72 fprintf(mFile,"\tsetAttr \".mna\" %f;\n", mna); 73 } setSpeedAttenuation(double spa)74 void setSpeedAttenuation(double spa) 75 { 76 if(spa == 0.0) return; 77 fprintf(mFile,"\tsetAttr \".spa\" %f;\n", spa); 78 } getDirection()79 void getDirection()const 80 { 81 fprintf(mFile,"\"%s.d\"",mName.c_str()); 82 } getDirectionX()83 void getDirectionX()const 84 { 85 fprintf(mFile,"\"%s.d.dx\"",mName.c_str()); 86 } getDirectionY()87 void getDirectionY()const 88 { 89 fprintf(mFile,"\"%s.d.dy\"",mName.c_str()); 90 } getDirectionZ()91 void getDirectionZ()const 92 { 93 fprintf(mFile,"\"%s.d.dz\"",mName.c_str()); 94 } getUseDirection()95 void getUseDirection()const 96 { 97 fprintf(mFile,"\"%s.ud\"",mName.c_str()); 98 } getInheritVelocity()99 void getInheritVelocity()const 100 { 101 fprintf(mFile,"\"%s.iv\"",mName.c_str()); 102 } getMotionAttenuation()103 void getMotionAttenuation()const 104 { 105 fprintf(mFile,"\"%s.mna\"",mName.c_str()); 106 } getSpeedAttenuation()107 void getSpeedAttenuation()const 108 { 109 fprintf(mFile,"\"%s.spa\"",mName.c_str()); 110 } getCurrentTime()111 void getCurrentTime()const 112 { 113 fprintf(mFile,"\"%s.cti\"",mName.c_str()); 114 } 115 protected: 116 DragField(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true) Field(file,name,parent,nodeType,shared,create)117 :Field(file, name, parent, nodeType, shared, create) {} 118 119 }; 120 }//namespace MayaDM 121 #endif//__MayaDM_DRAGFIELD_H__ 122