aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--data/displaywindow.ui8
-rw-r--r--src/Makefile.am2
-rw-r--r--src/control.c1
-rw-r--r--src/control.h3
-rw-r--r--src/displaywindow.c271
-rw-r--r--src/displaywindow.h8
-rw-r--r--src/intensities.c109
-rw-r--r--src/intensities.h24
-rw-r--r--src/reproject.c3
10 files changed, 310 insertions, 121 deletions
diff --git a/Makefile.am b/Makefile.am
index a0214f9..0c1d4bb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
EXTRA_DIST = configure src/displaywindow.h src/trackball.h src/reflections.h src/control.h src/readpng.h src/mrc.h src/imagedisplay.h src/main.h \
data/displaywindow.ui src/utils.h src/itrans.h src/qdrp.h src/cache.h src/itrans-threshold.h src/basis.h \
src/itrans-zaefferer.h src/itrans-stat.h src/mapping.h src/reproject.h src/prealign.h \
- src/dirax.h src/image.h src/refine.h src/gtk-valuegraph.h
+ src/dirax.h src/image.h src/refine.h src/gtk-valuegraph.h src/intensities.h
SUBDIRS = src data
diff --git a/data/displaywindow.ui b/data/displaywindow.ui
index 2c7e745..ceffd94 100644
--- a/data/displaywindow.ui
+++ b/data/displaywindow.ui
@@ -11,6 +11,9 @@
<menuitem name="ortho" action="OrthoAction" />
<menuitem name="perspective" action="PerspectiveAction" />
<separator />
+ <menuitem name="mapped" action="MappedAction" />
+ <menuitem name="measured" action="MeasuredAction" />
+ <separator />
<menuitem name="cube" action="CubeAction" />
<menuitem name="lines" action="LinesAction" />
<menuitem name="background" action="BackgroundAction" />
@@ -27,6 +30,9 @@
<menuitem name="setaxis" action="SetAxisAction" />
<menuitem name="incraxis" action="IncrAxisAction" />
<menuitem name="decraxis" action="DecrAxisAction" />
+ <separator />
+ <menuitem name="extractintensities" action="ExtractIntensitiesAction" />
+
</menu>
<menu name="help" action="HelpAction">
@@ -47,6 +53,8 @@
<separator />
<toolitem name="refinestep" action="ButtonRefineStepAction" />
<toolitem name="refineseq" action="ButtonRefineSeqAction" />
+ <separator />
+ <toolitem name="extractintensities" action="ExtractIntensitiesAction" />
</toolbar>
diff --git a/src/Makefile.am b/src/Makefile.am
index c9d4dd9..b303a24 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
bin_PROGRAMS = dtr
dtr_SOURCES = main.c displaywindow.c trackball.c reflections.c readpng.c mrc.c imagedisplay.c utils.c itrans.c qdrp.c cache.c \
itrans-threshold.c itrans-zaefferer.c itrans-stat.c control.c mapping.c reproject.c prealign.c basis.c \
- dirax.c image.c refine.c gtk-valuegraph.c
+ dirax.c image.c refine.c gtk-valuegraph.c intensities.c
dtr_LDADD = @LIBS@ @GTK_LIBS@ -lm @GTKGLEXT_LIBS@ -lgsl -lgslcblas -lutil
AM_CFLAGS = -Wall -g @CFLAGS@ @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@
AM_CPPFLAGS = -DDATADIR=\""$(datadir)"\"
diff --git a/src/control.c b/src/control.c
index 5c66713..b822457 100644
--- a/src/control.c
+++ b/src/control.c
@@ -31,6 +31,7 @@ ControlContext *control_ctx_new() {
ctx->reflectionlist = NULL;
ctx->refine_window = NULL;
ctx->cell_lattice = NULL;
+ ctx->integrated = NULL;
return ctx;
diff --git a/src/control.h b/src/control.h
index c6e1306..e5bde09 100644
--- a/src/control.h
+++ b/src/control.h
@@ -78,10 +78,11 @@ typedef struct cctx_struct {
struct imagelist_struct *images;
/* "Output" */
- struct reflectionlist_struct *reflectionlist; /* Measured reflections (and stuff added to get displayed) */
+ struct reflectionlist_struct *reflectionlist; /* Measured reflections (and stuff added to get displayed with them) */
struct dw_struct *dw;
struct basis_struct *cell; /* Current estimate of the reciprocal unit cell */
struct reflectionlist_struct *cell_lattice; /* Reflections calculated from 'cell' */
+ struct reflectionlist_struct *integrated; /* "Final" integrated intensities */
/* GTK bits */
GtkWidget *combo_peaksearch;
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 9769a07..4eef09e 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -36,6 +36,7 @@
#include "mapping.h"
#include "refine.h"
#include "imagedisplay.h"
+#include "intensities.h"
static void displaywindow_gl_set_ortho(DisplayWindow *dw, GLfloat w, GLfloat h) {
@@ -73,6 +74,14 @@ static gint displaywindow_changeview(GtkWidget *widget, GtkRadioAction *action,
}
+static gint displaywindow_changemode(GtkWidget *widget, GtkRadioAction *action, DisplayWindow *dw) {
+
+ dw->mode = gtk_radio_action_get_current_value(action);
+ displaywindow_update(dw);
+
+ return 0;
+
+}
static gboolean displaywindow_gl_button_press(GtkWidget *widget, GdkEventButton *event, DisplayWindow *dw) {
dw->x_start = event->x;
dw->y_start = event->y;
@@ -134,7 +143,6 @@ static gint displaywindow_gl_motion_notify(GtkWidget *widget, GdkEventMotion *ev
#define DRAW_BLOB \
double step = M_PI/(double)BLOB_BITS; \
- double size = 0.15; \
int is, js; \
for ( is=0; is<BLOB_BITS; is++ ) { \
for ( js=0; js<BLOB_BITS*2; js++ ) { \
@@ -264,6 +272,7 @@ static void displaywindow_gl_prepare(DisplayWindow *dw) {
normals = malloc(3*dw->gl_marker_num_vertices*sizeof(GLfloat));
while ( reflection != NULL ) {
if ( reflection->type == REFLECTION_MARKER ) {
+ double size = 0.15;
DRAW_BLOB
}
reflection = reflection->next;
@@ -286,36 +295,39 @@ static void displaywindow_gl_prepare(DisplayWindow *dw) {
glGenBuffersARB(1, &dw->gl_gen_vertex_buffer);
glGenBuffersARB(1, &dw->gl_gen_normal_buffer);
}
- reflection = ctx->reflectionlist->reflections;
- i = 0;
- while ( reflection != NULL ) {
- if ( reflection->type == REFLECTION_GENERATED ) i++;
- reflection = reflection->next;
- };
- dw->gl_gen_num_vertices = i*VERTICES_IN_A_BLOB;
- if ( dw->gl_gen_num_vertices ) {
+ if ( ctx->integrated != NULL ) {
+ reflection = ctx->integrated->reflections;
i = 0;
- reflection = ctx->reflectionlist->reflections;
- vertices = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat));
- normals = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat));
while ( reflection != NULL ) {
- if ( reflection->type == REFLECTION_GENERATED ) {
+ if ( reflection->type == REFLECTION_GENERATED ) i++;
+ reflection = reflection->next;
+ };
+ dw->gl_gen_num_vertices = i*VERTICES_IN_A_BLOB;
+ if ( dw->gl_gen_num_vertices ) {
+ i = 0;
+ reflection = ctx->integrated->reflections;
+ vertices = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat));
+ normals = malloc(3*dw->gl_gen_num_vertices*sizeof(GLfloat));
+ while ( reflection != NULL ) {
+ double size = 5.0 * log(1+0.1*reflection->intensity);
DRAW_BLOB
+ reflection = reflection->next;
+ };
+ if ( dw->gl_use_buffers ) {
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer);
+ glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
+ free(vertices);
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer);
+ glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW);
+ free(normals);
+ glBindBufferARB(GL_ARRAY_BUFFER, 0); /* ************* */
+ } else {
+ dw->gl_gen_vertex_array = vertices;
+ dw->gl_gen_normal_array = normals;
}
- reflection = reflection->next;
- };
- if ( dw->gl_use_buffers ) {
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer);
- glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
- free(vertices);
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer);
- glBufferDataARB(GL_ARRAY_BUFFER, 3*dw->gl_gen_num_vertices*sizeof(GLfloat), normals, GL_STATIC_DRAW);
- free(normals);
- glBindBufferARB(GL_ARRAY_BUFFER, 0); /* ************* */
- } else {
- dw->gl_gen_vertex_array = vertices;
- dw->gl_gen_normal_array = normals;
}
+ } else {
+ dw->gl_gen_num_vertices = 0;
}
/* Indexing lines */
@@ -709,98 +721,104 @@ static gint displaywindow_gl_expose(GtkWidget *widget, GdkEventExpose *event, Di
build_rotmatrix(m, dw->view_quat);
glMultMatrixf(&m[0][0]);
- /* Draw the "measured" reflections */
- if ( dw->gl_ref_num_vertices ) {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, green);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, black);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0);
- if ( dw->gl_use_buffers ) {
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_vertex_buffer);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_normal_buffer);
- glNormalPointer(GL_FLOAT, 0, NULL);
- glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices);
- glBindBufferARB(GL_ARRAY_BUFFER, 0);
- } else {
- glVertexPointer(3, GL_FLOAT, 0, dw->gl_ref_vertex_array);
- glNormalPointer(GL_FLOAT, 0, dw->gl_ref_normal_array);
- glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices);
+ if ( dw->mode == DW_MAPPED ) {
+
+ /* Draw the "measured" reflections */
+ if ( dw->gl_ref_num_vertices ) {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, green);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, black);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0);
+ if ( dw->gl_use_buffers ) {
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_vertex_buffer);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_ref_normal_buffer);
+ glNormalPointer(GL_FLOAT, 0, NULL);
+ glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices);
+ glBindBufferARB(GL_ARRAY_BUFFER, 0);
+ } else {
+ glVertexPointer(3, GL_FLOAT, 0, dw->gl_ref_vertex_array);
+ glNormalPointer(GL_FLOAT, 0, dw->gl_ref_normal_array);
+ glDrawArrays(GL_POINTS, 0, dw->gl_ref_num_vertices);
+ }
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glPopClientAttrib();
}
- glDisableClientState(GL_NORMAL_ARRAY);
- glPopClientAttrib();
- }
-
- /* Draw marker points */
- if ( dw->gl_marker_num_vertices ) {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- 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, blue_spec);
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0);
- if ( dw->gl_use_buffers ) {
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_vertex_buffer);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_normal_buffer);
- glNormalPointer(GL_FLOAT, 0, NULL);
- glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices);
- glBindBufferARB(GL_ARRAY_BUFFER, 0);
- } else {
- glVertexPointer(3, GL_FLOAT, 0, dw->gl_marker_vertex_array);
- glNormalPointer(GL_FLOAT, 0, dw->gl_marker_normal_array);
- glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices);
+
+ /* Draw marker points */
+ if ( dw->gl_marker_num_vertices ) {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ 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, blue_spec);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0);
+ if ( dw->gl_use_buffers ) {
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_vertex_buffer);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_marker_normal_buffer);
+ glNormalPointer(GL_FLOAT, 0, NULL);
+ glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices);
+ glBindBufferARB(GL_ARRAY_BUFFER, 0);
+ } else {
+ glVertexPointer(3, GL_FLOAT, 0, dw->gl_marker_vertex_array);
+ glNormalPointer(GL_FLOAT, 0, dw->gl_marker_normal_array);
+ glDrawArrays(GL_QUADS, 0, dw->gl_marker_num_vertices);
+ }
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glPopClientAttrib();
}
- glDisableClientState(GL_NORMAL_ARRAY);
- glPopClientAttrib();
- }
-
- /* Draw generated reflections */
- if ( dw->gl_gen_num_vertices ) {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_NORMAL_ARRAY);
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, gold);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, gold_spec);
- glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.0);
- if ( dw->gl_use_buffers ) {
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer);
- glNormalPointer(GL_FLOAT, 0, NULL);
- glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices);
- glBindBufferARB(GL_ARRAY_BUFFER, 0);
- } else {
- glVertexPointer(3, GL_FLOAT, 0, dw->gl_gen_vertex_array);
- glNormalPointer(GL_FLOAT, 0, dw->gl_gen_normal_array);
- glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices);
+
+ /* Draw indexing lines */
+ if ( dw->lines && dw->gl_line_num_vertices ) {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, grey);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, black);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
+ if ( dw->gl_use_buffers ) {
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_line_vertex_buffer);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+ glDrawArrays(GL_LINES, 0, dw->gl_line_num_vertices);
+ glBindBufferARB(GL_ARRAY_BUFFER, 0);
+ } else {
+ glVertexPointer(3, GL_FLOAT, 0, dw->gl_line_vertex_array);
+ glDrawArrays(GL_LINES, 0, dw->gl_line_num_vertices);
+ }
+ glPopClientAttrib();
}
- glDisableClientState(GL_NORMAL_ARRAY);
- glPopClientAttrib();
- }
- /* Draw indexing lines */
- if ( dw->lines && dw->gl_line_num_vertices ) {
- glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
- glEnableClientState(GL_VERTEX_ARRAY);
- glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, grey);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, black);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
- if ( dw->gl_use_buffers ) {
- glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_line_vertex_buffer);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
- glDrawArrays(GL_LINES, 0, dw->gl_line_num_vertices);
- glBindBufferARB(GL_ARRAY_BUFFER, 0);
- } else {
- glVertexPointer(3, GL_FLOAT, 0, dw->gl_line_vertex_array);
- glDrawArrays(GL_LINES, 0, dw->gl_line_num_vertices);
+ } else {
+
+ /* Draw generated reflections */
+ if ( dw->gl_gen_num_vertices ) {
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, gold);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, gold_spec);
+ glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.0);
+ if ( dw->gl_use_buffers ) {
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_vertex_buffer);
+ glVertexPointer(3, GL_FLOAT, 0, NULL);
+ glBindBufferARB(GL_ARRAY_BUFFER, dw->gl_gen_normal_buffer);
+ glNormalPointer(GL_FLOAT, 0, NULL);
+ glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices);
+ glBindBufferARB(GL_ARRAY_BUFFER, 0);
+ } else {
+ glVertexPointer(3, GL_FLOAT, 0, dw->gl_gen_vertex_array);
+ glNormalPointer(GL_FLOAT, 0, dw->gl_gen_normal_array);
+ glDrawArrays(GL_QUADS, 0, dw->gl_gen_num_vertices);
+ }
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glPopClientAttrib();
}
- glPopClientAttrib();
+
}
/* Draw everything else */
@@ -1130,6 +1148,12 @@ static gint displaywindow_refinestack(GtkWidget *widget, DisplayWindow *dw) {
return 0;
}
+static gint displaywindow_extract(GtkWidget *widget, DisplayWindow *dw) {
+ intensities_extract(dw->ctx);
+ displaywindow_update(dw);
+ return 0;
+}
+
static void displaywindow_addmenubar(DisplayWindow *dw) {
GtkActionEntry entries[] = {
@@ -1146,9 +1170,10 @@ static void displaywindow_addmenubar(DisplayWindow *dw) {
{ "StopDirAxAction", NULL, "Stop DirAx", NULL, NULL, G_CALLBACK(displaywindow_dirax_stop) },
{ "RefineStepAction", GTK_STOCK_EXECUTE, "Refine Current Image", NULL, NULL, G_CALLBACK(displaywindow_refinestep) },
{ "RefineSeqAction", GTK_STOCK_EXECUTE, "Refine Entire Stack", NULL, NULL, G_CALLBACK(displaywindow_refinestack) },
- { "SetAxisAction", NULL, "Set Tilt Axis Position", NULL, NULL, G_CALLBACK(displaywindow_setaxis) },
+ { "SetAxisAction", NULL, "Set Tilt Axis Position...", NULL, NULL, G_CALLBACK(displaywindow_setaxis) },
{ "IncrAxisAction", NULL, "Increase Tilt Axis Position", "<Ctrl>Up", NULL, G_CALLBACK(displaywindow_incraxis) },
{ "DecrAxisAction", NULL, "Decrease Tilt Axis Position", "<Ctrl>Down", NULL, G_CALLBACK(displaywindow_decraxis) },
+ { "ExtractIntensitiesAction", GTK_STOCK_EXECUTE, "Extract Reflection Intensities", NULL, NULL, G_CALLBACK(displaywindow_extract) },
{ "HelpAction", NULL, "_Help", NULL, NULL, NULL },
{ "AboutAction", GTK_STOCK_ABOUT, "_About DTR...", NULL, NULL, G_CALLBACK(displaywindow_about) },
@@ -1164,11 +1189,19 @@ static void displaywindow_addmenubar(DisplayWindow *dw) {
};
guint n_entries = G_N_ELEMENTS(entries);
+
GtkRadioActionEntry radios[] = {
- { "OrthoAction", NULL, "_Orthographic", NULL, NULL, DW_ORTHO },
- { "PerspectiveAction", NULL, "_Perspective", NULL, NULL, DW_PERSPECTIVE },
+ { "OrthoAction", NULL, "_Orthographic Projection", NULL, NULL, DW_ORTHO },
+ { "PerspectiveAction", NULL, "_Perspective Projection", NULL, NULL, DW_PERSPECTIVE },
};
guint n_radios = G_N_ELEMENTS(radios);
+
+ GtkRadioActionEntry radios2[] = {
+ { "MappedAction", NULL, "Show Mapped Features", NULL, NULL, DW_MAPPED },
+ { "MeasuredAction", NULL, "Show Measured Intensities", NULL, NULL, DW_MEASURED },
+ };
+ guint n_radios2 = G_N_ELEMENTS(radios2);
+
GtkToggleActionEntry toggles[] = {
{ "CubeAction", NULL, "Show 100 nm^-1 _Cube", NULL, NULL, G_CALLBACK(displaywindow_changecube), dw->cube },
{ "LinesAction", NULL, "Show Indexing Lines", NULL, NULL, G_CALLBACK(displaywindow_changelines), dw->lines },
@@ -1181,6 +1214,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw) {
dw->action_group = gtk_action_group_new("dtrdisplaywindow");
gtk_action_group_add_actions(dw->action_group, entries, n_entries, dw);
gtk_action_group_add_radio_actions(dw->action_group, radios, n_radios, -1, G_CALLBACK(displaywindow_changeview), dw);
+ gtk_action_group_add_radio_actions(dw->action_group, radios2, n_radios2, -1, G_CALLBACK(displaywindow_changemode), dw);
gtk_action_group_add_toggle_actions(dw->action_group, toggles, n_toggles, dw);
dw->ui = gtk_ui_manager_new();
@@ -1296,6 +1330,7 @@ DisplayWindow *displaywindow_open(ControlContext *ctx) {
dw->gl_use_buffers = 1;
dw->view = DW_ORTHO;
+ dw->mode = DW_MAPPED;
dw->distance = 150;
dw->x_pos = 0;
dw->y_pos = 0;
@@ -1409,6 +1444,10 @@ void displaywindow_enable_cell_functions(DisplayWindow *dw, gboolean g) {
gtk_widget_set_sensitive(d, g);
d = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindowtoolbar/refinestep");
gtk_widget_set_sensitive(d, g);
+ d = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindow/tools/extractintensities");
+ gtk_widget_set_sensitive(d, g);
+ d = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindowtoolbar/extractintensities");
+ gtk_widget_set_sensitive(d, g);
}
diff --git a/src/displaywindow.h b/src/displaywindow.h
index 6484b33..86d2645 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -26,6 +26,11 @@ typedef enum {
DW_PERSPECTIVE
} DisplayWindowView;
+typedef enum {
+ DW_MAPPED, /* Display the features from the images mapped into 3D */
+ DW_MEASURED /* Display the intensities of reflections measured via intensities.c */
+} DisplayWindowMode;
+
typedef struct dw_struct {
ControlContext *ctx;
@@ -35,7 +40,6 @@ typedef struct dw_struct {
GtkWidget *window;
GtkWidget *bigvbox;
GtkWidget *status_bar;
- DisplayWindowView view;
GtkWidget *drawing_area;
GtkWidget *savecache_window;
@@ -62,6 +66,7 @@ typedef struct dw_struct {
GLsizei gl_line_num_vertices;
/* Display parameters */
+ DisplayWindowView view;
GLfloat distance;
GLfloat x_pos;
GLfloat y_pos;
@@ -71,6 +76,7 @@ typedef struct dw_struct {
int background;
float x_start;
float y_start;
+ DisplayWindowMode mode;
int cur_image;
struct imagedisplay_struct *stack;
diff --git a/src/intensities.c b/src/intensities.c
new file mode 100644
index 0000000..96c7ad1
--- /dev/null
+++ b/src/intensities.c
@@ -0,0 +1,109 @@
+/*
+ * intensities.c
+ *
+ * Extract integrated intensities by relrod estimation
+ *
+ * (c) 2007 Thomas White <taw27@cam.ac.uk>
+ *
+ * dtr - Diffraction Tomography Reconstruction
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "control.h"
+#include "reflections.h"
+#include "image.h"
+#include "reproject.h"
+
+/* Extract integrated reflection intensities by estimating the spike function
+ * based on the observed intensity and the calculated excitation error from
+ * the lattice refinement. Easy. */
+void intensities_extract(ControlContext *ctx) {
+
+ int i, j;
+ int n_meas, n_dupl, n_notf;
+ double max;
+ Reflection *reflection;
+
+ /* Free previous analysis if required */
+ if ( ctx->integrated != NULL ) {
+ reflectionlist_free(ctx->integrated);
+ }
+ ctx->integrated = reflectionlist_new();
+
+ n_meas = 0;
+ n_dupl = 0;
+ n_notf = 0;
+ max = 0;
+ for ( i=0; i<ctx->images->n_images; i++ ) {
+
+ ImageRecord *image;
+
+ image = &ctx->images->images[i];
+ if ( image->rflist == NULL ) image->rflist = reproject_get_reflections(image, ctx->cell_lattice);
+
+ for ( j=0; j<image->rflist->n_features; j++ ) {
+
+ ImageFeature *feature;
+ signed int h, k, l;
+
+ feature = &image->rflist->features[j];
+
+ h = feature->reflection->h;
+ k = feature->reflection->k;
+ l = feature->reflection->l;
+
+ if ( feature->partner != NULL ) {
+
+ if ( (h!=0) || (k!=0) || (l!=0) ) {
+
+ double intensity;
+ Reflection *new;
+
+ /* Perform relrod calculation of doom here.
+ * TODO: Figure out if this is even possible. */
+ intensity = feature->partner->intensity;
+
+ new = reflection_add(ctx->integrated,
+ feature->reflection->x, feature->reflection->y, feature->reflection->z,
+ intensity, REFLECTION_GENERATED);
+
+ if ( new != NULL ) {
+ new->h = h;
+ new->k = k;
+ new->l = l;
+ //printf("IN: Adding %3i %3i %3i, intensity=%f\n", h, k, l, intensity);
+ if ( intensity > max ) max = intensity;
+ n_meas++;
+ } else {
+ printf("IN: Duplicate measurement for %3i %3i %3i\n", h, k, l);
+ n_dupl++;
+ }
+
+ }
+
+ } else {
+ //printf("IN: %3i %3i %3i not found\n", h, k, l);
+ n_notf++;
+ }
+
+ }
+
+ }
+
+ /* Normalise all reflections to the most intense reflection */
+ reflection = ctx->integrated->reflections;
+ while ( reflection ) {
+ reflection->intensity /= max;
+ reflection = reflection->next;
+ }
+
+ printf("IN: %5i intensities measured\n", n_meas);
+ printf("IN: %5i duplicated measurements\n", n_dupl);
+ printf("IN: %5i predicted reflections not found\n", n_notf);
+
+}
+
diff --git a/src/intensities.h b/src/intensities.h
new file mode 100644
index 0000000..88d385b
--- /dev/null
+++ b/src/intensities.h
@@ -0,0 +1,24 @@
+/*
+ * intensities.h
+ *
+ * Extract integrated intensities by relrod estimation
+ *
+ * (c) 2007 Thomas White <taw27@cam.ac.uk>
+ *
+ * dtr - Diffraction Tomography Reconstruction
+ *
+ */
+
+#ifndef INTENSITIES_H
+#define INTENSITIES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "control.h"
+
+extern void intensities_extract(ControlContext *ctx);
+
+#endif /* INTENSITIES_H */
+
diff --git a/src/reproject.c b/src/reproject.c
index 31fe00c..4d2d889 100644
--- a/src/reproject.c
+++ b/src/reproject.c
@@ -185,7 +185,8 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList *
/* Record the reflection */
image_add_feature_reflection(flist, x, y, image, reflection->intensity, reflection);
- /* TODO: Intensity needs to be multiplied by relrod spike function */
+ /* Intensity should be multiplied by relrod spike function except
+ * reprojected reflections aren't used quantitatively for anything */
//printf("Reflection at %f, %f\n", x, y);