aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-09-09 21:48:04 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-09-09 21:48:04 +0000
commitf56159b7936b041fa5093b35f0d25de7fabe6487 (patch)
tree27ab8a1e4fff244b5e83eefabe083d01284371cc /src
parente3a4cc7fcaa71c1954394fc4bdee90e3bcc38502 (diff)
Cosmetic alterations
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@129 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'src')
-rw-r--r--src/displaywindow.c46
-rw-r--r--src/ipr.c14
-rw-r--r--src/mapping.c2
3 files changed, 37 insertions, 25 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index a1e2a1a..4ab7d23 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -79,10 +79,10 @@ static void displaywindow_gl_set_ortho(DisplayWindow *dw, GLfloat w, GLfloat h)
glLoadIdentity();
if ( w > h ) {
GLfloat aspect = w/h;
- glOrtho(-aspect*(dw->distance/2), aspect*(dw->distance/2), -(dw->distance/2), (dw->distance/2), 0.01, 1000.0);
+ glOrtho(-aspect*(dw->distance/2.0), aspect*(dw->distance/2.0), -(dw->distance/2.0), (dw->distance/2.0), 1.0, 400.0);
} else {
GLfloat aspect = h/w;
- glOrtho(-(dw->distance/2), (dw->distance/2), -aspect*(dw->distance/2), aspect*(dw->distance/2), 0.01, 1000.0);
+ glOrtho(-(dw->distance/2.0), (dw->distance/2.0), -aspect*(dw->distance/2.0), aspect*(dw->distance/2.0), 1.0, 400.0);
}
glMatrixMode(GL_MODELVIEW);
@@ -90,15 +90,20 @@ static void displaywindow_gl_set_ortho(DisplayWindow *dw, GLfloat w, GLfloat h)
static void displaywindow_gl_set_perspective(DisplayWindow *dw, GLfloat w, GLfloat h) {
+ GLfloat d;
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if ( w > h ) {
- GLfloat aspect = w/h;
- glFrustum(-aspect, aspect, -1.0, 1.0, 10.0, 1000.0);
+
+ /* If zoomed a long way out, the model will be moved back rather than
+ * changing the projection matrix. This avoids getting a "fisheye" view */
+ if ( dw->distance/4.0 < 50.0 ) {
+ d = dw->distance/4.0;
} else {
- GLfloat aspect = h/w;
- glFrustum(-1.0, 1.0, -aspect, aspect, 10.0, 1000.0);
+ d = 50.0;
}
+
+ gluPerspective(d, w/h, 1.0, 400.0);
glMatrixMode(GL_MODELVIEW);
}
@@ -217,8 +222,12 @@ static gint displaywindow_gl_motion_notify(GtkWidget *widget, GdkEventMotion *ev
/* Control-click changes 'zoom' */
dw->distance += event->y - dw->y_start;
+ if ( dw->distance < 1.0 ) dw->distance = 1.0;
+ if ( dw->distance > 310.0 ) dw->distance = 310.0;
if ( dw->view == DW_ORTHO ) {
displaywindow_gl_set_ortho(dw, w, h);
+ } else {
+ displaywindow_gl_set_perspective(dw, w, h);
}
} else if ( event->state & GDK_SHIFT_MASK ) {
@@ -497,13 +506,13 @@ static void displaywindow_gl_create_list(DisplayWindow *dw) {
* Since the rotation is about +z, this is already anticlockwise
* when looking down z. */
glRotatef(ctx->images[0].omega, 0.0, 0.0, 1.0);
- glPolygonOffset(1.0, 1.0);
- glEnable(GL_POLYGON_OFFSET_LINE);
+// glPolygonOffset(1.0, 1.0);
+// glEnable(GL_POLYGON_OFFSET_LINE);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, yellow);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0);
DRAW_POINTER
- glDisable(GL_POLYGON_OFFSET_LINE);
+// glDisable(GL_POLYGON_OFFSET_LINE);
glPopMatrix();
/* Plot the other reflections */
@@ -662,15 +671,17 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di
return 0;
}
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- /* NB The virtual trackball works by rotating the objects, not the viewer.
- * i.e. it operates on the ModelView matrix, not the Projection matrix.
+ /* NB Camera position is in the ModelView matrix, not the Projection matrix.
* Therefore, multiply the current ModelView by whatever transformations
* are required, pushing/popping as appropriate. Don't do glLoadIdentity(). */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(dw->x_pos, -dw->y_pos, -dw->distance);
+ glTranslatef(dw->x_pos, -dw->y_pos, -100.0);
+ /* If zoomed a long way out, move the model back rather than
+ * changing the projection matrix. This avoids getting a "fisheye" view */
+ if ( dw->distance > 100.0 ) glTranslatef(dw->x_pos, -dw->y_pos, -(dw->distance-100.0));
build_rotmatrix(m, dw->view_quat);
glMultMatrixf(&m[0][0]);
@@ -708,8 +719,8 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
glMaterialfv(GL_FRONT, GL_SPECULAR, blue_spec);
glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
- glPolygonOffset(1.0, 1.0);
- glEnable(GL_POLYGON_OFFSET_FILL);
+// glPolygonOffset(1.0, 1.0);
+// glEnable(GL_POLYGON_OFFSET_FILL);
if ( dw->gl_use_buffers ) {
glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_vertex_buffer);
glVertexPointer(3, GL_FLOAT, 0, NULL);
@@ -721,7 +732,7 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di
glNormalPointer(GL_FLOAT, 0, dw->gl_marker_normal_array);
glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices);
}
- glDisable(GL_POLYGON_OFFSET_FILL);
+// glDisable(GL_POLYGON_OFFSET_FILL);
glPopClientAttrib();
/* Draw generated reflections */
@@ -799,6 +810,7 @@ static gboolean displaywindow_gl_configure(GtkWidget *widget, GdkEventConfigure
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
/* Nudge the projection matrix routines to preserve the aspect ratio */
if ( dw->view == DW_ORTHO ) {
diff --git a/src/ipr.c b/src/ipr.c
index aa55bd5..f12fb67 100644
--- a/src/ipr.c
+++ b/src/ipr.c
@@ -133,6 +133,7 @@ static Basis *ipr_choose_random_basis(ControlContext *ctx) {
basis = malloc(sizeof(Basis));
+restart:
basis->a.x = 0; basis->a.y = 0; basis->a.z = 0; basis->a.modulus = 1e30;
basis->b.x = 0; basis->b.y = 0; basis->b.z = 0; basis->b.modulus = 1e30;
basis->c.x = 0; basis->c.y = 0; basis->c.z = 0; basis->c.modulus = 1e30;
@@ -188,9 +189,7 @@ static Basis *ipr_choose_random_basis(ControlContext *ctx) {
/* End of list? */
if ( !reflection ) {
if ( (basis->a.modulus == 1e30) || (basis->b.modulus == 1e30) || (basis->c.modulus == 1e30) ) {
- //printf("IP: Failed to find appropriate starting basis!\n");
- free(basis);
- return NULL;
+ goto restart; /* Probably the one circumstance under which this is allowed... */
}
}
@@ -271,20 +270,18 @@ static Basis *ipr_choose_initial_basis(ControlContext *ctx) {
best_basis = NULL; best_efom = 0;
printf("IP: Finding initial basis using eFOM...\n");
- for ( i=1; i<=1000; i++ ) {
+ for ( i=1; i<=30; i++ ) {
double efom;
- do {
- basis = ipr_choose_random_basis(ctx);
- } while ( !basis );
+ basis = ipr_choose_random_basis(ctx);
efom = ipr_efom(ctx->reflectionctx, basis);
if ( (efom > best_efom) || !best_basis ) {
if ( best_basis ) free(best_basis);
best_efom = efom;
best_basis = basis;
- printf("IP: %3i: eFOM = %f %%\n", i, efom*100);
+ printf("IP: %3i: eFOM = %7.3f %%\n", i, efom*100);
}
@@ -388,6 +385,7 @@ int ipr_refine(ControlContext *ctx) {
ctx->ipr_basis = basis;
ctx->ipr_lat = ipr_generate(ctx, basis);
+ printf("IP: Performing refinement...\n");
finished = 0;
do {
diff --git a/src/mapping.c b/src/mapping.c
index 0990f81..251c804 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -27,10 +27,12 @@ ReflectionContext *mapping_create(ControlContext *ctx) {
/* Pass all images through itrans
* (let itrans add the reflections to rctx for now) */
+ printf("MP: Processing images..."); fflush(stdout);
ctx->reflectionctx = rctx;
for ( i=0; i<ctx->n_images; i++ ) {
itrans_process_image(ctx->images[i], ctx);
}
+ printf("done\n");
return rctx;