File: Window.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 (210 lines) | stat: -rw-r--r-- 4,912 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
#pragma once

#include "glGrib/OpenGL.h"

#include "glGrib/Render.h"
#include "glGrib/Scene.h"
#include "glGrib/View.h"
#include "glGrib/Shell.h"
#include "glGrib/Options.h"

#include <string>

#ifdef GLGRIB_USE_GLFW
namespace glGrib
{

class Shell;

class Window : public Render
{
public:

  static void getScreenSize (int *, int *);

  Window ();
  explicit Window (const Options &);
  virtual void setHints ();
  virtual ~Window ();
  void renderFrame (glGrib::Shell *);
  void run (class Shell * = nullptr) override;
  void makeCurrent () override
  { 
    glfwMakeContextCurrent (window); 
  }

  void toggleCursorposDisplay ();
  void toggleFlat ()
  {
    const auto & opts = scene.getLandscapeOptions ();
    scene.setLandscapeFlatOption (! opts.flat.on);
  }
  void resetView ()
  {
    OptionsView o0;
    const OptionsView & o = scene.getViewOptions ();
    o0.projection     = o.projection;
    o0.transformation = o.transformation;
    scene.setViewOptions (o0);
  }
  void toggleRotate      () 
  { 
    OptionsScene o = scene.getSceneOptions ();
    o.rotate_earth.on = ! o.rotate_earth.on; 
    scene.setSceneOptions (o);
  }
  void toggleRotateLight () 
  { 
    OptionsScene o = scene.getSceneOptions ();
    o.light.rotate.on = ! o.light.rotate.on; 
    scene.setSceneOptions (o);
  }
  void widenFov          () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.fov += 1.; 
    scene.setViewOptions (o);
  }
  void shrinkFov          () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.fov -= 1.; 
    scene.setViewOptions (o);
  }
  void increaseRadius     () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.distance += 0.1; 
    scene.setViewOptions (o);
  }
  void decreaseRadius     () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.distance -= 0.1; 
    scene.setViewOptions (o);
  }
  void rollLeft           () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.roll = float (o.roll) + 1.; 
    scene.setViewOptions (o);
  }
  void rollRight          () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.roll = float (o.roll) - 1.; 
    scene.setViewOptions (o);
  }
  void rotateUp           () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.pitch = float (o.pitch) + 1.; 
    scene.setViewOptions (o);
  }
  void rotateDown         ()
  {
    OptionsView o = scene.getViewOptions ();
    o.pitch = float (o.pitch) - 1.; 
    scene.setViewOptions (o);
  }
  void rotateRight        ()
  {
    OptionsView o = scene.getViewOptions ();
    o.yaw = float (o.yaw) + 1.; 
    scene.setViewOptions (o);
  }
  void rotateLeft         ()
  {
    OptionsView o = scene.getViewOptions ();
    o.yaw = float (o.yaw) - 1.; 
    scene.setViewOptions (o);
  }
  void rotateNorth        () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.lat = float (o.lat) + 5.; 
    scene.setViewOptions (o);
  }
  void rotateSouth        () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.lat = float (o.lat) - 5.; 
    scene.setViewOptions (o);
  }
  void rotateWest         () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.lon = float (o.lon) - 5.; 
    scene.setViewOptions (o);
  }
  void rotateEast         () 
  { 
    OptionsView o = scene.getViewOptions ();
    o.lon = float (o.lon) + 5.; 
    scene.setViewOptions (o);
  }
  void toggleWireframe ();

  void scroll (double, double);
  void onclick (int, int, int);
  virtual void onkey (int, int, int, int, bool = false);
  void displayCursorPosition (double, double);
  int getLatLonFromCursor (float *, float *);
  void centerViewAtCursorPos ();
  void centerLightAtCursorPos ();
  void debugTriangleNumber ();

  void selectField (int);
  void scaleFieldUp ();
  void scaleFieldDown ();
  void toggleHideField ();
  void hideAllFields ();
  void showAllFields ();
  void toggleLight ();
  void rotateLightNorth ();
  void rotateLightSouth ();
  void rotateLightWest  ();
  void rotateLightEast  ();
  void duplicate          ();
  void create (const Options &);

  class Render * clone (bool = true) override;
  void shouldClose () override
  { 
    glfwSetWindowShouldClose (window, 1); 
  }
  
  void setOptions (const OptionsRender &) override;
  void nextProjection ();
  void toggleTransformType ();
  void saveCurrentPalette ();
  void resampleCurrentField ();
  void toggleShowVector ();
  void toggleShowNorm ();
  void toggleFullScreen ();
  void setFullScreen ();
  void showHelp ();

  void fixLandscape (float, float, float, float);

  void moveTo (int, int);
  void zoom (double, double);
  void zoomSchmidt (double, double);

private:
  bool cursorpos = false;

  GLFWwindow * window = nullptr;

  void showHelpItem (const char *, const char *, const char *, const char *);
  void createGFLWwindow (GLFWwindow * = nullptr);
  double t0;
  std::string title = "";
  struct
  {
    int x = 100, y = 100, w = 800, h = 800;
  } fullscreen;
};

}
#endif