Changeset 935 for trunk


Ignore:
Timestamp:
Mar 3, 2010 9:27:00 AM (11 years ago)
Author:
toby
Message:

EXPGUI:

  • Implement routine to locate window where user wants (see LocateWindow?)
  • allow pgplot in gsas/pgl or gsas/pgplot

Import_cif: make sure that missing or defaulted values for Uiso & occ are set to valid values.

gsascmds:

  • implement LocateWindow?
  • update to use saved pgplot location: $expgui(pgplotdir)
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/expgui_cfg.html

    r930 r935  
    166166files that cannot be
    167167run at the time when the files are sourced. <I>(added in EXPGUI v1.21)</I>
     168</DL>
     169  <P><B>Window location variables.</B> These variables determine where
     170the EXPGUI window is located on the screen.
     171Note that regardless of the values, the window will never be placed so
     172that any part is outside of the screen.
     173<DL>
     174<DT><FONT FACE="COURIER">expgui(xpos)</FONT><DD>
     175  Horizontal window location where 0 is fully to the left and 100 is
     176  fully to the right. Default is 50 (middle).
     177<DT><FONT FACE="COURIER">expgui(ypos)</FONT><DD>
     178  Vertical window location where 0 is fully to the top and 100 is
     179  fully to the bottom. Default is 50 (middle).
     180<DT><FONT FACE="COURIER">expgui(poscenter)</FONT><DD>
     181  Specifies what part of the window is placed at the specifed location: N for top and S for
     182  bottom; W for left and E for right. These letters can be combined,
     183  so that NS centers vertically and EW centers horizontally. Default
     184  is the middle of the window (NSEW).
     185<P>
     186  <B>Example 1:</B> This code placed in the localconfig or gsas.config
     187  (or .gsas_config) file causes the window to be placed in the lower
     188  right side of the screen. Depending on the screen size, it may be
     189  flush to the bottom-left:
     190<blockquote><PRE>
     191set expgui(xpos) 25
     192set expgui(ypos) 75
     193</PRE></blockquote>
     194<P>
     195  <B>Example 2:</B> Instead, this code causes the window to be placed on the right side of
     196  the screen, vertically centered, but only when the screen has more than 2000 pixels (probably
     197  indicating a dual-screen configuration)
     198<blockquote><PRE>
     199  if {[winfo screenwidth .] > 2000} {
     200    set expgui(xpos) 25
     201}
     202</PRE></blockquote>
     203
     204</DL>
     205
    168206</DL></DL>
    169207
     
    210248other systems do not. You can toggle this option using the
    211249"Override Backspace" option on the file menu to see what works for you.
    212 
    213250</DL></DL>
    214251
  • trunk/expgui

    r930 r935  
    223223    }
    224224}
    225 # do we have a PGPLOT fonts file?
    226 # if it is in the "wrong" place/name -- make it "right"
    227 if {![file exists [file join $expgui(gsasdir) pgl grfont.dat]] && \
    228         [file exists [file join $expgui(gsasdir) fonts grfont.dat]]} {
    229     catch {file mkdir [file join $expgui(gsasdir) pgl]}
    230     file copy [file join $expgui(gsasdir) fonts grfont.dat] \
    231             [file join $expgui(gsasdir) pgl grfont.dat]
    232 }
    233 # do we have a PGPLOT fonts file?
    234 if {![file exists [file join $expgui(gsasdir) pgl grfont.dat]] && \
    235         [file exists [file join $expgui(gsasdir) fonts pgfont.dat]]} {
    236     catch {file mkdir [file join $expgui(gsasdir) pgl]}
    237     file copy [file join $expgui(gsasdir) fonts pgfont.dat] \
    238             [file join $expgui(gsasdir) pgl grfont.dat]
    239 }
    240 # do we have a PGPLOT fonts file?
    241 if {![file exists [file join $expgui(gsasdir) pgl grfont.dat]] && \
    242         [file exists [file join $expgui(gsasdir) pgl pgfont.dat]]} {
    243     file copy [file join $expgui(gsasdir) pgl pgfont.dat] \
    244             [file join $expgui(gsasdir) pgl grfont.dat]
    245 }
    246 if ![file exists [file join $expgui(gsasdir) pgl grfont.dat]] {
     225# find the pgplot directory
     226if {[file exists [file join $expgui(gsasdir) pgl]]} {
     227    set expgui(pgplotdir) [file join $expgui(gsasdir) pgl]
     228} elseif {[file exists [file join $expgui(gsasdir) pgplot]]} {
     229    set expgui(pgplotdir) [file join $expgui(gsasdir) pgplot]
     230} else {
    247231    MyMessageBox -parent . -title "PGPLOT Error" \
    248             -message "Warning -- Unable to find file GRFONT.DAT in [file join $expgui(gsasdir) pgl]. GSAS graphics will not work. Is GSAS correctly installed?" \
     232            -message "Warning -- Unable to find PGPLOT directory. GSAS graphics will not work without this. Is GSAS correctly installed?" \
     233            -icon warning -type {"Limp Ahead"} -default "Limp Ahead" \
     234            -helplink "expguierr.html NoPGPLOT"
     235    set expgui(resize) 1
     236    set expgui(pgplotdir) ""
     237}
     238
     239# old code used to fix up bad distributions
     240# # do we have a PGPLOT fonts file?
     241# # if it is in the "wrong" place/name -- make it "right"
     242# if {![file exists [file join $expgui(pgplotdir) grfont.dat]] && \
     243#       [file exists [file join $expgui(gsasdir) fonts grfont.dat]]} {
     244#     catch {file mkdir $expgui(pgplotdir)}
     245#     file copy [file join $expgui(gsasdir) fonts grfont.dat] \
     246#           [file join $expgui(pgplotdir)  grfont.dat]
     247# }
     248# # do we have a PGPLOT fonts file?
     249# if {![file exists [file join $expgui(pgplotdir)  grfont.dat]] && \
     250#       [file exists [file join $expgui(gsasdir) fonts pgfont.dat]]} {
     251#     catch {file mkdir $expgui(pgplotdir)}
     252#     file copy [file join $expgui(gsasdir) fonts pgfont.dat] \
     253#           [file join $expgui(pgplotdir)  grfont.dat]
     254# }
     255# # do we have a PGPLOT fonts file?
     256# if {![file exists [file join $expgui(pgplotdir)  grfont.dat]] && \
     257#       [file exists [file join $expgui(pgplotdir)  pgfont.dat]]} {
     258#     file copy [file join $expgui(pgplotdir)  pgfont.dat] \
     259#           [file join $expgui(pgplotdir)  grfont.dat]
     260# }
     261
     262if { $expgui(pgplotdir) != "" && \
     263         ![file exists [file join $expgui(pgplotdir)  grfont.dat]]} {
     264    MyMessageBox -parent . -title "PGPLOT Error" \
     265            -message "Warning -- Unable to find file GRFONT.DAT in $expgui(pgplotdir). GSAS graphics will not work. Is GSAS correctly installed?" \
    249266            -icon warning -type {"Limp Ahead"} -default "Limp Ahead" \
    250267            -helplink "expguierr.html NoPGPLOT"
     
    282299}
    283300if {$expgui(expfile) == ""} {
    284     # center the parent window because the getExpFileName window
    285     # will be centered above it.
    286     wm withdraw .
    287     set x [expr [winfo screenwidth .]/2 - [winfo reqwidth .]/2 ]
    288     set y [expr [winfo screenheight .]/2 - [winfo reqheight .]/2]
    289     wm geom . +$x+$y
    290     wm deiconify .
     301    # place the parent window because the getExpFileName window will be centered above it.
     302    set xpos 50
     303    catch {set xpos $expgui(xpos)}
     304    set ypos 50
     305    catch {set ypos $expgui(ypos)}
     306    set poscntr "nsew"
     307    catch {set posnctr $expgui(poscenter)}
     308    LocateWindow "." $xpos $ypos $poscntr
    291309    # windows needed this update before when using tk_getOpenFile.
    292310    # I am not sure it is still needed.
     
    43904408    #wm geom . [winfo reqwidth .]x[winfo reqheight .]
    43914409    wm geom . {}
    4392     # center the EXPGUI window
    4393     wm withdraw .
    4394     set x [expr [winfo screenwidth .]/2 - [winfo reqwidth .]/2 ]
    4395     set y [expr [winfo screenheight .]/2 - [winfo reqheight .]/2]
    4396     wm geom . +$x+$y
    4397     wm deiconify .
    4398 }
    4399 
     4410}
     4411# place the EXPGUI window
     4412set xpos 50
     4413catch {set xpos $expgui(xpos)}
     4414set ypos 50
     4415catch {set ypos $expgui(ypos)}
     4416set poscntr "nsew"
     4417catch {set posnctr $expgui(poscenter)}
     4418LocateWindow "." $xpos $ypos $poscntr
     4419update
    44004420RaisePage lsFrame
    44014421if {[CountHistory] > 200} {
  • trunk/gsascmds.tcl

    r930 r935  
    464464    afterputontop
    465465    return $makenew(result)
     466}
     467
     468# place a window on a selected part of the screen
     469# xfrac specifies the hozontal position with 0 to the left and 100 to the right
     470# yfrac specifies the vertical position with 0 to the top and 100 to the bottom
     471# loc chooses the part of the window to place at that location: N: upper, S: lower, W: left, E: right
     472# use NSEW for center
     473proc LocateWindow {win {xfrac 50} {yfrac 50} {loc c}} {
     474    wm withdraw $win
     475    set maxx [winfo screenwidth $win]
     476    set maxy [winfo screenheight $win]
     477    set reqx [winfo reqwidth $win]
     478    set reqy [winfo reqheight $win]
     479    set x [expr {$maxx*$xfrac/100.}]
     480    set y [expr {$maxy*$yfrac/100.}]
     481    if {[string match -nocase "*e*" $loc] && [string match -nocase "*w*" $loc]} {
     482        # EW: center
     483        set x [expr {$x - $reqx/2. }]
     484    } elseif {[string match -nocase "*e*" $loc]} {
     485        # right corner
     486        set x [expr {$x - $reqx}]
     487    } elseif {[string match -nocase "*w*" $loc]} {     
     488        # left corner -- do nothing
     489    } else {
     490        # center
     491        set x [expr {$x - $reqx/2. }]
     492    }
     493    if {[string match -nocase "*n*" $loc] && [string match -nocase "*s*" $loc]} {
     494        # NS: center
     495        set y [expr {$y - $reqy/2 }]
     496    } elseif {[string match -nocase "*n*" $loc]} {
     497        # upper corner -- do nothing
     498    } elseif {[string match -nocase "*s*" $loc]} {
     499        # lower corner
     500        set y [expr {$y - $reqy}]
     501    } else {
     502        # center
     503        set y [expr {$y - $reqy/2 }]
     504    }
     505    set x [expr {int($x + 0.5)}]
     506    set y [expr {int($y + 0.5)}]
     507    if {$x < 0} {set x 0}
     508    if {$x > $maxx-$reqx} {set x [expr {$maxx-$reqx}]}
     509    if {$y < 0} {set y 0}
     510    if {$y > $maxy-$reqy} {set y [expr {$maxy-$reqy}]}
     511    wm geom $win +$x+$y
     512    wm deiconify $win
    466513}
    467514
     
    25252572        set env(GSAS) [file nativename $expgui(gsasdir)]
    25262573        # PGPLOT_FONT is needed by PGPLOT
    2527         set env(PGPLOT_FONT) [file nativename [file join $expgui(gsasdir) pgl grfont.dat]]
     2574        set env(PGPLOT_FONT) [file nativename [file join $expgui(pgplotdir) grfont.dat]]
    25282575        # this is the number of lines/page in the .LST (etc.) file
    25292576        set env(LENPAGE) 60
     
    26112658        set env(GSAS) [file nativename $expgui(gsasdir)]
    26122659        # PGPLOT_FONT is needed by PGPLOT
    2613         set env(PGPLOT_FONT) [file nativename [file join $expgui(gsasdir) pgl grfont.dat]]
     2660        set env(PGPLOT_FONT) [file nativename [file join $expgui(pgplotdir) grfont.dat]]
    26142661        # this is the number of lines/page in the .LST (etc.) file
    26152662        set env(LENPAGE) 60
     
    26382685                # replace the forward slashes with backward
    26392686                regsub -all / $cmd \\ cmd
     2687                # use of file attributes -shortname & normalize and nativename
     2688                # might help here
    26402689                exec $env(COMSPEC) /c \
    26412690                        "start [file join $expgui(scriptdir) $script] $cmd"
     
    26712720        set env(ATMXSECT) [file join $expgui(gsasdir) data atmxsect.dat]
    26722721        # PGPLOT_DIR is needed by PGPLOT
    2673         set env(PGPLOT_DIR) [file join $expgui(gsasdir) pgl]
     2722        set env(PGPLOT_DIR) $expgui(pgplotdir)
    26742723        # this is the number of lines/page in the .LST (etc.) file
    26752724        set env(LENPAGE) 60
     
    27172766        set env(GSAS) [file nativename $expgui(gsasdir)]
    27182767        # PGPLOT_FONT is needed by PGPLOT
    2719         set env(PGPLOT_FONT) [file nativename [file join $expgui(gsasdir) pgl grfont.dat]]
     2768        set env(PGPLOT_FONT) [file nativename [file join $expgui(pgplotdir) grfont.dat]]
    27202769        # this is the number of lines/page in the .LST (etc.) file
    27212770        set env(LENPAGE) 60
     
    27372786        set env(ATMXSECT) [file join $expgui(gsasdir) data atmxsect.dat]
    27382787        # PGPLOT_DIR is needed by PGPLOT
    2739         set env(PGPLOT_DIR) [file join $expgui(gsasdir) pgl]
     2788        set env(PGPLOT_DIR) $expgui(pgplotdir)
    27402789        # this is the number of lines/page in the .LST (etc.) file
    27412790        set env(LENPAGE) 60
  • trunk/import_cif.tcl

    r930 r935  
    173173            z [ValueFromCIF block${i} _atom_site_fract_z] \
    174174            lbl $lbllist uiso $uisolist occ $occlist type $typelist {
    175         if {$uiso == ""} {set uiso 0.025}
     175        # deal with defaults
     176        if {$occ == "" || $occ == "."} {set occ 1.0}
     177        if {$uiso == "" || $uiso == "."} {set uiso 0.025}
    176178        # should not be any quotes, but remove them, if there are
    177179        foreach var {lbl type} {
Note: See TracChangeset for help on using the changeset viewer.