00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GR_UserOption__
00022 #define __GR_UserOption__
00023
00024 #include "GR_API.h"
00025
00026 #include <UT/UT_String.h>
00027 #include <UT/UT_VectorTypes.h>
00028
00029 class GR_OptionTemplate;
00030 class GR_UserDecoration;
00031 class GU_Detail;
00032 class UT_Options;
00033
00034 class GR_API GR_UserOptionParm
00035 {
00036 public:
00037 const char *myName;
00038 int myType;
00039 };
00040
00041 class GR_API GR_UserOption
00042 {
00043 public:
00044 GR_UserOption(const char *name, const char *label,
00045 GR_OptionTemplate *entry);
00046
00047 virtual ~GR_UserOption();
00048
00049 const char *getName() const { return (const char *) myName; }
00050 void setName(const char *name) { myName.harden(name); }
00051 const char *getLabel() const { return (const char *) myLabel; }
00052 void setLabel(const char *label) { myLabel.harden(label); }
00053 const char *getIconName() const { return (const char *) myIconName; }
00054 void setIconName(const char *name) { myIconName.harden(name); }
00055
00056 GR_OptionTemplate *getTemplate() const { return myTemplate; }
00057
00058
00059
00060 int getVersion() const { return myVersion; }
00061 void bumpVersion() { myVersion++; }
00062
00063 virtual GR_UserOption *duplicate() const = 0;
00064
00065
00066 virtual int saveCommand(ostream &os) const;
00067 virtual bool loadCommand(UT_IStream &is);
00068
00069 virtual bool save(ostream &os, int indent) const;
00070 virtual bool load(UT_IStream &is);
00071
00072
00073
00074 virtual void querySettings(UT_Options &options) const = 0;
00075 virtual bool applySettings(const UT_Options &options) = 0;
00076
00077
00078 virtual GR_UserDecoration *allocDecoration(const GU_Detail *) const
00079 { return 0; }
00080 virtual void freeDecoration(GR_UserDecoration *) const {}
00081
00082
00083
00084
00085
00086
00087 static int saveSettings(ostream &os,
00088 const UT_Options &options, bool for_cmd);
00089
00090
00091
00092
00093
00094
00095
00096 static bool loadSettings(UT_IStream &is,
00097 const GR_UserOptionParm *parm_templates,
00098 UT_Options &options, bool for_cmd,
00099 const char *terminal_token = 0);
00100
00101 protected:
00102 GR_UserOption(const GR_UserOption &src);
00103
00104 virtual const GR_UserOptionParm *getSettingTemplates() const = 0;
00105
00106 static void getDefaultColor(UT_Vector3 &clr);
00107 static void getDefaultSelColor(UT_Vector3 &clr);
00108
00109
00110
00111 static bool querySetting(const UT_Options &options,
00112 const char *name, bool &v);
00113 static bool querySetting(const UT_Options &options,
00114 const char *name, float &v);
00115 static bool querySetting(const UT_Options &options,
00116 const char *name, UT_String &v);
00117 static bool querySetting(const UT_Options &options,
00118 const char *name, UT_Vector3 &v);
00119
00120 private:
00121 UT_String myName;
00122 UT_String myLabel;
00123 UT_String myIconName;
00124 GR_OptionTemplate *myTemplate;
00125
00126 int myVersion;
00127 };
00128
00129 #endif