From b86df90147691912d48a1e9a0108cb07c306a6ed Mon Sep 17 00:00:00 2001 From: taw27 Date: Wed, 3 Oct 2007 14:26:37 +0000 Subject: Make the cube optional, remove fog option git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@147 bf6ca9ba-c028-0410-8290-897cf20841d1 --- src/displaywindow.c | 114 +++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 64 deletions(-) (limited to 'src/displaywindow.c') diff --git a/src/displaywindow.c b/src/displaywindow.c index 2dddbae..4c7771a 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -139,24 +139,10 @@ static gint displaywindow_changeview(GtkWidget *widget, GtkRadioAction *action, } -static gint displaywindow_changefog(GtkWidget *widget, DisplayWindow *dw) { +static gint displaywindow_changecube(GtkWidget *widget, DisplayWindow *dw) { - GdkGLContext *glcontext; - GdkGLDrawable *gldrawable; - - glcontext = gtk_widget_get_gl_context(dw->drawing_area); - gldrawable = gtk_widget_get_gl_drawable(dw->drawing_area); - - dw->fog = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(widget)); - if ( !gdk_gl_drawable_gl_begin(gldrawable, glcontext) ) { - return 1; - } - if ( dw->fog ) { - glEnable(GL_FOG); - } else { - glDisable(GL_FOG); - } - gdk_gl_drawable_gl_end(gldrawable); + dw->cube = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(widget)); + displaywindow_update(dw); return 0; } @@ -197,7 +183,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw) { }; guint n_radios = G_N_ELEMENTS(radios); GtkToggleActionEntry toggles[] = { - { "FogAction", NULL, "_Fog", NULL, NULL, G_CALLBACK(displaywindow_changefog), FALSE }, + { "CubeAction", NULL, "100 nm^-1 _cube", "C", NULL, G_CALLBACK(displaywindow_changecube), TRUE }, }; guint n_toggles = G_N_ELEMENTS(toggles); @@ -479,49 +465,51 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) { glNewList(dw->gl_list_id, GL_COMPILE); /* Bounding cube: 100 nm^-1 side length */ - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue); - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0); - glBegin(GL_LINE_LOOP); - glNormal3f(50.0, 50.0, 50.0); - glVertex3f(50.0, 50.0, 50.0); - glNormal3f(-50.0, 50.0, 50.0); - glVertex3f(-50.0, 50.0, 50.0); - glNormal3f(-50.0, -50.0, 50.0); - glVertex3f(-50.0, -50.0, 50.0); - glNormal3f(50.0, -50.0, 50.0); - glVertex3f(50.0, -50.0, 50.0); - - glEnd(); - glBegin(GL_LINE_LOOP); - glNormal3f(50.0, 50.0, -50.0); - glVertex3f(50.0, 50.0, -50.0); - glNormal3f(-50.0, 50.0, -50.0); - glVertex3f(-50.0, 50.0, -50.0); - glNormal3f(-50.0, -50.0, -50.0); - glVertex3f(-50.0, -50.0, -50.0); - glNormal3f(50.0, -50.0, -50.0); - glVertex3f(50.0, -50.0, -50.0); - glEnd(); - glBegin(GL_LINES); - glNormal3f(50.0, 50.0, 50.0); - glVertex3f(50.0, 50.0, 50.0); - glNormal3f(50.0, 50.0, -50.0); - glVertex3f(50.0, 50.0, -50.0); - glNormal3f(-50.0, 50.0, 50.0); - glVertex3f(-50.0, 50.0, 50.0); - glNormal3f(-50.0, 50.0, -50.0); - glVertex3f(-50.0, 50.0, -50.0); - glNormal3f(-50.0, -50.0, 50.0); - glVertex3f(-50.0, -50.0, 50.0); - glNormal3f(-50.0, -50.0, -50.0); - glVertex3f(-50.0, -50.0, -50.0); - glNormal3f(50.0, -50.0, 50.0); - glVertex3f(50.0, -50.0, 50.0); - glNormal3f(50.0, -50.0, -50.0); - glVertex3f(50.0, -50.0, -50.0); - glEnd(); + if ( dw->cube ) { + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0); + glBegin(GL_LINE_LOOP); + glNormal3f(50.0, 50.0, 50.0); + glVertex3f(50.0, 50.0, 50.0); + glNormal3f(-50.0, 50.0, 50.0); + glVertex3f(-50.0, 50.0, 50.0); + glNormal3f(-50.0, -50.0, 50.0); + glVertex3f(-50.0, -50.0, 50.0); + glNormal3f(50.0, -50.0, 50.0); + glVertex3f(50.0, -50.0, 50.0); + + glEnd(); + glBegin(GL_LINE_LOOP); + glNormal3f(50.0, 50.0, -50.0); + glVertex3f(50.0, 50.0, -50.0); + glNormal3f(-50.0, 50.0, -50.0); + glVertex3f(-50.0, 50.0, -50.0); + glNormal3f(-50.0, -50.0, -50.0); + glVertex3f(-50.0, -50.0, -50.0); + glNormal3f(50.0, -50.0, -50.0); + glVertex3f(50.0, -50.0, -50.0); + glEnd(); + glBegin(GL_LINES); + glNormal3f(50.0, 50.0, 50.0); + glVertex3f(50.0, 50.0, 50.0); + glNormal3f(50.0, 50.0, -50.0); + glVertex3f(50.0, 50.0, -50.0); + glNormal3f(-50.0, 50.0, 50.0); + glVertex3f(-50.0, 50.0, 50.0); + glNormal3f(-50.0, 50.0, -50.0); + glVertex3f(-50.0, 50.0, -50.0); + glNormal3f(-50.0, -50.0, 50.0); + glVertex3f(-50.0, -50.0, 50.0); + glNormal3f(-50.0, -50.0, -50.0); + glVertex3f(-50.0, -50.0, -50.0); + glNormal3f(50.0, -50.0, 50.0); + glVertex3f(50.0, -50.0, 50.0); + glNormal3f(50.0, -50.0, -50.0); + glVertex3f(50.0, -50.0, -50.0); + glEnd(); + } /* x, y, z pointers */ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); @@ -841,8 +829,6 @@ static gboolean displaywindow_gl_configure(GtkWidget *widget, GdkEventConfigure glViewport(0, 0, w, h); glEnable(GL_DEPTH_TEST); - if ( dw->fog ) glEnable(GL_FOG); - glFogf(GL_FOG_DENSITY, 0.005); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel(GL_SMOOTH); @@ -911,7 +897,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) { dw->view_quat[2] = 0.0; dw->view_quat[3] = 1.0; dw->ctx = ctx; - dw->fog = 0; + dw->cube = TRUE; dw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(dw->window), title); -- cgit v1.2.3