Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

View.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Eric Bohm
00003  *
00004  *This program is free software; you can redistribute it and/or modify
00005  *it under the terms of the GNU General Public License as published by
00006  *the Free Software Foundation version 2 of the License.
00007  * 
00008  *This program is distributed in the hope that it will be useful, but
00009  *WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  *General Public License for more details.
00012  * 
00013  *You should have received a copy of the GNU General Public License along
00014  *with this program; if not, write to the Free Software Foundation, Inc.,
00015  *675 Mass Ave, Cambridge, MA 02139, USA.
00016  *
00017  */
00018 #ifndef IS_VIEW_DEF_SIG
00019 #define IS_VIEW_DEF_SIG 1
00020 
00027 using namespace std;
00028 #include <GL/glut.h>
00029 //#include <stl_function.h>
00030 #include <functional>
00031 #include <map>
00032 
00033 #include "Timestep.h"
00034 #include "RGB.h"
00035 
00036 
00037 
00039 
00042 class View
00043 {
00044  private:
00045   unsigned int fillpoly;        
00046   unsigned int colormap;        
00047   bool showlabel;               
00048   bool showlength;              
00049   bool opaque;                  
00050   bool pointmode;               
00051   double xtri;                  
00052   double ytri;                  
00053   double ztri;                  
00054   double ztran;                 
00055   double xtran;                 
00056   double ytran;                 
00057   unsigned int currstep;        
00058   int filenum;                  
00059   int solo_chunk;               
00060   map <unsigned int, RGB> chunks;  
00061   vector <bool> uptodate_step;    
00062 
00065   map < unsigned int, Timestep > timesteps; 
00066   map < unsigned int, Timestep >::iterator now; 
00067   vector <Coordinate> points; 
00068   
00069  public:
00070   double scale;                 
00071   int ScreenWidth, ScreenHeight;        
00072   float aspect_ratio;           
00073 
00074   View()
00075     {
00076       fillpoly = GL_FILL;
00077       solo_chunk=-1;
00078       scale=1.0;
00079       colormap = 0;
00080       showlabel = false;
00081       showlength = false;
00082       opaque = true;
00083       pointmode = false;
00084       xtri = 1.0;
00085       ytri = 1.0;
00086       ztri = 1.0;
00087       scale = 1.0;
00088       currstep=0;
00089       uptodate_step.reserve(10);
00090       filenum = 0;
00091       now=timesteps.begin();
00092     }
00093   
00095   unsigned int get_currstep()
00096     {
00097       return currstep;
00098     }
00099 
00101   void next_step()
00102     {
00103       now++;
00104       display_step(now->first);
00105     }
00106 
00108   void set_solo_chunk(int chunk)
00109     {
00110       solo_chunk=chunk;
00111       note_update();
00112       display();
00113     }
00114 
00116   void prev_step()
00117     {
00118       now--;
00119       display_step(now->first);
00120     }
00121 
00123   void animate(int direction)
00124     {
00125       if(direction>0)
00126         {
00127           
00128           while(now!=timesteps.end())
00129             {
00130               display_step(now->first);
00131               now++;
00132             }
00133         }
00134       else
00135         {
00136           while(now!=timesteps.begin())
00137             {
00138               now--;
00139               display_step(now->first);
00140             }
00141           //      display_step(now->first);
00142         }
00143     }
00144 
00145   void action_view();
00146   void recenter();
00147 
00148   void display_step(unsigned int);
00149 
00151   void display_first()
00152     {
00153       now=timesteps.begin();
00154       display_step(now->first);
00155     }
00156 
00158   void display()
00159     {
00160       display_step(currstep);
00161     }
00162 
00164   void redisplay_step(unsigned int step)
00165     {
00166       if(glIsList(step))
00167         glCallList(step);
00168       else
00169         display_step(step);
00170     }
00171 
00172   bool loadfile(const char *filename);
00173 
00175   void note_update ()
00176     {
00177       uptodate_step.assign(uptodate_step.size(),false);
00178     }
00179 
00181   void toggle_fillpoly()
00182     {
00183       fillpoly = fillpoly == GL_FILL ? GL_LINE : GL_FILL;
00184       note_update();
00185     }
00186 
00188   void toggle_showlabel()
00189     {
00190       showlabel = showlabel ? false : true;
00191       note_update();
00192     }
00193 
00195   void toggle_showlength()
00196     {
00197       showlength = showlength ? false : true;
00198       note_update();
00199     }
00200 
00202   void toggle_opaque()
00203     {
00204       opaque = opaque ? false : true;
00205       note_update();
00206     }
00207 
00209   void toggle_pointmode()
00210     {
00211       pointmode = pointmode ? false : true;
00212       note_update();
00213     }
00214 
00216   void zoomin()
00217     {
00218       scale *= 1.1;
00219       note_update();
00220     }
00221 
00223   void zoomout()
00224     {
00225       scale *= 0.9;
00226       note_update();
00227     }
00228 
00230   void rotatecolormap()
00231     {
00232       colormap++;
00233       colormap = colormap % 3;
00234       note_update();
00235     }
00236 
00237   void rotate();
00238 
00239 
00241   void rotate_x(int direction)
00242     {
00243       xtri += direction;
00244       note_update();
00245     }
00247   void rotate_y(int direction)
00248     {
00249       ytri += direction;
00250       note_update();
00251     }
00253   void rotate_z(int direction)
00254     {
00255       ztri += direction;
00256       note_update();
00257     }
00259   void move_x(float direction)
00260     {
00261       xtran += direction;
00262       note_update();
00263     }
00265   void move_y(float direction)
00266     {
00267       ytran += direction;
00268       note_update();
00269     }
00271   void move_z(float direction)
00272     {
00273       ztran += direction;
00274       note_update();
00275     }
00276 
00277   void make_random_color_set();
00278   
00279 };
00280 #endif

Generated on Wed Oct 29 10:01:52 2003 for Tetraviewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002