glview.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * gcu/glview.h 
00006  *
00007  * Copyright (C) 2006 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 <gtk/gtkwidget.h>
00031 #include <libgnomeprint/gnome-print.h>
00032 #include <map>
00033 #include <string>
00034 
00035 extern double DefaultPsi, DefaultTheta, DefaultPhi;
00036 
00037 using namespace std;
00038 
00039 namespace gcu {
00040 
00041 class GLDocument;
00042 
00048 class GLView
00049 {
00050 public:
00052 
00057         GLView (GLDocument* pDoc);
00059 
00062         virtual ~GLView ();
00063 
00067         GtkWidget *GetWidget () {return m_pWidget;}
00071         void Init ();
00075         void Reshape ();
00079         void Draw ();
00086         bool OnPressed (GdkEventButton *event);
00095         bool OnMotion (GdkEventMotion *event);
00100         void Update ();
00108         void SetRotation (double psi, double theta, double phi);
00116         void Print (GnomePrintContext *pc, gdouble width, gdouble height);
00127         void SaveAsImage (string const &filename, char const *type, map<string, string>& options, unsigned width, unsigned height);
00128 
00129 private:
00136         void Rotate (gdouble x, gdouble y);
00146         GdkPixbuf *BuildPixbuf (unsigned width, unsigned height);
00147 
00148 protected:
00152         GtkWidget *m_pWidget;
00156         unsigned m_nGLList;
00157 
00158 private:
00159         bool m_bInit;
00160         Matrix m_Euler;
00161         double m_Height, m_Width, m_Near, m_Far;
00162         double m_Lastx, m_Lasty;
00163 
00164 // Properties
00174 GCU_PROP (double, Angle)
00184 GCU_PROP (double, Psi)
00194 GCU_PROP (double, Phi)
00204 GCU_PROP (double, Theta)
00214 GCU_PROP (float, Red)
00224 GCU_PROP (float, Green)
00234 GCU_PROP (float, Blue)
00251 GCU_PROP (float, Alpha)
00255 GCU_RO_PROP (GLDocument *, Doc)
00262 GCU_PROT_PROP (double, Radius);
00263 };
00264 
00265 }       // namespace gcu
00266 
00267 #endif  //      GCU_GL_VIEW_H

Generated on Sun Jan 27 05:20:50 2008 for The Gnome Chemistry Utils by  doxygen 1.5.4