/* ARGSUSED */ static void pgasel_irregStartEh ( Widget w, XtPointer clnt, XEvent *event, Boolean *ctdr ) /************************************************************************ * pgasel_irregStartEh * * * * Internal callback of button press for irregular area selection * * * * static void pgasel_irregStartiEh ( w, clnt, event, ctdr ) * * * * Input parameters: * * w Widget Widget that activated callback * * clnt XtPointer Pointer to client data * * *event XEvent Event that triggered callback * * * ** * * Log: * * J. Wu/SAIC 04/04 copy from pgdsel_irregStart * ***********************************************************************/ { int ier, xoff, yoff; float xx, yy; char mesg[] = {"Maximum points exceeded."}; /*---------------------------------------------------------------------*/ /* * Make sure event is triggered from left button. */ if ( event->xbutton.button == Button1 ) { xgtoff ( &xoff, &yoff, &ier ); xx = (float) (event->xbutton.x + xoff); yy = (float) (event->xbutton.y + yoff); if ( _irregPt + 2 >= _maxAllowPts ) { NxmWarn_show ( w, mesg ); mbotw_mouseSet ( LMHINT_ERROR, MMHINT_DONE ); } else { _irregPt++; _xPtsBuf[_irregPt +1] = _xPtsBuf[_irregPt] = xx; _yPtsBuf[_irregPt +1] = _yPtsBuf[_irregPt] = yy; pggst_drawGhost ( GST_NEW_LINE ); pggst_replaceGhostPts ( 1, &xx, &yy, &ier ); pggst_addGhostPts ( 1, &xx, &yy, &ier ); pggst_drawGhost ( GST_NEW_LINE ); } } }
void wnxm_NxmWarn_show( Widget parent, char *message ) /************************************************************************ * wnxm_NxmWarn_show * * * * void wnxm_NxmWarn_show ( parent, message ) * * * * Input parameters: * * parent Widget The top level widget * * *message char Warning message to be displayed * * * * Output parameters: * * Return: * * NONE * ** * * Log: * * E. Safford/SAIC 11/07 initial coding * ***********************************************************************/ { NxmWarn_show( parent, message ); }
/* ARGSUSED */ static void pglpfw_browseDoneCb ( Widget wid, XtPointer clnt, XtPointer cbs ) /************************************************************************ * pglpfw_browseDoneCb * * * * This is an internal callback function for the browse buttons, * * Ok and Cancel. * * * * void pglpfw_browseDoneCb (wid, clnt, cbs) * * * * Input parameters: * * wid Widget Widget that activated callback * * clnt XtPointer Pointer to client data (GrInfo) * * cbs XtPointer Callback struct * * * ** * * Log: * * T. Lee/SAIC 04/02 * * E. Safford/SAIC 04/02 use cfl_isdir instead of local version * ***********************************************************************/ { int which, ier; char *text; char filepart[MXFLSZ] = "\0" , pathpart[LLPATH] = "\0"; Widget popup; FSBCBS *fcbs; /*---------------------------------------------------------------------*/ which = (long)clnt; if (which == 1) { /* OK */ fcbs = (FSBCBS *) cbs; XmStringGetLtoR (fcbs->value, XmFONTLIST_DEFAULT_TAG, &text); if ( cfl_isdir ( text ) ) { _fileName[0] = '\0'; strcpy ( _dirPath, text ); } else { cfl_path ( text, pathpart, filepart, &ier ) ; if ( filepart[0] != '\0' ) { strcpy ( _fileName, filepart ); } if ( pathpart[0] != '\0' ) { strcpy ( _dirPath, pathpart ); } } if ( _dirPath[ ( strlen(_dirPath) - 1 ) ] != '/' ) { strcat ( _dirPath, "/" ); } XtFree (text); if ( _fileName[0] == '\0' ) { popup = (XtIsManaged (_browsePopup)) ? _browsePopup : _fileSelW; NxmWarn_show (popup, "Not a valid file."); } else { pglpfw_openCtlBtnCb ( NULL, 0, NULL ); } } else { /* CANDEL */ XtUnmanageChild (_browsePopup); } }
/* 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); } } }
int get_group ( Widget widget ) /************************************************************************ * * * This subroutione gets the frame selection for the * * specified group. * * * * GET_GROUP ( WIDGET ) * * * * Input parameters: * * WIDGET Widget parent widget * ** * * Log: * * T. Piper/SAIC 10/04 Changed MAX_PIXMAP to MAX_FRAME_GROUP * ***********************************************************************/ { int framecnt, ii, status; XmStringTable selectedframes; char text[40], message[256]; /*---------------------------------------------------------------------*/ get_text(group_nameW, &text[0]); if ( *text ) { strcpy( GroupList[GroupNo].groupname,text ); XtVaGetValues(gframe_listW, XmNselectedItemCount, &framecnt, XmNselectedItems, &selectedframes, NULL); if ( framecnt == 0 ) { NxmWarn_show( widget, "Please Select Frames." ); status = 0; } else { if ( framecnt > MAX_FRAME_GROUP ) { sprintf(message, "The number of frames in this group exceeds the limit of %d.", MAX_FRAME_GROUP); NxmWarn_show( widget, message ); status = 0; } else { GroupList[GroupNo].frame_num = framecnt; for ( ii = 0; ii < framecnt; ii++ ) { GroupList[GroupNo].frames[ii] = XmListItemPos(gframe_listW, selectedframes[ii]); } GroupNo ++; status = 1; add_grouplist(); } } } /* end of if */ else { status = 0; NxmWarn_show( widget, "Please Input the Group Name."); } return (status); }