The Gnome Chemistry Utils  0.12.11
spectrumdoc.h
Go to the documentation of this file.
1 /*
2  * Gnome Chemisty Utils
3  * spectrumdoc.h
4  *
5  * Copyright (C) 2007-2009 Jean Bréfort <jean.brefort@normalesup.org>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22 
23 #ifndef GCU_SPECTRUM_DOC_H
24 #define GCU_SPECTRUM_DOC_H
25 
26 #include "document.h"
27 #include "macros.h"
28 #include "printable.h"
29 #include <string>
30 #include <vector>
31 
33 namespace gcu
34 {
35 
40 typedef enum {
90 } SpectrumType;
91 
92 
96 typedef enum {
143 
148 typedef enum {
167 
173 typedef enum {
200 
201 class Application;
202 class SpectrumView;
203 
207 typedef struct {
211  std::string Name;
215  char Symbol;
231  unsigned NbValues;
235  double First;
239  double Last;
243  double Min;
247  double Max;
252  double Factor;
256  double *Values;
261  GogSeries *Series;
262 } JdxVar;
263 
268 class SpectrumDocument: public Document, public Printable
269 {
270 public:
274  SpectrumDocument ();
279  SpectrumDocument (Application *app, SpectrumView *view = NULL);
280 
285 
293  void Load (char const *uri, char const *mime_type = NULL);
294 
302  void OnXUnitChanged (int i);
303 
311  void OnYUnitChanged (int i);
312 
319  void OnXAxisInvert (bool inverted);
320 
324  void OnShowIntegral ();
325 
332  void OnTransformFID (GtkButton *btn);
333 
334 private:
335  void LoadJcampDx (char const *data);
336  void ReadDataLine (char const *data, std::list<double> &l);
337  void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
338  GtkWindow *GetGtkWindow ();
339  void ReadDataTable (std::istream &s, double *x, double *y);
340  double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double);
341 
342 private:
343  double *x, *y;
344  unsigned npoints;
345  double maxx, maxy, minx, miny;
346  double firstx, lastx, deltax, firsty;
347  double xfactor, yfactor;
348  std::vector <JdxVar> variables;
349  int X, Y, R, I, integral, Rt, It, Rp;
350  double freq;
351  double offset, refpoint;
352  GtkWidget *m_XAxisInvertBtn;
353  guint m_XAxisInvertSgn;
354 
365 GCU_RO_PROP (bool, Empty)
369 GCU_RO_PROP (SpectrumType, SpectrumType)
379 GCU_RO_PROP (SpectrumUnitType, YUnit)
384 GCU_RO_PROP (bool, IntegralVisible)
385 };
386 
387 }
388 
389 #endif // GCU_SPECTRUM_DOC_H