File: Scene.h

package info (click to toggle)
glgrib 1.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,861,496 kB
  • sloc: cpp: 20,811; ansic: 6,530; perl: 2,902; sh: 513; makefile: 147; python: 58; sql: 18
file content (318 lines) | stat: -rw-r--r-- 7,230 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#pragma once

#include <vector>
#include <set>

#include "glGrib/Font.h"
#include "glGrib/Image.h"
#include "glGrib/String.h"
#include "glGrib/View.h"
#include "glGrib/Object.h"
#include "glGrib/Program.h"
#include "glGrib/LandScape.h"
#include "glGrib/Grid.h"
#include "glGrib/Ticks.h"
#include "glGrib/Field.h"
#include "glGrib/Coast.h"
#include "glGrib/Border.h"
#include "glGrib/Rivers.h"
#include "glGrib/Departements.h"
#include "glGrib/Colorbar.h"
#include "glGrib/Mapscale.h"
#include "glGrib/Cities.h"
#include "glGrib/GeoPoints.h"
#include "glGrib/Test.h"
#include "glGrib/Land.h"
#include "glGrib/Loader.h"
#include "glGrib/Clear.h"

#include <set>

namespace glGrib
{

class Scene
{
public:


  Scene () {}
  Scene & operator= (const Scene & other);
  virtual ~Scene ();
  void setup (const Options &);
  void render () const;
  void render (const Object3D *) const;
  void render (const Object2D *) const;
 
  void clear ();

  int getCurrentFieldRank () const
  {
    return d.currentFieldRank;
  }

  Field * getCurrentField () const
  { 
    return static_cast<size_t> (d.currentFieldRank) < fieldlist.size () ? fieldlist[d.currentFieldRank] : nullptr; 
  }

  void getLightPos (float * lon, float * lat) const
  {
    *lon = d.opts.scene.light.lon;
    *lat = d.opts.scene.light.lat;
  }

  void setLightPos (float lon, float lat) 
  { 
    d.opts.scene.light.lon = lon;
    d.opts.scene.light.lat = lat;
  }

  void setLight ()
  {
    d.opts.scene.light.on = true;
  }

  void unsetLight () { d.opts.scene.light.on = false; }
  bool hasLight () const { return d.opts.scene.light.on; }
  void update ();
  void updateColorbar ();
  void updateLight ();
  void updateInterpolation ();
  void updateView ();
  void updateDate ();
  void updateTitle ();
  void updateGeoPoints ();

  void setCurrentFieldRank (int r) { d.currentFieldRank = r; }

  const glGrib::Field * getFieldColorbar () const
  {
    const glGrib::Field * fld = getCurrentField ();
    if ((fld != nullptr) && (d.colorbar.isReady ()))
      if (fld->useColorBar ())
        return fld;
    return nullptr;
  }

  void setViewport (int, int);

  void setMessage (const std::string & mess) { if (d.strmess.isReady ()) d.strmess.update (mess); }
  void reSize ();
  const OptionDate * getDate ();

  template <typename T, typename O>
  void setObjectOptions (T & object, const O & o)
  {
    glGrib::clear (object);
    object.setup (o);
    object.reSize (d.view);
  }

  void hideAllFields ()
  {
    for (auto f : fieldlist)
      if (f != nullptr)
        f->hide ();
  }
  
  void showAllFields ()
  {
    for (auto f : fieldlist)
      if (f != nullptr)
        f->show ();
  }

  const View & getView () const
  {
    return d.view;
  }

  View & getView () 
  {
    return d.view;
  }

  void setViewOptions (const OptionsView &);
  void setLandscapeOptions (const OptionsLandscape &);
  void setLandscapeWireFrameOption (bool wireframe)
  {
    d.landscape.setWireFrameOption (wireframe);
  }
  void setLandscapeFlatOption (bool flat)
  {
    d.landscape.setFlatOption (flat);
  }
  void setLandscapePositionOptions (const glGrib::OptionsLandscapePosition &o)
  {
    d.landscape.setPositionOptions (o);
  }
  void setGridOptions (const OptionsGrid & o)
  {
    setObjectOptions (d.grid, o);
  }
  void setTicksOptions (const OptionsTicks & o)
  {
    setObjectOptions (d.ticks, o);
  }
  void setLandOptions (const OptionsLand & o)
  {
    setObjectOptions (d.land, o);
  }
  void setCoastOptions (const OptionsCoast & o)
  {
    setObjectOptions (d.coast, o);
  }
  void setBorderOptions (const OptionsBorder & o)
  {
    setObjectOptions (d.border, o);
  }
  void setRiversOptions (const OptionsRivers & o)
  {
    setObjectOptions (d.rivers, o);
  }
  void setDepartementsOptions (const OptionsDepartements & o)
  {
    setObjectOptions (d.departements, o);
  }
  void setMapScaleOptions (const OptionsMapscale & o)
  {
    setObjectOptions (d.mapscale, o);
  }
  void setImageOptions (const OptionsImage & o)
  {
    setObjectOptions (d.image, o);
  }
  void setCitiesOptions (const OptionsCities & o)
  {
    setObjectOptions (d.cities, o);
  }
  void setGeoPointsOptions (const OptionsGeoPoints & o)
  {
    setObjectOptions (d.geopoints, o);
  }

  void setFieldOptions (int, const OptionsField &, float = 0);
  void setFieldPaletteOptions (int, const OptionsPalette &);
  void setGridColorOptions (const OptionColor &);
  void setGridScaleOptions (float);
  void setColorBarOptions (const OptionsColorbar &);
  void setTextOptions (const OptionsText &);
  void setDateOptions (const OptionsDate &);
  void setLightOptions (const OptionsLight &);
  void setSceneOptions (const OptionsScene &);
  void setTitleOptions (const OptionsTitle &);

  const Options getOptions () const;

  const OptionsScene & getSceneOptions () const 
  { 
    return d.opts.scene; 
  }
  const OptionsView & getViewOptions () const
  {
    return d.view.getOptions ();
  }
  const OptionsLandscape & getLandscapeOptions () const
  {
    return d.landscape.getOptions ();
  }
  const OptionsGrid & getGridOptions () const
  {
    return d.grid.getOptions ();
  }
  const OptionsTicks & getTicksOptions () const
  {
    return d.ticks.getOptions ();
  }
  const OptionsLand & getLandOptions () const
  {
    return d.land.getOptions ();
  }
  const OptionsCoast & getCoastOptions () const
  {
    return d.coast.getOptions ();
  }
  const OptionsBorder & getBorderOptions () const
  {
    return d.border.getOptions ();
  }
  const OptionsRivers & getRiversOptions () const
  {
    return d.rivers.getOptions ();
  }
  const OptionsDepartements & getDepartementsOptions () const
  {
    return d.departements.getOptions ();
  }
  const OptionsMapscale & getMapScaleOptions () const
  {
    return d.mapscale.getOptions ();
  }
  const OptionsImage & getImageOptions () const
  {
    return d.image.getOptions ();
  }
  const OptionsCities & getCitiesOptions () const
  {
    return d.cities.getOptions ();
  }
  const OptionsGeoPoints & getGeoPointsOptions () const
  {
    return d.geopoints.getOptions ();
  }

  const OptionColor & getGridColorOptions () const;
  const OptionsColorbar & getColorBarOptions () const;
  const OptionsText & getTextOptions () const;
  const OptionsDate & getDateOptions () const;
  const OptionsLight & getLightOptions () const;
  const OptionsTitle & getTitleOptions () const;

  std::string getCurrentFieldName () const;

  void centerOnCurrentField ();

private:
  std::vector<Field*> fieldlist;

  class _data
  {
    public:
      Options opts;
      View view;
      Landscape landscape;
      Coast coast;
      Border border;
      Rivers rivers;
      Grid grid;
      Ticks ticks;
      Departements departements;
      Cities cities;
      GeoPoints geopoints;
      Test test;
      Land land;
    private:
      Image image;
      Colorbar colorbar;
      Mapscale mapscale;
      String2D<0,1> strmess;
      String2D<0,1> strdate;
      String2D<0,1> strtitle;
      std::vector<String2D<0,1>> str;
      int nupdate = 0;
      int currentFieldRank = 0;
      glm::mat4 MVP_R, MVP_L;
      friend class Scene;
  };
  std::string strdate = "";
  std::string strtitle = "";

  _data d;

  Loader ld;

};


}