/* Copyright 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * SharpConstruct is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef EDITOR_HH #define EDITOR_HH #include "ArcBall.h" #include "Color.h" #include "Cursor.hh" #include "Math.hh" #include "Optimized.h" #include "Output3D.hh" #include #include namespace SharpConstruct { namespace GInterface { class Editor : public Gtk::GL::DrawingArea { public: class DisplayOptionsData { public: enum GraphicsModeType { VBO, VAR, IMMEDIATE }; DisplayOptionsData( Editor& ); ~DisplayOptionsData(); bool Wireframe() const; bool Smoothed() const; bool DoubleSided() const; bool Speed() const; const Output3D& Output() const; Output3D& Output(); GraphicsModeType GraphicsMode() const; const Color& BackgroundColor() const; void ToggleWireframe(); void ToggleSmoothed(); void ToggleDoubleSided(); void ToggleSpeed(); void SetGraphicsMode(); void SetGraphicsMode( const GraphicsModeType ); void SetBackgroundColor( const Color& ); private: Editor& view_; bool wireframe_; bool smoothed_; bool double_sided_; bool speed_; Output3D* glout_; GraphicsModeType graphics_mode_; Color background_color_; }; Editor(); void Refresh( const bool, const bool ); void ResetView(); const DisplayOptionsData& DisplayOptions() const; DisplayOptionsData& DisplayOptions(); protected: virtual bool on_button_press_event( GdkEventButton* ); virtual bool on_motion_notify_event( GdkEventMotion* ); virtual bool on_button_release_event( GdkEventButton* ); virtual bool on_scroll_event( GdkEventScroll* ); virtual void on_size_allocate( Gtk::Allocation& ); virtual void on_realize(); virtual bool on_configure_event( GdkEventConfigure* ); virtual bool on_expose_event( GdkEventExpose* ); void on_entire_section_changed_( const bool, const bool, const bool ); private: void draw_model_(); void load_data_(); void orientate_(); Optimized::Point3D project_( const Optimized::Point3D& in ) const; Math::Point2D< int > project_2d_( const Optimized::Point3D& in ) const; Optimized::Point3D unproject_( const Optimized::Point3D& in ) const; void project_points_(); void project_normals_(); Math::Rect2D< int > selection_boundary_() const; void set_viewport_(); void update_mouse_(); bool update_vert_norm_; bool update_color_; bool update_polygons_; DisplayOptionsData display_options_; bool redraw_complete_; bool rendered_; Math::Rect2D< int > dirty_; // Depth copy bool update_depth_storage_; std::vector< float > depth_storage_; // Camera ArcBall arc_ball_; Math::Point2D< float > location_; float zoom_; // Cached camera values double model_matrix_[ 16 ]; double projection_matrix_[ 16 ]; int viewport_[ 4 ]; Cursor cursor_; Gdk::Point mouse_loc_; Gdk::ModifierType mouse_state_; Math::Point2D< int > last_mouse_location_; bool recalc_all_projected_; std::map< std::string, Math::Point2D< int > > symm_locs_; }; } } #endif