00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __SIM_OptionsUser_h__
00015 #define __SIM_OptionsUser_h__
00016
00017 #include "SIM_API.h"
00018 #include "SIM_Options.h"
00019
00020 class SIM_Data;
00021
00022
00023
00024
00025
00026 class SIM_API SIM_OptionsUser
00027 {
00028 public:
00029 SIM_OptionsUser(SIM_Data *owner);
00030 virtual ~SIM_OptionsUser();
00031
00032
00033
00034 void optionChanged(const char *name);
00035
00036 protected:
00037 const SIM_Options &getOptions() const;
00038 SIM_Options &getOptions();
00039
00040 virtual void optionChangedSubclass(const char *name);
00041
00042 private:
00043 SIM_Data *myOwner;
00044 SIM_Options myOptions;
00045 };
00046
00047 #define GET_DATA_FUNC_I(DataName, FuncName) \
00048 int64 get##FuncName() const \
00049 { return getOptions().getOptionI(DataName); }
00050 #define GET_DATA_FUNC_E(DataName, FuncName, EnumType) \
00051 EnumType get##FuncName() const \
00052 { return static_cast<EnumType> \
00053 (getOptions().getOptionI(DataName)); }
00054 #define GET_DATA_FUNC_B(DataName, FuncName) \
00055 bool get##FuncName() const \
00056 { return getOptions().getOptionB(DataName); }
00057 #define GET_DATA_FUNC_F(DataName, FuncName) \
00058 fpreal64 get##FuncName() const \
00059 { return getOptions().getOptionF(DataName); }
00060
00061 #define _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, BaseType, Accessor) \
00062 const BaseType##D get##FuncName##D() const \
00063 { return getOptions().getOption##Accessor(DataName); } \
00064 const BaseType##F get##FuncName##F() const \
00065 { return getOptions().getOption##Accessor(DataName); } \
00066 const BaseType##F get##FuncName() const \
00067 { return getOptions().getOption##Accessor(DataName); }
00068
00069 #define GET_DATA_FUNC_V2(DataName, FuncName) \
00070 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector2, V2);
00071 #define GET_DATA_FUNC_V2D(DataName, FuncName) \
00072 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector2D, V2);
00073 #define GET_DATA_FUNC_UV(DataName, FuncName) \
00074 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector2, V2);
00075 #define GET_DATA_FUNC_V3(DataName, FuncName) \
00076 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector3, V3);
00077 #define GET_DATA_FUNC_V3D(DataName, FuncName) \
00078 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector3D, V3);
00079 #define GET_DATA_FUNC_UVW(DataName, FuncName) \
00080 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector3, V3);
00081 #define GET_DATA_FUNC_V4(DataName, FuncName) \
00082 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector4, V4);
00083 #define GET_DATA_FUNC_V4D(DataName, FuncName) \
00084 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Vector4D, V4);
00085 #define GET_DATA_FUNC_Q(DataName, FuncName) \
00086 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Quaternion, Q);
00087 #define GET_DATA_FUNC_QD(DataName, FuncName) \
00088 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_QuaternionD, Q);
00089 #define GET_DATA_FUNC_M3(DataName, FuncName) \
00090 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Matrix3, M3);
00091 #define GET_DATA_FUNC_M4(DataName, FuncName) \
00092 _BUILD_SIM_OPTION_GETTERS(DataName, FuncName, UT_Matrix4, M4);
00093 #define GET_DATA_FUNC_S(DataName, FuncName) \
00094 void get##FuncName(UT_String &value) const \
00095 { getOptions().getOptionS(DataName, value); }
00096
00097 #define _BUILD_SIM_OPTION_GUIDE_GETTERS(DataName, FuncName, Default, BaseType, Accessor) \
00098 const BaseType##D get##FuncName##D(const SIM_Options &options) const \
00099 { return options.hasOption(DataName) \
00100 ? options.getOption##Accessor(DataName) \
00101 : BaseType##D Default; \
00102 } \
00103 const BaseType##F get##FuncName##F(const SIM_Options &options) const \
00104 { return options.hasOption(DataName) \
00105 ? options.getOption##Accessor(DataName) \
00106 : BaseType##D Default; \
00107 } \
00108 const BaseType##F get##FuncName(const SIM_Options &options) const \
00109 { return options.hasOption(DataName) \
00110 ? options.getOption##Accessor(DataName) \
00111 : BaseType##D Default; \
00112 }
00113
00114 #define GET_GUIDE_FUNC_I(DataName, FuncName, Default) \
00115 int64 get##FuncName(const SIM_Options &options) const \
00116 { return options.hasOption(DataName) \
00117 ? options.getOptionI(DataName) \
00118 : Default; \
00119 }
00120 #define GET_GUIDE_FUNC_E(DataName, FuncName, EnumType, Default) \
00121 EnumType get##FuncName(const SIM_Options &options) const \
00122 { return static_cast<EnumType> (options.hasOption(DataName) \
00123 ? options.getOptionI(DataName) \
00124 : Default); \
00125 }
00126 #define GET_GUIDE_FUNC_B(DataName, FuncName, Default) \
00127 bool get##FuncName(const SIM_Options &options) const \
00128 { return options.hasOption(DataName) \
00129 ? options.getOptionB(DataName) \
00130 : Default; \
00131 }
00132 #define GET_GUIDE_FUNC_F(DataName, FuncName, Default) \
00133 fpreal64 get##FuncName(const SIM_Options &options) const \
00134 { return options.hasOption(DataName) \
00135 ? options.getOptionF(DataName) \
00136 : Default; \
00137 }
00138 #define GET_GUIDE_FUNC_V2(DataName, FuncName, Default) \
00139 _BUILD_SIM_OPTION_GUIDE_GETTERS(DataName, FuncName, Default, UT_Vector2, V2)
00140 #define GET_GUIDE_FUNC_V3(DataName, FuncName, Default) \
00141 _BUILD_SIM_OPTION_GUIDE_GETTERS(DataName, FuncName, Default, UT_Vector3, V3)
00142 #define GET_GUIDE_FUNC_V4(DataName, FuncName, Default) \
00143 _BUILD_SIM_OPTION_GUIDE_GETTERS(DataName, FuncName, Default, UT_Vector4, V4)
00144
00145 #define GET_GUIDE_FUNC_S(DataName, FuncName, Default) \
00146 void get##FuncName(UT_String &value, const SIM_Options &options) const \
00147 { if (options.hasOption(DataName)) \
00148 options.getOptionS(DataName, value); \
00149 else \
00150 value = Default; \
00151 }
00152
00153 #define SET_DATA_FUNC_I(DataName, FuncName) \
00154 void set##FuncName(const int64 value) \
00155 { getOptions().setOptionI(DataName, value); }
00156 #define SET_DATA_FUNC_E(DataName, FuncName, EnumType) \
00157 void set##FuncName(const EnumType value) \
00158 { getOptions().setOptionI(DataName, \
00159 static_cast<int>(value)); }
00160 #define SET_DATA_FUNC_B(DataName, FuncName) \
00161 void set##FuncName(const bool value) \
00162 { getOptions().setOptionB(DataName, value); }
00163 #define SET_DATA_FUNC_F(DataName, FuncName) \
00164 void set##FuncName(const fpreal64 value) \
00165 { getOptions().setOptionF(DataName, value); }
00166 #define SET_DATA_FUNC_V2(DataName, FuncName) \
00167 void set##FuncName(const UT_Vector2F &value) \
00168 { getOptions().setOptionV2(DataName, value); } \
00169 void set##FuncName(const UT_Vector2D &value) \
00170 { getOptions().setOptionV2(DataName, value); }
00171 #define SET_DATA_FUNC_UV(DataName, FuncName) \
00172 void set##FuncName(const UT_Vector2F &value) \
00173 { getOptions().setOptionUV(DataName, value); } \
00174 void set##FuncName(const UT_Vector2D &value) \
00175 { getOptions().setOptionUV(DataName, value); }
00176 #define SET_DATA_FUNC_V3(DataName, FuncName) \
00177 void set##FuncName(const UT_Vector3F &value) \
00178 { getOptions().setOptionV3(DataName, value); } \
00179 void set##FuncName(const UT_Vector3D &value) \
00180 { getOptions().setOptionV3(DataName, value); }
00181 #define SET_DATA_FUNC_UVW(DataName, FuncName) \
00182 void set##FuncName(const UT_Vector3F &value) \
00183 { getOptions().setOptionUVW(DataName, value); } \
00184 void set##FuncName(const UT_Vector3D &value) \
00185 { getOptions().setOptionUVW(DataName, value); }
00186 #define SET_DATA_FUNC_V4(DataName, FuncName) \
00187 void set##FuncName(const UT_Vector4F &value) \
00188 { getOptions().setOptionV4(DataName, value); } \
00189 void set##FuncName(const UT_Vector4D &value) \
00190 { getOptions().setOptionV4(DataName, value); }
00191 #define SET_DATA_FUNC_Q(DataName, FuncName) \
00192 void set##FuncName(const UT_QuaternionF &value) \
00193 { getOptions().setOptionQ(DataName, value); } \
00194 void set##FuncName(const UT_QuaternionD &value) \
00195 { getOptions().setOptionQ(DataName, value); }
00196 #define SET_DATA_FUNC_M3(DataName, FuncName) \
00197 void set##FuncName(const UT_Matrix3F &value) \
00198 { getOptions().setOptionM3(DataName, value); } \
00199 void set##FuncName(const UT_Matrix3D &value) \
00200 { getOptions().setOptionM3(DataName, value); }
00201 #define SET_DATA_FUNC_M4(DataName, FuncName) \
00202 void set##FuncName(const UT_Matrix4F &value) \
00203 { getOptions().setOptionM4(DataName, value); } \
00204 void set##FuncName(const UT_Matrix4D &value) \
00205 { getOptions().setOptionM4(DataName, value); }
00206 #define SET_DATA_FUNC_S(DataName, FuncName) \
00207 void set##FuncName(const UT_String &value) \
00208 { getOptions().setOptionS(DataName, value); }
00209
00210 #define GETSET_DATA_FUNCS_I(DataName, FuncName) \
00211 GET_DATA_FUNC_I(DataName, FuncName) \
00212 SET_DATA_FUNC_I(DataName, FuncName)
00213 #define GETSET_DATA_FUNCS_E(DataName, FuncName, EnumType) \
00214 GET_DATA_FUNC_E(DataName, FuncName, EnumType) \
00215 SET_DATA_FUNC_E(DataName, FuncName, EnumType)
00216 #define GETSET_DATA_FUNCS_B(DataName, FuncName) \
00217 GET_DATA_FUNC_B(DataName, FuncName) \
00218 SET_DATA_FUNC_B(DataName, FuncName)
00219 #define GETSET_DATA_FUNCS_F(DataName, FuncName) \
00220 GET_DATA_FUNC_F(DataName, FuncName) \
00221 SET_DATA_FUNC_F(DataName, FuncName)
00222 #define GETSET_DATA_FUNCS_V2(DataName, FuncName) \
00223 GET_DATA_FUNC_V2(DataName, FuncName) \
00224 SET_DATA_FUNC_V2(DataName, FuncName)
00225 #define GETSET_DATA_FUNCS_UV(DataName, FuncName) \
00226 GET_DATA_FUNC_UV(DataName, FuncName) \
00227 SET_DATA_FUNC_UV(DataName, FuncName)
00228 #define GETSET_DATA_FUNCS_V3(DataName, FuncName) \
00229 GET_DATA_FUNC_V3(DataName, FuncName) \
00230 SET_DATA_FUNC_V3(DataName, FuncName)
00231 #define GETSET_DATA_FUNCS_UVW(DataName, FuncName) \
00232 GET_DATA_FUNC_UVW(DataName, FuncName) \
00233 SET_DATA_FUNC_UVW(DataName, FuncName)
00234 #define GETSET_DATA_FUNCS_V4(DataName, FuncName) \
00235 GET_DATA_FUNC_V4(DataName, FuncName) \
00236 SET_DATA_FUNC_V4(DataName, FuncName)
00237 #define GETSET_DATA_FUNCS_Q(DataName, FuncName) \
00238 GET_DATA_FUNC_Q(DataName, FuncName) \
00239 SET_DATA_FUNC_Q(DataName, FuncName)
00240 #define GETSET_DATA_FUNCS_M3(DataName, FuncName) \
00241 GET_DATA_FUNC_M3(DataName, FuncName) \
00242 SET_DATA_FUNC_M3(DataName, FuncName)
00243 #define GETSET_DATA_FUNCS_M4(DataName, FuncName) \
00244 GET_DATA_FUNC_M4(DataName, FuncName) \
00245 SET_DATA_FUNC_M4(DataName, FuncName)
00246 #define GETSET_DATA_FUNCS_S(DataName, FuncName) \
00247 GET_DATA_FUNC_S(DataName, FuncName) \
00248 SET_DATA_FUNC_S(DataName, FuncName)
00249
00250 #endif
00251