glview.h

Go to the documentation of this file.
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 GOConfNode *m_ConfNode;
00173         static guint m_NotificationId;
00174         static int nbViews;
00175 
00176 // Properties
00186 GCU_PROP (double, Angle)
00196 GCU_PROP (double, Psi)
00206 GCU_PROP (double, Phi)
00216 GCU_PROP (double, Theta)
00226 GCU_PROP (float, Red)
00236 GCU_PROP (float, Green)
00246 GCU_PROP (float, Blue)
00263 GCU_PROP (float, Alpha)
00267 GCU_PROT_POINTER_PROP (GLDocument, Doc)
00274 GCU_PROT_PROP (double, Radius);
00275 };
00276 
00277 }       // namespace gcu
00278 
00279 #endif  //      GCU_GL_VIEW_H

Generated on Fri Sep 24 15:58:41 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9