diff options
-rw-r--r-- | src/control.h | 1 | ||||
-rw-r--r-- | src/displaywindow.c | 64 | ||||
-rw-r--r-- | src/displaywindow.h | 45 | ||||
-rw-r--r-- | src/ipr.c | 7 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/reflections.c | 31 | ||||
-rw-r--r-- | src/reflections.h | 1 | ||||
-rw-r--r-- | src/reproject.c | 2 |
8 files changed, 108 insertions, 45 deletions
diff --git a/src/control.h b/src/control.h index 3dc030c..cf3b8c4 100644 --- a/src/control.h +++ b/src/control.h @@ -110,6 +110,7 @@ typedef struct cctx_struct { /* Output */ struct rctx_struct *reflectionctx; + struct dw_struct *dw; /* GTK bits */ GtkWidget *combo_algorithm; diff --git a/src/displaywindow.c b/src/displaywindow.c index d2afb67..64a4c41 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -29,50 +29,13 @@ #include "reflections.h" #include "main.h" #include "ipr.h" +#include "displaywindow.h" enum { DW_ORTHO, DW_PERSPECTIVE }; -typedef struct { - - ControlContext *ctx; - - GtkUIManager *ui; - GtkActionGroup *action_group; - GtkWidget *window; - GtkWidget *bigvbox; - GtkWidget *status_bar; - int view; - GtkWidget *drawing_area; - - /* OpenGL stuff */ - GLfloat distance; - GLfloat x_pos; - GLfloat y_pos; - float x_start; - float y_start; - float view_quat[4]; - int fog; - GLuint gl_list_id; /* Display list for "everything else" */ - int gl_use_buffers; /* 0=use vertex arrays only, otherwise use VBOs */ - GLuint gl_ref_vertex_buffer; /* "Measured reflection" stuff */ - GLfloat *gl_ref_vertex_array; - GLsizei gl_ref_num_vertices; - GLuint gl_marker_vertex_buffer; /* Marker "reflection" stuff */ - GLuint gl_marker_normal_buffer; - GLfloat *gl_marker_vertex_array; - GLfloat *gl_marker_normal_array; - GLsizei gl_marker_num_vertices; - GLuint gl_gen_vertex_buffer; /* Generated reflection stuff */ - GLuint gl_gen_normal_buffer; - GLfloat *gl_gen_vertex_array; - GLfloat *gl_gen_normal_array; - GLsizei gl_gen_num_vertices; - -} DisplayWindow; - static void displaywindow_about() { GtkWidget *window; @@ -810,7 +773,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { dw->view_quat[2] = 0.0; dw->view_quat[3] = 1.0; dw->ctx = ctx; - dw->fog = 1; + dw->fog = 0; dw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(dw->window), title); @@ -850,3 +813,26 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { } +void displaywindow_update(DisplayWindow *dw) { + + if ( dw->gl_use_buffers ) { + glDeleteBuffersARB(1, &dw->gl_ref_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_marker_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_marker_normal_buffer); + glDeleteBuffersARB(1, &dw->gl_gen_vertex_buffer); + glDeleteBuffersARB(1, &dw->gl_gen_normal_buffer); + } else { + free(dw->gl_ref_vertex_array); + free(dw->gl_marker_vertex_array); + free(dw->gl_marker_normal_array); + free(dw->gl_gen_vertex_array); + free(dw->gl_gen_normal_array); + } + glDeleteLists(dw->gl_list_id, 1); + + displaywindow_gl_create_list(dw); + + gdk_window_invalidate_rect(dw->drawing_area->window, &dw->drawing_area->allocation, FALSE); + +} + diff --git a/src/displaywindow.h b/src/displaywindow.h index 3d20d4b..8c4e388 100644 --- a/src/displaywindow.h +++ b/src/displaywindow.h @@ -20,10 +20,47 @@ #include "control.h" -extern GtkWidget *displaywindow_gtkwindow(void); -extern void displaywindow_open(ControlContext *ctx); -extern void displaywindow_statusbar(const char *message); -extern void error_report(const char *message); +typedef struct dw_struct { + + ControlContext *ctx; + + GtkUIManager *ui; + GtkActionGroup *action_group; + GtkWidget *window; + GtkWidget *bigvbox; + GtkWidget *status_bar; + int view; + GtkWidget *drawing_area; + + /* OpenGL stuff */ + GLfloat distance; + GLfloat x_pos; + GLfloat y_pos; + float x_start; + float y_start; + float view_quat[4]; + int fog; + GLuint gl_list_id; /* Display list for "everything else" */ + int gl_use_buffers; /* 0=use vertex arrays only, otherwise use VBOs */ + GLuint gl_ref_vertex_buffer; /* "Measured reflection" stuff */ + GLfloat *gl_ref_vertex_array; + GLsizei gl_ref_num_vertices; + GLuint gl_marker_vertex_buffer; /* Marker "reflection" stuff */ + GLuint gl_marker_normal_buffer; + GLfloat *gl_marker_vertex_array; + GLfloat *gl_marker_normal_array; + GLsizei gl_marker_num_vertices; + GLuint gl_gen_vertex_buffer; /* Generated reflection stuff */ + GLuint gl_gen_normal_buffer; + GLfloat *gl_gen_vertex_array; + GLfloat *gl_gen_normal_array; + GLsizei gl_gen_num_vertices; + +} DisplayWindow; + +extern DisplayWindow *displaywindow_open(ControlContext *ctx); + +extern void displaywindow_update(DisplayWindow *dw); #endif /* DISPLAYWINDOW_H */ @@ -24,6 +24,7 @@ #include "imagedisplay.h" #include "reproject.h" #include "ipr.h" +#include "displaywindow.h" static int ipr_choose_max(Basis *basis) { @@ -250,13 +251,17 @@ static gint ipr_clicked(GtkWidget *widget, GdkEventButton *event, ControlContext ctx->ipr_cur_image++; if ( ctx->ipr_cur_image == ctx->n_images ) ctx->ipr_cur_image = 0; - refl = reproject_get_reflections(ctx->images[ctx->ipr_cur_image], &n, ctx->ipr_lat, ctx); imagedisplay_clear_circles(ctx->ipr_id); + reflection_clear_markers(ctx->reflectionctx); + + ctx->images[ctx->ipr_cur_image].omega = 30; /* Temporary! */ + refl = reproject_get_reflections(ctx->images[ctx->ipr_cur_image], &n, ctx->ipr_lat, ctx); for ( j=0; j<n; j++ ) { imagedisplay_mark_circle(ctx->ipr_id, refl[j].x, refl[j].y); } imagedisplay_put_data(ctx->ipr_id, ctx->images[ctx->ipr_cur_image]); + displaywindow_update(ctx->dw); return 0; @@ -52,7 +52,7 @@ void main_do_reconstruction(ControlContext *ctx) { } if ( !val && (ctx->reflectionctx) ) { - displaywindow_open(ctx); + ctx->dw = displaywindow_open(ctx); } else { fprintf(stderr, "Reconstruction failed.\n"); gtk_exit(0); diff --git a/src/reflections.c b/src/reflections.c index a1a8267..ba68baa 100644 --- a/src/reflections.c +++ b/src/reflections.c @@ -44,6 +44,37 @@ ReflectionContext *reflection_init() { } +void reflection_clear_markers(ReflectionContext *reflectionctx) { + + Reflection *reflection = reflectionctx->reflections; + Reflection *prev = NULL; + int del = 0; + + do { + Reflection *next = reflection->next; + + if ( (reflection->type == REFLECTION_MARKER) || (reflection->type == REFLECTION_GENERATED) + || (reflection->type == REFLECTION_VECTOR_MARKER_1) || (reflection->type == REFLECTION_VECTOR_MARKER_2) + || (reflection->type == REFLECTION_VECTOR_MARKER_3) ) { + free(reflection); + del++; + if ( prev ) { + prev->next = next; + } else { + reflectionctx->reflections = next; + } + } else { + prev = reflection; + } + + reflection = next; + + } while ( reflection ); + + reflectionctx->n_reflections -= del; + reflectionctx->last_reflection = prev; + +} void reflection_clear(ReflectionContext *reflectionctx) { Reflection *reflection = reflectionctx->reflections; diff --git a/src/reflections.h b/src/reflections.h index 0eade3a..253a110 100644 --- a/src/reflections.h +++ b/src/reflections.h @@ -55,6 +55,7 @@ typedef struct rctx_struct { extern ReflectionContext *reflection_init(void); extern void reflection_clear(ReflectionContext *reflectionctx); +extern void reflection_clear_markers(ReflectionContext *reflectionctx); extern void reflection_free(ReflectionContext *reflectionctx); extern Reflection *reflection_add(ReflectionContext *reflectionctx, double x, double y, double z, double intensity, ReflectionType type); diff --git a/src/reproject.c b/src/reproject.c index ffd49b9..4f0dd3c 100644 --- a/src/reproject.c +++ b/src/reproject.c @@ -103,6 +103,8 @@ ImageReflection *reproject_get_reflections(ImageRecord image, size_t *n, Reflect uyt = cos(tilt); uzt = -sin(tilt); /* tilt it (uxt not needed) */ ux = uyt*-sin(omega); uy = uyt*cos(omega); uz = uzt; /* rotate it */ + if ( i == 0 ) reflection_add(ctx->reflectionctx, ux*50, uy*50, uz*50, 1, REFLECTION_VECTOR_MARKER_2); + /* Calculate azimuth of point in image (clockwise from "up", will be changed later) */ cx = nz*yi - ny*zi; cy = nx*zi - nz*xi; cz = ny*xi - nx*yi; /* c = (-n) x i */ psi = angle_between(cx, cy, cz, ux, uy, uz); |