aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-03-04 22:25:02 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:17 +0100
commit0c8f51e61f300215a9c1278b48d9e627c398803c (patch)
tree47d3843aa46e6b0cd0640dd5a346ccc674b9e362 /src
parent57dba87d11224b41c9799cf507019e15e3450e6c (diff)
hdfsee: Menu item to turn peaks on/off
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c101
-rw-r--r--src/dw-hdfsee.h1
2 files changed, 61 insertions, 41 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index a99cfc15..1a3f6b7b 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -171,7 +171,6 @@ static void show_ring(cairo_t *cr, DisplayWindow *dw,
static int draw_stuff(cairo_surface_t *surf, DisplayWindow *dw)
{
cairo_t *cr;
- int i;
cairo_matrix_t basic_m;
cairo_matrix_t m;
@@ -251,58 +250,60 @@ static int draw_stuff(cairo_surface_t *surf, DisplayWindow *dw)
cairo_fill(cr);
}
- if ( dw->image->features == NULL ) {
- cairo_destroy(cr);
- return 0;
- }
-
/* Ensure a clean Cairo context, since the rings often cause
* matrix trouble */
cairo_destroy(cr);
cr = cairo_create(surf);
- cairo_set_matrix(cr, &basic_m);
- for ( i=0; i<image_feature_count(dw->image->features); i++ ) {
+ if ( (dw->image->features != NULL) && (dw->show_peaks) ) {
- double fs, ss;
- double x, y, xs, ys;
- struct imagefeature *f;
- struct panel *p;
+ int i;
- f = image_get_feature(dw->image->features, i);
- if ( f == NULL ) continue;
+ cairo_set_matrix(cr, &basic_m);
- fs = f->x;
- ss = f->y;
+ for ( i=0; i<image_feature_count(dw->image->features); i++ ) {
- p = find_panel(dw->image->det, fs, ss);
- if ( p == NULL ) continue;
+ double fs, ss;
+ double x, y, xs, ys;
+ struct imagefeature *f;
+ struct panel *p;
- xs = (fs-p->min_fs)*p->fsx + (ss-p->min_ss)*p->ssx;
- ys = (fs-p->min_fs)*p->fsy + (ss-p->min_ss)*p->ssy;
- x = xs + p->cnx;
- y = ys + p->cny;
+ f = image_get_feature(dw->image->features, i);
+ if ( f == NULL ) continue;
- cairo_arc(cr, x/dw->binning, y/dw->binning,
- 7.0/dw->binning, 0.0, 2.0*M_PI);
- switch ( dw->scale ) {
+ fs = f->x;
+ ss = f->y;
- case SCALE_COLOUR :
- cairo_set_source_rgb(cr, 1.0, 1.0, 0.0);
- break;
+ p = find_panel(dw->image->det, fs, ss);
+ if ( p == NULL ) continue;
- case SCALE_MONO :
- cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
- break;
+ xs = (fs-p->min_fs)*p->fsx + (ss-p->min_ss)*p->ssx;
+ ys = (fs-p->min_fs)*p->fsy + (ss-p->min_ss)*p->ssy;
+ x = xs + p->cnx;
+ y = ys + p->cny;
- case SCALE_INVMONO:
- cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
- break;
+ cairo_arc(cr, x/dw->binning, y/dw->binning,
+ 7.0/dw->binning, 0.0, 2.0*M_PI);
+ switch ( dw->scale ) {
- }
+ case SCALE_COLOUR :
+ cairo_set_source_rgb(cr, 1.0, 1.0, 0.0);
+ break;
+
+ case SCALE_MONO :
+ cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+ break;
+
+ case SCALE_INVMONO:
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ break;
+
+ }
+
+ cairo_set_line_width(cr, 0.75);
+ cairo_stroke(cr);
- cairo_set_line_width(cr, 0.75);
- cairo_stroke(cr);
+ }
}
@@ -655,10 +656,16 @@ static gint displaywindow_peaklist_response(GtkWidget *d, gint response,
if ( response == GTK_RESPONSE_ACCEPT ) {
char *filename;
+ GtkWidget *w;
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d));
load_features_from_file(dw->image, filename);
+ dw->show_peaks = 1;
+ w = gtk_ui_manager_get_widget(dw->ui,
+ "/ui/displaywindow/view/showpeaks");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE);
+
displaywindow_update(dw);
g_free(filename);
@@ -942,6 +949,14 @@ static gint displaywindow_set_colscale(GtkWidget *widget, DisplayWindow *dw)
}
+static gint displaywindow_set_peaks(GtkWidget *widget, DisplayWindow *dw)
+{
+ dw->show_peaks = 1 - dw->show_peaks;
+ gdk_window_invalidate_rect(dw->drawingarea->window, NULL, FALSE);
+ return 0;
+}
+
+
static gint displaywindow_numbers_response(GtkWidget *widget,
gint response, DisplayWindow *dw)
{
@@ -1150,7 +1165,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
{ "ToolsAction", NULL, "_Tools", NULL, NULL, NULL },
{ "NumbersAction", NULL, "View Numbers...", "F2", NULL,
G_CALLBACK(displaywindow_show_numbers) },
- { "PeaksAction", NULL, "Peak Position Overlay...", NULL, NULL,
+ { "PeaksAction", NULL, "Load Feature List...", NULL, NULL,
G_CALLBACK(displaywindow_peak_overlay) },
{ "LoadGeomAction", NULL, "Load Geometry File...", NULL, NULL,
G_CALLBACK(displaywindow_load_geom) },
@@ -1164,12 +1179,14 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
guint n_entries = G_N_ELEMENTS(entries);
GtkToggleActionEntry toggles[] = {
- { "ColScaleAction", NULL, "Show Colour Scale", NULL, NULL,
- G_CALLBACK(displaywindow_set_colscale), FALSE },
{ "GeometryAction", NULL, "Use Detector Geometry", NULL, NULL,
G_CALLBACK(displaywindow_set_usegeom), FALSE },
- { "RingsAction", NULL, "Show Resolution Rings", NULL, NULL,
+ { "ColScaleAction", NULL, "Colour Scale", NULL, NULL,
+ G_CALLBACK(displaywindow_set_colscale), FALSE },
+ { "RingsAction", NULL, "Resolution Rings", NULL, NULL,
G_CALLBACK(displaywindow_set_rings), dw->show_rings },
+ { "ShowPeaksAction", NULL, "Features", NULL, NULL,
+ G_CALLBACK(displaywindow_set_peaks), dw->show_peaks },
};
guint n_toggles = G_N_ELEMENTS(toggles);
GtkRadioActionEntry radios[] = {
@@ -1486,6 +1503,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
dw->image = NULL;
dw->use_geom = 0;
dw->show_rings = show_rings;
+ dw->show_peaks = 0;
dw->scale = colscale;
dw->binning = binning;
dw->boostint = boost;
@@ -1532,6 +1550,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
/* Peak list provided at startup? */
if ( peaks != NULL ) {
load_features_from_file(dw->image, peaks);
+ dw->show_peaks = 1;
}
dw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h
index d3419390..98a5e636 100644
--- a/src/dw-hdfsee.h
+++ b/src/dw-hdfsee.h
@@ -77,6 +77,7 @@ typedef struct {
int noisefilter; /* Use aggressive noise filter */
int use_geom;
int show_rings;
+ int show_peaks;
int show_col_scale;
int scale;