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-2008 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 #ifdef HAVE_GO_CONF_SYNC
00032 #   ifdef GOFFICE_HAS_GLOBAL_HEADER
00033 #      include <goffice/goffice.h>
00034 #   else
00035 #      include <goffice/app/go-conf.h>
00036 #   endif
00037 #else
00038 #   include <gconf/gconf-client.h>
00039 #endif
00040 #include <gtk/gtkwidget.h>
00041 #include <map>
00042 #include <string>
00043 #include <stdexcept>
00044 
00045 extern double DefaultPsi, DefaultTheta, DefaultPhi;
00046 
00048 namespace gcu {
00049 
00050 class GLDocument;
00051 
00057 class GLView: public Printable
00058 {
00059 public:
00061 
00066         GLView (GLDocument* pDoc) throw (std::runtime_error);
00068 
00071         virtual ~GLView ();
00072 
00076         GtkWidget *GetWidget () {return m_pWidget;}
00080         void Init ();
00084         void Reshape ();
00088         void Draw ();
00095         bool OnPressed (GdkEventButton *event);
00104         bool OnMotion (GdkEventMotion *event);
00109         void Update ();
00117         void SetRotation (double psi, double theta, double phi);
00128         void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const;
00137         GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const;
00144         void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00148         GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));}
00156         void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const;
00157 
00158 private:
00165         void Rotate (gdouble x, gdouble y);
00166 
00167 protected:
00171         GtkWidget *m_pWidget;
00172 
00173 private:
00174         bool m_bInit;
00175         Matrix m_Euler;
00176         double m_Height, m_Width, m_Near, m_Far;
00177         double m_Lastx, m_Lasty;
00178 #ifdef HAVE_GO_CONF_SYNC
00179         static GOConfNode *m_ConfNode;
00180 #else
00181         static GConfClient *m_ConfClient;
00182 #endif
00183         static guint m_NotificationId;
00184         static int nbViews;
00185 
00186 // Properties
00196 GCU_PROP (double, Angle)
00206 GCU_PROP (double, Psi)
00216 GCU_PROP (double, Phi)
00226 GCU_PROP (double, Theta)
00236 GCU_PROP (float, Red)
00246 GCU_PROP (float, Green)
00256 GCU_PROP (float, Blue)
00273 GCU_PROP (float, Alpha)
00277 GCU_PROT_POINTER_PROP (GLDocument, Doc)
00284 GCU_PROT_PROP (double, Radius);
00285 };
00286 
00287 }       // namespace gcu
00288 
00289 #endif  //      GCU_GL_VIEW_H

Generated on Sat Nov 14 11:46:35 2009 for The Gnome Chemistry Utils by  doxygen 1.6.1