The Gnome Chemistry Utils  0.13.91
spectrumdoc.h
Go to the documentation of this file.
1 /*
2  * Gnome Chemisty Utils
3  * spectrumdoc.h
4  *
5  * Copyright (C) 2007-2012 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 3 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 <gcu/document.h>
27 #include <gcu/macros.h>
28 #include "printable.h"
29 #include <string>
30 #include <vector>
31 
33 namespace gcugtk
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 
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);
340  bool SetProperty (unsigned property, char const *value);
344  bool Loaded () throw (gcu::LoaderError);
345 
346 private:
347  void LoadJcampDx (char const *data);
348  void ReadDataLine (char const *data, std::list<double> &l);
349  void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
350  GtkWindow *GetGtkWindow ();
351  void ReadDataTable (std::istream &s, double *x, double *y);
352  double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double);
353 
354 private:
355  double *x, *y;
356  unsigned npoints;
357  double maxx, maxy, minx, miny;
358  double firstx, lastx, deltax, firsty;
359  double xfactor, yfactor;
360  std::vector <JdxVar> variables;
361  int X, Xt, Y, R, I, integral, Rt, It, Rp;
362  double freq;
363  double offset, refpoint;
364  GtkWidget *m_XAxisInvertBtn;
365  guint m_XAxisInvertSgn;
366 
377 GCU_RO_PROP (bool, Empty)
381 GCU_RO_PROP (SpectrumType, SpectrumType)
391 GCU_RO_PROP (SpectrumUnitType, YUnit)
396 GCU_RO_PROP (bool, IntegralVisible)
397 };
398 
399 }
400 
401 #endif // GCU_SPECTRUM_DOC_H