Changeset 1152 for trunk


Ignore:
Timestamp:
Sep 12, 2008, 1:29:18 PM (16 years ago)
Author:
gah
Message:

xylegend fixes

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r1126 r1152  
     12008-09-09:
    12
     3    * Created legend for xy plots.  You can raise/lower/show/hide/rename
     4      traces (curves).  There is also a provision for displaying the
     5      fill area between two curves and taking the average of two or
     6      more curves.
     7    * Nanovis markers now change the transfer function globally. Previously
     8      changing the a marker changes the transfer function for that volume
     9      only.  Now all volumes using that transfer function are affected.
     10    * Pymolproxy changed to use file transfer for PDB files.  This should
     11      prevent large datasets from breaking pymol.
     12    * Data sent to render servers now made in one write. Should improve
     13      performance for large datasets.
     14    * Nanovis server was profiled and improvements made to protocol.
     15    * "Abort" button fixed.  Previous version abort was disabled during
     16      simulation.
     17    * New checkbutton indicator for booleanentry (switch).
     18    * Empty sequences (pymol) are now checked.
     19    * Fixed heightmap (surface plot) grid to accurately measure the surface.
    220    * added bohr units and conversion to meters
    321    * added a free text label so users can label each element of a sequence.
     
    523    * changed boolean widget to use a simple checkbutton
    624    * added ability to set the color of integer and number widgets
    7         to a wavelength or range of wavelengths.
     25      to a wavelength or range of wavelengths.
    826       
    9272008-06-11: fixed bug in Ruby putfile() method (bhaley)
     
    11292008-03-30: Rappture 20080330 released
    12302008-02-18: added initial bindings and build scripts for Ruby (bhaley)
     31
  • trunk/gui/pkgIndex.tcl.in

    r1018 r1152  
    88        variable library $dir
    99    }
     10    package require Rappture
    1011    package provide RapptureGUI $version
    1112} $dir]
  • trunk/gui/scripts/visviewer.tcl

    r1142 r1152  
    149149    set hosts [split $hostlist ,]
    150150    set random_hosts {}
     151    set ticks [clock ticks]
     152    expr {srand($ticks)}
    151153    for { set i [llength $hosts] } { $i > 0 } { incr i -1 } {
    152154        set index [expr {round(rand()*$i - 0.5)}]
  • trunk/gui/scripts/xylegend.tcl

    r1141 r1152  
    2525    inherit itk::Widget
    2626
     27    private variable autocolors_ {
     28        #0000cd
     29        #cd0000
     30        #00cd00
     31        #3a5fcd
     32        #cdcd00
     33        #cd1076
     34        #009acd
     35        #00c5cd
     36        #a2b5cd
     37        #7ac5cd
     38        #66cdaa
     39        #a2cd5a
     40        #cd9b9b
     41        #cdba96
     42        #cd3333
     43        #cd6600
     44        #cd8c95
     45        #cd00cd
     46        #9a32cd
     47        #6ca6cd
     48        #9ac0cd
     49        #9bcd9b
     50        #00cd66
     51        #cdc673
     52        #cdad00
     53        #cd5555
     54        #cd853f
     55        #cd7054
     56        #cd5b45
     57        #cd6889
     58        #cd69c9
     59        #551a8b
     60    }
     61    private variable lastColorIndex_ ""
    2762    private variable _dispatcher "" ;# dispatcher for !events
    2863    private variable graph_     ""
    2964    private variable tree_      ""
    30     private variable diff_      ""
    31     private variable focus_     ""
     65    private variable diff_      "";     # Polygon marker used for difference.
     66    private variable rename_    "";     # Node selected to be renamed.
    3267    private variable diffelements_
    3368
     
    3570    destructor {}
    3671
    37     public method Activate {}
     72    public method reset {}
    3873    public method Average {}
    3974    public method Check {}
    40     public method Deactivate {}
    4175    public method Delete { args }
    4276    public method Difference {}
     
    163197            -applycommand [itcl::code $this Editor apply]
    164198    }
     199    set lastColorIndex_ [llength $autocolors_]
    165200    Check
    166201    eval itk_initialize $args
     
    171206# ----------------------------------------------------------------------
    172207itcl::body Rappture::XyLegend::destructor {} {
    173     Deactivate
     208    foreach node [$tree_ children root] {
     209        $tree_ delete $node
     210    }
     211    if { $diff_ != "" } {
     212        catch { $graph_ marker delete $diff_ }
     213    }
    174214}
    175215
     
    183223    $itk_component(legend) entry configure $node -label $label -icon $im \
    184224        -activeicon $im
     225    update idletasks
    185226    return $node
    186227}
    187228
    188229# ----------------------------------------------------------------------
    189 # USAGE: activate <curve> ?<settings>?
     230# USAGE: reset <curve> ?<settings>?
    190231#
    191232# Clients use this to add a curve to the plot.  The optional <settings>
     
    193234# -brightness, -width, -linestyle and -raise.
    194235# ----------------------------------------------------------------------
    195 itcl::body Rappture::XyLegend::Activate {} {
     236itcl::body Rappture::XyLegend::reset {} {
     237    foreach node [$tree_ children root] {
     238        $tree_ delete $node
     239    }
    196240    foreach elem [$graph_ element show] {
    197241        set label [$graph_ element cget $elem -label]
     
    202246    }
    203247    $itk_component(legend) open -recurse root
    204 }
    205 
    206 itcl::body Rappture::XyLegend::Deactivate {} {
    207     foreach node [$tree_ children root] {
    208         $tree_ delete $node
    209     }
     248    Check
    210249}
    211250
     
    355394        }
    356395    }
    357     if { [$itk_component(legend) index focus] != -1 } {
    358             $itk_component(controls).rename configure -state normal
    359     }
    360396    if { [$tree_ degree 0] > 1  && [llength $nodes] > 0 } {
    361397        foreach n { raise lower } {
     
    367403        }
    368404        1 {
    369             foreach n { hide show toggle } {
     405            foreach n { hide show toggle rename } {
    370406                $itk_component(controls).$n configure -state normal
    371407            }
     
    403439    set ycoords [blt::vector create \#auto -command ""]
    404440
     441    blt::busy hold $itk_component(hull)
     442    update
    405443    # Step 1. Get the x-values for each curve, then sort them to get the
    406444    #         unique values.
     
    450488    # Don't use the vector because we don't know when it will be cleaned up.
    451489
     490    if { $lastColorIndex_ == 0 } {
     491        set lastColorIndex_ [llength $autocolors_]
     492    }
     493    incr lastColorIndex_ -1
     494    set color [lindex $autocolors_ $lastColorIndex_]
    452495    $graph_ element create $name -label $label -x [$xcoords range 0 end]\
    453         -y [$sum range 0 end] -symbol scross
     496        -y [$sum range 0 end] -symbol scross -pixels 3 -color $color
    454497    blt::vector destroy $xcoords $ycoords $sum
    455498    set node [Add $name $label -delete]
    456499    Raise $node
     500    blt::busy forget $itk_component(hull)
    457501}
    458502
     
    484528    set diff_ [$graph_ marker create polygon \
    485529                   -coords [$m range 0 end] \
    486                    -elem $elem1 \
     530                   -element $elem1 \
    487531                   -stipple dot1 \
    488                    -outline "" -fill blue4 ]
     532                   -outline "" -fill "#cd69c9"]
    489533    blt::vector destroy $m $x $y
    490534    set diffelements_($elem1) 1
     
    519563        }
    520564        activate {
    521             set focus_ [$itk_component(legend) index focus]
    522             if { $focus_ == "" } {
     565            set rename_ [$itk_component(legend) curselection]
     566            if { $rename_ == "" } {
    523567                return;
    524568            }
    525             set label [$itk_component(legend) entry cget $focus_ -label]
    526             foreach { l r w h } [$itk_component(legend) bbox $focus_] break
     569            set label [$itk_component(legend) entry cget $rename_ -label]
     570            foreach { l r w h } [$itk_component(legend) bbox $rename_] break
    527571            set info(text) $label
    528572            set info(x) [expr $l + [winfo rootx $itk_component(legend)]]
     
    542586            }
    543587            set label [lindex $args 0]
    544             $itk_component(legend) entry configure $focus_ -label $label
    545             set elem [$tree_ label $focus_]
     588            $itk_component(legend) entry configure $rename_ -label $label
     589            set elem [$tree_ label $rename_]
    546590            $graph_ element configure $elem -label $label
    547591        }
  • trunk/gui/scripts/xyresult.tcl

    r1140 r1152  
    3030    #000080 #800000 #006600
    3131    #660066 #996600 #666600
    32 }
    33 set autocolors {
    34 #4876ff
    35 #00bfff
    36 #cae1ff
    37 #98f5ff
    38 #7fffd4
    39 #00ff7f
    40 #caff70
    41 #ffff00
    42 #ffc1c1
    43 #ffe7ba
    44 #ff4040
    45 #ff7f00
    46 #ff0000
    47 #ffaeb9
    48 #ff00ff
    49 #bf3dff
    50 #0000ff
    51 #87ceff
    52 #bfefff
    53 #00f5ff
    54 #c1ffc1
    55 #00ff00
    56 #fff68f
    57 #ffd700
    58 #ff6a6a
    59 #ffa54f
    60 #ff8c69
    61 #ff7256
    62 #ff1493
    63 #ff82ab
    64 #ff93fa
    65 #9b30ff
    6632}
    6733set autocolors {
     
    191157        rename -highlightbackground -controlbackground controlBackground Background
    192158    }
    193     pack $itk_component(reset) -padx 4 -pady 4 -anchor e
     159    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
    194160    Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
    195161
     
    274240    itk_component add legendbutton {
    275241        button $itk_component(controls).legendbutton \
    276             -borderwidth 1 -padx 3 -pady 0 \
     242            -borderwidth 1 -padx 2 -pady 0 -highlightthickness 0 \
    277243            -text "L" -font "-*-times new roman-bold-i-*-*-11-*-*-*-*-*-*-*" \
    278244            -command [itcl::code $this legend toggle]
     
    282248        rename -highlightbackground -controlbackground controlBackground Background
    283249    }
    284     pack $itk_component(legendbutton) -padx 4 -pady 4 -anchor e
     250    pack $itk_component(legendbutton) -padx 4 -pady { 0 2 } -anchor e
    285251   
    286252    itk_component add legend {
     
    289255    after idle [subst {
    290256        update idletasks
    291         $itk_component(legend) Activate
     257        $itk_component(legend) reset
    292258    }]
    293259    Rappture::Tooltip::for $itk_component(legendbutton) \
     
    439405    }
    440406
    441     # if anything changed, then rebuild the plot
     407    # If anything changed, then rebuild the plot
    442408    if {$changed} {
    443409        $_dispatcher event -idle !rebuild
    444410    }
    445411
    446     # nothing left? then start over with auto colors
     412    # Nothing left? then start over with auto colors
    447413    if {[llength $_clist] == 0} {
    448414        set _autoColorI 0
     
    810776        }
    811777    }
     778    $itk_component(legend) reset
    812779}
    813780
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r1142 r1152  
    4848#define IO_TIMEOUT (30000)
    4949
     50typedef struct {
     51    unsigned int date;
     52    size_t nFrames;             /* # of frames sent to client. */
     53    size_t nBytes;              /* # of bytes for all frames. */
     54    size_t nCommands;           /* # of commands executed */
     55    double cmdTime;             /* Elasped time spend executing commands. */
     56    struct timeval start;       /* Start of elapsed time. */
     57} Stats;
     58
     59static Stats stats;
     60
    5061static FILE *flog;
    5162static int debug = 1;
     
    91102} PymolProxy;
    92103
     104static int
     105ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr, Stats *statsPtr)
     106{
     107    struct timeval tv;
     108    double start, finish;
     109
     110    gettimeofday(&tv, NULL);
     111    start = ((double)tv.tv_sec) + ((double)tv.tv_usec * 1.0e-6);
     112    Tcl_Eval(interp, Tcl_DStringValue(dsPtr));
     113    trace("Executed (%s)", Tcl_DStringValue(dsPtr));
     114    Tcl_DStringSetLength(dsPtr, 0);
     115    gettimeofday(&tv, NULL);
     116   
     117    finish = ((double)tv.tv_sec) + ((double)tv.tv_usec * 1.0e-6);
     118    statsPtr->cmdTime += finish - start;
     119    statsPtr->nCommands++;
     120}
     121
     122static int
     123WriteStats(Stats *statsPtr, int code)
     124{
     125    struct timeval tv;
     126    double start, finish;
     127    int lockf;
     128    FILE *f;
     129    char *lockFileName, *statsFileName;
     130
     131    /* Get ending time.  */
     132    gettimeofday(&tv, NULL);
     133    finish = ((double)tv.tv_sec) + ((double)tv.tv_usec * 1.0e-6);
     134    tv = statsPtr->start;
     135    start = ((double)tv.tv_sec) + ((double)tv.tv_usec * 1.0e-6);
     136    for(;;) {
     137        lockf = open(lockFileName, O_EXCL | O_CREAT | O_TRUNC | O_WRONLY, 0600);
     138        if (lockf >= 0) {
     139            break;
     140        }
     141        if (errno != EEXIST) {
     142            fprintf(stderr, "can't open lock file \"%s\"\n: %s\n",
     143                    lockFileName, strerror(errno));
     144            return 0;
     145        }
     146        /* Need to turn off alarms first. */
     147        alarm(0);
     148        sleep(1);
     149    }
     150    f = fopen(statsFileName, "a+");
     151    if (f == NULL) {
     152        fprintf(f, "\"pymolproxy\",%d,%d,%d,%d,%d,%d,%g,%g",
     153                getpid(),
     154                code,
     155                statsPtr->date,
     156                statsPtr->nFrames,
     157                statsPtr->nBytes,
     158                statsPtr->nCommands,
     159                statsPtr->cmdTime,
     160                finish - start);
     161        fclose(f);
     162    }
     163    close(lockf);
     164    unlink(lockFileName);
     165    return 1;
     166}
     167
    93168INLINE static void
    94169dyBufferInit(DyBuffer *buffer)
     
    183258        result = 0;
    184259    }
    185     return(total);
     260    return total;
    186261}
    187262
     
    10321107{
    10331108    char buffer[800];
    1034     unsigned int bytes=0;
     1109    unsigned int nBytes=0;
    10351110    float samples = 0.0;
    10361111    PymolProxy *pymol = (PymolProxy *) cdata;
     
    10491124    waitForString(pymol, "image follows: ", buffer, 800);
    10501125
    1051     sscanf(buffer, "image follows: %d %f\n", &bytes, &samples);
     1126    sscanf(buffer, "image follows: %d %f\n", &nBytes, &samples);
    10521127 
    1053     write(3,&samples,sizeof(samples));
     1128    write(3, &samples, sizeof(samples));
    10541129 
    1055     dyBufferSetLength(&pymol->image, bytes);
     1130    dyBufferSetLength(&pymol->image, nBytes);
    10561131
    10571132    bread(pymol->p_stdout, pymol->image.data, pymol->image.used);
     
    10591134    waitForString(pymol, " ScenePNG", buffer,800);
    10601135
    1061     if (bytes && (pymol->image.used == bytes)) {
     1136    if ((nBytes > 0) && (pymol->image.used == nBytes)) {
    10621137        sprintf(buffer, "nv>image %d %d %d %d\n",
    1063                 bytes, pymol->cacheid, pymol->frame, pymol->rock_offset);
     1138                nBytes, pymol->cacheid, pymol->frame, pymol->rock_offset);
    10641139        trace("to-molvis> %s", buffer);
    10651140        write(pymol->c_stdin, buffer, strlen(buffer));
    1066         bwrite(pymol->c_stdin, pymol->image.data, bytes);
     1141        bwrite(pymol->c_stdin, pymol->image.data, nBytes);
     1142        stats.nFrames++;
     1143        stats.nBytes += nBytes;
    10671144    }
    10681145    return pymol->status;
     
    10731150{
    10741151    char buffer[800];
    1075     unsigned int bytes=0;
     1152    unsigned int nBytes=0;
    10761153    float samples = 0.0;
    10771154    PymolProxy *pymol = (PymolProxy *) cdata;
     
    10901167    waitForString(pymol, "image follows: ", buffer, 800);
    10911168
    1092     sscanf(buffer, "image follows: %d %f\n", &bytes, &samples);
     1169    sscanf(buffer, "image follows: %d %f\n", &nBytes, &samples);
    10931170    write(3,&samples,sizeof(samples));
    10941171
    1095     dyBufferSetLength(&pymol->image, bytes);
     1172    dyBufferSetLength(&pymol->image, nBytes);
    10961173
    10971174    bread(pymol->p_stdout, pymol->image.data, pymol->image.used);
    10981175
    1099     if (bytes && (pymol->image.used == bytes)) {
     1176    if ((nBytes > 0) && (pymol->image.used == nBytes)) {
    11001177        sprintf(buffer, "nv>image %d %d %d %d\n",
    1101                 bytes, pymol->cacheid, pymol->frame, pymol->rock_offset);
     1178                nBytes, pymol->cacheid, pymol->frame, pymol->rock_offset);
    11021179        write(pymol->c_stdin, buffer, strlen(buffer));
    11031180        trace("to-molvis buffer=%s\n", buffer);
    1104         bwrite(pymol->c_stdin, pymol->image.data, bytes);
     1181        bwrite(pymol->c_stdin, pymol->image.data, nBytes);
     1182        stats.nFrames++;
     1183        stats.nBytes += nBytes;
    11051184    }
    11061185    return pymol->status;
     
    11201199    int pid;
    11211200    PymolProxy pymol;
    1122     struct timeval now,end;
     1201    struct timeval now, end;
    11231202    int timeout;
    11241203
     
    12421321
    12431322    gettimeofday(&end, NULL);
    1244 
    1245     while(1)
    1246         {
    1247             char ch;
    1248 
    1249             gettimeofday(&now,NULL);
    1250 
    1251             if ( (!pymol.need_update) )
    1252                 timeout = -1;
    1253             else if ((now.tv_sec > end.tv_sec) || ( (now.tv_sec == end.tv_sec) && (now.tv_usec >= end.tv_usec)) )
    1254                 timeout = 0;
    1255             else
    1256                 {
    1257                     timeout = (end.tv_sec - now.tv_sec) * 1000;
    1258 
    1259                     if (end.tv_usec > now.tv_usec)
    1260                         timeout += (end.tv_usec - now.tv_usec) / 1000;
    1261                     else
    1262                         timeout += (((1000000 + end.tv_usec) - now.tv_usec) / 1000) - 1000;
    1263 
    1264                 }
    1265 
    1266             if (!pymol.immediate_update)
    1267                 status = poll(ufd, 3, timeout);
    1268             else
    1269                 status = 0;
    1270 
    1271             if ( status < 0 )
    1272                 {
    1273                     trace("pymolproxy: POLL ERROR: status = %d, errno = %d, %s \n", status,errno,strerror(errno));
    1274                 }
    1275             else if (status > 0)
    1276                 {
    1277                     gettimeofday(&now,NULL);
    1278 
    1279                     if (ufd[0].revents) { /* Client Stdout Connection: command input */
    1280                         if (read(ufd[0].fd,&ch,1) <= 0)
    1281                             {
    1282                                 if (errno != EINTR)
    1283                                     {
    1284                                         trace("pymolproxy: lost client connection (%d).\n", errno);
    1285                                         break;
    1286                                     }
    1287                             }
    1288                         else
    1289                             {
    1290                                 Tcl_DStringAppend(&cmdbuffer, &ch, 1);
    1291 
    1292                                 if (ch == '\n' && Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer))) {
    1293                                     Tcl_Eval(interp, Tcl_DStringValue(&cmdbuffer));
    1294                                     trace("Executed(%d,%d): %s", pymol.need_update, pymol.immediate_update, Tcl_DStringValue(&cmdbuffer));
    1295                                     Tcl_DStringSetLength(&cmdbuffer, 0);
    1296 
    1297                                     if (timeout == 0) status = 0; // send update
    1298                                 }
    1299                             }
    1300                     }
    1301 
    1302                     if (ufd[1].revents ) { /* pyMol Stdout Connection: pymol (unexpected) output */
    1303                         if (read(ufd[1].fd, &ch, 1) <= 0)
    1304                             {
    1305                                 if (errno != EINTR) {
    1306                                     trace("pymolproxy: lost connection (stdout) to pymol server\n");
    1307                                     break;
    1308                                 }
    1309                             }
    1310                         else
    1311                             {
    1312                                 dyBufferAppend(&dybuffer, &ch, 1);
    1313 
    1314                                 if (ch == '\n') {
    1315                                     ch = 0;
    1316                                     dyBufferAppend(&dybuffer, &ch, 1);
    1317                                     trace("STDOUT>%s",dybuffer.data);
    1318                                     dyBufferSetLength(&dybuffer,0);
    1319                                 }
    1320                             }
    1321                     }
    1322 
    1323                     if (ufd[2].revents) { /* pyMol Stderr Connection: pymol standard error output */
    1324                         if (read(ufd[2].fd, &ch, 1) <= 0)
    1325                             {
    1326                                 if (errno != EINTR) {
    1327                                     trace("pymolproxy: lost connection (stderr) to pymol server\n");
    1328                                     break;
    1329                                 }
    1330                             }
    1331                         else {
    1332                             dyBufferAppend(&dybuffer2, &ch, 1);
    1333 
    1334                             if (ch == '\n') {
    1335                                 ch = 0;
    1336                                 dyBufferAppend(&dybuffer2, &ch, 1);
    1337                                 trace("stderr>%s", dybuffer2.data);
    1338                                 dyBufferSetLength(&dybuffer2,0);
    1339                             }
    1340                         }
    1341                     }
    1342                 }
    1343 
    1344             if (status == 0)
    1345                 {
    1346                     gettimeofday(&now,NULL);
    1347 
    1348                     if (pymol.need_update && pymol.can_update)
    1349                         Tcl_Eval(interp, "bmp -\n");
    1350 
    1351                     end.tv_sec = now.tv_sec;
    1352                     end.tv_usec = now.tv_usec + 150000;
    1353 
    1354                     if (end.tv_usec >= 1000000)
    1355                         {
    1356                             end.tv_sec++;
    1357                             end.tv_usec -= 1000000;
    1358                         }
    1359 
    1360                 }
    1361 
    1362         }
    1363 
     1323    stats.start = end;
     1324    while(1) {
     1325        char ch;
     1326       
     1327        gettimeofday(&now,NULL);
     1328       
     1329        if ( (!pymol.need_update) )
     1330            timeout = -1;
     1331        else if ((now.tv_sec > end.tv_sec) || ( (now.tv_sec == end.tv_sec) && (now.tv_usec >= end.tv_usec)) )
     1332            timeout = 0;
     1333        else {
     1334            timeout = (end.tv_sec - now.tv_sec) * 1000;
     1335           
     1336            if (end.tv_usec > now.tv_usec)
     1337                timeout += (end.tv_usec - now.tv_usec) / 1000;
     1338            else
     1339                timeout += (((1000000 + end.tv_usec) - now.tv_usec) / 1000) - 1000;
     1340           
     1341        }
     1342       
     1343        if (!pymol.immediate_update)
     1344            status = poll(ufd, 3, timeout);
     1345        else
     1346            status = 0;
     1347       
     1348        if ( status < 0 ) {
     1349            trace("pymolproxy: POLL ERROR: status = %d, errno = %d, %s \n", status,errno,strerror(errno));
     1350        } else if (status > 0) {
     1351            gettimeofday(&now,NULL);
     1352           
     1353            if (ufd[0].revents) { /* Client Stdout Connection: command input */
     1354                if (read(ufd[0].fd,&ch,1) <= 0) {
     1355                    if (errno != EINTR) {
     1356                        trace("pymolproxy: lost client connection (%d).\n", errno);
     1357                        break;
     1358                    }
     1359                } else {
     1360                    Tcl_DStringAppend(&cmdbuffer, &ch, 1);
     1361                   
     1362                    if (ch == '\n' && Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer))) {
     1363                        ExecuteCommand(interp, &cmdbuffer, &stats);
     1364                        if (timeout == 0) status = 0; // send update
     1365                    }
     1366                }
     1367            }
     1368
     1369            if (ufd[1].revents ) { /* pyMol Stdout Connection: pymol (unexpected) output */
     1370                if (read(ufd[1].fd, &ch, 1) <= 0) {
     1371                    if (errno != EINTR) {
     1372                        trace("pymolproxy: lost connection (stdout) to pymol server\n");
     1373                        break;
     1374                    }
     1375                } else {
     1376                    dyBufferAppend(&dybuffer, &ch, 1);
     1377                   
     1378                    if (ch == '\n') {
     1379                        ch = 0;
     1380                        dyBufferAppend(&dybuffer, &ch, 1);
     1381                        trace("STDOUT>%s",dybuffer.data);
     1382                        dyBufferSetLength(&dybuffer,0);
     1383                    }
     1384                }
     1385            }
     1386           
     1387            if (ufd[2].revents) { /* pyMol Stderr Connection: pymol standard error output */
     1388                if (read(ufd[2].fd, &ch, 1) <= 0) {
     1389                    if (errno != EINTR) {
     1390                        trace("pymolproxy: lost connection (stderr) to pymol server\n");
     1391                        break;
     1392                    }
     1393                } else {
     1394                    dyBufferAppend(&dybuffer2, &ch, 1);
     1395                   
     1396                    if (ch == '\n') {
     1397                        ch = 0;
     1398                        dyBufferAppend(&dybuffer2, &ch, 1);
     1399                        trace("stderr>%s", dybuffer2.data);
     1400                        dyBufferSetLength(&dybuffer2,0);
     1401                    }
     1402                }
     1403            }
     1404        }
     1405       
     1406        if (status == 0) {
     1407            gettimeofday(&now,NULL);
     1408           
     1409            if (pymol.need_update && pymol.can_update)
     1410                Tcl_Eval(interp, "bmp -\n");
     1411           
     1412            end.tv_sec = now.tv_sec;
     1413            end.tv_usec = now.tv_usec + 150000;
     1414           
     1415            if (end.tv_usec >= 1000000) {
     1416                end.tv_sec++;
     1417                end.tv_usec -= 1000000;
     1418            }
     1419           
     1420        }
     1421       
     1422    }
     1423   
    13641424    status = waitpid(pid, &result, WNOHANG);
    1365 
     1425    WriteStats(&stats, status);
    13661426    if (status == -1) {
    13671427        trace("pymolproxy: error waiting on pymol server to exit (%d)\n", errno);
     
    13731433        alarm(0);
    13741434
    1375         while ((status == -1) && (errno == EINTR))
    1376             {
    1377                 trace("pymolproxy: Attempting to SIGKILL process.\n");
    1378                 kill(-pid, SIGKILL); // kill process group
    1379                 alarm(10);
    1380                 status = waitpid(pid, &result, 0);
    1381                 alarm(0);
    1382             }
    1383     }
    1384 
     1435        while ((status == -1) && (errno == EINTR)) {
     1436            trace("pymolproxy: Attempting to SIGKILL process.\n");
     1437            kill(-pid, SIGKILL); // kill process group
     1438            alarm(10);
     1439            status = waitpid(pid, &result, 0);
     1440            alarm(0);
     1441        }
     1442    }
     1443   
    13851444    trace("pymolproxy: pymol server process ended (%d)\n", result);
    1386 
     1445   
    13871446    dyBufferFree(&pymol.image);
    1388 
     1447   
    13891448    Tcl_DeleteInterp(interp);
    1390 
     1449   
    13911450    return( (status == pid) ? 0 : 1);
    13921451}
Note: See TracChangeset for help on using the changeset viewer.