* use the GtkBuilder for the ui
[hkl3d.git] / gui / ghkl3d / hkl3d-gui-scene.h
blob6a07992e40bc576b73d4eac7b4f07449add23653
1 /*
2 * This file is part of the hkl3d library.
3 * inspired from logo-model.c of the GtkGLExt logo models.
4 * written by Naofumi Yasufuku <naofumi@users.sourceforge.net>
6 * The hkl library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * The hkl library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
19 * Copyright (C) 2010 Synchrotron SOLEIL
20 * L'Orme des Merisiers Saint-Aubin
21 * BP 48 91192 GIF-sur-YVETTE CEDEX
23 * Authors: Oussama Sboui <oussama.sboui@synchrotron-soleil.fr>
24 * Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
27 #ifndef __HKL3D_GUI_SCENE_H__
28 #define __HKL3D_GUI_SCENE_H__
30 #include <gtkmm.h>
31 #include <gtkglmm.h>
33 #include "hkl3d-gui-view.h"
34 #include "hkl3d-gui-model.h"
36 //#include "GlutDemoApplication.h"
37 //#include "hkl3d.h"
39 namespace Logo
41 class Scene : public Gtk::GL::DrawingArea
43 // friend class View;
44 // friend class Model;
46 public:
47 static const unsigned int TIMEOUT_INTERVAL;
49 // OpenGL scene related constants:
50 static const float CLEAR_COLOR[4];
51 static const float CLEAR_DEPTH;
53 static const float LIGHT0_POSITION[4];
54 static const float LIGHT0_DIFFUSE[4];
55 static const float LIGHT0_SPECULAR[4];
57 public:
58 explicit Scene(unsigned int rot_count = Model::DEFAULT_ROT_COUNT,
59 bool enable_anim = true);
60 virtual ~Scene(void);
62 protected:
63 // signal handlers:
64 virtual void on_realize(void);
65 virtual bool on_configure_event(GdkEventConfigure* event);
66 virtual bool on_expose_event(GdkEventExpose* event);
67 virtual bool on_button_press_event(GdkEventButton* event);
68 virtual bool on_map_event(GdkEventAny* event);
69 virtual bool on_unmap_event(GdkEventAny* event);
70 virtual bool on_visibility_notify_event(GdkEventVisibility* event);
71 virtual bool on_timeout(void);
73 public:
74 // Invalidate whole window.
75 void invalidate(void)
77 this->get_window()->invalidate_rect(get_allocation(), false);
80 // Update window synchronously (fast).
81 void update(void)
83 this->get_window()->process_updates(false);
86 protected:
87 // timeout signal connection:
88 sigc::connection m_ConnectionTimeout;
90 void timeout_add(void);
91 void timeout_remove(void);
93 public:
94 // OpenGL scene related methods:
95 bool anim_is_enabled(void) const
97 return m_Model.anim_is_enabled();
100 void toggle_anim(void);
102 void init_anim(void);
104 protected:
105 Gtk::Menu* create_popup_menu(void);
107 // Popup menu:
108 Gtk::Menu* m_Menu;
110 // OpenGL scene related objects:
111 View m_View;
112 Model m_Model;
116 #endif //__HKL3D_GUI_SCENE_H__