View.h

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009, 2010 James Legg.
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 #ifndef VIEW_H_
00012 #define VIEW_H_
00013 
00014 #include <boost/shared_ptr.hpp>
00015 
00016 #include <gtkmm/uimanager.h>
00017 #include <gtkmm/menu.h>
00018 
00019 #include <gtkglmm.h>
00020 
00021 #include <libtrack/document/Document.h>
00022 #include <libtrack/edit_base/Selectable.h>
00023 #include <libtrack/edit_base/Dragable.h>
00024 
00027 class View : public Gtk::GL::DrawingArea
00028 {
00029 public:
00034     View();
00035     
00043     View(View & view);
00044     
00045     virtual ~View();
00046     
00048     enum ViewAngle {
00050         VIEW_TOP,
00051         
00053         VIEW_SIDE,
00054         
00056         VIEW_FRONT};
00057     
00066     void set_document(Document::Document & document);
00067     
00071     void set_angle(const ViewAngle angle);
00072     
00074     ViewAngle get_angle() const;
00075     
00079     void set_scale(const float scale);
00080     
00082     float get_scale() const;
00083     
00087     void set_centre(btVector3 centre);
00088     
00090     btVector3 get_centre() const;
00091     
00092     // Make realize public so that the View can have an OpenGL context created
00093     // for another View to share with.
00094     void realize()
00095     {
00096         Gtk::GL::DrawingArea::realize();
00097     }
00098     
00109     sigc::signal<void, boost::shared_ptr<Document::DocumentDelta> > signal_command();
00110     
00120     sigc::signal<void, boost::shared_ptr<Document::DocumentDelta> > signal_preview_command();
00121     
00131     sigc::signal<void> signal_preview_cancel();
00132 protected:
00133     // signal handlers:
00134     virtual void on_realize();
00135     virtual bool on_configure_event(GdkEventConfigure* event);
00136     virtual bool on_expose_event(GdkEventExpose* event);
00137     virtual bool on_scroll_event(GdkEventScroll* event);
00138     // Handle other mouse events
00139     virtual bool on_button_press_event (GdkEventButton* event);
00140     virtual bool on_button_release_event (GdkEventButton* event);
00141     virtual bool on_motion_notify_event (GdkEventMotion* event);
00142     // actions
00143     void on_delete_vertex();
00144     void on_delete_edge();
00145     void on_delete_attachment();
00146     void on_flip_edge();
00147     void on_insert_vertex();
00148     void on_set_start_edge();
00149     void on_add_booster();
00150     
00153     void setup_ui();
00154     
00158     void recentre_view();
00159     
00161     void draw_path(const Track::Path & path);
00162     
00164     Document::Document * document;
00165     
00167     float scale;
00168     
00170     btScalar handle_length;
00171     
00173     btVector3 centre;
00174     
00176     ViewAngle view_angle;
00177     
00179     bool needs_recentre;
00180     
00182     const Track::EditAssist::Selectable * get_selectable_under_mouse();
00183     
00185     btVector3 mouse_to_scene(btScalar x, btScalar y) const;
00186     
00190     btVector3 new_position;
00191     
00198     void set_relative_depth(btVector3 & position, btScalar depth);
00199     
00200     const Track::EditAssist::Dragable * drag_object;
00201     
00202     const Track::EditAssist::Selectable * popup_object;
00203     
00207     sigc::signal<void, boost::shared_ptr<Document::DocumentDelta> > m_signal_command;
00208     
00211     sigc::signal<void, boost::shared_ptr<Document::DocumentDelta> > m_signal_preview_command;
00212     
00215     sigc::signal<void> m_signal_preview_cancel;
00216     
00217     Glib::RefPtr<Gtk::ActionGroup> m_action_group; 
00218     Glib::RefPtr<Gtk::UIManager> m_ui_manager;
00219     Gtk::UIManager::ui_merge_id m_menu_id;
00221     Gtk::Menu * m_popup_menu;
00223     Gtk::Menu * m_empty_menu;
00225     Gtk::Menu * m_attachment_menu;
00226     
00227     void pick_segment(std::size_t index);
00228 };
00229 
00230 #endif /*VIEW_H_*/

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:13 2010 by Doxygen version 1.4.7 for Racer version svn335.