The Gnome Chemistry Utils  0.14.0
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 {
147 
152 typedef enum {
171 
177 typedef enum {
204 
205 class Application;
206 class SpectrumView;
207 
211 typedef struct {
215  std::string Name;
219  char Symbol;
235  unsigned NbValues;
239  double First;
243  double Last;
247  double Min;
251  double Max;
256  double Factor;
260  double *Values;
265  GogSeries *Series;
266 } JdxVar;
267 
273 {
274 public:
278  SpectrumDocument ();
283  SpectrumDocument (Application *app, SpectrumView *view = NULL);
284 
289 
297  void Load (char const *uri, char const *mime_type = NULL);
298 
306  void OnXUnitChanged (int i);
307 
315  void OnYUnitChanged (int i);
316 
323  void OnXAxisInvert (bool inverted);
324 
328  void OnShowIntegral ();
329 
336  void OnTransformFID (GtkButton *btn);
344  bool SetProperty (unsigned property, char const *value);
348  bool Loaded () throw (gcu::LoaderError);
349 
350 private:
351  void LoadJcampDx (char const *data);
352  void ReadDataLine (char const *data, std::list<double> &l);
353  void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
354  GtkWindow *GetGtkWindow ();
355  void ReadDataTable (std::istream &s, double *x, double *y);
356  double (*GetConversionFunction (SpectrumUnitType oldu, SpectrumUnitType newu, double &factor, double &offset)) (double, double, double);
357 
358 private:
359  double *x, *y;
360  unsigned npoints;
361  double maxx, maxy, minx, miny;
362  double firstx, lastx, deltax, firsty;
363  double xfactor, yfactor;
364  std::vector <JdxVar> variables;
365  int X, Xt, Y, R, I, integral, Rt, It, Rp;
366  double freq;
367  double offset, refpoint;
368  GtkWidget *m_XAxisInvertBtn;
369  guint m_XAxisInvertSgn;
370 
381 GCU_RO_PROP (bool, Empty)
385 GCU_RO_PROP (SpectrumType, SpectrumType)
395 GCU_RO_PROP (SpectrumUnitType, YUnit)
400 GCU_RO_PROP (bool, IntegralVisible)
401 };
402 
403 }
404 
405 #endif // GCU_SPECTRUM_DOC_H