예제 #1
0
void pgfilterw_turnOnTime ( const char *newTime )
/************************************************************************
 * pgfilterw_turnOnTime							*
 *									*
 * Turns on the given new time, if it is in the menu.			*
 *									*
 * void pgfilterw_turnOnTime ( newTime )				*
 *									*
 * Input parameters:							*
 *	*newTime	char	New time to be turned on		*
 *									*
 * Output parameters:							*
 *	none								*
 *									*
 **									*
 * Log:									*
 * J. Wu/SAIC		08/04	initial coding				*
 * M. Li/SAIC           03/07   add cvg_matchfilter                 	*
 * M. Li/SAIC		03/07	Turn on _fromGfa - change from GFA	*
 ***********************************************************************/
{
    int 	ii, ier;
    filter_t	timeMatched, timecmp;
    Boolean	matchAny = True, filter_match;
    /*---------------------------------------------------------------------*/

    strcpy ( timecmp, newTime );
    cvg_matchfilter ( timecmp, matchAny, &filter_match, timeMatched, &ier );
    if ( filter_match ) {
        strcpy ( timecmp, timeMatched );
    }

    for ( ii = 0; ii < _nFilTime[TIME_FILTER]; ii++ ) {
        if ( !(_filterStatus[ii] ) &&
                strcasecmp ( timecmp, _filTime[TIME_FILTER][ii] ) == 0 ) {

            _filterStatus[ii] = True;
            XmToggleButtonSetState ( _filterChkBtn[ii], True, False );

            _fromGfa = True;
            pgfilterw_updateFilter ();

            break;
        }
    }
}
예제 #2
0
void cvg_rfrshLayer ( FILE *fp, char *fname, int layer, int fsize, 
		      float llx, float lly, float urx, float ury, int *iret )
/************************************************************************
 * cvg_rfrshLayer							*
 *									*
 * This function re-displays all VG records that fall within a specified*
 * range on a given layer. The elements are displayed in sequence of 	*
 * their displaying level. By default, records on the given layer of	*
 * WORK_FILE will be drawn.						*
 *									*
 * Note: The displaying level refers to the order in which VG elements	*
 *       are displayed ( i.e.,filled elements first, then lines, etc.)	*
 *       This is different from production layers.			*
 *									*
 * cvg_rfrshLayer ( fp, fname, layer, fsize, llx, lly, urx, ury, iret )	*
 *									*
 * Input parameters:							*
 *	*fp		FILE		Pointer to VG "fname"		*
 *	*fname		char		VG File to be read 		*
 *	 layer		int		layer to to be drawn		*
 *	 fsize		int		size of the VG file in bytes	*
 *	 llx		float		Lower left X coordinate		*
 *	 lly		float		Lower left Y coordinate		*
 *	 urx		float		Upper right X coordinate	*
 *	 ury		float		Upper right Y coordinate	*
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 *					 -8 = No VG file is open	*
 **									*
 * Log:									*
 * J. Wu/SAIC           03/02   initial coding				*
 * T. Lee/SAIC		11/03	used cvgcmn.h				*
 * J. Wu/SAIC           07/04   add display filter			*
 * B. Yin/SAIC          08/04   Added code to free TCA memory           *
 * B. Yin/SAIC          08/04   changed pgtca_freeBkpts to cvg_freeBkpts
 * J. Wu/SAIC		10/04	free GFA block pointers			*
 * J. Wu/SAIC		06/06	call cvg_matchfilter 			*
 * M. Li/SAIC           03/07   Updated cvg_matchfilter                 *
 ***********************************************************************/
{
    int 		ii, kk, ier, flag, level, location, el_layer;
    int			elms[3][MAX_EDITABLE_ELEMS], lvl_cnt[LEVELS];
    float		fllx, flly, furx, fury;
    VG_DBStruct		el;
    filter_t		el_filter, timeMatched;
    Boolean		filter_match, matchAny = False;
/*---------------------------------------------------------------------*/

    *iret = 0;

    for ( ii = 0; ii < 3; ii++ ) {
        lvl_cnt[ ii ] = 0;
    }

    if ( fp == NULL ) {
        *iret = -1;
	return;
    }


    /*
     *  Scan the range records and locate elements on the given layer.       
     */
    for ( ii = 0; ii < MAX_EDITABLE_ELEMS; ii++ ) {

	crg_goffset( ii, &location, &ier );

	if ( location >= 0 ) {
	    crg_get( ii, &el_layer, el_filter, &fllx, &flly, &furx, &fury, &ier);
	    
	     if ( el_layer == layer && 
	         cgr_ntrsct(llx, lly, urx, ury, fllx, flly, furx, fury, &ier) ) {
	        
                 cvg_matchfilter ( el_filter, matchAny, &filter_match, timeMatched, &ier );
				
	         if ( filter_match ) {
		     cvg_rdhdr( fname, fp, location, fsize, &el, &flag, &ier );

                     cvg_level( &el.hdr, &level, &ier );
	             if ( ier == 0 ) {	
	                 elms[ level ] [ lvl_cnt[level]++ ] = location;
                     }
		 }
	     }
        }
    }


    /*
     *  Now loop thru the levels and display elements on the given layer.
     */
    level = 0;    
    for ( ii = 0; ii < LEVELS; ii++ ) {

	for ( kk = 0; kk < lvl_cnt[level]; kk++ ) {
	    location = elms[ii][kk];
	    cvg_rdhdr( fname, fp, location, fsize, &el, &flag, &ier );
	    cvg_rdele( &el, location, el.hdr.recsz, fp, &ier );
    	    cds_dspelm( &el, &ier );

	    /*
              * Free TCA/GFA memory
              */
            if ( el.hdr.vg_type == TCA_ELM ) {
               cvg_freeBkpts ( &el );
            }
            else if ( el.hdr.vg_type == GFA_ELM ) {
                cvg_freeElPtr ( &el );
	    }

    	}

	level++;
    }

}
예제 #3
0
void cvg_scangfa ( char *fname, int layer, int subtype, int areatype,
		   char *tag, VG_DBStruct *el, int *selected, int *iret )
/************************************************************************
 * cvg_scangfa								*
 *									*
 * This function scans a vector graphics file looking for a GFA element	*
 * that matches the layer, subtype, area type (hazard) and tag input.	*
 * The first matching record is returned in "el". Also,			*
 * the element should match one of the active filters.			*
 *									*
 * cvg_scan ( fname, layer, subtype, areatype, tag, el, selected, iret )*
 *									*
 * Input parameters:							*
 *	*fname		char		Name of file to scan from	*
 *	layer		int		layer to test against		*
 *	subtype		int		subtype to test against		*
 *	areatype	int		area type to test against	*
 * 	tag		char		gfa tag to test against		*
 *									*
 * Output parameters:							*
 *	*el		VG_DBStruct	Pointer to VG record structure	*
 * 	*selected	int		Offset to selected element	*
 *	*iret		int		Return code			*
 *					 -1 = error opening VG file	*
 *					 -2 = error closing VG file	*
 *					 -6 = element not found		*
 *					-13 = error reading VG header	*
 *					-14 = error reading VG element	*
 *									*
 **									*
 * Log:									*
 * J. Wu/SAIC		08/04	initial coding (modified from cvg_scan)	*
 * J. Wu/SAIC		10/04	use cvg_getFld to access GFA attributes	*
 * E. Safford/SAIC	07/05	replace seqnum param with tag		*
 * J. Wu/SAIC		06/06	call cvg_matchfilter 			*
 * M. Li/SAIC           03/07   Updated cvg_matchfilter                 *
 ***********************************************************************/
{
    int		ii, ier, el_layer, location;
    float	llx,lly,urx,ury;
    long	size;
    char	newfil[133], reqfil[133], cclass, ctype, value[32];
    FILE	*fp;
    filter_t    el_filter, timeMatched;
    Boolean     filter_match, matchAny = False;
/*---------------------------------------------------------------------*/

    *iret = 0;
    *selected = -1;
    
    if ( !fname ) {
	strcpy ( reqfil, work_file );
    }
    else { 
	strcpy ( reqfil, fname );
    }

    /* 
     *  Inquire the size of the VG file and open the file for update.
     */
    cfl_inqr ( reqfil, NULL, &size, newfil, &ier );
    fp = (FILE *) cfl_uopn ( newfil, &ier );
    if ( (ier != 0) || (fp == NULL) ) {
	*iret = -1;
	return;
    }

    /* 
     *  Loop through all elements to find a match.
     */    
    for ( ii = 0; ii < MAX_EDITABLE_ELEMS; ii++ ) {

	crg_goffset ( ii, &location, &ier );
	if ( location < 0 ) {
	    continue;
	}

	crg_get ( ii, &el_layer, el_filter, &llx, &lly, &urx, &ury, &ier );
	if ( ier >= 0 ) {
	    crg_gtyp ( ii, &cclass, &ctype, &ier );
	}	
	
	if ( ier < 0 ) {
	    continue;
	}
	
	
	/*
	 *  Match layer, class, vg type first.
	 */
	if ( (el_layer == layer) && (cclass == CLASS_MET) &&
	     (ctype == GFA_ELM) ) {

	    
	    /*
	     *  Then check if the element matches one of the filters.
	     */
            cvg_matchfilter ( el_filter, matchAny, &filter_match, timeMatched, &ier );
	    
	    if ( !filter_match ) {
		continue;
	    }
            
	    
	    /*
             *  Read the element.
             */
            cvg_rdrecnoc ( newfil, fp, location, el, iret );	    
	    if ( *iret != 0 ) {
	        continue;
	    }
	    
	    
	    /*
             *  Match the subtype, area type, and tag.
             */
	    cvg_getFld ( el, TAG_GFA_SUBTYPE, value, &ier );
	    if ( subtype == atoi(value) ) {
	        cvg_getFld ( el, TAG_GFA_AREATYPE, value, &ier );
	        
  		if ( areatype == atoi(value) ) {
  	            cvg_getFld ( el, TAG_GFA_TAG, value, &ier ); 

		    if( strcmp( tag, value ) == 0 ) {	            
		        *selected = location;
		        break;
  		    } 
		}
	    }
	}	    
    }	


    /*
     *  Check if there is an matching record found.
     */
    if ( *selected < 0 ) {
        *iret = -6;
    }
    
    /*
     *  Close the VG file.
     */
    cfl_clos(fp, &ier);
    if ( ier != 0 )  *iret = -2;

}
예제 #4
0
void cvg_load ( char *fname, Boolean selflag, Boolean wrtflg, 
			Boolean plotflg, int layer, int icol, int *iret )
/************************************************************************
 * cvg_load								*
 *									*
 * This function loads data from a VGF formatted file and converts 	*
 * encountered records to a set of actions that display the feature	*
 * to an appropriate driver.  The parameter icol controls whether the	*
 * graphics will be plotted with the file-specified colors (icol=0)	*
 * or whether the VGF file will be plotted monochrome (icol=other).	*
 *									*
 * void cvg_load ( fname, selflag, wrtflg, plotflg, layer, icol, iret )	*
 *									*
 * Input parameters:							*
 *	*fname		char		Name of file to load		*
 *	selflag		Boolean		Are elements "selectable"	*
 *	wrtflg		Boolean		Write flag for file		*
 *	plotflg		Boolean		Display the elements or not	*
 *	layer		int		Layer the file contents will be	*
 *					   assigned to			*
 *	icol		int		Plot color			*
 *									*
 * Output parameters:							*
 *	*iret		int		Return code			*
 *					  1 = elms in file exceeded 	*
 *				              (MAX_EDITABLE_ELEMS)	*
 *					 -1 = error opening VG file	*
 *					 -2 = error closing VG file	*
 *					 -4 = error reading el hdr      *
 *					 -5 = VG file is empty		*
 **									*
 * Log:									*
 * E. Wehner/EAi	10/96	Created					*
 * D. Keiser/GSC	 1/97	Clean up				*
 * E. Wehner/EAi	 2/97	Added selection flag.			*
 * E. Wehner/EAi	 5/97	Add double tier loading 		*
 * E. Wehner/EAi	 5/97	Stop loading if > MAX_EDITABLE_ELEMS	*
 * E. Wehner/EAi	 5/97	Added refresh after displaying 		*
 * D. Keiser/GSC	 5/97	Change cvg_dsply to cds_dspvg		*
 * S. Jacobs/NCEP	 6/97	Added write flag			*
 * C. Lin/NCEP	 	 6/97	Bug fix in calling cfl_ropn 		*
 * E. Wehner/EAi	 6/97	Added check to not load header		*
 * E. Wehner/EAi	 7/97	Filled areas on all elements		*
 * E. Wehner/EAi	 8/97	Removed the graphics info record.	*
 * E. Wehner/EAi	 9/97	Allow NULL file name			*
 * F. Yen/NCEP		 1/98	Updated calls for crg library cleanup	*
 * I. Durham/GSC	 5/98	Changed underscore decl. to an include	*
 * F. J. Yen/NCEP	 5/98	Updated cds function names		*
 * E. Safford/GSC	10/98	added display levels revised file reads *
 * T. Piper/GSC		10/98	Prolog update				*
 * E. Safford/GSC	12/98	move display levels to pgprm.h		*
 * S. Jacobs/NCEP	 3/99	Added symbols to the last display level	*
 * A. Hardy/GSC          1/01   changed fptr from int to FILE           *
 * J. WU/SAIC           11/01   change prototype & add plotflg param	*
 * J. WU/SAIC           12/01   add layer param to feed crg_set()	*
 * J. WU/SAIC           12/01   locate displaying level	with cvg_level  *
 * T. Lee/SAIC		11/03	changed .DEFAULT.vgf to work_file	*
 * T. Lee/SAIC		11/03	used cvgcmn.h				*
 * M. Li/SAIC		08/04	Added time filter			*
 * B. Yin/SAIC          08/04   Added code to free TCA memory           *
 * B. Yin/SAIC          08/04   changed pgtca_freeBkpts to cvg_freeBkpts*
 * J. Wu/SAIC		10/04	free GFA block pointers			*
 * S. Danz/AWC          03/06   Call autoplacement if enabled           *
 * J. Wu/SAIC		06/06	call cvg_matchfilter 			*
 * M. Li/SAIC           03/07   Updated cvg_matchfilter                 *
 * m.gamazaychikov/SAIC	06/07	Add code to free TCB and TCT memory	*
 ***********************************************************************/
{
    int		    curpos, ier, flag, el_level;
    long	    maxbytes;
    int		    ier1, loglev, ic, icx, ii, jj, kk, one=1;
    int		    elms[3][MAX_EDITABLE_ELEMS], lvl_cnt[LEVELS], total_elms;
    char	    newfil[LLPATH], reqfil[LLPATH], grp[4], dbgfile[LLPATH];
    Boolean         autopl_enabled;
    VG_DBStruct	    el;
    filter_t	    el_filter, timeMatched;
    Boolean	    filter_match, matchAny = False;
    FILE	    *fptr;
    CMDObjectSet    nmap_metadata = NULL;
    PlacementSet    nmap_placements = NULL;
    cvg_group_info  *nmap_group_check = NULL;
/*---------------------------------------------------------------------*/

    ic = icol;
    icx = 256;
    if ( ic > icx || ic < 0 )  ic = 0;
    cds_scol ( ic, iret );

    strcpy(grp, "CVG");
    loglev = 0;
    *iret = 0;
    curpos  = 0;
    maxbytes = 0;    

    if (!fname) {
	strcpy(reqfil, work_file);
    }
    else {
	strcpy(reqfil, fname);
    }


    cvg_open(reqfil, (int)wrtflg, &fptr, &ier);

    if (( ier != 0 ) || ( fptr == NULL )) {
	*iret = -1;
	er_lmsg( &loglev, grp, &ier, reqfil, &ier1, strlen(grp),strlen(reqfil));
	return;
    }

    cfl_inqr(reqfil, NULL, &maxbytes, newfil, &ier);
    if (ier < 0) {
	*iret = -1;
	er_lmsg( &loglev, grp, &ier, reqfil, &ier1, strlen(grp),strlen(reqfil));
	return;
    }

    /*
     * Get each el.hdr and assign each elem offset to one of the levels.
     */
    for (ii = 0; ii < 3; ii++) {
        lvl_cnt[ii] = 0;
    }

    /*
     *  Scan the vg file and load the offsets of all non-deleted elements.
     *  Stop loading at end of file or MAX_EDITABLE_ELEMS.
     */
    total_elms = 0;
    while (((long)curpos < maxbytes) && (total_elms < MAX_EDITABLE_ELEMS))  {

        cvg_rdhdr(newfil, fptr, curpos, (int)maxbytes, &el, &flag, &ier);
	if (ier < 0 || el.hdr.recsz < 0 || el.hdr.recsz > 65536) {
	    *iret = -4;
	    return;
	}

        cvg_level( &el.hdr, &el_level, &ier );
	if ( ier == 0 ) {	
	    elms[ el_level ] [ lvl_cnt[el_level]++ ] = curpos;
	    total_elms++;
	}
		
 	curpos += el.hdr.recsz;	
    }

    if (total_elms >= MAX_EDITABLE_ELEMS) {
	*iret = 1;
	er_lmsg( &loglev, grp, &ier, newfil, &ier1, 
						strlen(grp),strlen(reqfil));
    }

    /*
     *  Create the structures to manage the metadata and object placement
     *  information.  If there were structures already in place, hold them
     *  aside as they were put there by product generation.
     */
    ctb_pfbool( "ENABLE_AUTOPLACE", &autopl_enabled, &ier );
    if (autopl_enabled) {
        if (cvg_metadata) {
            nmap_metadata = cvg_metadata;
            nmap_placements = cvg_placements;
            nmap_group_check = cvg_group_check;
        }
        cmd_osnew(&cvg_metadata, &ier);
        cap_psnew(&cvg_placements, &ier);
        G_CALLOC(cvg_group_check, cvg_group_info, one, "cvg_load: cvg_group_check");

        /*
         * Fill in the structures with the information needed
         */
        cvg_ld4place(fname, iret);

        /*
         * Ok, its all loaded, so place all the objects where they belong
         */
        cap_psplace(cvg_placements, cvg_metadata, iret);

        ctb_pfstr("AUTOPLACE_DBG", dbgfile, &ier );
        if (dbgfile[0] != '\0') {
            dump_objects(dbgfile, cvg_metadata, cvg_placements);
        }
    }

    /*
     *  Now loop thru the levels and display the elements
     */
    kk = 0;

    for (ii = 0; ii < LEVELS; ii++) {

	for (jj=0; jj<lvl_cnt[kk]; jj++) {
	    curpos = elms[ii][jj];
            cvg_rdhdr(newfil, fptr, curpos, (int)maxbytes, &el, &flag, &ier);
	    cvg_rdele(&el, curpos, el.hdr.recsz, fptr, &ier);

	    cvg_getElFilter ( &el, el_filter, &ier ); 

            cvg_matchfilter ( el_filter, matchAny, &filter_match, timeMatched, &ier );

	    if (selflag) {
	        crg_set(&el, curpos, layer, &ier);
	    }

	    if ( filter_match ) {
	        cds_dspelm( &el, &ier); 
	    }

            /*
             * Free TCA/GFA/TCT/TCB memory
             */
            if ( el.hdr.vg_type == TCA_ELM ) {
                cvg_freeBkpts ( &el );
            }
            else if ( el.hdr.vg_type == GFA_ELM ) {
                cvg_freeElPtr ( &el );
            }
            else if ( el.hdr.vg_type == TCTRK_ELM ) {
                cvg_freeTct ( &el );
            }
            else if ( el.hdr.vg_type == TCBKL_ELM ) {
                cvg_freeTcb ( &el );
	    }
	}

	kk++;
    }

    cvg_clos(fptr, &ier);
    if ( ier != 0 )
	*iret = -2;

    if ( plotflg ) geplot(&ier);
    ic = 0;
    cds_scol ( ic, iret );

    /*
     * Free up the metadata and placement information now that we 
     * are done plotting everything
     */
    if (autopl_enabled) {
        cmd_osdel(cvg_metadata, iret);
        cap_psdel(cvg_placements, iret);
        G_FREE(cvg_group_check, cvg_group_info);

        /*
         * Put back the product generation metadata
         */
        cvg_metadata = nmap_metadata;
        cvg_placements = nmap_placements;
        cvg_group_check = nmap_group_check;
    }

    return;

}