aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-10-04 14:45:39 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:01 +0100
commit66d5da36aae43e0984fec4e45516ab21aada2ad6 (patch)
tree604fa611ded088156bb112f19b03940e0886120a /src
parentf7a312058664d5f3e8c5176ba27bb593ae0f1b0d (diff)
hdfsee: Take colour scale on command line
Diffstat (limited to 'src')
-rw-r--r--src/displaywindow.c18
-rw-r--r--src/displaywindow.h2
-rw-r--r--src/hdfsee.c36
3 files changed, 47 insertions, 9 deletions
diff --git a/src/displaywindow.c b/src/displaywindow.c
index 145602e0..b37a483a 100644
--- a/src/displaywindow.c
+++ b/src/displaywindow.c
@@ -785,14 +785,20 @@ static void displaywindow_addui_callback(GtkUIManager *ui, GtkWidget *widget,
static gint displaywindow_setscale(GtkWidget *widget, GtkRadioAction *action,
DisplayWindow *dw)
{
- dw->scale = gtk_radio_action_get_current_value(action);
+ switch ( gtk_radio_action_get_current_value(action) )
+ {
+ case 0 : dw->scale = SCALE_COLOUR; break;
+ case 1 : dw->scale = SCALE_MONO; break;
+ case 2 : dw->scale = SCALE_INVMONO; break;
+ }
displaywindow_update(dw);
return 0;
}
-static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox)
+static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox,
+ int colscale)
{
GError *error = NULL;
GtkActionEntry entries[] = {
@@ -844,7 +850,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox)
gtk_action_group_add_toggle_actions(dw->action_group, toggles,
n_toggles, dw);
gtk_action_group_add_radio_actions(dw->action_group, radios, n_radios,
- SCALE_COLOUR,
+ colscale,
G_CALLBACK(displaywindow_setscale),
dw);
@@ -1107,7 +1113,7 @@ static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event,
DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
int boost, int binning, int cmfilter,
- int noisefilter)
+ int noisefilter, int colscale)
{
DisplayWindow *dw;
char *title;
@@ -1119,7 +1125,6 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
dw->binning_dialog = NULL;
dw->show_col_scale = 0;
dw->col_scale = NULL;
- dw->scale = SCALE_COLOUR;
dw->boostint_dialog = NULL;
dw->boostint = 1;
dw->motion_callback = 0;
@@ -1143,7 +1148,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(dw->window), vbox);
- displaywindow_addmenubar(dw, vbox);
+ displaywindow_addmenubar(dw, vbox, colscale);
dw->drawingarea = gtk_drawing_area_new();
gtk_box_pack_start(GTK_BOX(vbox), dw->drawingarea, TRUE, TRUE, 0);
@@ -1171,6 +1176,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
gtk_window_set_resizable(GTK_WINDOW(dw->window), FALSE);
gtk_widget_show_all(dw->window);
+ dw->scale = colscale;
dw->binning = binning;
dw->boostint = boost;
dw->cmfilter = cmfilter;
diff --git a/src/displaywindow.h b/src/displaywindow.h
index ee34dab9..142243fe 100644
--- a/src/displaywindow.h
+++ b/src/displaywindow.h
@@ -76,7 +76,7 @@ typedef struct {
extern DisplayWindow *displaywindow_open(const char *filename,
const char *peaks, int boost,
int binning, int cmfilter,
- int noisefilter);
+ int noisefilter, int colscale);
#endif /* DISPLAYWINDOW_H */
diff --git a/src/hdfsee.c b/src/hdfsee.c
index de150df2..da047297 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -20,6 +20,7 @@
#include "displaywindow.h"
#include "utils.h"
+#include "render.h"
/* Global program state */
@@ -43,6 +44,12 @@ static void show_help(const char *s)
" sets all pixels in each 3x3 region to\n"
" zero if any of them have negative\n"
" values.\n"
+" -c, --colscale=<scale> Use the given colour scale. Choose from:\n"
+" mono : Greyscale, black is zero.\n"
+" invmono : Greyscale, white is zero.\n"
+" colour : Colour scale:\n"
+" black-blue-pink-red-orange-\n"
+" -yellow-white.\n"
"\n");
}
@@ -83,6 +90,8 @@ int main(int argc, char *argv[])
int binning = 2;
int config_cmfilter = 0;
int config_noisefilter = 0;
+ int colscale = SCALE_COLOUR;
+ char *cscale = NULL;
/* Long options */
const struct option longopts[] = {
@@ -92,13 +101,15 @@ int main(int argc, char *argv[])
{"binning", 1, NULL, 'b'},
{"filter-cm", 0, &config_cmfilter, 1},
{"filter-noise", 0, &config_noisefilter, 1},
+ {"colscale", 1, NULL, 'c'},
{0, 0, NULL, 0}
};
gtk_init(&argc, &argv);
/* Short options */
- while ((c = getopt_long(argc, argv, "hp:b:i:", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hp:b:i:c:",
+ longopts, NULL)) != -1) {
switch (c) {
case 'h' :
@@ -124,6 +135,10 @@ int main(int argc, char *argv[])
}
break;
+ case 'c' :
+ cscale = strdup(optarg);
+ break;
+
case 0 :
break;
@@ -140,11 +155,28 @@ int main(int argc, char *argv[])
return -1;
}
+ if ( cscale == NULL ) cscale = strdup("colour");
+ if ( strcmp(cscale, "mono") == 0 ) {
+ colscale = SCALE_MONO;
+ } else if ( strcmp(cscale, "invmono") == 0 ) {
+ colscale = SCALE_INVMONO;
+ } else if ( strcmp(cscale, "colour") == 0 ) {
+ colscale = SCALE_COLOUR;
+ } else if ( strcmp(cscale, "color") == 0 ) {
+ colscale = SCALE_COLOUR;
+ } else {
+ ERROR("Unrecognised colour scale '%s'\n", cscale);
+ return 1;
+ }
+ free(cscale);
+
+
for ( i=0; i<nfiles; i++ ) {
main_window_list[i] = displaywindow_open(argv[optind+i], peaks,
boost, binning,
config_cmfilter,
- config_noisefilter);
+ config_noisefilter,
+ colscale);
if ( main_window_list[i] == NULL ) {
ERROR("Couldn't open display window\n");
} else {