spectrumdoc.h

Go to the documentation of this file.
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 #ifdef GOFFICE_HAS_GLOBAL_HEADER
00030 #   include <goffice/goffice.h>
00031 #else
00032 #   include <goffice/graph/gog-series.h>
00033 #endif
00034 #include <string>
00035 #include <vector>
00036 
00038 namespace gcu
00039 {
00040 
00045 typedef enum {
00049         GCU_SPECTRUM_INFRARED,
00053         GCU_SPECTRUM_RAMAN,
00057         GCU_SPECTRUM_INFRARED_PEAK_TABLE,
00061         GCU_SPECTRUM_INFRARED_INTERFEROGRAM,
00065         GCU_SPECTRUM_INFRARED_TRANSFORMED,
00069         GCU_SPECTRUM_UV_VISIBLE,
00073         GCU_SPECTRUM_NMR,
00077         GCU_SPECTRUM_NMR_FID,
00081         GCU_SPECTRUM_NMR_PEAK_TABLE,
00085         GCU_SPECTRUM_NMR_PEAK_ASSIGNMENTS,
00089         GCU_SPECTRUM_MASS,
00094         GCU_SPECTRUM_MAX
00095 } SpectrumType;
00096 
00097 
00101 typedef enum {
00105         GCU_SPECTRUM_UNIT_CM_1,
00109         GCU_SPECTRUM_UNIT_TRANSMITTANCE,
00113         GCU_SPECTRUM_UNIT_ABSORBANCE,
00117         GCU_SPECTRUM_UNIT_PPM,
00121         GCU_SPECTRUM_UNIT_NANOMETERS,
00125         GCU_SPECTRUM_UNIT_MICROMETERS,
00129         GCU_SPECTRUM_UNIT_SECONDS,
00133         GCU_SPECTRUM_UNIT_HZ,
00137         GCU_SPECTRUM_UNIT_M_Z,
00141         GCU_SPECTRUM_UNIT_REL_ABUNDANCE,
00146         GCU_SPECTRUM_UNIT_MAX
00147 } SpectrumUnitType;
00148 
00153 typedef enum {
00157         GCU_SPECTRUM_TYPE_INDEPENDENT,
00161         GCU_SPECTRUM_TYPE_DEPENDENT,
00165         GCU_SPECTRUM_TYPE_PAGE,
00170         GCU_SPECTRUM_TYPE_MAX
00171 } SpectrumVarType;
00172 
00178 typedef enum {
00182         GCU_SPECTRUM_FORMAT_ASDF,
00186         GCU_SPECTRUM_FORMAT_AFFN,
00190         GCU_SPECTRUM_FORMAT_PAC,
00194         GCU_SPECTRUM_FORMAT_SQZ,
00198         GCU_SPECTRUM_FORMAT_DIF,
00203         GCU_SPECTRUM_FORMAT_MAX
00204 } SpectrumFormatType;
00205 
00206 class Application;
00207 class SpectrumView;
00208 
00212 typedef struct  {
00216         std::string Name;
00220         char Symbol;
00224         SpectrumVarType Type;
00228         SpectrumUnitType Unit;
00232         SpectrumFormatType Format;
00236         unsigned NbValues;
00240         double First;
00244         double Last;
00248         double Min;
00252         double Max;
00257         double Factor;
00261         double *Values;
00266         GogSeries *Series;
00267 } JdxVar;
00268 
00273 class SpectrumDocument: public Document, public Printable
00274 {
00275 public:
00279         SpectrumDocument ();
00284         SpectrumDocument (Application *app, SpectrumView *view = NULL);
00285 
00289         ~SpectrumDocument ();
00290 
00298         void Load (char const *uri, char const *mime_type = NULL);
00299 
00307         void OnXUnitChanged (int i);
00308 
00316         void OnYUnitChanged (int i);
00317 
00324         void OnXAxisInvert (bool inverted);
00325 
00329         void OnShowIntegral ();
00330 
00337         void OnTransformFID (GtkButton *btn);
00338 
00339 private:
00340         void LoadJcampDx (char const *data);
00341         void ReadDataLine (char const *data, std::list<double> &l);
00342         void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00343         GtkWindow *GetGtkWindow ();
00344         void ReadDataTable (std::istream &s, double *x, double *y);
00345         double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double);
00346 
00347 private:
00348         double *x, *y;
00349         unsigned npoints;
00350         double maxx, maxy, minx, miny;
00351         double firstx, lastx, deltax, firsty;
00352         double xfactor, yfactor;
00353         std::vector <JdxVar> variables;
00354         int X, Y, R, I, integral, Rt, It, Rp;
00355         double freq;
00356         double offset, refpoint;
00357         GtkWidget *m_XAxisInvertBtn;
00358         guint m_XAxisInvertSgn;
00359 
00366 GCU_PROT_PROP (SpectrumView*, View)
00370 GCU_RO_PROP (bool, Empty)
00374 GCU_RO_PROP (SpectrumType, SpectrumType)
00379 GCU_RO_PROP (SpectrumUnitType, XUnit)
00384 GCU_RO_PROP (SpectrumUnitType, YUnit)
00389 GCU_RO_PROP (bool, IntegralVisible)
00390 };
00391 
00392 }
00393 
00394 #endif  //      GCU_SPECTRUM_DOC_H

Generated on Wed Feb 3 12:55:25 2010 for The Gnome Chemistry Utils by  doxygen 1.6.1