1 /*
2     This file is a part of the RepSnapper project.
3     Copyright (C) 2010 Michael Meeks
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU Lesser General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU Lesser General Public License for more details.
14 
15     You should have received a copy of the GNU Lesser General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #ifndef RENDER_H
20 #define RENDER_H
21 
22 #include "arcball.h"
23 #include <gtkglmm.h>
24 
25 class View;
26 class Model;
27 class gllight;
28 class Settings;
29 
30 class Render : public Gtk::GL::DrawingArea
31 {
32   ArcBall  *m_arcBall;
33   Matrix4fT m_transform;
34   Vector2f  m_downPoint;
35   Vector2f  m_dragStart;
36   View *m_view;
37   Model *get_model() const;
38   Glib::RefPtr<Gtk::TreeSelection> m_selection;
39 
40   // font rendering:
41   static GLuint fontlistbase;
42   static int fontheight;
43 
44   float m_zoom;
45   gllight *m_lights[4];
46 
47   void SetEnableLight(unsigned int lightNr, bool on);
48   void CenterView();
49   void selection_changed();
50   guint find_object_at(gdouble x, gdouble y);
51   Vector3d mouse_on_plane(double x, double y, double plane_z=0) const;
52 
53  public:
54   Render (View *view, Glib::RefPtr<Gtk::TreeSelection> selection);
55   ~Render();
56 
57   GtkWidget *get_widget();
58   void set_model (Model *model);
set_zoom(float zoom)59   void set_zoom (float zoom) {m_zoom=zoom;};
60   void zoom_to_model();
set_transform(const Matrix4fT & transform)61   void set_transform(const Matrix4fT &transform) {m_transform=transform;};
62 
63   static void draw_string(const Vector3d &pos, const string s);
64 
65   virtual void on_realize();
66   virtual bool on_configure_event(GdkEventConfigure* event);
67   virtual bool on_expose_event(GdkEventExpose* event);
68   virtual bool on_motion_notify_event(GdkEventMotion* event);
69   virtual bool on_button_press_event(GdkEventButton* event);
70   virtual bool on_button_release_event(GdkEventButton* event);
71   virtual bool on_scroll_event(GdkEventScroll* event);
72   virtual bool on_key_press_event(GdkEventKey* event);
73   virtual bool on_key_release_event(GdkEventKey* event);
74 };
75 
76 #endif // RENDER_H
77