The Gnome Chemistry Utils 0.12.10
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * gcu/glview.h 00006 * 00007 * Copyright (C) 2006-2009 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 "printable.h" 00031 #include <goffice/goffice.h> 00032 #include <gtk/gtkwidget.h> 00033 #include <map> 00034 #include <string> 00035 #include <stdexcept> 00036 00037 extern double DefaultPsi, DefaultTheta, DefaultPhi; 00038 00040 namespace gcu { 00041 00042 class GLDocument; 00043 00049 class GLView: public Printable 00050 { 00051 public: 00053 00058 GLView (GLDocument* pDoc) throw (std::runtime_error); 00060 00063 virtual ~GLView (); 00064 00068 GtkWidget *GetWidget () {return m_pWidget;} 00072 void Init (); 00076 void Reshape (int width, int height); 00080 void Draw (); 00087 bool OnPressed (GdkEventButton *event); 00096 bool OnMotion (GdkEventMotion *event); 00101 void Update (); 00109 void SetRotation (double psi, double theta, double phi); 00120 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const; 00129 GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const; 00137 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const; 00141 GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));} 00149 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const; 00150 00151 private: 00158 void Rotate (gdouble x, gdouble y); 00159 00160 protected: 00164 GtkWidget *m_pWidget; 00165 00166 private: 00167 bool m_bInit; 00168 Matrix m_Euler; 00169 int m_WindowHeight, m_WindowWidth; 00170 double m_Height, m_Width, m_Near, m_Far; 00171 double m_Lastx, m_Lasty; 00172 static int nbViews; 00173 00174 // Properties 00184 GCU_PROP (double, Angle) 00194 GCU_PROP (double, Psi) 00204 GCU_PROP (double, Phi) 00214 GCU_PROP (double, Theta) 00224 GCU_PROP (float, Red) 00234 GCU_PROP (float, Green) 00244 GCU_PROP (float, Blue) 00261 GCU_PROP (float, Alpha) 00265 GCU_PROT_POINTER_PROP (GLDocument, Doc) 00272 GCU_PROT_PROP (double, Radius); 00273 }; 00274 00275 } // namespace gcu 00276 00277 #endif // GCU_GL_VIEW_H