summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ds9/doc/release/r8.1.html1
-rw-r--r--ds9/library/colorbar.tcl97
-rw-r--r--tksao/colorbar/colorbar.C130
-rw-r--r--tksao/colorbar/colormap.h2
-rw-r--r--tksao/colorbar/lut.C5
-rw-r--r--tksao/colorbar/lut.h2
-rw-r--r--tksao/colorbar/sao.C5
-rw-r--r--tksao/colorbar/sao.h2
8 files changed, 143 insertions, 101 deletions
diff --git a/ds9/doc/release/r8.1.html b/ds9/doc/release/r8.1.html
index b58b6b8..1eeb36a 100644
--- a/ds9/doc/release/r8.1.html
+++ b/ds9/doc/release/r8.1.html
@@ -81,6 +81,7 @@
<li><tt><b>05.15.2019 RELEASE version 8.1b1</b></tt></li>
<li><tt>05.28.2019 URL: more tolerant of mime types when downloading via http.</tt></li>
<li><tt>06.04.2019 COLORBAR: fixed a number of issues with updating the screen with color tags active.</tt></li>
+<li><tt>06.05.2019 GUI: colobar cmds load/save errors now report via Error proc.</tt></li>
<li><tt><b>xx.xx.2019 RELEASE version 8.1b2</b></tt></li>
</ol>
</div>
diff --git a/ds9/library/colorbar.tcl b/ds9/library/colorbar.tcl
index f3a657f..c3fa35f 100644
--- a/ds9/library/colorbar.tcl
+++ b/ds9/library/colorbar.tcl
@@ -133,33 +133,39 @@ proc LoadColormap {} {
}
# used by backup
-proc LoadColormapFile {filename} {
+proc LoadColormapFile {fn} {
global colorbar
global icolorbar
global current
global ds9
- if {$filename != {}} {
- colorbar load "\{$filename\}"
- set id [colorbar get id]
- set colorbar(map) [colorbar get name]
+ if {$fn == {}} {
+ return
+ }
+
+ if {[catch {colorbar load "\{$fn\}"} rr]} {
+ Error $rr
+ return
+ }
+
+ set id [colorbar get id]
+ set colorbar(map) [colorbar get name]
+
+ $ds9(mb).color.user add radiobutton \
+ -label "$colorbar(map)" \
+ -variable colorbar(map) \
+ -command [list ChangeColormapID $id]
- $ds9(mb).color.user add radiobutton \
+ if {[winfo exists $icolorbar(top)]} {
+ $icolorbar(mb).colormap.user add radiobutton \
-label "$colorbar(map)" \
-variable colorbar(map) \
-command [list ChangeColormapID $id]
-
- if {[winfo exists $icolorbar(top)]} {
- $icolorbar(mb).colormap.user add radiobutton \
- -label "$colorbar(map)" \
- -variable colorbar(map) \
- -command [list ChangeColormapID $id]
- }
- incr icolorbar(count)
-
- ChangeColormapID $id
}
+ incr icolorbar(count)
+
+ ChangeColormapID $id
}
proc SaveColormap {} {
@@ -167,36 +173,45 @@ proc SaveColormap {} {
SaveColormapFile [SaveFileDialog colorbarfbox]
}
-proc SaveColormapFile {filename} {
- if {$filename != {}} {
- colorbar save "\{$filename\}"
+proc SaveColormapFile {fn} {
+ if {$fn == {}} {
+ return
+ }
+
+ if {[catch {colorbar save "\{$fn\}"} rr]} {
+ Error $rr
+ return
}
}
proc LoadContrastBias {} {
global dcolorbar
- set filename [OpenFileDialog contrastbiasfbox]
- if {$filename != {}} {
- if {![catch {set ch [open $filename r]}]} {
- set ll [gets $ch]
- close $ch
- set dcolorbar(contrast) [lindex $ll 0]
- set dcolorbar(bias) [lindex $ll 1]
- ApplyColormap
- }
+ set fn [OpenFileDialog contrastbiasfbox]
+ if {$fn == {}} {
+ return
+ }
+
+ if {![catch {set ch [open $fn r]}]} {
+ set ll [gets $ch]
+ close $ch
+ set dcolorbar(contrast) [lindex $ll 0]
+ set dcolorbar(bias) [lindex $ll 1]
+ ApplyColormap
}
}
proc SaveContrastBias {} {
global dcolorbar
- set filename [SaveFileDialog contrastbiasfbox]
- if {$filename != {}} {
- if {![catch {set ch [open $filename w]}]} {
- puts $ch "$dcolorbar(contrast) $dcolorbar(bias)"
- close $ch
- }
+ set fn [SaveFileDialog contrastbiasfbox]
+ if {$fn == {}} {
+ return
+ }
+
+ if {![catch {set ch [open $fn w]}]} {
+ puts $ch "$dcolorbar(contrast) $dcolorbar(bias)"
+ close $ch
}
}
@@ -676,7 +691,10 @@ proc LoadColorTag {fn} {
if {$fn != {}} {
# yes, we need this
UpdateColormapLevel
- $current(colorbar) tag load "\{$fn\}"
+ if {[catch {$current(colorbar) tag load "\{$fn\}"} rr]} {
+ Error $rr
+ return
+ }
if {$current(frame) != {}} {
$current(frame) colormap [$current(colorbar) get colormap]
$current(frame) colorbar tag "\{[$current(colorbar) get tag]\}"
@@ -688,8 +706,13 @@ proc SaveColorTag {} {
global current
set fn [SaveFileDialog colortagfbox]
- if {$fn != {}} {
- $current(colorbar) tag save "\{$fn\}"
+ if {$fn == {}} {
+ return
+ }
+
+ if {[catch {colorbar tag save "\{$fn\}"} rr]} {
+ Error $rr
+ return
}
}
diff --git a/tksao/colorbar/colorbar.C b/tksao/colorbar/colorbar.C
index a35610d..5b7a817 100644
--- a/tksao/colorbar/colorbar.C
+++ b/tksao/colorbar/colorbar.C
@@ -487,7 +487,10 @@ void Colorbar::mapCmd(int id)
void Colorbar::saveCmd(const char* fn)
{
- cmaps.current()->save(fn);
+ if (!cmaps.current()->save(fn)) {
+ Tcl_AppendResult(interp, " unable to save colormap: ", fn, NULL);
+ result = TCL_ERROR;
+ }
}
void Colorbar::saveCmd(int id, const char* fn)
@@ -495,12 +498,16 @@ void Colorbar::saveCmd(int id, const char* fn)
ColorMapInfo* ptr = cmaps.begin();
while (ptr) {
if (ptr->getID() == id) {
- ptr->save(fn);
+ if (!ptr->save(fn)) {
+ Tcl_AppendResult(interp, " unable to save colormap: ", fn, NULL);
+ result = TCL_ERROR;
+ }
return;
}
ptr = ptr->next();
}
+ Tcl_AppendResult(interp, " unable to save colormap: ", fn, NULL);
result = TCL_ERROR;
}
@@ -723,69 +730,78 @@ void Colorbar::tagLoadCmd(const char* fn)
{
ifstream str(fn);
- if (str) {
- ctags.deleteAll();
-
- while (!str.eof()) {
- int mm=0;
- int nn=0;
- double aa =0;
- double bb =0;
- char color[32];
- *color ='\0';
-
- str >> aa >> bb >> color;
-
- if (aa && bb && *color) {
- // special case
- if (aa>lut[cnt-1] && bb>lut[cnt-1])
- continue;
- else if (aa<lut[0] && bb<lut[0])
- continue;
-
- mm =0;
- for (int ii=0; ii<cnt; ii++)
- if (aa<lut[ii]) {
- mm=ii;
- break;
- }
- nn =cnt-1;
- for (int ii=cnt-1; ii>=0; ii--)
- if (bb>lut[ii]) {
- nn=ii;
- break;
- }
-
- Vector rr = Vector(mm,nn)/cnt*colorCount;
- ctags.append(new ColorTag(this,rr[0],rr[1],color));
- }
- }
+ if (!str) {
+ Tcl_AppendResult(interp, " unable to load color tags: ", fn, NULL);
+ result = TCL_ERROR;
+ return;
+ }
- updateColors();
+ ctags.deleteAll();
+
+ while (!str.eof()) {
+ int mm=0;
+ int nn=0;
+ double aa =0;
+ double bb =0;
+ char color[32];
+ *color ='\0';
+
+ str >> aa >> bb >> color;
+
+ if (aa && bb && *color) {
+ // special case
+ if (aa>lut[cnt-1] && bb>lut[cnt-1])
+ continue;
+ else if (aa<lut[0] && bb<lut[0])
+ continue;
+
+ mm =0;
+ for (int ii=0; ii<cnt; ii++)
+ if (aa<lut[ii]) {
+ mm=ii;
+ break;
+ }
+ nn =cnt-1;
+ for (int ii=cnt-1; ii>=0; ii--)
+ if (bb>lut[ii]) {
+ nn=ii;
+ break;
+ }
+
+ Vector rr = Vector(mm,nn)/cnt*colorCount;
+ ctags.append(new ColorTag(this,rr[0],rr[1],color));
+ }
}
+
+ updateColors();
}
void Colorbar::tagSaveCmd(const char* fn)
{
ofstream str(fn);
- if (str) {
- ctags.head();
- while (ctags.current()) {
- int startid = float(ctags.current()->start())/colorCount * cnt;
- int stopid = float(ctags.current()->stop())/colorCount * cnt;
- if (startid<0)
- startid = 0;
- if (startid>=cnt)
- startid = cnt-1;
- if (stopid<0)
- stopid = 0;
- if (stopid>=cnt)
- stopid = cnt-1;
- str << lut[startid] << ' ' << lut[stopid] << ' '
- << ctags.current()->colorname() << endl;
- ctags.next();
- }
+ if (!str) {
+ Tcl_AppendResult(interp, " unable to save color tags: ", fn, NULL);
+ result = TCL_ERROR;
+ return;
+ }
+
+ ctags.head();
+ while (ctags.current()) {
+ int startid = float(ctags.current()->start())/colorCount * cnt;
+ int stopid = float(ctags.current()->stop())/colorCount * cnt;
+ if (startid<0)
+ startid = 0;
+ if (startid>=cnt)
+ startid = cnt-1;
+ if (stopid<0)
+ stopid = 0;
+ if (stopid>=cnt)
+ stopid = cnt-1;
+
+ str << lut[startid] << ' ' << lut[stopid] << ' '
+ << ctags.current()->colorname() << endl;
+ ctags.next();
}
}
diff --git a/tksao/colorbar/colormap.h b/tksao/colorbar/colormap.h
index 9d1c006..45a66e0 100644
--- a/tksao/colorbar/colormap.h
+++ b/tksao/colorbar/colormap.h
@@ -53,7 +53,7 @@ public:
virtual ColorMapInfo* dup() =0;
virtual int load() =0;
virtual int load(const char*) =0;
- virtual void save(const char*) =0;
+ virtual int save(const char*) =0;
virtual unsigned char getRedChar(int, int) =0;
virtual unsigned char getGreenChar(int, int) =0;
diff --git a/tksao/colorbar/lut.C b/tksao/colorbar/lut.C
index 3b51110..08340c4 100644
--- a/tksao/colorbar/lut.C
+++ b/tksao/colorbar/lut.C
@@ -96,12 +96,13 @@ int LUTColorMap::load(const char* var)
return 1; // we found at least one RGBColor
}
-void LUTColorMap::save(const char* fn)
+int LUTColorMap::save(const char* fn)
{
ofstream fstr(fn);
if (!fstr)
- return;
+ return 0;
fstr << *this;
+ return 1;
}
unsigned char LUTColorMap::getRedChar(int ii, int count)
diff --git a/tksao/colorbar/lut.h b/tksao/colorbar/lut.h
index 8b8bdf3..8249572 100644
--- a/tksao/colorbar/lut.h
+++ b/tksao/colorbar/lut.h
@@ -57,7 +57,7 @@ public:
ColorMapInfo* dup() {return new LUTColorMap(*this);}
int load();
int load(const char* var);
- void save(const char*);
+ int save(const char*);
unsigned char getRedChar(int, int);
unsigned char getGreenChar(int, int);
diff --git a/tksao/colorbar/sao.C b/tksao/colorbar/sao.C
index c862371..10ff9bf 100644
--- a/tksao/colorbar/sao.C
+++ b/tksao/colorbar/sao.C
@@ -105,12 +105,13 @@ int SAOColorMap::load(const char* var)
return 1; // we found at least one LIColor for each RGB
}
-void SAOColorMap::save(const char* fn)
+int SAOColorMap::save(const char* fn)
{
ofstream f(fn);
if (!f)
- return;
+ return 0;
f << *this;
+ return 1;
}
unsigned char SAOColorMap::getColorChar(int i, int count, List<LIColor>* cc)
diff --git a/tksao/colorbar/sao.h b/tksao/colorbar/sao.h
index 8e1d357..b67b7a7 100644
--- a/tksao/colorbar/sao.h
+++ b/tksao/colorbar/sao.h
@@ -65,7 +65,7 @@ public:
ColorMapInfo* dup() {return new SAOColorMap(*this);}
int load();
int load(const char* var);
- void save(const char*);
+ int save(const char*);
unsigned char getRedChar(int i, int c) {return getColorChar(i,c,&red);}
unsigned char getGreenChar(int i, int c) {return getColorChar(i,c,&green);}