glview.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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 #include <goffice/app/go-conf.h>
00033 #else
00034 #include <gconf/gconf-client.h>
00035 #endif
00036 #include <gtk/gtkwidget.h>
00037 #include <map>
00038 #include <string>
00039
00040 extern double DefaultPsi, DefaultTheta, DefaultPhi;
00041
00042 namespace gcu {
00043
00044 class GLDocument;
00045
00051 class GLView: public Printable
00052 {
00053 public:
00055
00060 GLView (GLDocument* pDoc);
00062
00065 virtual ~GLView ();
00066
00070 GtkWidget *GetWidget () {return m_pWidget;}
00074 void Init ();
00078 void Reshape ();
00082 void Draw ();
00089 bool OnPressed (GdkEventButton *event);
00098 bool OnMotion (GdkEventMotion *event);
00103 void Update ();
00111 void SetRotation (double psi, double theta, double phi);
00122 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const;
00131 GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const;
00132 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00133 GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));}
00134 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const;
00135
00136 private:
00143 void Rotate (gdouble x, gdouble y);
00144
00145 protected:
00149 GtkWidget *m_pWidget;
00150
00151 private:
00152 bool m_bInit;
00153 Matrix m_Euler;
00154 double m_Height, m_Width, m_Near, m_Far;
00155 double m_Lastx, m_Lasty;
00156 #ifdef HAVE_GO_CONF_SYNC
00157 static GOConfNode *m_ConfNode;
00158 #else
00159 static GConfClient *m_ConfClient;
00160 #endif
00161 static guint m_NotificationId;
00162 static int nbViews;
00163
00164
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_PROT_POINTER_PROP (GLDocument, Doc)
00262 GCU_PROT_PROP (double, Radius);
00263 };
00264
00265 }
00266
00267 #endif // GCU_GL_VIEW_H