spectrumdoc.h

00001 /* 
00002  * Gnome Chemisty Utils
00003  * spectrumdoc.h
00004  *
00005  * Copyright (C) 2007-2008 Jean Bréfort <jean.brefort@normalesup.org>
00006  *
00007  * This program is free software; you can redistribute it and/or 
00008  * modify it under the terms of the GNU General Public License as 
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00020  * USA
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 
00033 namespace gcu
00034 {
00035 
00036 typedef enum {
00037         GCU_SPECTRUM_INFRARED,
00038         GCU_SPECTRUM_RAMAN,
00039         GCU_SPECTRUM_INFRARED_PEAK_TABLE,
00040         GCU_SPECTRUM_INFRARED_INTERFEROGRAM,
00041         GCU_SPECTRUM_INFRARED_TRANSFORMED,
00042         GCU_SPECTRUM_UV_VISIBLE,
00043         GCU_SPECTRUM_NMR,
00044         GCU_SPECTRUM_NMR_FID,
00045         GCU_SPECTRUM_NMR_PEAK_TABLE,
00046         GCU_SPECTRUM_NMR_PEAK_ASSIGNMENTS,
00047         GCU_SPECTRUM_MASS,
00048         GCU_SPECTRUM_MAX
00049 } SpectrumType;
00050 
00051 typedef enum {
00052         GCU_SPECTRUM_UNIT_CM_1,
00053         GCU_SPECTRUM_UNIT_TRANSMITTANCE,
00054         GCU_SPECTRUM_UNIT_ABSORBANCE,
00055         GCU_SPECTRUM_UNIT_PPM,
00056         GCU_SPECTRUM_UNIT_NANOMETERS,
00057         GCU_SPECTRUM_UNIT_MICROMETERS,
00058         GCU_SPECTRUM_UNIT_SECONDS,
00059         GCU_SPECTRUM_UNIT_HZ,
00060         GCU_SPECTRUM_UNIT_M_Z,
00061         GCU_SPECTRUM_UNIT_REL_ABUNDANCE,
00062         GCU_SPECTRUM_UNIT_MAX
00063 } SpectrumUnitType;
00064 
00065 typedef enum {
00066         GCU_SPECTRUM_TYPE_INDEPENDENT,
00067         GCU_SPECTRUM_TYPE_DEPENDENT,
00068         GCU_SPECTRUM_TYPE_PAGE,
00069         GCU_SPECTRUM_TYPE_MAX
00070 } SpectrumVarType;
00071 
00072 typedef enum {
00073         GCU_SPECTRUM_FORMAT_ASDF,
00074         GCU_SPECTRUM_FORMAT_AFFN,
00075         GCU_SPECTRUM_FORMAT_PAC,
00076         GCU_SPECTRUM_FORMAT_SQZ,
00077         GCU_SPECTRUM_FORMAT_DIF,
00078         GCU_SPECTRUM_FORMAT_MAX
00079 } SpectrumFormatType;
00080 
00081 class Application;
00082 class SpectrumView;
00083 
00084 typedef struct  {
00085         std::string Name;
00086         char Symbol;
00087         SpectrumVarType Type;
00088         SpectrumUnitType Unit;
00089         SpectrumFormatType Format;
00090         unsigned NbValues;
00091         double First, Last, Min, Max, Factor;
00092         double *Values;
00093         GogSeries *Series;
00094 } JdxVar;
00095 
00096 class SpectrumDocument: public Document, public Printable
00097 {
00098 public:
00102         SpectrumDocument ();
00107         SpectrumDocument (Application *app, SpectrumView *view = NULL);
00108 
00112         ~SpectrumDocument ();
00113 
00121         void Load (char const *uri, char const *mime_type = NULL);
00122 
00125         void OnUnitChanged (int i);
00126 
00129         void OnShowIntegral ();
00130 
00133         void OnTransformFID (GtkButton *btn);
00134 
00135 private:
00136         void LoadJcampDx (char const *data);
00137         void ReadDataLine (char const *data, std::list<double> &l);
00138         void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00139         GtkWindow *GetGtkWindow ();
00140         void ReadDataTable (std::istream &s, double *x, double *y);
00141         double GetConversionFactor (SpectrumUnitType oldu, SpectrumUnitType newu);
00142 
00143 private:
00144         double *x, *y;
00145         unsigned npoints;
00146         double maxx, maxy, minx, miny;
00147         double firstx, lastx, deltax, firsty;
00148         double xfactor, yfactor;
00149         std::vector <JdxVar> variables;
00150         int X, Y, R, I, integral, Rt, It, Rp;
00151         double freq;
00152 
00153 GCU_PROT_PROP (SpectrumView*, View)
00154 GCU_RO_PROP (bool, Empty)
00155 GCU_RO_PROP (SpectrumType, SpectrumType)
00156 GCU_RO_PROP (SpectrumUnitType, XUnit)
00157 GCU_RO_PROP (SpectrumUnitType, YUnit)
00158 GCU_RO_PROP (bool, IntegralVisible)
00159 };
00160 
00161 }
00162 
00163 #endif  //      GCU_SPECTRUM_DOC_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6