summaryrefslogtreecommitdiffstats
authorDon Pellegrino <don@coffee.donpellegrino.com>2009-08-17 16:59:55 (GMT)
committer Don Pellegrino <don@coffee.donpellegrino.com>2009-08-17 16:59:55 (GMT)
commit8af3b6fb74db30540bc877049ca795fc2428f383 (patch) (unidiff)
tree961e65a55548141a324630fdf4b4c5c487ce9fd4
parent8ecdebf950d7d2458bc28c0bae2ad590f183e148 (diff)
downloadexp005-8af3b6fb74db30540bc877049ca795fc2428f383.zip
exp005-8af3b6fb74db30540bc877049ca795fc2428f383.tar.gz
exp005-8af3b6fb74db30540bc877049ca795fc2428f383.tar.bz2
Refactored the controller package into separate actions and
callbacks. Design justification added as a README to the controller subdirectory.
-rw-r--r--src/Makefile.am55
-rw-r--r--src/controller/README_controller.txt18
-rw-r--r--src/controller/actions/clear_selection.h (renamed from src/controller/clear_selection.h)0
-rw-r--r--src/controller/actions/clear_selection.sqc (renamed from src/controller/clear_selection.sqc)4
-rw-r--r--src/controller/actions/pan.c8
-rw-r--r--src/controller/actions/pan.h9
-rw-r--r--src/controller/actions/process_hits.c (renamed from src/controller/exp004processhits.c)12
-rw-r--r--src/controller/actions/process_hits.h8
-rw-r--r--src/controller/actions/sel_save.c141
-rw-r--r--src/controller/actions/sel_save.h9
-rw-r--r--src/controller/actions/sel_save.sqc (renamed from src/controller/selsave.sqc)8
-rw-r--r--src/controller/actions/selection_from_db.h (renamed from src/controller/selection_from_db.h)0
-rw-r--r--src/controller/actions/selection_from_db.sqc (renamed from src/controller/selection_from_db.sqc)8
-rw-r--r--src/controller/actions/set_ortho.h (renamed from src/controller/set_ortho.h)0
-rw-r--r--src/controller/actions/vis_sel_set.h (renamed from src/controller/vis_sel_set.h)0
-rw-r--r--src/controller/actions/zoom.c (renamed from src/controller/performzoom.c)12
-rw-r--r--src/controller/actions/zoom.h9
-rw-r--r--src/controller/callbacks/display.c (renamed from src/controller/exp004display.c)8
-rw-r--r--src/controller/callbacks/display.h9
-rw-r--r--src/controller/callbacks/keyboard.c (renamed from src/controller/keyboard.c)10
-rw-r--r--src/controller/callbacks/keyboard.h (renamed from src/controller/keyboard.h)0
-rw-r--r--src/controller/callbacks/mouse.c (renamed from src/controller/exp004mouse.c)36
-rw-r--r--src/controller/callbacks/mouse.h9
-rw-r--r--src/controller/callbacks/mouse_wheel.c (renamed from src/controller/mousewheel.c)22
-rw-r--r--src/controller/callbacks/mouse_wheel.h (renamed from src/controller/mousewheel.h)8
-rw-r--r--src/controller/callbacks/reshape.c (renamed from src/controller/exp004reshape.c)10
-rw-r--r--src/controller/callbacks/reshape.h6
-rw-r--r--src/controller/exp004display.h6
-rw-r--r--src/controller/exp004mouse.h6
-rw-r--r--src/controller/exp004processhits.h8
-rw-r--r--src/controller/exp004reshape.h6
-rw-r--r--src/controller/performzoom.h9
-rw-r--r--src/controller/selsave.h9
-rw-r--r--src/controller/set_ortho.c21
-rw-r--r--src/model/geometry/density_legend_geometry.c4
-rw-r--r--src/view/exp004view.c20
36 files changed, 332 insertions, 176 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3bb95ee..1ccb4f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,17 +1,18 @@
1bin_PROGRAMS = exp004viz1bin_PROGRAMS = exp004viz
22
3exp004viz_SOURCES = \3exp004viz_SOURCES = \
4 controller/clear_selection.c \4 controller/actions/clear_selection.c \
5 controller/exp004display.c \5 controller/actions/pan.c \
6 controller/exp004mouse.c \6 controller/actions/process_hits.c \
7 controller/exp004processhits.c \7 controller/actions/sel_save.c \
8 controller/exp004reshape.c \8 controller/actions/selection_from_db.c \
9 controller/keyboard.c \9 controller/actions/set_ortho.c \
10 controller/mousewheel.c \10 controller/actions/zoom.c \
11 controller/performzoom.c \11 controller/callbacks/display.c \
12 controller/selection_from_db.c \12 controller/callbacks/keyboard.c \
13 controller/selsave.c \13 controller/callbacks/mouse.c \
14 controller/set_ortho.c \14 controller/callbacks/mouse_wheel.c \
15 controller/callbacks/reshape.c \
15 db/dbconnect.c \16 db/dbconnect.c \
16 exp004viz.c \17 exp004viz.c \
17 model/exp004base.c \18 model/exp004base.c \
@@ -32,24 +33,26 @@ exp004viz_SOURCES = \
32exp004viz_LDADD = ${GLUT_LIBS}33exp004viz_LDADD = ${GLUT_LIBS}
3334
34noinst_HEADERS = \35noinst_HEADERS = \
35 controller/clear_selection.h \36 controller/actions/clear_selection.h \
36 controller/exp004display.h \37 controller/actions/pan.h \
37 controller/exp004mouse.h \38 controller/actions/process_hits.h \
38 controller/exp004processhits.h \39 controller/actions/sel_save.h \
39 controller/exp004reshape.h \40 controller/actions/selection_from_db.h \
40 controller/keyboard.h \41 controller/actions/set_ortho.h \
41 controller/mousewheel.h \42 controller/actions/vis_sel_set.h \
42 controller/performzoom.h \43 controller/actions/zoom.h \
43 controller/selection_from_db.h \44 controller/callbacks/display.h \
44 controller/selsave.h \45 controller/callbacks/keyboard.h \
45 controller/set_ortho.h \46 controller/callbacks/mouse.h \
47 controller/callbacks/mouse_wheel.h \
48 controller/callbacks/reshape.h \
46 db/dbconnect.h \49 db/dbconnect.h \
47 model/exp004base.h \50 model/exp004base.h \
48 model/exp004state.h \51 model/exp004state.h \
49 model/geometry/density_legend_geometry.h \52 model/geometry/density_legend_geometry.h \
53 model/geometry/map_geometry.h \
50 model/geometry/protein_geometry.h \54 model/geometry/protein_geometry.h \
51 model/geometry/protein_selected_geometry.h \55 model/geometry/protein_selected_geometry.h \
52 model/geometry/map_geometry.h \
53 model/selection_info.h \56 model/selection_info.h \
54 model/selection_info_init.h \57 model/selection_info_init.h \
55 model/selection_purposes.h \58 model/selection_purposes.h \
@@ -79,8 +82,8 @@ AM_CFLAGS = -Wall -ggdb -std=gnu99 -pipe -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_S
79 db2 PRECOMPILE $<;82 db2 PRECOMPILE $<;
8083
81CLEANFILES = \84CLEANFILES = \
82 controller/clear_selection.c \85 controller/actions/clear_selection.c \
83 controller/selection_from_db.c \86 controller/actions/selection_from_db.c \
84 controller/selsave.c \87 controller/actions/sel_save.c \
85 db/dbconnect.c \88 db/dbconnect.c \
86 model/exp004base.c89 model/exp004base.c
diff --git a/src/controller/README_controller.txt b/src/controller/README_controller.txt
new file mode 100644
index 0000000..c9e7f83
--- a/dev/null
+++ b/src/controller/README_controller.txt
@@ -0,0 +1,18 @@
1The controller is split into two sections. The callbacks subdirectory
2contains the functions that are used as callbacks from the GLUT event
3loop. The actions subdirectory contains functions that operate on the
4data and state. To the extent possible callbacks should be empty
5shells that transform information from hardware and the event loop to
6the calling parameters of actions. This design has the advantage of
7facilitating the scripting of user actions in the future. A script
8should be able to call action functions and generate equivalent
9behaviors as if the user had initiated the sequences of actions using
10the user interface. Another advantage is that multiple user interface
11callbacks can share the same actions. A common example of this is the
12execution of the same function through either a menu selection
13callback or a toolbar callback. As per the "GNU Coding Standards"
14section "5.4 Naming Variables, Functions, and Files
15[http://www.gnu.org/prep/standards/html_node/Names.html#Names]"
16underscores should be used to separate words in a name.
17
18 LocalWords: callbacks callback
diff --git a/src/controller/clear_selection.h b/src/controller/actions/clear_selection.h
index c57e358..c57e358 100644
--- a/src/controller/clear_selection.h
+++ b/src/controller/actions/clear_selection.h
diff --git a/src/controller/clear_selection.sqc b/src/controller/actions/clear_selection.sqc
index 4549c22..e527c30 100644
--- a/src/controller/clear_selection.sqc
+++ b/src/controller/actions/clear_selection.sqc
@@ -1,7 +1,7 @@
1#define GL_GLEXT_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
2#include "clear_selection.h"2#include "clear_selection.h"
3#include "../model/geometry/map_geometry.h"3#include "../../model/geometry/map_geometry.h"
4#include "../view/exp004state0.h"4#include "../../view/exp004state0.h"
5#include <GL/glut.h>5#include <GL/glut.h>
6#include "sqlca.h"6#include "sqlca.h"
7extern struct sqlca sqlca;7extern struct sqlca sqlca;
diff --git a/src/controller/actions/pan.c b/src/controller/actions/pan.c
new file mode 100644
index 0000000..cdc5cad
--- a/dev/null
+++ b/src/controller/actions/pan.c
@@ -0,0 +1,8 @@
1#include "pan.h"
2
3void
4pan ()
5{
6
7 return;
8}
diff --git a/src/controller/actions/pan.h b/src/controller/actions/pan.h
new file mode 100644
index 0000000..18ac876
--- a/dev/null
+++ b/src/controller/actions/pan.h
@@ -0,0 +1,9 @@
1#ifndef PAN_H
2#define PAN_H
3
4/*
5 * Pan around the geometry.
6 */
7void pan ();
8
9#endif // PAN_H
diff --git a/src/controller/exp004processhits.c b/src/controller/actions/process_hits.c
index c51e170..4a76d1c 100644
--- a/src/controller/exp004processhits.c
+++ b/src/controller/actions/process_hits.c
@@ -1,8 +1,8 @@
1#define GL_GLEXT_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
2#include "../view/exp004state0.h"2#include "../../view/exp004state0.h"
3#include "../model/geometry/map_geometry.h"3#include "../../model/geometry/map_geometry.h"
4#include "exp004processhits.h"4#include "process_hits.h"
5#include "selsave.h"5#include "sel_save.h"
66
7/*7/*
8 * A simple alias to make the code more readable.8 * A simple alias to make the code more readable.
@@ -14,7 +14,7 @@
14 * [Angel,2008,pp80-81].14 * [Angel,2008,pp80-81].
15 */15 */
16void16void
17exp004processhits (const GLint hits, const GLuint * hitlist)17process_hits (const GLint hits, const GLuint * hitlist)
18{18{
19 for (unsigned int i = 0; i < hits; i++)19 for (unsigned int i = 0; i < hits; i++)
20 {20 {
@@ -28,7 +28,7 @@ exp004processhits (const GLint hits, const GLuint * hitlist)
28 hitlist++;28 hitlist++;
29 }29 }
3030
31 selsave ();31 sel_save ();
3232
33 glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);33 glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);
34 glColorPointer (4, GL_FLOAT, 0, 0);34 glColorPointer (4, GL_FLOAT, 0, 0);
diff --git a/src/controller/actions/process_hits.h b/src/controller/actions/process_hits.h
new file mode 100644
index 0000000..d664a6e
--- a/dev/null
+++ b/src/controller/actions/process_hits.h
@@ -0,0 +1,8 @@
1#ifndef PROCESS_HITS_H
2#define PROCESS_HITS_H
3
4#include <GL/glut.h>
5
6void process_hits (const GLint hits, const GLuint * hitlist);
7
8#endif // PROCESS_HITS_H
diff --git a/src/controller/actions/sel_save.c b/src/controller/actions/sel_save.c
new file mode 100644
index 0000000..424f101
--- a/dev/null
+++ b/src/controller/actions/sel_save.c
@@ -0,0 +1,141 @@
1static char sqla_program_id[292] =
2{
3 172,0,65,69,65,78,65,73,108,65,118,119,77,82,73,90,48,49,49,49,
4 49,32,50,32,32,32,32,32,32,32,32,32,8,0,68,79,78,32,32,32,
5 32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
6 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
7 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
8 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
10 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
11 0,0,8,0,83,69,76,95,83,65,86,69,0,0,0,0,0,0,0,0,
12 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
13 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
14 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
15 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
17 0,0,0,0,0,0,0,0,0,0,0,0
18};
19
20#include "sqladef.h"
21
22static struct sqla_runtime_info sqla_rtinfo =
23{{'S','Q','L','A','R','T','I','N'}, sizeof(wchar_t), 0, {' ',' ',' ',' '}};
24
25
26static const short sqlIsLiteral = SQL_IS_LITERAL;
27static const short sqlIsInputHvar = SQL_IS_INPUT_HVAR;
28
29
30#line 1 "sel_save.sqc"
31#include "../../util/check_error.h"
32#include "../../view/exp004state0.h"
33#include "sel_save.h"
34#include "sqlca.h"
35#include <string.h>
36extern struct sqlca sqlca;
37
38/*
39 * A simple alias to make the code more readable.
40 */
41#define S exp004state0
42
43void
44sel_save (void)
45{
46
47/*
48EXEC SQL BEGIN DECLARE SECTION;
49*/
50
51#line 16 "sel_save.sqc"
52
53 char gi[255];
54
55/*
56EXEC SQL END DECLARE SECTION;
57*/
58
59#line 18 "sel_save.sqc"
60
61
62 /*
63 * WHERE gi IS NOT NULL is added to prevent the PRECOMPILE command
64 * from throwing a warning about modifying an entire table. Since
65 * gi is defined as NOT NULL this will clear the entire table.
66 */
67
68/*
69EXEC SQL DELETE FROM vis_selection WHERE gi IS NOT NULL;
70*/
71
72{
73#line 25 "sel_save.sqc"
74 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
75#line 25 "sel_save.sqc"
76 sqlacall((unsigned short)24,1,0,0,0L);
77#line 25 "sel_save.sqc"
78 sqlastop(0L);
79}
80
81#line 25 "sel_save.sqc"
82
83 check_error (__FILE__, __LINE__);
84
85 for (unsigned int i = 0; i < S.rows; i++)
86 {
87 if (S.selection.set[i] == true)
88 {
89 strncpy (gi, S.gi_data + i + 3, sizeof (gi));
90
91/*
92EXEC SQL INSERT INTO vis_selection VALUES (:gi);
93*/
94
95{
96#line 33 "sel_save.sqc"
97 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
98#line 33 "sel_save.sqc"
99 sqlaaloc(2,1,1,0L);
100 {
101 struct sqla_setdata_list sql_setdlist[1];
102#line 33 "sel_save.sqc"
103 sql_setdlist[0].sqltype = 460; sql_setdlist[0].sqllen = 255;
104#line 33 "sel_save.sqc"
105 sql_setdlist[0].sqldata = (void*)gi;
106#line 33 "sel_save.sqc"
107 sql_setdlist[0].sqlind = 0L;
108#line 33 "sel_save.sqc"
109 sqlasetdata(2,0,1,sql_setdlist,0L,0L);
110 }
111#line 33 "sel_save.sqc"
112 sqlacall((unsigned short)24,2,2,0,0L);
113#line 33 "sel_save.sqc"
114 sqlastop(0L);
115}
116
117#line 33 "sel_save.sqc"
118
119 }
120 }
121
122
123/*
124EXEC SQL COMMIT;
125*/
126
127{
128#line 37 "sel_save.sqc"
129 sqlastrt(sqla_program_id, &sqla_rtinfo, &sqlca);
130#line 37 "sel_save.sqc"
131 sqlacall((unsigned short)21,0,0,0,0L);
132#line 37 "sel_save.sqc"
133 sqlastop(0L);
134}
135
136#line 37 "sel_save.sqc"
137
138 check_error (__FILE__, __LINE__);
139
140 return;
141}
diff --git a/src/controller/actions/sel_save.h b/src/controller/actions/sel_save.h
new file mode 100644
index 0000000..11b5785
--- a/dev/null
+++ b/src/controller/actions/sel_save.h
@@ -0,0 +1,9 @@
1#ifndef SEL_SAVE_H
2#define SEL_SAVE_H
3
4/*
5 * Send the current selection from memory to the database.
6 */
7void sel_save (void);
8
9#endif // SEL_SAVE_H
diff --git a/src/controller/selsave.sqc b/src/controller/actions/sel_save.sqc
index 8c192ad..5fa614f 100644
--- a/src/controller/selsave.sqc
+++ b/src/controller/actions/sel_save.sqc
@@ -1,6 +1,6 @@
1#include "../util/check_error.h"1#include "../../util/check_error.h"
2#include "../view/exp004state0.h"2#include "../../view/exp004state0.h"
3#include "selsave.h"3#include "sel_save.h"
4#include "sqlca.h"4#include "sqlca.h"
5#include <string.h>5#include <string.h>
6extern struct sqlca sqlca;6extern struct sqlca sqlca;
@@ -11,7 +11,7 @@ extern struct sqlca sqlca;
11#define S exp004state011#define S exp004state0
1212
13void13void
14selsave (void)14sel_save (void)
15{15{
16 EXEC SQL BEGIN DECLARE SECTION;16 EXEC SQL BEGIN DECLARE SECTION;
17 char gi[255];17 char gi[255];
diff --git a/src/controller/selection_from_db.h b/src/controller/actions/selection_from_db.h
index 8f0d8a2..8f0d8a2 100644
--- a/src/controller/selection_from_db.h
+++ b/src/controller/actions/selection_from_db.h
diff --git a/src/controller/selection_from_db.sqc b/src/controller/actions/selection_from_db.sqc
index f847e16..442f7c2 100644
--- a/src/controller/selection_from_db.sqc
+++ b/src/controller/actions/selection_from_db.sqc
@@ -1,8 +1,8 @@
1#define GL_GLEXT_PROTOTYPES1#define GL_GLEXT_PROTOTYPES
2#include "selection_from_db.h"2#include "selection_from_db.h"
3#include "../model/geometry/map_geometry.h"3#include "../../model/geometry/map_geometry.h"
4#include "../view/exp004state0.h"4#include "../../view/exp004state0.h"
5#include "../util/check_error.h"5#include "../../util/check_error.h"
6#include <GL/glut.h>6#include <GL/glut.h>
7#include "sqlca.h"7#include "sqlca.h"
8extern struct sqlca sqlca;8extern struct sqlca sqlca;
@@ -19,7 +19,7 @@ selection_from_db (void)
19 * db2dclgn -d exp004 -t vis_sel_set19 * db2dclgn -d exp004 -t vis_sel_set
20 */20 */
21 EXEC SQL BEGIN DECLARE SECTION;21 EXEC SQL BEGIN DECLARE SECTION;
22 EXEC SQL INCLUDE 'controller/vis_sel_set.h';22 EXEC SQL INCLUDE 'controller/actions/vis_sel_set.h';
23 EXEC SQL END DECLARE SECTION;23 EXEC SQL END DECLARE SECTION;
2424
25 EXEC SQL DECLARE c3 CURSOR FOR25 EXEC SQL DECLARE c3 CURSOR FOR
diff --git a/src/controller/set_ortho.h b/src/controller/actions/set_ortho.h
index 4e95330..4e95330 100644
--- a/src/controller/set_ortho.h
+++ b/src/controller/actions/set_ortho.h
diff --git a/src/controller/vis_sel_set.h b/src/controller/actions/vis_sel_set.h
index 5df08f1..5df08f1 100644
--- a/src/controller/vis_sel_set.h
+++ b/src/controller/actions/vis_sel_set.h
diff --git a/src/controller/performzoom.c b/src/controller/actions/zoom.c
index 2fed1d2..e33dcb8 100644
--- a/src/controller/performzoom.c
+++ b/src/controller/actions/zoom.c
@@ -1,7 +1,7 @@
1#include "performzoom.h"1#include "zoom.h"
2#include "exp004reshape.h"2#include "../callbacks/reshape.h"
3#include "../util/check_error.h"3#include "../../util/check_error.h"
4#include "../view/exp004state0.h"4#include "../../view/exp004state0.h"
5#include <GL/glut.h>5#include <GL/glut.h>
6#include <math.h>6#include <math.h>
77
@@ -11,7 +11,7 @@
11#define S exp004state011#define S exp004state0
1212
13void13void
14performzoom (int x1, int y1, int x2, int y2)14zoom (int x1, int y1, int x2, int y2)
15{15{
16 /*16 /*
17 * Convert the selection boundary from window coordinates to17 * Convert the selection boundary from window coordinates to
@@ -57,7 +57,7 @@ performzoom (int x1, int y1, int x2, int y2)
57 S.zoom.coords[2] = fmin (start_position[1], end_position[1]);57 S.zoom.coords[2] = fmin (start_position[1], end_position[1]);
58 S.zoom.coords[3] = fmax (start_position[1], end_position[1]);58 S.zoom.coords[3] = fmax (start_position[1], end_position[1]);
59 59
60 exp004reshape (S.viewport.w, S.viewport.h);60 reshape (S.viewport.w, S.viewport.h);
61 61
62 glutPostRedisplay ();62 glutPostRedisplay ();
63 63
diff --git a/src/controller/actions/zoom.h b/src/controller/actions/zoom.h
new file mode 100644
index 0000000..bd5b852
--- a/dev/null
+++ b/src/controller/actions/zoom.h
@@ -0,0 +1,9 @@
1#ifndef ZOOM_H
2#define ZOOM_H
3
4/*
5 * Perform a zoom operation.
6 */
7void zoom (int x1, int y1, int x2, int y2);
8
9#endif // ZOOM_H
diff --git a/src/controller/exp004display.c b/src/controller/callbacks/display.c
index dd9c387..68211b5 100644
--- a/src/controller/exp004display.c
+++ b/src/controller/callbacks/display.c
@@ -1,11 +1,9 @@
1#include "exp004display.h"1#include "display.h"
2#include "../view/exp004geometry.h"2#include "../../view/exp004geometry.h"
3#include <GL/glut.h>3#include <GL/glut.h>
44
5#define WINHEIGHT 500
6
7void5void
8exp004display (void)6display (void)
9{7{
10 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);8 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
11 exp004geometry (GL_RENDER);9 exp004geometry (GL_RENDER);
diff --git a/src/controller/callbacks/display.h b/src/controller/callbacks/display.h
new file mode 100644
index 0000000..a57ba8f
--- a/dev/null
+++ b/src/controller/callbacks/display.h
@@ -0,0 +1,9 @@
1#ifndef DISPLAY_H
2#define DISPLAY_H
3
4/*
5 * Draw the contents of the window.
6 */
7void display (void);
8
9#endif // DISPLAY_H
diff --git a/src/controller/keyboard.c b/src/controller/callbacks/keyboard.c
index 99a20d0..1187bce 100644
--- a/src/controller/keyboard.c
+++ b/src/controller/callbacks/keyboard.c
@@ -1,8 +1,8 @@
1#include "keyboard.h"1#include "keyboard.h"
2#include "clear_selection.h"2#include "../actions/clear_selection.h"
3#include "selection_from_db.h"3#include "../actions/selection_from_db.h"
4#include "exp004reshape.h"4#include "reshape.h"
5#include "../view/exp004state0.h"5#include "../../view/exp004state0.h"
6#include <GL/glut.h>6#include <GL/glut.h>
77
8#define S exp004state08#define S exp004state0
@@ -43,7 +43,7 @@ keyboard (unsigned char key, int x, int y)
43 * Reset the view (unzoom).43 * Reset the view (unzoom).
44 */44 */
45 S.zoom.active = false;45 S.zoom.active = false;
46 exp004reshape (S.viewport.w, S.viewport.h);46 reshape (S.viewport.w, S.viewport.h);
47 glutPostRedisplay ();47 glutPostRedisplay ();
48 break;48 break;
4949
diff --git a/src/controller/keyboard.h b/src/controller/callbacks/keyboard.h
index c01fc5f..c01fc5f 100644
--- a/src/controller/keyboard.h
+++ b/src/controller/callbacks/keyboard.h
diff --git a/src/controller/exp004mouse.c b/src/controller/callbacks/mouse.c
index cf09bef..fc48eff 100644
--- a/src/controller/exp004mouse.c
+++ b/src/controller/callbacks/mouse.c
@@ -1,12 +1,12 @@
1#include "exp004mouse.h"1#include "../../util/check_error.h"
2#include "exp004processhits.h"2#include "../../util/pick_convert.h"
3#include "exp004reshape.h"3#include "../../view/exp004geometry.h"
4#include "performzoom.h"4#include "../../view/exp004state0.h"
5#include "set_ortho.h"5#include "../actions/process_hits.h"
6#include "../view/exp004geometry.h"6#include "../actions/set_ortho.h"
7#include "../view/exp004state0.h"7#include "../actions/zoom.h"
8#include "../util/check_error.h"8#include "mouse.h"
9#include "../util/pick_convert.h"9#include "reshape.h"
10#include <GL/glut.h>10#include <GL/glut.h>
11#include <math.h>11#include <math.h>
12#include <stdlib.h>12#include <stdlib.h>
@@ -17,7 +17,7 @@
17#define S exp004state017#define S exp004state0
1818
19void19void
20exp004mouse (int button, int state, int x, int y)20mouse (int button, int state, int x, int y)
21{21{
22 if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)22 if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)
23 {23 {
@@ -32,16 +32,10 @@ exp004mouse (int button, int state, int x, int y)
32 GLint viewport[4];32 GLint viewport[4];
33 glGetIntegerv (GL_VIEWPORT, viewport);33 glGetIntegerv (GL_VIEWPORT, viewport);
3434
35 printf ("Zooming to: %i, %i, %i, %i\n", 35 zoom (S.selection.x,
36 S.selection.x, 36 viewport[3] - S.selection.y,
37 viewport[3] - S.selection.y, 37 x,
38 x, 38 viewport[3] - y);
39 viewport[3] - y);
40
41 performzoom (S.selection.x,
42 viewport[3] - S.selection.y,
43 x,
44 viewport[3] - y);
45 }39 }
4640
47 /*41 /*
@@ -114,7 +108,7 @@ exp004mouse (int button, int state, int x, int y)
114 check_error (__FILE__, __LINE__);108 check_error (__FILE__, __LINE__);
115109
116 /* "process hits from selection mode rendering [Angel,2008]." */110 /* "process hits from selection mode rendering [Angel,2008]." */
117 exp004processhits (hits, select_buf);111 process_hits (hits, select_buf);
118112
119 /* "normal render [Angel,2008]." */113 /* "normal render [Angel,2008]." */
120 glutPostRedisplay ();114 glutPostRedisplay ();
diff --git a/src/controller/callbacks/mouse.h b/src/controller/callbacks/mouse.h
new file mode 100644
index 0000000..2dfc838
--- a/dev/null
+++ b/src/controller/callbacks/mouse.h
@@ -0,0 +1,9 @@
1#ifndef MOUSE_H
2#define MOUSE_H
3
4/*
5 * Handle events generated by the mouse.
6 */
7void mouse (int button, int state, int x, int y);
8
9#endif // MOUSE_H
diff --git a/src/controller/mousewheel.c b/src/controller/callbacks/mouse_wheel.c
index c9ac742..52d3c8b 100644
--- a/src/controller/mousewheel.c
+++ b/src/controller/callbacks/mouse_wheel.c
@@ -1,9 +1,9 @@
1#include "mousewheel.h"1#include "mouse_wheel.h"
2#include "performzoom.h"2#include "../actions/zoom.h"
3#include <GL/glut.h>3#include <GL/glut.h>
44
5void 5void
6mousewheel (int button, int dir, int x, int y)6mouse_wheel (int button, int dir, int x, int y)
7{7{
8 /*8 /*
9 * Get the current coordinates, substract some fixed amount and9 * Get the current coordinates, substract some fixed amount and
@@ -26,19 +26,19 @@ mousewheel (int button, int dir, int x, int y)
26 // Zoom in26 // Zoom in
27 if (dir > 0)27 if (dir > 0)
28 {28 {
29 performzoom (step,29 zoom (step,
30 step,30 step,
31 viewport[3] - step,31 viewport[3] - step,
32 viewport[3] - step); 32 viewport[3] - step);
33 }33 }
3434
35 // Zoom out35 // Zoom out
36 else36 else
37 {37 {
38 performzoom (-step,38 zoom (-step,
39 -step,39 -step,
40 viewport[3] + step,40 viewport[3] + step,
41 viewport[3] + step); 41 viewport[3] + step);
42 }42 }
4343
44 return;44 return;
diff --git a/src/controller/mousewheel.h b/src/controller/callbacks/mouse_wheel.h
index a3944d0..8f6a57d 100644
--- a/src/controller/mousewheel.h
+++ b/src/controller/callbacks/mouse_wheel.h
@@ -1,11 +1,11 @@
1#ifndef MOUSEWHEEL_H1#ifndef MOUSE_WHEEL_H
2#define MOUSEWHEEL_H2#define MOUSE_WHEEL_H
33
4/*4/*
5 * GLUT callback to be called whenever the scroll wheel is scrolled.5 * GLUT callback to be called whenever the scroll wheel is scrolled.
6 * Based on code from Ashwin at6 * Based on code from Ashwin at
7 * http://stackoverflow.com/questions/14378/using-the-mouse-scrollwheel-in-glut/14444.7 * http://stackoverflow.com/questions/14378/using-the-mouse-scrollwheel-in-glut/14444.
8 */8 */
9void mousewheel (int, int, int, int);9void mouse_wheel (int, int, int, int);
1010
11#endif // MOUSEWHEEL_H11#endif // MOUSE_WHEEL_H
diff --git a/src/controller/exp004reshape.c b/src/controller/callbacks/reshape.c
index a127e46..da2e2bf 100644
--- a/src/controller/exp004reshape.c
+++ b/src/controller/callbacks/reshape.c
@@ -1,13 +1,13 @@
1#include "exp004reshape.h"1#include "../../model/geometry/density_legend_geometry.h"
2#include "set_ortho.h"2#include "../../view/exp004state0.h"
3#include "../view/exp004state0.h"3#include "../actions/set_ortho.h"
4#include "../model/geometry/density_legend_geometry.h"4#include "reshape.h"
5#include <GL/glut.h>5#include <GL/glut.h>
66
7#define S exp004state07#define S exp004state0
88
9void9void
10exp004reshape (int w, int h)10reshape (int w, int h)
11{11{
12 glMatrixMode (GL_PROJECTION);12 glMatrixMode (GL_PROJECTION);
13 glLoadIdentity ();13 glLoadIdentity ();
diff --git a/src/controller/callbacks/reshape.h b/src/controller/callbacks/reshape.h
new file mode 100644
index 0000000..8a829b4
--- a/dev/null
+++ b/src/controller/callbacks/reshape.h
@@ -0,0 +1,6 @@
1#ifndef RESHAPE_H
2#define RESHAPE_H
3
4void reshape (int w, int h);
5
6#endif // RESHAPE_H
diff --git a/src/controller/exp004display.h b/src/controller/exp004display.h
deleted file mode 100644
index 6a5f9f7..0000000
--- a/src/controller/exp004display.h
+++ b/dev/null
@@ -1,6 +0,0 @@
1#ifndef EXP004DISPLAY_H
2#define EXP004DISPLAY_H
3
4void exp004display (void);
5
6#endif // EXP004DISPLAY_H
diff --git a/src/controller/exp004mouse.h b/src/controller/exp004mouse.h
deleted file mode 100644
index a6809be..0000000
--- a/src/controller/exp004mouse.h
+++ b/dev/null
@@ -1,6 +0,0 @@
1#ifndef EXP004MOUSE_H
2#define EXP004MOUSE_H
3
4void exp004mouse (int button, int state, int x, int y);
5
6#endif // EXP004MOUSE_H
diff --git a/src/controller/exp004processhits.h b/src/controller/exp004processhits.h
deleted file mode 100644
index 0cc9e4b..0000000
--- a/src/controller/exp004processhits.h
+++ b/dev/null
@@ -1,8 +0,0 @@
1#ifndef EXP004PROCESSHITS_H
2#define EXP004PROCESSHITS_H
3
4#include <GL/glut.h>
5
6void exp004processhits (const GLint hits, const GLuint * hitlist);
7
8#endif // EXP004PROCESSHITS_H
diff --git a/src/controller/exp004reshape.h b/src/controller/exp004reshape.h
deleted file mode 100644
index 3bb20a5..0000000
--- a/src/controller/exp004reshape.h
+++ b/dev/null
@@ -1,6 +0,0 @@
1#ifndef EXP004RESHAPE_H
2#define EXP004RESHAPE_H
3
4void exp004reshape (int w, int h);
5
6#endif // EXP004RESHAPE_H
diff --git a/src/controller/performzoom.h b/src/controller/performzoom.h
deleted file mode 100644
index 323cc20..0000000
--- a/src/controller/performzoom.h
+++ b/dev/null
@@ -1,9 +0,0 @@
1#ifndef PERFORMZOOM_H
2#define PERFORMZOOM_H
3
4/*
5 * Perform a zoom operation.
6 */
7void performzoom (int x1, int y1, int x2, int y2);
8
9#endif // PERFORMZOOM_H
diff --git a/src/controller/selsave.h b/src/controller/selsave.h
deleted file mode 100644
index f5b8fa7..0000000
--- a/src/controller/selsave.h
+++ b/dev/null
@@ -1,9 +0,0 @@
1#ifndef SELSAVE_H
2#define SELSAVE_H
3
4/*
5 * Send the current selection from memory to the database.
6 */
7void selsave (void);
8
9#endif // SELSAVE_H
diff --git a/src/controller/set_ortho.c b/src/controller/set_ortho.c
deleted file mode 100644
index 6478d21..0000000
--- a/src/controller/set_ortho.c
+++ b/dev/null
@@ -1,21 +0,0 @@
1#include "set_ortho.h"
2#include "../view/exp004state0.h"
3#include <GL/glut.h>
4
5#define S exp004state0
6
7void
8set_ortho (void)
9{
10 if (S.zoom.active)
11 {
12 gluOrtho2D (S.zoom.coords[0],
13 S.zoom.coords[1], S.zoom.coords[2], S.zoom.coords[3]);
14 }
15 else
16 {
17 gluOrtho2D (S.ortho.min_x, S.ortho.max_x, S.ortho.min_y, S.ortho.max_y);
18 }
19
20 return;
21}
diff --git a/src/model/geometry/density_legend_geometry.c b/src/model/geometry/density_legend_geometry.c
index 83f34d9..ed34b8d 100644
--- a/src/model/geometry/density_legend_geometry.c
+++ b/src/model/geometry/density_legend_geometry.c
@@ -1,6 +1,6 @@
1#include "density_legend_geometry.h"1#include "../../controller/callbacks/reshape.h"
2#include "../../view/exp004state0.h"2#include "../../view/exp004state0.h"
3#include "../../controller/exp004reshape.h"3#include "density_legend_geometry.h"
4#include <GL/glut.h>4#include <GL/glut.h>
55
6#define S exp004state06#define S exp004state0
diff --git a/src/view/exp004view.c b/src/view/exp004view.c
index 434c016..b16597d 100644
--- a/src/view/exp004view.c
+++ b/src/view/exp004view.c
@@ -1,8 +1,8 @@
1#include "../controller/exp004display.h"1#include "../controller/callbacks/display.h"
2#include "../controller/exp004mouse.h"2#include "../controller/callbacks/keyboard.h"
3#include "../controller/exp004reshape.h"3#include "../controller/callbacks/mouse.h"
4#include "../controller/keyboard.h"4#include "../controller/callbacks/mouse_wheel.h"
5#include "../controller/mousewheel.h"5#include "../controller/callbacks/reshape.h"
6#include "../db/dbconnect.h"6#include "../db/dbconnect.h"
7#include "exp004init.h"7#include "exp004init.h"
8#include "exp004state0.h"8#include "exp004state0.h"
@@ -44,12 +44,12 @@ exp004view (void)
44 // Initialize the model.44 // Initialize the model.
45 exp004init ();45 exp004init ();
4646
47 // Callbacks (Controllers)47 // Callbacks
48 glutDisplayFunc (exp004display);48 glutDisplayFunc (display);
49 glutKeyboardFunc (keyboard);49 glutKeyboardFunc (keyboard);
50 glutMouseFunc (exp004mouse);50 glutMouseFunc (mouse);
51 glutMouseWheelFunc (mousewheel);51 glutMouseWheelFunc (mouse_wheel);
52 glutReshapeFunc (exp004reshape);52 glutReshapeFunc (reshape);
5353
54 return;54 return;
55}55}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.