Commit 66d5da36 authored by Thomas White's avatar Thomas White
Browse files

hdfsee: Take colour scale on command line

parent f7a31205
......@@ -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;
......
......@@ -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 */
......@@ -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 {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment