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" ); } }
/* ARGSUSED */ static void pgconn_select ( Widget wid, XtPointer clnt, XEvent *event, Boolean *ctdr ) /************************************************************************ * pgconn_select * * * * This function handles the selection callbacks * * * * static void pgconn_select (wid, clnt, event, ctdr ) * * * * Input parameters: * * wid Widget calling widget * * clnt XtPointer * * *event XEvent * * * * Output parameters: * * NONE * * * ** * * Log: * * S. Law/GSC 09/98 Initial coding * * S. Law/GSC 09/98 Removed unnecessary refreshes * * E. Safford/GSC 09/98 fix ghost problem conn to 2 pt lines * * G. Krueger/EAI 10/98 Using table for mouse hints * * S. Law/GSC 09/98 added CLASS_SIGMETS * * S. Law/GSC 09/99 added parameter to mcanvw_set* functions* * E. Safford/GSC 10/99 update for new xwcmn.h * * S. Law/GSC 02/00 added CCF * * S. Law/GSC 03/00 added parameter to pgutls_prepNew * * H. Zeng/EAI 04/00 changed cursor name * * S. Law/GSC 06/00 changed to use xgtoff * * H. Zeng/EAI 11/00 modified for the new undo design * * A. Hardy/GSC 11/00 renamed coordinate system declaration * * H. Zeng/EAI 12/00 modified for multiple undo steps * * J. Wu/GSC 03/01 added "EXIT" hint to bottom panel * * J. Wu/SAIC 01/02 scan the current PGEN layer only * * E. Safford/SAIC 03/02 rename from _pgconn_select, add * * pgutls_regroup(), clean up * * E. Safford/SAIC 04/02 check ier from cvg_scan to avoid UMR * * T. Lee/SAIC 11/03 added user directory to work_file * * T. Lee/SAIC 11/03 used cvg_getworkfile * * S. Danz/AWC 08/06 New flag to pgvgf_saveNewElm to place el* * J. Wu/SAIC 06/07 connect GFAs * ***********************************************************************/ { float xx, yy, llx, lly, urx, ury; float *primary_x, *primary_y; float secondary_x[MAXPTS], secondary_y[MAXPTS]; int primary_n, primary_loc, secondary_n; int ier, near, test, xoff, yoff, cur_layer; int start, grp_num1, grp_num2; char grp_typ1, grp_typ2, warnMsg[256], value[10]; char mesg[] = {"Maximum vertices exceeded."}; Boolean primary_grouped = FALSE; Boolean secondary_grouped = FALSE; static int secondary_elnum; static int secondary_loc; static Boolean reverse_flag = FALSE; static VG_DBStruct secondary_el; static VG_DBStruct GFA_el; int GFA_pts, GFA_newloc; float GFA_x[MAXPTS], GFA_y[MAXPTS]; /*---------------------------------------------------------------------*/ xgtoff (&xoff, &yoff, &ier); cur_layer = pglayer_getCurLayer (); if (event->xbutton.button == Button1) { if (_selectFlag) { /* confirming secondary element */ grp_typ1 = _primaryEl.hdr.grptyp; grp_num1 = _primaryEl.hdr.grpnum; if ( grp_typ1 > 0 && grp_num1 > 0 ) { primary_grouped = TRUE; } cvg_todev (&secondary_el, &secondary_n, secondary_x, secondary_y, &ier); grp_typ2 = secondary_el.hdr.grptyp; grp_num2 = secondary_el.hdr.grpnum; if ( grp_typ2 > 0 && grp_num2 > 0 ) { secondary_grouped = TRUE; } if ( _drawGhost ) { near = pgactv_getNearPt (); pgactv_getDevPts (&primary_n, &primary_x, &primary_y); start = (FindNearEnd (0, near, (primary_n - 1)) == 0) ? 0 : primary_n; if (reverse_flag) { pgutls_fReverseArray (secondary_n, secondary_x, secondary_y); } pgactv_addPts (secondary_x, secondary_y, secondary_n, start, &ier); } if (ier == 0) { if ( _drawGhost ) { pgactv_getDevPts (&primary_n, &primary_x, &primary_y); } /* * Grouping the new element: * * If the primary element was grouped, the new element stays in * that group. If the primary element was not grouped, but the * secondary element was, then put the new element in the * secondary element's group. */ if ( !primary_grouped && secondary_grouped ) { _primaryEl.hdr.grptyp = grp_typ2; _primaryEl.hdr.grpnum = grp_num2; } /* * Save the new element: * * For non-GFAs or open FZLVLs, use points of both the primary * and secondary elements. * * For closed GFAs, use points resulting from smearing the primary * and secondary elements. * * Note: The new GFA element will use the the primary element's * forecast hour, color, and line attributes. */ if ( _drawGhost ) { pgundo_newStep(); pgundo_storeThisLoc ( _primaryLoc, UNDO_DEL, &ier ); pgundo_storeThisLoc ( secondary_loc, UNDO_DEL, &ier ); pgutls_prepNew ( -1, &_primaryEl, &llx, &lly, &urx, &ury, &ier); pgvgf_saveNewElm ( cvg_getworkfile(), sys_D, &_primaryEl, primary_n, primary_x, primary_y, TRUE, &primary_loc, &ier ); pgutls_redraw ( primary_loc, &_primaryEl, &ier ); pgundo_storeThisLoc ( primary_loc, UNDO_ADD, &ier); } else { pgvgf_saveNewElm ( cvg_getworkfile(), sys_M, &GFA_el, 0, GFA_x, GFA_y, TRUE, &GFA_newloc, &ier ); if ( ier >= 0 ) { pgundo_newStep(); pgundo_storeThisLoc ( _primaryLoc, UNDO_DEL, &ier ); pgundo_storeThisLoc ( secondary_loc, UNDO_DEL, &ier ); pgactv_setActvElm ( &_primaryEl, _primaryLoc ); pgutls_prepNew ( _primaryLoc, &_primaryEl, &llx, &lly, &urx, &ury, &ier); pgutls_redraw ( GFA_newloc, &GFA_el, &ier ); pgundo_storeThisLoc ( GFA_newloc, UNDO_ADD, &ier ); } else if ( ier == -28 ) { /* too few points in resulting smear */ cvg_getFld ( &GFA_el, TAG_GFA_TAG, value, &ier ); sprintf( warnMsg, "Unable to connect tag %s.\n It has too few points after smearing and/or snapping.\n", value ); NxmWarn_show( mcanvw_getDrawingW(), warnMsg ); } cvg_freeElPtr ( &GFA_el ); } /* * set the secondary element as the active * one, so that prepNew can remove it */ pgactv_setActvElm (&secondary_el, secondary_loc); pgutls_prepNew (secondary_loc, &secondary_el, &llx, &lly, &urx, &ury, &ier); /* * If both elements were grouped, then move all elements * grouped with the secondary element into the primary * element's group. */ if ( primary_grouped && secondary_grouped ) { pgutls_regroup ( grp_typ2, grp_num2, grp_typ1, grp_num1, &ier ); } pgundo_endStep(); /* * Clean up for next connection. */ if ( _isGFA ) { cvg_freeElPtr ( &secondary_el ); cvg_freeElPtr ( &_primaryEl ); } pghdlb_deselectAll (); pgactv_clearActv (); pggst_clearGhost ( FALSE ); } else { NxmWarn_show (wid, mesg); } mcanvw_setPressFunc ((XtEventHandler)&pgevt_locateElmCb, CURS_DEFAULT); if ( _drawGhost ) mcanvw_disarmDrag (); _selectFlag = FALSE; mbotw_mouseSet(LMHINT_SELECT, MMHINT_EXIT); } else { /* selecting secondary element */ xx = (float) (event->xbutton.x + xoff); yy = (float) (event->xbutton.y + yoff); test = False; cvg_scan (NULL, cur_layer, (char)_primaryEl.hdr.vg_class, xx, yy, 0, &secondary_el, &secondary_loc, &near, &ier); /* * Verify elements only if no error returned from cvg_scan. */ if ( ier >= 0 ) { test = pgconn_verifyType ( &_primaryEl, &secondary_el); } /* * Verify there are actually 2 elements, not the same element. */ if (test) { if (secondary_loc == pgactv_getElmLoc () || secondary_loc == 0) { test = FALSE; } } if ( test ) { crg_getinx ( secondary_loc, &secondary_elnum, &ier ); /* * Get the points for the potential connect/join and use it * to draw the ghost line so the user can have a feel of the * result before making the confirmation. * * For non-GFAs or open FZLVLs, connect points of both the primary * and secondary elements. * * For closed GFAs, get points by smearing the primary and * secondary elements. * */ if ( !_drawGhost ) { /* * Select the second GFA. */ pghdlb_select ( &secondary_el, secondary_loc ); /* * Smear two GFA polygons. */ GFA_pts = 0; GFA_el.elem.gfa.info.nblocks = 0; pgconn_smear ( _primaryLoc, secondary_loc, &GFA_el, &GFA_pts, GFA_x, GFA_y ); /* * Ghost the resulting polygon. */ pggst_clearGhost (TRUE); pggst_setLineAttr ( _primaryEl.hdr.smooth, (Boolean)_primaryEl.hdr.closed ); pggst_addGhostPts ( GFA_pts, GFA_x, GFA_y, &ier ); pggst_drawGhost ( GST_NORMAL ); } else { pggst_drawGhost (GST_NORMAL); mcanvw_disarmDrag (); cvg_todev (&secondary_el, &secondary_n, secondary_x, secondary_y, &ier); if (FindNearEnd (0, near, (secondary_n - 1))) { reverse_flag = TRUE; pgutls_fReverseArray (secondary_n, secondary_x, secondary_y); } else { reverse_flag = FALSE; } pggst_replaceGhostPts (1, &secondary_x[0], &secondary_y[0], &ier); pggst_addGhostPts ((secondary_n - 1), &secondary_x[1], &secondary_y[1], &ier); pggst_drawGhost (GST_NORMAL); } _selectFlag = TRUE; mbotw_mouseSet(LMHINT_CONFIRM, MMHINT_CANCEL); } } } else { if (_selectFlag) { /* unselecting secondary element */ pghdlb_deselectEl ( secondary_elnum, TRUE ); pghdlb_displayAllSel (); if ( _drawGhost ) { xx = (float) (event->xbutton.x + xoff); yy = (float) (event->xbutton.y + yoff); _ghostX[_ghostN] = xx; _ghostY[_ghostN] = yy; pggst_clearGhost (FALSE); pggst_addGhostPts ((_ghostN + 1), _ghostX, _ghostY, &ier); pggst_drawGhost (GST_NORMAL); } _selectFlag = FALSE; mbotw_mouseSet(LMHINT_NEXT, MMHINT_DONE); if ( _drawGhost ) { mcanvw_setDragFunc((XtEventHandler)&pgconn_ghost, CURS_DEFAULT); } if ( _isGFA ) { cvg_freeElPtr ( &secondary_el ); if ( !_drawGhost ) cvg_freeElPtr ( &GFA_el ); } } else { /* unselecting primary element */ if ( _isGFA ) { cvg_freeElPtr ( &_primaryEl ); } mcanvw_disarmDynamic (); _selectFlag = FALSE; pghdlb_deselectAll(); mcanvw_setPressFunc ((XtEventHandler)&pgevt_locateElmCb, CURS_DEFAULT); _selectFlag = FALSE; mbotw_mouseSet(LMHINT_SELECT, MMHINT_EXIT); } } }