void UIMenuDisplayHelp(char *helpFile) { if (helpFile == (char *) NULL) UIMessage((char *) "Sorry, No Help! You are on your own!"); else { char cmndString[2048]; if (getenv("GHAAS_BROWSER") == NULL) { UIMessage((char *) "You Don't have Web Browser Configured!"); return; } sprintf(cmndString, getenv("GHAAS_BROWSER"), helpFile); system(cmndString); } }
char *UISelectObject (Widget widget,DBObjectLIST<DBObject> *objList,DBInt (*condFunc) (const DBObject *)) { int i = 0; XmString *strings; DBObject *obj; if (objList->ItemNum () < 1) { UIMessage ((char *) "Empty List"); return (NULL); } if ((strings = (XmString *) calloc (objList->ItemNum (),sizeof (XmString))) == NULL) { CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return (NULL); } if (condFunc == (UISelectCondFunc) NULL) condFunc = _UISelectObjectAll; for (obj = objList->First ();obj != NULL;obj = objList->Next ()) if (((obj->Flags () & DBObjectFlagIdle) != DBObjectFlagIdle) && (*condFunc) (obj)) strings [i++] = XmStringCreateSimple (obj->Name ()); _UISelection = NULL; XtVaSetValues (widget,XmNlistItems, strings,XmNlistItemCount, i,NULL); XtManageChild (widget); while (UILoop ()); XtUnmanageChild (widget); for (;i > 0;--i) XmStringFree (strings [i - 1]); free (strings); return (_UISelection); }
/* return movie information */ void MovieInfo(void) { Message message; extern Movie movie; if( !movie ){ return; } sprintf(message, "Movie: dir=%d run=%d delay=%d cache=%d", movie->dir, movie->run, movie->delay, movie->cache); UIMessage(message); }
/* print info about axis */ void AxisInfo(Axis axis) { Message message; if( !axis ){ return; } (void)sprintf(message, "Axis: label%d=%s n%d=%d o%d=%g d%d=%g z%d=%g prec=%d scale=%d", axis->dir ,axis->label ,axis->dir ,axis->size ,axis->dir, axis->first ,axis->dir ,axis->delta ,axis->dir ,axis->zoom, axis->prec ,axis->scale); UIMessage(message); }
/* write color table contents to a file */ void ColorTableDump(void) { extern ColorTable ctable; string filename; FILE *fd; int i; (void)sprintf(filename, "color.table.%d.txt", ctable->size); fd = fopen(filename, "w"); for( i = 0; i < ctable->size; i++ ){ (void)fprintf(fd, "%3d : %5d %5d %5d : %5d %5d %5d\n", i, ctable->red0[i], ctable->green0[i], ctable->blue0[i], ctable->red[i], ctable->green[i], ctable->blue[i]); } (void)fclose(fd); UIMessage("color table dumped to file"); }
void ColorInfo(void) { Message message; extern ColorTable ctable; if( !ctable ){ return; } (void)sprintf(message, "Color: base=%d size=%d color=%s overlay=%s mark=%s back=%s contrast=%d contrast0=%d gpow=%g", ctable->base, ctable->size, ct_names[ctable->color], over_names[ctable->overlay], mark_names[ctable->mark], background_names[ctable->background], ctable->contrast, ctable->contrast0, ctable->gpow); UIMessage(message); }
static void _RGISARCInfoImportFileSelectCBK (Widget widget,Widget coverText,XmAnyCallbackStruct *callData) { static Widget fileSelect = NULL; char *infoFile; if (fileSelect == NULL) fileSelect = UIFileSelectionCreate ((char *) "ARC/Info Coverage",NULL,(char *) "*",XmFILE_DIRECTORY); if ((infoFile = UIFileSelection (fileSelect,true)) != NULL) { if (_RGISARCTempTable != (DBObjTable *) NULL) delete _RGISARCTempTable; _RGISARCTempTable = new DBObjTable ((char *) "ARCImp Temporary Table"); if (DBInfoGetFields (_RGISARCTempTable,DBInfoFileName (infoFile,_RGISARCDataType)) == DBFault) { UIMessage ((char *) "Missing Attribute Table"); delete _RGISARCTempTable; _RGISARCTempTable = ( DBObjTable *) NULL; return; } XmTextFieldSetString (coverText,infoFile); } else { XmTextFieldSetString (coverText,(char *) ""); if (_RGISARCTempTable != NULL) { delete _RGISARCTempTable; _RGISARCTempTable = NULL; } } }
static void _RGISToolsImportASCIITableCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { static Widget fileSelect = (Widget) NULL; DBObjData *data = new DBObjData ("",DBTypeTable); widget = widget; callData = callData; if (fileSelect == NULL) fileSelect = UIFileSelectionCreate ((char *) "ASCII Import",NULL,(char *) "*.*",XmFILE_REGULAR); if (UIDataHeaderForm (data)) { char *fileName; if ((fileName = UIFileSelection (fileSelect,true)) == NULL) { delete data; return; } if (DBImportASCIITable (data->Table (DBrNItems),fileName) == DBFault) { UIMessage ((char *) "Import failed!"); delete data; return; } if (UITableRedefineFields (data->Table (DBrNItems)) != true) { delete data; return; } workspace->CurrentData (data); } else delete data; }
static void _UINoMatchSelectionCallback (Widget widget,void *data,XmSelectionBoxCallbackStruct *callData) { UIMessage ((char *) "Must Select!"); }
void _RGISUserFuncionNetwork (DBObjData *data,UI2DView *view,XEvent *event) { DBInt sX, sY, redraw = false; DBNetworkIF *netIF; DBCoordinate coord; DBObjRecord *cellRec, *basinRec; void _RGISUserFuncionQuery (DBObjData *,UI2DView *,XEvent *); if ((data->Flags () & DBDataFlagUserModeFlags) == DBDataFlagUserModeQuery) { _RGISUserFuncionQuery (data,view,event); return; } if (event->type != ButtonPress) return; if (DBTypeNetwork != data->Type ()) { CMmsgPrint (CMmsgAppError, "Invalid data Type in: %s %d",__FILE__,__LINE__); } sX = event->xbutton.x; sY = event->xbutton.y; view->Window2Map (sX,sY, &coord.X, &coord.Y); netIF = new DBNetworkIF (data); switch (data->Flags () & DBDataFlagUserModeFlags) { case DBDataFlagUserModeSelect: { DBInt basinID, cellID; DBRegion extent; UITable *tableView; if ((cellRec = netIF->Cell (coord)) == (DBObjRecord *) NULL) { UIMessage ((char *) "Cell Does not Exists!"); return; } for (basinID = 0;basinID < netIF->BasinNum ();++basinID) { basinRec = netIF->Basin (basinID); if ((basinRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected) { data->SelectObject (basinRec,DBClear); extent.Expand (data->Extent (basinRec)); } } for (cellID = 0;cellID < netIF->CellNum ();++cellID) { cellRec = netIF->Cell (cellID); if ((cellRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected) { extent.Expand (netIF->Center (cellRec) + (netIF->CellSize () / 2.0)); extent.Expand (netIF->Center (cellRec) - (netIF->CellSize () / 2.0)); cellRec->Flags (DBObjectFlagSelected,DBClear); } } if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNItems)))) != (UITable *) NULL) tableView->Draw (); if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNCells)))) != (UITable *) NULL) tableView->Draw (); UI2DViewRedrawAll (extent); cellRec = netIF->Cell (coord); switch (data->Flags () & DBDataFlagSelectMode) { case DBDataFlagSelectMode: netIF->DownStreamSearch (cellRec, DBNetworkSelect); break; default: netIF->UpStreamSearch (cellRec, DBNetworkSelect); break; } extent.Initialize (); for (cellID = 0;cellID < netIF->CellNum ();++cellID) { cellRec = netIF->Cell (cellID); if ((cellRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected) { extent.Expand (netIF->Center (cellRec) + (netIF->CellSize () / 2.0)); extent.Expand (netIF->Center (cellRec) - (netIF->CellSize () / 2.0)); } } UI2DViewRedrawAll (extent); if ((tableView = (UITable *) data->Display (UITableName (data,data->Table (DBrNCells)))) != (UITable *) NULL) tableView->Draw (); } break; case DBDataFlagUserModeAdd: if (netIF->CellAdd (coord) == (DBObjRecord *) NULL) UIMessage ((char *) "Cell Creation Error"); else redraw = true; break; case DBDataFlagUserModeDelete: if (netIF->CellDelete (coord) == DBFault) UIMessage ((char *) "Cell Does not Exists!"); else redraw = true; break; case DBDataFlagUserModeRotate: { DBObjRecord *cellRec = netIF->Cell (coord); if (cellRec != (DBObjRecord *) NULL) { switch (netIF->CellDirection (cellRec)) { case DBNull: netIF->CellDirection (cellRec,DBNetDirN); break; case DBNetDirNW: netIF->CellDirection (cellRec,DBNull); break; default: netIF->CellRotate (cellRec,DBForward); break; } redraw = true; } } break; default: printf ("Unknown Mode %lX",data->Flags () & DBDataFlagUserModeFlags); break; } if (redraw) { DBPosition pos; if (netIF->Coord2Pos (coord,pos) == DBSuccess) { DBRegion extent; DBCoordinate delta (netIF->CellWidth () * 1.25, netIF->CellHeight () * 1.25); netIF->Pos2Coord (pos,coord); coord = coord + delta; extent.Expand (coord); netIF->Pos2Coord (pos,coord); coord = coord - delta; extent.Expand (coord); UI2DViewRedrawAll (extent); } } delete netIF; }
static void _UIFileSelectionNoMatchCBK(Widget widget, void *dummy, XmFileSelectionBoxCallbackStruct *callData) { UIMessage((char *) "Must Select!"); }
static void _UINotImplementedCBK(Widget widget, char *text, XmAnyCallbackStruct *callData) { UIMessage((char *) "This menu option is not implemented"); }
void RGISEditGridDateLayersCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { static char yearText [DBStringLength]; static DBInt timeStep = DBTimeStepYear; static DBInt proc; DBDataset *dataset = UIDataset (); DBObjData *dbData = dataset->Data (); static Widget dShell = (Widget) NULL; static Widget yearTextF; static Widget menu, button; if (dShell == (Widget) NULL) { Widget mainForm; XmString string; dShell = UIDialogForm ((char *) "Date Layers",false); mainForm = UIDialogFormGetMainForm (dShell); menu = XmCreatePulldownMenu (mainForm,(char *) "RGISEditGridDateLayersTimeStepMenu",NULL,0); string = XmStringCreate ((char *) "Year",UICharSetNormal); button = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &timeStep, NULL); XmStringFree (string); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepYear); string = XmStringCreate ((char *) "Month",UICharSetNormal); button = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &timeStep, NULL); XmStringFree (string); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepMonth); string = XmStringCreate ((char *) "Day",UICharSetNormal); button = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &timeStep, NULL); XmStringFree (string); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepDay); string = XmStringCreate ((char *) "Hour",UICharSetNormal); button = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &timeStep, NULL); XmStringFree (string); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepHour); string = XmStringCreate ((char *) "Minute",UICharSetNormal); button = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &timeStep, NULL); XmStringFree (string); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditGridLayersYearButtonCBK,(XtPointer) DBTimeStepMinute); string = XmStringCreate ((char *) "Time Step:",UICharSetBold); menu = XtVaCreateManagedWidget ("RGISEditGridDateLayersTimeStepMenu",xmRowColumnWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNrowColumnType, XmMENU_OPTION, XmNlabelString, string, XmNsubMenuId, menu, NULL); XmStringFree (string); yearTextF = XtVaCreateManagedWidget ("RGISEditGridDateLayersYearTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, menu, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, menu, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, menu, XmNmaxLength, 4, XmNcolumns, 4, NULL); XtAddCallback (yearTextF,XmNvalueChangedCallback,(XtCallbackProc) _RGISEditGridLayersYearTextCBK,yearText); string = XmStringCreate ((char *) "Begin Year",UICharSetBold); XtVaCreateManagedWidget ("RGISEditGridDateLayersYearLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, menu, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, yearTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, menu, XmNlabelString, string, NULL); XmStringFree (string); XtSetSensitive (UIDialogFormGetOkButton (dShell),true); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&proc); } proc = false; UIDialogFormPopup (dShell); while (UILoop ()) { } UIDialogFormPopdown (dShell); if (proc) { DBInt layerID, year; DBDate stepDate; DBGridIF *gridIF = new DBGridIF (dbData); DBObjRecord *layerRec; DBDate date; switch (timeStep) { case DBTimeStepYear: stepDate.Set (1); break; case DBTimeStepMonth: stepDate.Set (0,1); break; case DBTimeStepDay: stepDate.Set (0,0,1); break; case DBTimeStepHour: stepDate.Set (0,0,0,1); break; case DBTimeStepMinute: stepDate.Set (0,0,0,0,1); break; } if (sscanf (yearText,"%d",&year) != 1) { year = DBDefaultMissingIntVal; if (((stepDate.Year () > 0) && (gridIF->LayerNum () > 1)) || ((stepDate.Month () > 0) && (gridIF->LayerNum () > 12)) || ((stepDate.Day () > 0) && (gridIF->LayerNum () > 365)) || ((stepDate.Hour () > 0) && (gridIF->LayerNum () > 365 * 24)) || ((stepDate.Minute () > 0) && (gridIF->LayerNum () > 365 * 24 * 60))) { UIMessage ((char *) "Too Many Layers in Dataset"); } } UIPauseDialogOpen ((char *) "Labeling Layers"); date.Set (year); if (stepDate.Month () > 0) date.Set (year,0); if (stepDate.Day () > 0) date.Set (year,0,0); if (stepDate.Hour () > 0) date.Set (year,0,0,0); if (stepDate.Minute () > 0) date.Set (year,0,0,0,0); for (layerID = 0;layerID < gridIF->LayerNum ();++layerID) { layerRec = gridIF->Layer (layerID); if (UIPause (layerRec->RowID () * 100 / gridIF->LayerNum ())) goto Stop; gridIF->RenameLayer (layerRec,date.Get ()); date = date + stepDate; } Stop: UIPauseDialogClose (); delete gridIF; } }