aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2014-11-10 14:26:45 +0100
committerThomas White <taw@physics.org>2014-11-10 18:59:34 +0100
commite3135a2154b1aa1c137664030972a09e50b7f1d8 (patch)
treed29d9afc83084411065b0219c3b0c43af551d53d /src
parent44fa1b1c46f9cd52fb0f0842a09b1d499e3cf08c (diff)
Copy and Replace when saving geometry
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c19
-rw-r--r--src/dw-hdfsee.h8
-rw-r--r--src/hdfsee.c9
3 files changed, 24 insertions, 12 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index f4655d0a..e9b6ee86 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -1176,7 +1176,7 @@ static gint displaywindow_about(GtkWidget *widget, DisplayWindow *dw)
static int save_geometry_file(DisplayWindow *dw)
{
GtkWidget *d;
- gchar * filename;
+ gchar * output_filename;
int w;
d = gtk_file_chooser_dialog_new("Save Detector Geometry",
@@ -1187,10 +1187,11 @@ static int save_geometry_file(DisplayWindow *dw)
NULL);
gtk_dialog_run (GTK_DIALOG (d));
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (d));
- w = write_detector_geometry(filename, dw->image->det);
+ output_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (d));
+ w = write_detector_geometry(dw->geom_filename, output_filename,
+ dw->image->det);
gtk_widget_destroy(d);
- g_free(filename);
+ g_free(output_filename);
return w;
}
@@ -2429,7 +2430,8 @@ static gint displaywindow_keypress(GtkWidget *widget, GdkEventKey *event,
}
-DisplayWindow *displaywindow_open(char *filename, const char *peaks,
+DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
+ const char *peaks,
double boost, int binning,
int noisefilter, int calibmode, int colscale,
const char *element,
@@ -2479,6 +2481,7 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks,
dw->multi_event = 0;
dw->curr_event = 0;
dw->ev_list = NULL;
+ dw->geom_filename = strdup(geom_filename);
dw->image->det = det_geom;
dw->image->beam = beam;
@@ -2488,6 +2491,7 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks,
dw->hdfile = hdfile_open(filename);
if ( dw->hdfile == NULL ) {
ERROR("Couldn't open file: %s\n", filename);
+ free(dw->geom_filename);
free(dw);
return NULL;
}
@@ -2502,6 +2506,7 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks,
if ( dw->ev_list == NULL ) {
ERROR("Error while parsing file structure\n");
free_event_list(dw->ev_list);
+ free(dw->geom_filename);
free(dw);
return NULL;
}
@@ -2509,6 +2514,7 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks,
ERROR("Multi-event geometry file but no events found "
"in data file\n");
free_event_list(dw->ev_list);
+ free(dw->geom_filename);
free(dw);
return NULL;
} else {
@@ -2532,8 +2538,9 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks,
}
if ( check ) {
ERROR("Couldn't load file\n");
- free(dw);
+ free(dw->geom_filename);
hdfile_close(dw->hdfile);
+ free(dw->geom_filename);
return NULL;
}
diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h
index fc16594d..14c17287 100644
--- a/src/dw-hdfsee.h
+++ b/src/dw-hdfsee.h
@@ -90,11 +90,13 @@ typedef struct {
int not_ready_yet;
- struct detector* simple_geom;
+ struct detector* simple_geom;
- struct hdfile *hdfile;
+ struct hdfile *hdfile;
struct image *image;
+ char *geom_filename;
+
/* Dialog boxes */
BinningDialog *binning_dialog;
BoostIntDialog *boostint_dialog;
@@ -137,7 +139,7 @@ typedef struct {
} DisplayWindow;
/* Open an image display window showing the given filename, or NULL */
-extern DisplayWindow *displaywindow_open(char *filename,
+extern DisplayWindow *displaywindow_open(char *filename, char *geom_filename,
const char *peaks, double boost,
int binning,
int noisefilter, int calibmode,
diff --git a/src/hdfsee.c b/src/hdfsee.c
index cc35b6e0..cdf4ae92 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -117,6 +117,7 @@ int main(int argc, char *argv[])
size_t i;
int nfiles;
char *peaks = NULL;
+ char *geom_filename = NULL;
double boost = 1.0;
int binning = 2;
int config_noisefilter = 0;
@@ -213,7 +214,9 @@ int main(int argc, char *argv[])
break;
case 'g' :
- det_geom = get_detector_geometry(optarg, &cbeam);
+ geom_filename = strdup(optarg);
+ det_geom = get_detector_geometry(geom_filename, &cbeam);
+
if ( det_geom == NULL ) {
ERROR("Failed to read detector geometry from '%s'\n",
optarg);
@@ -293,8 +296,8 @@ int main(int argc, char *argv[])
free(cscale);
for ( i=0; i<nfiles; i++ ) {
- main_window_list[i] = displaywindow_open(argv[optind+i], peaks,
- boost, binning,
+ main_window_list[i] = displaywindow_open(argv[optind+i], geom_filename,
+ peaks, boost, binning,
config_noisefilter,
config_calibmode,
colscale, element,