-rw-r--r-- | src/model/exp004base.sqc | 11 | ||||
-rw-r--r-- | src/model/exp004state.h | 35 | ||||
-rw-r--r-- | src/view/exp004init.c | 5 | ||||
-rw-r--r-- | src/view/exp004view.c | 4 |
4 files changed, 18 insertions, 37 deletions
diff --git a/src/model/exp004base.sqc b/src/model/exp004base.sqc index cbf2291..2742138 100644 --- a/src/model/exp004base.sqc +++ b/src/model/exp004base.sqc | |||
@@ -4,11 +4,12 @@ | |||
4 | 4 | ||
5 | #include "exp004base.h" | 5 | #include "exp004base.h" |
6 | #include "../view/exp004state0.h" | 6 | #include "../view/exp004state0.h" |
7 | #include "../util/check_error.h" | ||
7 | #include <GL/glut.h> | 8 | #include <GL/glut.h> |
8 | #include <stdio.h> | 9 | #include <stdio.h> |
9 | #include <string.h> | 10 | #include <string.h> |
10 | 11 | #include "sqlca.h" | |
11 | EXEC SQL INCLUDE sqlca; | 12 | extern struct sqlca sqlca; |
12 | 13 | ||
13 | /* | 14 | /* |
14 | * A simple alias to make the code more readable. | 15 | * A simple alias to make the code more readable. |
@@ -18,8 +19,6 @@ EXEC SQL INCLUDE sqlca; | |||
18 | void | 19 | void |
19 | exp004base (void) | 20 | exp004base (void) |
20 | { | 21 | { |
21 | EXEC SQL CONNECT TO exp004; | ||
22 | |||
23 | /* | 22 | /* |
24 | * This implementation can be improved by mapping the video memory | 23 | * This implementation can be improved by mapping the video memory |
25 | * directly rather than loading into system memory and then copying | 24 | * directly rather than loading into system memory and then copying |
@@ -49,7 +48,7 @@ exp004base (void) | |||
49 | EXEC SQL FETCH c2 INTO :coordinates; | 48 | EXEC SQL FETCH c2 INTO :coordinates; |
50 | while (sqlca.sqlcode != 100) | 49 | while (sqlca.sqlcode != 100) |
51 | { | 50 | { |
52 | int i = coordinates.coord_id; | 51 | int i = coordinates.coord_id - 1; |
53 | 52 | ||
54 | strncpy(S.gi_data[i], | 53 | strncpy(S.gi_data[i], |
55 | coordinates.gi.data, | 54 | coordinates.gi.data, |
@@ -70,7 +69,7 @@ exp004base (void) | |||
70 | /* | 69 | /* |
71 | * Deselected by default. | 70 | * Deselected by default. |
72 | */ | 71 | */ |
73 | S.selection[i] = false; | 72 | S.selection.set[i] = false; |
74 | 73 | ||
75 | S.base_colors_data[i][0] = DEFAULT_COLOR_R; | 74 | S.base_colors_data[i][0] = DEFAULT_COLOR_R; |
76 | S.base_colors_data[i][1] = DEFAULT_COLOR_G; | 75 | S.base_colors_data[i][1] = DEFAULT_COLOR_G; |
diff --git a/src/model/exp004state.h b/src/model/exp004state.h index e3106ec..11e9ebd 100644 --- a/src/model/exp004state.h +++ b/src/model/exp004state.h | |||
@@ -1,7 +1,8 @@ | |||
1 | #ifndef EXP004STATE_H | 1 | #ifndef EXP004STATE_H |
2 | #define EXP004STATE_H | 2 | #define EXP004STATE_H |
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include "selection_info.h" |
5 | #include "zoom_info.h" | ||
5 | 6 | ||
6 | /* | 7 | /* |
7 | * Buffer object identifiers. | 8 | * Buffer object identifiers. |
@@ -9,11 +10,6 @@ | |||
9 | #define BASE_VERTICES 0 | 10 | #define BASE_VERTICES 0 |
10 | #define BASE_COLORS 1 | 11 | #define BASE_COLORS 1 |
11 | 12 | ||
12 | /* | ||
13 | * Vertices in the graph. | ||
14 | */ | ||
15 | #define ROWS 83905 | ||
16 | |||
17 | #define DEFAULT_COLOR_R 0.5 | 13 | #define DEFAULT_COLOR_R 0.5 |
18 | #define DEFAULT_COLOR_G 0.5 | 14 | #define DEFAULT_COLOR_G 0.5 |
19 | #define DEFAULT_COLOR_B 0.5 | 15 | #define DEFAULT_COLOR_B 0.5 |
@@ -88,31 +84,10 @@ typedef struct | |||
88 | */ | 84 | */ |
89 | float base_colors_data[ROWS][4]; | 85 | float base_colors_data[ROWS][4]; |
90 | 86 | ||
91 | /* | 87 | SELECTION_INFO selection; |
92 | * Selection list. | ||
93 | */ | ||
94 | bool selection[ROWS]; | ||
95 | |||
96 | /* | ||
97 | * Indicate if the user is currently defining a selection. | ||
98 | */ | ||
99 | bool selecting; | ||
100 | |||
101 | /* | ||
102 | * X coordinate of mouse when selection mode initiated. | ||
103 | */ | ||
104 | int select_x; | ||
105 | |||
106 | /* | ||
107 | * Y coordinate of mouse when selection mode initiated. | ||
108 | */ | ||
109 | int select_y; | ||
110 | |||
111 | /* | ||
112 | * Indicate if a selection should be used for a new set or a zoom region. | ||
113 | */ | ||
114 | bool zoom; | ||
115 | 88 | ||
89 | ZOOM_INFO zoom; | ||
90 | |||
116 | } EXP004STATE; | 91 | } EXP004STATE; |
117 | 92 | ||
118 | #endif // EXP004STATE_H | 93 | #endif // EXP004STATE_H |
diff --git a/src/view/exp004init.c b/src/view/exp004init.c index fa4b2b0..97bd779 100644 --- a/src/view/exp004init.c +++ b/src/view/exp004init.c | |||
@@ -1,12 +1,15 @@ | |||
1 | #include "exp004init.h" | 1 | #include "exp004init.h" |
2 | #include "exp004state0.h" | 2 | #include "exp004state0.h" |
3 | #include "../model/selection_info_init.h" | ||
4 | #include "../model/zoom_info_init.h" | ||
3 | 5 | ||
4 | #define S exp004state0 | 6 | #define S exp004state0 |
5 | 7 | ||
6 | void | 8 | void |
7 | exp004init (void) | 9 | exp004init (void) |
8 | { | 10 | { |
9 | S.zoom = false; | 11 | selection_info_init (&S.selection); |
12 | zoom_info_init (&S.zoom); | ||
10 | 13 | ||
11 | return; | 14 | return; |
12 | } | 15 | } |
diff --git a/src/view/exp004view.c b/src/view/exp004view.c index aa6e966..cc27a93 100644 --- a/src/view/exp004view.c +++ b/src/view/exp004view.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include "../controller/exp004mouse.h" | 2 | #include "../controller/exp004mouse.h" |
3 | #include "../controller/exp004reshape.h" | 3 | #include "../controller/exp004reshape.h" |
4 | #include "../controller/keyboard.h" | 4 | #include "../controller/keyboard.h" |
5 | #include "../db/dbconnect.h" | ||
5 | #include "../model/exp004base.h" | 6 | #include "../model/exp004base.h" |
6 | #include "exp004init.h" | 7 | #include "exp004init.h" |
7 | #include "exp004view.h" | 8 | #include "exp004view.h" |
@@ -10,6 +11,9 @@ | |||
10 | void | 11 | void |
11 | exp004view (void) | 12 | exp004view (void) |
12 | { | 13 | { |
14 | // Connect to the database. | ||
15 | dbconnect (); | ||
16 | |||
13 | // GLUT Initialization | 17 | // GLUT Initialization |
14 | glutInitWindowSize (500, 500); | 18 | glutInitWindowSize (500, 500); |
15 | glutInitWindowPosition (100, 100); | 19 | glutInitWindowPosition (100, 100); |