int DoIt( char *in_file, int vg_class, int vg_type, int obj_type, int *match ) { int iret; int readpos; long in_size; char tmp_name[PATH_MAX]; VG_DBStruct el; readpos = 0; *match = 0; cfl_inqr(in_file, NULL, &in_size, tmp_name, &iret); while (!*match && !iret && (readpos < in_size)) { cvg_rdrec(in_file, readpos, &el, &iret); if (!iret) { readpos += el.hdr.recsz; *match = obj_match(&el, vg_class, vg_type, obj_type); } } return iret; }
int main ( void ) /************************************************************************ * TESTCVQ * * * * This program tests the CGEMLIB "CVQ" functions. * * * ** * * Log: * * E. Wehner/EAi 6/97 Created * * E. Wehner/EAi 7/97 Fixed typecasting of group type * * E. Wehner/EAi 7/97 Added cvq_higrp. * * I. Durham/GSC 5/98 Changed underscore decl. to an include * * A. Hardy/SAIC 11/01 Added maxoff to cvq_scangrp * ***********************************************************************/ { int cont, iret, numsub, i, ier; int flag, level, elevel, ebuff; int eflag; int ingrp, maxoff; long size; char select[LLSCRN], filnam[LLSCRN]; char grp[4], path[133]; VG_DBStruct el; int vgstart; char gptyp; /* group type */ int gpnum; /* group number */ int members[10]; int fpos; int tgtyp; /* temporary group type */ /*---------------------------------------------------------------------*/ iret = 0; size = 0; cont = G_FALSE; flag = G_FALSE; eflag = G_FALSE; strcpy(grp, "CVQ"); level = 0; elevel = 2; ebuff = 0; in_bdta(&ier); er_stat(&elevel, &ebuff, &eflag, &ier); vgstart = 0; cvg_rdrec ( filnam, vgstart, &el, &iret ); while ( cont == G_FALSE ) { numsub = 0; printf ( "\n\n" ); printf (" 1 = CVQ_SCANGRP 2 = CVQ_GETGINF 3 = CVQ_NXTGNM\n"); printf (" 4 = CVQ_HIGP \n"); printf ( "\n" ); printf ( "Select a function number or type EXIT: " ); scanf ( " %s", select ); switch ( select[0] ) { case 'e': case 'E': cont = G_TRUE; break; default: numsub = atoi ( select ); break; } /*---------------------------------------------------------------------*/ switch (numsub) { /* * ---------------------------------------------------------- * CVQ_SCANGRP - retrieve the members of a group * ---------------------------------------------------------- */ case 1: printf ( "Enter the VG file name to scan:\n" ); scanf ( " %s", filnam ); printf( "Enter Group type to retrieve:\n"); scanf( " %i", &tgtyp); printf( "Enter Group number to retrieve: \n"); scanf( " %i", &gpnum); printf( "Enter maximum number of offsets to find: \n"); scanf( " %i", &maxoff); gptyp = (char)tgtyp; cvq_scangrp( filnam, gptyp, gpnum, maxoff, members, &ingrp, &iret); printf ( "\nCVQ_SCANGRP: iret = %d\n\n", iret ); printf(" Extracted %i elements in group: %i/%i \n", ingrp, gptyp, gpnum); for (i = 0; i< ingrp; i++) { /* read header */ cfl_inqr ( filnam, " ", &size, path, &ier ); if (members[i] < size) { cvg_rdrec ( filnam, members[i], &el, &iret ); cvg_dump ( el, el.hdr.recsz, el.hdr.recsz, flag, &iret ); } } er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp), strlen(filnam) ); break; /* * ---------------------------------------------------------- * CVQ_GETGINF - Return group type and number from elem. * ---------------------------------------------------------- */ case 2: printf ( "Enter the VG file name to examine:\n" ); scanf ( " %s", filnam ); printf( "Enter file location of element in question:\n"); scanf( " %i", &fpos); cvq_getginf( filnam, fpos, &gptyp, &gpnum, &iret); printf ( "\nCVQ_GETGINF: iret = %d\n\n", iret ); printf(" Element is in group %c %i \n", gptyp, gpnum); er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp), strlen(filnam) ); break; /* * ---------------------------------------------------------- * CVQ_NXTGNM - Get next group number used in file * ---------------------------------------------------------- */ case 3: printf ( "Enter the VG file name to examine:\n" ); scanf ( " %s", filnam ); printf( "Enter the group type to retrieve from:\n"); scanf( " %i", &tgtyp); gptyp = (char)tgtyp; printf( "Locate the next group number above: \n"); scanf( " %i", &gpnum); cvq_nxtgnm( filnam, gptyp, &gpnum, &iret); printf ( "\nCVQ_NXTGNM: iret = %d\n\n", iret ); printf(" The next group number of group type %c is %i \n", gptyp, gpnum); er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp), strlen(filnam) ); break; /* * ---------------------------------------------------------- * CVQ_HIGP - Get highest group number used in file * ---------------------------------------------------------- */ case 4: printf ( "Enter the VG file name to examine:\n" ); scanf ( " %s", filnam ); cvq_higp( filnam, &gpnum, &iret); printf ( "\nCVQ_HIGP: iret = %d\n\n", iret ); printf(" The highest group number is %i \n", gpnum); er_lmsg ( &level, grp, &iret, filnam, &ier, strlen(grp), strlen(filnam) ); break; } } return 0; }
static void pgfilterw_updateFilter ( void ) /************************************************************************ * pgfilterw_updateFilter * * * * Updates the current filter string and then refreshes the display. * * * * static void pgfilterw_updateFilter ( void ) * * * * Input parameters: * * Output parameters: * * none * * * ** * * Log: * * J. Wu/SAIC 07/04 initial coding * * J. Wu/SAIC 08/04 link filter change with GFA window * * J. Wu/SAIC 09/04 Restart GFA for any filter changes * * J. Wu/SAIC 10/04 Access GFA attr with cvg_getFld() * * E. Safford/SAIC 07/05 rm sequence # from cvg_scangfa() call * * M. Li/SAIC 03/07 Not reset fcst hour if change from GFA * * E. Safford/SAIC 05/07 fix gfa' connection * * E. Safford/SAIC 06/07 fix bug in preFilterOn determination * * B. Yin/SAIC 12/07 set GFA hr to last selected filter time * ***********************************************************************/ { int ii, filternum, ier, cur_obj, cur_loc, newel_loc, num; int subtyp, areatyp, len; char lastTime[8], value[32], tag[32], timeCmp[10]; Boolean gfaIsUp = False, gfaInAdd = False, preFilterOn = False; Boolean gfaPrimeIsUp = False; VG_DBStruct cur_el, newel; /*---------------------------------------------------------------------*/ cur_el.elem.gfa.info.nblocks = 0; _curFilter[0] = '\0'; filternum = 0; for ( ii = 0; ii < _nFilTime[TIME_FILTER]; ii++ ) { if ( _filterStatus[ii] ) { filternum++; strcat ( _curFilter, _filTime[TIME_FILTER][ii] ); if ( ii < (_nFilTime[TIME_FILTER] - 1) ) { strcat ( _curFilter, ";" ); } } } /* * If no filter is provided but the filter window is up - none * of the elements with time stamp will be displayed. If the * filter window is down, all elements should be displayed. */ if ( filternum == 0 ) { if ( pgfilterw_isUp() ) { strcpy ( _curFilter, ACTV_FILTER ); } else { strcpy ( _curFilter, CANCEL_FILTER ); } } /* * Check if gfaw is up and its mode. */ gfaIsUp = pggfaw_isUp(); gfaPrimeIsUp = pggfawp_isUp(); if( gfaIsUp ) { gfaInAdd = pggfaw_isAddMode(); } else if( gfaPrimeIsUp ) { gfaInAdd = pggfawp_isAddMode(); } cur_obj = pgpalw_getCurObjId (); /* * If gfaw is up, retrieve the current GFA attributes and check * if the previous forecast hour is still "ON" in filter window. * * If it is still on, then take no action. If it is not, and there * is another time selected, set the GFA/GFA' window forecast hour to * the first selected time. * * Note that the GFA/GFA' will ignore the Airmet and Outlook filter * settings. */ cur_loc = -1; preFilterOn = False; if ( gfaIsUp || gfaPrimeIsUp ) { if ( gfaInAdd ) { if( gfaIsUp ) { pggfaw_getAttr ( &cur_el ); ier = 0; } else { pggfawp_getAttr ( &cur_el ); ier = 0; } } else { cur_loc = pgactv_getElmLoc (); cvg_rdrec ( cvg_getworkfile(), cur_loc, &cur_el, &ier ); } cvg_getFld ( &cur_el, TAG_GFA_FCSTHR, value, &ier ); if ( filternum > 0 && ier == 0 ) { for ( ii = 0; ii < _nFilTime[TIME_FILTER]; ii++ ) { if ( _filterStatus[ii] ) { strcpy( timeCmp, _filTime[TIME_FILTER][ii] ); len = strlen( timeCmp ); if( timeCmp[ len-1 ] == '+' ) { timeCmp[ len-1 ] = '\0'; } if ( strcmp ( value, timeCmp ) == 0 ) { preFilterOn = True; break; } } } } } /* * Update filter setting in CVG library. */ cvg_setfilter ( _curFilter, &ier ); /* * Refresh the display. */ pgfilterw_refresh (); /* * Adjust GFA window, if necessary. */ if ( gfaIsUp || gfaPrimeIsUp ) { /* * If previously in "Add" mode, keep drawing. */ if ( gfaInAdd ) { /* * Set the GFA hour to the last selected filter time. * */ pgfilterw_getLastTime ( lastTime ); if ( strlen ( lastTime ) > (size_t)0 ) { if (!_fromGfa) { if( gfaIsUp ) { pggfaw_setHour ( lastTime ); } else { pggfawp_setHour ( lastTime ); } } } } else { /* Previously in "Edit" mode */ /* * The filter matching the active element's forecast hour * is still ON, keep editing it. */ if ( preFilterOn ) { cvg_freeElPtr( &cur_el ); pghdlb_select ( &cur_el, cur_loc ); } else { /* * The filter matching the active element's forecast * hour is OFF, terminate all pending actions. * However, if it is turned off by pressing hotkeys, * and a GFA element matching the same subtype, * and area type number could be found, * set to edit that element. */ if ( _offByHotkey ) { cvg_getFld ( &cur_el, TAG_GFA_SUBTYPE, value, &ier ); subtyp = atoi ( value ); cvg_getFld ( &cur_el, TAG_GFA_AREATYPE, value, &ier ); areatyp = atoi ( value ); cvg_getFld ( &cur_el, TAG_GFA_TAG, tag, &ier ); cvg_scangfa ( NULL, pglayer_getCurLayer(), subtyp, areatyp, tag, &newel, &newel_loc, &ier ); if ( ier == 0 ) { crg_getinx ( cur_loc, &num, &ier); pghdlb_deselectEl ( num, TRUE ); pgactv_setActvElm ( &newel, newel_loc ); pghdlb_select ( &newel, newel_loc ); if( gfaIsUp ) { pggfaw_setAttr ( &newel ); } else { pggfawp_setAttr ( &newel ); } } else { pgevt_unsetOper ( TRUE ); } } else { pgevt_unsetOper ( TRUE ); } _offByHotkey = False; } } /* End "if" in edit mode */ } cvg_freeElPtr( &cur_el ); _fromGfa = False; }
void cvg_rdsel ( char *fname, int fpos, float x, float y, int *hotpt, float *distance, VG_DBStruct *el, int *iret ) /************************************************************************ * cvg_rdsel * * * * This function reads in a record from a vector graphics file only * * based upon the contents of the Graphics Infor record, which * * specifies the requested element number, and the file name. * * * * cvg_rdsel ( fname,fpos,x, y, hotpt, distance, el, iret ) * * * * Input parameters: * * *fname char File name to read from * * fpos int File position selected * * x float X coordinate of point to locate * * y float Y coordinate of point to locate * * * * Output parameters: * * *hotpt int Index to closest point * * *distance float distance to closest point * * *el VG_DBStruct Pointer to VG record structure * * *iret int Return code * * 1 = distance to hotpt * * exceeds tie-in * * -1 = error opening VG file * * -2 = error closing VG file * * -13 = error reading VG header * * -14 = error reading VG element * * * ** * * Log: * * E. Wehner/EAi 11/96 Created * * D. Keiser/GSC 1/97 Clean up * * E. Wehner/EAi 2/97 cgr_distance -> cgr_dist * * D.W.Plummer/NCEP 9/97 Changes for new vgstruct header file * * E. Wehner/EAi 9/97 Remove grinfo, use parms for fname * * F. J. Yen/NCEP 11/97 Replace " " with NULL in invocation of * * cfl_inqr. * * G. Krueger/EAI 1/98 Ignore non-fatal read warnings. * * I. Durham/GSC 5/98 Changed underscore decl. to an include * * E. Safford/GSC 10/98 use WORK_FILE & use cvg_rdrec for read * * T. Piper/GSC 10/98 Prolog update * * E. Safford/GSC 02/01 add tie-in distance check & return code * * T. Lee/SAIC 11/03 added user directory to work_file * * T. Lee/SAIC 11/03 used cvgcmn.h * ***********************************************************************/ { int ier, np; float dist; float dx[MAXPTS], dy[MAXPTS]; char grp[4]; char reqfil[133]; /*---------------------------------------------------------------------*/ *iret = 0; dist = *distance = -99.0F; np = 1; strcpy(grp, "CVG"); if (!fname) { strcpy(reqfil, work_file); } else { strcpy(reqfil, fname); } cvg_rdrec (reqfil, fpos, el, iret); if ( *iret < 0 ) { el = (VG_DBStruct *) NULL; hotpt = NULL; } /* * Locate the nearest point & return as hotpt. */ if ( ( x > 0.0F ) && ( y > 0.0F ) ) { /* * Convert the element vertices to D coords then check distance * to the line segment. */ cvg_todev( el, &np, dx, dy, &ier); cgr_dist(np, dx, dy, x, y, &dist, hotpt, &ier); *distance = dist; } /* * If distance exceeds vertex tiein, return warning */ if ( dist > VERTEX_TIEIN ) { *iret = 1; } }
/* ARGSUSED */ static void _pgmvcp_groupDropEh ( Widget w, XtPointer clnt, XEvent *event, Boolean *ctdr ) /************************************************************************ * _pgmvcp_groupDropEh * * * * This function is the callback for a drop on a group. * * * * static void _pgmvcp_groupDropEh (w, clnt, event, ctdr) * * * * Input parameters: * * w Widget Parent widget * * clnt XtPointer State information record * * *event XEvent Button press event record * * * ** * * Log: * * E. Safford/GSC 06/97 Modified to handle Special Text * * E. Wehner/EAi 07/97 Remove offsets when replacing text. * * E. Safford/GSC 07/97 Fixed drag with special text problem * * E. Wehner/EAi 08/97 Remove watch box slide * * C. Lin/EAI 8/97 Add offsets for 'S' coord(roam) * * D.W.Plummer/NCEP 9/97 Combine into NxmDraw for new vgstruct.h * * E. Wehner/EAi 9/97 Remove graphics info record * * C. Lin/EAi 10/97 rename from NxmDrSlDropCb, cleanup * * C. Lin/EAi 10/97 add WBOX_ELEM related functions * * C. Lin/EAi 11/97 further cleanup * * E. Safford/GSC 02/98 add _storedEl for undo function * * S. Law/GSC 04/98 added copy function * * E. Safford/GSC 04/98 added FUNC_SELECT to FUNC_MOVE ops * * S. Law/GSC 05/98 cleaned up drag, added group box * * E. Safford/GSC 05/98 mod for new undo routines * * E. Safford/GSC 05/98 move to nmap_pgmvcp.c * * E. Safford/GSC 06/98 split from mvcpDrop.c * * E. Safford/GSC 06/98 added call to cgr_grfrsh.c * * G. Krueger/EAI 06/98 Uniform status hints * * C. Lin/EAI 08/98 fix ghosting problem & reset _dragCount * * G. Krueger/EAI 09/98 Added ghost veiling * * G. Krueger/EAI 10/98 Using table for hints * * E. Safford/GSC 12/98 modify refresh to limit area affected * * D.W.Plummer/NCEP 4/99 remove call to pgwlst_update * * E. Safford/GSC 10/99 update for new xwcmn.h * * S. Law/GSC 06/00 changed to use xgtoff * * H. Zeng/EAI 11/00 changed for the new undo design * * H. Zeng/EAI 11/00 changed cvg_rdrec() parameters * * A. Hardy/GSC 11/00 renamed coordinate system declarations * * H. Zeng/EAI 12/00 modified for multiple undo steps * * J. Wu/SAIC 12/01 add layer in crg_set() call * * T. Lee/SAIC 11/03 added user directory to work_file * * T. Lee/SAIC 11/03 used cvg_getworkfile * * J. Wu/SAIC 11/03 adjust jet barb/hash position * * J. Wu/SAIC 02/04 adjust gfa attribute box position * * J. Wu/SAIC 10/04 free GFA block memory * * S. Danz/AWC 07/06 Added new cvg_delet placement argument * * S. Danz/AWC 08/06 New flag to pgvgf_saveNewElm to place el* * S. Danz/AWC 08/06 Updated to use cvg_checkplace to find * * area impacted and call crg_rebuild() * ***********************************************************************/ { int location, ier, nelm, ii, jj, *inxarry, layer, update_crg; int currfunc, newnum, old_location, xoff, yoff, found; float llx, lly, urx, ury, delx, dely; float o_llx, o_lly, o_urx, o_ury, inf_bbox[4]; char newtyp; VG_DBStruct el, del_el; /*---------------------------------------------------------------------*/ _dragCount = 0; mcanvw_disarmDrag(); mcanvw_disarmDrop(); pggst_clearGhost(TRUE); if (!_midDrag) return; _midDrag = FALSE; update_crg = 0; currfunc = pgpalw_getCurOperId(); old_location = pgactv_getElmLoc(); cvg_rdrec(cvg_getworkfile(), old_location, &el, &ier); crg_ggnel(el.hdr.grptyp, el.hdr.grpnum, &nelm, &ier); if (nelm <= 0) return; inxarry = (int *)malloc(nelm*sizeof(int)); crg_gginx (el.hdr.grptyp, el.hdr.grpnum, nelm, inxarry, &nelm, &ier); newtyp = el.hdr.grptyp; newnum = el.hdr.grpnum; crg_ggbnd (newtyp, newnum, &o_llx, &o_urx, &o_ury, &o_lly, &ier); if (currfunc == FUNC_COPY) crg_ggnxt (el.hdr.grptyp, &newnum, &ier); /* * set "delta" amounts... */ xgtoff (&xoff, &yoff, &ier); delx = (float)event->xbutton.x + (float)xoff - _dragX; dely = (float)event->xbutton.y + (float)yoff - _dragY; _dragX += delx; _dragY += dely; delx = _dragX - _origX - _goffX; dely = _dragY - _origY - _goffY; pghdlb_deselectEl (old_location, FALSE); /* * 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 ); } pgundo_newStep(); layer = pglayer_getCurLayer( ); for (ii = 0; ii < nelm; ii++) { crg_goffset(inxarry[ii], &location, &ier); cvg_rdrec(cvg_getworkfile(), location, &el, &ier); pgactv_setActvElm ( &el, location); pgactv_getDevPts (&_dcN, &_dcX, &_dcY); for (jj = 0; jj < _dcN; jj++) { pgactv_modPt (jj, *(_dcX + jj) + delx, *(_dcY + jj) + dely); } if ((currfunc == FUNC_MOVE) || (currfunc == FUNC_SELECT)) { /* * Mark elements in placement that are effected by * the delete, and get the area of influence back */ cvg_rdrec(cvg_getworkfile(), location, &del_el, &ier); cvg_checkplace(&del_el, 1, location, &found, inf_bbox, &ier); if (found > 0) { /* * Update the refresh extent if the area impacted by * placement was bigger than the area passed in */ o_llx = G_MIN(o_llx, inf_bbox[0]); o_lly = G_MIN(o_lly, inf_bbox[2]); o_urx = G_MAX(o_urx, inf_bbox[1]); o_ury = G_MAX(o_ury, inf_bbox[3]); update_crg = 1; } /* * Free TCA/GFA memory */ if ( del_el.hdr.vg_type == TCA_ELM ) { cvg_freeBkpts ( &del_el ); } else if ( del_el.hdr.vg_type == GFA_ELM ) { cvg_freeElPtr ( &del_el ); } /* * delete old element */ cvg_delet (cvg_getworkfile(), location, TRUE, &ier); crg_clear (inxarry[ii], &ier); pgundo_storeThisLoc(location, UNDO_DEL, &ier); } /* * adjust jet barb/hash position accordingly */ if ( el.hdr.vg_type == JET_ELM ) { _pgmvcp_jetCalc ( &el, delx, dely, True ); } /* * adjust GFA attribute box position accordingly */ if ( el.hdr.vg_type == GFA_ELM ) { _pgmvcp_gfaCalc ( &el, delx, dely, True ); } /* * save new element */ el.hdr.grptyp = newtyp; el.hdr.grpnum = newnum; pgvgf_saveNewElm(NULL, sys_D, &el, _dcN, _dcX, _dcY, FALSE, &location, &ier); pgundo_storeThisLoc (location, UNDO_ADD, &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 ); } cvg_rdrec(cvg_getworkfile(), location, &el, &ier); crg_set (&el, location, layer, &ier); /* * Mark elements in placement that are effected by * the new element, and get the area of influence back */ cvg_checkplace(&el, 0, location, &found, inf_bbox, &ier); if (found > 0) { /* * Update the refresh extent if the area impacted by * placement was bigger than the area passed in */ o_llx = G_MIN(o_llx, inf_bbox[0]); o_lly = G_MIN(o_lly, inf_bbox[2]); o_urx = G_MAX(o_urx, inf_bbox[1]); o_ury = G_MAX(o_ury, inf_bbox[3]); update_crg = 1; } /* * 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 ); } } /* for */ pgundo_endStep(); pgactv_setActvElm (&el, location); crg_ggbnd (newtyp, newnum, &llx, &urx, &ury, &lly, &ier); free (inxarry); o_llx -= EXTRA; o_lly -= EXTRA; o_urx += EXTRA; o_ury += EXTRA; if (o_llx < llx) llx = o_llx; if (o_lly < lly) lly = o_lly; if (o_urx > urx) urx = o_urx; if (o_ury > ury) ury = o_ury; xpgpaste (llx, lly, urx, ury, &ier); cvg_rfrsh (NULL, llx, lly, urx, ury, &ier); /* * If we may have impacted other elements with placement * we will need to rebuild the range records */ if (update_crg) { crg_rebuild(); } pghdlb_select (&el, location); mbotw_mouseSet(LMHINT_DRAG, MMHINT_DONE); }
/* ARGSUSED */ static void _pgmvcp_elDropEh ( Widget w, XtPointer clnt, XEvent *event, Boolean *ctdr ) /************************************************************************ * _pgmvcp_elDropEh * * * * This function is the callback for a drop on a selected element. * * * * static void _pgmvcp_elDropEh (w, clnt, event, ctdr) * * * * Input parameters: * * w Widget Parent widget * * clnt XtPointer State information record * * *event XEvent Button press event record * * * ** * * Log: * * E. Safford/GSC 06/97 Modified to handle Special Text * * E. Wehner/EAi 07/97 Remove offsets when replacing text. * * E. Safford/GSC 07/97 Fixed drag with special text problem * * E. Wehner/EAi 08/97 Remove watch box slide * * C. Lin/EAI 8/97 Add offsets for 'S' coord(roam) * * D.W.Plummer/NCEP 9/97 Combine into NxmDraw for new vgstruct.h * * E. Wehner/EAi 9/97 Remove graphics info record * * C. Lin/EAi 10/97 rename from NxmDrSlDropCb, cleanup * * C. Lin/EAi 10/97 add WBOX_ELEM related functions * * C. Lin/EAi 11/97 further cleanup * * E. Safford/GSC 02/98 add _storedEl for undo function * * S. Law/GSC 04/98 added copy function * * E. Safford/GSC 04/98 added FUNC_SELECT to FUNC_MOVE ops * * S. Law/GSC 05/98 cleaned up drag, added group box * * E. Safford/GSC 05/98 mod for new undo routines * * E. Safford/GSC 05/98 move to nmap_pgmvcp.c * * E. Safford/GSC 06/98 split from mvcpDrop.c * * G. Krueger/EAI 06/98 Uniform status hints * * E. Safford/GSC 07/98 reset _dcN for closed figures * * C. Lin/EAI 08/98 fix ghosting problem & reset _dragCount * * G. Krueger/EAI 09/98 Added ghost veiling * * G. Krueger/EAI 10/98 Using table for hints * * E. Safford/GSC 12/98 modify refresh to limit area affected * * D.W.Plummer/NCEP 4/99 remove call to pgwlst_update * * E. Safford/GSC 11/00 wipe the county list for watches * * H. Zeng/EAI 11/00 changed for the new undo design * * H. Zeng/EAI 11/00 changed cvg_rdrec() parameters * * A. Hardy/GSC 11/00 renamed coordinate system declaration * * H. Zeng/EAI 12/00 modified for multiple undo steps * * J. Wu/SAIC 12/01 add layer in crg_set() call * * J. Wu/SAIC 01/02 add layer in crg_get() call * * T. Lee/SAIC 11/03 added user directory to work_file * * T. Lee/SAIC 11/03 used cvg_getworkfile * * J. Wu/SAIC 11/03 adjust jet barb/hash position * * J. Wu/SAIC 02/04 adjust gfa attribute box position * * J. Wu/SAIC 07/04 add filter param. to crg_get() * * J. Wu/SAIC 07/04 free GFA block memory * * B. Yin/SAIC 02/05 add a call to snap for GFA * * E. Safford/SAIC 06/05 allow smear to get smaller on edit * * S. Danz/AWC 07/06 Added new cvg_delet placement argument * * S. Danz/AWC 08/06 New flag to pgvgf_saveNewElm to place el* * S. Danz/AWC 08/06 Updated to use cvg_checkplace to find * * area impacted and call crg_rebuild() * * S. Danz/AWC 02/07 Add logic to update GFA centroid * * L. Hinson/AWC 07/09 Add code to update CCF centroid * ***********************************************************************/ { int location, ier, currfunc, new_location, num, layer, el_layer; int found, update_crg, one = 1; float llx, lly, urx, ury; float x_cntr, y_cntr, c_lat, c_lon, area; float o_llx, o_lly, o_urx, o_ury, inf_bbox[4]; char value[32]; VG_DBStruct el, del_el; filter_t filter; /*---------------------------------------------------------------------*/ _dragCount = 0; mcanvw_disarmDrag(); mcanvw_disarmDrop(); if ( _wboxElm ) { pgwpts_setSnap (TRUE); _pgmvcp_wboxCalc ( ); } pggst_clearGhost(TRUE); if (!_midDrag) return; _midDrag = FALSE; update_crg = 0; currfunc = pgpalw_getCurOperId(); pgundo_newStep(); location = pgactv_getElmLoc(); cvg_rdrec(cvg_getworkfile(), location, &el, &ier); crg_getinx (location, &num, &ier); crg_get (num, &el_layer, filter, &o_llx, &o_lly, &o_urx, &o_ury, &ier); pghdlb_deselectEl (location, FALSE); if ((currfunc == FUNC_MOVE) || (currfunc == FUNC_SELECT)) { /* * Mark elements in placement that are effected by * the delete, and get the area of influence back */ cvg_rdrec(cvg_getworkfile(), location, &del_el, &ier); cvg_checkplace(&del_el, 1, location, &found, inf_bbox, &ier); if (found > 0) { /* * Update the refresh extent if the area impacted by * placement was bigger than the area passed in */ o_llx = G_MIN(o_llx, inf_bbox[0]); o_lly = G_MIN(o_lly, inf_bbox[2]); o_urx = G_MAX(o_urx, inf_bbox[1]); o_ury = G_MAX(o_ury, inf_bbox[3]); update_crg = 1; } /* * Free TCA/GFA memory */ if ( del_el.hdr.vg_type == TCA_ELM ) { cvg_freeBkpts ( &del_el ); } else if ( del_el.hdr.vg_type == GFA_ELM ) { cvg_freeElPtr ( &del_el ); } /* * delete old element */ cvg_delet (cvg_getworkfile(), location, TRUE, &ier); crg_clear (num, &ier); pgundo_storeThisLoc(location, UNDO_DEL, &ier); } if ( el.hdr.vg_type == WBOX_ELM ) { pgwbxw_getAnchor ( 0, el.elem.wbx.info.w_a0id, &el.elem.wbx.info.w_a0lt, &el.elem.wbx.info.w_a0ln, &el.elem.wbx.info.w_a0dis, el.elem.wbx.info.w_a0dir, &ier ); pgwbxw_getAnchor ( 1, el.elem.wbx.info.w_a1id, &el.elem.wbx.info.w_a1lt, &el.elem.wbx.info.w_a1ln, &el.elem.wbx.info.w_a1dis, el.elem.wbx.info.w_a1dir, &ier ); /* * Wipe the county list */ el.elem.wbx.info.numcnty = 0; } /* * adjust jet barb/hash position accordingly */ if ( el.hdr.vg_type == JET_ELM ) { _pgmvcp_jetCalc ( &el, 0, 0, False ); } if ( el.hdr.vg_type == SIGCCF_ELM ) { _pgmvcp_ccfCalc ( &el, 0, 0, False ); gtrans ( sys_D, sys_M, &_dcN, _dcX, _dcY, &(el.elem.ccf.latlon[0]), &(el.elem.ccf.latlon[_dcN]), &ier, strlen(sys_D), strlen(sys_M) ); _dcN = el.elem.ccf.info.npts; cvg_todev ( &el, &_dcN, _dcX, _dcY, &ier ); if ( el.hdr.closed ) { cgr_centroid ( _dcX, _dcY, &_dcN, &x_cntr, &y_cntr, &area, &ier ); } else { x_cntr = _dcX[0] ; y_cntr = _dcY[0] ; } gtrans( sys_D, sys_M, &one, &x_cntr, &y_cntr, &c_lat, &c_lon, &ier, strlen(sys_D), strlen(sys_M) ); el.elem.ccf.info.arrowlat = c_lat; el.elem.ccf.info.arrowlon = c_lon; } /* * adjust GFA attribute box position accordingly */ if ( el.hdr.vg_type == GFA_ELM ) { _pgmvcp_gfaCalc ( &el, 0, 0, False ); gtrans ( sys_D, sys_M, &_dcN, _dcX, _dcY, &(el.elem.gfa.latlon[0]), &(el.elem.gfa.latlon[_dcN]), &ier, strlen(sys_D), strlen(sys_M) ); pgsmear_snapEl ( FALSE, &el, &ier ); _dcN = el.elem.gfa.info.npts; cvg_todev( &el, &_dcN, _dcX, _dcY, &ier ); if ( pggfaw_isClosed() ) { cgr_centroid( _dcX, _dcY, &_dcN, &x_cntr, &y_cntr, &area, &ier ); } else { x_cntr = _dcX[ 0 ]; y_cntr = _dcY[ 0 ]; } gtrans( sys_D, sys_M, &one, &x_cntr, &y_cntr, &c_lat, &c_lon, &ier, strlen(sys_D), strlen(sys_M) ); sprintf ( value, "%7.2f", c_lat ); cvg_setFld ( &el, TAG_GFA_ARROW_LAT, value, &ier ); sprintf ( value, "%7.2f", c_lon ); cvg_setFld ( &el, TAG_GFA_ARROW_LON, value, &ier ); } /* * save new element */ pgvgf_saveNewElm(NULL, sys_D, &el, _dcN, _dcX, _dcY, FALSE, &new_location, &ier); pgundo_storeThisLoc (new_location, UNDO_ADD, &ier); pgundo_endStep(); /* * 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 ); } cvg_rdrec(cvg_getworkfile(), new_location, &el, &ier); layer = pglayer_getCurLayer( ); crg_set (&el, new_location, layer, &ier); pgactv_setActvElm (&el, new_location); crg_getinx (new_location, &num, &ier); crg_get(num, &el_layer, filter, &llx, &lly, &urx, &ury, &ier); if (o_llx < llx) llx = o_llx; if (o_lly < lly) lly = o_lly; if (o_urx > urx) urx = o_urx; if (o_ury > ury) ury = o_ury; /* * Mark elements in placement that are effected by * the new element, and get the area of influence back */ cvg_checkplace(&el, 0, new_location, &found, inf_bbox, &ier); if (found > 0) { /* * Update the refresh extent if the area impacted by * placement was bigger than the area passed in */ llx = G_MIN(llx, inf_bbox[0]); lly = G_MIN(lly, inf_bbox[2]); urx = G_MAX(urx, inf_bbox[1]); ury = G_MAX(ury, inf_bbox[3]); update_crg = 1; } xpgpaste (llx, lly, urx, ury, &ier); cvg_rfrsh (NULL, llx, lly, urx, ury, &ier); /* * If we may have impacted other elements with placement * we will need to rebuild the range records */ if (update_crg) { crg_rebuild(); } pghdlb_select (&el, new_location); /* * 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 ); } mbotw_mouseSet(LMHINT_DRAG, MMHINT_DONE); }
static int pgdel_deleteElms ( void ) /************************************************************************ * pgdel_deleteElms * * * * This function deletes all the currently selected elements. * * * * static void pgdel_deleteElms ( ) * * * * Input parameters: * * Output parameters: * * none * * * * Return: * * int number of deleted elements * ** * * Log: * * E. Safford/GSC 04/04 initial coding * * 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 07/06 Added new cvg_delet placement argument * ***********************************************************************/ { int num = 0, ier = 0, found, update_crg; int grpnum = 0, ii = 0, nelm = 0; int curIndex = -1, selIndex = 0, selLoc = 0; int iret = 0, *inxarry = NULL, count = 0; char grptyp = '0'; float llx = 0, lly = 0, urx = 0, ury = 0, inf_bbox[4]; VG_DBStruct el; /*---------------------------------------------------------------------*/ pghdlb_getNextIndex( curIndex, &selIndex, &selLoc, &iret ); update_crg = 0; while ( iret >= 0 ) { /* * If this is the first deletion, start the undo step */ if( count == 0 ) { pgundo_newStep(); } crg_getinx(selLoc, &num, &ier); crg_ggrp (num, &grptyp, &grpnum, &ier); /* * If deleting _by_ group, process the whole group */ if (grptyp && grpnum && (grptyp == GRPTYP_COMSYM || grptyp == GRPTYP_CCF || pgpalw_getMode() == TYPE_GRP)) { crg_ggbnd (grptyp, grpnum, &llx, &urx, &ury, &lly, &ier); llx -= EXTRA; lly -= EXTRA; urx += EXTRA; ury += EXTRA; crg_ggnel(grptyp, grpnum, &nelm, &ier); inxarry = (int *)malloc(nelm*sizeof(int)); crg_gginx(grptyp, grpnum, nelm, inxarry, &nelm, &ier); for ( ii = 0; ii < nelm; ii++ ) { /* * Mark elements in placement that are effected by * the delete, and get the area of influence back */ cvg_rdrec ( cvg_getworkfile(), selLoc, &el, &ier ); cvg_checkplace(&el, 1, selLoc, &found, inf_bbox, &ier); if (found > 0) { /* * Update the refresh extent if the area impacted by placement is bigger */ llx = G_MIN(llx, inf_bbox[0]); lly = G_MIN(lly, inf_bbox[2]); urx = G_MAX(urx, inf_bbox[1]); ury = G_MAX(ury, inf_bbox[3]); update_crg = 1; } /* * Free TCA break point/GFA block memory */ if ( el.hdr.vg_type == TCA_ELM ) { cvg_freeBkpts ( &el ); } else if ( el.hdr.vg_type == GFA_ELM ) { cvg_freeElPtr ( &el ); } crg_goffset(inxarry[ii], &selLoc, &ier); pgundo_storeThisLoc(selLoc, UNDO_DEL, &ier); cvg_delet(cvg_getworkfile(), selLoc, TRUE, &ier); count++; crg_clear (inxarry[ii], &ier); } free(inxarry); xpgpaste(llx, lly, urx, ury, &ier); /* * The deleted elements are deselected here so we won't * try to process them again in the outer while loop. */ pghdlb_deselectEl (num, TRUE); cvg_rfrsh(NULL, llx, lly, urx, ury, &ier); } else { /* non-group mode */ pgutls_prepNew (selLoc, &el, &llx, &lly, &urx, &ury, &ier); pgundo_storeThisLoc(selLoc, UNDO_DEL, &ier); /* * Free TCA break point/GFA block memory */ if ( el.hdr.vg_type == TCA_ELM ) { cvg_freeBkpts ( &el ); } else if ( el.hdr.vg_type == GFA_ELM ) { cvg_freeElPtr ( &el ); } count++; } /* * Check for the next selected element */ curIndex = selIndex; pghdlb_getNextIndex( curIndex, &selIndex, &selLoc, &iret ); } if( count > 0 ) { pgundo_endStep(); pglayer_setChngMade( pglayer_getCurLayer(), TRUE ); pgactv_clearActv(); } /* * If we may have impacted other elements with placement * we will need to rebuild the range records */ if (update_crg) { crg_rebuild(); } return ( count ); }
void pggrpch_chngGrp ( void ) /************************************************************************ * pggrpch_chngGrp * * * * Change the group type of the elements according to instructions on * * VG Group Change Window. * * * * void pggrpch_chngGrp () * * * * Input parameters: * * Output parameters: * * Return: * * NONE * * * ** * * Log: * * H. Zeng/EAI 05/01 initial coding * * J. Wu/SAIC 12/01 add layer in crg_set() call * * J. Wu/SAIC 01/02 change only groups on current layer * * H. Zeng/EAI 03/02 renamed for new nmap_pggrpch file * * H. Zeng/EAI 05/02 modified to use master group type list * * T. Lee/SAIC 11/03 added user directory to work_file * * T. Lee/SAIC 11/03 used cvg_getworkfile * * J. Wu/SAIC 07/04 add filter param to crg_get * * 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 memory * * S. Danz/AWC 07/06 Added new cvg_delet placement argument * * S. Danz/AWC 08/06 New flag to pgvgf_saveNewElm to place el* * S. Danz/AWC 08/06 Updated to use cvg_checkplace to find * * area impacted and call crg_rebuild() * ***********************************************************************/ { int el_num, new_num, el_loc, extra = 5, dest_grpnum; int ori_grpnum, ier2, elN, new_location, ii, selection, iret; int grpid, cur_layer, el_layer, pl_found, update_crg; float llx, lly, urx, ury, m_llx, m_lly, m_urx, m_ury; float *elX, *elY, inf_bbox[4]; char ori_grptyp, dest_grptyp, ori_grpnam[20], dest_grpnam[20]; Boolean found; VG_DBStruct el; struct convertTblStrc *convert_tbl, *ptr, *ptr_prev; filter_t filter; /*---------------------------------------------------------------------*/ m_llx = 999999.0F; m_lly = 999999.0F; m_urx = 0.0F; m_ury = 0.0F; convert_tbl = NULL; ptr = NULL; ptr_prev = NULL; update_crg = 0; pgundo_newStep(); cur_layer = pglayer_getCurLayer( ); for (el_num = 0; el_num < MAX_EDITABLE_ELEMS; el_num++) { crg_goffset (el_num, &el_loc, &ier2); el_layer = crg_getLayer ( el_loc ); /* * Skip cleared range record or those not on current layer. */ if (el_loc == -1 || el_layer != cur_layer) { continue; } crg_ggrp (el_num, &ori_grptyp, &ori_grpnum, &ier2); if (ori_grpnum && ori_grptyp != GRPTYP_OTHERS && ori_grptyp != GRPTYP_COMSYM && ori_grptyp != GRPTYP_WATCH && ori_grptyp != GRPTYP_CCF ) { ces_gtgnam((int)ori_grptyp, ori_grpnam, &ier2); for( ii = 0; ii < _numCurGrp; ii++ ) { if(strcmp(_curGrpStr[ii], ori_grpnam) == 0) { selection = ii + 1; break; } } if(ii < _numCurGrp && _chngToStrc.chng_flag[selection] == TRUE) { strcpy(dest_grpnam, _chngToStr[ _chngToStrc.current[selection]-1 ]); ces_gtgid(dest_grpnam, &grpid, &ier2); dest_grptyp = (char)grpid; /* Search on conversion table to see if there is entry * that has the same ori_grptyp, ori_grpnum and dest_grptyp. * If yes, get dest_grpnum from there. */ found = FALSE; ptr = convert_tbl; while(ptr != NULL) { if(ori_grptyp == ptr->ori_grptyp && dest_grptyp== ptr->dest_grptyp&& ori_grpnum == ptr->ori_grpnum ) { dest_grpnum = ptr->dest_grpnum; found = TRUE; break; } ptr = ptr->next; } /* * If not found on conversion table, get next available * group number. Add new entry into conversion table. */ if(!found) { crg_ggnxt(dest_grptyp, &dest_grpnum, &ier2); if(convert_tbl == NULL) { convert_tbl = (struct convertTblStrc*)malloc( sizeof(struct convertTblStrc) ); convert_tbl->ori_grptyp = ori_grptyp; convert_tbl->dest_grptyp= dest_grptyp; convert_tbl->ori_grpnum = ori_grpnum; convert_tbl->dest_grpnum= dest_grpnum; convert_tbl->next = NULL; convert_tbl->prev = NULL; } else { ptr = convert_tbl; while(ptr->next != NULL) ptr = ptr->next; ptr->next = (struct convertTblStrc*)malloc( sizeof(struct convertTblStrc) ); ptr_prev = ptr; ptr = ptr->next; ptr->ori_grptyp = ori_grptyp; ptr->dest_grptyp= dest_grptyp; ptr->ori_grpnum = ori_grpnum; ptr->dest_grpnum= dest_grpnum; ptr->next = NULL; ptr->prev = ptr_prev; } } /* the end of if(!found... */ cvg_rdrec (cvg_getworkfile(), el_loc, &el, &ier2); /* * Create a copy of the element with new group info, */ pgactv_setActvElm ( &el, el_loc); pgactv_getDevPts (&elN, &elX, &elY); pgvgf_saveNewElm(NULL, sys_D, &el, elN, elX, elY, FALSE, &new_location, &iret); cvg_setginf(cvg_getworkfile(), new_location, dest_grptyp, dest_grpnum, &iret); /* * 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 ); } cvg_rdrec(cvg_getworkfile(), new_location, &el, &iret); crg_set (&el, new_location, cur_layer, &iret); crg_getinx (new_location, &new_num, &iret); crg_get(new_num, &el_layer, filter, &llx, &lly, &urx, &ury, &iret); if (m_llx > llx) m_llx = llx; if (m_lly > lly) m_lly = lly; if (m_urx < urx) m_urx = urx; if (m_ury < ury) m_ury = ury; /* * Mark elements in placement that are effected by * the new element, and get the area of influence back */ cvg_checkplace(&el, 0, new_location, &pl_found, inf_bbox, &iret); if (pl_found > 0) { /* * Update the refresh extent if the area impacted by * placement is bigger */ m_llx = G_MIN(m_llx, inf_bbox[0]); m_lly = G_MIN(m_lly, inf_bbox[2]); m_urx = G_MAX(m_urx, inf_bbox[1]); m_ury = G_MAX(m_ury, inf_bbox[3]); update_crg = 1; } /* * 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 ); } pgundo_storeThisLoc(new_location, UNDO_ADD, &iret); /* * Mark elements in placement that are effected by * the delete, and get the area of influence back */ cvg_rdrec(cvg_getworkfile(), el_loc, &el, &iret); cvg_checkplace(&el, 1, el_loc, &pl_found, inf_bbox, &iret); if (pl_found > 0) { /* * Update the refresh extent if the area impacted by * placement is bigger */ m_llx = G_MIN(m_llx, inf_bbox[0]); m_lly = G_MIN(m_lly, inf_bbox[2]); m_urx = G_MAX(m_urx, inf_bbox[1]); m_ury = G_MAX(m_ury, inf_bbox[3]); update_crg = 1; } /* * 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 ); } /* * Mark the original element as deleted. */ cvg_delet(cvg_getworkfile(), el_loc, TRUE, &ier2); crg_get (el_num, &el_layer, filter, &llx, &lly, &urx, &ury, &ier2); if (m_llx > llx) m_llx = llx; if (m_lly > lly) m_lly = lly; if (m_urx < urx) m_urx = urx; if (m_ury < ury) m_ury = ury; crg_clear(el_num, &ier2); pgundo_storeThisLoc (el_loc, UNDO_DEL, &ier2); } /* the end of if(ii < _numCurGrp ... ) */ } /* the end of if (ori_grpnum &&... */ } /* for (el_num = 0 ... */ pgundo_endStep(); m_llx -= (float)extra; m_lly -= (float)extra; m_urx += (float)extra; m_ury += (float)extra; xpgpaste (m_llx, m_lly, m_urx, m_ury, &ier2); cvg_rfrsh (NULL, m_llx, m_lly, m_urx, m_ury, &ier2); /* * If we may have impacted other elements with placement * we will need to rebuild the range records */ if (update_crg) { crg_rebuild(); } /* * Free conversion table */ if(convert_tbl != NULL) { ptr = convert_tbl; while(ptr->next != NULL) ptr = ptr->next; do { ptr_prev = ptr->prev; free(ptr); ptr = ptr_prev; } while(ptr != NULL); } }