Changeset 5598


Ignore:
Timestamp:
Aug 4, 2008, 9:07:10 AM (11 years ago)
Author:
jack
Message:

Progress on height quantities.

Location:
anuga_work/development/anugavis/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/anugavis.cc

    r5488 r5598  
    1717#include <SDL.h>
    1818#include "anugavis.hh"
     19#include "height_quantity.hh"
    1920
    2021using std::string;
     
    2829AnugaVis::~AnugaVis(void){
    2930  if(this->screen != NULL) SDL_Quit();
     31}
     32
     33void AnugaVis::add_HeightQuantity(HeightQuantity &height){
     34  height.set_dynamic(this->sww_file.nc_inq_varndims_by_name(height.get_name()) \
     35                     == 2);
     36  this->heights.push_back(height);
     37}
     38
     39void AnugaVis::run(void){
     40
    3041}
    3142
  • anuga_work/development/anugavis/src/anugavis.hh

    r5488 r5598  
    44/* The main controller object. */
    55
     6#include <list>
    67#include <string>
    78#include <SDL.h>
     9#include "height_quantity.hh"
    810#include "sww_file.hh"
    911
     12using std::list;
    1013using std::string;
    1114
     
    1417  AnugaVis(const string &sww_file, int width, int height);
    1518  ~AnugaVis(void);
     19  void add_HeightQuantity(HeightQuantity &height);
     20  void run(void);
    1621private:
    1722  void init_SDL(int width, int height);
     
    1924  SDL_Surface *screen;
    2025  SWWFile sww_file;
     26  list<HeightQuantity> heights;
    2127};
    2228
  • anuga_work/development/anugavis/src/anugavis_simple_cxx.cc

    r5487 r5598  
    1919  try{
    2020    AnugaVis anuga(argv[1], 640, 480);
     21    HeightQuantity elevation("elevation", 0, 1, 0.5, 0.5, 0.5);
     22    HeightQuantity stage("stage", 0, 1, 0, 0, 0.8);
     23    anuga.add_HeightQuantity(elevation);
     24    anuga.add_HeightQuantity(stage);
     25    anuga.run();
    2126  }catch(const char *str){
    2227    output_string(string(str));
  • anuga_work/development/anugavis/src/height_quantity.cc

    r5502 r5598  
    1515#endif
    1616#include "height_quantity.hh"
    17 #include "sww_file.hh"
    1817
    1918using std::string;
    2019
    21 HeightQuantity::HeightQuantity(const SWWFile &sww, const string &name,
     20HeightQuantity::HeightQuantity(const string &name,
    2221                               GLdouble offset, GLdouble scale,
    2322                               GLfloat red, GLfloat green, GLfloat blue):
    2423  offset(offset), scale(scale), red(red), green(green), blue(blue), name(name),
    25   frame_number(-1), sww(sww){
     24  frame_number(-1){
    2625  GLenum glerror;
    27   this->dynamic = (sww.nc_inq_varndims_by_name(name) == 2);
    2826  this->display_list = glGenLists(1);
    2927  if((glerror = glGetError()) != GL_NO_ERROR) throw gluErrorString(glerror);
    30  
    3128}
    3229
     
    4845}
    4946
     47const string &HeightQuantity::get_name(void){
     48  return this->name;
     49}
     50
     51void HeightQuantity::set_dynamic(bool dynamic){
     52  this->dynamic = dynamic;
     53}
     54
    5055void HeightQuantity::compile(int frame){
    5156 
  • anuga_work/development/anugavis/src/height_quantity.hh

    r5502 r5598  
    1515#  include <OpenGL/gl.h>
    1616#endif
    17 #include "sww_file.hh"
    1817
    1918using std::string;
    2019
     20/* HeightQuantity instances cannot be shared amongst different
     21   AnugaVis instances. This shouldn't matter since AnugaVis'
     22   initialisation does SDL initialisation and that should only happen
     23   once.
     24*/
     25
    2126class HeightQuantity {
    2227public:
    23   HeightQuantity(const SWWFile &sww, const string &name,
     28  HeightQuantity(const string &name,
    2429                 const GLdouble offset, GLdouble scale,
    2530                 GLfloat red, GLfloat green, GLfloat blue);
    2631  ~HeightQuantity(void);
    2732  void draw(int frame);
     33  const string &get_name(void);
     34  void set_dynamic(bool dynamic);
    2835  GLdouble offset;
    2936  GLdouble scale;
     
    3845  bool dynamic;
    3946  GLuint display_list;
    40   const SWWFile &sww;
    4147};
    4248
  • anuga_work/development/anugavis/src/sww_file.cc

    r5502 r5598  
    3838}
    3939
    40 
    4140int SWWFile::nc_inq_varndims_by_name(const string &name) const{
    4241  int ncstatus;
    4342  int dimid;
    4443  int ndims;
    45   if(((ncstatus = nc_inq_dimid(this->netcdf_id,
     44  if(((ncstatus = nc_inq_varid(this->netcdf_id,
    4645                               name.c_str(), &dimid)) != NC_NOERR) ||
    4746     ((ncstatus = nc_inq_varndims(this->netcdf_id,
Note: See TracChangeset for help on using the changeset viewer.