[Matrix-SIG] ezplot fixes/suggestions - again

Jeff Collins collins@seal.aero.org
Mon, 26 Jul 1999 09:06:57 -0700


I'm submitting these patches without fully understanding
the ezplot package, but they seem to fix the following problems:

1)  When cgm("on") is called before win("on"), then no x-window
is opened for plotting - only the cgm file is used.  The first portion
of the patch fixes this (though there is probably a better way).

2)  Corrected a typo to prevent font-lock problems in emacs

3)  Modified titles() to accept the window keyword, so that
different titles can be placed on different windows.  It wasn't
clear how to accomplish this without the fix.

Thanks,

Jeff




--- /usr/local/lib/python1.5/site-packages/oog/ezplot.py	Fri Jun 11 10:20:19 1999
+++ ezplot.py	Fri Jul 23 11:34:25 1999
@@ -227,8 +227,17 @@
    if val == "on" or val == "ON" or val == "On" \
       or val == "open" or val == "OPEN" or val == "Open" :
       _window_number_ = _check_win_ (_window_number_)
-      if _window_number_ == []:
+      _file_windows_ = []
+      _win_windows_ = _window_number_[:]
+      if _cgm_plotter_ in _win_windows_:
+         _file_windows_.append(_cgm_plotter_)
+         del _win_windows_[_cgm_plotter_]
+      if _ps_plotter_ in _win_windows_:
+         _file_windows_.append(_ps_plotter_)
+         del _win_windows_[_ps_plotter_]
+      if _win_windows_ == []:
          _window_number_ = [_get_free_win_number_ ( )]
+         _window_number_ = _window_number_ + _file_windows_
          if _window_number_ [0] < 0 :
             raise _WinSpecError_, "win ('open'): all windows are in use."
       for i in _window_number_:
@@ -267,7 +276,7 @@
 
 def new_plot_file ( filename ) :
    """new_plot_file ( ) will eventually return the name of the next
-   available file in the sequence "Aa00.ps/cgm", Ab00.ps/cgm", etc.
+   available file in the sequence "Aa00.ps/cgm", "Ab00.ps/cgm", etc.
    """
    if not os.path.isfile ("./" + filename) :
       return filename
@@ -508,6 +517,8 @@
             GistPlotter.Plotter ( "none" , n = _cgm_plotter_, hcp = _cgm_file_)
       _win_plotters_ [_cgm_plotter_].set_bytscl (_cmin_, _cmax_)
       _set_axis_limits_ ( )
+      if not hasattr (cgm, "win_no") :
+         win_no = _win_plotters_ [_cgm_plotter_]._n
       if _cgm_plotter_ != win_no :
          _object_list_ [_cgm_plotter_] = _object_list_ [win_no]
       if _current_graph_ [_cgm_plotter_] == None :
@@ -546,7 +557,9 @@
    if kw.has_key ("new_frame") :
       new_frame = kw ["new_frame"]
    elif _ezcshow_ == "false" :
-      new_frame = "no"
+      new_frame = "no" 
+   else:
+      new_frame = "yes"
    if val == "on" or val == "ON" or val == "On" \
       or val == "open" or val == "OPEN" or val == "Open" :
       _ps_ = "yes"
@@ -614,6 +627,8 @@
             GistPlotter.Plotter ( "none" , n = _ps_plotter_, hcp = _ps_file_)
       _win_plotters_ [_ps_plotter_].set_bytscl (_cmin_, _cmax_)
       _set_axis_limits_ ( )
+      if not hasattr (cgm, "win_no") :
+         win_no = _win_plotters_ [_cgm_plotter_]._n
       if _ps_plotter_ != win_no :
          _object_list_ [_ps_plotter_] = _object_list_ [win_no]
       if _current_graph_ [_ps_plotter_] == None :
@@ -743,7 +758,7 @@
    else :
       _displays_ = vals
 
-def titles (* vals) :
+def titles (*vals, **keywords):
    global _titles_
    if len (vals) == 0 :
       _titles_ = [defbot, deftop, defleft, defright]
@@ -761,6 +776,11 @@
       else :
          _titles_ [2] = defleft
          _titles_ [3] = defright
+   if keywords.has_key ("window") :
+      window = keywords ["window"]
+   else :
+      window = "all"
+   sf( window=window)
 
 def titleb (val) :
    global _titles_