From: Maynard B. <Bra...@co...> - 2003-03-17 19:49:09
|
Hello. I'm building an Itcl class, PlotXY, containing a Plplot window and some buttons to allow control of axes formats, etc. I want to use a white background instead of the default black background. I use "$w cmd plscolbg 255 255 255" to set the white background. The plot appears correctly when I create the PlotXY object. When I change the plot settings and redraw the plot, I get a black background. If I cover all or part of the plot window with another window and then bring the plot window back to the front, the portion of the plot window that was covered has a white background. I'm running TclPro1.4 on a Windows 2000 machine. I'm using Vince Darley's binary Plplotter5.1.1 package. (Download from ftp://ftp.ucsd.edu/pub/alpha/tcl/extensions/plplotter5.1.1.zip; then unzip the entire contents into the lib subdirectory of your tcl). The script that follows demonstrates the problem. If I'm doing something wrong in my code, can someone please tell me what it is. If this is a problem in the Plplot library, can someone suggest where to start looking. I'll try to figure out a patch. Thanks in advance. -Maynard Brandsma #==== begin demo script ====================== # Demonstration of plwin background color problem # ------------------------------------------------------------------- # INSTRUCTIONS: # 1. Start a wish that knows about the Plplot library. # 2. From the prompt, do: "source PlotXY.itcl". A plot will appear # (red on white). # 3. Click on the "Revise" button. The plot will be redrawn with a # short X-axis and new labels on X and Y axes. The plot colors # will be red on black. # THE PROBLEM: # The background should still be white. If you move another window # to partially or completely cover the plot window and then expose # the plot window again, the background of the area covered changes # to white. # # ------------------------------------------------------------------- package require Itcl # uses Vince Darley's Plplotter Windows binary from his web site package require Plplotter # ------------------------------------------------------------------- # PlotXY plots an XY curve (defined internally for demo purposes) # Uses Plwindow.itcl from Plplot library directory # ------------------------------------------------------------------- ::itcl::class PlotXY { constructor { } {} destructor {} # Class Method Prototypes private method draw {w} private method setup {w} private method revise {w} # Class Data Members private variable _w ;# this window (toplevel) private variable _vpleft ;# left end of X-axis private variable _vpright ;# right end of X-axis private variable _vpbot ;# bottom end of Y-axis private variable _vptop ;# top end of Y-axis private variable _xmin ;# minimum X private variable _xmax ;# maximum X private variable _x_major_tick ;# X major tick interval private variable _x_num_minor_tick_int ;# subtick intervals private variable _ymin ;# minimum Y private variable _ymax ;# maximum Y private variable _y_major_tick ;# Y major tick interval private variable _y_num_minor_tick_int ;# subtick intervals private variable _xlab ;# X axis label private variable _ylab ;# Y axis label private variable _title ;# plot title private variable _npts } # ------------------------------------------------------------------- # PlotXY constructor body # ------------------------------------------------------------------- ::itcl::body PlotXY::constructor { } { set _w .[namespace tail $this] # This is a top level window catch {destroy $_w} toplevel $_w wm withdraw $_w wm title $_w "PlotXY" # Set up the plot window frames set _plot_frame [Plwindow $_w.plot] $_plot_frame configure -width 600 -height 400 set _control_frame \ [frame $_w.control -borderwidth 2 -relief ridge] label $_control_frame.lbl -text "Controls" pack $_control_frame.lbl -side top -padx 5 -pady 5 set _redraw_button [button $_w.control.redraw -text "Revise" \ -command [::itcl::code $this revise $_plot_frame]] pack $_redraw_button -side top -padx 5 -pady 5 pack $_control_frame -side left -padx 5 -pady 5 pack $_plot_frame -side right -padx 5 -pady 5 setup $_plot_frame wm geometry $_w +20+20 wm deiconify $_w } ::itcl::body PlotXY::setup {w} { # Define test data set _npts 6 matrix x float $_npts -persist = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 } matrix y float $_npts -persist = { 0.0, 0.1, 0.3, 0.8, 0.5, 0.3 } set _xmin 0.0 set _xmax 1.0 set _x_major_tick 0.2 set _x_num_minor_tick_int 2 set _ymin 0.0 set _ymax 1.0 set _y_major_tick 0.2 set _y_num_minor_tick_int 2 set _xlab (x) set _ylab (y) set _title "Plwindow demo plot" # Set up the viewport limits set _vpleft 0.15 set _vpright 0.9 set _vpbot 0.2 set _vptop 0.85 $w cmd plscolbg 255 255 255 ;# set background color to WHITE $w cmd plcol 1 ;# draw in red $this draw $w } ::itcl::body PlotXY::revise {w} { # Revise the plot format set _vpleft 0.35 set _xlab X-axis set _ylab Y-axis $this draw $w } ::itcl::body PlotXY::draw {w} { $w cmd pladv 0 $w cmd plvpor $_vpleft $_vpright $_vpbot $_vptop $w cmd plwind $_xmin $_xmax $_ymin $_ymax $w cmd plaxes $_xmin $_ymin \ bcints $_x_major_tick $_x_num_minor_tick_int \ bcintsv $_y_major_tick $_y_num_minor_tick_int $w cmd pllab $_xlab $_ylab $_title $w cmd plline $_npts x y ;# draw the line $w cmd plpoin $_npts x y 4 ;# symbol is hollow circle } # Make the plot window appear PlotXY w # ======= end demo script ================================== |