void RGISAnalysePointSTNCharCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *dbData = dataset->Data (); DBObjTable *pointTable = dbData->Table (DBrNItems); DBObjTableField *cellIDFLD = pointTable->Field (RGlibCellID); DBObjTableField *basinFLD = pointTable->Field (DBrNBasin); DBObjTableField *basinNameFLD = pointTable->Field (RGlibBasinName); DBObjTableField *orderFLD = pointTable->Field (DBrNOrder); DBObjTableField *colorFLD = pointTable->Field (RGlibColor); DBObjTableField *basinCellsFLD = pointTable->Field (RGlibCellNum); DBObjTableField *basinLengthFLD = pointTable->Field (RGlibLength); DBObjTableField *basinAreaFLD = pointTable->Field (RGlibArea); DBObjTableField *interAreaFLD = pointTable->Field (RGlibInterStation); DBObjTableField *nextStationFLD = pointTable->Field (RGlibNextStation); UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,pointTable)); UIPauseDialogOpen ((char *) "STN Characteristics"); if ((RGlibPointSTNCharacteristics (dbData) == DBSuccess) && (tableCLS != (UITable *) NULL)) { if (cellIDFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibCellID)); if (basinFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (DBrNBasin)); if (basinNameFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibBasinName)); if (orderFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (DBrNOrder)); if (colorFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibColor)); if (basinCellsFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibCellNum)); if (basinLengthFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibLength)); if (basinAreaFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibArea)); if (interAreaFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibInterStation)); if (nextStationFLD == (DBObjTableField *) NULL) tableCLS->AddField (pointTable->Field (RGlibNextStation)); tableCLS->Draw (); } UIPauseDialogClose (); }
void RGISAnNetworkCellSlopesCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *inGridData, *outGridData; widget = widget; callData = callData; if ((inGridData = netData->LinkedData ()) == (DBObjData *) NULL) { CMmsgPrint (CMmsgAppError,"Null Linked Data in: %s %d",__FILE__,__LINE__); return; } outGridData = DBNetworkToGrid (netData,DBTypeGridContinuous); outGridData->Document (DBDocGeoDomain,inGridData->Document (DBDocGeoDomain)); outGridData->Document (DBDocSubject,"Slope"); if (UIDataHeaderForm (outGridData)) { UIPauseDialogOpen ((char *) "Calculating Slopes"); if (RGlibNetworkCellSlopes (netData,inGridData,outGridData) == DBSuccess) workspace->CurrentData (outGridData); else delete outGridData; UIPauseDialogClose (); } else delete outGridData; }
void RGISAnNetworkBasinProfCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *gridData, *tblData; widget = widget; callData = callData; if ((gridData = netData->LinkedData ()) == (DBObjData *) NULL) { CMmsgPrint (CMmsgAppError, "Null Linked Data in: %s %d",__FILE__,__LINE__); return; } tblData = new DBObjData ("",DBTypeTable); tblData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); tblData->Document (DBDocSubject,"Basin Profiles"); if (UIDataHeaderForm (tblData)) { UIPauseDialogOpen ((char *) "Creating Basin Profiles"); if (RGlibNetworkBasinProf (netData,gridData,tblData) == DBSuccess) workspace->CurrentData (tblData); else delete tblData; UIPauseDialogClose (); } else delete tblData; }
void RGISAnalysePointSubbasinHistCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *selection; DBDataset *dataset = UIDataset (); DBObjData *pntData = dataset->Data (); DBObjData *grdData = pntData->LinkedData (); DBObjData *netData; DBObjData *tblData; static Widget selectWidget = (Widget) NULL; if (selectWidget == (Widget) NULL) selectWidget = UISelectionCreate ((char *) "Select Network"); if ((selection = UISelectObject (selectWidget,(DBObjectLIST<DBObject> *) dataset->DataList (),_RGISAnalyseTestNetwork)) == (char *) NULL) return; if ((netData = dataset->Data (selection)) == (DBObjData *) NULL) { return; } tblData = new DBObjData ("",DBTypeTable); tblData->Document (DBDocGeoDomain,pntData->Document (DBDocGeoDomain)); tblData->Document (DBDocSubject,"Subbasin Histogram"); if (UIDataHeaderForm (tblData)) { UIPauseDialogOpen ((char *) "Calculating Histogram"); if (RGlibPointSubbasinHist (pntData,netData,grdData,tblData) == DBSuccess) workspace->CurrentData (tblData); else delete tblData; UIPauseDialogClose (); } else delete tblData; }
void RGISAnNetworkToGridCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *selection; DBInt dataType; DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjTable *cellTable = netData->Table (DBrNCells); DBObjTableField *field; DBObjData *grdData; static Widget select = NULL; if (select == NULL) select = UISelectionCreate ((char *) "Field Selection"); selection = UISelectObject (select,(DBObjectLIST<DBObject> *) (cellTable->Fields ()),DBTableFieldIsSimple); if (selection == (char *) NULL) return; if ((field = cellTable->Field (selection)) == (DBObjTableField *) NULL) { CMmsgPrint (CMmsgAppError,"Corrupt Network Dataset in: %s %d",__FILE__,__LINE__); return; } if (DBTableFieldIsCategory (field) && DBTableFieldIsNumeric (field)) { DBObjData *tmpData; tmpData = new DBObjData ("",DBTypeGrid); tmpData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); tmpData->Document (DBDocSubject,field->Name ()); if (UIDataHeaderForm (tmpData)) { grdData = DBNetworkToGrid (netData,tmpData->Type ()); grdData->Name (tmpData->Name ()); grdData->Document (DBDocGeoDomain,tmpData->Document (DBDocGeoDomain)); grdData->Document (DBDocSubject,tmpData->Document (DBDocSubject)); grdData->Document (DBDocVersion,tmpData->Document (DBDocVersion)); grdData->Document (DBDocCitationRef,tmpData->Document (DBDocCitationRef)); grdData->Document (DBDocCitationInst,tmpData->Document (DBDocCitationInst)); grdData->Document (DBDocSourceInst,tmpData->Document (DBDocSourceInst)); grdData->Document (DBDocSourcePerson,tmpData->Document (DBDocSourcePerson)); grdData->Document (DBDocOwnerPerson,tmpData->Document (DBDocOwnerPerson)); grdData->Document (DBDocComment,tmpData->Document (DBDocComment)); delete tmpData; } else { return; } } else { if (DBTableFieldIsCategory (field)) dataType = DBTypeGridDiscrete; else if (DBTableFieldIsNumeric (field)) dataType = DBTypeGridContinuous; else { CMmsgPrint (CMmsgAppError,"Invalid field type in: %s %d",__FILE__,__LINE__); return; } grdData = DBNetworkToGrid (netData,dataType); if (UIDataHeaderForm (grdData) == false) { delete grdData; return; } } UIPauseDialogOpen ((char *) "Converting Network to Grid"); if (RGlibNetworkToGrid (netData,field,grdData) == DBSuccess) workspace->CurrentData (grdData); else delete grdData; UIPauseDialogClose (); }
void RGISAnNetworkCellSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (), *grdData = netData->LinkedData (); UIPauseDialogOpen ((char *) "Cell Sampling"); RGlibGridSampling (netData,grdData,true); UIPauseDialogClose (); }
void RGISEditGridRemovePitsCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *grdData = dataset->Data (); DBObjData *netData = grdData->LinkedData (); UIPauseDialogOpen ((char *) "Removing Pits"); RGlibGridRemovePits (netData,grdData); UIPauseDialogClose (); }
void RGISEditNetDistToOceanCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBNetworkIF *netIF = new DBNetworkIF (netData); UIPauseDialogOpen ((char *) "Calculate Distance to Ocean"); netIF->SetDistToOcean (); UIPauseDialogClose (); delete netIF; }
void RGISEditNetBuildCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBNetworkIF *netIF = new DBNetworkIF (netData); UIPauseDialogOpen ((char *) "Building Topological Networks"); netIF->Build (); UIPauseDialogClose (); delete netIF; }
void RGISAnalysePointSubbasinCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *pntData = dataset->Data (); DBObjData *netData = pntData->LinkedData (); DBObjData *grdData = DBNetworkToGrid (netData,DBTypeGridDiscrete); grdData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); grdData->Document (DBDocSubject,"Subbasins"); if (UIDataHeaderForm (grdData)) { UIPauseDialogOpen ((char *) "Creating Subbasin Grid"); if (DBPointToGrid (pntData,netData,grdData) == DBFault) delete grdData; else workspace->CurrentData (grdData); UIPauseDialogClose (); } else delete grdData; }
void RGISAnNetworkBasinGridCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *grdData; grdData = DBNetworkToGrid (netData,DBTypeGridDiscrete); grdData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); grdData->Document (DBDocSubject,netData->Document (DBDocSubject)); if (UIDataHeaderForm (grdData)) { UIPauseDialogOpen ((char *) "Converting Network to Basin Grid"); if (RGlibNetworkBasinGrid (netData,grdData) == DBSuccess) workspace->CurrentData (grdData); else delete grdData; UIPauseDialogClose (); } else delete grdData; }
void RGISAnalysePointSubbasinCenterCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *pntData =dataset->Data (); DBObjTable *pointTable = pntData->Table (DBrNItems); DBObjTableField *massCoordXFLD = pointTable->Field (RGlibMassCoordX); DBObjTableField *massCoordYFLD = pointTable->Field (RGlibMassCoordY); DBObjData *netData = pntData->LinkedData (); UITable *tableCLS = (UITable *) pntData->Display (UITableName (pntData,pointTable)); UIPauseDialogOpen ((char *) "Subbasin Centers"); if ((RGlibPointSubbasinCenter (pntData, netData) == DBSuccess) && (tableCLS != (UITable *) NULL)) { if (massCoordXFLD == NULL) tableCLS->AddField (pointTable->Field (RGlibMassCoordX)); if (massCoordYFLD == NULL) tableCLS->AddField (pointTable->Field (RGlibMassCoordY)); tableCLS->Draw (); } UIPauseDialogClose (); }
void RGISAnNetworkHistogramCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *grdData = netData->LinkedData (); DBObjData *tblData = new DBObjData ("",DBTypeTable); tblData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); tblData->Document (DBDocSubject,"Elevation Distribution"); if (UIDataHeaderForm (tblData)) { UIPauseDialogOpen ((char *) "Calculating Histogram"); if (RGlibNetworkHistogram (netData,grdData,tblData) == DBSuccess) workspace->CurrentData (tblData); else delete tblData; UIPauseDialogClose (); } else delete tblData; }
void RGISEditNetAddBasinXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBInt basinID; DBDataset *dataset = UIDataset (); DBObjData *dbData =dataset->Data (); DBNetworkIF *netIF = new DBNetworkIF (dbData); DBObjTable *itemTable = dbData->Table (DBrNItems); DBObjTableField *xCoordFLD = itemTable->Field (RGISNetMouthXCoord); DBObjTableField *yCoordFLD = itemTable->Field (RGISNetMouthYCoord); DBCoordinate coord; DBObjRecord *basinRec; UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,itemTable)); UIPauseDialogOpen ((char *) "Adding XY Coordinates"); if (xCoordFLD == NULL) { xCoordFLD = new DBObjTableField (RGISNetMouthXCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4)); itemTable->AddField (xCoordFLD); if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD); UIPause (40); } if (yCoordFLD == NULL) { yCoordFLD = new DBObjTableField (RGISNetMouthYCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4)); itemTable->AddField (yCoordFLD); if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD); UIPause (80); } for (basinID = 0;basinID < netIF->BasinNum ();++basinID) { basinRec = netIF->Basin (basinID); if (UIPause (80 + basinID * 20 / netIF->BasinNum ())) goto Stop; coord = netIF->Center (netIF->MouthCell (basinRec)); xCoordFLD->Float (basinRec,coord.X); yCoordFLD->Float (basinRec,coord.Y); } Stop: UIPauseDialogClose (); if (tableCLS != (UITable *) NULL) tableCLS->Draw (); }
static void _RGISToolsImportASCIINetCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBObjData *data = new DBObjData ("",DBTypeNetwork); static Widget fileSelect = NULL; widget = widget; callData = callData; if (fileSelect == NULL) fileSelect = UIFileSelectionCreate ((char *) "GHAAS Data Import",NULL,(char *) "*",XmFILE_REGULAR); data->Document (DBDocSubject,"STNetwork"); if (UIDataHeaderForm (data)) { char *fileName; if ((fileName = UIFileSelection (fileSelect,true)) == NULL) { delete data; return; } UIPauseDialogOpen ((char *) "Importing Networks"); if (DBImportASCIINet (data,fileName) == DBFault) delete data; else workspace->CurrentData (data); UIPauseDialogClose (); } else delete data; }
void RGISEditPointAddXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *dbData =dataset->Data (); DBVPointIF *pntIF = new DBVPointIF (dbData); DBObjTable *pointTable = dbData->Table (DBrNItems); DBObjTableField *xCoordFLD = pointTable->Field (RGISEditPointXCoord); DBObjTableField *yCoordFLD = pointTable->Field (RGISEditPointYCoord); DBCoordinate coord; DBObjRecord *pointRec; UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,pointTable)); widget = widget; workspace = workspace; callData = callData; UIPauseDialogOpen ((char *) "Adding XY Coordinates"); if (xCoordFLD == NULL) { xCoordFLD = new DBObjTableField (RGISEditPointXCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)); pointTable->AddField (xCoordFLD); if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD); UIPause (40); } if (yCoordFLD == NULL) { yCoordFLD = new DBObjTableField (RGISEditPointYCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4)); pointTable->AddField (yCoordFLD); if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD); UIPause (80); } for (pointRec = pntIF->FirstItem (); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem ()) { if (UIPause (80 + pointRec->RowID () * 20 / pntIF->ItemNum ())) goto Stop; coord = pntIF->Coordinate (pointRec); xCoordFLD->Float (pointRec,coord.X); yCoordFLD->Float (pointRec,coord.Y); } Stop: UIPauseDialogClose (); if (tableCLS != (UITable *) NULL) tableCLS->Draw (); }
void RGISAnalysePointInterStationTSCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *selection; DBDataset *dataset = UIDataset (); DBObjMetaEntry *metaEntry; DBObjData *pntData = dataset->Data (), *tsData; DBObjTable *relateTBL = pntData->Table (DBrNRelations); DBObjRecord *relateRec; DBObjTableField *relDataFLD; DBObjTableField *relateFLD; DBObjTableField *joinFLD; static Widget selectWidget = (Widget) NULL; if (selectWidget == (Widget) NULL) selectWidget = UISelectionCreate ((char *) "Select Time Series"); if ((selection = UISelectObject (selectWidget,(DBObjectLIST<DBObject> *) relateTBL)) == (char *) NULL) return; if ((relateRec = relateTBL->Item (selection)) == (DBObjRecord *) NULL) { CMmsgPrint (CMmsgAppError, "Relate Record Error in: %s %d",__FILE__,__LINE__); return; } relDataFLD = relateTBL->Field (DBrNRelateData); relateFLD = relateTBL->Field (DBrNRelateField); joinFLD = relateTBL->Field (DBrNRelateJoinField); if ((tsData = dataset->Data (relDataFLD->String (relateRec))) == (DBObjData *) NULL) { if ((metaEntry = dataset->Meta (relDataFLD->String (relateRec))) == (DBObjMetaEntry *) NULL) { CMmsgPrint (CMmsgAppError, "Meta Enrty Finding Error in: %s %d",__FILE__,__LINE__); return; } tsData = new DBObjData (); if (tsData->Read (metaEntry->FileName ()) != DBSuccess) return; } workspace->CurrentData (tsData); UIPauseDialogOpen ((char *) "Calculating"); RGlibPointInterStationTS (pntData,tsData,relateFLD->String (relateRec),joinFLD->String (relateRec)); UIPauseDialogClose (); }
void RGISEditLineDirectionCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBFloat elev0, elev1; DBCoordinate coord; DBObjRecord *lineRec; DBDataset *dataset = UIDataset (); DBObjData *lineData = dataset->Data (); DBObjData *gridData = lineData->LinkedData (); DBVLineIF *lineIF = new DBVLineIF (lineData); DBGridIF *gridIF = new DBGridIF (gridData); UIPauseDialogOpen ((char *) "Changing Directionality"); for (lineRec = lineIF->FirstItem ();lineRec != (DBObjRecord *) NULL;lineRec = lineIF->NextItem ()) { DBPause (lineRec->RowID () * 100 / lineIF->ItemNum ()); coord = lineIF->FromCoord (lineRec); if (gridIF->Value (coord,&elev0) == false) continue; coord = lineIF->ToCoord (lineRec); if (gridIF->Value (coord,&elev1) == false) continue; if (elev0 < elev1) lineIF->Flip (lineRec); } UIPauseDialogClose (); }
void RGISAnalyseLineSSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *fText; int allowOk; static int sample; DBDataset *dataset = UIDataset (); DBObjData *dbData = dataset->Data (), *grdData = dbData->LinkedData (); DBObjTable *itemTable = dbData->Table (DBrNItems); static Widget dShell = (Widget) NULL, mainForm; static Widget fromNameTextF, toNameTextF; XmString string; widget = widget; workspace = workspace; callData = callData; _RGISAnLineSampleGridFields = itemTable->Fields (); if (dShell == (Widget) NULL) { Widget button; dShell = UIDialogForm ((char *) "Single Layer Grid Sampling",false); mainForm = UIDialogFormGetMainForm (dShell); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, grdData->Type () == DBTypeGridContinuous ? DBTableFieldIsNumeric : DBTableFieldIsCategory, NULL); XmStringFree (string); fromNameTextF = XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGIAnalyseLineSSampleGridSSelectCBK,fromNameTextF); string = XmStringCreate ((char *) "From Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, fromNameTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, button, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, grdData->Type () == DBTypeGridContinuous ? DBTableFieldIsNumeric : DBTableFieldIsCategory, NULL); XmStringFree (string); toNameTextF = XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGIAnalyseLineSSampleGridSSelectCBK,toNameTextF); string = XmStringCreate ((char *) "To Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalyseLineSSampleNameLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, toNameTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&sample); } sample = false; UIDialogFormPopup (dShell); while (UILoop ()) { allowOk = false; fText = XmTextFieldGetString (fromNameTextF); if (strlen (fText) > 0) allowOk = true; XtFree (fText); fText = XmTextFieldGetString (toNameTextF); if (strlen (fText) > 0) allowOk = true; XtFree (fText); XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk); } UIDialogFormPopdown (dShell); if (sample) { DBInt ret; DBFloat value; DBCoordinate coord; DBGridIF *gridIF = new DBGridIF (grdData); DBVLineIF *lineIF = new DBVLineIF (dbData); DBObjTableField *fromField; DBObjTableField *toField; DBObjRecord *record; fText = XmTextFieldGetString (fromNameTextF); if (strlen (fText) > 0) { if ((fromField = itemTable->Field (fText)) == (DBObjTableField *) NULL) itemTable->AddField (fromField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4))); } else fromField = (DBObjTableField *) NULL; XtFree (fText); fText = XmTextFieldGetString (toNameTextF); if (strlen (fText) > 0) { if ((toField = itemTable->Field (fText)) == (DBObjTableField *) NULL) itemTable->AddField (toField = new DBObjTableField (fText,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4))); } else toField = (DBObjTableField *) NULL; XtFree (fText); UIPauseDialogOpen ((char *) "Sampling Grid"); for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ()) { if (UIPause (record->RowID () * 100 / itemTable->ItemNum ())) goto Stop; if (fromField != (DBObjTableField *) NULL) { coord = lineIF->FromCoord (record); ret = gridIF->Value (coord,&value); if (fromField->Type () == DBTableFieldFloat) { if (ret) fromField->Float (record,value); else fromField->Float (record,fromField->FloatNoData ()); } else { if (ret) fromField->Int (record,(DBInt) value); else fromField->Int (record,fromField->IntNoData ()); } } if (toField != (DBObjTableField *) NULL) { coord = lineIF->ToCoord (record); ret = gridIF->Value (coord,&value); if (toField->Type () == DBTableFieldFloat) { if (ret) toField->Float (record,value); else toField->Float (record,toField->FloatNoData ()); } else { if (ret) toField->Int (record,(DBInt) value); else toField->Int (record,toField->IntNoData ()); } } } Stop: UIPauseDialogClose (); delete lineIF; delete gridIF; } }
void RGISAnalyseLineMSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBInt layerID, layerNum; DBCoordinate coord; DBFloat realValue; DBDataset *dataset = UIDataset (); DBObjData *dbData = dataset->Data (); DBObjData *grdData = dbData->LinkedData (); DBObjData *tblData; DBObjTable *table, *itemTable = dbData->Table (DBrNItems); DBObjTableField *lineIDFLD; DBObjTableField *layerIDFLD; DBObjTableField *layerNameFLD; DBObjTableField *fromValueFLD = (DBObjTableField *) NULL; DBObjTableField *toValueFLD = (DBObjTableField *) NULL; DBVLineIF *lineIF = (DBVLineIF *) NULL; DBGridIF *gridIF; DBObjRecord *record, *layerRec, *tblRec; DBObjectLIST<DBObjTableField> *fields; widget = widget; callData = callData; gridIF = new DBGridIF (grdData); for (layerID = 0;layerID < gridIF->LayerNum ();++layerID) { layerRec = gridIF->Layer (layerID); if ((layerRec->Flags () & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum; } if (layerNum < 1) { CMmsgPrint (CMmsgAppError, "No Layer to Process in: %s %d",__FILE__,__LINE__); delete gridIF; return; } tblData = new DBObjData ("",DBTypeTable); tblData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain)); tblData->Document (DBDocSubject,grdData->Document (DBDocSubject)); if (UIDataHeaderForm (tblData) == false) { delete gridIF; delete tblData; return; } table = tblData->Table (DBrNItems); lineIF = new DBVLineIF (dbData); table->AddField (lineIDFLD = new DBObjTableField ("GHAASPointID",DBTableFieldInt, "%8d",sizeof (DBInt))); table->AddField (layerIDFLD = new DBObjTableField ("LayerID", DBTableFieldInt, "%4d",sizeof (DBShort))); table->AddField (layerNameFLD = new DBObjTableField ("LayerName", DBTableFieldString,"%s",DBStringLength)); table->AddField (fromValueFLD = new DBObjTableField (RGISLineFromNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4))); table->AddField (toValueFLD = new DBObjTableField (RGISLineToNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4))); grdData->Flags (DBObjectFlagProcessed,DBSet); UIPauseDialogOpen ((char *) "Sampling Grid(s)"); for (layerID = 0;layerID < gridIF->LayerNum ();++layerID) { layerRec = gridIF->Layer (layerID); if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue; for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ()) { if (UIPause ((layerRec->RowID () * itemTable->ItemNum () + record->RowID ()) * 100 / (itemTable->ItemNum () * gridIF->LayerNum ()))) goto Stop; if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue; tblRec = table->Add (record->Name ()); lineIDFLD->Int (tblRec,record->RowID () + 1); layerIDFLD->Int (tblRec,layerRec->RowID ()); layerNameFLD->String (tblRec,layerRec->Name ()); coord = lineIF->FromCoord (record); if (gridIF->Value (layerRec,coord,&realValue)) fromValueFLD->Float (tblRec,realValue); coord = lineIF->ToCoord (record); if (gridIF->Value (layerRec,coord,&realValue)) toValueFLD->Float (tblRec,realValue); } } Stop: UIPauseDialogClose (); delete gridIF; delete lineIF; fields = new DBObjectLIST<DBObjTableField> ("Field List"); fields->Add (new DBObjTableField (*lineIDFLD)); fields->Add (new DBObjTableField (*layerIDFLD)); table->ListSort (fields); workspace->CurrentData (tblData); delete fields; }
void RGISAnNetworkStreamLinesCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *selection; DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjTable *cellTable = netData->Table (DBrNCells); DBObjData *arcData = new DBObjData ("",DBTypeVectorLine); DBNetworkIF *netIF = new DBNetworkIF (netData); static Widget fieldSelect = (Widget) NULL; widget = widget; callData = callData; if (fieldSelect == (Widget) NULL) fieldSelect = UISelectionCreate ((char *) "Select Field"); if ((selection = UISelectObject (fieldSelect,(DBObjectLIST<DBObject> *) cellTable->Fields (),DBTableFieldIsInteger)) == (char *) NULL) return; if ((_RGISAnNetOrderField = cellTable->Field (selection)) == (DBObjTableField *) NULL) { CMmsgPrint (CMmsgAppError, "Field Selection Error in: %s %d",__FILE__,__LINE__); return; } arcData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); arcData->Document (DBDocSubject,"Stream Lines"); if (UIDataHeaderForm (arcData)) { DBInt cellID; char objName [DBStringLength]; DBVLineIF *lineIF = new DBVLineIF (arcData); DBObjTable *cellTable = netData->Table (DBrNCells); DBObjTable *lineTable = arcData->Table (DBrNItems); DBObjTableField *basinFLD = new DBObjTableField (DBrNBasin,DBTableFieldInt,"%8d",sizeof (DBInt)); DBObjTableField *fieldFLD = new DBObjTableField (_RGISAnNetOrderField->Name (), _RGISAnNetOrderField->Type (), _RGISAnNetOrderField->Format (), _RGISAnNetOrderField->Length ()); DBObjTableField *lengthFLD = new DBObjTableField (RGISNetStreamLength,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4)); DBObjTableField *areaFLD = new DBObjTableField (RGISNetStreamArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4)); DBObjTableField *basinAreaFLD = new DBObjTableField (RGISNetBasinArea,DBTableFieldFloat,"%10.1f",sizeof (DBFloat4)); DBObjTableField *nextFLD = new DBObjTableField (RGISNetStreamNext,DBTableFieldInt,"%6d",sizeof (DBInt)); DBObjRecord *cellRec, *toCellRec, *lineRec; arcData->Projection (netData->Projection ()); arcData->Precision (netData->Precision ()); arcData->MaxScale (netData->MaxScale ()); arcData->MinScale (netData->MinScale ()); lineTable->AddField (basinFLD); lineTable->AddField (fieldFLD); lineTable->AddField (lengthFLD); lineTable->AddField (areaFLD); lineTable->AddField (basinAreaFLD); lineTable->AddField (nextFLD); cellTable->AddField (_RGISAnNetStreamIDFLD = new DBObjTableField ("StreamID",DBTableFieldInt,"%8d",sizeof (DBInt))); _RGISAnNetStreamID = 0; UIPauseDialogOpen ((char *) "Creating Stream Lines"); cellID = netIF->CellNum () - 1; cellRec = netIF->Cell (cellID); if (lineIF->NewSymbol ("Default Symbol") == (DBObjRecord *) NULL) { CMmsgPrint (CMmsgAppError, "Symbol Creation Error in: %s %d",__FILE__,__LINE__); return; } for (;cellID >= 0;--cellID) { cellRec = netIF->Cell (cellID); if (((toCellRec = netIF->ToCell (cellRec)) == (DBObjRecord *) NULL) || (_RGISAnNetOrderField->Int (cellRec) != _RGISAnNetOrderField->Int (toCellRec)) || (netIF->CellOrder (cellRec) != netIF->CellOrder (toCellRec))) { if (UIPause ((netIF->CellNum () - cellRec->RowID ()) * 100 / netIF->CellNum ())) goto Stop; sprintf (objName,"Line: %5d",_RGISAnNetStreamID + 1); if ((lineRec = lineIF->NewItem (objName)) == (DBObjRecord *) NULL) { CMmsgPrint (CMmsgAppError, "Line Insertion Error in: %s %d",__FILE__,__LINE__); return; } nextFLD->Int (lineRec,toCellRec == (DBObjRecord *) NULL ? 0 : _RGISAnNetStreamIDFLD->Int (toCellRec) + 1); basinFLD->Int (lineRec,netIF->CellBasinID (cellRec)); fieldFLD->Int (lineRec,_RGISAnNetOrderField->Int (cellRec)); _RGISAnNetVertex = 0; netIF->UpStreamSearch (_RGISAnNetworkCellRec = cellRec,(DBNetworkACTION) _RGISAnNetworkUpStreamAction); lineIF->FromNode (lineRec,lineIF->Node (netIF->Center (_RGISAnNetworkCellRec),true)); lineIF->ToNode (lineRec,lineIF->Node (netIF->Center (cellRec) + netIF->Delta (cellRec),true)); _RGISAnNetArea = netIF->CellArea (_RGISAnNetworkCellRec); if (_RGISAnNetVertex > 1) { if (_RGISAnNetVertexNum < _RGISAnNetVertex - 1) { _RGISAnNetCoord = (DBCoordinate *) realloc (_RGISAnNetCoord,(_RGISAnNetVertex - 1) * sizeof (DBCoordinate)); if (_RGISAnNetCoord == (DBCoordinate *) NULL) { CMmsgPrint (CMmsgSysError, "Memory Allocation Error in: %s %d",__FILE__,__LINE__); return; } } _RGISAnNetVertex = 0; netIF->DownStreamSearch (netIF->ToCell (_RGISAnNetworkCellRec),(DBNetworkACTION) _RGISAnNetworkDownStreamAction); } else _RGISAnNetVertex = 0; lineIF->Vertexes (lineRec,_RGISAnNetCoord,_RGISAnNetVertex); lineIF->ItemSymbol (lineRec,lineIF->Symbol (0)); lengthFLD->Float (lineRec,netIF->CellBasinLength (cellRec)); areaFLD->Float (lineRec,_RGISAnNetArea); basinAreaFLD->Float (lineRec,netIF->CellBasinArea (cellRec)); _RGISAnNetStreamID += 1; } } Stop: UIPauseDialogClose (); if (_RGISAnNetCoord != (DBCoordinate *) NULL) free (_RGISAnNetCoord); delete lineIF; if (cellID >= 0) delete arcData; else workspace->CurrentData (arcData); } else delete arcData; delete netIF; }
void RGISEditPointSTNCoordsCBK (Widget widget,void *data,XmAnyCallbackStruct *callData) { char *text; static DBInt cont; DBDataset *dataset; DBObjData *dbData; DBObjTable *table; DBObjTableField *field = (DBObjTableField *) NULL; static Widget dShell = NULL, mainForm, button, textF; widget = widget; data = data; callData = callData; if (dShell == (Widget) NULL) { XmString string; dShell = UIDialogForm ((char *) "Area Field",false); mainForm = UIDialogFormGetMainForm (dShell); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISEditPointSTNBestCoordsButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, DBTableFieldIsCategory, NULL); XmStringFree (string); textF = XtVaCreateManagedWidget ("RGISEditPointSTNBestCoordsTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _RGISEditPointSTNCoordsSelectCBK,textF); string = XmStringCreate ((char *) "Area Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISEditJoinTableNameLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, textF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&cont); XtSetSensitive (UIDialogFormGetOkButton (dShell),true); } dataset = UIDataset (); dbData = dataset->Data (); table = dbData->Table (DBrNItems); XtVaSetValues (textF,XmNuserData,table->Fields (),NULL); UIDialogFormPopup (dShell); cont = false; while (UILoop ()); { if (strlen (text = XmTextFieldGetString (textF)) > 0) field = table->Field (text); /* if ((strlen (text = XmTextFieldGetString (textF)) > 0) && ((field = table->Field (text)) != (DBObjTableField *) NULL)) XtSetSensitive (UIDialogFormGetOkButton (dShell),True); else XtSetSensitive (UIDialogFormGetOkButton (dShell),False); */ XtFree (text); } UIDialogFormPopdown (dShell); if (cont) { UIPauseDialogOpen ((char *) "Moving Points"); RGlibPointSTNCoordinates (dbData,field); UIPauseDialogClose (); UI2DViewRedrawAll (); } }
void RGISAnalysePointSTNPointsCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *srcText; static DBInt cont, diffMethod; DBDataset *dataset; DBObjData *dbData; DBObjTable *table; DBObjTableField *field = (DBObjTableField *) NULL; static Widget dShell = NULL, mainForm, button; static Widget srcTextF, dstTextF, cmpTextF, errTextF; static Widget menu, mButton; if (dShell == (Widget) NULL) { XmString string; dShell = UIDialogForm ((char *) "Area Field",false); mainForm = UIDialogFormGetMainForm (dShell); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsSrcButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, DBTableFieldIsNumeric, NULL); XmStringFree (string); srcTextF = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsSrcTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxObjectSelectCBK,srcTextF); string = XmStringCreate ((char *) "Area Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsSrcLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, srcTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsSrcButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, srcTextF, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, DBTableFieldIsNumeric, NULL); XmStringFree (string); dstTextF = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsDstTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxObjectSelectCBK,dstTextF); string = XmStringCreate ((char *) "Target Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsDstLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, dstTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsErrorButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, dstTextF, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, DBTableFieldIsNumeric, NULL); XmStringFree (string); cmpTextF = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsCompTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxObjectSelectCBK,cmpTextF); string = XmStringCreate ((char *) "Compare Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsDstLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, cmpTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); string = XmStringCreate ((char *) "Select",UICharSetBold); button = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsErrorButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, cmpTextF, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmarginHeight, 5, XmNtraversalOn, False, XmNlabelString, string, XmNuserData, DBTableFieldIsNumeric, NULL); XmStringFree (string); errTextF = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsErrorTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, button, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNmaxLength, DBStringLength, XmNcolumns, DBStringLength / 2, NULL); XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxObjectSelectCBK,errTextF); string = XmStringCreate ((char *) "Error Field:",UICharSetBold); XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsDstLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, button, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, errTextF, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, button, XmNlabelString, string, NULL); XmStringFree (string); menu = XmCreatePulldownMenu (mainForm,(char *) "RGISAnalysePointSTNPointsMenu",NULL,0); string = XmStringCreate ((char *) "Plain",UICharSetNormal); mButton = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsMenuButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &diffMethod, NULL); XmStringFree (string); XtAddCallback (mButton,XmNactivateCallback,(XtCallbackProc) UIAuxSetIntegerCBK,(XtPointer) 0); string = XmStringCreate ((char *) "Simple %",UICharSetNormal); mButton = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsMenuButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &diffMethod, NULL); XmStringFree (string); XtAddCallback (mButton,XmNactivateCallback,(XtCallbackProc) UIAuxSetIntegerCBK,(XtPointer) 1); string = XmStringCreate ((char *) "Symmetric %",UICharSetNormal); mButton = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsMenuButton",xmPushButtonWidgetClass,menu, XmNlabelString, string, XmNuserData, &diffMethod, NULL); XmStringFree (string); XtAddCallback (mButton,XmNactivateCallback,(XtCallbackProc) UIAuxSetIntegerCBK,(XtPointer) 2); string = XmStringCreate ((char *) "Difference Method:",UICharSetBold); menu = XtVaCreateManagedWidget ("RGISAnalysePointSTNPointsMenu",xmRowColumnWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, button, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNrowColumnType, XmMENU_OPTION, XmNlabelString, string, XmNsubMenuId, menu, NULL); XmStringFree (string); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&cont); XtSetSensitive (UIDialogFormGetOkButton (dShell),true); } dataset = UIDataset (); dbData = dataset->Data (); table = dbData->Table (DBrNItems); XtVaSetValues (srcTextF,XmNuserData,table->Fields (),NULL); XtVaSetValues (dstTextF,XmNuserData,table->Fields (),NULL); XtVaSetValues (cmpTextF,XmNuserData,table->Fields (),NULL); XtVaSetValues (errTextF,XmNuserData,table->Fields (),NULL); UIDialogFormPopup (dShell); cont = false; while (UILoop ()) { if ((strlen (srcText = XmTextFieldGetString (srcTextF)) > 0) && ((field = table->Field (srcText)) != (DBObjTableField *) NULL)) XtSetSensitive (UIDialogFormGetOkButton (dShell),True); else XtSetSensitive (UIDialogFormGetOkButton (dShell),False); XtFree (srcText); if ((strlen (srcText = XmTextFieldGetString (cmpTextF)) > 0) && ((field = table->Field (srcText)) != (DBObjTableField *) NULL)) { XtSetSensitive (button,True); XtSetSensitive (errTextF,True); XtSetSensitive (menu,True); } else { XmTextFieldSetString (errTextF,(char *) ""); XtSetSensitive (button,False); XtSetSensitive (errTextF,False); XtSetSensitive (menu,False); } XtFree (srcText); } UIDialogFormPopdown (dShell); if (cont) { char dataName [DBDataNameLen + 5]; DBObjData *netData = dbData->LinkedData (); sprintf (dataName,"%s STN",dbData->Name ()); dbData = new DBObjData (*dbData); dbData->Name (dataName); if (UIDataHeaderForm (dbData)) { char *dstText; DBObjTable *groups; DBObjRecord *pointRec; srcText = XmTextFieldGetString (srcTextF); dbData->LinkedData (netData); table = dbData->Table (DBrNItems); groups = dbData->Table (DBrNGroups); for (pointRec = table->First ();pointRec != (DBObjRecord *) NULL;pointRec = table->Next ()) if ((pointRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) { if (groups != (DBObjTable *) NULL) groups->Delete (groups->Item (pointRec->RowID ())); table->Delete (pointRec); pointRec = table->Next (DBBackward); } field = table->Field (srcText); XtFree (srcText); RGlibPointSTNCoordinates (dbData,field); UIPauseDialogOpen ((char *) "Moving Points"); RGlibPointSTNCharacteristics (dbData); UIPauseDialogClose (); srcText = XmTextFieldGetString (srcTextF); if (strlen (dstText = XmTextFieldGetString (dstTextF)) > 0) { srcText = XmTextFieldGetString (srcTextF); RGlibGenFuncTopoSubtract (table,RGlibNextStation,srcText,dstText); XtFree (dstText); } if (strlen (dstText = XmTextFieldGetString (errTextF)) > 0) { char *cmpText; srcText = XmTextFieldGetString (srcTextF); cmpText = XmTextFieldGetString (cmpTextF); RGlibGenFuncFieldCompare (table,srcText,cmpText,dstText,diffMethod); XtFree (dstText); XtFree (cmpText); } XtFree (srcText); UI2DViewRedrawAll (); workspace->CurrentData (dbData); } else delete dbData; } }
void RGISEditAdjustNetworkCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBInt vertex, vertexNum, dir, cell, cellNum, maxCellNum = 0; DBPosition pos0, pos1; DBCoordinate *vertexes; DBObjRecord *lineRec, **cellList = (DBObjRecord **) NULL; DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); DBObjData *lineData = netData->LinkedData (); DBNetworkIF *netIF = new DBNetworkIF (netData); DBVLineIF *lineIF = new DBVLineIF (lineData); UIPauseDialogOpen ((char *) "Adjusting Networks"); cellNum = 0; for (lineRec = lineIF->FirstItem ();lineRec != (DBObjRecord *) NULL; lineRec = lineIF->NextItem ()) { UIPause (lineRec->RowID () * 100 / lineIF->ItemNum ()); if (lineIF->ToNode (lineRec) == lineIF->FromNode (lineRec)) continue; if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return; if ((cellList [cellNum] = netIF->Cell (lineIF->FromCoord (lineRec))) == (DBObjRecord *) NULL) if((cellList [cellNum] = netIF->CellAdd (lineIF->FromCoord (lineRec))) != (DBObjRecord *) NULL) cellNum++; if ((vertexNum = lineIF->VertexNum (lineRec)) > 0) { vertexes = lineIF->Vertexes (lineRec); for (vertex = 0; vertex < vertexNum; ++vertex) { if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return; if ((cellList [cellNum] = netIF->Cell (vertexes [vertex])) == (DBObjRecord *) NULL) if((cellList [cellNum] = netIF->CellAdd (vertexes [vertex])) == (DBObjRecord *) NULL) continue; for (cell = 0;cell < cellNum;++cell) if (cellList [cell] == cellList [cellNum]) break; if (cell != cellNum) continue; cellNum++; /* if (cellNum > 1) { pos0 = netIF->CellPosition (cellList [cellNum - 2]); pos1 = netIF->CellPosition (cellList [cellNum - 1]); printf ("%5d %3d %3d %3d %3d\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row); if ((abs (pos0.Row - pos1.Row) <= 1) && (abs (pos0.Col - pos1.Col) <= 1)) continue; if (abs (pos0.Row - pos1.Row) > abs (pos0.Col - pos1.Col)) for (pos.Row = pos0.Row; pos.Row != pos1.Row; pos.Row = (pos0.Row < pos1.Row) ? pos.Row + 1 : pos.Row - 1) { pos.Col = pos0.Col + (DBUShort) ((((DBInt) pos.Row - (DBInt) pos0.Row) * ((DBInt) pos1.Col - (DBInt) pos0.Col)) / ((DBInt) pos1.Row - (DBInt) pos0.Row)); if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return; if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL) { cellList [cellNum] = cellList [cellNum - 1]; cellList [cellNum - 1] = cellRec; cellNum++; } } else for (pos.Col = pos0.Col; pos.Col != pos1.Col; pos.Col = (pos0.Col < pos1.Col) ? pos.Col + 1 : pos.Col - 1) { pos.Row = pos0.Row + (DBUShort) ((((DBInt) pos.Col - (DBInt) pos0.Col) * ((DBInt) pos1.Row - (DBInt) pos0.Row)) / ((DBInt) pos1.Col - (DBInt) pos0.Col)); if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return; if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL) { cellList [cellNum] = cellList [cellNum - 1]; cellList [cellNum - 1] = cellRec; cellNum++; } } } */ } } for (cell = 0;cell < cellNum - 1;++cell) { pos0 = netIF->CellPosition (cellList [cell]); pos1 = netIF->CellPosition (cellList [cell + 1]); if ((pos0.Col < pos1.Col) && (pos0.Row == pos1.Row)) dir = DBNetDirE; else if ((pos0.Col < pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirSE; else if ((pos0.Col == pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirS; else if ((pos0.Col > pos1.Col) && (pos0.Row > pos1.Row)) dir = DBNetDirSW; else if ((pos0.Col > pos1.Col) && (pos0.Row == pos1.Row)) dir = DBNetDirW; else if ((pos0.Col > pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirNW; else if ((pos0.Col == pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirN; else if ((pos0.Col < pos1.Col) && (pos0.Row < pos1.Row)) dir = DBNetDirNE; // printf ("%5d %3d %3d %3d %3d %2x\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row,dir); netIF->CellDirection (cellList [cell],dir); } } if (maxCellNum > 0) free (cellList); UIPauseDialogClose (); UIPauseDialogOpen ((char *) "Building Networks"); // netIF->Build (); UIPauseDialogClose (); }
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; } }
int _RGISARCInfoImport (DBObjData *vecData) { char *text; int allowSave, ret = DBFault; static int import; static Widget dShell = NULL; static Widget coverTextF, nameTextF, nameButton, symbolTextF, symbolButton; _RGISARCDataType = vecData->Type (); if (dShell == NULL) { Widget mainForm, label, coverButton; XmString string; dShell = UIDialogForm ((char *) "ARC/Info Coverage Import"); mainForm = UIDialogFormGetMainForm (dShell); string = XmStringCreate ((char *) "Coverage:",UICharSetBold); label = XtVaCreateManagedWidget ("RGISARCInfoImportFormCoverLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, XmNlabelString, string, NULL); XmStringFree (string); coverTextF = XtVaCreateManagedWidget ("RGISARCInfoImportFormCoverTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label, XmNleftOffset, 5, XmNmaxLength, 64, XmNcolumns, 64, NULL); string = XmStringCreate ((char *) "Select",UICharSetBold); coverButton = XtVaCreateManagedWidget ("RGISARCInfoImportFormCoverLabel",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, coverTextF, XmNleftOffset, 5, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNtraversalOn, False, XmNlabelString, string, NULL); XtAddCallback (coverButton,XmNactivateCallback,(XtCallbackProc) _RGISARCInfoImportFileSelectCBK,coverTextF); XmStringFree (string); string = XmStringCreate ((char *) "Name Field:",UICharSetBold); label = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolIDLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, XmNlabelString, string, NULL); XmStringFree (string); nameTextF = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolIDTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label, XmNleftOffset, 5, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNmaxLength, DBStringLength, XmNcolumns, 16, NULL); string = XmStringCreate ((char *) "Select",UICharSetBold); nameButton = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolIDButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, nameTextF, XmNleftOffset, 5, XmNuserData, DBTableFieldIsString, XmNlabelString, string, XmNtraversalOn, False, NULL); XtAddCallback (nameButton,XmNactivateCallback,(XtCallbackProc) _RGISARCInfoImportFieldSelectCBK,nameTextF); XtAddCallback (coverTextF,XmNvalueChangedCallback,(XtCallbackProc) _RGISARCInfoImportClearFieldCBK,nameTextF); XmStringFree (string); XtSetSensitive (nameButton,False); string = XmStringCreate ((char *) "Select",UICharSetBold); symbolButton = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolNameButton",xmPushButtonWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNlabelString, string, XmNuserData, DBTableFieldIsCategory, XmNtraversalOn, False, NULL); XmStringFree (string); XtSetSensitive (symbolButton,False); symbolTextF = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolNameTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, symbolButton, XmNrightOffset, 5, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNmaxLength, DBStringLength, XmNcolumns, 16, NULL); XtAddCallback (symbolButton,XmNactivateCallback,(XtCallbackProc) _RGISARCInfoImportFieldSelectCBK,symbolTextF); XtAddCallback (coverTextF,XmNvalueChangedCallback,(XtCallbackProc) _RGISARCInfoImportClearFieldCBK,symbolTextF); string = XmStringCreate ((char *) "Symbol Field:",UICharSetBold); label = XtVaCreateManagedWidget ("RGISARCInfoImportFormSymbolNameLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, coverTextF, XmNtopOffset, 5, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, symbolTextF, XmNrightOffset, 5, XmNlabelString, string, NULL); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&import); XmStringFree (string); } XmProcessTraversal (coverTextF,XmTRAVERSE_CURRENT); import = false; UIDialogFormPopup (dShell); while (UILoop ()) { text = XmTextFieldGetString (coverTextF); allowSave = strlen (text) > 0; XtSetSensitive (nameButton,allowSave); XtSetSensitive (symbolButton,allowSave); XtSetSensitive (UIDialogFormGetOkButton (dShell),allowSave); XtFree (text); } UIDialogFormPopdown (dShell); if (import) { char *infoFile, *nameField, *symbolField; infoFile = XmTextFieldGetString (coverTextF); nameField = XmTextFieldGetString (nameTextF); symbolField = XmTextFieldGetString (symbolTextF); UIPauseDialogOpen ((char *) "Loading ARC/Info Coverage"); ret = DBImportARCVector (vecData, infoFile, strlen (nameField) > 0 ? nameField : (char *) NULL, strlen (symbolField) > 0 ? symbolField : (char *) NULL); UIPauseDialogClose (); XtFree (infoFile); XtFree (nameField ); XtFree (symbolField); } if ( _RGISARCTempTable != NULL) {delete _RGISARCTempTable; _RGISARCTempTable = (DBObjTable *) NULL; } return (ret); }
static void _RGISToolsNetBasinMouthCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (), *pntData; DBNetworkIF *netIF; widget = widget; callData = callData; if (netData == (DBObjData *) NULL) { CMmsgPrint (CMmsgAppError, "Null Data in: %s %d",__FILE__,__LINE__); return; } netIF = new DBNetworkIF (netData); if (UIDataHeaderForm (pntData = new DBObjData ("",DBTypeVectorPoint))) { char symName [DBStringLength]; DBInt basinID, order; DBCoordinate coord; DBObjTable *items = pntData->Table (DBrNItems); DBObjTable *symbols = pntData->Table (DBrNSymbols); DBObjTableField *coordField = items->Field (DBrNCoord); DBObjTableField *symbolFLD = items->Field (DBrNSymbol); DBObjTableField *orderFLD = new DBObjTableField (DBrNOrder,DBTableFieldInt,"%3d",sizeof (DBByte)); DBObjTableField *subbasinLengthFLD = new DBObjTableField (DBrNSubbasinLength,DBTableFieldFloat,"%10.1f",sizeof (float)); DBObjTableField *subbasinAreaFLD = new DBObjTableField (DBrNSubbasinArea,DBTableFieldFloat,"%10.1f",sizeof (float)); DBObjTableField *foregroundFLD = symbols->Field (DBrNForeground); DBObjTableField *backgroundFLD = symbols->Field (DBrNBackground); DBObjTableField *styleFLD = symbols->Field (DBrNStyle); DBObjRecord *pntRec, *symRec, *cellRec, *basinRec; DBRegion dataExtent; items->AddField (orderFLD); items->AddField (subbasinLengthFLD); items->AddField (subbasinAreaFLD); cellRec = netIF->Cell ((DBInt) 0); for (order = 0;order <= netIF->CellOrder (cellRec);++order) { sprintf (symName,"Strahler Order:%2d",order); symRec = symbols->Add (symName); styleFLD->Int (symRec,0); foregroundFLD->Int (symRec,1); backgroundFLD->Int (symRec,0); } UIPauseDialogOpen ((char *) "Creating Basin Mouth"); for (basinID = 0;basinID < netIF->BasinNum ();++basinID) { basinRec = netIF->Basin (basinID); if (UIPause (basinID * 100 / netIF->BasinNum ())) goto Stop; symRec = symbols->Item (netIF->CellOrder (cellRec)); cellRec = netIF->MouthCell (basinRec); pntRec = items->Add (basinRec->Name ()); coord = netIF->Center (cellRec); coordField->Coordinate (pntRec,coord); symbolFLD->Record (pntRec,symRec); orderFLD->Int (pntRec,netIF->CellOrder (cellRec)); subbasinLengthFLD->Float (pntRec,netIF->CellBasinLength (cellRec)); subbasinAreaFLD->Float (pntRec,netIF->CellBasinArea (cellRec)); dataExtent.Expand (coord); } Stop: UIPauseDialogClose (); pntData->Extent (dataExtent); workspace->CurrentData (pntData); } else delete pntData; delete netIF; }
void RGISAnNetworkStationsCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { char *areaText, *toleranceText; DBFloat area, tolerance; DBDataset *dataset = UIDataset (); DBObjData *netData = dataset->Data (); static int proc; static Widget dShell = (Widget) NULL, areaField, toleranceField; if (dShell == (Widget) NULL) { Widget mainForm, label; XmString string; dShell = UIDialogForm ((char *) "Network Stations"); mainForm = UIDialogFormGetMainForm (dShell); areaField = XtVaCreateManagedWidget ("RGISAnNetworkStationsAreaTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 10, XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 10, XmNmaxLength, DBStringLength / 2, XmNcolumns, DBStringLength / 2, NULL); string = XmStringCreate ((char *) "Subbasin Area [km2]:",UICharSetBold); label = XtVaCreateManagedWidget ("RGISAnNetworkStationsAreaLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, areaField, XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 10, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, areaField, XmNrightOffset, 10, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, areaField, XmNlabelString, string, XmNmarginWidth, 5, NULL); XmStringFree (string); toleranceField = XtVaCreateManagedWidget ("RGISAnNetworkStationsToleranceTextF",xmTextFieldWidgetClass,mainForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, areaField, XmNtopOffset, 5, XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET, XmNleftWidget, areaField, XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET, XmNrightWidget, areaField, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNmaxLength, DBStringLength / 2, XmNcolumns, DBStringLength / 2, NULL); string = XmStringCreate ((char *) "Tolerance [%]:",UICharSetBold); label = XtVaCreateManagedWidget ("RGISAnNetworkStationsToleranceLabel",xmLabelWidgetClass,mainForm, XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET, XmNtopWidget, toleranceField, XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET, XmNleftWidget, label, XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET, XmNbottomWidget, toleranceField, XmNlabelString, string, XmNmarginWidth, 5, NULL); XmStringFree (string); XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&proc); XtAddCallback (UIDialogFormGetCancelButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanFalseCBK,&proc); } proc = false; UIDialogFormPopup (dShell); while (UILoop ()) { areaText = XmTextFieldGetString (areaField); toleranceText = XmTextFieldGetString (toleranceField); if ((strlen (areaText) > 0) && (sscanf (areaText,"%lf",&area) == 1) && (strlen (toleranceText) > 0) && (sscanf (toleranceText,"%lf",&tolerance) == 1)) XtSetSensitive (UIDialogFormGetOkButton (dShell),true); else XtSetSensitive (UIDialogFormGetOkButton (dShell),false); XtFree (areaText); XtFree (toleranceText); } UIDialogFormPopdown (dShell); if (proc) { DBObjData *pntData; pntData = new DBObjData ("",DBTypeVectorPoint); pntData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain)); pntData->Document (DBDocSubject,GHAASSubjStations); if (UIDataHeaderForm (pntData)) { UIPauseDialogOpen ((char *) "Creating Stations"); if (RGlibNetworkStations (netData,area,tolerance,pntData) == DBSuccess) { workspace->CurrentData (pntData); UI2DViewRedrawAll (); } else delete pntData; UIPauseDialogClose (); } else delete pntData; } }
void RGISEditGridNetFilterCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData) { DBInt layerID, cellID, count, ret, kernel, kernelSize, maxProgress, dir; DBFloat elev, cellElev, prevElev, upElev [5], meanElev, minElev, dElev; DBDataset *dataset = UIDataset (); DBObjData *grdData = dataset->Data (); DBObjData *netData = grdData->LinkedData (); DBGridIF *gridIF = new DBGridIF (grdData); DBNetworkIF *netIF = new DBNetworkIF (netData); DBObjRecord *cellRec, *fromCell, *nextCell, *layerRec; UIPauseDialogOpen ((char *) "Network Filtering"); maxProgress = netIF->CellNum () * gridIF->LayerNum (); for (layerID = 0;layerID < gridIF->LayerNum (); ++layerID) { layerRec = gridIF->Layer (layerID); for (cellID = 0;cellID < netIF->CellNum (); ++cellID) { if (UIPause (((layerID + 1) * netIF->CellNum () - cellID) * 100 / maxProgress)) goto Stop; fromCell = netIF->Cell (cellID); if (netIF->FromCell (fromCell) != (DBObjRecord *) NULL) continue; while (gridIF->Value (layerRec,netIF->Center (fromCell),&prevElev) == (DBInt) false) if ((fromCell = netIF->ToCell (fromCell)) == (DBObjRecord *) NULL) break; if (fromCell == (DBObjRecord *) NULL) continue; kernelSize = 0; for (cellRec = netIF->ToCell (fromCell); (cellRec != (DBObjRecord *) NULL) && (netIF->FromCell (cellRec) == fromCell); cellRec = netIF->ToCell (cellRec)) { dElev = netIF->CellLength (fromCell) * RGlibMinSLOPE; if ((ret = gridIF->Value (layerRec,netIF->Center (cellRec),&cellElev)) == false) { count = 0; meanElev = 0.0; } else { count = 1, meanElev = cellElev; } if (kernelSize + 1 < (int) (sizeof (upElev) / sizeof (upElev [0]))) kernelSize++; for (kernel = kernelSize - 1;kernel > 0;--kernel) upElev [kernel] = upElev [kernel - 1]; upElev [0] = prevElev; for (kernel = 0;kernel < kernelSize;++kernel) { meanElev += upElev [kernel]; count++; } minElev = prevElev; for (dir = 0; dir < 8;++dir) if (((fromCell = netIF->FromCell (cellRec,0x01 << dir,true)) != (DBObjRecord *) NULL) && (gridIF->Value (layerRec,netIF->Center (fromCell),&elev) == true) && (minElev > elev)) { minElev = elev; dElev = netIF->CellLength (fromCell) * RGlibMinSLOPE; } nextCell = netIF->ToCell (cellRec); for (kernel = 0;(kernel < kernelSize) && (nextCell != (DBObjRecord *) NULL);++kernel) { if(gridIF->Value (layerRec,netIF->Center (nextCell),&elev) != (DBInt) false) { meanElev += elev; count++; } nextCell = netIF->ToCell (nextCell); } if (count > 0) { meanElev = meanElev / count; if (meanElev > minElev - dElev) meanElev = minElev - dElev; gridIF->Value (layerRec,netIF->Center (cellRec),meanElev); prevElev = meanElev; } else gridIF->Value (layerRec,netIF->Center (cellRec),gridIF->MissingValue ()); fromCell = cellRec; } } gridIF->RecalcStats (layerRec); } Stop: UIPauseDialogClose (); delete gridIF; delete netIF; }