1 /*
2  * SFVec2d.h
3  *
4  * Copyright (C) 1999 Stephen F. White
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #ifndef _SFVEC2D_H
23 #define _SFVEC2D_H
24 
25 #ifndef _FIELDVALUE_H
26 #include "FieldValue.h"
27 #endif
28 
29 class SFVec2d : public FieldValue {
30 public:
31                         SFVec2d(double x, double y);
32                         SFVec2d(const double *values);
33                         SFVec2d(void); // silly default
34 
getType()35     virtual int         getType() const { return SFVEC2D; }
getStride()36     virtual int         getStride() const { return 2; }
getTypeName()37     virtual const char *getTypeName() const { return "SFVec2d"; }
38     virtual MyString    getString(int index, int stride) const;
39 
40     virtual int         writeData(int filedes, int i) const;
41 
42     virtual int         writeC(int filedes, const char* variableName,
43                                int languageFlag) const;
getTypeC(int languageFlag)44     virtual const char *getTypeC(int languageFlag) const { return "double"; }
isArrayInC(void)45     virtual bool        isArrayInC(void) const { return true; }
46 
47     virtual bool        readLine(int index, char *line);
48 
getNumbersPerType(void)49     virtual int         getNumbersPerType(void) const { return 2; }
needCheckFloat(void)50     virtual bool        needCheckFloat(void) const { return true; }
51 
52     virtual bool        equals(const FieldValue *value) const;
copy()53     virtual FieldValue *copy() { return new SFVec2d(*this); }
54 
getValue(int index)55     double               getValue(int index) const { return m_value[index]; }
getValue()56     const double        *getValue() const { return m_value; }
setValue(int pos,double value)57     void                setValue(int pos, double value)
58                            { m_value[pos] = value; }
59     void                setValue(double v1, double v2);
60 
61     MyString            getEcmaScriptComment(MyString name, int flags) const;
62 
supportAnimation(bool x3d)63     bool                supportAnimation(bool x3d) const { return x3d; }
64 
getRandom(Scene * scene,int nodeType)65     FieldValue         *getRandom(Scene *scene, int nodeType)
66                            { return new SFVec2d(FLOAT_RAND(), FLOAT_RAND()); }
67 private:
68     double               m_value[2];
69 };
70 
71 #endif // _SFVEC2D_H
72