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 int 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 fpreal get##FuncName() const \
00059 { return getOptions().getOptionF(DataName); }
00060 #define GET_DATA_FUNC_V2(DataName, FuncName) \
00061 const UT_Vector2 get##FuncName() const \
00062 { return getOptions().getOptionV2(DataName); }
00063 #define GET_DATA_FUNC_UV(DataName, FuncName) \
00064 const UT_Vector2 get##FuncName() const \
00065 { return getOptions().getOptionUV(DataName); }
00066 #define GET_DATA_FUNC_V3(DataName, FuncName) \
00067 const UT_Vector3 get##FuncName() const \
00068 { return getOptions().getOptionV3(DataName); }
00069 #define GET_DATA_FUNC_UVW(DataName, FuncName) \
00070 const UT_Vector3 get##FuncName() const \
00071 { return getOptions().getOptionUVW(DataName); }
00072 #define GET_DATA_FUNC_V4(DataName, FuncName) \
00073 const UT_Vector4 get##FuncName() const \
00074 { return getOptions().getOptionV4(DataName); }
00075 #define GET_DATA_FUNC_Q(DataName, FuncName) \
00076 const UT_Quaternion get##FuncName() const \
00077 { return getOptions().getOptionQ(DataName); }
00078 #define GET_DATA_FUNC_M3(DataName, FuncName) \
00079 const UT_Matrix3 get##FuncName() const \
00080 { return getOptions().getOptionM3(DataName); }
00081 #define GET_DATA_FUNC_M4(DataName, FuncName) \
00082 const UT_Matrix4 get##FuncName() const \
00083 { return getOptions().getOptionM4(DataName); }
00084 #define GET_DATA_FUNC_S(DataName, FuncName) \
00085 void get##FuncName(UT_String &value) const \
00086 { getOptions().getOptionS(DataName, value); }
00087
00088 #define GET_GUIDE_FUNC_I(DataName, FuncName, Default) \
00089 int get##FuncName(const SIM_Options &options) const \
00090 { return options.hasOption(DataName) \
00091 ? options.getOptionI(DataName) \
00092 : Default; \
00093 }
00094 #define GET_GUIDE_FUNC_E(DataName, FuncName, EnumType, Default) \
00095 EnumType get##FuncName(const SIM_Options &options) const \
00096 { return static_cast<EnumType> (options.hasOption(DataName) \
00097 ? options.getOptionI(DataName) \
00098 : Default); \
00099 }
00100 #define GET_GUIDE_FUNC_B(DataName, FuncName, Default) \
00101 bool get##FuncName(const SIM_Options &options) const \
00102 { return options.hasOption(DataName) \
00103 ? options.getOptionB(DataName) \
00104 : Default; \
00105 }
00106 #define GET_GUIDE_FUNC_F(DataName, FuncName, Default) \
00107 fpreal get##FuncName(const SIM_Options &options) const \
00108 { return options.hasOption(DataName) \
00109 ? options.getOptionF(DataName) \
00110 : Default; \
00111 }
00112 #define GET_GUIDE_FUNC_V2(DataName, FuncName, Default) \
00113 const UT_Vector2 get##FuncName(const SIM_Options &options) const \
00114 { return options.hasOption(DataName) \
00115 ? options.getOptionV2(DataName) \
00116 : UT_Vector2 Default; \
00117 }
00118 #define GET_GUIDE_FUNC_V3(DataName, FuncName, Default) \
00119 const UT_Vector3 get##FuncName(const SIM_Options &options) const \
00120 { return options.hasOption(DataName) \
00121 ? options.getOptionV3(DataName) \
00122 : UT_Vector3 Default; \
00123 }
00124 #define GET_GUIDE_FUNC_V4(DataName, FuncName, Default) \
00125 const UT_Vector4 get##FuncName(const SIM_Options &options) const \
00126 { return options.hasOption(DataName) \
00127 ? options.getOptionV4(DataName) \
00128 : UT_Vector4 Default; \
00129 }
00130
00131 #define GET_GUIDE_FUNC_S(DataName, FuncName, Default) \
00132 void get##FuncName(UT_String &value, const SIM_Options &options) const \
00133 { if (options.hasOption(DataName)) \
00134 options.getOptionS(DataName, value); \
00135 else \
00136 value = Default; \
00137 }
00138
00139 #define SET_DATA_FUNC_I(DataName, FuncName) \
00140 void set##FuncName(const int value) \
00141 { getOptions().setOptionI(DataName, value); }
00142 #define SET_DATA_FUNC_E(DataName, FuncName, EnumType) \
00143 void set##FuncName(const EnumType value) \
00144 { getOptions().setOptionI(DataName, \
00145 static_cast<int>(value)); }
00146 #define SET_DATA_FUNC_B(DataName, FuncName) \
00147 void set##FuncName(const bool value) \
00148 { getOptions().setOptionB(DataName, value); }
00149 #define SET_DATA_FUNC_F(DataName, FuncName) \
00150 void set##FuncName(const fpreal value) \
00151 { getOptions().setOptionF(DataName, value); }
00152 #define SET_DATA_FUNC_V2(DataName, FuncName) \
00153 void set##FuncName(const UT_Vector2 &value) \
00154 { getOptions().setOptionV2(DataName, value); }
00155 #define SET_DATA_FUNC_UV(DataName, FuncName) \
00156 void set##FuncName(const UT_Vector2 &value) \
00157 { getOptions().setOptionUV(DataName, value); }
00158 #define SET_DATA_FUNC_V3(DataName, FuncName) \
00159 void set##FuncName(const UT_Vector3 &value) \
00160 { getOptions().setOptionV3(DataName, value); }
00161 #define SET_DATA_FUNC_UVW(DataName, FuncName) \
00162 void set##FuncName(const UT_Vector3 &value) \
00163 { getOptions().setOptionUVW(DataName, value); }
00164 #define SET_DATA_FUNC_V4(DataName, FuncName) \
00165 void set##FuncName(const UT_Vector4 &value) \
00166 { getOptions().setOptionV4(DataName, value); }
00167 #define SET_DATA_FUNC_Q(DataName, FuncName) \
00168 void set##FuncName(const UT_Quaternion &value) \
00169 { getOptions().setOptionQ(DataName, value); }
00170 #define SET_DATA_FUNC_M3(DataName, FuncName) \
00171 void set##FuncName(const UT_Matrix3 &value) \
00172 { getOptions().setOptionM3(DataName, value); }
00173 #define SET_DATA_FUNC_M4(DataName, FuncName) \
00174 void set##FuncName(const UT_Matrix4 &value) \
00175 { getOptions().setOptionM4(DataName, value); }
00176 #define SET_DATA_FUNC_S(DataName, FuncName) \
00177 void set##FuncName(const UT_String &value) \
00178 { getOptions().setOptionS(DataName, value); }
00179
00180 #define GETSET_DATA_FUNCS_I(DataName, FuncName) \
00181 GET_DATA_FUNC_I(DataName, FuncName) \
00182 SET_DATA_FUNC_I(DataName, FuncName)
00183 #define GETSET_DATA_FUNCS_E(DataName, FuncName, EnumType) \
00184 GET_DATA_FUNC_E(DataName, FuncName, EnumType) \
00185 SET_DATA_FUNC_E(DataName, FuncName, EnumType)
00186 #define GETSET_DATA_FUNCS_B(DataName, FuncName) \
00187 GET_DATA_FUNC_B(DataName, FuncName) \
00188 SET_DATA_FUNC_B(DataName, FuncName)
00189 #define GETSET_DATA_FUNCS_F(DataName, FuncName) \
00190 GET_DATA_FUNC_F(DataName, FuncName) \
00191 SET_DATA_FUNC_F(DataName, FuncName)
00192 #define GETSET_DATA_FUNCS_V2(DataName, FuncName) \
00193 GET_DATA_FUNC_V2(DataName, FuncName) \
00194 SET_DATA_FUNC_V2(DataName, FuncName)
00195 #define GETSET_DATA_FUNCS_UV(DataName, FuncName) \
00196 GET_DATA_FUNC_UV(DataName, FuncName) \
00197 SET_DATA_FUNC_UV(DataName, FuncName)
00198 #define GETSET_DATA_FUNCS_V3(DataName, FuncName) \
00199 GET_DATA_FUNC_V3(DataName, FuncName) \
00200 SET_DATA_FUNC_V3(DataName, FuncName)
00201 #define GETSET_DATA_FUNCS_UVW(DataName, FuncName) \
00202 GET_DATA_FUNC_UVW(DataName, FuncName) \
00203 SET_DATA_FUNC_UVW(DataName, FuncName)
00204 #define GETSET_DATA_FUNCS_V4(DataName, FuncName) \
00205 GET_DATA_FUNC_V4(DataName, FuncName) \
00206 SET_DATA_FUNC_V4(DataName, FuncName)
00207 #define GETSET_DATA_FUNCS_Q(DataName, FuncName) \
00208 GET_DATA_FUNC_Q(DataName, FuncName) \
00209 SET_DATA_FUNC_Q(DataName, FuncName)
00210 #define GETSET_DATA_FUNCS_M3(DataName, FuncName) \
00211 GET_DATA_FUNC_M3(DataName, FuncName) \
00212 SET_DATA_FUNC_M3(DataName, FuncName)
00213 #define GETSET_DATA_FUNCS_M4(DataName, FuncName) \
00214 GET_DATA_FUNC_M4(DataName, FuncName) \
00215 SET_DATA_FUNC_M4(DataName, FuncName)
00216 #define GETSET_DATA_FUNCS_S(DataName, FuncName) \
00217 GET_DATA_FUNC_S(DataName, FuncName) \
00218 SET_DATA_FUNC_S(DataName, FuncName)
00219
00220 #endif
00221