/***************************************************************/ /* SHARP-95 */ /* Advanced Interactive Sounding Analysis Program */ /* */ /* DOS Video Graphics Routines (Part #2) */ /* These are the routines that set up the VIDEO environment */ /* in DOS and provide a workplace for SHARP. */ /* */ /* John A. Hart */ /* National Severe Storms Forecast Center */ /* Kansas City, Missouri */ /* -------------------------------------------------- */ /* List of Routines in this module: */ /* */ /* CHECK_VICO */ /* RESET_VIDEO */ /* SET_VIDEO */ /* SET_FONT */ /* INTERACTIVE */ /* SWITCH_MODES */ /* REDRAW_GRAPH */ /* DISP_PARAM */ /* EDIT_SKEWT */ /* GRAB_LEVEL */ /* SKEWT_CURSOR_DATA */ /* HODO_CURSOR_DATA */ /* */ /***************************************************************/ #define VIDEO #include #include #include "winline.h" /*NP*/ short switch_modes( short mode ) /*************************************************************/ /* SWITCH_MODES */ /* John Hart NSSFC KCMO */ /* */ /* Changes screen output from Skew-T to Hodograph and back. */ /*************************************************************/ { short i; /* ----- Erase Current Graphic Workplace ----- */ setcolor(0); rectangle( 0, 1, 1, skv.brx + 19, skv.bry + 19 ); /* ----- Redraw Graphic ----- */ if( mode == 2 ) { pagenum = 1; clear_paramarea(); draw_skewt(); show_page( pagenum ); mode = 1; } else { pagenum = 2; clear_paramarea(); draw_hodo(); show_page( pagenum ); mode = 2; } /* ----- Display New Button ----- */ XFlush ( XtDisplay(draw_reg) ); return mode; } /*NP*/ void redraw_graph( short mode ) /*************************************************************/ /* REDRAW_GRAPH */ /* John Hart NSSFC KCMO */ /* */ /* Redraws current graph (Skew-T or Hodograph). */ /*************************************************************/ { short i; /* ----- Erase Current Graphic Workplace ----- */ setcolor(0); rectangle( 1, 1, 1, skv.brx + 19, skv.bry + 19 ); /* ----- Redraw Graphic ----- */ if( mode == 1 ) { draw_skewt(); } else { draw_hodo(); } set_font(2); } /*NP*/ void disp_param( char *value, short rcol, short rlin) /*************************************************************/ /* DISP_PARAM */ /* John Hart NSSFC KCMO */ /* */ /* Right justifies value at location rrow, rlin. */ /*************************************************************/ { outgtext ( value, rcol - getgtextextent( value ), rlin ); } /*NP*/ void edit_skewt( short pagenum ) /*************************************************************/ /* EDIT_SKEWT */ /* John Hart NSSFC KCMO */ /* */ /* This routine allows the user to edit the skewt chart. */ /*************************************************************/ { short x, y, i, yy; float pres, temp, dwpt, tcur, d1, d2, chg1; char st[20]; XEvent mse; /* ----- Get current mouse location ----- */ GetPtrPos( &mse ); /* ----- Determine whether to grab the T or TD trace ----- */ pres = pix_to_pres( (short)mse.xbutton.y ); tcur = pix_to_temp( (short)mse.xbutton.x, (short)mse.xbutton.y ); if (pres > sndg[sfc()][1]) { pres = sndg[sfc()][1]; } temp = i_temp( pres ); dwpt = i_dwpt( pres ); d1 = (float)fabs(tcur - temp); d2 = (float)fabs(tcur - dwpt); printf( "tcur=%f temp=%f\n", tcur, temp); if( d1 < d2 ) { /* ----- Edit Temperatures ----- */ i = grab_level( pres ); if(!qc(sndg[i][3])) { sndg[i][3] = i_temp(sndg[i][1]); } /* ----- Move mouse to starting spot ----- */ yy = pres_to_pix(sndg[i][1]); SetPtrPos( temp_to_pix(sndg[i][3], sndg[i][1]), yy); /*while(mse.fsBtn) { GetPtrPos(&mse); if((mse.xbutton.y > yy + 10) || (mse.xbutton.y < yy - 10)) { SetPtrPos(mse.xbutton.x, yy); } }*/ /* ----- Update sounding array with new temp ----- */ chg1 = pix_to_temp( (short)mse.xbutton.x, yy ); if(chg1 < i_dwpt(sndg[i][1])) { chg1 = i_dwpt(sndg[i][1]); } sndg[i][3] = chg1; /* ----- Redraw skewt and update parameters ----- */ printf( "Defining Parcel\n" ); define_parcel( -1, 850); SetPtrVis( HIDE ); printf( "Redraw Graph\n" ); redraw_graph( 1 ); show_page( pagenum ); SetPtrVis( SHOW ); } else { /* ----- Edit Dew Points ----- */ i = grab_level( pres ); if(!qc(sndg[i][4])) { sndg[i][4] = i_dwpt(sndg[i][1]); } /* ----- Move mouse to starting spot ----- */ yy = pres_to_pix(sndg[i][1]); SetPtrPos( temp_to_pix(sndg[i][4], sndg[i][1]), yy ); /*while(mse.fsBtn) { GetPtrPos( &mse ); if((mse.y > yy + 10) || (mse.y < yy - 10)) { SetPtrPos(mse.x, yy); } }*/ /* ----- Update sounding array with new temp ----- */ chg1 = pix_to_temp( (short)mse.xbutton.x, yy ); if(chg1 > i_temp(sndg[i][1])) { chg1 = i_temp(sndg[i][1]); } sndg[i][4] = chg1; /* ----- Redraw skewt and update parameters ----- */ printf( "Defining Parcel\n" ); define_parcel( -1, 850); SetPtrVis( HIDE ); printf( "Redraw Graph\n" ); redraw_graph( 1 ); show_page( pagenum ); SetPtrVis( SHOW ); } } /*NP*/ short grab_level( float pres ) /*************************************************************/ /* GRAB_LEVEL */ /* John Hart NSSFC KCMO */ /* */ /* Returns the array index of the closest data level that */ /* contains temperature data. */ /*************************************************************/ { short i, ii; float dx, mindx, t1; mindx = 9999; for(i=0; i