diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-02-24 11:52:46 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:15 +0100 |
commit | ff5f60512263afac7059c2748511e4e0244f7940 (patch) | |
tree | e48cc0af287acd7399e4e59e48f12896dca1b406 | |
parent | b57080f25fc077aa8289f20c6856dddb32101f8a (diff) |
hdfsee: Initial geometry stuff
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 7 | ||||
-rw-r--r-- | data/hdfsee.ui | 1 | ||||
-rw-r--r-- | src/displaywindow.c | 71 | ||||
-rw-r--r-- | src/hdfsee.c | 1 |
5 files changed, 78 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am index 52b842b1..27914687 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,7 @@ endif if HAVE_GTK src_hdfsee_SOURCES = src/hdfsee.c src/displaywindow.c src/render.c \ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ - src/thread-pool.c + src/thread-pool.c src/detector.c src_geomatic_SOURCES = src/geomatic.c src/dw-geomatic.c src/render.c \ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ diff --git a/Makefile.in b/Makefile.in index 588c3418..ba92b9e3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -146,12 +146,13 @@ src_get_hkl_LDADD = $(LDADD) src_get_hkl_DEPENDENCIES = $(top_builddir)/lib/libgnu.a am__src_hdfsee_SOURCES_DIST = src/hdfsee.c src/displaywindow.c \ src/render.c src/hdf5-file.c src/utils.c src/image.c \ - src/filters.c src/thread-pool.c + src/filters.c src/thread-pool.c src/detector.c @HAVE_GTK_TRUE@am_src_hdfsee_OBJECTS = src/hdfsee.$(OBJEXT) \ @HAVE_GTK_TRUE@ src/displaywindow.$(OBJEXT) \ @HAVE_GTK_TRUE@ src/render.$(OBJEXT) src/hdf5-file.$(OBJEXT) \ @HAVE_GTK_TRUE@ src/utils.$(OBJEXT) src/image.$(OBJEXT) \ -@HAVE_GTK_TRUE@ src/filters.$(OBJEXT) src/thread-pool.$(OBJEXT) +@HAVE_GTK_TRUE@ src/filters.$(OBJEXT) src/thread-pool.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/detector.$(OBJEXT) src_hdfsee_OBJECTS = $(am_src_hdfsee_OBJECTS) src_hdfsee_LDADD = $(LDADD) src_hdfsee_DEPENDENCIES = $(top_builddir)/lib/libgnu.a @@ -616,7 +617,7 @@ src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c \ src/beam-parameters.c src/reflist.c $(am__append_4) @HAVE_GTK_TRUE@src_hdfsee_SOURCES = src/hdfsee.c src/displaywindow.c src/render.c \ @HAVE_GTK_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ -@HAVE_GTK_TRUE@ src/thread-pool.c +@HAVE_GTK_TRUE@ src/thread-pool.c src/detector.c @HAVE_GTK_TRUE@src_geomatic_SOURCES = src/geomatic.c src/dw-geomatic.c src/render.c \ @HAVE_GTK_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ diff --git a/data/hdfsee.ui b/data/hdfsee.ui index 7975ad4f..beed7c4e 100644 --- a/data/hdfsee.ui +++ b/data/hdfsee.ui @@ -23,6 +23,7 @@ <menu name="tools" action="ToolsAction"> <menuitem name="numbers" action="NumbersAction" /> <menuitem name="peaks" action="PeaksAction" /> + <menuitem name="geometry" action="LoadGeomAction" /> </menu> <menu name="help" action="HelpAction"> diff --git a/src/displaywindow.c b/src/displaywindow.c index 49e9ef1a..07e121eb 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -532,6 +532,65 @@ static gint displaywindow_about(GtkWidget *widget, DisplayWindow *dw) } +static int load_geometry_file(DisplayWindow *dw, struct image *image, + const char *filename) +{ + struct detector *geom; + + geom = get_detector_geometry(filename); + if ( geom == NULL ) return -1; + + if ( image->det != NULL ) free_detector_geometry(image->det); + image->det = geom; + return 0; +} + + +static gint displaywindow_loadgeom_response(GtkWidget *d, gint response, + DisplayWindow *dw) +{ + if ( response == GTK_RESPONSE_ACCEPT ) { + + char *filename; + + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); + + if ( load_geometry_file(dw, dw->image, filename) == 0 ) { + displaywindow_update(dw); + } else { + displaywindow_error(dw, "Failed to load geometry file"); + } + + g_free(filename); + + } + + gtk_widget_destroy(d); + + return 0; +} + + +static gint displaywindow_load_geom(GtkWidget *widget, DisplayWindow *dw) +{ + GtkWidget *d; + + d = gtk_file_chooser_dialog_new("Load Geometry File", + GTK_WINDOW(dw->window), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + g_signal_connect(G_OBJECT(d), "response", + G_CALLBACK(displaywindow_loadgeom_response), dw); + + gtk_widget_show_all(d); + + return 0; +} + + static gint displaywindow_peak_overlay(GtkWidget *widget, DisplayWindow *dw) { GtkWidget *d; @@ -552,6 +611,14 @@ static gint displaywindow_peak_overlay(GtkWidget *widget, DisplayWindow *dw) } +static gint displaywindow_set_usegeom(GtkWidget *d, gint response, + DisplayWindow *dw) +{ + return 0; +} + + + struct savedialog { DisplayWindow *dw; GtkWidget *cb; @@ -850,12 +917,16 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox, G_CALLBACK(displaywindow_set_binning) }, { "BoostIntAction", NULL, "Boost Intensity...", "F5", NULL, G_CALLBACK(displaywindow_set_boostint) }, + { "GeometryAction", NULL, "Use Detector Geometry", NULL, NULL, + G_CALLBACK(displaywindow_set_usegeom) }, { "ToolsAction", NULL, "_Tools", NULL, NULL, NULL }, { "NumbersAction", NULL, "View Numbers...", "F2", NULL, G_CALLBACK(displaywindow_show_numbers) }, { "PeaksAction", NULL, "Peak Position Overlay...", NULL, NULL, G_CALLBACK(displaywindow_peak_overlay) }, + { "LoadGeomAction", NULL, "Load Geometry File...", NULL, NULL, + G_CALLBACK(displaywindow_load_geom) }, { "HelpAction", NULL, "_Help", NULL, NULL, NULL }, { "AboutAction", GTK_STOCK_ABOUT, "_About hdfsee...", diff --git a/src/hdfsee.c b/src/hdfsee.c index 57a1d025..a7a3631f 100644 --- a/src/hdfsee.c +++ b/src/hdfsee.c @@ -51,6 +51,7 @@ static void show_help(const char *s) " -yellow-white.\n" " -e, --image=<element> Start up displaying this image from the\n" " HDF5 file. Example: /data/data0.\n" +" -g, --geometry=<filename> Use geometry from file for display.\n" "\n"); } |