Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SceneControl.h

Go to the documentation of this file.
00001 //     $Id: SceneControl.h,v 1.1.1.1 2001/01/04 01:01:11 burnett Exp $
00002 // Project: Arve graphics
00003 //  Author: Toby Burnett
00004 //
00005 
00006 #ifndef  SCENECONTROL_H
00007 #define  SCENECONTROL_H
00008 
00009 #include <iostream>
00010 
00011 #include "gui/ViewPort.h"
00012 #include <vector>
00013 
00014 namespace gui {
00015 
00016 class Scene;
00017 class Draw2D;
00018 
00019 class SubMenu;
00020 
00021 
00022 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00023 class SceneControl 
00024 //  *Manage an Scene.    
00025 //  *Has a list of (now four) ViewPort objects, which know how to
00026 //    draw contents of DisplayRep's 
00027 //  *Provides interface to ViewPort projection options
00028 //  *Implements keystroke commands to modify views
00029 // Also manage a second Scene, with 2-d transform 
00030 {
00031 public:
00032 
00033     
00034     virtual ~SceneControl();
00035     
00036     GraphicsVector & reference_point(){return m_reference_point;}
00037     // get a modifiable reference to the current display refrence point
00038 
00039     void draw();
00040     // generate a display
00041 
00042     virtual void redisplay(){draw();}
00043     // subclass that knows about display device can implement to
00044     // trigger refresh
00045 
00046     void redisplay(Draw2D* temp);
00047     // if the ViewPorts are Projectors, redisplay using temporary canvas
00048     // (i.e., to postcript)
00049 
00050     void displaycurrent(int hl);
00051     // redisplay the current window
00052 
00053     void select_view_number(int number);
00054     // select view: number=1-4 for view number
00055 
00056     void set_origin(const GraphicsVector& neworig){m_origin = neworig;}
00057     // modify basic display
00058 
00059     void set_single(int value);
00060     // select view and display it only (0: means all)
00061 
00062     void reset_view();
00063     // reset reference point, current view parameters
00064 
00065     ViewPort& view();
00066     // return reference to current view
00067 
00068     Scene& scene()const;
00069     // reference to the scene object
00070 
00071     Scene& scene_2d()const;
00072 
00073     //-----------------------------
00074     // adjustments to current view
00075     //-----------------------------
00076 
00077     void move_by(float,float);
00078     void move_left(float x=0.1);
00079     void move_right(float x=0.1);
00080     void move_up(float x=0.1);
00081     void move_down(float x=0.1);
00082     // adjust reference point according to current view
00083 
00084     void zoom_in(float x = 0.25);
00085     void zoom_out(float x= 0.25);
00086     void set_zoom(float z = 1.);
00087     // adjust zoom factor
00088 
00089     void move_in(float=0.1);
00090     void move_out(float=0.1);
00091     void set_view_distance(float=0);
00092     // adjust perspective
00093 
00094     void set_detail(float d=0.);
00095     // set detail threshold
00096 
00097     void setViewPort (float xmin, float ymin, float xmax, float ymax);
00098     // pan and zoom to the given boundaries
00099 
00100     void rotate_x(float);
00101     void rotate_y(float);
00102     void rotate_z(float);
00103     void rotate_euler(const float*);
00104     void rotate_euler(float,float,float);
00105     // change orientation of current view
00106 
00107     int do_command(const char *);
00108     // display control, allowing interactive modification of view parameters
00109     //  return -1: unrecognized
00110     //          0: ok, no redisplay needed
00111     //          1: must redisplay current view
00112     //          2: must redraw entire screen
00113     // Subclass can implement a displayer by passing keystroke commands to
00114     // it in an enent loop
00115 
00116 
00117     virtual void print_commands(std::ostream& );
00118     // prints list of commands to the stream
00119 
00120     void set_menu(const SubMenu* m){m_menu = m;}
00121     const SubMenu* menu()const{return m_menu;}
00122 
00123 protected:
00124     SceneControl(ViewPort*, float size=100 , int initial_view=1);
00125     // constructor, for subclass that will fill in the ViewPort object
00126 
00127     void resize(int x, int y);  
00128     // process screen size change
00129 
00130     
00131 private:
00132 
00133     Scene*      m_scene;
00134     Scene*      m_2d_scene;
00135     // the scenes that we control, 3d multiple views, and 2d
00136 
00137     GraphicsVector m_origin;                // default reference point
00138     GraphicsVector m_reference_point;        // current reference point
00139 
00140     int     m_max_view;             // number of views
00141     int     m_single_view;          // Flag if single or multiple views
00142     int     m_selected_view;        // selected view number if multiple displayed
00143 
00144 
00145     std::vector<ViewPort*> m_views;         // list of active viewports
00146     ViewPort*         m_current_view;       //  current view
00147     ViewPort*       m_2d_view;          // special view for 2-d display
00148 
00149 
00150     float m_detail; // doCommand
00151     int   m_axis;
00152     bool        m_enabled;      // toggle for enabling display
00153 
00154     const SubMenu* m_menu;    // pointer to associated menu
00155 
00156 
00157 };
00158 //----------------------- inlines ---------------------------------
00159 inline ViewPort&
00160 SceneControl::view(){
00161     return *m_current_view;
00162 }
00163 inline Scene& SceneControl::scene()const{return *m_scene;}
00164 inline Scene& SceneControl::scene_2d()const{return *m_2d_scene;}
00165 
00166 } // namespace gui
00167 
00168 #endif
00169 

Generated at Wed Nov 21 12:20:55 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000