static void _pgmvcp_gfaCalc ( VG_DBStruct *el, float dx, float dy, Boolean grp ) /************************************************************************ * _pgmvcp_gfaCalc * * * * Internal function for MOVE/COPY GFA's atribute box location. * * * * static void _pgmvcp_gfaCalc () * * *el VG_DBStruct Pointer to gfa element * * dx float Increment on X axis * * dy float Increment on Y axis * * grp Boolean Group mode or not * * * * Input parameters: * * * ** * * Log: * * J. Wu/SAIC 02/04 initial coding * * J. Wu/SAIC 10/04 Access GFA attr with cvg_getFld() * ***********************************************************************/ { int np, ier; float delx, dely, xx, yy, nlat, nlon; char value[32]; /*---------------------------------------------------------------------*/ /* * For group drag/drop, use the given dx, dy as the "delta" increment. */ delx = dx; dely = dy; /* * For single element drag/drop, recalculate the "delta" increment. */ if ( !grp && _dcN > 0 ) { delx = *(_dcX + _nearPt) - _origX; dely = *(_dcY + _nearPt) - _origY; } /* * Adjust attribute text box location. */ np = 1; cvg_getFld ( el, TAG_GFA_LAT, value, &ier ); nlat = atof ( value ); cvg_getFld ( el, TAG_GFA_LON, value, &ier ); nlon = atof ( value ); gtrans ( sys_M, sys_D, &np, &nlat, &nlon, &xx, &yy, &ier, strlen(sys_M), strlen(sys_D) ); xx += delx; yy += dely; gtrans ( sys_D, sys_M, &np, &xx, &yy, &nlat,&nlon, &ier, strlen(sys_D), strlen(sys_M) ); sprintf ( value, "%7.2f", nlat ); cvg_setFld ( el, TAG_GFA_LAT, value, &ier ); sprintf ( value, "%7.2f", nlon ); cvg_setFld ( el, TAG_GFA_LON, value, &ier ); }
void recalcGFAtLblArwLoc(VG_DBStruct *el) /*********************************************************************** * recalcGFAtLblArwLoc * * * * This routine recomputes a location for the text box and associated * * arrow to be positioned at the eastern most vertex of a polygon * * Its purpose, in the context of this module, was to correct * * problems with a dangling text label arrow, that may be a result of * * a clipping operation on a polygon that's intersected the boundary * * * * Input/Output parameter: * * *el VG_DBStruct Pointer to VG record structure * * * * * ** * * Log: * * L. Hinson/AWC 07/07 Created * **********************************************************************/ { int i, npts, ier; float ernlon=-999.0; float ernlat=0.0; char slat[20], slon[20]; npts = el->elem.gfa.info.npts; for (i = 0; i < npts; i++) if (el->elem.gfa.latlon[i+npts] > ernlon) { ernlon=el->elem.gfa.latlon[i+npts]; ernlat=el->elem.gfa.latlon[i]; } ; sprintf(slat, " %5.2f", ernlat); sprintf(slon, " %5.2f", ernlon); cvg_setFld (el, TAG_GFA_LAT, slat, &ier); cvg_setFld (el, TAG_GFA_LON, slon, &ier); cvg_setFld (el, TAG_GFA_ARROW_LAT, slat, &ier); cvg_setFld (el, TAG_GFA_ARROW_LON, slon, &ier); }
void ces_get ( int subtyp, VG_DBStruct *el, int *iret ) /************************************************************************ * ces_get * * * * This function gets settings for a type of element into the header * * of the passed in element. The passed in element is also queried to * * determine what type of element to retrieve settings for. * * * * ces_get ( subtyp, el, iret ) * * * * Input parameters: * * subtyp int Element subtype * * * * Input/Output parameters: * * *el VG_DBStruct Element as mask and returned * * * * Output parameters: * * *iret int Return code * * -2 = Unable to get settings * ** * * Log: * * E. Wehner/EAi 8/97 Created * * C. Lin/EAi 10/97 Add WBOX_ELM * * M. Linda/GSC 10/97 Corrected the prologue format * * C. Lin/EAi 11/97 use CLASS_WATCHES for WBOX_ELM * * C. Lin/EAi 11/97 add front strenth, wind line width * * S. Law/GSC 03/98 loads size and hdsiz for CLASS_WINDS * * F.J. Yen/NCEP 4/98 Rename from ces_elset.Clean up. Add text* * F.J. Yen/NCEP 4/98 Set hsiz for BARB_ELM * * W. Li/EAI 04/98 Add DARR and HASH in CLASS_WIND * * W. Li/EAI 07/98 Added txt_attrib's text value setting * * C. Lin/EAI 09/98 Added smoothing level hdr.unused1 * * A. Hardy/GSC 12/98 Added CLASS_CIRCLE * * W. Li/EAI 03/99 Added latitude/longitude for symbols * * S. Law/GSC 03/99 added filled and closed * * S. Law/GSC 05/99 Added CLASS_TRACKS * * S. Law/GSC 07/99 Added CLASS_SIGMETS * * S. Law/GSC 08/99 updated element * * S. Law/GSC 02/00 added CFF catch to SIGMETS * * J. Wu/GSC 02/01 Modified 'unused1' in VG to 'smooth' * * H. Zeng/EAI 02/01 added group type info. * * H. Zeng/EAI 03/01 modified to allow invalid group name * * J. Wu/SAIC 11/02 add class LIST * * H. Zeng/XTRIA 01/03 added marker info. for Watch * * H. Zeng/XTRIA 03/03 special handling for grp_typ * * H. Zeng/XTRIA 07/03 added VOLC_ELM and ASHCLD_ELM * * J. Wu/SAIC 09/03 add CLASS_MET -> JET_ELM * * J. Wu/SAIC 01/04 add CLASS_MET -> GFA_ELM * * B. Yin/SAIC 02/04 added CLASS_MET -> TCA_ELM * * J. Wu/SAIC 10/04 remove line width from GFA_ELM * * T. Piper/SAIC 12/05 redone for NEW Setting_t structure * * B. Yin/SAIC 12/05 add line width for GFA * * B. Yin/SAIC 07/06 add line type and line element for GFA * * L. Hinson/AWC 12/06 add text color, size, font, hw, width, * * alignment for GFA * * L. Hinson/AWC 06/07 add arrow size for GFA * * L. Hinson/AWC 07/09 add fills, linetype, szarrow, text size * * font, hw, width, alignment, and text * * Layout to CCF * * L. Hinson/AWC 01/12 Add CLASS_MET -> SGWX_ELM * ***********************************************************************/ { char logstr[10], grp[4], grp_typ[25], *ptr, widthStr[8]; char lineType[ 8 ], lineElm[ 8 ]; int ier1, ier2, ii, indx, loglev, grpid; char arrowSize[6]; char txtColr[2], txtFont[2], txtHw[2], txtWidth[2]; char txtAlign[2], txtSize[6]; /*---------------------------------------------------------------------*/ *iret = G_NORMAL; /* * Retrieve the index to this type of element in the settings * array by making a call to ces_getinx. */ ces_getinx(el, subtyp, &indx, iret); if (*iret == -2) { loglev = 2; strcpy(grp, "CES"); sprintf(logstr, "%i", subtyp); er_lmsg ( &loglev, grp, iret, logstr, &ier1, strlen(grp), strlen(logstr) ); return; } /* * Using the index, retrieve the settings for the element from * the settings array. Key off the vg_type field in the VG * element. */ el->hdr.maj_col = set[indx].maj_col; el->hdr.min_col = set[indx].min_col; el->hdr.smooth = 0; strcpy ( grp_typ, set[indx].grp_typ ); ptr = strtok ( grp_typ, "/" ); ces_gtgid( ptr, &grpid, &ier2 ); if( ier2 == 0 ) { el->hdr.grptyp = (char)grpid; } else { el->hdr.grptyp = NON_GRPID; } switch (el->hdr.vg_class) { case CLASS_FRONTS: /* FRONT_ELM */ el->elem.frt.info.fcode = set[indx].subtyp; el->elem.frt.info.fpipsz = set[indx].info.frt->fpipsz; el->elem.frt.info.fpipst = set[indx].info.frt->fpipst; el->elem.frt.info.fpipdr = set[indx].info.frt->fpipdr; el->elem.frt.info.fwidth = set[indx].info.frt->fwidth; el->hdr.smooth = set[indx].smooth; break; case CLASS_WATCHES: /* WBOX_ELM */ el->elem.wbx.info.w_type = set[indx].info.wbx->w_type; el->elem.wbx.info.w_number = set[indx].info.wbx->w_number; el->elem.wbx.info.w_mrktyp = set[indx].info.wbx->w_mrktyp; el->elem.wbx.info.w_mrksiz = set[indx].info.wbx->w_mrksiz; el->elem.wbx.info.w_mrkwid = set[indx].info.wbx->w_mrkwid; break; case CLASS_CIRCLE: /* CIRCLE_ELM */ el->elem.cir.info.lintyp = set[indx].info.cir->lintyp; el->elem.cir.info.lthw = set[indx].info.cir->lthw; el->elem.cir.info.width = set[indx].info.cir->width; el->elem.cir.info.lwhw = set[indx].info.cir->lwhw; break; case CLASS_LINES: switch (el->hdr.vg_type) { case LINE_ELM: el->elem.lin.info.lintyp = set[indx].info.lin->lintyp; el->elem.lin.info.lthw = set[indx].info.lin->lthw; el->elem.lin.info.width = set[indx].info.lin->width; el->elem.lin.info.lwhw = set[indx].info.lin->lwhw; el->hdr.smooth = set[indx].smooth; el->hdr.filled = set[indx].filled; el->hdr.closed = set[indx].closed; break; case SPLN_ELM: el->elem.spl.info.spltyp = set[indx].info.spl->spltyp; el->elem.spl.info.splstr = set[indx].info.spl->splstr; el->elem.spl.info.spldir = set[indx].info.spl->spldir; el->elem.spl.info.splsiz = set[indx].info.spl->splsiz; el->elem.spl.info.splwid = set[indx].info.spl->splwid; el->hdr.smooth = set[indx].smooth; el->hdr.filled = set[indx].filled; el->hdr.closed = set[indx].closed; break; default: *iret = -2; break; } break; case CLASS_SYMBOLS: el->elem.sym.info.width = set[indx].info.sym->info.width; el->elem.sym.info.size = set[indx].info.sym->info.size; el->elem.sym.data.latlon[0] = set[indx].info.sym->data.latlon[0]; el->elem.sym.data.latlon[1] = set[indx].info.sym->data.latlon[1]; break; case CLASS_WINDS: switch (el->hdr.vg_type) { case ARROW_ELM: /* WIND ARROWS */ case BARB_ELM: /* WIND BARBS */ case DARR_ELM: /* DIRECTION */ case HASH_ELM: /* HASH MAKE */ el->elem.wnd.info.wndtyp = set[indx].info.wnd->wndtyp; el->elem.wnd.info.width = set[indx].info.wnd->width; el->elem.wnd.info.size = set[indx].info.wnd->size; el->elem.wnd.info.hdsiz = set[indx].info.wnd->hdsiz; break; default: *iret = -2; break; } break; case CLASS_TEXT: switch (el->hdr.vg_type) { case TEXT_ELM: case TEXTC_ELM: el->elem.txt.info.rotn = set[indx].info.txt->info.rotn; el->elem.txt.info.sztext = set[indx].info.txt->info.sztext; el->elem.txt.info.itxfn = set[indx].info.txt->info.itxfn; el->elem.txt.info.ithw = set[indx].info.txt->info.ithw; el->elem.txt.info.iwidth = set[indx].info.txt->info.iwidth; el->elem.txt.info.ialign = set[indx].info.txt->info.ialign; strcpy(el->elem.txt.text, set[indx].info.txt->text); break; case SPTX_ELM: el->elem.spt.info.rotn = set[indx].info.spt->text.info.rotn; el->elem.spt.info.sztext = set[indx].info.spt->text.info.sztext; el->elem.spt.info.sptxtyp = set[indx].info.spt->text.info.sptxtyp; el->elem.spt.info.turbsym = set[indx].info.spt->text.info.turbsym; el->elem.spt.info.itxfn = set[indx].info.spt->text.info.itxfn; el->elem.spt.info.ithw = set[indx].info.spt->text.info.ithw; el->elem.spt.info.iwidth = set[indx].info.spt->text.info.iwidth; el->elem.spt.info.ialign = set[indx].info.spt->text.info.ialign; strcpy(el->elem.spt.text, set[indx].info.spt->text.text); break; default: *iret = -2; break; } break; case CLASS_TRACKS: el->elem.trk.info.ltype1 = set[indx].info.trk->ltype1; el->elem.trk.info.ltype2 = set[indx].info.trk->ltype2; el->elem.trk.info.mtype1 = set[indx].info.trk->mtype1; el->elem.trk.info.mtype2 = set[indx].info.trk->mtype2; el->elem.trk.info.width = set[indx].info.trk->width; el->elem.trk.info.incr = set[indx].info.trk->incr; break; case CLASS_SIGMETS: if (el->hdr.vg_type == VOLC_ELM) { el->elem.vol.info.width = set[indx].info.vol->width; el->elem.vol.info.size = set[indx].info.vol->size; } else if (el->hdr.vg_type != SIGCCF_ELM && el->hdr.vg_type != ASHCLD_ELM ) { el->elem.sig.info.lintyp = set[indx].info.sig->lintyp; el->elem.sig.info.linwid = set[indx].info.sig->linwid; el->elem.sig.info.status = 0; el->elem.sig.info.seqnum = 0; strcpy (el->elem.sig.info.remarks, ""); } else if (el->hdr.vg_type == SIGCCF_ELM) { el->elem.ccf.info.fillhi = set[indx].info.ccf->fillhi; el->elem.ccf.info.fillmed = set[indx].info.ccf->fillmed; el->elem.ccf.info.filllow = set[indx].info.ccf->filllow; el->elem.ccf.info.linetype = set[indx].info.ccf->linetype; el->elem.ccf.info.szarrow = set[indx].info.ccf->szarrow; el->elem.ccf.spt.info.sztext = set[indx].info.ccf->info.sztext; el->elem.ccf.spt.info.itxfn = set[indx].info.ccf->info.itxfn; el->elem.ccf.spt.info.ithw = set[indx].info.ccf->info.ithw; el->elem.ccf.spt.info.iwidth = set[indx].info.ccf->info.iwidth; el->elem.ccf.spt.info.ialign = set[indx].info.ccf->info.ialign; strcpy(el->elem.ccf.textLayout, set[indx].info.ccf->textLayout); } break; case CLASS_LIST: el->elem.lst.info.subtyp = set[indx].info.lst->subtyp; el->elem.lst.info.mrktyp = set[indx].info.lst->mrktyp; el->elem.lst.info.mrksiz = set[indx].info.lst->mrksiz; el->elem.lst.info.mrkwid = set[indx].info.lst->mrkwid; break; case CLASS_MET: switch (el->hdr.vg_type) { case JET_ELM: for ( ii = 0; ii < MAX_JETPTS; ii++ ) { el->elem.jet.barb[ii].wndcol = set[indx].info.jet->barb[ii].wndcol; el->elem.jet.barb[ii].wnd.info.size = set[indx].info.jet->barb[ii].wnd.info.size; el->elem.jet.barb[ii].wnd.info.width = set[indx].info.jet->barb[ii].wnd.info.width; el->elem.jet.barb[ii].wnd.info.wndtyp = set[indx].info.jet->barb[ii].wnd.info.wndtyp; el->elem.jet.barb[ii].wnd.info.hdsiz = set[indx].info.jet->barb[ii].wnd.info.hdsiz; el->elem.jet.barb[ii].sptcol = set[indx].info.jet->barb[ii].sptcol; el->elem.jet.barb[ii].spt.info.sztext = set[indx].info.jet->barb[ii].spt.info.sztext; el->elem.jet.barb[ii].spt.info.itxfn = set[indx].info.jet->barb[ii].spt.info.itxfn; el->elem.jet.barb[ii].spt.info.ithw = set[indx].info.jet->barb[ii].spt.info.ithw; el->elem.jet.barb[ii].spt.info.iwidth = set[indx].info.jet->barb[ii].spt.info.iwidth; el->elem.jet.barb[ii].spt.info.ialign = set[indx].info.jet->barb[ii].spt.info.ialign; el->elem.jet.barb[ii].spt.info.rotn = set[indx].info.jet->barb[ii].spt.info.rotn; el->elem.jet.barb[ii].spt.info.sptxtyp = set[indx].info.jet->barb[ii].spt.info.sptxtyp; el->elem.jet.barb[ii].spt.info.turbsym = set[indx].info.jet->barb[ii].spt.info.turbsym; el->elem.jet.barb[ii].spt.info.txtcol = set[indx].info.jet->barb[ii].spt.info.txtcol; el->elem.jet.barb[ii].spt.info.filcol = set[indx].info.jet->barb[ii].spt.info.filcol; el->elem.jet.barb[ii].spt.info.lincol = set[indx].info.jet->barb[ii].spt.info.lincol; strcpy(el->elem.jet.barb[ii].spt.text, set[indx].info.jet->barb[ii].spt.text); el->elem.jet.hash[ii].wndcol = set[indx].info.jet->hash[ii].wndcol; el->elem.jet.hash[ii].wnd.info.size = set[indx].info.jet->hash[ii].wnd.info.size; el->elem.jet.hash[ii].wnd.info.width = set[indx].info.jet->hash[ii].wnd.info.width; el->elem.jet.hash[ii].wnd.info.wndtyp = set[indx].info.jet->hash[ii].wnd.info.wndtyp; el->elem.jet.hash[ii].wnd.info.hdsiz = set[indx].info.jet->hash[ii].wnd.info.hdsiz; } el->hdr.smooth = set[indx].smooth; el->hdr.filled = set[indx].filled; el->hdr.closed = set[indx].closed; el->elem.jet.line.splcol = set[indx].info.jet->splcol; el->elem.jet.line.spl.info.spltyp = set[indx].info.jet->line.spltyp; el->elem.jet.line.spl.info.splsiz = set[indx].info.jet->line.splsiz; el->elem.jet.line.spl.info.splwid = set[indx].info.jet->line.splwid; el->elem.jet.line.spl.info.splstr = set[indx].info.jet->line.splstr; el->elem.jet.line.spl.info.spldir = set[indx].info.jet->line.spldir; break; case GFA_ELM: sprintf ( widthStr, "%d", set[indx].info.gfa->linwid ); cvg_setFld ( el, TAG_GFA_LINEWIDTH, widthStr, &ier1 ); sprintf ( lineElm, "%d", set[indx].info.gfa->linelm ); cvg_setFld ( el, TAG_GFA_LINELM, lineElm, &ier1 ); sprintf ( lineType, "%d", set[indx].info.gfa->lintyp ); cvg_setFld ( el, TAG_GFA_LINTYP, lineType, &ier1 ); sprintf ( arrowSize, "%4.2f", set[indx].info.gfa->szarrow ); cvg_setFld ( el, TAG_GFA_ARROWSZ, arrowSize, &ier1 ); sprintf ( txtColr, "%d", set[indx].info.gfa->info.txtcol ); cvg_setFld ( el, TAG_GFA_TXTCLR, txtColr, &ier1 ); sprintf ( txtSize, "%4.2f", set[indx].info.gfa->info.sztext ); cvg_setFld ( el, TAG_GFA_TXTSZ, txtSize, &ier1 ); sprintf ( txtFont, "%d", set[indx].info.gfa->info.itxfn ); cvg_setFld ( el, TAG_GFA_TXTFN, txtFont, &ier1 ); sprintf ( txtHw, "%d", set[indx].info.gfa->info.ithw); cvg_setFld ( el, TAG_GFA_TXTHW, txtHw, &ier1 ); sprintf ( txtWidth, "%d", set[indx].info.gfa->info.iwidth); cvg_setFld ( el, TAG_GFA_TXTWDTH, txtWidth, &ier1 ); sprintf ( txtAlign, "%d", set[indx].info.gfa->info.ialign); cvg_setFld ( el, TAG_GFA_TXTALGN, txtAlign, &ier1 ); cvg_setFld ( el, TAG_GFA_TXTLYT, set[indx].info.gfa->textLayout, &ier1 ); break; case SGWX_ELM: el->elem.sgwx.info.lineelm = set[indx].info.sgwx->lineelm; el->elem.sgwx.info.linetype = set[indx].info.sgwx->linetype; el->elem.sgwx.info.linewidth = set[indx].info.sgwx->linewidth; el->elem.sgwx.info.szarrow = set[indx].info.sgwx->szarrow; el->elem.sgwx.spt.info.sztext = set[indx].info.sgwx->info.sztext; el->elem.sgwx.spt.info.itxfn = set[indx].info.sgwx->info.itxfn; el->elem.sgwx.spt.info.ithw = set[indx].info.sgwx->info.ithw; el->elem.sgwx.spt.info.iwidth = set[indx].info.sgwx->info.iwidth; el->elem.sgwx.spt.info.ialign = set[indx].info.sgwx->info.ialign; el->elem.sgwx.spt.info.filcol = 0; el->elem.sgwx.spt.info.txtcol = set[indx].maj_col; el->hdr.smooth = 1; el->hdr.closed = 1; break; case TCA_ELM: break; default: *iret = -2; break; } /* End of 'switch (el->hdr.vg_type)' */ break; default: *iret = -2; break; } /* End of 'switch (el->hdr.vg_class)' */ if (*iret !=0) { loglev = 2; strcpy(grp, "CES"); sprintf(logstr, "%i", subtyp); er_lmsg ( &loglev, grp, iret, logstr, &ier1, strlen(grp), strlen(logstr) ); } }
/* 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 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; }