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, float scalemax);
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_logscale(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
00175 bool overlay_logscale;
00176
00180 float overlay_rectsize;
00181 };
00182
00183
00185
00189 struct GuiProps {
00190 GuiProps() : fixedsize(true) {}
00191
00195 ArrayScale scale[n_ScaleTypes];
00196
00201 bool fixedsize;
00202
00206 PixmapProps pixmap;
00207 };
00208
00210
00211
00222 enum parxCodeType {parx_def, parx_passval, parx_passval_head, parx_parclass_def, parx_parclass_init, parx_parclass_passval};
00223
00224
00229 struct ParxEquiv {
00230 ParxEquiv() : factor(1.0), offset(0.0) {}
00231
00235 STD_string name;
00236
00240 STD_string type;
00241
00245 double factor;
00246
00250 double offset;
00251
00252 };
00253
00255
00264 class JcampDxClass : public ListItem<JcampDxClass>, public virtual Labeled {
00265
00266 public:
00267
00268 virtual ~JcampDxClass();
00269
00274 virtual STD_string print() const;
00275
00279 virtual STD_ostream& print2stream(STD_ostream& os) const {return os << printvalstring();}
00280
00284 friend STD_ostream& operator << (STD_ostream& s,const JcampDxClass& value) { return value.print2stream(s);}
00285
00286
00294 virtual bool parse(STD_string& parstring);
00295
00305 virtual int load(const STD_string &filename);
00306
00314 virtual int write(const STD_string &filename) const;
00315
00316
00321 virtual bool parsevalstring (const STD_string&) = 0;
00322
00327 virtual STD_string printvalstring() const = 0;
00328
00329
00334 virtual JcampDxClass& set_compatmode(compatMode compat_mode) {compatmode=compat_mode; return *this;}
00335
00340 virtual compatMode get_compatmode() const {return compatmode;}
00341
00342
00346 virtual const char* get_typeInfo() const = 0;
00347
00348
00353 virtual double get_minval() const {return 0.0;}
00354
00355
00360 virtual double get_maxval() const {return 0.0;}
00361
00366 bool has_minmax() const {return get_maxval()>get_minval();}
00367
00368
00372 virtual JcampDxClass* create_copy() const = 0;
00373
00374
00375
00380 JcampDxClass& set_userDefParameter(bool userDef) {userDefParameter=userDef; return *this;}
00381
00382
00387 bool isUserDefParameter() const {return userDefParameter;}
00388
00389
00394 const STD_string& get_description() const {return description;}
00395
00400 JcampDxClass& set_description(const STD_string& descr) {description=descr; return *this;}
00401
00402
00406 virtual svector get_alternatives() const {return svector();}
00407
00408
00413 const STD_string& get_unit() const {return unit;}
00414
00419 JcampDxClass& set_unit(const STD_string& un) {unit=un; return *this;}
00420
00421
00426 virtual parameterMode get_parmode() const {return parmode;}
00427
00432 virtual JcampDxClass& set_parmode(parameterMode parameter_mode) {parmode=parameter_mode; return *this;}
00433
00438 virtual fileMode get_filemode() const {return filemode;}
00439
00444 virtual JcampDxClass& set_filemode(fileMode file_mode) {filemode=file_mode; return *this;}
00445
00446
00447
00452 virtual GuiProps get_gui_props() const {return GuiProps();}
00453
00458 virtual JcampDxClass& set_gui_props(const GuiProps&) {return *this;}
00459
00460
00461
00466 virtual STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv=ParxEquiv()) const;
00467
00474 virtual ParxEquiv get_parx_equiv() const {ParxEquiv pe; pe.type=get_typeInfo(); return pe;}
00475
00476
00477
00478
00479
00480 virtual JcampDxBlock* cast(JcampDxBlock*) {return 0;}
00481 virtual int* cast(int*) {return 0;}
00482 virtual long* cast(long*) {return 0;}
00483 virtual float* cast(float*) {return 0;}
00484 virtual double* cast(double*) {return 0;}
00485 virtual bool* cast(bool*) {return 0;}
00486 virtual STD_complex* cast(STD_complex*) {return 0;}
00487 virtual JDXenum* cast(JDXenum*) {return 0;}
00488 virtual STD_string* cast(STD_string*) {return 0;}
00489 virtual JDXfileName* cast(JDXfileName*) {return 0;}
00490 virtual JDXformula* cast(JDXformula*) {return 0;}
00491 virtual JDXaction* cast(JDXaction*) {return 0;}
00492 virtual iarray* cast(iarray*) {return 0;}
00493 virtual darray* cast(darray*) {return 0;}
00494 virtual farray* cast(farray*) {return 0;}
00495 virtual carray* cast(carray*) {return 0;}
00496 virtual sarray* cast(sarray*) {return 0;}
00497 virtual JDXtriple* cast(JDXtriple*) {return 0;}
00498 virtual JDXfunction* cast(JDXfunction*) {return 0;}
00499
00500
00501
00502 int set_parameter_id(int newid) {id=newid; return 0;}
00503 int get_parameter_id() const {return id;}
00504
00505 JcampDxClass& set_cmdline_option(const STD_string& opt) {cmdline_option=opt; return *this;}
00506 STD_string get_cmdline_option() const {return cmdline_option;}
00507
00508
00509 protected:
00510
00511 JcampDxClass();
00512 JcampDxClass(const JcampDxClass& jdc);
00513 JcampDxClass& operator = (const JcampDxClass& jdc);
00514
00515 STD_string get_parx_def_string(const STD_string type, unsigned int dim) const;
00516
00517 private:
00518 friend class JDXwidget;
00519 friend class JcampDxBlock;
00520
00521 virtual STD_string get_jdx_prefix() const;
00522 virtual STD_string get_jdx_postfix() const {return "\n";}
00523
00524 compatMode compatmode;
00525 bool userDefParameter;
00526 parameterMode parmode;
00527 fileMode filemode;
00528
00529 STD_string description;
00530 STD_string unit;
00531
00532 int id;
00533
00534 STD_string cmdline_option;
00535
00536 };
00537
00538
00539
00541
00542
00543
00544 class JDXeditWidget {
00545
00546 public:
00547
00548 virtual void updateWidget() = 0;
00549
00550 virtual ~JDXeditWidget() {}
00551 };
00552
00553
00554
00555 class JDXeditCaller {
00556
00557 public:
00558
00559 virtual void parameter_relations(JDXeditWidget* editwidget) = 0;
00560
00561 virtual ~JDXeditCaller() {}
00562 };
00563
00564
00565
00579 #endif