static void pgconn_smear ( int loc1, int loc2, VG_DBStruct *elOut, int *nout, float *outX, float *outY ) /************************************************************************ * pgconn_smear * * * * This function smears two selected GFA elements. If the two GFAs * * intersect, they are combined using "union"; otherwise, they are * * combined using "shrink-wrap" algorithm. * * * * static void pgconn_smear ( loc1, loc2, elOut, nout, outX, outY ) * * * * Input parameters: * * loc1 int Location of first GFA element * * loc2 int Location of second GFA element * * * * Output parameters: * * *elOut VG_DBStruct GFA element * * *nout int number of smear points * * outX[] float x of smear points in sys_D * * outY[] float y of smear points in sys_D * * * * Return parameters: * * None * ** * * Log: * * J. Wu/SAIC 06/07 initial coding * * J. Wu/SAIC 09/07 add "unionOnly" into pgsmear_smear * ***********************************************************************/ { int ii, jj, npts, ier, GFA_loc[2], ntmp; char value[10]; float *xtmp, *ytmp, *lat, *lon; Boolean repeat; /*---------------------------------------------------------------------*/ /* * Set computational projection */ ncw_set ( ); ncw_sproj ( "PREFS" ); /* * Smear * Note: pgsmear_smear() needs following options for "join" GFAs: * "skipFzlvl" - False: closed FZLVL could be joined. * "useAllShapShots" - True: snapshots' status doesn't matter. * "reducePts" - False: no point reduction performed. */ GFA_loc[ 0 ] = loc1; GFA_loc[ 1 ] = loc2; pgsmear_smear ( 2, GFA_loc, False, _primaryEl.hdr.maj_col, 0, NULL, False, False, True, False, True, elOut, nout, outX, outY ); /* * Remove repeated points */ ntmp = *nout; G_MALLOC ( xtmp, float, ntmp, "pgsmear_doSnap xtmp" ); G_MALLOC ( ytmp, float, ntmp, "pgsmear_doSnap ytmp" ); G_MALLOC ( lat, float, ntmp, "pgconn_select: lat" ); G_MALLOC ( lon, float, ntmp, "pgconn_select: lon" ); npts = 0; for ( ii = 0; ii < *nout; ii++ ) { repeat = False; for ( jj = ii + 1; jj < ntmp; jj++ ) { if ( ( fabs ( outX[ ii ] - outX[ jj ] ) < .0001 ) && ( fabs ( outY[ ii ] - outY[ jj ] ) < .0001 ) ) { repeat = True; break; } } if ( !repeat ) { xtmp[ npts ] = outX[ ii ]; ytmp[ npts ] = outY[ ii ]; npts++; } } /* * Convert device (x,y) to (lat,lon) and put into el. */ gtrans ( sys_D, sys_M, &npts, xtmp, ytmp, lat, lon, &ier, strlen(sys_D), strlen(sys_M) ); if ( npts > 0 ) { elOut->elem.gfa.info.npts = npts; for ( ii = 0; ii < npts; ii++ ) { elOut->elem.gfa.latlon[ ii ] = lat[ ii ]; elOut->elem.gfa.latlon[ ii + npts ] = lon[ ii ]; } } /* * Unset computational projection and back to current projection */ ncw_unset ( ); /* * Snap if the first polygon is an airmet or outlook. */ cvg_getFld ( &_primaryEl, TAG_GFA_FCSTHR, value, &ier ); if ( strchr ( value, '-' ) ) { pgsmear_snapEl ( True, elOut, &ier ); } /* * Convert into device for ghosting in current projection. */ *nout = elOut->elem.gfa.info.npts; gtrans ( sys_M, sys_D, nout, elOut->elem.gfa.latlon, &(elOut->elem.gfa.latlon[*nout]), outX, outY, &ier, strlen(sys_M), strlen(sys_D) ); G_MALLOC ( xtmp, float, ntmp, "pgconn_smear xtmp" ); G_MALLOC ( ytmp, float, ntmp, "pgconn_smear ytmp" ); G_MALLOC ( lat, float, ntmp, "pgconn_smear lat" ); G_MALLOC ( lon, float, ntmp, "pgconn_smear lon" ); /* * Adopt the first selected GFA's attributes. */ cvg_getFld ( &_primaryEl, TAG_GFA_FCSTHR, value, &ier ); cvg_setFld ( elOut, TAG_GFA_FCSTHR, value, &ier ); cvg_getFld ( &_primaryEl, TAG_GFA_SUBTYPE, value, &ier ); cvg_setFld ( elOut, TAG_GFA_SUBTYPE, value, &ier ); ces_get( atoi( value ), elOut, &ier ); elOut->hdr.maj_col = _primaryEl.hdr.maj_col; elOut->hdr.min_col = _primaryEl.hdr.min_col; }
static void pgfilterw_refresh ( void ) /************************************************************************ * pgpalw_refresh * * * * This function refeshes the drawn pgen elements and signals for a * * reload of all frames in the loop. The current pixmap is cleared and * * restored from the master copy, then cvg_redraw is called to redraw * * pgen elements. The xw driver will then reload the pgen elements for * * all the remaining pixmaps in the loop. This reload will take place * * the next time they are displayed. * * * * static void pgfilterw_refresh ( ) * * * * Input parameters: * * Output parameters: * * Return value: * * NONE * ** * * Log: * * J. Wu/SAIC 07/04 copy from pgpalw_refresh() * * S. Danz/AWC 07/06 cvg_redraw before crg_rebuild so * * autoplacement is ready * * J. Wu/SAIC 02/08 refresh under user's projection * ***********************************************************************/ { Widget canvas; Cardinal width, height; int ier; Boolean compWinIsUp = False; /*---------------------------------------------------------------------*/ /* * Check if the comptational window is up or not. The refresh should be * done on the user's projection */ if ( ncw_isup() ) { compWinIsUp = True; ncw_unset(); } /* * Clear current display */ canvas = (Widget)mcanvw_getDrawingW(); XtVaGetValues ( canvas, XmNwidth, &width, XmNheight, &height, NULL ); XClearArea ( XtDisplay(canvas), XtWindow(canvas), 0, 0, width, height, False ); /* * For each frame, copy from master pixmap to displayable * pixmaps in gemwindow. */ xpgrestlp (); /* * Tell xw driver to refresh the vector graphics * for all pixmaps in the loop. */ xpgrfrsh (); /* * Load and plot the vg elements in current frame. */ cvg_redraw( cvg_getworkfile(), &ier ); /* * Now that we have everything loaded, rebuild the range * records */ crg_rebuild (); geplot ( &ier ); /* * Reset the comptational window if necessary. */ if ( compWinIsUp ) { ncw_set (); ncw_sproj ( "PREFS" ); } }
void ncw_sproj ( const char *source ) /************************************************************************ * ncw_sproj * * * * This function sets the projection information for the computational * * window. The computational window usage may be specified in the * * 'prefs.tbl' table using the boolean keyword 'COMP_WINDOW'. The * * projection to be employed is specified in 'source', a tagged string. * * For example: * * '<PROJ>str/90;-97;0<GAREA>19.00;-119.00;47.00;-56.00' * * A default projection and geographical area may be specified in the * * 'prefs.tbl' with 'COMP_PROJ' and 'COMP_GAREA'. * * If any of the provided projection information cannot be decoded - * * either through 'source' or the 'prefs.tbl' table - then an error is * * set and whatever projection is in the main window will be used. * * * * void ncw_sproj( char *source ) * * * * Input parameters: * * source const char projection information string * * * * Output parameters: * * NONE * * * * Return parameters: * * NONE * * * ** * * Log: * * D.W.Plummer/NCEP 12/06 * ***********************************************************************/ { int p, ier, ier1, ier2, mone, idrpfl; char *src, PROJ[32], GAREA[32]; Boolean qcomp; /*---------------------------------------------------------------------*/ ctb_pfbool ( "COMP_WINDOW", &qcomp, &ier ); if ( qcomp ) { G_MALLOC ( src, char, strlen(source)+1, "ncw_sproj: Error allocating src" ); strcpy ( src, source ); p = G_TRUE; if ( strcmp ( src, "PREFS" ) != 0 ) { /* * If user input is not exactly 'PREFS' (meaning get the projection * info from 'prefs.tbl'), then try to find 'PROJ' and 'GAREA' * tags and parse/process that info. */ cst_gtag ( "PROJ", src, "", PROJ, &ier1 ); cst_gtag ( "GAREA", src, "", GAREA, &ier2 ); if ( ier1 != 0 || ier2 != 0 ) { /* * If tags cannot be found, then process as if 'PREFS' was * specified. */ strcpy ( src, "PREFS" ); } } if ( strcmp ( src, "PREFS" ) == 0 ) { /* * Get the projection specs from 'prefs.tbl'. * If not found, set error and use main window projection. */ ctb_pfstr ( "COMP_PROJ", PROJ, &ier1 ); ctb_pfstr ( "COMP_GAREA", GAREA, &ier2 ); if ( ier1 != 0 || ier2 != 0 ) { p = G_FALSE; } } if ( p ) { gg_maps ( PROJ, GAREA, "", &idrpfl, &ier, strlen(PROJ), strlen(GAREA), strlen("") ); if ( ier != 0 ) { p = G_FALSE; } } if ( !p ) { ncw_unset (); mone = -1; er_wmsg ( "NCW", &mone, NULL, &ier, strlen("NCW"), 0 ); NxmErr_update (); } G_FREE ( src, char ); } }