The Gnome Chemistry Utils 0.12.10
|
00001 /* 00002 * Gnome Chemisty Utils 00003 * spectrumdoc.h 00004 * 00005 * Copyright (C) 2007-2009 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 <string> 00030 #include <vector> 00031 00033 namespace gcu 00034 { 00035 00040 typedef enum { 00044 GCU_SPECTRUM_INFRARED, 00048 GCU_SPECTRUM_RAMAN, 00052 GCU_SPECTRUM_INFRARED_PEAK_TABLE, 00056 GCU_SPECTRUM_INFRARED_INTERFEROGRAM, 00060 GCU_SPECTRUM_INFRARED_TRANSFORMED, 00064 GCU_SPECTRUM_UV_VISIBLE, 00068 GCU_SPECTRUM_NMR, 00072 GCU_SPECTRUM_NMR_FID, 00076 GCU_SPECTRUM_NMR_PEAK_TABLE, 00080 GCU_SPECTRUM_NMR_PEAK_ASSIGNMENTS, 00084 GCU_SPECTRUM_MASS, 00089 GCU_SPECTRUM_MAX 00090 } SpectrumType; 00091 00092 00096 typedef enum { 00100 GCU_SPECTRUM_UNIT_CM_1, 00104 GCU_SPECTRUM_UNIT_TRANSMITTANCE, 00108 GCU_SPECTRUM_UNIT_ABSORBANCE, 00112 GCU_SPECTRUM_UNIT_PPM, 00116 GCU_SPECTRUM_UNIT_NANOMETERS, 00120 GCU_SPECTRUM_UNIT_MICROMETERS, 00124 GCU_SPECTRUM_UNIT_SECONDS, 00128 GCU_SPECTRUM_UNIT_HZ, 00132 GCU_SPECTRUM_UNIT_M_Z, 00136 GCU_SPECTRUM_UNIT_REL_ABUNDANCE, 00141 GCU_SPECTRUM_UNIT_MAX 00142 } SpectrumUnitType; 00143 00148 typedef enum { 00152 GCU_SPECTRUM_TYPE_INDEPENDENT, 00156 GCU_SPECTRUM_TYPE_DEPENDENT, 00160 GCU_SPECTRUM_TYPE_PAGE, 00165 GCU_SPECTRUM_TYPE_MAX 00166 } SpectrumVarType; 00167 00173 typedef enum { 00177 GCU_SPECTRUM_FORMAT_ASDF, 00181 GCU_SPECTRUM_FORMAT_AFFN, 00185 GCU_SPECTRUM_FORMAT_PAC, 00189 GCU_SPECTRUM_FORMAT_SQZ, 00193 GCU_SPECTRUM_FORMAT_DIF, 00198 GCU_SPECTRUM_FORMAT_MAX 00199 } SpectrumFormatType; 00200 00201 class Application; 00202 class SpectrumView; 00203 00207 typedef struct { 00211 std::string Name; 00215 char Symbol; 00219 SpectrumVarType Type; 00223 SpectrumUnitType Unit; 00227 SpectrumFormatType Format; 00231 unsigned NbValues; 00235 double First; 00239 double Last; 00243 double Min; 00247 double Max; 00252 double Factor; 00256 double *Values; 00261 GogSeries *Series; 00262 } JdxVar; 00263 00268 class SpectrumDocument: public Document, public Printable 00269 { 00270 public: 00274 SpectrumDocument (); 00279 SpectrumDocument (Application *app, SpectrumView *view = NULL); 00280 00284 ~SpectrumDocument (); 00285 00293 void Load (char const *uri, char const *mime_type = NULL); 00294 00302 void OnXUnitChanged (int i); 00303 00311 void OnYUnitChanged (int i); 00312 00319 void OnXAxisInvert (bool inverted); 00320 00324 void OnShowIntegral (); 00325 00332 void OnTransformFID (GtkButton *btn); 00333 00334 private: 00335 void LoadJcampDx (char const *data); 00336 void ReadDataLine (char const *data, std::list<double> &l); 00337 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const; 00338 GtkWindow *GetGtkWindow (); 00339 void ReadDataTable (std::istream &s, double *x, double *y); 00340 double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double); 00341 00342 private: 00343 double *x, *y; 00344 unsigned npoints; 00345 double maxx, maxy, minx, miny; 00346 double firstx, lastx, deltax, firsty; 00347 double xfactor, yfactor; 00348 std::vector <JdxVar> variables; 00349 int X, Y, R, I, integral, Rt, It, Rp; 00350 double freq; 00351 double offset, refpoint; 00352 GtkWidget *m_XAxisInvertBtn; 00353 guint m_XAxisInvertSgn; 00354 00361 GCU_PROT_PROP (SpectrumView*, View) 00365 GCU_RO_PROP (bool, Empty) 00369 GCU_RO_PROP (SpectrumType, SpectrumType) 00374 GCU_RO_PROP (SpectrumUnitType, XUnit) 00379 GCU_RO_PROP (SpectrumUnitType, YUnit) 00384 GCU_RO_PROP (bool, IntegralVisible) 00385 }; 00386 00387 } 00388 00389 #endif // GCU_SPECTRUM_DOC_H