00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef JDXBASE_H
00019 #define JDXBASE_H
00020
00021
00022 #include <tjutils/tjutils.h>
00023 #include <tjutils/tjlabel.h>
00024 #include <tjutils/tjlist.h>
00025 #include <tjutils/tjarray.h>
00026
00027
00028
00029 #define _BRUKER_MODE_STRING_CAP_START_ 1000
00030 #define _BRUKER_MODE_STRING_MIN_SIZE_ 256
00031 #define _BRUKER_MODE_STRING_CAP_FACTOR_ 3
00032
00033
00047 enum compatMode {bruker,notBroken};
00048
00049
00056 enum parameterMode {edit,noedit,hidden};
00057
00058
00066 enum fileMode {include,compressed,exclude};
00067
00068
00069
00071
00072
00073 class JcampDxBlock;
00074 class JDXfunction;
00075 class JDXtriple;
00076 class JDXaction;
00077 class JDXenum;
00078 class JDXfileName;
00079 class JDXformula;
00080 class JDXrecoIndices;
00081
00082
00084
00089 class JcampDx {
00090 public:
00091 static const char* get_compName();
00092 };
00093
00095
00103 enum scaleType {displayScale=0,xPlotScale,yPlotScaleLeft,yPlotScaleRight,n_ScaleTypes};
00104
00105
00109 struct ArrayScale {
00110
00111 ArrayScale() : minval(0), maxval(0) {}
00112
00113 ArrayScale(const STD_string& scalelabel, const STD_string& scaleunit, float scalemin=0.0, float scalemax=0.0);
00114
00115 STD_string get_label_with_unit() const;
00116
00120 STD_string label;
00121
00125 STD_string unit;
00126
00130 float minval,maxval;
00131 };
00132
00134
00138 struct PixmapProps {
00139
00140 PixmapProps() : minsize(128), maxsize(1024), autoscale(true), color(false), overlay_minval(0), overlay_maxval(0), overlay_firescale(false), overlay_rectsize(0.8f) {}
00141
00142
00143 void get_overlay_range(float& min, float& max) const;
00144
00148 unsigned int minsize, maxsize;
00149
00153 bool autoscale;
00154
00158 bool color;
00159
00160
00164 farray overlay_map;
00165
00169 float overlay_minval, overlay_maxval;
00170
00174 bool overlay_firescale;
00175
00179 float overlay_rectsize;
00180 };
00181
00182
00184
00188 struct GuiProps {
00189 GuiProps() : fixedsize(true) {}
00190
00194 ArrayScale scale[n_ScaleTypes];
00195
00200 bool fixedsize;
00201
00205 PixmapProps pixmap;
00206 };
00207
00209
00210
00221 enum parxCodeType {parx_def, parx_passval, parx_passval_head, parx_parclass_def, parx_parclass_init, parx_parclass_passval};
00222
00223
00228 struct ParxEquiv {
00229 ParxEquiv() : factor(1.0), offset(0.0) {}
00230
00234 STD_string name;
00235
00239 STD_string type;
00240
00244 double factor;
00245
00249 double offset;
00250
00251 };
00252
00254
00263 class JcampDxClass : public ListItem<JcampDxClass>, public virtual Labeled {
00264
00265 public:
00266
00267 virtual ~JcampDxClass();
00268
00273 virtual STD_string print() const;
00274
00278 virtual STD_ostream& print2stream(STD_ostream& os) const {return os << printvalstring();}
00279
00283 friend STD_ostream& operator << (STD_ostream& s,const JcampDxClass& value) { return value.print2stream(s);}
00284
00285
00293 virtual bool parse(STD_string& parstring);
00294
00304 virtual int load(const STD_string &filename);
00305
00313 virtual int write(const STD_string &filename) const;
00314
00315
00320 virtual bool parsevalstring (const STD_string&) = 0;
00321
00326 virtual STD_string printvalstring() const = 0;
00327
00328
00333 virtual JcampDxClass& set_compatmode(compatMode compat_mode) {compatmode=compat_mode; return *this;}
00334
00339 virtual compatMode get_compatmode() const {return compatmode;}
00340
00341
00345 virtual const char* get_typeInfo() const = 0;
00346
00347
00352 virtual double get_minval() const {return 0.0;}
00353
00354
00359 virtual double get_maxval() const {return 0.0;}
00360
00365 bool has_minmax() const {return get_maxval()>get_minval();}
00366
00367
00371 virtual JcampDxClass* create_copy() const = 0;
00372
00373
00374
00379 JcampDxClass& set_userDefParameter(bool userDef) {userDefParameter=userDef; return *this;}
00380
00381
00386 bool isUserDefParameter() const {return userDefParameter;}
00387
00388
00393 const STD_string& get_description() const {return description;}
00394
00399 JcampDxClass& set_description(const STD_string& descr) {description=descr; return *this;}
00400
00401
00405 virtual svector get_alternatives() const {return svector();}
00406
00407
00412 const STD_string& get_unit() const {return unit;}
00413
00418 JcampDxClass& set_unit(const STD_string& un) {unit=un; return *this;}
00419
00420
00425 virtual parameterMode get_parmode() const {return parmode;}
00426
00431 virtual JcampDxClass& set_parmode(parameterMode parameter_mode) {parmode=parameter_mode; return *this;}
00432
00437 virtual fileMode get_filemode() const {return filemode;}
00438
00443 virtual JcampDxClass& set_filemode(fileMode file_mode) {filemode=file_mode; return *this;}
00444
00445
00446
00451 virtual GuiProps get_gui_props() const {return GuiProps();}
00452
00457 virtual JcampDxClass& set_gui_props(const GuiProps&) {return *this;}
00458
00459
00460
00465 virtual STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv=ParxEquiv()) const;
00466
00473 virtual ParxEquiv get_parx_equiv() const {ParxEquiv pe; pe.type=get_typeInfo(); return pe;}
00474
00475
00476
00477
00478
00479 virtual JcampDxBlock* cast(JcampDxBlock*) {return 0;}
00480 virtual int* cast(int*) {return 0;}
00481 virtual long* cast(long*) {return 0;}
00482 virtual float* cast(float*) {return 0;}
00483 virtual double* cast(double*) {return 0;}
00484 virtual bool* cast(bool*) {return 0;}
00485 virtual STD_complex* cast(STD_complex*) {return 0;}
00486 virtual JDXenum* cast(JDXenum*) {return 0;}
00487 virtual STD_string* cast(STD_string*) {return 0;}
00488 virtual JDXfileName* cast(JDXfileName*) {return 0;}
00489 virtual JDXformula* cast(JDXformula*) {return 0;}
00490 virtual JDXaction* cast(JDXaction*) {return 0;}
00491 virtual iarray* cast(iarray*) {return 0;}
00492 virtual darray* cast(darray*) {return 0;}
00493 virtual farray* cast(farray*) {return 0;}
00494 virtual carray* cast(carray*) {return 0;}
00495 virtual sarray* cast(sarray*) {return 0;}
00496 virtual JDXtriple* cast(JDXtriple*) {return 0;}
00497 virtual JDXfunction* cast(JDXfunction*) {return 0;}
00498
00499
00500
00501 int set_parameter_id(int newid) {id=newid; return 0;}
00502 int get_parameter_id() const {return id;}
00503
00504 JcampDxClass& set_cmdline_option(const STD_string& opt) {cmdline_option=opt; return *this;}
00505 STD_string get_cmdline_option() const {return cmdline_option;}
00506
00507
00508 protected:
00509
00510 JcampDxClass();
00511 JcampDxClass(const JcampDxClass& jdc);
00512 JcampDxClass& operator = (const JcampDxClass& jdc);
00513
00514 STD_string get_parx_def_string(const STD_string type, unsigned int dim) const;
00515
00516 private:
00517 friend class JDXwidget;
00518 friend class JcampDxBlock;
00519
00520 virtual STD_string get_jdx_prefix() const;
00521 virtual STD_string get_jdx_postfix() const {return "\n";}
00522
00523 compatMode compatmode;
00524 bool userDefParameter;
00525 parameterMode parmode;
00526 fileMode filemode;
00527
00528 STD_string description;
00529 STD_string unit;
00530
00531 int id;
00532
00533 STD_string cmdline_option;
00534
00535 };
00536
00537
00538
00540
00541
00542
00543 class JDXeditWidget {
00544
00545 public:
00546
00547 virtual void updateWidget() = 0;
00548
00549 virtual ~JDXeditWidget() {}
00550 };
00551
00552
00553
00554 class JDXeditCaller {
00555
00556 public:
00557
00558 virtual void parameter_relations(JDXeditWidget* editwidget) = 0;
00559
00560 virtual ~JDXeditCaller() {}
00561 };
00562
00563
00564
00578 #endif