Create Xref-Html Frames                    Remove All Frames
file:d:/code/LRC/Splicer/splicer_code_ver2.2/splicer-callbacks-c.c        (Fri Sep 03 17:16:36 2004 )


   1: /*
   2:  * Generated by the ICS builderXcessory (BX).
   3:  *
   4:  *
   5:  * Builder Xcessory 3.0.
   6:  *
   7:  */
   8: #include <Xm/Xm.h>
   9: #include <Xm/Text.h>
  10: #include <Xm/TextF.h>
  11: #include <Xm/ToggleB.h>
  12: #include <Xm/FileSB.h>
  13: #include <Xm/List.h>
  14: #include <X11/keysymdef.h>
  15: #include <X11/cursorfont.h>
  16: #include <stdio.h>
  17: #include<time.h>
  18: /*
  19:  * Standard includes for builtins.
  20:  */
  21: #include <string.h>
  22: #include <ctype.h>
  23: #include <math.h>
  24: #include <malloc.h>
  25: #include "splicer-creation-c.h"
  26: #include "splicer_vars.h"
  27: /*
  28:  * Macros to make code look nicer between ANSI and K&R.
  29:  */
  30: #ifndef ARGLIST
  31: #if (NeedFunctionPrototypes == 0)
  32: #define PROTOTYPE(p)  ()
  33: #define ARGLIST(p)  p
  34: #define ARG(a, b) a b;
  35: #define GRA(a, b) a b;
  36: #define UARG(a, b)      a b;
  37: #define GRAU(a, b)      a b;
  38: #else
  39: #define PROTOTYPE(p)  p
  40: #define ARGLIST(p)  (
  41: #define ARG(a, b) a b,
  42: #define GRA(a, b) a b)
  43: #ifdef __cplusplus
  44: #define UARG(a, b)      a,
  45: #define GRAU(a, b)      a)
  46: #else
  47: #define UARG(a, b)      a b,
  48: #define GRAU(a, b)      a b)
  49: #endif
  50: #endif
  51: #endif
  52: 
  53: Widget    BxFindTopShell PROTOTYPE((Widget));
  54: WidgetList  BxWidgetIdsFromNames PROTOTYPE((Widget, char*, char*));
  55: 
  56: void  XmFileSelectionDoSearch();
  57: 
  58: 
  59: /*      Function Name:  BxExitCB
  60:  *
  61:  *      Description:    This functions expects an integer to be passed in
  62:  *            client data.  It calls the exit() system call with
  63:  *      the integer value as the argument to the function.
  64:  *
  65:  *      Arguments:      Widget    w:  the activating widget.
  66:  *      XtPointer client: the integer exit value.
  67:  *      XtPointer call: the call data (unused).
  68:  */
  69: 
  70: /* ARGSUSED */
  71: void
  72: BxExitCB ARGLIST((w, client, call))
  73: UARG( Widget, w)
  74: ARG( XtPointer, client)
  75: GRAU( XtPointer, call)
  76: {
  77:     int   exitValue = (int)client;
  78:   void  exit();
  79:     
  80:     SpExit();
  81:     exit(exitValue);
  82: }
  83: 
  84: /*      Function Name:  SpDialogCB
  85:  *
  86:  *      Description:    This function causes the named dialog to be
  87:  *            managed and displayed.
  88:  *      
  89:  *
  90:  *      Arguments:      Widget    w:  the activating widget.
  91:  *      XtPointer client: dialog to manage
  92:  *      XtPointer call: the call data (unused).
  93:  */
  94: /* ARGSUSED */
  95: void
  96: SpDialogCB(w, client, call)
  97: Widget w;
  98: XtPointer client;
  99: XtPointer call;
 100: {
 101: }
 102: 
 103: 
 104: /*      Function Name:  SpOkSaveReportCB
 105:  *
 106:  *      Description:    This function sets up the report file information and
 107:  *            opens the file for use.
 108:  *      
 109:  *
 110:  *      Arguments:      Widget    w:  the activating widget
 111:  *      XtPointer client: unused
 112:  *      XtPointer call: the call data (unused).
 113:  */
 114: /* ARGSUSED */
 115: void
 116: SpOkSaveReportCB(w, client, call)
 117: Widget w;
 118: XtPointer client;
 119: XtPointer call;
 120: {
 121: }
 122: 
 123: /*      Function Name:  BxUnmanageCB
 124:  *
 125:  *      Description:    Given a string of the form:
 126:  *            "(WL)[widgetName, widgetName, ...]"
 127:  *      BxUnmanageCB attempts to convert the name to a Widget
 128:  *      ID and unmanage the widget.
 129:  *
 130:  *      Arguments:      Widget      w:      the widget activating the callback.
 131:  *            XtPointer   client: the list of widget names to attempt
 132:  *              to find and unmanage.
 133:  *            XtPointer   call:   the call data (unused).
 134:  *
 135:  *      Notes:        * This function expects that there is an application
 136:  *            shell from which all other widgets are descended.
 137:  */
 138: 
 139: /* ARGSUSED */
 140: void
 141: BxUnmanageCB ARGLIST((w, client, call))
 142: ARG( Widget, w)
 143: ARG( XtPointer, client)
 144: GRAU( XtPointer, call)
 145: {
 146:     WidgetList    widgets;
 147:     int     i;
 148: 
 149:     /*
 150:      * This function returns a NULL terminated WidgetList.  The memory for
 151:      * the list needs to be freed when it is no longer needed.
 152:      */
 153:     widgets = BxWidgetIdsFromNames(w, "BxUnmanageCB", (String)client);
 154: 
 155:     i = 0;
 156:     while( widgets && widgets[i] != NULL )
 157:     {
 158:   XtUnmanageChild(widgets[i]);
 159:   i++;
 160:     }
 161:     XtFree((char *)widgets);
 162: }
 163: 
 164: /*      Function Name:  SpCloseOKCB
 165:  *
 166:  *      Description:    This function closes the selected data files.
 167:  *            
 168:  *      
 169:  *
 170:  *      Arguments:      Widget    w:  PushButtonCloseOK
 171:  *      XtPointer client: unused
 172:  *      XtPointer call: the call data (unused).
 173:  */
 174: /* ARGSUSED */
 175: void
 176: SpCloseOKCB(w, client, call)
 177: Widget w;
 178: XtPointer client;
 179: XtPointer call;
 180: {
 181:   /*SUPPRESS 594*/
 182: }
 183: 
 184: 
 185: /*      Function Name:  SpCloseDataCB
 186:  *
 187:  *      Description:    This function displays the close data file selection
 188:  *            dialog that allows the user to select which of the 
 189:  *      open data files to close.
 190:  *
 191:  *      Arguments:      Widget    w:  pushButtonCloseData
 192:  *      XtPointer client: unused
 193:  *      XtPointer call: the call data (unused).
 194:  */
 195: /* ARGSUSED */
 196: void
 197: SpCloseDataCB(w, client, call)
 198: Widget w;
 199: XtPointer client;
 200: XtPointer call;
 201: {
 202:   /*SUPPRESS 594*/
 203: }
 204: 
 205: /*      Function Name:  BxManageCB
 206:  *
 207:  *      Description:    Given a string of the form:
 208:  *            "(WL)[widgetName, widgetName, ...]"
 209:  *      BxManageCB attempts to convert the name to a Widget
 210:  *      ID and manage the widget.
 211:  *
 212:  *      Arguments:      Widget      w:      the widget activating the callback.
 213:  *            XtPointer   client: the list of widget names to attempt
 214:  *              to find and manage.
 215:  *            XtPointer   call:   the call data (unused).
 216:  *
 217:  *      Notes:        * This function expects that there is an application
 218:  *            shell from which all other widgets are descended.
 219:  */
 220: 
 221: /* ARGSUSED */
 222: void
 223: BxManageCB ARGLIST((w, client, call))
 224: ARG( Widget, w)
 225: ARG( XtPointer, client)
 226: GRAU( XtPointer, call)
 227: {
 228:     WidgetList    widgets;
 229:     int     i;
 230: 
 231:     /*
 232:      * This function returns a NULL terminated WidgetList.  The memory for
 233:      * the list needs to be freed when it is no longer needed.
 234:      */
 235:     widgets = BxWidgetIdsFromNames(w, "BxManageCB", (String)client);
 236: 
 237:     i = 0;
 238:     while( widgets && widgets[i] != NULL )
 239:     {
 240:   XtManageChild(widgets[i]);
 241:   i++;
 242:     }
 243:     XtFree((char *)widgets);
 244: 
 245: }
 246: 
 247: 
 248: /*      Function Name:  SpOpenFilterCB
 249:  *
 250:  *      Description:    This function updates the files and directories 
 251:  *            in the open data file menu after a new filter
 252:  *      has been set.
 253:  *
 254:  *      Arguments:      Widget    w:  textOpenFilter
 255:  *      XtPointer client: unused
 256:  *      XtPointer call: the call data (unused).
 257:  */
 258: /* ARGSUSED */
 259: void
 260: SpOpenFilterCB(w, client, call)
 261: Widget w;
 262: XtPointer client;
 263: XtPointer call;
 264: {
 265:   /*SUPPRESS 594*/
 266:   SpUpdateOpen(FILE_FILTER);
 267: 
 268:         (void)sprintf(preview_input_path,"%s",current_path);
 269: }
 270: 
 271: /*      Function Name:  SpOpenSelectCB
 272:  *
 273:  *      Description:    This functions is called when the select file button
 274:  *      is pressed in the open file dialog. It finds the
 275:  *      selected files in the OpenFiles list and adds them
 276:  *      to the OpenSelected list. A warning is issued if an
 277:  *      attempt is made to add a duplicate file.
 278:  *
 279:  *      Arguments:      Widget    w:  widget pushButtonOpenSelect.
 280:  *      XtPointer client: the user data (unused).
 281:  *      XtPointer call: the call data (unused).
 282:  */
 283: /* ARGSUSED */
 284: void
 285: SpOpenSelectCB(w, client, call)
 286: Widget w;
 287: XtPointer client;
 288: XtPointer call;
 289: {
 290:   XmString  *selected,xmstring,*requested; 
 291:   int   item_count,selected_count,i,j,exists=False,count;
 292:   char    *bufptr,*filename;
 293:   void    XmListAddItem(),XmListSetPos(), XmListSetBottomPos();
 294: 
 295:   /*SUPPRESS 594*/
 296: /* get selected items from file list */
 297:   (void)XtVaGetValues(listOpenFiles, XmNselectedItemCount,&item_count,
 298:     XmNselectedItems,&requested, NULL);
 299:   (void)XtVaGetValues(listOpenSelected, XmNitemCount,&selected_count,
 300:     XmNitems,&selected, NULL);
 301:   count=selected_count;
 302: /* loop through files. Do not include if it already exists */
 303:         if(item_count < 1) {
 304:           return;
 305:         }
 306:   for(i=0;i<item_count;i++)
 307:   {
 308:     if(!XmStringGetLtoR(requested[i],XmFONTLIST_DEFAULT_TAG,&filename))
 309:     {
 310:       message.error=True;
 311:       message.fatal=False;
 312:                         message.caller=NONE;
 313:                         message.type=XmDIALOG_WARNING;
 314:                         message.default_button=XmDIALOG_OK_BUTTON;
 315:       if((message.label=(char*)calloc(200,CHAR_SIZE))==NULL)
 316:         SpBadMemAlloc("SpOpenSelectCB 0");
 317:       else
 318:         (void)sprintf(message.label,"Unable to get requested filename from list!");
 319:       SpManageMessage(message);
 320:     }
 321:     if((charptr=(char*)calloc((int)strlen(filename)+5,CHAR_SIZE))==NULL)
 322:       SpBadMemAlloc("SpOpenSelectCB 1");
 323:     (void)sprintf(charptr,"%s",filename);
 324:     XtFree(filename);
 325:     xmstring=XmCvtCTToXmString(charptr);
 326:   /* check if file is already in selected list, if not add to list*/
 327:     for(j=0;j<selected_count && !exists;j++)
 328:        if(XmStringCompare(xmstring,selected[j])) exists=True;
 329:     if(!exists)
 330:     {
 331:       XmListAddItem(listOpenSelected,xmstring,0);
 332:       count++;
 333:     }
 334:     else
 335:     {
 336:       if((bufptr=(char*)calloc((int)strlen(charptr)+50,CHAR_SIZE))==NULL)
 337:         SpBadMemAlloc("SpOpenSelectCB 2");
 338:       (void)sprintf(bufptr,"File %s is already selected!",charptr);
 339:       SpManageWarningBox(bufptr);
 340:       free(bufptr);
 341:     }
 342:     XmStringFree(xmstring);
 343:     free(charptr);
 344:     exists=False;
 345:   }
 346: /* clean up */
 347:   XmListSetPos(listOpenSelected,1);
 348:   XmListDeselectAllItems(listOpenFiles);
 349:   XmListSetBottomPos(listOpenSelected,count);
 350: }
 351: 
 352: /*      Function Name:  SpOpenDeselectCB
 353:  *
 354:  *      Description:   This function removes the selected name(s) from  
 355:  *            the file selected list.
 356:  *      
 357:  *
 358:  *      Arguments:      Widget    w:  pushButtonOpenDeselect
 359:  *      XtPointer client: the integer exit value.
 360:  *      XtPointer call: the call data (unused).
 361:  */
 362: /* ARGSUSED */
 363: void
 364: SpOpenDeselectCB(w, client, call)
 365: Widget w;
 366: XtPointer client;
 367: XtPointer call;
 368: {
 369:   int position_count;
 370:   int *ptr_list = NULL;
 371:   Boolean XmListGetSelectedPos();
 372:   void  XmListDeletePos();
 373: 
 374: /* get list of selected file(s) and remove from listOpenSelected */
 375: 
 376:   if(XmListGetSelectedPos(listOpenSelected,&ptr_list,&position_count)) {
 377:       while(--position_count>=0)
 378:         (void)XmListDeletePos(listOpenSelected,ptr_list[position_count]);
 379:           /* clean up area */
 380:     if(ptr_list) XtFree((char *)ptr_list);
 381:     XmListDeselectAllItems(listOpenSelected);
 382:         }
 383: }
 384: 
 385: /*      Function Name:  SpOpenDirectoriesCB
 386:  *
 387:  *      Description:    This function updates the files and directories 
 388:  *            in the open data file menu after a new directory
 389:  *      has been selected.
 390:  *
 391:  *      Arguments:      Widget    w:  listOpenDirectories
 392:  *      XtPointer client: unused
 393:  *      XtPointer call: the call data (unused).
 394:  */
 395: /* ARGSUSED */
 396: void
 397: SpOpenDirectoriesCB(w, client, call)
 398: Widget w;
 399: XtPointer client;
 400: XtPointer call;
 401: {
 402:   /*SUPPRESS 594*/
 403:   SpUpdateOpen(DIRECTORIES);
 404: 
 405:         (void)sprintf(preview_input_path,"%s",current_path);
 406: }
 407: 
 408: /*      Function Name:  SPOpenAffineCB
 409:  *
 410:  *      Description:    This function gets the current affine table values and
 411:  *            opens a file selection dialog for affine table.
 412:  *
 413:  *      Arguments:      Widget    w:  the activating widget.
 414:  *      XtPointer client: unused
 415:  *      XtPointer call: the call data (unused).
 416:  */
 417: /* ARGSUSED */
 418: void
 419: SpOpenAffineCB(w, client, call)
 420: Widget w;
 421: XtPointer client;
 422: XtPointer call;
 423: {
 424:   /*SUPPRESS 594*/
 425: 
 426:   XmToggleButtonSetState(toggleButtonUseAffine,affine.usetable,FALSE);
 427:   XmToggleButtonSetState(toggleButtonNotUseAffine,!affine.usetable,FALSE);
 428:         if(affine.usetable == True) {
 429:     if((charptr=(char*)calloc((int)strlen(affine.filename)+5,CHAR_SIZE))==NULL)
 430:     SpBadMemAlloc("SpOpenAffineCB 1");
 431:     (void)sprintf(charptr,"%s",affine.filename);
 432:           XmTextSetString(textFieldAffineFileName,charptr);
 433:     free(charptr);
 434:           XtSetSensitive(pushButtonSelectAffineFileName, True);
 435:         }
 436:         else {
 437:           XmTextSetString(textFieldAffineFileName,"");
 438:           XtSetSensitive(pushButtonSelectAffineFileName, False);
 439:         }
 440:   XtManageChild(formUseAffine); 
 441: }
 442: 
 443: /*      Function Name:  SpCancelCB
 444:  *
 445:  *      Description:    This function is called by the cancel buttons in th
 446:  *            splicer application. Different actions are taken depending
 447:  *      on which widget has initiated the cancel.
 448:  *
 449:  *      Arguments:      Widget    w:  the activating widget.
 450:  *      XtPointer client: form to close
 451:  *      XtPointer call: the call data (unused).
 452:  */
 453: /* ARGSUSED */
 454: void
 455: SpCancelCB(w, client, call)
 456: Widget w;
 457: XtPointer client;
 458: XtPointer call;
 459: {
 460:   XmString  xmstring;
 461:   char    *ctstring;
 462:   char  cflag[200];
 463:   int i;
 464: 
 465:   /*SUPPRESS 594*/
 466: /* close widget */
 467:   Widget *closewidget = (Widget*)client;
 468:   XtUnmanageChild(*closewidget);
 469: 
 470: /* change values if necessary */
 471:   if(*closewidget==messageBoxWorking)
 472:   {
 473:     XtVaGetValues(*closewidget,XmNmessageString,&xmstring,NULL);
 474:     if(!XmStringGetLtoR(xmstring,XmFONTLIST_DEFAULT_TAG,&ctstring))
 475:     {
 476:       message.error=True;
 477:       message.fatal=False;
 478:                         message.caller=NONE;
 479:                         message.type=XmDIALOG_WARNING;
 480:                         message.default_button=XmDIALOG_OK_BUTTON;
 481:       if((message.label=(char*)calloc(200,CHAR_SIZE))==NULL)
 482:         SpBadMemAlloc("SpCanceCB 1");
 483:       else
 484:         (void)sprintf(message.label,"Unable to get message from working box");
 485:       SpManageMessage(message);
 486:     }
 487:     (void)sscanf(ctstring,"%s",cflag);
 488:     XtFree(ctstring);
 489:     for(i=0;i<NUM_CLEANUP_TYPES && (int)strcmp(cflag,cleanup_type[i]);i++);
 490:     if(i<NUM_CLEANUP_TYPES)
 491:       SpCleanUp(i);
 492:     SpManageWarningBox("Clean-up after halt attempted. Program may be unstable.");
 493:     XtRemoveWorkProc(work_id);
 494:   }
 495:         if(*closewidget==formOpen) {
 496:           open_dataform_is_up = NO;
 497:         }
 498: }
 499: 
 500: 
 501: /*      Function Name:  SpSmoothMethodsCB
 502:  *
 503:  *      Description:    This function is called when the data smoothing option
 504:  *            is changed. It sets up the smoothing dialog properly for
 505:  *      the selected method.
 506:  *
 507:  *      Arguments:      Widget    w:  a smooth method toggle button
 508:  *      XtPointer client: none
 509:  *      XtPointer call: the call data (unused).
 510:  */
 511: /* ARGSUSED */
 512: void
 513: SpSmoothMethodsCB(w, client, call)
 514: Widget w;
 515: XtPointer client;
 516: XtPointer call;
 517: {
 518:   if(XmToggleButtonGetState(toggleButtonSmoothNone))  /* no filter */
 519:   {
 520:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,TRUE,FALSE);
 521:     XmToggleButtonSetState(toggleButtonSmoothOnly,FALSE,FALSE);
 522:     XmToggleButtonSetState(toggleButtonSmoothBoth,FALSE,FALSE);
 523:     XtSetSensitive(toggleButtonSmoothOnly,FALSE);
 524:     XtSetSensitive(toggleButtonSmoothBoth,FALSE);
 525:     XtSetSensitive(textFieldSmoothWidth,FALSE);
 526:     XtSetSensitive(optionMenuWidthUnits,FALSE);
 527: 
 528:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth, True, NULL);
 529:                 XmToggleButtonSetState(toggleButtonPlotSmooth, False, NULL);
 530:                 XmToggleButtonSetState(toggleButtonPlotBoth, False, NULL);
 531:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE); 
 532:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE); 
 533:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 534:   }
 535:   if(XmToggleButtonGetState(toggleButtonSmoothGaussian))  /* use gaussian filter */
 536:   {
 537:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,FALSE,FALSE);
 538:                 XmToggleButtonSetState(toggleButtonSmoothOnly,FALSE,FALSE);
 539:                 XmToggleButtonSetState(toggleButtonSmoothBoth,TRUE,FALSE);
 540:     XtSetSensitive(toggleButtonSmoothOnly,TRUE);
 541:     XtSetSensitive(toggleButtonSmoothBoth,TRUE);
 542:     XtSetSensitive(textFieldSmoothWidth,TRUE);
 543:     XtSetSensitive(optionMenuWidthUnits,TRUE);
 544: 
 545:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth, False, NULL); 
 546:                 XmToggleButtonSetState(toggleButtonPlotSmooth, False, NULL); 
 547:                 XmToggleButtonSetState(toggleButtonPlotBoth, True, NULL);
 548:                 XtSetSensitive(toggleButtonPlotSmooth,TRUE); 
 549:                 XtSetSensitive(toggleButtonPlotUnsmooth,TRUE); 
 550:                 XtSetSensitive(toggleButtonPlotBoth,TRUE);
 551:   }
 552:   else if(XmToggleButtonGetState(toggleButtonSmoothOther))  /* use other filter */
 553:   {
 554:   /* this option is not active, it sets the "none" option instead  and
 555:      warns the user */
 556:     XmToggleButtonSetState(toggleButtonSmoothOther,FALSE,FALSE);
 557:     XmToggleButtonSetState(toggleButtonSmoothNone,TRUE,FALSE);
 558:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,TRUE,FALSE);
 559:     XmToggleButtonSetState(toggleButtonSmoothOnly,FALSE,FALSE);
 560:     XmToggleButtonSetState(toggleButtonSmoothBoth,FALSE,FALSE);
 561:     XtSetSensitive(toggleButtonSmoothOnly,FALSE);
 562:     XtSetSensitive(toggleButtonSmoothBoth,FALSE);
 563:     XtSetSensitive(textFieldSmoothWidth,FALSE);
 564:     XtSetSensitive(optionMenuWidthUnits,FALSE);
 565:              
 566:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth, True, NULL); 
 567:                 XmToggleButtonSetState(toggleButtonPlotSmooth, False, NULL); 
 568:                 XmToggleButtonSetState(toggleButtonPlotBoth, False, NULL);
 569:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE); 
 570:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE); 
 571:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 572: 
 573:                 if((message.label=(char*)calloc(100,CHAR_SIZE))==NULL)
 574:                         SpBadMemAlloc("Sp");
 575:                 (void)sprintf(message.label,"This Option is incomplete.");
 576:                 SpManageMessage(message);
 577:   }
 578: }
 579: 
 580: 
 581: /*      Function Name:  SpOpenSmoothCB
 582:  *
 583:  *      Description:    This function sets up and manages the smoothing
 584:  *            information dialog.
 585:  *
 586:  *      Arguments:      Widget    w:  pushButtonOpenSmooth
 587:  *      XtPointer client: unused
 588:  *      XtPointer call: the call data (unused).
 589:  */
 590: /* ARGSUSED */
 591: void
 592: SpOpenSmoothCB(w, client, call)
 593: Widget w;
 594: XtPointer client;
 595: XtPointer call;
 596: {
 597:   /*SUPPRESS 594*/
 598: /* get current default values and set them in dialog */
 599: /* smoothing methods */
 600:   if(smooth.method==NONE)
 601:   {
 602:     XmToggleButtonSetState(toggleButtonSmoothNone,TRUE,FALSE);
 603:     XmToggleButtonSetState(toggleButtonSmoothGaussian,FALSE,FALSE);
 604:     XmToggleButtonSetState(toggleButtonSmoothOther,FALSE,FALSE);
 605:     XtSetSensitive(textFieldSmoothWidth,FALSE);
 606:     XtSetSensitive(optionMenuWidthUnits,FALSE);
 607:     XtSetSensitive(toggleButtonSmoothOnly,FALSE);
 608:     XtSetSensitive(toggleButtonSmoothBoth,FALSE);
 609: 
 610:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE);
 611:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE);
 612:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 613:   }
 614:   else if(smooth.method==GAUSSIAN)
 615:   {
 616:     XmToggleButtonSetState(toggleButtonSmoothNone,FALSE,FALSE);
 617:     XmToggleButtonSetState(toggleButtonSmoothGaussian,TRUE,FALSE);
 618:     XmToggleButtonSetState(toggleButtonSmoothOther,FALSE,FALSE);
 619:     XtSetSensitive(textFieldSmoothWidth,TRUE);
 620:     XtSetSensitive(optionMenuWidthUnits,TRUE);
 621:     XtSetSensitive(toggleButtonSmoothBoth,TRUE);
 622:     XtSetSensitive(toggleButtonSmoothOnly,TRUE);
 623: 
 624:                 XtSetSensitive(toggleButtonPlotSmooth,TRUE); 
 625:                 XtSetSensitive(toggleButtonPlotUnsmooth,TRUE); 
 626:                 XtSetSensitive(toggleButtonPlotBoth,TRUE);
 627:   }
 628:   else if (smooth.method==OTHER)
 629:   {
 630:   /* remember that this doesn't exist, use NONE instead */
 631:     XmToggleButtonSetState(toggleButtonSmoothNone,TRUE,FALSE);
 632:     XmToggleButtonSetState(toggleButtonSmoothGaussian,FALSE,FALSE);
 633:     XmToggleButtonSetState(toggleButtonSmoothOther,FALSE,FALSE);
 634:     XtSetSensitive(textFieldSmoothWidth,FALSE);
 635:     XtSetSensitive(optionMenuWidthUnits,FALSE);
 636:     XtSetSensitive(toggleButtonSmoothOnly,FALSE);
 637:     XtSetSensitive(toggleButtonSmoothBoth,FALSE);
 638: 
 639:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE); 
 640:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE); 
 641:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 642:   }
 643:   else
 644:     SpManageWarningBox("Invalid Smoothing method used!");
 645: /* plot display choice */
 646:   if(smooth.plot==UNSMOOTHED)
 647:   {
 648:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,TRUE,FALSE);
 649:     XmToggleButtonSetState(toggleButtonSmoothBoth,FALSE,FALSE);
 650:     XmToggleButtonSetState(toggleButtonSmoothOnly,FALSE,FALSE);
 651: 
 652:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,TRUE,NULL);
 653:                 XmToggleButtonSetState(toggleButtonPlotSmooth,FALSE,NULL);
 654:                 XmToggleButtonSetState(toggleButtonPlotBoth,FALSE,NULL);
 655:   }
 656:   else if(smooth.plot==SMOOTHED)
 657:   {
 658:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,FALSE,FALSE);
 659:     XmToggleButtonSetState(toggleButtonSmoothBoth,FALSE,FALSE);
 660:     XmToggleButtonSetState(toggleButtonSmoothOnly,TRUE,FALSE);
 661: 
 662:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,FALSE,NULL); 
 663:                 XmToggleButtonSetState(toggleButtonPlotSmooth,TRUE,NULL); 
 664:                 XmToggleButtonSetState(toggleButtonPlotBoth,FALSE,NULL);
 665:   }
 666:   else if(smooth.plot==SMOOTHEDBOTH)
 667:   {
 668:     XmToggleButtonSetState(toggleButtonUnsmoothOnly,FALSE,FALSE);
 669:     XmToggleButtonSetState(toggleButtonSmoothBoth,TRUE,FALSE);
 670:     XmToggleButtonSetState(toggleButtonSmoothOnly,FALSE,FALSE);
 671: 
 672:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,FALSE,NULL); 
 673:                 XmToggleButtonSetState(toggleButtonPlotSmooth,FALSE,NULL); 
 674:                 XmToggleButtonSetState(toggleButtonPlotBoth,TRUE,NULL);
 675:   }
 676:   else
 677:     SpManageWarningBox("Invalid smoothing display option found!");
 678: /* smoothing options */
 679:   if(smooth.width_units==DEPTH)
 680:     XtVaSetValues(optionMenuWidthUnits,XmNmenuHistory,pushButtonUnitsDepth,NULL);
 681:   else if(smooth.width_units==POINTS)
 682:     XtVaSetValues(optionMenuWidthUnits,XmNmenuHistory,pushButtonUnitsPoints,NULL);
 683:   else
 684:     SpManageWarningBox("Invalid smoothing units supplied.");
 685:   if((charptr=(char*)calloc(20,CHAR_SIZE))==NULL)
 686:     SpBadMemAlloc("SpOpenSmoothCB 1");
 687:   (void)sprintf(charptr,"%d",smooth.width);
 688:   XmTextSetString(textFieldSmoothWidth,charptr);
 689:   free(charptr);
 690: /* manage dialog */
 691:   XtManageChild(formSmooth);
 692: }
 693: 
 694: /*      Function Name:  SpSmoothOKCB
 695:  *
 696:  *      Description:    This function saves the user selected smoothing 
 697:  *            values and unmanages the smoothing dialog.
 698:  *      
 699:  *
 700:  *      Arguments:      Widget    w:  pushButtonSmoothOK
 701:  *      XtPointer client: none
 702:  *      XtPointer call: the call data (unused).
 703:  */
 704: /* ARGSUSED */
 705: void
 706: SpSmoothOKCB(w, client, call)
 707: Widget w;
 708: XtPointer client;
 709: XtPointer call;
 710: {
 711:         int i;
 712:   Widget  tmp_widget;
 713:   XmString xmstring;
 714:         Cursor   cursor;
 715:         void SmoothData(), DrawDrawingAreaEdit(), DrawDrawingAreaView(), DrawDrawingAreaSpliceToAge();
 716: 
 717:   /*SUPPRESS 594*/
 718: /* get smooth method */
 719:   if(XmToggleButtonGetState(toggleButtonSmoothNone)){
 720:     smooth.method=NONE;
 721:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE); 
 722:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE); 
 723:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 724:         }
 725:   else if(XmToggleButtonGetState(toggleButtonSmoothGaussian)){
 726:     smooth.method=GAUSSIAN;
 727:                 XtSetSensitive(toggleButtonPlotSmooth,TRUE); 
 728:                 XtSetSensitive(toggleButtonPlotUnsmooth,TRUE); 
 729:                 XtSetSensitive(toggleButtonPlotBoth,TRUE);
 730:         }
 731:   else if(XmToggleButtonGetState(toggleButtonSmoothOther)){
 732:     smooth.method=OTHER;
 733:                 XtSetSensitive(toggleButtonPlotSmooth,FALSE); 
 734:                 XtSetSensitive(toggleButtonPlotUnsmooth,FALSE); 
 735:                 XtSetSensitive(toggleButtonPlotBoth,FALSE);
 736:         }
 737: /* get plot display */
 738:   if(XmToggleButtonGetState(toggleButtonUnsmoothOnly)){
 739:     smooth.plot=UNSMOOTHED;
 740:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,TRUE,NULL);
 741:                 XmToggleButtonSetState(toggleButtonPlotSmooth,FALSE,NULL);
 742:                 XmToggleButtonSetState(toggleButtonPlotBoth,FALSE,NULL);
 743:         }
 744:   else if(XmToggleButtonGetState(toggleButtonSmoothOnly)){
 745:     smooth.plot=SMOOTHED;
 746:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,FALSE,NULL);
 747:                 XmToggleButtonSetState(toggleButtonPlotSmooth,TRUE,NULL);
 748:                 XmToggleButtonSetState(toggleButtonPlotBoth,FALSE,NULL);
 749:         }
 750:   else if(XmToggleButtonGetState(toggleButtonSmoothBoth)){
 751:     smooth.plot=SMOOTHEDBOTH;
 752:                 XmToggleButtonSetState(toggleButtonPlotUnsmooth,FALSE,NULL);
 753:                 XmToggleButtonSetState(toggleButtonPlotSmooth,FALSE,NULL);
 754:                 XmToggleButtonSetState(toggleButtonPlotBoth,TRUE,NULL);
 755:        }
 756: /* get width units */
 757:   XtVaGetValues(optionMenuWidthUnits,XmNmenuHistory,&tmp_widget,NULL);
 758:   if(tmp_widget==pushButtonUnitsDepth)
 759:     smooth.width_units=DEPTH;
 760:   else if(tmp_widget==pushButtonUnitsPoints)
 761:     smooth.width_units=POINTS;
 762: /* get width */
 763:   charptr=XmTextGetString(textFieldSmoothWidth);
 764:   smooth.width = atoi(charptr);
 765:         XtFree(charptr);
 766:         if(smooth.method != NONE && (smooth.width <= 0 || 
 767:            (smooth.width_units == DEPTH && smooth.width > MAXSMOOTHWIDTHDEPTH) ||
 768:            (smooth.width_units == POINTS && smooth.width > MAXSMOOTHWIDTHPOINTS))) { 
 769:           SpManageWarningBox("The width of the filter is unreasonable. Please re-enter.");
 770:           smooth.method = NONE;
 771:           return;
 772:         }
 773:         else if(smooth.method != NONE && smooth.width_units == POINTS && smooth.width < MINSMOOTHWIDTH) {
 774:           if((charptr=(char*)calloc(150,CHAR_SIZE))==NULL)
 775:                                         SpBadMemAlloc("SpSmoothOKCB");
 776:           (void)sprintf(charptr, "The width of the filter is too small. Please create a filter as wide or wider than %d pts.", 
 777:                                  MINSMOOTHWIDTH);
 778:           SpManageWarningBox(charptr);
 779:           free(charptr);
 780:           smooth.method = NONE;
 781:           return;
 782:         }
 783:         else if(have_data == DO && smooth.method != NONE && smooth.width_units == DEPTH && 
 784:                 smooth.width < MINSMOOTHWIDTH * average_depth_step) {
 785:           if((charptr=(char*)calloc(150,CHAR_SIZE))==NULL)
 786:                                         SpBadMemAlloc("SpSmoothOKCB");
 787:           (void)sprintf(charptr, "The width of the filter is too small. Please create a filter as wide or wider than %d cms.",
 788:                                  MINSMOOTHWIDTH * average_depth_step);
 789:           SpManageWarningBox(charptr);
 790:           free(charptr);
 791:           smooth.method = NONE; 
 792:           return;
 793:         }
 794:         if(smooth.method==NONE)
 795:     xmstring=XmCvtCTToXmString("No Smooth...");
 796:         else
 797:     xmstring=XmCvtCTToXmString("Smooth...");
 798:         XtVaSetValues(pushButtonOpenSmooth,XmNlabelString,xmstring,NULL);
 799:         XmStringFree(xmstring);
 800: /* unmanage dialog */
 801:         XtUnmanageChild(formSmooth);
 802: 
 803:         if(smooth.method != NONE && open_dataform_is_up == NO && have_data == DO) {
 804: 
 805:           cursor = XCreateFontCursor(XtDisplay(formSplicer), XC_watch);
 806:           if(cursor != BadAlloc && cursor != BadFont && cursor != BadValue) {
 807:             XDefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer), cursor);
 808:           }
 809:           for(i=0; i<dataset_cnt; ++i) {
 810:             SmoothData(i);
 811:           }
 812:           if(cursor) {
 813:             XUndefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer));
 814:             XFreeCursor(XtDisplay(formSplicer), cursor);
 815:           }
 816: 
 817:           if(XtIsManaged(XtParent(drawingAreaEdit))) {
 818:             reason_for_redraw = DRAW_EVERYTHING;
 819:             DrawDrawingAreaEdit(drawingAreaEdit, (XtPointer)NULL, (XtPointer)NULL);
 820:           }
 821:           if(have_splice == DO) {
 822:             if(XtIsManaged(XtParent(drawingAreaView))) {
 823:               reason_for_redraw = DRAW_EVERYTHING;
 824:               DrawDrawingAreaView(drawingAreaView, (XtPointer)NULL, (XtPointer)NULL);
 825:             }
 826:             if(are_agemodelling == YES) {
 827:               if(XtIsManaged(XtParent(drawingAreaSpliceToAge))) {
 828:                 reason_for_redraw = DRAW_EVERYTHING;
 829:                 DrawDrawingAreaSpliceToAge(drawingAreaSpliceToAge, (XtPointer)NULL, (XtPointer)NULL);
 830:               }
 831:             }
 832:           }
 833:         }
 834: }
 835: 
 836: /*      Function Name:  SpDecimateOKCB
 837:  *
 838:  *      Description:    This function saves the decimation options and
 839:  *            closes the dialog.
 840:  *      
 841:  *
 842:  *      Arguments:      Widget    w:  pushButtonDecimateOK
 843:  *      XtPointer client: unused
 844:  *      XtPointer call: the call data (unused).
 845:  */
 846: /* ARGSUSED */
 847: void
 848: SpDecimateOKCB(w, client, call)
 849: Widget w;
 850: XtPointer client;
 851: XtPointer call;
 852: {
 853:         int i;
 854:   XmString xmstring;
 855:         Cursor   cursor;
 856:         void DecimateData(), DrawDrawingAreaEdit(), DrawDrawingAreaView(), DrawDrawingAreaSpliceToAge();
 857: 
 858:   charptr=XmTextGetString(textFieldDecimate);
 859:         decimate_value = atoi(charptr);
 860:         
 861:   if(decimate_value>1)
 862:     xmstring=XmCvtCTToXmString("Decimate...");
 863:   else
 864:     xmstring=XmCvtCTToXmString("No Decimate...");
 865:   XtVaSetValues(pushButtonOpenDecimate,XmNlabelString,xmstring,NULL);
 866:   XmStringFree(xmstring);
 867: /* unmanage dialog */
 868:   XtUnmanageChild(formDecimate);
 869: 
 870:         /* if open_dataform_is_up == No then open data dialog is not up
 871:            therfore event came from progress menu, data menu decimate button push
 872:         */
 873:         if(open_dataform_is_up == NO && have_data == DO) {
 874:           cursor = XCreateFontCursor(XtDisplay(formSplicer), XC_watch);
 875:           if(cursor != BadAlloc && cursor != BadFont && cursor != BadValue) {
 876:             XDefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer), cursor);
 877:           }
 878:  
 879:           data[dset]->decimate_value = decimate_value;
 880:           DecimateData(dset, data[dset]->decimate_value);
 881:           
 882:           if(cursor) {
 883:             XUndefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer));
 884:             XFreeCursor(XtDisplay(formSplicer), cursor);
 885:           }
 886: 
 887:           if(XtIsManaged(XtParent(drawingAreaEdit))) {
 888:             reason_for_redraw = DRAW_EVERYTHING;
 889:             DrawDrawingAreaEdit(drawingAreaEdit, (XtPointer)NULL, (XtPointer)NULL);
 890:           }
 891:           if(have_splice == DO) {
 892:             if(XtIsManaged(XtParent(drawingAreaView))) {
 893:               reason_for_redraw = DRAW_EVERYTHING;
 894:               DrawDrawingAreaView(drawingAreaView, (XtPointer)NULL, (XtPointer)NULL);
 895:             }
 896:             if(are_agemodelling == YES) {
 897:               if(XtIsManaged(XtParent(drawingAreaSpliceToAge))) {
 898:                 reason_for_redraw = DRAW_EVERYTHING;
 899:                 DrawDrawingAreaSpliceToAge(drawingAreaSpliceToAge, (XtPointer)NULL, (XtPointer)NULL);
 900:               }
 901:             }
 902:           }
 903:         }
 904: }
 905: 
 906: /*      Function Name:  SpOpenDecimateCB
 907:  *
 908:  *      Description:    This function displays the decimation options.
 909:  *            
 910:  *      
 911:  *
 912:  *      Arguments:      Widget    w:  pushButtonOpenDecimate
 913:  *      XtPointer client: unused
 914:  *      XtPointer call: the call data (unused).
 915:  */
 916: /* ARGSUSED */
 917: void
 918: SpOpenDecimateCB(w, client, call)
 919: Widget w;
 920: XtPointer client;
 921: XtPointer call;
 922: {
 923:   /*SUPPRESS 594*/
 924: /* set values and display form */
 925:   if((charptr=(char*)calloc(20,CHAR_SIZE))==NULL)
 926:     SpBadMemAlloc("SpOpenDecimateCB 1");
 927:         if(open_dataform_is_up == NO && have_data == DO) {
 928:           (void)sprintf(charptr,"%d", data[dset]->decimate_value);
 929:         }
 930:         else {
 931:           (void)sprintf(charptr,"%d",decimate_value);
 932:         }
 933:   XmTextSetString(textFieldDecimate,charptr);
 934:   free(charptr);
 935:   XtManageChild(formDecimate);
 936: }
 937: 
 938: /*      Function Name:  SpUseAffineOKCB
 939:  *
 940:  *      Description:    This function saves the affine table defaults.
 941:  *
 942:  *      Arguments:      Widget    w:  pushButtonuseAffineOK
 943:  *      XtPointer client: unused
 944:  *      XtPointer call: the call data (unused).
 945:  */
 946: /* ARGSUSED */
 947: void
 948: SpUseAffineOKCB(w, client, call)
 949: Widget w;
 950: XtPointer client;
 951: XtPointer call;
 952: {
 953:         char            *testfile;
 954:         int             readable;
 955:   XmString  xmstring;
 956:         int             VerifyFileReadable();
 957: 
 958:   /*SUPPRESS 594*/
 959:   if((affine.usetable=XmToggleButtonGetState(toggleButtonUseAffine)))
 960:         {
 961:             testfile = XmTextGetString(textFieldAffineFileName);
 962:             readable = VerifyFileReadable(testfile, OPEN, OPENAFFINE);
 963:             if(readable == NO) {
 964:               (void)sprintf(buffer,"Affine table name  %s is not a readable file.",testfile);
 965:               free(testfile);
 966:               XmToggleButtonSetState(toggleButtonUseAffine, False, False);
 967:               XmToggleButtonSetState(toggleButtonNotUseAffine, True, False);
 968:               affine.usetable = False;
 969:               XmTextSetString(textFieldAffineFileName,"");
 970:               SpManageWarningBox(buffer);
 971:               return;
 972:             }
 973:             else {
 974:               XtFree(affine.filename);
 975:               if((affine.filename=(char*)calloc((int)strlen(testfile)+10, CHAR_SIZE)) == NULL) {
 976:                        SpBadMemAlloc("SpUseAffineOKCB");
 977:               }
 978:               (void)sprintf(affine.filename, "%s", testfile);
 979:               *strrchr(testfile,'/')= '\0';
 980:               if((affine.dirname=(char*)calloc((int)strlen(testfile)+10, CHAR_SIZE)) == NULL) {
 981:                        SpBadMemAlloc("SpUseAffineOKCB");
 982:               }
 983:               (void)sprintf(affine.dirname, "%s", testfile);
 984:               free(testfile);
 985:             }
 986: 
 987:     xmstring=XmCvtCTToXmString("Use Affine...");
 988:         }
 989:   else
 990:         {
 991:     xmstring=XmCvtCTToXmString("Don't Use Affine...");
 992:                 affine.usetable = False;
 993:         }
 994:   XtVaSetValues(pushButtonOpenAffine,XmNlabelString,xmstring,NULL);
 995:   XmStringFree(xmstring);
 996:   XtUnmanageChild(formUseAffine);
 997: }
 998: 
 999: /*      Function Name:  SpUseAffineCB
1000:  *
1001:  *      Description:    This function is called when the user has changed the
1002:  *            use affine table value.
1003:  *      
1004:  *
1005:  *      Arguments:      Widget    w:  toggleButtonUseAffine
1006:  *      XtPointer client: unused
1007:  *      XtPointer call: toggle button return.
1008:  */
1009: /* ARGSUSED */
1010: void
1011: SpUseAffineCB(w, client, call)
1012: Widget w;
1013: XtPointer client;
1014: XtPointer call;
1015: {
1016:   /*SUPPRESS 594*/
1017:         /* if Use affine is set, display file selection Dialog for Affine 
1018:         */
1019:   XmToggleButtonCallbackStruct *toggle_info=(XmToggleButtonCallbackStruct *) call;
1020:         affine.usetable = True;
1021:   if(toggle_info->set) {
1022:           if((charptr=(char*)calloc((int)strlen(affine.filename)+5,CHAR_SIZE))==NULL)
1023:                 SpBadMemAlloc("SpOpenAffineCB 1");
1024:           (void)sprintf(charptr,"%s",affine.filename);
1025:           XmTextSetString(textFieldAffineFileName,charptr);
1026:           free(charptr);
1027:           XtSetSensitive(pushButtonSelectAffineFileName, True);
1028:         }
1029: }
1030: 
1031: /*      Function Name:  SpCullOKCB
1032:  *
1033:  *      Description:    This function saves the culling options and closes the
1034:  *            dialog box.
1035:  *      
1036:  *
1037:  *      Arguments:      Widget    w:  pushButtonCullOK
1038:  *      XtPointer client: unused
1039:  *      XtPointer call: the call data (unused).
1040:  */
1041: /* ARGSUSED */
1042: void
1043: SpCullOKCB(w, client, call)
1044: Widget w;
1045: XtPointer client;
1046: XtPointer call;
1047: {
1048:         char            *testfile;
1049:   XmString  xmstring;
1050:   String    cstring;
1051:   int   tmp_type,tmp_format, readable;
1052:   Widget    tmp_widget;
1053:         Cursor          cursor;
1054:         void            CullData(), DrawDrawingAreaEdit(), DrawDrawingAreaView(), DrawDrawingAreaSpliceToAge();
1055:         int             VerifyFileReadable();
1056: 
1057:   /*SUPPRESS 594*/
1058: 
1059:         /* if are using a cull table get its file name and check that
1060:            it is readable
1061:         */
1062:         if(XmToggleButtonGetState(toggleButtonUseCullTable) == True) {
1063:           testfile = XmTextGetString(textFieldCullTableFilename);
1064:           readable = VerifyFileReadable(testfile, OPEN, OPENCULLTABLE);
1065:           if(readable == NO) {
1066:             (void)sprintf(buffer,"Cull table name  %s is not a readable file.",testfile);
1067:             free(testfile);
1068:             XmToggleButtonSetState(toggleButtonUseCullTable, False, False);
1069:             XmToggleButtonSetState(toggleButtonDontUseCullTable, True, False);
1070:             XmTextSetString(textFieldCullTableFilename,"");
1071:             SpManageWarningBox(buffer);
1072:             return;
1073:           }
1074:           else {
1075:             XtFree(cull.filename);
1076:             if((cull.filename=(char*)calloc((int)strlen(testfile)+10, CHAR_SIZE)) == NULL) {
1077:                        SpBadMemAlloc("SpUseAffineOKCB");
1078:             }
1079:             (void)sprintf(cull.filename, "%s", testfile);
1080:             *strrchr(testfile,'/')= '\0';
1081:             if((cull.dirname=(char*)calloc((int)strlen(testfile)+10, CHAR_SIZE)) == NULL) {
1082:                     SpBadMemAlloc("SpUseAffineOKCB");
1083:             }
1084:             (void)sprintf(cull.dirname, "%s", testfile);
1085:             free(testfile);
1086:           }
1087:         }
1088: 
1089: /* save cull values */
1090:         if(XmToggleButtonGetState(toggleButtonCullParameters) == True &&
1091:            XmToggleButtonGetState(toggleButtonUseCullTable) == True) {
1092:           cull.method = CULL_PARAMETER_AND_TABLE;
1093:         }
1094:   else if(XmToggleButtonGetState(toggleButtonCullParameters)) {
1095:     cull.method=CULL_PARAMETERS;
1096:         }
1097:   else if(XmToggleButtonGetState(toggleButtonUseCullTable)) {
1098:     cull.method=CULL_TABLE;
1099:         }
1100:   else {
1101:     cull.method=NONE;
1102:         }
1103: 
1104:         if(open_dataform_is_up == YES) {
1105:       XtVaGetValues(optionMenuOpenFormat,XmNmenuHistory,&tmp_widget,NULL);
1106:           XtVaGetValues(tmp_widget,XmNuserData,&tmp_format,NULL);
1107:         }
1108:         else if(have_data == DO) {
1109:           tmp_format = data[dset]->in_format;
1110:         }
1111:         else {
1112:           tmp_format = MST95REPORT;
1113:         }
1114: 
1115:         if(tmp_format == ODPOTHER) {
1116:           if(XmToggleButtonGetState(toggleButtonOpenFormatsOther1) == True) {
1117:             tmp_format = ODPOTHER1;
1118:           }
1119:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther2) == True) {
1120:             tmp_format = ODPOTHER2;
1121:           }
1122:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther3) == True) {
1123:             tmp_format = ODPOTHER3;
1124:           }
1125:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther4) == True) {
1126:             tmp_format = ODPOTHER4;
1127:           }
1128:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther5) == True) {
1129:             tmp_format = ODPOTHER5;
1130:           }
1131:           else {
1132:             tmp_format = ODPOTHER1;
1133:           }
1134:         }
1135:        
1136:         if(open_dataform_is_up == YES) {
1137:           XtVaGetValues(optionMenuOpenType,XmNmenuHistory,&tmp_widget,NULL);
1138:           XtVaGetValues(tmp_widget,XmNuserData,&tmp_type,NULL);
1139:         }
1140:         else if(have_data == DO) {
1141:           tmp_type = data[dset]->type;
1142:         }
1143:         else {
1144:           tmp_type = GRAPE;
1145:         }
1146:      
1147:   switch (tmp_type)
1148:   {
1149:     case GRAPE:
1150:       SpGetEquationValues(&cull.grape);
1151:       break;
1152:     case PWAVE:
1153:       SpGetEquationValues(&cull.pwave);
1154:       cstring=XmTextGetString(textFieldCullSignal);
1155:       cull.pwave_signal_max=(float)atof(cstring);
1156:       XtFree(cstring);
1157:       break;
1158:     case SUSCEPTIBILITY:
1159:       SpGetEquationValues(&cull.susceptibility);
1160:       break;
1161:     case NATURALGAMMA:
1162:       SpGetEquationValues(&cull.naturalgamma);
1163:       break;
1164:     case REFLECTANCEMST:
1165:       SpGetEquationValues(&cull.reflectance);
1166:       break;
1167:     case OTHERTYPE:
1168:       SpGetEquationValues(&cull.otherodp);
1169:       break;
1170:     default:
1171:       break;
1172:   }
1173:   cstring=XmTextGetString(textFieldCullTop);
1174:   cull.top=(float)atof(cstring);
1175:   XtFree(cstring);
1176:   if(XmToggleButtonGetState(toggleButtonCullUseAll))
1177:     cull.by_core_num=False;
1178:   else
1179:     cull.by_core_num=True;
1180:   cstring=XmTextGetString(textFieldCullCoreNum);
1181:   cull.max_core=(float)atof(cstring);
1182:   XtFree(cstring);
1183:   if(cull.method==NONE &&  cull.top <= 0.0 && !cull.by_core_num)
1184:     xmstring=XmCvtCTToXmString("No Cull...");
1185:   else
1186:     xmstring=XmCvtCTToXmString("Cull...");
1187:   XtVaSetValues(pushButtonOpenCull,XmNlabelString,xmstring,NULL);
1188:   XmStringFree(xmstring);
1189:     
1190: /* close dialog */
1191:   XtUnmanageChild(formCull);
1192: 
1193:         if(open_dataform_is_up == NO && have_data == DO) {
1194:           cursor = XCreateFontCursor(XtDisplay(formSplicer), XC_watch);
1195:           if(cursor != BadAlloc && cursor != BadFont && cursor != BadValue) {
1196:             XDefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer), cursor);
1197:           }
1198:           CullData(dset);
1199:           if(cursor) {
1200:             XUndefineCursor(XtDisplay(formSplicer), XtWindow(formSplicer));
1201:             XFreeCursor(XtDisplay(formSplicer), cursor);
1202:           }
1203: 
1204:           if(XtIsManaged(XtParent(drawingAreaEdit))) {
1205:             reason_for_redraw = DRAW_EVERYTHING;
1206:             DrawDrawingAreaEdit(drawingAreaEdit, (XtPointer)NULL, (XtPointer)NULL);
1207:           }
1208:           if(have_splice == DO) {
1209:             if(XtIsManaged(XtParent(drawingAreaView))) {
1210:               reason_for_redraw = DRAW_EVERYTHING;
1211:               DrawDrawingAreaView(drawingAreaView, (XtPointer)NULL, (XtPointer)NULL);
1212:             }
1213:             if(are_agemodelling == YES) {
1214:               if(XtIsManaged(XtParent(drawingAreaSpliceToAge))) {
1215:                 reason_for_redraw = DRAW_EVERYTHING;
1216:                 DrawDrawingAreaSpliceToAge(drawingAreaSpliceToAge, (XtPointer)NULL, (XtPointer)NULL);
1217:               }
1218:             }
1219:           }
1220:         }
1221: }
1222: 
1223: /*      Function Name:  SpOpenCullCB
1224: 
1225:  *
1226:  *      Description:    This function sets the cull values and opens the cull
1227:  *            menu dialog.
1228:  *      
1229:  *
1230:  *      Arguments:      Widget    w:  pushButtonOpenCull
1231:  *      XtPointer client: unused
1232:  *      XtPointer call: the call data (unused).
1233:  */
1234: /* ARGSUSED */
1235: void
1236: SpOpenCullCB(w, client, call)
1237: Widget w;
1238: XtPointer client;
1239: XtPointer call;
1240: {
1241:   Widget  *tmp_widget;
1242:   int tmp_type,tmp_format;
1243:   XmString  xmstring;
1244: 
1245:   /*SUPPRESS 594*/
1246: /* set cull method type*/
1247:         
1248:   if(cull.method==CULL_PARAMETERS || cull.method == CULL_PARAMETER_AND_TABLE)
1249:   {
1250:     XtSetSensitive(formCullOptions,True);
1251:     XmToggleButtonSetState(toggleButtonCullParameters,True,True);
1252:   }
1253:   if(cull.method==CULL_TABLE || cull.method == CULL_PARAMETER_AND_TABLE)
1254:   {
1255:     XmToggleButtonSetState(toggleButtonUseCullTable,True,True);
1256:     if((charptr=(char*)calloc((int)strlen(cull.filename)+10,CHAR_SIZE))==NULL)
1257:       SpBadMemAlloc("SpOpenCullCB 0");
1258:     (void)sprintf(charptr,"%s",cull.filename);
1259:                 XtVaSetValues(textFieldCullTableFilename, XmNvalue, charptr, NULL);
1260:     free(charptr);
1261:   }
1262:         if(cull.method!=CULL_PARAMETERS && cull.method != CULL_PARAMETER_AND_TABLE)
1263:         {
1264:     XtSetSensitive(formCullOptions,False);
1265:     XmToggleButtonSetState(toggleButtonCullNone,True,True);
1266:   }
1267:         if(cull.method!=CULL_TABLE && cull.method != CULL_PARAMETER_AND_TABLE)
1268:         {
1269:           XmToggleButtonSetState(toggleButtonDontUseCullTable,True,True);
1270:           XtVaSetValues(textFieldCullTableFilename, XmNvalue, "", NULL);
1271:           XtSetSensitive(pushButtonSelectCullTableFilename, False);
1272:         }
1273:         else if(cull.method==CULL_TABLE || cull.method == CULL_PARAMETER_AND_TABLE)
1274:         {
1275:           XtSetSensitive(pushButtonSelectCullTableFilename, True);
1276:         }
1277: 
1278:   if((charptr=(char*)calloc(20,CHAR_SIZE))==NULL)
1279:     SpBadMemAlloc("SpOpenCullCB 1");
1280:   (void)sprintf(charptr,"%.1f",cull.pwave_signal_max);
1281:   XmTextSetString(textFieldCullSignal,charptr);
1282:   (void)sprintf(charptr,"%.1f",cull.top);
1283:   XmTextSetString(textFieldCullTop,charptr);
1284:   if(cull.by_core_num)
1285:     XmToggleButtonSetState(toggleButtonCullByCore,True,True);
1286:   else
1287:     XmToggleButtonSetState(toggleButtonCullUseAll,True,True);
1288:   (void)sprintf(charptr,"%d",cull.max_core);
1289:   XmTextSetString(textFieldCullCoreNum,charptr);
1290:   free(charptr);
1291: /* set type/format label */
1292:         if(open_dataform_is_up == YES) {
1293:     XtVaGetValues(optionMenuOpenFormat,XmNmenuHistory,&tmp_widget,NULL);
1294:     XtVaGetValues(*tmp_widget,XmNuserData,&tmp_format,NULL);
1295:         }
1296:         else if(have_data == DO) {
1297:           tmp_format = data[dset]->in_format;
1298:         }
1299:         else {
1300:           tmp_format = MST95REPORT;
1301:         }
1302: 
1303:         if(tmp_format == ODPOTHER) {
1304:           if(XmToggleButtonGetState(toggleButtonOpenFormatsOther1) == True) {
1305:             tmp_format = ODPOTHER1;
1306:           }
1307:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther2) == True) {
1308:             tmp_format = ODPOTHER2;
1309:           }
1310:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther3) == True) {
1311:             tmp_format = ODPOTHER3;
1312:           }
1313:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther4) == True) {
1314:             tmp_format = ODPOTHER4;
1315:           }
1316:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther5) == True) {
1317:             tmp_format = ODPOTHER5;
1318:           }
1319:           else {
1320:             tmp_format = ODPOTHER1;
1321:           }
1322:         }
1323:         
1324:         if(open_dataform_is_up == YES) {
1325:           XtVaGetValues(optionMenuOpenType,XmNmenuHistory,&tmp_widget,NULL);
1326:           XtVaGetValues(*tmp_widget,XmNuserData,&tmp_type,NULL);
1327:         }
1328:         else if(have_data == DO) {
1329:           tmp_type = data[dset]->type;
1330:         }
1331:         else {
1332:           tmp_type = GRAPE;
1333:         }
1334:        
1335:   if((charptr=(char*)calloc((int)strlen(format[tmp_format])+(int)strlen(type[tmp_type])+50,CHAR_SIZE))==NULL)
1336:     SpBadMemAlloc("SpOpenCullCB 2");
1337:   (void)sprintf(charptr,"Data Format: %s   Type: %s",format[tmp_format],type[tmp_type]);
1338:   xmstring=XmCvtCTToXmString(charptr);
1339:   XtVaSetValues(labelCullFormatType,XmNlabelString,xmstring,NULL);
1340:   XmStringFree(xmstring);
1341:   free(charptr);
1342:   XtSetSensitive(labelCullSignal,False);
1343:   XtSetSensitive(textFieldCullSignal,False);
1344:   switch(tmp_type)
1345:   {
1346:           case GRAPE:
1347:                   SpSetEquationValues(cull.grape);
1348:       break;
1349:           case PWAVE:
1350:                         SpSetEquationValues(cull.pwave);
1351:                         XtVaGetValues(optionMenuOpenFormat,XmNmenuHistory,&tmp_widget,NULL);
1352:                         XtVaGetValues(*tmp_widget,XmNuserData,&tmp_format,NULL);
1353:                         if(tmp_format == MST95REPORT) {
1354:                       XtSetSensitive(textFieldCullSignal,TRUE);
1355:                       XtSetSensitive(labelCullSignal,TRUE);
1356:                         }
1357:             break;
1358:           case SUSCEPTIBILITY:
1359:                   SpSetEquationValues(cull.susceptibility);
1360:       break;
1361:           case NATURALGAMMA:
1362:                   SpSetEquationValues(cull.naturalgamma);
1363:       break;
1364:           case REFLECTANCEMST:
1365:                   SpSetEquationValues(cull.reflectance);
1366:             break;
1367:     case OTHERTYPE:
1368:                   SpSetEquationValues(cull.otherodp);
1369:             break;
1370:     default:
1371:       break;
1372:         }
1373: /* manage dialog */
1374:   XtManageChild(formCull);
1375: }
1376: 
1377: /*      Function Name:  SpOpenOKCB
1378:  *
1379:  *      Description:    This function saves the open data file values
1380:  *            and closes the form.
1381:  *
1382:  *      Arguments:      Widget    w:  pushButtonOpenOK
1383:  *      XtPointer client: unused
1384:  *      XtPointer call: the call data (unused).
1385:  */
1386: /* ARGSUSED */
1387: void
1388: SpOpenOKCB(w, client, call)
1389: Widget w;
1390: XtPointer client;
1391: XtPointer call;
1392: {
1393:   XmString  *items;
1394:   int info_len,i,tmp_len,len;
1395:   char  *info,*charptr,*tmp_buf,*filename, *openfilter;
1396:   Widget  tmp_widget;
1397: 
1398:   /*SUPPRESS 594*/
1399: 
1400: /* check if have exceeded number of datasets allowed
1401: */
1402:    if(dataset_cnt + 1 > NDATASET) {
1403:                 message.error=False;
1404:                 message.fatal=False;
1405:                 message.caller=OPENOK;
1406:                 message.type=XmDIALOG_WARNING;
1407:                 message.default_button=XmDIALOG_OK_BUTTON;
1408:                 if((message.label=(char*)calloc(100,CHAR_SIZE))==NULL)
1409:                         SpBadMemAlloc("SpOpenOKCB 1");
1410:                 (void)sprintf(message.label,"You have exceeded the number of data sets allowed!");
1411:                 SpManageMessage(message);
1412:                 return;
1413:    }
1414: 
1415: /* get file names */
1416:   XtVaGetValues(listOpenSelected, XmNitemCount,&openfileinfo.num_in_files, XmNitems,&items, NULL);
1417: /* no data files selected */
1418:   if(openfileinfo.num_in_files<=0)
1419:   {
1420:     message.error=False;
1421:     message.fatal=False;
1422:     message.caller=OPENOK;
1423:                 message.type=XmDIALOG_WARNING;
1424:                 message.default_button=XmDIALOG_OK_BUTTON;
1425:     if((message.label=(char*)calloc(50,CHAR_SIZE))==NULL)
1426:       SpBadMemAlloc("SpOpenOKCB 1");
1427:     (void)sprintf(message.label,"You must select at least one data file!");
1428:     SpManageMessage(message);
1429:     return;
1430:   }
1431:   if((openfileinfo.in_file_names=(char**)calloc(openfileinfo.num_in_files,sizeof(char*)))==NULL) 
1432:     SpBadMemAlloc("SpOpenOKCB 2");
1433:   for(i=0;i<openfileinfo.num_in_files;i++)
1434:   {
1435:     if(!XmStringGetLtoR(items[i],XmFONTLIST_DEFAULT_TAG,&filename))
1436:     {
1437:       message.error=True;
1438:       message.fatal=False;
1439:                         message.caller=OPENOK;
1440:                         message.type=XmDIALOG_WARNING;
1441:                         message.default_button=XmDIALOG_OK_BUTTON;
1442:       if((message.label=(char*)calloc(200,CHAR_SIZE))==NULL)
1443:         SpBadMemAlloc("SpOpenOKCB 1a");
1444:       else
1445:         (void)sprintf(message.label,"SpOpenOKCB: Unable to get filename from list");
1446:       SpManageMessage(message);
1447:     }
1448:                 else
1449:                 {
1450: 
1451:                   openfilter = XmTextGetString(textOpenFilter);
1452:                   len = (int)strlen(openfilter);
1453:                   if(strcmp(&openfilter[len-1], "*") == 0) {
1454:                     *strrchr(openfilter,'*')= '\0';
1455:                   }
1456:                   len = (int)strlen(openfilter);
1457:                   if(strcmp(&openfilter[len-1], "/") == 0) {
1458:                     *strrchr(openfilter,'/')= '\0';
1459:                   }
1460:                   if((openfileinfo.in_file_names[i]=(char*)calloc((int)strlen(openfilter)+(int)strlen(filename)+5,CHAR_SIZE))==NULL)
1461:                         SpBadMemAlloc("SpOpenOKCB 1b");
1462: 
1463:                   (void)sprintf(openfileinfo.in_file_names[i],"%s/%s",openfilter,filename);
1464:                   XtFree(openfilter);
1465:                   XtFree(filename);
1466:                 }
1467:   }
1468: /* get format & type */
1469:   XtVaGetValues(optionMenuOpenFormat,XmNmenuHistory,&tmp_widget,NULL);
1470:   XtVaGetValues(tmp_widget,XmNuserData,&openfileinfo.in_data_format,NULL);
1471: 
1472:         if(openfileinfo.in_data_format == ODPOTHER) {
1473:           if(XmToggleButtonGetState(toggleButtonOpenFormatsOther1) == True) {
1474:             openfileinfo.in_data_format = ODPOTHER1;
1475:           }
1476:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther2) == True) {
1477:             openfileinfo.in_data_format = ODPOTHER2;
1478:           }
1479:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther3) == True) {
1480:             openfileinfo.in_data_format = ODPOTHER3;
1481:           }
1482:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther4) == True) {
1483:             openfileinfo.in_data_format = ODPOTHER4;
1484:           }
1485:           else if(XmToggleButtonGetState(toggleButtonOpenFormatsOther5) == True) {
1486:             openfileinfo.in_data_format = ODPOTHER5;
1487:           }
1488:           else {
1489:             openfileinfo.in_data_format = ODPOTHER1;
1490:           }
1491:         }
1492:         if(openfileinfo.in_data_format == JANUS) {
1493:           if(XmToggleButtonGetState(toggleButtonJanusClean) == True) {
1494:             openfileinfo.in_data_format = JANUSCLEAN;
1495:           }
1496:           else if(XmToggleButtonGetState(toggleButtonJanusOrig) == True) {
1497:             openfileinfo.in_data_format = JANUSORIG;
1498:           }
1499:         }
1500:         
1501:         XtVaGetValues(optionMenuOpenType,XmNmenuHistory,&tmp_widget,NULL);
1502:         XtVaGetValues(tmp_widget,XmNuserData,&openfileinfo.in_data_type,NULL);
1503: 
1504: /* make tmp buffer */
1505:   tmp_len=1000;
1506:   if((tmp_buf=(char*)calloc(tmp_len,CHAR_SIZE))==NULL)
1507:     SpBadMemAlloc("SpOpenOKCB 5");
1508: /* create output text */
1509:   info_len=2000;
1510:   if((info=(char*)calloc(info_len,CHAR_SIZE))==NULL)
1511:     SpBadMemAlloc("SPOpenOKCB 6");
1512:   (void)sprintf(info,"\nSplicer Input Files:\n");
1513:   for(i=0;i<openfileinfo.num_in_files;i++)
1514:   {
1515:     if((int)strlen(info)+(int)strlen(openfileinfo.in_file_names[i])+2 >= info_len)
1516:     {
1517:       info_len+=500;
1518:       if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL)
1519:         SpBadMemAlloc("SpOpenOKCB 7");
1520:       else
1521:         info=charptr;
1522:     }
1523:     (void)strcat(info,openfileinfo.in_file_names[i]);
1524:     (void)strcat(info,"\n");
1525:   }
1526:   if((len=50+(int)strlen(type[openfileinfo.in_data_type]))>tmp_len)
1527:   {
1528:     tmp_len=len;
1529:     if((charptr=(char*)realloc(tmp_buf,tmp_len*CHAR_SIZE))==NULL)
1530:       SpBadMemAlloc("SpOpenOKCB 8");
1531:     else
1532:       tmp_buf=charptr;
1533:   }
1534:   (void)sprintf(tmp_buf,"\nData Type: %s\n",type[openfileinfo.in_data_type]);
1535:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1536:   {
1537:     info_len+=500;
1538:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL)
1539:                   SpBadMemAlloc("SpOpenOKCB 9");
1540:                 else 
1541:                   info=charptr;
1542:   }
1543:   (void)strcat(info,tmp_buf);
1544:         if((len=50+(int)strlen(format[openfileinfo.in_data_format]))>tmp_len) 
1545:         { 
1546:                 tmp_len=len;
1547:                 if((charptr=(char*)realloc(tmp_buf,tmp_len*CHAR_SIZE))==NULL)
1548:                         SpBadMemAlloc("SpOpenOKCB 10");
1549:                 else
1550:                         tmp_buf=charptr;
1551:   }
1552:   (void)sprintf(tmp_buf,"\nData File Format: %s\n",format[openfileinfo.in_data_format]);
1553:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1554:   {
1555:                 info_len+=500; 
1556:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1557:                         SpBadMemAlloc("SpOpenOKCB 11"); 
1558:                 else 
1559:                         info=charptr;
1560:   }
1561:   (void)strcat(info,tmp_buf);
1562:         if((len=50+(int)strlen(affine.filename)*2)>tmp_len)  
1563:         {  
1564:                 tmp_len=len;
1565:                 if((charptr=(char*)realloc(tmp_buf,tmp_len*CHAR_SIZE))==NULL) 
1566:                         SpBadMemAlloc("SpOpenOKCB 12"); 
1567:                 else
1568:                         tmp_buf=charptr;
1569:         }
1570:   if(affine.usetable)
1571:     (void)sprintf(tmp_buf,"\nAffine Table: %s\n",affine.filename);
1572:   else
1573:     (void)sprintf(tmp_buf,"\nNo Affine Table used.\n");
1574:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1575:   {
1576:                 info_len+=500; 
1577:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1578:                         SpBadMemAlloc("SpOpenOKCB 13"); 
1579:                 else 
1580:                         info=charptr;
1581:   }
1582:   (void)strcat(info,tmp_buf);
1583:         if((len=50+(int)strlen(smooth_units[smooth.width_units])+(int)strlen(plot_display[smooth.plot]))>tmp_len)  
1584:         {  
1585:                 tmp_len=len;
1586:                 if((charptr=(char*)realloc(tmp_buf,tmp_len*CHAR_SIZE))==NULL) 
1587:                         SpBadMemAlloc("SpOpenOKCB 14"); 
1588:                 else
1589:                         tmp_buf=charptr;
1590:         }
1591:   if(smooth.method==GAUSSIAN)
1592:     (void)sprintf(tmp_buf,"\nGaussian Smoothing: %d %s\nPlot Display: %s\n",
1593:           smooth.width,smooth_units[smooth.width_units],
1594:           plot_display[smooth.plot]);
1595:   else
1596:     (void)sprintf(tmp_buf,"\nNo data smoothing.\n");
1597:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1598:   {
1599:                 info_len+=500; 
1600:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1601:                         SpBadMemAlloc("SpOpenOKCB 15"); 
1602:                 else 
1603:                         info=charptr;
1604:   }
1605:   (void)strcat(info,tmp_buf);
1606:         if((len=100+(int)strlen(cull.filename))>tmp_len)  
1607:         {  
1608:                 tmp_len=len;
1609:                 if((charptr=(char*)realloc(tmp_buf,tmp_len*CHAR_SIZE))==NULL) 
1610:                         SpBadMemAlloc("SpOpenOKCB 16"); 
1611:                 else
1612:                         tmp_buf=charptr;
1613:         }
1614: 
1615:         if(cull.method!=CULL_TABLE && cull.method!=CULL_PARAMETERS && cull.method!=CULL_PARAMETER_AND_TABLE)
1616:         {
1617:                 (void)sprintf(tmp_buf,"\nNo culling by data values.\n");
1618:         }
1619:         else 
1620:         {
1621:     if(cull.method == CULL_PARAMETER_AND_TABLE)
1622:           {
1623:     (void)sprintf(tmp_buf,"\nCull Table: %s\n",cull.filename);
1624:                 strcat(tmp_buf, "Culling will be done with user set parameters.\n");  
1625:           }
1626:           else if(cull.method==CULL_TABLE) 
1627:           {
1628:                 (void)sprintf(tmp_buf,"\nCull Table: %s\n",cull.filename);
1629:           }
1630:     else if(cull.method==CULL_PARAMETERS)
1631:           {
1632:     (void)sprintf(tmp_buf,"\nCulling will be done with user set parameters.\n");
1633:           }
1634:         }
1635: 
1636:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1637:   {
1638:                 info_len+=500; 
1639:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1640:                         SpBadMemAlloc("SpOpenOKCB 17"); 
1641:                 else 
1642:                         info=charptr;
1643:   }
1644:   (void)strcat(info,tmp_buf);
1645:   (void)sprintf(tmp_buf,"Top %.1f cm will be removed from core.\n",cull.top);
1646:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1647:   {
1648:                 info_len+=500; 
1649:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1650:                         SpBadMemAlloc("SpOpenOKCB 18"); 
1651:                 else 
1652:                         info=charptr;
1653:   }
1654:   (void)strcat(info,tmp_buf);
1655:   if(cull.by_core_num)
1656:     (void)sprintf(tmp_buf,"Only cores <= %d will be used.\n",cull.max_core);
1657:   else
1658:     (void)sprintf(tmp_buf,"All cores will be used.\n");
1659:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1660:   {
1661:                 info_len+=500; 
1662:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL) 
1663:                         SpBadMemAlloc("SpOpenOKCB 19"); 
1664:                 else 
1665:                         info=charptr;
1666:   }
1667:   (void)strcat(info,tmp_buf);
1668:   if(decimate_value>1)
1669:     (void)sprintf(tmp_buf,"\nDecimation: every %d point will be used.\n",decimate_value);
1670:   else
1671:     (void)sprintf(tmp_buf,"\nEvery data point will be used.\n");
1672:   if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1673:   {
1674:                 info_len+=500;
1675:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL)
1676:                         SpBadMemAlloc("SpOpenOKCB 20"); 
1677:                 else 
1678:                         info=charptr;
1679:   }
1680:   (void)strcat(info,tmp_buf);
1681:   (void)sprintf(tmp_buf,"\nNote: multiple data values will be averaged.\n");
1682:         if((int)strlen(info)+(int)strlen(tmp_buf)+2 >=info_len)
1683:         {
1684:                 info_len+=500;
1685:                 if((charptr=(char*)realloc(info,info_len*CHAR_SIZE))==NULL)
1686:                         SpBadMemAlloc("SpOpenOKCB 21"); 
1687:                 else 
1688:                         info=charptr;
1689:         }
1690:         (void)strcat(info,tmp_buf);
1691: 
1692: /* display information window */
1693:   XmTextSetString(textOpenInfo,info);
1694:   XtManageChild(formOpenInfo);
1695:   free(info);
1696:   free(tmp_buf);
1697: }
1698: 
1699: /*      Function Name:  SpOpenDataCB
1700:  *
1701:  *      Description:    This function displays the dialog for choosing data
1702:  *            values for opening data files.
1703:  *      
1704:  *
1705:  *      Arguments:      Widget    w:  pushButtonOpenData
1706:  *      XtPointer client: unused
1707:  *      XtPointer call: the call data (unused).
1708:  */
1709: /* ARGSUSED */
1710: void
1711: SpOpenDataCB(w, client, call)
1712: Widget w;
1713: XtPointer client;
1714: XtPointer call;
1715: {
1716:   XmString  xmstring;
1717:   Widget    *tmp_widget;
1718:   int   len, tmp_format;
1719:   FILE    *fptr;
1720:   char    errorstring[500], *str;
1721:   /*SUPPRESS 594*/
1722:   message.error=False;
1723:   errorstring[0]='\0';
1724:         open_dataform_is_up = YES;
1725:         if(dataset_cnt > 1) {
1726:           decimate_value = 1;
1727:         }
1728:   if(affine.usetable)
1729:   {
1730:     if((fptr=fopen(affine.filename,"r"))==NULL)
1731:     {
1732:       message.error=True;
1733:       (void)sprintf(errorstring,"Affine table not found!");
1734:       affine.usetable=False;
1735:       xmstring=XmCvtCTToXmString("Don't Use Affine...");
1736:     }
1737:     else
1738:     {
1739:       fclose(fptr);
1740:       xmstring=XmCvtCTToXmString("Use Affine...");
1741:     }
1742:   }
1743:   else
1744:     xmstring=XmCvtCTToXmString("Don't Use Affine...");
1745:   XtVaSetValues(pushButtonOpenAffine,XmNlabelString,xmstring,NULL);
1746:   XmStringFree(xmstring);
1747:   if(cull.method==NONE && cull.top<=0.0 && !cull.by_core_num)
1748:     xmstring=XmCvtCTToXmString("No Cull...");
1749:   else if(cull.method==CULL_TABLE)
1750:   {
1751:     if((fptr=fopen(cull.filename,"r"))==NULL)
1752:     {
1753:       message.error=True;
1754:       (void)strcat(errorstring," Cull Table not found!");
1755:       cull.method=NONE;
1756:       if(cull.top<=0.0 && !cull.by_core_num)
1757:         xmstring=XmCvtCTToXmString("No Cull...");
1758:     }
1759:     else
1760:     {
1761:       fclose(fptr);
1762:       xmstring=XmCvtCTToXmString("Cull...");
1763:     }
1764:   }
1765:   else
1766:     xmstring=XmCvtCTToXmString("Cull...");
1767:   XtVaSetValues(pushButtonOpenCull,XmNlabelString,xmstring,NULL);
1768:   XmStringFree(xmstring);
1769:   if(smooth.method==None)
1770:     xmstring=XmCvtCTToXmString("No Smooth...");
1771:   else
1772:     xmstring=XmCvtCTToXmString("Smooth...");
1773:   XtVaSetValues(pushButtonOpenSmooth,XmNlabelString,xmstring,NULL);
1774:   XmStringFree(xmstring);
1775:   if(decimate_value>1)
1776:     xmstring=XmCvtCTToXmString("Decimate...");
1777:   else
1778:     xmstring=XmCvtCTToXmString("No Decimate...");
1779:   XtVaSetValues(pushButtonOpenDecimate,XmNlabelString,xmstring,NULL);
1780:   XmStringFree(xmstring);
1781: 
1782:         if(openfileinfo.in_data_format == MST95REPORT) {
1783:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenMST95Report, NULL);
1784:           XtSetSensitive(pushButtonOpenReflectance, True);
1785:           XtSetSensitive(pushButtonOpenGrape, True);
1786:           XtSetSensitive(pushButtonOpenPwave, True);
1787:           XtSetSensitive(pushButtonOpenSusceptibility, True);
1788:           XtSetSensitive(pushButtonOpenNaturalGamma, True);
1789:           XtSetSensitive(pushButtonOpenOtherType, False);
1790:         }
1791:         else if(openfileinfo.in_data_format == TKREPORT) {
1792:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenTKReport, NULL);
1793:           XtSetSensitive(pushButtonOpenReflectance, True);
1794:           XtSetSensitive(pushButtonOpenGrape, True);
1795:           XtSetSensitive(pushButtonOpenPwave, True);
1796:           XtSetSensitive(pushButtonOpenSusceptibility, True);
1797:           XtSetSensitive(pushButtonOpenNaturalGamma, True);
1798:           XtSetSensitive(pushButtonOpenOtherType, False);
1799:         }
1800:         else if(openfileinfo.in_data_format == ODPOTHER || openfileinfo.in_data_format == ODPOTHER1 ||
1801:                 openfileinfo.in_data_format == ODPOTHER2 || openfileinfo.in_data_format == ODPOTHER3 ||
1802:                 openfileinfo.in_data_format == ODPOTHER4 || openfileinfo.in_data_format == ODPOTHER5) {
1803:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenODPOther, NULL);
1804:           XtSetSensitive(pushButtonOpenReflectance, True);
1805:           XtSetSensitive(pushButtonOpenGrape, True);
1806:           XtSetSensitive(pushButtonOpenPwave, True);
1807:           XtSetSensitive(pushButtonOpenSusceptibility, True);
1808:           XtSetSensitive(pushButtonOpenNaturalGamma, True);
1809:           XtSetSensitive(pushButtonOpenOtherType, True);
1810:         }
1811:         else if(openfileinfo.in_data_format == OSUSCAT) {
1812:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenOSUSCAT, NULL);
1813:           XtSetSensitive(pushButtonOpenReflectance, True);
1814:           XtSetSensitive(pushButtonOpenGrape, False);
1815:           XtSetSensitive(pushButtonOpenPwave, False);
1816:           XtSetSensitive(pushButtonOpenSusceptibility, False);
1817:           XtSetSensitive(pushButtonOpenNaturalGamma, False);
1818:           XtSetSensitive(pushButtonOpenOtherType, False);
1819:         }
1820:         else if(openfileinfo.in_data_format == JANUSCLEAN || openfileinfo.in_data_format == JANUSORIG) {
1821:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenJANUS, NULL);
1822:           XtSetSensitive(pushButtonOpenReflectance, True);
1823:           XtSetSensitive(pushButtonOpenGrape, True);
1824:           XtSetSensitive(pushButtonOpenPwave, True);
1825:           XtSetSensitive(pushButtonOpenSusceptibility, True);
1826:           XtSetSensitive(pushButtonOpenNaturalGamma, True);
1827:           XtSetSensitive(pushButtonOpenOtherType, False);
1828:         }
1829:         else {
1830:           openfileinfo.in_data_format = MST95REPORT;
1831:           XtVaSetValues(optionMenuOpenFormat, XmNmenuHistory, pushButtonOpenMST95Report, NULL);
1832:           XtSetSensitive(pushButtonOpenReflectance, True);
1833:           XtSetSensitive(pushButtonOpenGrape, False);
1834:           XtSetSensitive(pushButtonOpenPwave, False);
1835:           XtSetSensitive(pushButtonOpenSusceptibility, False);
1836:           XtSetSensitive(pushButtonOpenNaturalGamma, False);
1837:           XtSetSensitive(pushButtonOpenOtherType, False);
1838:         }
1839:         if(openfileinfo.in_data_format == JANUSORIG) {
1840:           XmToggleButtonSetState(toggleButtonHeaderNo, True, NULL);
1841:           XmToggleButtonSetState(toggleButtonHeaderYes, False, NULL);
1842:           XtSetSensitive(toggleButtonHeaderNo, False);
1843:           XtSetSensitive(toggleButtonHeaderYes, False);
1844:           XtSetSensitive(textFieldNHeader, False);
1845:         }
1846:         else {
1847:           XtSetSensitive(toggleButtonHeaderNo, True);
1848:           XtSetSensitive(toggleButtonHeaderYes, True);
1849:           XtSetSensitive(textFieldNHeader, True);
1850:         }
1851:         if(openfileinfo.in_data_format == JANUSCLEAN) {
1852:           XmToggleButtonSetState(toggleButtonJanusOrig, False, NULL);
1853:           XmToggleButtonSetState(toggleButtonJanusClean, True, NULL);
1854:         }
1855:         else if(openfileinfo.in_data_format == JANUSORIG) {
1856:           XmToggleButtonSetState(toggleButtonJanusOrig, True, NULL);
1857:           XmToggleButtonSetState(toggleButtonJanusClean, False, NULL);
1858:         }
1859:         else {
1860:           XmToggleButtonSetState(toggleButtonJanusOrig, True, NULL);
1861:           XmToggleButtonSetState(toggleButtonJanusClean, False, NULL);
1862:         }
1863: 
1864:         /* set data type. note that format type OSUSCAT is always reflectance
1865:         */
1866:         if(openfileinfo.in_data_format == OSUSCAT) {
1867:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenReflectance, NULL);
1868:         }
1869:         else if(openfileinfo.in_data_type == GRAPE) {
1870:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenGrape, NULL);
1871:         }
1872:         else if(openfileinfo.in_data_type == PWAVE) {
1873:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenPwave, NULL);
1874:         }
1875:         else if(openfileinfo.in_data_type == SUSCEPTIBILITY) { 
1876:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenSusceptibility, NULL);
1877:         }
1878:         else if(openfileinfo.in_data_type == NATURALGAMMA) { 
1879:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenNaturalGamma, NULL);
1880:         }
1881:         else if(openfileinfo.in_data_type == REFLECTANCEMST) { 
1882:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenReflectance, NULL);
1883:         }
1884:         else if(openfileinfo.in_data_type == OTHERTYPE) { 
1885:           if(openfileinfo.in_data_format == MST95REPORT || openfileinfo.in_data_format == TKREPORT ||
1886:              openfileinfo.in_data_format == JANUSCLEAN || openfileinfo.in_data_format == JANUSORIG) {
1887:             /*MST95 and TK and Janus formats do not have an other type */
1888:             XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenGrape, NULL);
1889:           }
1890:           else {
1891:             XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenOtherType, NULL);
1892:           }
1893:         }
1894:         else {
1895:           openfileinfo.in_data_type = GRAPE;
1896:           XtVaSetValues(optionMenuOpenType, XmNmenuHistory, pushButtonOpenGrape, NULL);
1897:         } 
1898: 
1899:         XtFree(current_path);
1900:         current_path=NULL;
1901:         if((current_path=(char*)calloc((int)strlen(open_data_directory)+5,CHAR_SIZE))==NULL)
1902:                                 SpBadMemAlloc("SpOpenData");
1903:         (void)sprintf(current_path, "%s", open_data_directory);
1904: 
1905:         len = (int)strlen(current_path);
1906:         if(strcmp(&current_path[len-1], "/") == 0) {
1907:           *strrchr(current_path,'/')= '\0';
1908:         }
1909: 
1910:         if((str=(char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL)
1911:                                 SpBadMemAlloc("SpOpenData");
1912:         (void)sprintf(str,"%s/*",current_path);
1913:         XtVaSetValues(textOpenFilter, XmNvalue, str, NULL);
1914:         free(str);
1915: 
1916:   SpUpdateOpen(FILE_FILTER);
1917:   
1918:         (void)sprintf(preview_input_path,"%s",current_path);
1919: 
1920:   XtVaGetValues(optionMenuOpenFormat,XmNmenuHistory,&tmp_widget,NULL);
1921:   XtVaGetValues(*tmp_widget,XmNuserData,&tmp_format,NULL);
1922:   XtManageChild(formOpen);
1923:   if(message.error)
1924:     SpManageWarningBox(errorstring);
1925: }
1926: 
1927: /*      Function Name:  SpCullSaveCB
1928:  *
1929:  *      Description:    This function opens the fileSelection dialog box for
1930:  *            saving the cull table.
1931:  *      
1932:  *
1933:  *      Arguments:      Widget    w:  pushButtonSaveCull
1934:  *      XtPointer client: unused
1935:  *      XtPointer call: the call data (unused).
1936:  */
1937: /* ARGSUSED */
1938: void
1939: SpCullSaveCB(w, client, call)
1940: Widget w;
1941: XtPointer client;
1942: XtPointer call;
1943: {
1944: }
1945: 
1946: /*      Function Name:  SpFileSelectionBoxOKCB
1947:  *
1948:  *      Description:    This function is called by the OK button in a
1949:  *            fileSelectionBox. It saves the file and filter
1950:  *      values and opens the appropriate file.
1951:  *
1952:  *      Arguments:      Widget    w:  the activating widget.
1953:  *      XtPointer client: fileselection widget
1954:  *      XtPointer call: fileselection callback struct.
1955:  */
1956: /* ARGSUSED */
1957: void
1958: SpFileSelectionBoxOKCB(w, client, call)
1959: Widget w;
1960: XtPointer client;
1961: XtPointer call;
1962: {
1963: }
1964: 
1965: /*      Function Name:  SpVerifyFloatCB
1966:  *
1967:  *      Description:    This function checks that the text value of the
1968:  *            widget supplied is a valid floating point field.
1969:  *      
1970:  *
1971:  *      Arguments:      Widget    w:  the activating widget.
1972:  *      XtPointer client: unused
1973:  *      XtPointer call: TextVerifyCallback
1974:  */
1975: /* ARGSUSED */
1976: void
1977: SpVerifyFloatCB(w, client, call)
1978: Widget w;
1979: XtPointer client;
1980: XtPointer call;
1981: {
1982:   int i=0,len,decimal_found=False;
1983:   char  numbuffer[200];
1984:   /*SUPPRESS 594*/
1985: /* get text strings */
1986:   char *oldtext = XmTextGetString(w);
1987:   XmTextVerifyCallbackStruct *textcall=(XmTextVerifyCallbackStruct*)call;
1988: /* check that new value is numeric */ 
1989:   for(i=0;i<textcall->text->length&& textcall->doit==True;i++)
1990:   {
1991:     if(!(isdigit(textcall->text->ptr[i])) && textcall->text->ptr[i]!='.'
1992:         && textcall->text->ptr[i]!='-')
1993:       textcall->doit = False;
1994:   }
1995: /* check that altered value will be OK */
1996:   if(textcall->doit)
1997:   {
1998:   /* create new value */
1999:     numbuffer[0]='\0';
2000:     if(textcall->startPos > 0)
2001:     {
2002:       (void)strncpy(numbuffer,oldtext,textcall->startPos);
2003:       numbuffer[textcall->startPos]='\0';
2004:     }
2005:     if(textcall->text->ptr != NULL)
2006:       (void)strcat(numbuffer,textcall->text->ptr);
2007:     if(textcall->endPos < (int)strlen(oldtext))
2008:       (void)strcat(numbuffer,&oldtext[textcall->endPos]);
2009:   /* check if valid floating point */
2010:     len=(int)strlen(numbuffer);
2011:     for(i=0;i<len && textcall->doit;i++)
2012:     {
2013:       if(!isdigit(numbuffer[i]) && !(numbuffer[i]=='-' && i==0) &&
2014:           !(numbuffer[i]=='.' && !decimal_found))
2015:         textcall->doit=False;
2016:       if(numbuffer[i]=='.') decimal_found=True;
2017:     }
2018:   }
2019:   XtFree(oldtext);
2020: }
2021: 
2022: /*      Function Name:  SpCullJoinCB
2023:  *
2024:  *      Description:    This function is called by the join option menu
2025:  *            in the cull dialog. It set the sensitivity of th
2026:  *      second set of equation values.
2027:  *
2028:  *      Arguments:      Widget    w:  the cull join pushbuttons
2029:  *      XtPointer client: unused
2030:  *      XtPointer call: the call data (unused).
2031:  */
2032: /* ARGSUSED */
2033: void
2034: SpCullJoinCB(w, client, call)
2035: Widget w;
2036: XtPointer client;
2037: XtPointer call;
2038: {
2039:   /*SUPPRESS 594*/
2040:   Widget *tmpwidget=(Widget*)w;
2041:   if(*tmpwidget==pushButtonCullOnly)
2042:   {
2043:     XtSetSensitive(equationMenuCull2.EquationMenu,FALSE);
2044:     XtSetSensitive(textFieldCullValue2,FALSE);
2045:   }
2046:   else
2047:   {
2048:     XtSetSensitive(equationMenuCull2.EquationMenu,True);
2049:     XtSetSensitive(textFieldCullValue2,True);
2050:   }
2051: }
2052: /*      Function Name: BxVerifyNumericCB
2053:  *      Description:   Used as the XmNmodifyVerify callback on a text
2054:  *             or text field widget. Allows only numeric characters
2055:  *             to be entered [no decimal point or sign is allowed].
2056:  *      Arguments:     Widget     w:  the widget calling the function.
2057:  *             XtPointer  client:  unused
2058:  *             XtPointer  call:  pointer to XmTextVerifyCallbackStruct
2059:  */
2060: 
2061: /* ARGSUSED */
2062: void
2063: BxVerifyNumericCB ARGLIST((w, client, call))
2064: UARG( Widget, w)
2065: UARG( XtPointer, client)
2066: GRA( XtPointer, call)
2067: {
2068:     int       i;
2069:     XmTextVerifyCallbackStruct  *theVerifyCB;
2070:     XmTextBlock     textBlock;   /* the text to be inserted */
2071:  
2072:     theVerifyCB = (XmTextVerifyCallbackStruct *)call;
2073:     textBlock = theVerifyCB->text;
2074: 
2075:     for ( i=0; i < textBlock->length; i++)
2076:     { 
2077:         if ( !(isascii(textBlock->ptr[i])) || !(isdigit(textBlock->ptr[i])) )
2078:   {
2079:             theVerifyCB->doit = False;
2080:   }
2081:     }
2082:     /*
2083:      * keyboard bell will be rung  by default
2084:      */
2085: }
2086: 
2087: /*      Function Name:  SpOpenInfoOKCB
2088:  *
2089:  *      Description:    This function OKs the user selected input
2090:  *            information and starts the data reading.
2091:  *      
2092:  *
2093:  *      Arguments:      Widget    w:  pushButtonOpenInfoOK
2094:  *      XtPointer client: unused
2095:  *      XtPointer call: the call data (unused).
2096:  */
2097: /* ARGSUSED */
2098: void
2099: SpOpenInfoOKCB(w, client, call)
2100: Widget w;
2101: XtPointer client;
2102: XtPointer call;
2103: {
2104:   char  *info;
2105: 
2106:   /*SUPPRESS 594*/
2107:   XtWorkProc SpInputData;
2108:   XtUnmanageChild(formOpenInfo);
2109:   info=XmTextGetString(textOpenInfo);
2110:   SpUpdateReport(info);
2111:   XtFree(info);
2112:         done_reading = False;
2113:   work_id=XtAppAddWorkProc(app,SpInputData,messageBoxWorking);
2114:   XtManageChild(messageBoxWorking);
2115:   XtPopup(XtParent(messageBoxWorking),XtGrabNone);
2116: }
2117: 
2118: /*      Function Name:  SplicerHelpCB
2119:  *
2120:  *      Description:    THis function calls the splicer help program using
2121:  *            the file name passed by the calling widget.
2122:  *      
2123:  *
2124:  *      Arguments:      Widget    w:  the activating widget.
2125:  *      XtPointer client: name of help file
2126:  *      XtPointer call: the call data (unused).
2127:  */
2128: /* ARGSUSED */
2129: void
2130: SplicerHelpCB(w, client, call)
2131: Widget w;
2132: XtPointer client;
2133: XtPointer call;
2134: {
2135:   /*SUPPRESS 594*/
2136:   char  *helpfiles_path, *help_path,*getenv();
2137: /* get text string */
2138:   char *helpbuffer= (char*) client;
2139: /* put together command and submit it */
2140: 
2141:         if((helpfiles_path=(char*)calloc(1000,CHAR_SIZE))==NULL)
2142:                 SpBadMemAlloc("SplicerHelpCB 1");
2143:         if((help_path=(char*)calloc(1000,CHAR_SIZE))==NULL)
2144:                 SpBadMemAlloc("SplicerHelpCB 2");
2145:   (void)strcpy(helpfiles_path,(char*)getenv("SPLICER_HELPFILES_PATH"));
2146:         (void)strcpy(help_path,(char*)getenv("SPLICER_HELP_PATH"));
2147:   if((charptr=(char*)calloc((int)strlen(helpfiles_path) + (int)strlen(help_path)+(int)strlen(helpbuffer)+200,CHAR_SIZE))==NULL)
2148:     SpBadMemAlloc("SplicerHelpCB 3");
2149:   (void)sprintf(charptr,"%s/hsplicer-c -bg %s -fg %s <%s/%s & ", help_path, prgbgcolor, prgfgcolor, helpfiles_path,helpbuffer);
2150:   (void)system(charptr);
2151:   free(charptr);
2152:         free(helpfiles_path);
2153:         free(help_path);
2154: }
2155: 
2156: /*      Function Name:  SpAffineSaveCB
2157:  *
2158:  *      Description:    This function  sets the defaults for the save affine
2159:  *            dialog and opens the dialog.
2160:  *
2161:  *      Arguments:      Widget    w:  pushButtonSaveAffine
2162:  *      XtPointer client: the integer exit value.
2163:  *      XtPointer call: the call data (unused).
2164:  */
2165: /* ARGSUSED */
2166: void
2167: SpAffineSaveCB(w, client, call)
2168: Widget w;
2169: XtPointer client;
2170: XtPointer call;
2171: {
2172: }
2173: 
2174: /* ARGSUSED */
2175: void
2176: SpManageCB(w, client, call)
2177: Widget w;
2178: XtPointer client;
2179: XtPointer call;
2180: {
2181:   /*SUPPRESS 594*/
2182: }
2183: 
2184: /*      Function Name:  SpExitCB
2185:  *
2186:  *      Description:    This function cleans up and exits the program.
2187:  *
2188:  *      Arguments:      Widget    w:  pushButtonOK from messageBoxExit
2189:  *      XtPointer client: the integer exit value.
2190:  *      XtPointer call: the call data (unused).
2191:  */
2192: /* ARGSUSED */
2193: void
2194: SpExitCB(w, client, call)
2195: Widget w;
2196: XtPointer client;
2197: XtPointer call;
2198: {
2199:   /*SUPPRESS 594*/
2200:     int  exitValue = (int)client;
2201:     void exit(), SpWriteReport();
2202: 
2203:     /* write the report
2204:     */
2205:     if(write_report == NO) {
2206:     }
2207:     else {
2208:       SpWriteReport();
2209:     }
2210:     
2211:     SpExit();
2212:     exit(exitValue);
2213: }
2214: 
2215: /*      Function Name:  SpClearWorkspaceCB
2216:  *
2217:  *      Description:    This function cleans up all opened data strucutures
2218: *     and clears windows.
2219:  *
2220:  *      Arguments:      Widget    w:  pushButtonOK from messageBoxClearWorkspace
2221:  *      XtPointer client: the integer exit value.
2222:  *      XtPointer call: the call data (unused).
2223:  */
2224: /* ARGSUSED */
2225: void
2226: SpClearWorkspaceCB(w, client, call)
2227: Widget w;
2228: XtPointer client;
2229: XtPointer call;
2230: {
2231:   /*SUPPRESS 594*/
2232:   if(have_data == DO) {
2233:   SpCleanUp(ALL);
2234:   }
2235: }
2236: 
2237: /*      Function Name:  SpCreateReportCB
2238:  *
2239:  *      Description:    writes time to start of report text
2240:  *
2241:  *      Arguments:      Widget    w:  the activating widget.
2242:  *      XtPointer client: the integer exit value.
2243:  *      XtPointer call: the call data (unused).
2244:  */
2245: 
2246: /* ARGSUSED */
2247: void
2248: SpCreateReportCB(w, client, call)
2249: Widget w;
2250: XtPointer client;
2251: XtPointer call;
2252: {
2253: }
2254: 
2255: /* ARGSUSED */
2256: void
2257: SpCreateCB(w, client, call)
2258: Widget w;
2259: XtPointer client;
2260: XtPointer call;
2261: {
2262:       String       drawingAreaEditTranslations;
2263:       XtActionsRec drawingAreaEditButtonActions;
2264:       String       drawingAreaViewTranslations;
2265:       XtActionsRec drawingAreaViewButtonActions;
2266:       String       drawingAreaTieCorrelationTranslations;
2267:       XtActionsRec drawingAreaTieCorrelationButtonActions;
2268:       String       drawingAreaSpliceCorrelationTranslations;
2269:       XtActionsRec drawingAreaSpliceCorrelationButtonActions;
2270:       String       drawingAreaDepthOffsetTranslations;
2271:       XtActionsRec drawingAreaDepthOffsetButtonActions;
2272:         String       drawingAreaAgeDepthTranslations;
2273:         XtActionsRec drawingAreaAgeDepthButtonActions;
2274:         String       drawingAreaSpliceToAgeTranslations;
2275:         XtActionsRec drawingAreaSpliceToAgeButtonActions;
2276:         String       drawingAreaTieToTimeSeriesCorrTranslations;
2277:         XtActionsRec drawingAreaTieToTimeSeriesCorrButtonActions;
2278:   extern void EventProcDrawingAreaDepthOffset();
2279:   extern void EventProcDrawingAreaEdit();
2280:   extern void EventProcDrawingAreaView();
2281:   extern void EventProcDrawingAreaTieCorrelation();
2282:   extern void EventProcDrawingAreaSpliceCorrelation();
2283:         extern void EventProcDrawingAreaAgeDepth();
2284:         extern void EventProcDrawingAreaSpliceToAge();
2285:         extern void EventProcDrawingAreaTieToTimeSeriesCorr();
2286: 
2287:   /*SUPPRESS 594*/
2288:   Widget *setme = (Widget*)client;
2289:   if(*setme == messageBoxWorking)
2290:   {
2291:     XtUnmanageChild(XmMessageBoxGetChild(messageBoxWorking,XmDIALOG_OK_BUTTON));
2292:     XtUnmanageChild(XmMessageBoxGetChild(messageBoxWorking,XmDIALOG_HELP_BUTTON));
2293:          }
2294:   else if(*setme == drawingAreaDepthOffset)
2295:   {
2296:         drawingAreaDepthOffsetButtonActions.string = "EventProcDrawingAreaDepthOffset"; 
2297:         drawingAreaDepthOffsetButtonActions.proc = EventProcDrawingAreaDepthOffset; 
2298:         XtAppAddActions(app, &drawingAreaDepthOffsetButtonActions, 1);
2299:      
2300:         drawingAreaDepthOffsetTranslations =
2301:           "<Btn1Down>:   EventProcDrawingAreaDepthOffset(but_1_down) ManagerGadgetArm()\n\
2302:           <Btn1Up>:     EventProcDrawingAreaDepthOffset(but_1_up)   ManagerGadgetActivate()\n\
2303:           <Btn1Motion>: EventProcDrawingAreaDepthOffset(but_1_move) ManagerGadgetButtonMotion()"; 
2304:  
2305:         XtVaSetValues(*setme, XmNtranslations, XtParseTranslationTable(drawingAreaDepthOffsetTranslations),NULL);
2306:   }
2307:         else if(*setme == drawingAreaAgeDepth)
2308:         {
2309:                 drawingAreaAgeDepthButtonActions.string = "EventProcDrawingAreaAgeDepth";
2310:                 drawingAreaAgeDepthButtonActions.proc = EventProcDrawingAreaAgeDepth;
2311:                 XtAppAddActions(app, &drawingAreaAgeDepthButtonActions, 1);
2312:                  
2313:                 drawingAreaAgeDepthTranslations =
2314:                         "<Btn1Down>:   EventProcDrawingAreaAgeDepth(but_1_down) ManagerGadgetArm()\n\
2315:                         <Btn1Up>:     EventProcDrawingAreaAgeDepth(but_1_up)   ManagerGadgetActivate()\n\
2316:                         <Btn1Motion>: EventProcDrawingAreaAgeDepth(but_1_move) ManagerGadgetButtonMotion()\n\
2317:                         <Btn2Down>:   EventProcDrawingAreaAgeDepth(but_2_down) ManagerGadgetArm()\n\
2318:                         <Btn2Up>:     EventProcDrawingAreaAgeDepth(but_2_up)   ManagerGadgetActivate()\n\
2319:                         <Btn2Motion>: EventProcDrawingAreaAgeDepth(but_2_move) ManagerGadgetButtonMotion()\n\
2320:                         <Btn3Down>:   EventProcDrawingAreaAgeDepth(but_3_down) ManagerGadgetArm()\n\
2321:                         <Btn3Up>:     EventProcDrawingAreaAgeDepth(but_3_up)   ManagerGadgetActivate()\n\
2322:                         <Btn3Motion>: EventProcDrawingAreaAgeDepth(but_3_move) ManagerGadgetButtonMotion()";
2323:  
2324:                 XtVaSetValues(*setme, XmNtranslations, XtParseTranslationTable(drawingAreaAgeDepthTranslations),NULL);
2325:         }
2326:         else if(*setme == drawingAreaSpliceToAge)
2327:         {
2328:                 drawingAreaSpliceToAgeButtonActions.string = "EventProcDrawingAreaSpliceToAge";
2329:                 drawingAreaSpliceToAgeButtonActions.proc = EventProcDrawingAreaSpliceToAge;
2330:                 XtAppAddActions(app, &drawingAreaSpliceToAgeButtonActions, 1);
2331: 
2332:                 drawingAreaSpliceToAgeTranslations =
2333:                         "<Btn1Down>:   EventProcDrawingAreaSpliceToAge(but_1_down) ManagerGadgetArm()\n\
2334:                         <Btn1Up>:     EventProcDrawingAreaSpliceToAge(but_1_up)   ManagerGadgetActivate()\n\
2335:                         <Btn1Motion>: EventProcDrawingAreaSpliceToAge(but_1_move) ManagerGadgetButtonMotion()\n\
2336:                         <Btn2Down>:   EventProcDrawingAreaSpliceToAge(but_2_down) ManagerGadgetArm()\n\
2337:                         <Btn2Up>:     EventProcDrawingAreaSpliceToAge(but_2_up)   ManagerGadgetActivate()\n\
2338:                         <Btn2Motion>: EventProcDrawingAreaSpliceToAge(but_2_move) ManagerGadgetButtonMotion()\n\
2339:                         <Btn3Down>:   EventProcDrawingAreaSpliceToAge(but_3_down) ManagerGadgetArm()\n\
2340:                         <Btn3Up>:     EventProcDrawingAreaSpliceToAge(but_3_up)   ManagerGadgetActivate()\n\
2341:                         <Btn3Motion>: EventProcDrawingAreaSpliceToAge(but_3_move) ManagerGadgetButtonMotion()\n\
2342:                         <KeyDown>Return:  EventProcDrawingAreaSpliceToAge(return_down)  ManagerGadgetSelect()\n\
2343:                         <KeyDown>osfUp: EventProcDrawingAreaSpliceToAge(arrow_up)   ManagerGadgetSelect()\n\
2344:                         <KeyDown>osfDown: EventProcDrawingAreaSpliceToAge(arrow_down)   ManagerGadgetSelect()";
2345: 
2346:                 XtVaSetValues(*setme, XmNtranslations, XtParseTranslationTable(drawingAreaSpliceToAgeTranslations),NULL);
2347:         }
2348:   else if(*setme == drawingAreaEdit)
2349:   {
2350:         drawingAreaEditButtonActions.string = "EventProcDrawingAreaEdit";
2351:         drawingAreaEditButtonActions.proc = EventProcDrawingAreaEdit;
2352:         XtAppAddActions(app, &drawingAreaEditButtonActions, 1);
2353:  
2354:         drawingAreaEditTranslations =
2355:                     "<Btn1Down>:    EventProcDrawingAreaEdit(but_1_down) ManagerGadgetArm()\n\
2356:                       <Btn1Up>:       EventProcDrawingAreaEdit(but_1_up)   ManagerGadgetActivate()\n\
2357:                       <Btn1Motion>:   EventProcDrawingAreaEdit(but_1_move  ManagerGadgetButtonMotion()\n\
2358:                       <Btn2Down>:     EventProcDrawingAreaEdit(but_2_down) ManagerGadgetArm()\n\
2359:                       <Btn2Up>:       EventProcDrawingAreaEdit(but_2_up)   ManagerGadgetActivate()\n\
2360:                                 <Btn2Motion>:   EventProcDrawingAreaEdit(but_2_move) ManagerGadgetButtonMotion()\n\
2361:                       <Btn3Down>:     EventProcDrawingAreaEdit(but_3_down) ManagerGadgetArm()\n\
2362:                       <Btn3Up>:       EventProcDrawingAreaEdit(but_3_up)   ManagerGadgetActivate()\n\
2363:                                 <Btn3Motion>:   EventProcDrawingAreaEdit(but_3_move) ManagerGadgetButtonMotion()\n\
2364:                                 <KeyDown>Return:  EventProcDrawingAreaEdit(return_down)  ManagerGadgetSelect()\n\
2365:                                 <KeyDown>osfUp: EventProcDrawingAreaEdit(arrow_up)   ManagerGadgetSelect()\n\
2366:                                 <KeyDown>osfDown: EventProcDrawingAreaEdit(arrow_down)   ManagerGadgetSelect()";
2367:         XtVaSetValues(drawingAreaEdit, XmNtranslations, XtParseTranslationTable(drawingAreaEditTranslations),NULL);
2368:   }
2369:   else if(*setme == drawingAreaView)
2370:   {
2371:         drawingAreaViewButtonActions.string = "EventProcDrawingAreaView";
2372:         drawingAreaViewButtonActions.proc = EventProcDrawingAreaView;
2373:         XtAppAddActions(app, &drawingAreaViewButtonActions, 1);
2374:   
2375:         drawingAreaViewTranslations =
2376:           "<Btn1Down>:   EventProcDrawingAreaView(but_1_down) ManagerGadgetArm()\n\
2377:           <Btn1Up>:     EventProcDrawingAreaView(but_1_up)   ManagerGadgetActivate()\n\
2378:           <Btn1Motion>: EventProcDrawingAreaView(but_1_move) ManagerGadgetButtonMotion()\n\
2379:           <Btn2Down>:   EventProcDrawingAreaView(but_2_down) ManagerGadgetArm()\n\
2380:           <Btn2Up>:     EventProcDrawingAreaView(but_2_up)   ManagerGadgetActivate()\n\
2381:                         <Btn2Motion>: EventProcDrawingAreaView(but_2_move) ManagerGadgetButtonMotion()\n\
2382:           <Btn3Down>:   EventProcDrawingAreaView(but_3_down) ManagerGadgetArm()\n\
2383:           <Btn3Up>:     EventProcDrawingAreaView(but_3_up)   ManagerGadgetActivate()\n\
2384:                         <Btn3Motion>: EventProcDrawingAreaView(but_3_move) ManagerGadgetButtonMotion()\n\
2385:                         <KeyDown>Return:  EventProcDrawingAreaView(return_down)  ManagerGadgetSelect()\n\
2386:                         <KeyDown>osfUp: EventProcDrawingAreaView(arrow_up)   ManagerGadgetSelect()\n\
2387:                         <KeyDown>osfDown: EventProcDrawingAreaView(arrow_down)   ManagerGadgetSelect()";
2388:         XtVaSetValues(drawingAreaView, XmNtranslations, XtParseTranslationTable(drawingAreaViewTranslations),NULL);
2389:   }
2390:   else if(*setme == drawingAreaCompCorrelation)
2391:   {
2392:         drawingAreaSpliceCorrelationButtonActions.string = "EventProcDrawingAreaSpliceCorrelation";
2393:         drawingAreaSpliceCorrelationButtonActions.proc = EventProcDrawingAreaSpliceCorrelation;
2394:         XtAppAddActions(app, &drawingAreaSpliceCorrelationButtonActions, 1);
2395: 
2396:         drawingAreaSpliceCorrelationTranslations =
2397:           "<Btn1Down>:   EventProcDrawingAreaSpliceCorrelation(but_1_down) ManagerGadgetArm()\n\
2398:           <Btn1Up>:     EventProcDrawingAreaSpliceCorrelation(but_1_up)   ManagerGadgetActivate()\n\
2399:           <Btn1Motion>: EventProcDrawingAreaSpliceCorrelation(but_1_move) ManagerGadgetButtonMotion()";
2400:         XtVaSetValues(drawingAreaCompCorrelation, XmNtranslations, XtParseTranslationTable(drawingAreaSpliceCorrelationTranslations),NULL);
2401:   }
2402:   else if(*setme == drawingAreaTieCorrelation)
2403:   {
2404:         drawingAreaTieCorrelationButtonActions.string = "EventProcDrawingAreaTieCorrelation";
2405:         drawingAreaTieCorrelationButtonActions.proc = EventProcDrawingAreaTieCorrelation;
2406:         XtAppAddActions(app, &drawingAreaTieCorrelationButtonActions, 1);
2407: 
2408:         drawingAreaTieCorrelationTranslations =
2409:           "<Btn1Down>:   EventProcDrawingAreaTieCorrelation(but_1_down) ManagerGadgetArm()\n\
2410:           <Btn1Up>:     EventProcDrawingAreaTieCorrelation(but_1_up)   ManagerGadgetActivate()\n\
2411:           <Btn1Motion>: EventProcDrawingAreaTieCorrelation(but_1_move) ManagerGadgetButtonMotion()";
2412: 
2413:         XtVaSetValues(drawingAreaTieCorrelation, XmNtranslations, XtParseTranslationTable(drawingAreaTieCorrelationTranslations),NULL);
2414:   }
2415:         else if(*setme == drawingAreaTieToTimeSeriesCorr)
2416:         {
2417:                 drawingAreaTieToTimeSeriesCorrButtonActions.string = "EventProcDrawingAreaTieToTimeSeriesCorr";
2418:                 drawingAreaTieToTimeSeriesCorrButtonActions.proc = EventProcDrawingAreaTieToTimeSeriesCorr;
2419:                 XtAppAddActions(app, &drawingAreaTieToTimeSeriesCorrButtonActions, 1);
2420: 
2421:                 drawingAreaTieToTimeSeriesCorrTranslations =
2422:                         "<Btn1Down>:   EventProcDrawingAreaTieToTimeSeriesCorr(but_1_down) ManagerGadgetArm()\n\
2423:                         <Btn1Up>:     EventProcDrawingAreaTieToTimeSeriesCorr(but_1_up)   ManagerGadgetActivate()\n\
2424:                         <Btn1Motion>: EventProcDrawingAreaTieToTimeSeriesCorr(but_1_move) ManagerGadgetButtonMotion()";
2425: 
2426:                 XtVaSetValues(drawingAreaTieToTimeSeriesCorr, XmNtranslations, XtParseTranslationTable(drawingAreaTieToTimeSeriesCorrTranslations),NULL);
2427:          }
2428: }
2429: 
2430: /* ARGSUSED */
2431: void
2432: SpMessageBoxInfoCB(w, client, call)
2433: Widget w;
2434: XtPointer client;
2435: XtPointer call;
2436: {
2437:   void  exit();
2438: 
2439:   /*SUPPRESS 594*/
2440:   XtUnmanageChild(messageBoxInfo);
2441:   if(message.fatal)
2442:   {
2443:     
2444:     SpCleanUp(EXIT);
2445:     exit(0);
2446:   }
2447:   message.error=False;
2448:   free(message.label);
2449:   message.label=NULL;
2450: }
2451: 
2452: /* ARGSUSED */
2453: void
2454: SpOutputOKCB(w, client, call)
2455: Widget w;
2456: XtPointer client;
2457: XtPointer call;
2458: {
2459:         int             readable, len;
2460:         char            *testdir;
2461:   XmString  xmstring;
2462:   XtWorkProc SpOutputData;
2463: 
2464:   /*SUPPRESS 594*/
2465: 
2466:   /* check that is a directory
2467:   */
2468:   testdir = XmTextGetString(textFieldSaveDataDirectory);
2469:   readable = VerifyFileReadable(testdir, SAVE, SAVEDATA);
2470:   if(readable == NO) {
2471:     (void)sprintf(buffer,"%s is not a directory.",testdir);
2472:     free(testdir);
2473:     XmTextSetString(textFieldAffineFileName,"");
2474:     SpManageWarningBox(buffer);
2475:     return;
2476:   }
2477:   else {
2478: 
2479:         free(outdata_dirname);
2480:         if((outdata_dirname=(char*)calloc((int)strlen(testdir)+5,CHAR_SIZE))==NULL)
2481:                                 SpBadMemAlloc("OpenSplicerTable");
2482:         (void)sprintf(outdata_dirname, "%s", testdir);
2483: 
2484:         len = (int)strlen(outdata_dirname);
2485:         if(strcmp(&outdata_dirname[len-1], "/") != 0) {
2486:           (void)strcat(outdata_dirname, "/");
2487:         }
2488: 
2489:         XtUnmanageChild(formOutput);
2490: 
2491: /* start working procedure for reading splicer table*/
2492:   work_id=XtAppAddWorkProc(app,SpOutputData,messageBoxWorking);
2493: /* display working box */
2494:   xmstring=XmStringCreateLocalized("Output : writing output data.");
2495:         XtVaSetValues(messageBoxWorking,XmNmessageString,xmstring, NULL);
2496:         XmStringFree(xmstring);
2497:         XtManageChild(messageBoxWorking);
2498:         XtPopup(XtParent(messageBoxWorking),XtGrabNone);
2499:   }
2500: }
2501: 
2502: /* ARGSUSED */
2503: void
2504: SpViewReportCB(w, client, call)
2505: Widget w;
2506: XtPointer client;
2507: XtPointer call;
2508: {
2509: 
2510:   /*SUPPRESS 594*/
2511: 
2512:   XmString xmstring;
2513:   char  *string;
2514: 
2515:   XtVaGetValues(pushButtonViewReport, XmNlabelString, &xmstring, NULL);
2516:   if(!XmStringGetLtoR(xmstring,XmFONTLIST_DEFAULT_TAG,&string))
2517:   {
2518:   message.error=True;
2519:   message.fatal=False;
2520:         message.caller=NONE;
2521:         message.type=XmDIALOG_WARNING;
2522:         message.default_button=XmDIALOG_OK_BUTTON;
2523:   if((message.label=(char*)calloc(200,CHAR_SIZE))==NULL)
2524:     SpBadMemAlloc("SpViewReportCB 1");
2525:   else
2526:     (void)sprintf(message.label,"Unable to convert report label to char");
2527:   SpManageMessage(message);
2528:   }
2529: /*  XmStringFree(xmstring);
2530: */
2531:   if((int)strcmp(string, "View Report") == 0){
2532: 
2533:       /*  XtManageChild(formTextReport); */
2534:         if(!XtIsManaged(XtParent(formTextReport))) {
2535:           XtManageChild(formTextReport);
2536:         }
2537:         XtPopup(XtParent(formTextReport), XtGrabNone);
2538: 
2539:     xmstring=XmCvtCTToXmString("Hide Report");
2540:     XtVaSetValues(pushButtonViewReport,XmNlabelString,xmstring,NULL);
2541:     XmStringFree(xmstring);
2542:   }
2543:   else if((int)strcmp(string, "Hide Report") == 0) {
2544: 
2545:   /*  XtUnmanageChild(formTextReport); */
2546:     XtPopdown(XtParent(formTextReport));
2547:     xmstring=XmCvtCTToXmString("View Report");
2548:     XtVaSetValues(pushButtonViewReport,XmNlabelString,xmstring,NULL);
2549:     XmStringFree(xmstring);
2550:   }
2551:   XtFree(string);
2552: }
2553: 
2554: 
2555: /* ARGSUSED */
2556: void
2557: EventProcDrawingAreaEdit(w, event, args, num_args)
2558: Widget w;
2559: XButtonEvent *event;
2560: String *args;
2561: int *num_args;
2562: {
2563:   int x, y, i, j, k, holenum, corenum, arraynum, sm, err1, err2, 
2564:       starting_hole, report_tie1, report_tie2, found_strat, save_tie1, save_tie2;
2565:   char string[200], idstring[200], varstring[20], coreselectstring[5];
2566:   float depth, chlow, chhigh, diff, *var_val, avedep, avedep1, avedep2;
2567:   double checkdep;
2568:   Dimension win_height, win_width;
2569:   String str;
2570:   XmString xmstring;
2571:   void DrawDrawingAreaEdit(), TieCorrelate(), GetSelectCore(), TieShift();
2572: 
2573:   x = event->x;
2574:   y = event->y;
2575:   XtVaGetValues(w, XmNheight, &win_height, XmNwidth, &win_width, NULL);
2576:   (void)sprintf(string, "");
2577: 
2578:   if(have_data == DONT) {
2579:     last_tie = NONE;
2580:     have_tie1 = DONT;
2581:     have_tie2 = DONT;
2582:     have_tie = DONT;
2583:   }
2584:   else if(y < 0 || y > (int)win_height || x < OFF || x > (int)win_width){
2585:     (void)sprintf(string, "");
2586:     xmstring = XmStringCreateSimple(string);
2587:     XtVaSetValues(labelCursorLocation, XmNlabelString, xmstring, NULL);
2588:     XtVaSetValues(labelSpliceCursorLocation, XmNlabelString, xmstring, NULL);
2589:     XmStringFree(xmstring);
2590:   }
2591:   else if(have_data == DO) {
2592: 
2593:     /* calculate the cursor location in depth(m)
2594:        note that top_off_edit is the pixel offset from top of drawingAreaEdit
2595:        and top_meter_edit is the value of the top of the depth axis
2596:     */
2597:     depth = (((y - top_off_edit) * depperpix) + top_meter_edit);
2598: 
2599:     /* get the cores scale value. it will be the array num of
2600:        the first hole to search. in other words; where to 'skip to'
2601:     */
2602:     XmScaleGetValue(scaleCores, &starting_hole);
2603:     if(starting_hole >= data[dset]->numholes || starting_hole < 0) {
2604:       return;
2605:     }
2606: 
2607:     if(have_tie1 == DONT && have_tie2 == DONT) {
2608:       last_tie = NONE;
2609:     }
2610:     else if(have_tie1 == DONT && last_tie == TIE1) {
2611:       if(have_tie2 == DO){
2612:         last_tie = TIE2;
2613:       }  
2614:       else {
2615:         last_tie = NONE;
2616:       }  
2617:     }  
2618:     else if(have_tie2 == DONT && last_tie == TIE2) {
2619:       if(have_tie1 == DO){
2620:         last_tie = TIE1;
2621:       }  
2622:       else {
2623:         last_tie = NONE;
2624:       }  
2625:     }
2626:  
2627:     report_tie1 = NO;
2628:     report_tie2 = NO;
2629:  
2630:     /* smoothed and if so plot type
2631:     */
2632:     if(smooth.plot == NONE || smooth.plot == UNSMOOTHED){
2633:       sm = NO;
2634:     }
2635:     else if((smooth.method == GAUSSIAN || smooth.method == OTHER) &&
2636:             (smooth.plot == SMOOTHED || smooth.plot == SMOOTHEDBOTH)){
2637:       sm = YES;
2638:     }
2639:     else {
2640:       sm = NO;
2641:     }
2642: 
2643:     /* event is any button up, down or move
2644:     */
2645:     if((int)strcmp(args[0], "but_1_down") == 0 || (int)strcmp(args[0], "but_1_move") == 0 ||
2646:        (int)strcmp(args[0], "but_2_down") == 0 || (int)strcmp(args[0], "but_2_move") == 0 ||
2647:        (int)strcmp(args[0], "but_3_down") == 0 || (int)strcmp(args[0], "but_3_move") == 0) {
2648:  
2649:       /* find the nearest sample to cursor pixel location
2650:       */ 
2651:       /* if are compositing, only look for hole and core if is button down event or button one move.
2652:          a button 2 or 3 move would mean have allready picked a point in a core
2653:          and are now moving up or down the same core
2654:       */
2655:       if( (((int)strcmp(args[0], "but_1_down") == 0 || (int)strcmp(args[0], "but_2_down") == 0 || 
2656:             (int)strcmp(args[0], "but_3_down") == 0 || (int)strcmp(args[0], "but_1_move") == 0) && are_compositing == YES) ||
2657:           (((int)strcmp(args[0], "but_1_down") == 0 || (int)strcmp(args[0], "but_1_move") == 0 ||
2658:             (int)strcmp(args[0], "but_2_down") == 0 || (int)strcmp(args[0], "but_2_move") == 0 ||
2659:             (int)strcmp(args[0], "but_3_down") == 0 || (int)strcmp(args[0], "but_3_move") == 0) && are_compositing == NO)) { 
2660: 
2661:         /* find which hole
2662:         */
2663:         holenum = -1;
2664:         corenum = -1;
2665:         for(i=starting_hole; i<data[dset]->numholes; ++i){
2666:           if(x >= OFF + SPACE + (i - starting_hole) * (varaxislen + SPACE) &&
2667:                x <= OFF + SPACE + (i - starting_hole) * (varaxislen + SPACE) + varaxislen) {
2668:             holenum = i;
2669:             break;
2670:           }
2671:         }  
2672:  
2673:         /* find which core
2674:         */ 
2675:         if(holenum != -1) {
2676:           for(j=0; j < data[dset]->holes[holenum]->numcores; ++j){
2677:             if(data[dset]->holes[holenum]->core[j]->value[0]->quality == BAD_CORE_NUM){
2678:             }
2679:             else {
2680:               for(k=0; data[dset]->holes[holenum]->core[j]->value[k]->quality != GOOD; ++k){
2681:                 if(k >= data[dset]->holes[holenum]->core[j]->numvalues){
2682:                   return;
2683:                 }
2684:               }
2685:               chlow=data[dset]->holes[holenum]->core[j]->value[k]->sb_depth +
2686:                                      data[dset]->holes[holenum]->core[j]->cum_dep_offset;
2687:               for(k=data[dset]->holes[holenum]->core[j]->numvalues -1;
2688:                 data[dset]->holes[holenum]->core[j]->value[k]->quality != GOOD; --k){
2689:                 if(k <= 0){
2690:                   return;
2691:                 }
2692:               }
2693:               chhigh= data[dset]->holes[holenum]->core[j]->value[k]->sb_depth +
2694:                                      data[dset]->holes[holenum]->core[j]->cum_dep_offset;
2695:               if(depth >= chlow && depth <= chhigh){
2696:                 if(smooth.plot == SMOOTHED && data[dset]->holes[holenum]->core[j]->smooth_status != SMOK) {
2697:                   return;
2698:                 }
2699:                 else if(data[dset]->holes[holenum]->core[j]->smooth_status != SMOK) {
2700:                   sm = NO;
2701:                 }
2702:                 corenum=j;
2703:                 break;
2704:               }
2705:             }
2706:           }
2707:         }
2708:       }
2709: 
2710:       else if(last_tie == TIE1) {
2711:         holenum = tie1holenum;
2712:         corenum = tie1corenum;
2713:       }
2714: 
2715:       else if(last_tie == TIE2) {
2716:         holenum = tie2holenum; 
2717:         corenum = tie2corenum;
2718:       }
2719: 
2720:       else {
2721:         return;
2722:       }
2723:  
2724:       /* find nearest good sample
2725:       */
2726:       arraynum = -1;
2727:       if(corenum != -1) {
2728:         diff = 99999.0;
2729:         for(k=0; k<data[dset]->holes[holenum]->core[corenum]->numvalues; ++k){
2730:           checkdep = depth - (data[dset]->holes[holenum]->core[corenum]->value[k]->sb_depth +
2731:                             data[dset]->holes[holenum]->core[corenum]->cum_dep_offset);
2732:           if(data[dset]->holes[holenum]->core[corenum]->value[k]->quality != GOOD) {
2733:           }
2734:           else if(fabs(checkdep) < diff){
2735:             diff = fabs(checkdep);
2736:             arraynum = k;
2737:           }
2738:         }
2739:       }
2740: 
2741:       /* did not find a core sample. if have strat data, is cursor over one of the datums?
2742:       */
2743:       if((holenum == -1 && corenum == -1 && arraynum == -1) && have_strat == DO) {
2744:         found_strat = NO;
2745:         for(i=0; i<strat_file_cnt; ++i){
2746:           if(found_strat == YES) {
2747:             break;
2748:           }
2749:           for(j=0; j<strat[i]->data_cnt; ++j){
2750:             if(strat[i]->data[j].x_pix_loc_edit < 0 || strat[i]->data[j].y_pix_loc_edit < 0) {
2751: 
2752:             }
2753:             else if(abs(strat[i]->data[j].x_pix_loc_edit + 5 - x) < CLOSE && 
2754:                abs(strat[i]->data[j].y_pix_loc_edit - 5 - y) < CLOSE) {
2755:               found_strat = YES;
2756:               if(fabs(strat[i]->data[j].top_age - strat[i]->data[j].bot_age) < ROUNDCHECK) {
2757:                 (void)sprintf(string,"hole %c  %s  %6.3f Ma   %6.2f to %6.2f mbsf  %6.2f to %6.2f mcd", 
2758:                  strat[i]->data[j].top.hole, strat[i]->data[j].name, strat[i]->data[j].top_age,
2759:                  strat[i]->data[j].top.sb_depth, strat[i]->data[j].bot.sb_depth,
2760:                  strat[i]->data[j].top.sb_depth + strat[i]->data[j].top.offset,
2761:                  strat[i]->data[j].bot.sb_depth + strat[i]->data[j].bot.offset);
2762:               }
2763:               else {
2764:                 (void)sprintf(string,"hole %c  %s  %6.3f to %6.3f Ma   %6.2f to %6.2f mbsf  %6.2f to %6.2f mcd", 
2765:                  strat[i]->data[j].top.hole, strat[i]->data[j].name, strat[i]->data[j].top_age, strat[i]->data[j].bot_age,
2766: