author | Don Pellegrino <don@drexel.edu> | 2009-07-01 20:50:36 (GMT) |
---|---|---|
committer | Don Pellegrino <don@drexel.edu> | 2009-07-01 20:50:36 (GMT) |
commit | 106a2d9c8782be085eafe632b187366cee7f862c (patch) (unidiff) | |
tree | 5f26f26f10921bfa399c53b764368b791c5bad39 | |
parent | e4d02addde594ced73be73a127f006317c37c9e3 (diff) | |
download | exp005-106a2d9c8782be085eafe632b187366cee7f862c.zip exp005-106a2d9c8782be085eafe632b187366cee7f862c.tar.gz exp005-106a2d9c8782be085eafe632b187366cee7f862c.tar.bz2 |
Added subdirectory for running r and a script to connect to the DB2
backend and retrieve details of the current selection made with the
visualization. Added Make target for running GNU indent. Ran indent
on all of the code and headers.
-rw-r--r-- | Makefile.am | 10 | ||||
-rw-r--r-- | r/connect.R | 16 | ||||
-rw-r--r-- | src/controller/exp004mouse.c | 51 | ||||
-rw-r--r-- | src/controller/exp004processhits.c | 16 | ||||
-rw-r--r-- | src/controller/exp004reshape.c | 26 | ||||
-rw-r--r-- | src/controller/keyboard.c | 2 | ||||
-rw-r--r-- | src/controller/selection_from_db.sqc | 9 | ||||
-rw-r--r-- | src/controller/selsave.sqc | 4 | ||||
-rw-r--r-- | src/controller/set_ortho.c | 11 | ||||
-rw-r--r-- | src/controller/vis_sel_set.h | 3 | ||||
-rw-r--r-- | src/model/coordinates.h | 3 | ||||
-rw-r--r-- | src/model/exp004base.sqc | 30 | ||||
-rw-r--r-- | src/model/exp004state.h | 30 | ||||
-rw-r--r-- | src/model/selection_info.h | 11 | ||||
-rw-r--r-- | src/model/selection_info_init.c | 2 | ||||
-rw-r--r-- | src/model/selection_info_init.h | 2 | ||||
-rw-r--r-- | src/model/selection_purposes.h | 22 | ||||
-rw-r--r-- | src/model/zoom_info.h | 5 | ||||
-rw-r--r-- | src/model/zoom_info_init.c | 2 | ||||
-rw-r--r-- | src/model/zoom_info_init.h | 2 | ||||
-rw-r--r-- | src/util/pick_convert.c | 7 | ||||
-rw-r--r-- | src/util/sqlinfoprint.c | 2 | ||||
-rw-r--r-- | src/util/sqlinfoprint.h | 7 | ||||
-rw-r--r-- | src/view/exp004geometry.c | 6 | ||||
-rw-r--r-- | src/view/exp004view.c | 7 |
25 files changed, 140 insertions, 146 deletions
diff --git a/Makefile.am b/Makefile.am index a6d8603..9ac859b 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -1,2 +1,12 @@ | |||
1 | ACLOCAL_AMFLAGS = -I ax | 1 | ACLOCAL_AMFLAGS = -I ax |
2 | SUBDIRS = src | 2 | SUBDIRS = src |
3 | |||
4 | indent : | ||
5 | indent \ | ||
6 | src/*.c \ | ||
7 | src/controller/*.c src/controller/*.sqc src/controller/*.h \ | ||
8 | src/db/*.c src/db/*.sqc src/db/*.h \ | ||
9 | src/model/*.c src/model/*.sqc src/model/*.h \ | ||
10 | src/util/*.c src/util/*.h \ | ||
11 | src/view/*.c src/view/*.h | ||
12 | |||
diff --git a/r/connect.R b/r/connect.R new file mode 100644 index 0000000..b42b8bb --- a/dev/null +++ b/r/connect.R | |||
@@ -0,0 +1,16 @@ | |||
1 | require (RJDBC); | ||
2 | |||
3 | drv <- JDBC ("com.ibm.db2.jcc.DB2Driver"); | ||
4 | conn <- dbConnect (drv, "jdbc:db2:exp004"); | ||
5 | |||
6 | dbListTables (conn); | ||
7 | |||
8 | dbGetQuery (conn, "SELECT COUNT(*) FROM vis_collect"); | ||
9 | |||
10 | d <- dbReadTable (conn, "vis_collect"); | ||
11 | |||
12 | hist (d$"N_CITES"); | ||
13 | |||
14 | dbDisconnect (conn); | ||
15 | dbUnloadDriver (drv); | ||
16 | |||
diff --git a/src/controller/exp004mouse.c b/src/controller/exp004mouse.c index fb753d6..9a556ae 100644 --- a/src/controller/exp004mouse.c +++ b/src/controller/exp004mouse.c | |||
@@ -37,13 +37,13 @@ exp004mouse (int button, int state, int x, int y) | |||
37 | GLdouble model[16]; | 37 | GLdouble model[16]; |
38 | glGetDoublev (GL_MODELVIEW_MATRIX, model); | 38 | glGetDoublev (GL_MODELVIEW_MATRIX, model); |
39 | GLdouble projection[16]; | 39 | GLdouble projection[16]; |
40 | glGetDoublev (GL_PROJECTION_MATRIX, projection); | 40 | glGetDoublev (GL_PROJECTION_MATRIX, projection); |
41 | GLint viewport[4]; | 41 | GLint viewport[4]; |
42 | glGetIntegerv (GL_VIEWPORT, viewport); | 42 | glGetIntegerv (GL_VIEWPORT, viewport); |
43 | 43 | ||
44 | check_error (__FILE__, __LINE__); | 44 | check_error (__FILE__, __LINE__); |
45 | 45 | ||
46 | GLdouble start_position[3]; | 46 | GLdouble start_position[3]; |
47 | gluUnProject (S.selection.x, | 47 | gluUnProject (S.selection.x, |
48 | viewport[3] - S.selection.y, | 48 | viewport[3] - S.selection.y, |
49 | 0, | 49 | 0, |
@@ -51,8 +51,7 @@ exp004mouse (int button, int state, int x, int y) | |||
51 | projection, | 51 | projection, |
52 | viewport, | 52 | viewport, |
53 | &start_position[0], | 53 | &start_position[0], |
54 | &start_position[1], | 54 | &start_position[1], &start_position[2]); |
55 | &start_position[2]); | ||
56 | 55 | ||
57 | check_error (__FILE__, __LINE__); | 56 | check_error (__FILE__, __LINE__); |
58 | 57 | ||
@@ -63,12 +62,10 @@ exp004mouse (int button, int state, int x, int y) | |||
63 | model, | 62 | model, |
64 | projection, | 63 | projection, |
65 | viewport, | 64 | viewport, |
66 | &end_position[0], | 65 | &end_position[0], &end_position[1], &end_position[2]); |
67 | &end_position[1], | 66 | |
68 | &end_position[2]); | 67 | check_error (__FILE__, __LINE__); |
69 | 68 | ||
70 | check_error (__FILE__, __LINE__); | ||
71 | |||
72 | S.zoom.active = true; | 69 | S.zoom.active = true; |
73 | S.zoom.coords[0] = fmin (start_position[0], end_position[0]); | 70 | S.zoom.coords[0] = fmin (start_position[0], end_position[0]); |
74 | S.zoom.coords[1] = fmax (start_position[0], end_position[0]); | 71 | S.zoom.coords[1] = fmax (start_position[0], end_position[0]); |
@@ -76,7 +73,7 @@ exp004mouse (int button, int state, int x, int y) | |||
76 | S.zoom.coords[3] = fmax (start_position[1], end_position[1]); | 73 | S.zoom.coords[3] = fmax (start_position[1], end_position[1]); |
77 | 74 | ||
78 | exp004reshape (S.viewport.w, S.viewport.h); | 75 | exp004reshape (S.viewport.w, S.viewport.h); |
79 | 76 | ||
80 | glutPostRedisplay (); | 77 | glutPostRedisplay (); |
81 | } | 78 | } |
82 | 79 | ||
@@ -85,27 +82,27 @@ exp004mouse (int button, int state, int x, int y) | |||
85 | */ | 82 | */ |
86 | if (S.selection.active && S.selection.purpose == SET) | 83 | if (S.selection.active && S.selection.purpose == SET) |
87 | { | 84 | { |
88 | 85 | ||
89 | /* | 86 | /* |
90 | * "Specify the array to be used for the returned hit records | 87 | * "Specify the array to be used for the returned hit records |
91 | * with glSelectBuffer () [Redbook]." | 88 | * with glSelectBuffer () [Redbook]." |
92 | */ | 89 | */ |
93 | GLuint select_buf[ROWS]; | 90 | GLuint select_buf[ROWS]; |
94 | glSelectBuffer (ROWS, select_buf); | 91 | glSelectBuffer (ROWS, select_buf); |
95 | 92 | ||
96 | /* | 93 | /* |
97 | * "Enter selection mode by specifying GL_SELECT with | 94 | * "Enter selection mode by specifying GL_SELECT with |
98 | * glRenderMode () [Redbook]." | 95 | * glRenderMode () [Redbook]." |
99 | */ | 96 | */ |
100 | glRenderMode (GL_SELECT); | 97 | glRenderMode (GL_SELECT); |
101 | 98 | ||
102 | /* | 99 | /* |
103 | * "Initialize the name stack using glInitNames () and glPush | 100 | * "Initialize the name stack using glInitNames () and glPush |
104 | * Names () [Redbook]." | 101 | * Names () [Redbook]." |
105 | */ | 102 | */ |
106 | glInitNames (); | 103 | glInitNames (); |
107 | glPushName (0); | 104 | glPushName (0); |
108 | 105 | ||
109 | /* | 106 | /* |
110 | * "Define the viewing volume you want to use for selection. | 107 | * "Define the viewing volume you want to use for selection. |
111 | * Usually this is different from the viewing volume you | 108 | * Usually this is different from the viewing volume you |
@@ -116,10 +113,10 @@ exp004mouse (int button, int state, int x, int y) | |||
116 | glMatrixMode (GL_PROJECTION); | 113 | glMatrixMode (GL_PROJECTION); |
117 | glPushMatrix (); | 114 | glPushMatrix (); |
118 | glLoadIdentity (); | 115 | glLoadIdentity (); |
119 | 116 | ||
120 | GLint viewport[4]; | 117 | GLint viewport[4]; |
121 | glGetIntegerv (GL_VIEWPORT, viewport); | 118 | glGetIntegerv (GL_VIEWPORT, viewport); |
122 | 119 | ||
123 | double c_x = 0.0; | 120 | double c_x = 0.0; |
124 | double c_y = 0.0; | 121 | double c_y = 0.0; |
125 | double w = 0.0; | 122 | double w = 0.0; |
@@ -127,37 +124,33 @@ exp004mouse (int button, int state, int x, int y) | |||
127 | pick_convert (S.selection.x, S.selection.y, x, y, | 124 | pick_convert (S.selection.x, S.selection.y, x, y, |
128 | &c_x, &c_y, &w, &h); | 125 | &c_x, &c_y, &w, &h); |
129 | 126 | ||
130 | gluPickMatrix (c_x, | 127 | gluPickMatrix (c_x, (GLdouble) viewport[3] - c_y, w, h, viewport); |
131 | (GLdouble)viewport[3] - c_y, | ||
132 | w, | ||
133 | h, | ||
134 | viewport); | ||
135 | 128 | ||
136 | set_ortho (); | 129 | set_ortho (); |
137 | 130 | ||
138 | /* | 131 | /* |
139 | * "Alternately issue primitive drawing commands and commands to | 132 | * "Alternately issue primitive drawing commands and commands to |
140 | * manipulate the name stack so that each primitive of interest | 133 | * manipulate the name stack so that each primitive of interest |
141 | * has appropriate names assigned [Redbook]." | 134 | * has appropriate names assigned [Redbook]." |
142 | */ | 135 | */ |
143 | exp004geometry (GL_SELECT); | 136 | exp004geometry (GL_SELECT); |
144 | 137 | ||
145 | glMatrixMode (GL_PROJECTION); | 138 | glMatrixMode (GL_PROJECTION); |
146 | glPopMatrix (); | 139 | glPopMatrix (); |
147 | glutSwapBuffers (); | 140 | glutSwapBuffers (); |
148 | 141 | ||
149 | /* | 142 | /* |
150 | * "Exit selection mode and process the returned selection data | 143 | * "Exit selection mode and process the returned selection data |
151 | * (the hit records) [Redbook]." | 144 | * (the hit records) [Redbook]." |
152 | */ | 145 | */ |
153 | GLint hits = glRenderMode (GL_RENDER); | 146 | GLint hits = glRenderMode (GL_RENDER); |
154 | check_error (__FILE__, __LINE__); | 147 | check_error (__FILE__, __LINE__); |
155 | 148 | ||
156 | /* "process hits from selection mode rendering [Angel,2008]." */ | 149 | /* "process hits from selection mode rendering [Angel,2008]." */ |
157 | exp004processhits (hits, select_buf); | 150 | exp004processhits (hits, select_buf); |
158 | 151 | ||
159 | /* "normal render [Angel,2008]." */ | 152 | /* "normal render [Angel,2008]." */ |
160 | glutPostRedisplay (); | 153 | glutPostRedisplay (); |
161 | } | 154 | } |
162 | 155 | ||
163 | } | 156 | } |
diff --git a/src/controller/exp004processhits.c b/src/controller/exp004processhits.c index 84f8b8d..264bd46 100644 --- a/src/controller/exp004processhits.c +++ b/src/controller/exp004processhits.c | |||
@@ -1,10 +1,7 @@ | |||
1 | /* I seem to need this for glGenBuffers as per | ||
2 | http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */ | ||
3 | #define GL_GLEXT_PROTOTYPES | 1 | #define GL_GLEXT_PROTOTYPES |
4 | 2 | #include "../view/exp004state0.h" | |
5 | #include "exp004processhits.h" | 3 | #include "exp004processhits.h" |
6 | #include "selsave.h" | 4 | #include "selsave.h" |
7 | #include "../view/exp004state0.h" | ||
8 | #include <stdio.h> | 5 | #include <stdio.h> |
9 | 6 | ||
10 | /* | 7 | /* |
@@ -19,20 +16,13 @@ | |||
19 | void | 16 | void |
20 | exp004processhits (GLint hits, GLuint buffer[]) | 17 | exp004processhits (GLint hits, GLuint buffer[]) |
21 | { | 18 | { |
22 | printf ("Hits: %d\n", hits); | ||
23 | |||
24 | GLuint *hitlist = buffer; | 19 | GLuint *hitlist = buffer; |
25 | 20 | ||
26 | for (int i = 0; i < hits; i++) | 21 | for (int i = 0; i < hits; i++) |
27 | { | 22 | { |
28 | hitlist += 3; | 23 | hitlist += 3; |
29 | 24 | ||
30 | /* | 25 | /* |
31 | * Report the hit to the terminal. | ||
32 | */ | ||
33 | printf ("Hit %i: %s\n", i + 1, S.gi_data[*hitlist]); | ||
34 | |||
35 | /* | ||
36 | * Add the hits to the selection. | 26 | * Add the hits to the selection. |
37 | */ | 27 | */ |
38 | S.selection.set[*hitlist] = true; | 28 | S.selection.set[*hitlist] = true; |
@@ -51,8 +41,6 @@ exp004processhits (GLint hits, GLuint buffer[]) | |||
51 | glBufferData (GL_ARRAY_BUFFER, | 41 | glBufferData (GL_ARRAY_BUFFER, |
52 | sizeof (S.base_colors_data), S.base_colors_data, | 42 | sizeof (S.base_colors_data), S.base_colors_data, |
53 | GL_STATIC_DRAW); | 43 | GL_STATIC_DRAW); |
54 | |||
55 | printf ("\n"); | ||
56 | 44 | ||
57 | return; | 45 | return; |
58 | } | 46 | } |
diff --git a/src/controller/exp004reshape.c b/src/controller/exp004reshape.c index 4d46223..82f134d 100644 --- a/src/controller/exp004reshape.c +++ b/src/controller/exp004reshape.c | |||
@@ -19,26 +19,18 @@ exp004reshape (int w, int h) | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | if (w <= h) | 21 | if (w <= h) |
22 | { | 22 | { |
23 | S.ortho.min_x = | 23 | S.ortho.min_x = S.ortho_min; |
24 | S.ortho_min; | 24 | S.ortho.max_x = S.ortho_max; |
25 | S.ortho.max_x = | 25 | S.ortho.min_y = S.ortho_min * (GLfloat) h / (GLfloat) w; |
26 | S.ortho_max; | 26 | S.ortho.max_y = S.ortho_max * (GLfloat) h / (GLfloat) w; |
27 | S.ortho.min_y = | ||
28 | S.ortho_min * (GLfloat) h / (GLfloat) w; | ||
29 | S.ortho.max_y = | ||
30 | S.ortho_max * (GLfloat) h / (GLfloat) w; | ||
31 | } | 27 | } |
32 | else | 28 | else |
33 | { | 29 | { |
34 | S.ortho.min_x = | 30 | S.ortho.min_x = S.ortho_min * (GLfloat) w / (GLfloat) h; |
35 | S.ortho_min * (GLfloat) w / (GLfloat) h; | 31 | S.ortho.max_x = S.ortho_max * (GLfloat) w / (GLfloat) h; |
36 | S.ortho.max_x = | 32 | S.ortho.min_y = S.ortho_min; |
37 | S.ortho_max * (GLfloat) w / (GLfloat) h; | 33 | S.ortho.max_y = S.ortho_max; |
38 | S.ortho.min_y = | ||
39 | S.ortho_min; | ||
40 | S.ortho.max_y = | ||
41 | S.ortho_max; | ||
42 | } | 34 | } |
43 | 35 | ||
44 | set_ortho (); | 36 | set_ortho (); |
diff --git a/src/controller/keyboard.c b/src/controller/keyboard.c index 6b70af2..d817d7c 100644 --- a/src/controller/keyboard.c +++ b/src/controller/keyboard.c | |||
@@ -33,7 +33,7 @@ keyboard (unsigned char key, int x, int y) | |||
33 | * Reset the view (unzoom). | 33 | * Reset the view (unzoom). |
34 | */ | 34 | */ |
35 | S.zoom.active = false; | 35 | S.zoom.active = false; |
36 | exp004reshape (S.viewport.w, S.viewport.h); | 36 | exp004reshape (S.viewport.w, S.viewport.h); |
37 | glutPostRedisplay (); | 37 | glutPostRedisplay (); |
38 | break; | 38 | break; |
39 | 39 | ||
diff --git a/src/controller/selection_from_db.sqc b/src/controller/selection_from_db.sqc index 8a49510..8c12c79 100644 --- a/src/controller/selection_from_db.sqc +++ b/src/controller/selection_from_db.sqc | |||
@@ -22,18 +22,17 @@ selection_from_db (void) | |||
22 | EXEC SQL END DECLARE SECTION; | 22 | EXEC SQL END DECLARE SECTION; |
23 | 23 | ||
24 | EXEC SQL DECLARE c3 CURSOR FOR | 24 | EXEC SQL DECLARE c3 CURSOR FOR |
25 | SELECT * FROM vis_sel_set | 25 | SELECT * FROM vis_sel_set ORDER BY title, id DESC; |
26 | ORDER BY title, id DESC; | ||
27 | 26 | ||
28 | EXEC SQL OPEN c3; | 27 | EXEC SQL OPEN c3; |
29 | check_error (__FILE__, __LINE__); | 28 | check_error (__FILE__, __LINE__); |
30 | 29 | ||
31 | /* | 30 | /* |
32 | * This loop currently assumes only one set in the table and does | 31 | * This loop currently assumes only one set in the table and does |
33 | * not use the title assigned to that set. This should be improved | 32 | * not use the title assigned to that set. This should be improved |
34 | * to allow the user to manage multiple sets by name. | 33 | * to allow the user to manage multiple sets by name. |
35 | */ | 34 | */ |
36 | EXEC SQL FETCH c3 INTO :vis_sel_set; | 35 | EXEC SQL FETCH c3 INTO:vis_sel_set; |
37 | while (sqlca.sqlcode != 100) | 36 | while (sqlca.sqlcode != 100) |
38 | { | 37 | { |
39 | int i = vis_sel_set.id - 1; | 38 | int i = vis_sel_set.id - 1; |
@@ -44,7 +43,7 @@ selection_from_db (void) | |||
44 | S.base_colors_data[i][2] = vis_sel_set.b; | 43 | S.base_colors_data[i][2] = vis_sel_set.b; |
45 | S.base_colors_data[i][3] = 0.6; | 44 | S.base_colors_data[i][3] = 0.6; |
46 | 45 | ||
47 | EXEC SQL FETCH c3 INTO :vis_sel_set; | 46 | EXEC SQL FETCH c3 INTO:vis_sel_set; |
48 | } | 47 | } |
49 | 48 | ||
50 | EXEC SQL CLOSE c3; | 49 | EXEC SQL CLOSE c3; |
diff --git a/src/controller/selsave.sqc b/src/controller/selsave.sqc index 27734ab..2c6005f 100644 --- a/src/controller/selsave.sqc +++ b/src/controller/selsave.sqc | |||
@@ -24,12 +24,12 @@ selsave (void) | |||
24 | */ | 24 | */ |
25 | EXEC SQL DELETE FROM vis_selection WHERE gi IS NOT NULL; | 25 | EXEC SQL DELETE FROM vis_selection WHERE gi IS NOT NULL; |
26 | check_error (__FILE__, __LINE__); | 26 | check_error (__FILE__, __LINE__); |
27 | 27 | ||
28 | for (unsigned int i = 0; i < ROWS; i++) | 28 | for (unsigned int i = 0; i < ROWS; i++) |
29 | { | 29 | { |
30 | if (S.selection.set[i] == true) | 30 | if (S.selection.set[i] == true) |
31 | { | 31 | { |
32 | strncpy (gi, S.gi_data[i] + 3, sizeof(gi)); | 32 | strncpy (gi, S.gi_data[i] + 3, sizeof (gi)); |
33 | EXEC SQL INSERT INTO vis_selection VALUES (:gi); | 33 | EXEC SQL INSERT INTO vis_selection VALUES (:gi); |
34 | } | 34 | } |
35 | } | 35 | } |
diff --git a/src/controller/set_ortho.c b/src/controller/set_ortho.c index 75af6a6..6478d21 100644 --- a/src/controller/set_ortho.c +++ b/src/controller/set_ortho.c | |||
@@ -10,17 +10,12 @@ set_ortho (void) | |||
10 | if (S.zoom.active) | 10 | if (S.zoom.active) |
11 | { | 11 | { |
12 | gluOrtho2D (S.zoom.coords[0], | 12 | gluOrtho2D (S.zoom.coords[0], |
13 | S.zoom.coords[1], | 13 | S.zoom.coords[1], S.zoom.coords[2], S.zoom.coords[3]); |
14 | S.zoom.coords[2], | ||
15 | S.zoom.coords[3]); | ||
16 | } | 14 | } |
17 | else | 15 | else |
18 | { | 16 | { |
19 | gluOrtho2D (S.ortho.min_x, | 17 | gluOrtho2D (S.ortho.min_x, S.ortho.max_x, S.ortho.min_y, S.ortho.max_y); |
20 | S.ortho.max_x, | 18 | } |
21 | S.ortho.min_y, | ||
22 | S.ortho.max_y); | ||
23 | } | ||
24 | 19 | ||
25 | return; | 20 | return; |
26 | } | 21 | } |
diff --git a/src/controller/vis_sel_set.h b/src/controller/vis_sel_set.h index 7c66a93..5df08f1 100644 --- a/src/controller/vis_sel_set.h +++ b/src/controller/vis_sel_set.h | |||
@@ -3,11 +3,10 @@ struct | |||
3 | struct | 3 | struct |
4 | { | 4 | { |
5 | short length; | 5 | short length; |
6 | char data[255]; | 6 | char data[255]; |
7 | } title; | 7 | } title; |
8 | sqlint32 id; | 8 | sqlint32 id; |
9 | double r; | 9 | double r; |
10 | double g; | 10 | double g; |
11 | double b; | 11 | double b; |
12 | } vis_sel_set; | 12 | } vis_sel_set; |
13 | |||
diff --git a/src/model/coordinates.h b/src/model/coordinates.h index 386f839..7620904 100644 --- a/src/model/coordinates.h +++ b/src/model/coordinates.h | |||
@@ -4,9 +4,8 @@ struct | |||
4 | struct | 4 | struct |
5 | { | 5 | { |
6 | short length; | 6 | short length; |
7 | char data[50]; | 7 | char data[50]; |
8 | } gi; | 8 | } gi; |
9 | double x; | 9 | double x; |
10 | double y; | 10 | double y; |
11 | } coordinates; | 11 | } coordinates; |
12 | |||
diff --git a/src/model/exp004base.sqc b/src/model/exp004base.sqc index 2742138..a9c94cf 100644 --- a/src/model/exp004base.sqc +++ b/src/model/exp004base.sqc | |||
@@ -23,17 +23,16 @@ exp004base (void) | |||
23 | * This implementation can be improved by mapping the video memory | 23 | * This implementation can be improved by mapping the video memory |
24 | * directly rather than loading into system memory and then copying | 24 | * directly rather than loading into system memory and then copying |
25 | * into video memory. | 25 | * into video memory. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * db2dclgn -d exp004 -t coordinates | 29 | * db2dclgn -d exp004 -t coordinates |
30 | */ | 30 | */ |
31 | EXEC SQL BEGIN DECLARE SECTION; | 31 | EXEC SQL BEGIN DECLARE SECTION; |
32 | EXEC SQL INCLUDE 'model/coordinates.h'; | 32 | EXEC SQL INCLUDE 'model/coordinates.h'; |
33 | EXEC SQL END DECLARE SECTION; | 33 | EXEC SQL END DECLARE SECTION; |
34 | 34 | ||
35 | EXEC SQL DECLARE c2 CURSOR FOR | 35 | EXEC SQL DECLARE c2 CURSOR FOR SELECT *FROM coordinates; |
36 | SELECT * FROM coordinates; | ||
37 | 36 | ||
38 | EXEC SQL OPEN c2; | 37 | EXEC SQL OPEN c2; |
39 | 38 | ||
@@ -45,14 +44,12 @@ exp004base (void) | |||
45 | S.bb.min_y = 0.0; | 44 | S.bb.min_y = 0.0; |
46 | S.bb.max_y = 0.0; | 45 | S.bb.max_y = 0.0; |
47 | 46 | ||
48 | EXEC SQL FETCH c2 INTO :coordinates; | 47 | EXEC SQL FETCH c2 INTO:coordinates; |
49 | while (sqlca.sqlcode != 100) | 48 | while (sqlca.sqlcode != 100) |
50 | { | 49 | { |
51 | int i = coordinates.coord_id - 1; | 50 | int i = coordinates.coord_id - 1; |
52 | 51 | ||
53 | strncpy(S.gi_data[i], | 52 | strncpy (S.gi_data[i], coordinates.gi.data, sizeof (S.gi_data[i])); |
54 | coordinates.gi.data, | ||
55 | sizeof (S.gi_data[i])); | ||
56 | 53 | ||
57 | S.base_vertices_data[i][0] = coordinates.x; | 54 | S.base_vertices_data[i][0] = coordinates.x; |
58 | S.base_vertices_data[i][1] = coordinates.y; | 55 | S.base_vertices_data[i][1] = coordinates.y; |
@@ -76,7 +73,7 @@ exp004base (void) | |||
76 | S.base_colors_data[i][2] = DEFAULT_COLOR_B; | 73 | S.base_colors_data[i][2] = DEFAULT_COLOR_B; |
77 | S.base_colors_data[i][3] = DEFAULT_COLOR_A; | 74 | S.base_colors_data[i][3] = DEFAULT_COLOR_A; |
78 | 75 | ||
79 | EXEC SQL FETCH c2 INTO :coordinates; | 76 | EXEC SQL FETCH c2 INTO:coordinates; |
80 | } | 77 | } |
81 | 78 | ||
82 | EXEC SQL CLOSE c2; | 79 | EXEC SQL CLOSE c2; |
@@ -106,8 +103,7 @@ exp004base (void) | |||
106 | 103 | ||
107 | // Invert the y coordinate to match up with the LGL Java viewer. | 104 | // Invert the y coordinate to match up with the LGL Java viewer. |
108 | for (int i = 0; i < ROWS; i++) | 105 | for (int i = 0; i < ROWS; i++) |
109 | S.base_vertices_data[i][1] = | 106 | S.base_vertices_data[i][1] = S.ortho_max - S.base_vertices_data[i][1]; |
110 | S.ortho_max - S.base_vertices_data[i][1]; | ||
111 | 107 | ||
112 | // Move the origin (0,0) to the center of the data. | 108 | // Move the origin (0,0) to the center of the data. |
113 | S.ortho_min = 0.0; | 109 | S.ortho_min = 0.0; |
@@ -115,9 +111,8 @@ exp004base (void) | |||
115 | 111 | ||
116 | for (int i = 0; i < ROWS; i++) | 112 | for (int i = 0; i < ROWS; i++) |
117 | { | 113 | { |
118 | S.base_vertices_data[i][0] = | 114 | S.base_vertices_data[i][0] = |
119 | S.base_vertices_data[i][0] - | 115 | S.base_vertices_data[i][0] - (0.5 * (S.bb.max_x - S.bb.min_x)); |
120 | (0.5 * (S.bb.max_x - S.bb.min_x)); | ||
121 | 116 | ||
122 | if (S.ortho_min > S.base_vertices_data[i][0]) | 117 | if (S.ortho_min > S.base_vertices_data[i][0]) |
123 | S.ortho_min = S.base_vertices_data[i][0]; | 118 | S.ortho_min = S.base_vertices_data[i][0]; |
@@ -125,9 +120,8 @@ exp004base (void) | |||
125 | if (S.ortho_max < S.base_vertices_data[i][0]) | 120 | if (S.ortho_max < S.base_vertices_data[i][0]) |
126 | S.ortho_max = S.base_vertices_data[i][0]; | 121 | S.ortho_max = S.base_vertices_data[i][0]; |
127 | 122 | ||
128 | S.base_vertices_data[i][1] = | 123 | S.base_vertices_data[i][1] = |
129 | S.base_vertices_data[i][1] - | 124 | S.base_vertices_data[i][1] - (0.5 * (S.bb.max_y - S.bb.min_y)); |
130 | (0.5 * (S.bb.max_y - S.bb.min_y)); | ||
131 | 125 | ||
132 | if (S.ortho_min > S.base_vertices_data[i][1]) | 126 | if (S.ortho_min > S.base_vertices_data[i][1]) |
133 | S.ortho_min = S.base_vertices_data[i][1]; | 127 | S.ortho_min = S.base_vertices_data[i][1]; |
@@ -140,7 +134,7 @@ exp004base (void) | |||
140 | 134 | ||
141 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]); | 135 | glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_VERTICES]); |
142 | glVertexPointer (2, GL_FLOAT, 0, 0); | 136 | glVertexPointer (2, GL_FLOAT, 0, 0); |
143 | glBufferData (GL_ARRAY_BUFFER, | 137 | glBufferData (GL_ARRAY_BUFFER, |
144 | sizeof (S.base_vertices_data), S.base_vertices_data, | 138 | sizeof (S.base_vertices_data), S.base_vertices_data, |
145 | GL_STATIC_DRAW); | 139 | GL_STATIC_DRAW); |
146 | 140 | ||
diff --git a/src/model/exp004state.h b/src/model/exp004state.h index 11e9ebd..d151966 100644 --- a/src/model/exp004state.h +++ b/src/model/exp004state.h | |||
@@ -10,15 +10,18 @@ | |||
10 | #define BASE_VERTICES 0 | 10 | #define BASE_VERTICES 0 |
11 | #define BASE_COLORS 1 | 11 | #define BASE_COLORS 1 |
12 | 12 | ||
13 | #define DEFAULT_COLOR_R 0.5 | 13 | #define CLEAR_COLOR 1.0, 1.0, 1.0, 1.0 |
14 | #define DEFAULT_COLOR_G 0.5 | 14 | #define DRAW_COLOR 0.0, 0.0, 0.0 |
15 | #define DEFAULT_COLOR_B 0.5 | ||
16 | #define DEFAULT_COLOR_A 0.5 | ||
17 | 15 | ||
18 | #define SELECT_COLOR_R 1.0 | 16 | #define DEFAULT_COLOR_R 0.00 |
19 | #define SELECT_COLOR_G 1.0 | 17 | #define DEFAULT_COLOR_G 0.00 |
20 | #define SELECT_COLOR_B 1.0 | 18 | #define DEFAULT_COLOR_B 0.01 |
21 | #define SELECT_COLOR_A 0.8 | 19 | #define DEFAULT_COLOR_A 0.25 |
20 | |||
21 | #define SELECT_COLOR_R 0.00 | ||
22 | #define SELECT_COLOR_G 0.00 | ||
23 | #define SELECT_COLOR_B 0.00 | ||
24 | #define SELECT_COLOR_A 0.75 | ||
22 | 25 | ||
23 | /* | 26 | /* |
24 | * Maintain state of the model. | 27 | * Maintain state of the model. |
@@ -29,7 +32,8 @@ typedef struct | |||
29 | /* | 32 | /* |
30 | * Track the bounding box of the points. | 33 | * Track the bounding box of the points. |
31 | */ | 34 | */ |
32 | struct { | 35 | struct |
36 | { | ||
33 | float min_x; | 37 | float min_x; |
34 | float max_x; | 38 | float max_x; |
35 | float min_y; | 39 | float min_y; |
@@ -49,7 +53,8 @@ typedef struct | |||
49 | /* | 53 | /* |
50 | * Orthographic coordinates after aspect preserving scaling. | 54 | * Orthographic coordinates after aspect preserving scaling. |
51 | */ | 55 | */ |
52 | struct { | 56 | struct |
57 | { | ||
53 | float min_x; | 58 | float min_x; |
54 | float max_x; | 59 | float max_x; |
55 | float min_y; | 60 | float min_y; |
@@ -59,7 +64,8 @@ typedef struct | |||
59 | /* | 64 | /* |
60 | * Viewport size. | 65 | * Viewport size. |
61 | */ | 66 | */ |
62 | struct { | 67 | struct |
68 | { | ||
63 | int w; | 69 | int w; |
64 | int h; | 70 | int h; |
65 | } viewport; | 71 | } viewport; |
@@ -87,7 +93,7 @@ typedef struct | |||
87 | SELECTION_INFO selection; | 93 | SELECTION_INFO selection; |
88 | 94 | ||
89 | ZOOM_INFO zoom; | 95 | ZOOM_INFO zoom; |
90 | 96 | ||
91 | } EXP004STATE; | 97 | } EXP004STATE; |
92 | 98 | ||
93 | #endif // EXP004STATE_H | 99 | #endif // EXP004STATE_H |
diff --git a/src/model/selection_info.h b/src/model/selection_info.h index 970ecec..ccd3f7a 100644 --- a/src/model/selection_info.h +++ b/src/model/selection_info.h | |||
@@ -9,13 +9,14 @@ | |||
9 | */ | 9 | */ |
10 | #define ROWS 83905 | 10 | #define ROWS 83905 |
11 | 11 | ||
12 | typedef struct { | 12 | typedef struct |
13 | { | ||
13 | 14 | ||
14 | /* | 15 | /* |
15 | * Selection list. | 16 | * Selection list. |
16 | */ | 17 | */ |
17 | bool set[ROWS]; | 18 | bool set[ROWS]; |
18 | 19 | ||
19 | /* | 20 | /* |
20 | * A selection is being performed. | 21 | * A selection is being performed. |
21 | */ | 22 | */ |
@@ -25,17 +26,17 @@ typedef struct { | |||
25 | * Indicate if the user is currently defining a selection. | 26 | * Indicate if the user is currently defining a selection. |
26 | */ | 27 | */ |
27 | SELECTION_PURPOSES purpose; | 28 | SELECTION_PURPOSES purpose; |
28 | 29 | ||
29 | /* | 30 | /* |
30 | * X coordinate of mouse when selection mode initiated. | 31 | * X coordinate of mouse when selection mode initiated. |
31 | */ | 32 | */ |
32 | int x; | 33 | int x; |
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Y coordinate of mouse when selection mode initiated. | 36 | * Y coordinate of mouse when selection mode initiated. |
36 | */ | 37 | */ |
37 | int y; | 38 | int y; |
38 | 39 | ||
39 | } SELECTION_INFO; | 40 | } SELECTION_INFO; |
40 | 41 | ||
41 | #endif // SELECTION_INFO_H | 42 | #endif // SELECTION_INFO_H |
diff --git a/src/model/selection_info_init.c b/src/model/selection_info_init.c index e01b2b8..7a98e74 100644 --- a/src/model/selection_info_init.c +++ b/src/model/selection_info_init.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #include "selection_info_init.h" | 1 | #include "selection_info_init.h" |
2 | 2 | ||
3 | void | 3 | void |
4 | selection_info_init (SELECTION_INFO* s) | 4 | selection_info_init (SELECTION_INFO * s) |
5 | { | 5 | { |
6 | s->active = false; | 6 | s->active = false; |
7 | s->purpose = SET; | 7 | s->purpose = SET; |
diff --git a/src/model/selection_info_init.h b/src/model/selection_info_init.h index 8ce56c5..d38b851 100644 --- a/src/model/selection_info_init.h +++ b/src/model/selection_info_init.h | |||
@@ -3,6 +3,6 @@ | |||
3 | 3 | ||
4 | #include "selection_info.h" | 4 | #include "selection_info.h" |
5 | 5 | ||
6 | void selection_info_init (SELECTION_INFO* s); | 6 | void selection_info_init (SELECTION_INFO * s); |
7 | 7 | ||
8 | #endif // SELECTION_INFO_INIT_H | 8 | #endif // SELECTION_INFO_INIT_H |
diff --git a/src/model/selection_purposes.h b/src/model/selection_purposes.h index 12d6ec7..6c2e651 100644 --- a/src/model/selection_purposes.h +++ b/src/model/selection_purposes.h | |||
@@ -1,17 +1,17 @@ | |||
1 | #ifndef SELECTION_PURPOSES_H | 1 | #ifndef SELECTION_PURPOSES_H |
2 | #define SELECTION_PURPOSES_H | 2 | #define SELECTION_PURPOSES_H |
3 | 3 | ||
4 | typedef enum | 4 | typedef enum |
5 | { | 5 | { |
6 | /* | 6 | /* |
7 | * The selection will define a new set. | 7 | * The selection will define a new set. |
8 | */ | 8 | */ |
9 | SET, | 9 | SET, |
10 | 10 | ||
11 | /* | 11 | /* |
12 | * The selection will define a zoom region. | 12 | * The selection will define a zoom region. |
13 | */ | 13 | */ |
14 | ZOOM | 14 | ZOOM |
15 | } SELECTION_PURPOSES; | 15 | } SELECTION_PURPOSES; |
16 | 16 | ||
17 | #endif // SELECTION_PURPOSES_H | 17 | #endif // SELECTION_PURPOSES_H |
diff --git a/src/model/zoom_info.h b/src/model/zoom_info.h index 0b935c8..5916b3c 100644 --- a/src/model/zoom_info.h +++ b/src/model/zoom_info.h | |||
@@ -6,12 +6,13 @@ | |||
6 | /* | 6 | /* |
7 | * Maintain information for zooming. | 7 | * Maintain information for zooming. |
8 | */ | 8 | */ |
9 | typedef struct { | 9 | typedef struct |
10 | { | ||
10 | /* | 11 | /* |
11 | * A zoomed region has been selection. | 12 | * A zoomed region has been selection. |
12 | */ | 13 | */ |
13 | bool active; | 14 | bool active; |
14 | 15 | ||
15 | /* | 16 | /* |
16 | * Left, right, bottom and top of zoom region in world coordinates. | 17 | * Left, right, bottom and top of zoom region in world coordinates. |
17 | */ | 18 | */ |
diff --git a/src/model/zoom_info_init.c b/src/model/zoom_info_init.c index c5a3b1d..f49dd59 100644 --- a/src/model/zoom_info_init.c +++ b/src/model/zoom_info_init.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #include "zoom_info_init.h" | 1 | #include "zoom_info_init.h" |
2 | 2 | ||
3 | void | 3 | void |
4 | zoom_info_init (ZOOM_INFO* z) | 4 | zoom_info_init (ZOOM_INFO * z) |
5 | { | 5 | { |
6 | z->active = false; | 6 | z->active = false; |
7 | 7 | ||
diff --git a/src/model/zoom_info_init.h b/src/model/zoom_info_init.h index 262d408..2cf2ac2 100644 --- a/src/model/zoom_info_init.h +++ b/src/model/zoom_info_init.h | |||
@@ -3,6 +3,6 @@ | |||
3 | 3 | ||
4 | #include "zoom_info.h" | 4 | #include "zoom_info.h" |
5 | 5 | ||
6 | void zoom_info_init (ZOOM_INFO* z); | 6 | void zoom_info_init (ZOOM_INFO * z); |
7 | 7 | ||
8 | #endif // ZOOM_INFO_INIT_H | 8 | #endif // ZOOM_INFO_INIT_H |
diff --git a/src/util/pick_convert.c b/src/util/pick_convert.c index baafcfb..eca819a 100644 --- a/src/util/pick_convert.c +++ b/src/util/pick_convert.c | |||
@@ -5,8 +5,9 @@ | |||
5 | */ | 5 | */ |
6 | #define N 3.0 | 6 | #define N 3.0 |
7 | 7 | ||
8 | void pick_convert (int select_x, int select_y, int x, int y, | 8 | void |
9 | double *c_x, double *c_y, double *w, double *h) | 9 | pick_convert (int select_x, int select_y, int x, int y, |
10 | double *c_x, double *c_y, double *w, double *h) | ||
10 | { | 11 | { |
11 | /* | 12 | /* |
12 | * Calculate X and the width. | 13 | * Calculate X and the width. |
@@ -14,7 +15,7 @@ void pick_convert (int select_x, int select_y, int x, int y, | |||
14 | if (x > select_x) | 15 | if (x > select_x) |
15 | { | 16 | { |
16 | *c_x = (x - select_x) / 2.0 + select_x; | 17 | *c_x = (x - select_x) / 2.0 + select_x; |
17 | *w = x - select_x; | 18 | *w = x - select_x; |
18 | } | 19 | } |
19 | else if (x < select_x) | 20 | else if (x < select_x) |
20 | { | 21 | { |
diff --git a/src/util/sqlinfoprint.c b/src/util/sqlinfoprint.c index 8e0ae07..071b4c9 100644 --- a/src/util/sqlinfoprint.c +++ b/src/util/sqlinfoprint.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | 5 | ||
6 | int | 6 | int |
7 | sqlinfoprint (char *appMsg, struct sqlca *pSqlca, | 7 | sqlinfoprint (char *appMsg, struct sqlca *pSqlca, |
8 | const char *file, const unsigned int line) | 8 | const char *file, const unsigned int line) |
9 | { | 9 | { |
10 | int rc = 0; | 10 | int rc = 0; |
diff --git a/src/util/sqlinfoprint.h b/src/util/sqlinfoprint.h index 984694b..7df2a09 100644 --- a/src/util/sqlinfoprint.h +++ b/src/util/sqlinfoprint.h | |||
@@ -7,9 +7,8 @@ | |||
7 | * Report SQL error messages. Based on code from: | 7 | * Report SQL error messages. Based on code from: |
8 | * http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.apdv.embed.doc/doc/c0005779.html | 8 | * http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.apdv.embed.doc/doc/c0005779.html |
9 | */ | 9 | */ |
10 | int sqlinfoprint (char *appMsg, | 10 | int sqlinfoprint (char *appMsg, |
11 | struct sqlca *pSqlca, | 11 | struct sqlca *pSqlca, |
12 | const char *file, | 12 | const char *file, const unsigned int line); |
13 | const unsigned int line); | ||
14 | 13 | ||
15 | #endif // SQLINFOPRINT_H | 14 | #endif // SQLINFOPRINT_H |
diff --git a/src/view/exp004geometry.c b/src/view/exp004geometry.c index 9ff6475..b34d7f3 100644 --- a/src/view/exp004geometry.c +++ b/src/view/exp004geometry.c | |||
@@ -15,18 +15,18 @@ exp004geometry (GLenum mode) | |||
15 | glPointSize (0.1); | 15 | glPointSize (0.1); |
16 | glColor3f (0.2, 0.2, 0.2); | 16 | glColor3f (0.2, 0.2, 0.2); |
17 | 17 | ||
18 | if (mode == GL_SELECT) | 18 | if (mode == GL_SELECT) |
19 | { | 19 | { |
20 | for (int i = 0; i < ROWS; i++) | 20 | for (int i = 0; i < ROWS; i++) |
21 | { | 21 | { |
22 | glLoadName (i); | 22 | glLoadName (i); |
23 | glDrawArrays (GL_POINTS, i, 1); | 23 | glDrawArrays (GL_POINTS, i, 1); |
24 | } | 24 | } |
25 | } | 25 | } |
26 | else | 26 | else |
27 | { | 27 | { |
28 | glDrawArrays (GL_POINTS, 0, ROWS); | 28 | glDrawArrays (GL_POINTS, 0, ROWS); |
29 | } | 29 | } |
30 | 30 | ||
31 | return; | 31 | return; |
32 | } | 32 | } |
diff --git a/src/view/exp004view.c b/src/view/exp004view.c index cc27a93..b7e4367 100644 --- a/src/view/exp004view.c +++ b/src/view/exp004view.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "../db/dbconnect.h" | 5 | #include "../db/dbconnect.h" |
6 | #include "../model/exp004base.h" | 6 | #include "../model/exp004base.h" |
7 | #include "exp004init.h" | 7 | #include "exp004init.h" |
8 | #include "exp004state0.h" | ||
8 | #include "exp004view.h" | 9 | #include "exp004view.h" |
9 | #include <GL/glut.h> | 10 | #include <GL/glut.h> |
10 | 11 | ||
@@ -20,8 +21,8 @@ exp004view (void) | |||
20 | glutCreateWindow ("Exp004"); | 21 | glutCreateWindow ("Exp004"); |
21 | 22 | ||
22 | // GL Initialization | 23 | // GL Initialization |
23 | glClearColor (0.0, 0.0, 0.0, 1.0); | 24 | glClearColor (CLEAR_COLOR); |
24 | glColor3f (1.0, 1.0, 1.0); | 25 | glColor3f (DRAW_COLOR); |
25 | glEnable (GL_AUTO_NORMAL); | 26 | glEnable (GL_AUTO_NORMAL); |
26 | glEnable (GL_DEPTH_TEST); | 27 | glEnable (GL_DEPTH_TEST); |
27 | glEnable (GL_MAP1_VERTEX_3); | 28 | glEnable (GL_MAP1_VERTEX_3); |
@@ -30,7 +31,7 @@ exp004view (void) | |||
30 | /* Buffer objects to use. */ | 31 | /* Buffer objects to use. */ |
31 | glEnableClientState (GL_COLOR_ARRAY); | 32 | glEnableClientState (GL_COLOR_ARRAY); |
32 | glEnableClientState (GL_VERTEX_ARRAY); | 33 | glEnableClientState (GL_VERTEX_ARRAY); |
33 | 34 | ||
34 | /* Enable Antialiasing as described in "Antialiasing" | 35 | /* Enable Antialiasing as described in "Antialiasing" |
35 | [Shreiner,247]. */ | 36 | [Shreiner,247]. */ |
36 | glEnable (GL_LINE_SMOOTH); | 37 | glEnable (GL_LINE_SMOOTH); |