Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

jsWRLtypes.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2002  Carsten Winkelholz / Pirros Tsiakoulis
00003 
00004 Address:  FGAN Forschungsgesellschaft fr Angewandte Naturwissenschaften e. V.
00005       Neuenahrer Str. 20
00006       D - 53343 Wachtberg
00007       
00008 Email:    winkelholz@fgan.de
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 #ifndef JSWRLTYPES_HC
00026 #define JSWRLTYPES_HC
00027 
00028 #include "jsapi.h"
00029 #include "../oawconfig.h"
00030 
00031 OAW_BEGIN_NAMESPACE
00032 
00033 
00034 
00036 //class for private data of javascript objects
00038 class OAW_DLLMAPPING jsPrivate
00039 {
00040 public:
00041   //for simple objects
00042   long m_wrlType;     //the type of the object
00043   const void *m_pWrlData;   //pointer to the actual data (C++)
00044   short m_hasFlag;    //is eventOut
00045   void *m_pWrlFlag;   //pointer to the flag for eventOuts
00046   short m_MustDelete; //flag if the C++ data must be deleted 
00047                       //when javascript object is destroyed
00048 
00049   //for copies of SFNode fields
00050   long m_fieldId;       //the id of field or eventOut
00051   const SFNode *m_pNode;    //the node containing the field
00052 
00053   //for global object's private data
00054   CybWorldC* m_pWorld;
00055   CybSAI::BrowserC* m_pBrowser;
00056   CybScriptC* m_pScript;
00057 
00058   //for global object
00059   jsPrivate(CybWorldC* pW,CybSAI::BrowserC* pB,CybScriptC* pS)
00060   {
00061     m_pWorld = pW;
00062     m_pBrowser = pB;
00063     m_pScript = pS;
00064     m_MustDelete = 0;
00065   }
00066 
00067   jsPrivate(long type, const void *data, short hasF, void *flag, short mustDel, long id = -1, const SFNode *node = NULL)
00068   {
00069     m_wrlType = type;
00070     m_pWrlData = data;
00071     m_hasFlag = hasF;
00072     m_pWrlFlag = flag;
00073     m_MustDelete = mustDel;
00074 
00075     m_fieldId = id;
00076     m_pNode = node;
00077   }
00078   
00079   ~jsPrivate();
00080 };
00081 
00082 //enumerations for SFVec2f, SFVec3f, SFColor, SFRotation, SFImage properties
00083 enum {SFVEC2F_X,SFVEC2F_Y};
00084 enum {SFVEC3F_X,SFVEC3F_Y,SFVEC3F_Z};
00085 enum {SFCOLOR_R,SFCOLOR_G,SFCOLOR_B};
00086 enum {SFROTATION_X,SFROTATION_Y,SFROTATION_Z,SFROTATION_ANGLE};
00087 enum {SFIMAGE_X,SFIMAGE_Y,SFIMAGE_COMP,SFIMAGE_ARRAY};
00088 
00089 //javascript class descriptors for VRML data types
00090 extern JSClass SFVec2f_class;
00091 extern JSClass SFVec3f_class;
00092 extern JSClass SFColor_class;
00093 extern JSClass SFRotation_class;
00094 extern JSClass SFNode_class;
00095 extern JSClass SFImage_class;
00096 
00097 extern JSClass MFInt32_class;
00098 extern JSClass MFFloat_class;
00099 extern JSClass MFVec2f_class;
00100 extern JSClass MFVec3f_class;
00101 extern JSClass MFRotation_class;
00102 extern JSClass MFColor_class;
00103 extern JSClass MFString_class;
00104 extern JSClass MFNode_class;
00105 
00106 /*initilizes all VRML javascript classes
00107     cx, obj context and global object*/
00108 OAW_DLLMAPPING bool initJsWrlClasses(JSContext *cx, JSObject *obj);
00109 
00110 /*constructs a new object and makes it global property or return it with rval
00111   cx, glob context and global object
00112   name the name of the global property 
00113   type the type of the ogject to create
00114   value the poiter to the actual C++ object or value
00115   flag the flag for eventOuts
00116   rval for returning the object if name = NULL
00117   fid and node for copies of SFNode fields
00118   mustdel flag if value should be deleted when object destroyed
00119   return value: on success 1, on error 0*/
00120 OAW_DLLMAPPING short NewGlobalProperty(JSContext *cx,JSObject *glob,const char *name, long type, void *value, void *flag, jsval *rval, long fid = -1, SFNode *node = NULL, short mustDel = 0);
00121 
00122 /*checks if simple eventOut has change and copies the new value
00123   type the type of the eventOut
00124   name the name of the eventOut
00125   dest the destination to copy the new data
00126   return value: on success 1, on error 0*/
00127 void CopyJSWrlData(JSContext *cx, JSObject *obj, long type, const char *name, void *dest);
00128 void WriteJSWrlData(JSContext *cx, JSObject *obj, long type, const char *name, void *src);
00129 
00130 
00131 /*returns the name of the SFNode node*/
00132 OAW_DLLMAPPING const char *GetSFNodeName(const SFNode *node);
00133 
00134 OAW_DLLMAPPING bool initBrowserObject(JSContext *cx, JSObject *obj);
00135 
00136 OAW_DLLMAPPING bool initSFVec2fClass(JSContext *cx, JSObject *obj);
00137 OAW_DLLMAPPING bool initSFVec3fClass(JSContext *cx, JSObject *obj);
00138 OAW_DLLMAPPING bool initSFColorClass(JSContext *cx, JSObject *obj);
00139 OAW_DLLMAPPING bool initSFRotationClass(JSContext *cx, JSObject *obj);
00140 OAW_DLLMAPPING bool initSFNodeClass(JSContext *cx, JSObject *obj);
00141 OAW_DLLMAPPING bool initSFImageClass(JSContext *cx, JSObject *obj);
00142 
00143 OAW_DLLMAPPING bool initMFInt32Class(JSContext *cx, JSObject *obj);
00144 OAW_DLLMAPPING bool initMFFloatClass(JSContext *cx, JSObject *obj);
00145 OAW_DLLMAPPING bool initMFVec2fClass(JSContext *cx, JSObject *obj);
00146 OAW_DLLMAPPING bool initMFVec3fClass(JSContext *cx, JSObject *obj);
00147 OAW_DLLMAPPING bool initMFRotationClass(JSContext *cx, JSObject *obj);
00148 OAW_DLLMAPPING bool initMFColorClass(JSContext *cx, JSObject *obj);
00149 OAW_DLLMAPPING bool initMFNodeClass(JSContext *cx, JSObject *obj);
00150 OAW_DLLMAPPING bool initMFStringClass(JSContext *cx, JSObject *obj);
00151 
00152 
00153 OAW_END_NAMESPACE
00154 
00155 
00156 #endif

Generated on Tue Jul 29 14:24:14 2003 for Open ActiveWrl by doxygen1.3-rc2