The Gnome Chemistry Utils 0.13.4
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * gcu/glview.h 00006 * 00007 * Copyright (C) 2006-2011 Jean Bréfort <jean.brefort@normalesup.org> 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License as 00011 * published by the Free Software Foundation; either version 2 of the 00012 * License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00022 * USA 00023 */ 00024 00025 #ifndef GCU_GL_VIEW_H 00026 #define GCU_GL_VIEW_H 00027 00028 #include "macros.h" 00029 #include "matrix.h" 00030 #include <goffice/goffice.h> 00031 #include <map> 00032 #include <string> 00033 #include <stdexcept> 00034 00035 extern double DefaultPsi, DefaultTheta, DefaultPhi; 00036 00038 namespace gcu { 00039 00040 class GLDocument; 00041 00047 class GLView 00048 { 00049 public: 00051 00056 GLView (GLDocument* pDoc) throw (std::runtime_error); 00058 00061 virtual ~GLView (); 00066 virtual void Update (); 00074 void SetRotation (double psi, double theta, double phi); 00086 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height, bool use_bg) const; 00096 virtual GdkPixbuf *BuildPixbuf (unsigned width, unsigned height, bool use_bg) const; 00105 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height, bool use_bg) const; 00106 00107 protected: 00114 void Rotate (gdouble x, gdouble y); 00115 virtual bool GLBegin () = 0; 00116 virtual void GLEnd () = 0; 00117 00118 protected: 00119 Matrix m_Euler; 00120 double m_Lastx, m_Lasty; 00121 int m_WindowHeight, m_WindowWidth; 00122 double m_Height, m_Width, m_Near, m_Far; 00123 00124 // Properties 00134 GCU_PROP (double, Angle) 00144 GCU_PROP (double, Psi) 00154 GCU_PROP (double, Phi) 00164 GCU_PROP (double, Theta) 00174 GCU_PROP (float, Red) 00184 GCU_PROP (float, Green) 00194 GCU_PROP (float, Blue) 00211 GCU_PROP (float, Alpha) 00215 GCU_PROT_POINTER_PROP (GLDocument, Doc) 00222 GCU_PROT_PROP (double, Radius); 00223 }; 00224 00225 } // namespace gcu 00226 00227 #endif // GCU_GL_VIEW_H