aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/displaywindow.c38
-rw-r--r--src/displaywindow.h1
-rw-r--r--src/image.c3
-rw-r--r--src/image.h4
-rw-r--r--src/peaks.c3
5 files changed, 41 insertions, 8 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 2536c1ed..12c31a5c 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -411,25 +411,29 @@ static void load_features_from_file(struct image *image, const char *filename)
do {
char line[1024];
- float x, y, d, df;
+ float x, y, df;
int r;
+ signed int h, k, l;
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
chomp(line);
/* Try long format (output of pattern_sim --near-bragg) */
- r = sscanf(line, "%f %f %f %f (at %f,%f)",
- &d, &d, &d, &df, &x, &y);
+ r = sscanf(line, "%i %i %i %f (at %f,%f)",
+ &h, &k, &l, &df, &x, &y);
if ( r == 6 ) {
- image_add_feature(image->features, x, y, image, 1.0);
+ char name[32];
+ snprintf(name, 31, "%i %i %i", h, k, l);
+ image_add_feature(image->features, x, y, image, 1.0,
+ strdup(name));
continue;
}
r = sscanf(line, "%f %f", &x, &y);
if ( r != 2 ) continue;
- image_add_feature(image->features, x, y, image, 1.0);
+ image_add_feature(image->features, x, y, image, 1.0, NULL);
} while ( rval != NULL );
}
@@ -550,7 +554,9 @@ static gint displaywindow_show_numbers(GtkWidget *widget, DisplayWindow *dw)
struct numberswindow *nw;
GtkWidget *vbox;
GtkWidget *hbox;
+ GtkWidget *hbox2;
GtkWidget *table;
+ GtkWidget *label;
unsigned int x, y;
if ( dw->numbers_window != NULL ) {
@@ -598,6 +604,13 @@ static gint displaywindow_show_numbers(GtkWidget *widget, DisplayWindow *dw)
}
}
+ hbox2 = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox2), FALSE, FALSE, 5);
+ label = gtk_label_new("Feature:");
+ gtk_box_pack_start(GTK_BOX(hbox2), GTK_WIDGET(label), FALSE, FALSE, 5);
+ nw->feat = gtk_label_new("-");
+ gtk_box_pack_start(GTK_BOX(hbox2), GTK_WIDGET(nw->feat), FALSE, FALSE, 5);
+
g_signal_connect(G_OBJECT(nw->window), "response",
G_CALLBACK(displaywindow_numbers_response), dw);
g_signal_connect(G_OBJECT(nw->window), "destroy",
@@ -613,6 +626,9 @@ static gint displaywindow_show_numbers(GtkWidget *widget, DisplayWindow *dw)
static void numbers_update(DisplayWindow *dw)
{
int px, py;
+ int imin;
+ double dmin;
+ struct imagefeature *f;
for ( px=0; px<17; px++ ) {
for ( py=0; py<17; py++ ) {
@@ -644,6 +660,18 @@ static void numbers_update(DisplayWindow *dw)
}
}
+
+ if ( dw->image->features == NULL ) return;
+
+ f = image_feature_closest(dw->image->features, dw->numbers_window->cx,
+ dw->numbers_window->cy, &dmin, &imin);
+ if ( dmin < 20.0 ) {
+ gtk_label_set_text(GTK_LABEL(dw->numbers_window->feat),
+ f->name);
+ } else {
+ gtk_label_set_text(GTK_LABEL(dw->numbers_window->feat),
+ "-");
+ }
}
diff --git a/src/displaywindow.h b/src/displaywindow.h
index 1520a1b1..63630abf 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -35,6 +35,7 @@ typedef struct {
struct numberswindow {
GtkWidget *window;
GtkWidget *labels[17*17];
+ GtkWidget *feat;
unsigned int cx;
unsigned int cy;
};
diff --git a/src/image.c b/src/image.c
index b0869cce..d4b7fcb9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -71,7 +71,7 @@ ImageList *image_list_new()
void image_add_feature(ImageFeatureList *flist, double x, double y,
- struct image *parent, double intensity)
+ struct image *parent, double intensity, const char *name)
{
if ( flist->features ) {
flist->features = realloc(flist->features,
@@ -88,6 +88,7 @@ void image_add_feature(ImageFeatureList *flist, double x, double y,
flist->features[flist->n_features].parent = parent;
flist->features[flist->n_features].partner = NULL;
flist->features[flist->n_features].partner_d = 0.0;
+ flist->features[flist->n_features].name = name;
flist->features[flist->n_features].valid = 1;
flist->n_features++;
diff --git a/src/image.h b/src/image.h
index 16452a0f..5159d63e 100644
--- a/src/image.h
+++ b/src/image.h
@@ -47,6 +47,7 @@ struct imagefeature {
/* Internal use only */
int valid;
+ const char *name;
};
/* An opaque type representing a list of image features */
@@ -111,7 +112,8 @@ extern ImageFeatureList *image_feature_list_new(void);
extern void image_feature_list_free(ImageFeatureList *flist);
extern void image_add_feature(ImageFeatureList *flist, double x, double y,
- struct image *parent, double intensity);
+ struct image *parent, double intensity,
+ const char *name);
extern void image_remove_feature(ImageFeatureList *flist, int idx);
diff --git a/src/peaks.c b/src/peaks.c
index 5cbf0f17..d146ce24 100644
--- a/src/peaks.c
+++ b/src/peaks.c
@@ -426,7 +426,8 @@ void search_peaks(struct image *image)
}
/* Add using "better" coordinates */
- image_add_feature(image->features, fx, fy, image, intensity);
+ image_add_feature(image->features, fx, fy, image, intensity,
+ NULL);
nacc++;
}