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 #include <goffice/goffice.h>
00032 #include <gtk/gtkwidget.h>
00033 #include <map>
00034 #include <string>
00035 #include <stdexcept>
00036
00037 extern double DefaultPsi, DefaultTheta, DefaultPhi;
00038
00040 namespace gcu {
00041
00042 class GLDocument;
00043
00049 class GLView: public Printable
00050 {
00051 public:
00053
00058 GLView (GLDocument* pDoc) throw (std::runtime_error);
00060
00063 virtual ~GLView ();
00064
00068 GtkWidget *GetWidget () {return m_pWidget;}
00072 void Init ();
00076 void Reshape (int width, int height);
00080 void Draw ();
00087 bool OnPressed (GdkEventButton *event);
00096 bool OnMotion (GdkEventMotion *event);
00101 void Update ();
00109 void SetRotation (double psi, double theta, double phi);
00120 void SaveAsImage (std::string const &filename, char const *type, std::map<std::string, std::string>& options, unsigned width, unsigned height) const;
00129 GdkPixbuf *BuildPixbuf (unsigned width, unsigned height) const;
00137 void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
00141 GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_pWidget));}
00149 void RenderToCairo (cairo_t *cr, unsigned width, unsigned height) const;
00150
00151 private:
00158 void Rotate (gdouble x, gdouble y);
00159
00160 protected:
00164 GtkWidget *m_pWidget;
00165
00166 private:
00167 bool m_bInit;
00168 Matrix m_Euler;
00169 int m_WindowHeight, m_WindowWidth;
00170 double m_Height, m_Width, m_Near, m_Far;
00171 double m_Lastx, m_Lasty;
00172 static GOConfNode *m_ConfNode;
00173 static guint m_NotificationId;
00174 static int nbViews;
00175
00176
00186 GCU_PROP (double, Angle)
00196 GCU_PROP (double, Psi)
00206 GCU_PROP (double, Phi)
00216 GCU_PROP (double, Theta)
00226 GCU_PROP (float, Red)
00236 GCU_PROP (float, Green)
00246 GCU_PROP (float, Blue)
00263 GCU_PROP (float, Alpha)
00267 GCU_PROT_POINTER_PROP (GLDocument, Doc)
00274 GCU_PROT_PROP (double, Radius);
00275 };
00276
00277 }
00278
00279 #endif // GCU_GL_VIEW_H