From 302cb76db41b80c4f1736f0c57d5efa129fb9d44 Mon Sep 17 00:00:00 2001
From: William Joye <wjoye@cfa.harvard.edu>
Date: Fri, 2 Aug 2019 14:57:17 -0400
Subject: support multiple graphs per  plot

---
 ds9/library/plotprocess.tcl | 9 +++++++++
 ds9/parsers/plotparser.tac  | 2 +-
 ds9/parsers/plotparser.tcl  | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ds9/library/plotprocess.tcl b/ds9/library/plotprocess.tcl
index a09efa2..3497de2 100644
--- a/ds9/library/plotprocess.tcl
+++ b/ds9/library/plotprocess.tcl
@@ -314,6 +314,15 @@ proc PlotCmdExport {format fn} {
     PlotExport $cvarname $fn $format
 }
 
+proc PlotCmdDataSetName {name} {
+    global cvarname
+    upvar #0 $cvarname cvar
+
+    $cvar(mb).graph.select entryconfig "$cvar(graph,ds,name)" -label "$name"
+    set cvar(graph,ds,name) $name
+    $cvar(graph,proc,updateelement) $cvarname
+}
+
 proc ProcessSendPlotCmd {proc id param {sock {}} {fn {}}} {
     global iap
     global parse
diff --git a/ds9/parsers/plotparser.tac b/ds9/parsers/plotparser.tac
index ac6d581..fd1138a 100644
--- a/ds9/parsers/plotparser.tac
+++ b/ds9/parsers/plotparser.tac
@@ -293,7 +293,7 @@ plotCmd : LOAD_ load
  # backward compatibility
  | ERRORBAR_ errorr
  | RELIEF_ relief {PlotCmdUpdateElement graph,ds,bar,relief $2}
- | NAME_ STRING_ {PlotCmdUpdateElement graph,ds,name $2}
+ | NAME_ STRING_ {PlotCmdDataSetName $2}
 
  # backward compatibility
  | GRAPH_ oldGraph
diff --git a/ds9/parsers/plotparser.tcl b/ds9/parsers/plotparser.tcl
index 630dd8b..c78fdf0 100644
--- a/ds9/parsers/plotparser.tcl
+++ b/ds9/parsers/plotparser.tcl
@@ -5704,7 +5704,7 @@ proc plot::yyparse {} {
                     101 { PlotCmdUpdateElement graph,ds,fill $2 }
                     102 { PlotCmdUpdateElement graph,ds,fill,color $2 }
                     105 { PlotCmdUpdateElement graph,ds,bar,relief $2 }
-                    106 { PlotCmdUpdateElement graph,ds,name $2 }
+                    106 { PlotCmdDataSetName $2 }
                     109 { PlotCmdLoad $1 xy }
                     110 { PlotCmdLoad $1 $2 }
                     111 { PlotCmdExport [ExtToFormat $1] $1 }
-- 
cgit v0.12

