The Gnome Chemistry Utils  0.14.0
glview.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcu/glview.h
6  *
7  * Copyright (C) 2006-2012 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_GL_VIEW_H
26 #define GCU_GL_VIEW_H
27 
28 #include "macros.h"
29 #include "matrix.h"
30 #include <goffice/goffice.h>
31 #include <map>
32 #include <string>
33 #include <stdexcept>
34 
35 extern double DefaultPsi, DefaultTheta, DefaultPhi;
36 
38 namespace gcu {
39 
40 class GLDocument;
41 
47 class GLView
48 {
49 public:
51 
56  GLView (GLDocument* pDoc) throw (std::runtime_error);
58 
61  virtual ~GLView ();
66  virtual void Update ();
74  void SetRotation (double psi, double theta, double phi);
86  void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height, bool use_bg) const;
96  virtual GdkPixbuf *BuildPixbuf (unsigned width, unsigned height, bool use_bg) const;
105  void RenderToCairo (cairo_t *cr, unsigned width, unsigned height, bool use_bg) const;
106 
107 protected:
114  void Rotate (gdouble x, gdouble y);
115 
121  virtual bool GLBegin () = 0;
122 
127  virtual void GLEnd () = 0;
128 
129 protected:
137  double m_Lastx;
141  double m_Lasty;
153  double m_Height;
157  double m_Width;
161  double m_Near;
165  double m_Far;
166 
167 // Properties
177 GCU_PROP (double, Angle)
187 GCU_PROP (double, Psi)
197 GCU_PROP (double, Phi)
207 GCU_PROP (double, Theta)
217 GCU_PROP (float, Red)
227 GCU_PROP (float, Green)
237 GCU_PROP (float, Blue)
254 GCU_PROP (float, Alpha)
265 GCU_PROT_PROP (double, Radius);
266 };
267 
268 } // namespace gcu
269 
270 #endif // GCU_GL_VIEW_H