00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GCU_SPECTRUM_DOC_H
00024 #define GCU_SPECTRUM_DOC_H
00025
00026 #include "document.h"
00027 #include "macros.h"
00028 #include "printable.h"
00029 #include <goffice/graph/gog-series.h>
00030 #include <string>
00031 #include <vector>
00032
00034 namespace gcu
00035 {
00036
00041 typedef enum {
00045 GCU_SPECTRUM_INFRARED,
00049 GCU_SPECTRUM_RAMAN,
00053 GCU_SPECTRUM_INFRARED_PEAK_TABLE,
00057 GCU_SPECTRUM_INFRARED_INTERFEROGRAM,
00061 GCU_SPECTRUM_INFRARED_TRANSFORMED,
00065 GCU_SPECTRUM_UV_VISIBLE,
00069 GCU_SPECTRUM_NMR,
00073 GCU_SPECTRUM_NMR_FID,
00077 GCU_SPECTRUM_NMR_PEAK_TABLE,
00081 GCU_SPECTRUM_NMR_PEAK_ASSIGNMENTS,
00085 GCU_SPECTRUM_MASS,
00090 GCU_SPECTRUM_MAX
00091 } SpectrumType;
00092
00093
00097 typedef enum {
00101 GCU_SPECTRUM_UNIT_CM_1,
00105 GCU_SPECTRUM_UNIT_TRANSMITTANCE,
00109 GCU_SPECTRUM_UNIT_ABSORBANCE,
00113 GCU_SPECTRUM_UNIT_PPM,
00117 GCU_SPECTRUM_UNIT_NANOMETERS,
00121 GCU_SPECTRUM_UNIT_MICROMETERS,
00125 GCU_SPECTRUM_UNIT_SECONDS,
00129 GCU_SPECTRUM_UNIT_HZ,
00133 GCU_SPECTRUM_UNIT_M_Z,
00137 GCU_SPECTRUM_UNIT_REL_ABUNDANCE,
00142 GCU_SPECTRUM_UNIT_MAX
00143 } SpectrumUnitType;
00144
00149 typedef enum {
00153 GCU_SPECTRUM_TYPE_INDEPENDENT,
00157 GCU_SPECTRUM_TYPE_DEPENDENT,
00161 GCU_SPECTRUM_TYPE_PAGE,
00166 GCU_SPECTRUM_TYPE_MAX
00167 } SpectrumVarType;
00168
00174 typedef enum {
00178 GCU_SPECTRUM_FORMAT_ASDF,
00182 GCU_SPECTRUM_FORMAT_AFFN,
00186 GCU_SPECTRUM_FORMAT_PAC,
00190 GCU_SPECTRUM_FORMAT_SQZ,
00194 GCU_SPECTRUM_FORMAT_DIF,
00199 GCU_SPECTRUM_FORMAT_MAX
00200 } SpectrumFormatType;
00201
00202 class Application;
00203 class SpectrumView;
00204
00208 typedef struct {
00212 std::string Name;
00216 char Symbol;
00220 SpectrumVarType Type;
00224 SpectrumUnitType Unit;
00228 SpectrumFormatType Format;
00232 unsigned NbValues;
00236 double First;
00240 double Last;
00244 double Min;
00248 double Max;
00253 double Factor;
00257 double *Values;
00262 GogSeries *Series;
00263 } JdxVar;
00264
00269 class SpectrumDocument: public Document, public Printable
00270 {
00271 public:
00275 SpectrumDocument ();
00280 SpectrumDocument (Application *app, SpectrumView *view = NULL);
00281
00285 ~SpectrumDocument ();
00286
00294 void Load (char const *uri, char const *mime_type = NULL);
00295
00303 void OnXUnitChanged (int i);
00304
00312 void OnYUnitChanged (int i);
00313
00320 void OnXAxisInvert (bool inverted);
00321
00325 void OnShowIntegral ();
00326
00333 void OnTransformFID (GtkButton *btn);
00334
00335 private:
00336 void LoadJcampDx (char const *data);
00337 void ReadDataLine (char const *data, std::list<double> &l);
00338 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00339 GtkWindow *GetGtkWindow ();
00340 void ReadDataTable (std::istream &s, double *x, double *y);
00341 double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double);
00342
00343 private:
00344 double *x, *y;
00345 unsigned npoints;
00346 double maxx, maxy, minx, miny;
00347 double firstx, lastx, deltax, firsty;
00348 double xfactor, yfactor;
00349 std::vector <JdxVar> variables;
00350 int X, Y, R, I, integral, Rt, It, Rp;
00351 double freq;
00352 double offset, refpoint;
00353 GtkWidget *m_XAxisInvertBtn;
00354 guint m_XAxisInvertSgn;
00355
00362 GCU_PROT_PROP (SpectrumView*, View)
00366 GCU_RO_PROP (bool, Empty)
00370 GCU_RO_PROP (SpectrumType, SpectrumType)
00375 GCU_RO_PROP (SpectrumUnitType, XUnit)
00380 GCU_RO_PROP (SpectrumUnitType, YUnit)
00385 GCU_RO_PROP (bool, IntegralVisible)
00386 };
00387
00388 }
00389
00390 #endif // GCU_SPECTRUM_DOC_H