glview.h
Go to the documentation of this file.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
00043 namespace gcu {
00044
00045 class GLDocument;
00046
00052 class GLView: public Printable
00053 {
00054 public:
00056
00061 GLView (GLDocument* pDoc);
00063
00066 virtual ~GLView ();
00067
00071 GtkWidget *GetWidget () {return m_pWidget;}
00075 void Init ();
00079 void Reshape ();
00083 void Draw ();
00090 bool OnPressed (GdkEventButton *event);
00099 bool OnMotion (GdkEventMotion *event);
00104 void Update ();
00112 void SetRotation (double psi, double theta, double phi);
00123 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const;
00132 GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const;
00139 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00143 GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));}
00151 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const;
00152
00153 private:
00160 void Rotate (gdouble x, gdouble y);
00161
00162 protected:
00166 GtkWidget *m_pWidget;
00167
00168 private:
00169 bool m_bInit;
00170 Matrix m_Euler;
00171 double m_Height, m_Width, m_Near, m_Far;
00172 double m_Lastx, m_Lasty;
00173 #ifdef HAVE_GO_CONF_SYNC
00174 static GOConfNode *m_ConfNode;
00175 #else
00176 static GConfClient *m_ConfClient;
00177 #endif
00178 static guint m_NotificationId;
00179 static int nbViews;
00180
00181
00191 GCU_PROP (double, Angle)
00201 GCU_PROP (double, Psi)
00211 GCU_PROP (double, Phi)
00221 GCU_PROP (double, Theta)
00231 GCU_PROP (float, Red)
00241 GCU_PROP (float, Green)
00251 GCU_PROP (float, Blue)
00268 GCU_PROP (float, Alpha)
00272 GCU_PROT_POINTER_PROP (GLDocument, Doc)
00279 GCU_PROT_PROP (double, Radius);
00280 };
00281
00282 }
00283
00284 #endif // GCU_GL_VIEW_H