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 #include <stdexcept>
00040
00041 extern double DefaultPsi, DefaultTheta, DefaultPhi;
00042
00044 namespace gcu {
00045
00046 class GLDocument;
00047
00053 class GLView: public Printable
00054 {
00055 public:
00057
00062 GLView (GLDocument* pDoc) throw (std::runtime_error);
00064
00067 virtual ~GLView ();
00068
00072 GtkWidget *GetWidget () {return m_pWidget;}
00076 void Init ();
00080 void Reshape ();
00084 void Draw ();
00091 bool OnPressed (GdkEventButton *event);
00100 bool OnMotion (GdkEventMotion *event);
00105 void Update ();
00113 void SetRotation (double psi, double theta, double phi);
00124 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const;
00133 GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const;
00140 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context) const;
00144 GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));}
00152 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const;
00153
00154 private:
00161 void Rotate (gdouble x, gdouble y);
00162
00163 protected:
00167 GtkWidget *m_pWidget;
00168
00169 private:
00170 bool m_bInit;
00171 Matrix m_Euler;
00172 double m_Height, m_Width, m_Near, m_Far;
00173 double m_Lastx, m_Lasty;
00174 #ifdef HAVE_GO_CONF_SYNC
00175 static GOConfNode *m_ConfNode;
00176 #else
00177 static GConfClient *m_ConfClient;
00178 #endif
00179 static guint m_NotificationId;
00180 static int nbViews;
00181
00182
00192 GCU_PROP (double, Angle)
00202 GCU_PROP (double, Psi)
00212 GCU_PROP (double, Phi)
00222 GCU_PROP (double, Theta)
00232 GCU_PROP (float, Red)
00242 GCU_PROP (float, Green)
00252 GCU_PROP (float, Blue)
00269 GCU_PROP (float, Alpha)
00273 GCU_PROT_POINTER_PROP (GLDocument, Doc)
00280 GCU_PROT_PROP (double, Radius);
00281 };
00282
00283 }
00284
00285 #endif // GCU_GL_VIEW_H