Exemple #1
0
int UIYesOrNo(char *message) {
    static int answer;
    Widget dShell;
    static Widget dialogWidget = NULL;
    XmString messageString;

    if (dialogWidget == NULL) {
        dShell = XtVaCreatePopupShell("UIQuestionDialogShell", xmDialogShellWidgetClass, UITopLevel(),
                                      XmNallowShellResize, true,
                                      XmNtransient, true,
                                      XmNkeyboardFocusPolicy, XmEXPLICIT,
                                      NULL);
        dialogWidget = XtVaCreateManagedWidget("UIQuestionDialog", xmMessageBoxWidgetClass, dShell,
                                               XmNnoResize, true,
                                               XmNautoUnmanage, false,
                                               XmNdialogTitle, XmStringCreate((char *) "Question", UICharSetNormal),
                                               XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
                                               XmNokLabelString, XmStringCreate((char *) "Yes", UICharSetNormal),
                                               XmNcancelLabelString, XmStringCreate((char *) "No", UICharSetNormal),
                                               NULL);
        XtAddCallback(dialogWidget, XmNokCallback, (XtCallbackProc) UIAuxSetBooleanTrueCBK, &answer);
        XtAddCallback(dialogWidget, XmNokCallback, (XtCallbackProc) UILoopStopCBK, 0);
        XtAddCallback(dialogWidget, XmNcancelCallback, (XtCallbackProc) UIAuxSetBooleanFalseCBK, &answer);
        XtAddCallback(dialogWidget, XmNcancelCallback, (XtCallbackProc) UILoopStopCBK, 0);
        XtUnmanageChild(XmMessageBoxGetChild(dialogWidget, XmDIALOG_HELP_BUTTON));
    }
    messageString = XmStringCreate(message, UICharSetNormal);
    XtVaSetValues(dialogWidget, XmNmessageString, messageString, NULL);
    XtManageChild(dialogWidget);
    while (UILoop());
    XtUnmanageChild(dialogWidget);
    XmStringFree(messageString);
    return (answer);
}
Exemple #2
0
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);
	}
Exemple #3
0
void UIDialogFormPopup (Widget widget)

	{
	Dimension actionHeight;

	if (!XtIsManaged (XtNameToWidget (widget,UIDialogBulletinName)))
		{
		Widget *children;
		int numChildren;

		XtVaGetValues (XtNameToWidget (widget,UIDialogPaneName),
								XmNchildren, 			&children,
								XmNnumChildren,		&numChildren, NULL);
		XtManageChild (XtNameToWidget (widget,UIDialogBulletinName));

		while (numChildren-- > 0)
			if (XmIsTraversable (children [numChildren])) XtVaSetValues (children [numChildren],XmNtraversalOn, false, NULL);
		XtVaGetValues (XtNameToWidget (widget,UIDialogActionFormName),XmNheight, &actionHeight, NULL);
		XtVaSetValues (XtNameToWidget (widget,UIDialogActionFormName),XmNpaneMaximum, actionHeight,
																						  XmNpaneMinimum, actionHeight,
																						  NULL);
		}
	XtPopup (widget,XtGrabNone);
	UILoop ();
	}
Exemple #4
0
char *UIFileSelection(Widget widget, int match) {
    XmString dirMask;
    XtVaGetValues(widget, XmNdirMask, &dirMask, NULL);
    XtVaSetValues(widget, XmNmustMatch, match, NULL);
    XmFileSelectionDoSearch(widget, dirMask);
    XtManageChild(widget);
    _UIFileName = NULL;
    while (UILoop());

    XtUnmanageChild(widget);
    return (_UIFileName);
}
Exemple #5
0
char *UIGetString (char *labelText,int length)

	{
	DBInt save = false, strLength = 0;
	XmString string;
	Widget dShell, mainForm, textF;

	dShell = UIDialogForm ((char *) "String Input");
	mainForm = UIDialogFormGetMainForm (dShell);
	textF = XtVaCreateManagedWidget ("UIGetStringTextF",xmTextFieldWidgetClass,mainForm,
								XmNuserData,				mainForm,
								XmNtopAttachment,			XmATTACH_FORM,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			5,
								XmNmaxLength,				length,
								XmNcolumns,					length,
								NULL);
	XtAddCallback (textF,XmNvalueChangedCallback,(XtCallbackProc) _UIGetStringTextValueChangedCBK,(XtPointer) &strLength);
	string = XmStringCreate (labelText,UICharSetBold);
	XtVaCreateManagedWidget ("UITableFieldEditFieldNameLabel",xmLabelGadgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				textF,
								XmNleftAttachment,		XmATTACH_WIDGET,
								XmNleftOffset,				5,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			textF,
								XmNrightOffset,			5,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			textF,
								XmNlabelString,			string,
								NULL);
	XmStringFree (string);
	XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&save);

	UIDialogFormPopup (dShell);
	while (UILoop ())
		XtSetSensitive (UIDialogFormGetOkButton (dShell),strLength > 0);
	UIDialogFormPopdown (dShell);
	XtDestroyWidget (dShell);
	if (strLength > 0) return (XmTextFieldGetString (textF));
	else	return ((char *) NULL);
	}
Exemple #6
0
char *UISelection(Widget widget, char *items, int itemSize, int itemNum) {
    int i;
    XmString *strings;

    if ((strings = (XmString *) calloc(itemNum, sizeof(XmString))) == NULL) {
        CMmsgPrint(CMmsgSysError, "Memory Allocation Error in: %s %d", __FILE__, __LINE__);
        return (NULL);
    }
    for (i = 0; i < itemNum; ++i) strings[i] = XmStringCreate(items + i * itemSize, UICharSetNormal);
    _UISelection = NULL;
    XtVaSetValues(widget, XmNlistItems, strings, XmNlistItemCount, itemNum, NULL);
    XtManageChild(widget);

    while (UILoop());
    XtUnmanageChild(widget);

    for (i = 0; i < itemNum; ++i) XmStringFree(strings[i]);
    free(strings);
    return (_UISelection);
}
Exemple #7
0
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;
		}
	}
Exemple #8
0
void RGISToolsConvertToPointCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	char *nText, *xText, *yText, *selection;
	int allowOk;
	static int convert;
	DBDataset *dataset = UIDataset ();
	DBObjData *dbData  = dataset->Data ();
	DBObjTable *itemTable;
	static Widget tableSelect = (Widget) NULL;
	static Widget dShell = (Widget) NULL, mainForm;
	static Widget nameTextF, xCoordTextF, yCoordTextF;
	XmString string;

	if (tableSelect == (Widget) NULL)	tableSelect = UISelectionCreate ((char *) "Table Selection");
	selection = UISelectObject (tableSelect,(DBObjectLIST<DBObject> *) dbData->Tables ());
	if (selection == (char *) NULL) return;
	if ((itemTable = dbData->Table (selection)) == (DBObjTable *) NULL)
		{ CMmsgPrint (CMmsgAppError, "Invalid Table in: %s %d",__FILE__,__LINE__); return; }

	_RGISToolsConvertToPointFields = itemTable->Fields ();
	if (dShell == (Widget) NULL)
		{
		Widget button;

		dShell = UIDialogForm ((char *) "Convert Table To Point",false);
		mainForm = UIDialogFormGetMainForm (dShell);

		string = XmStringCreate ((char *) "Select",UICharSetBold);
		button = XtVaCreateManagedWidget ("RGISToolsConvertToPointNameButton",xmPushButtonWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_FORM,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			10,
								XmNmarginHeight,			5,
								XmNtraversalOn,			False,
								XmNlabelString,			string,
								XmNuserData,				DBTableFieldIsString,
								NULL);
		XmStringFree (string);
		nameTextF = XtVaCreateManagedWidget ("RGISToolsConvertToPointNameTextF",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) _RGISToolsConvertToPointSelectCBK,nameTextF);
		string = XmStringCreate ((char *) "Name Field:",UICharSetBold);
		XtVaCreateManagedWidget ("RGISToolsConvertToPointNameLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				button,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,				10,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			nameTextF,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			button,
								XmNlabelString,			string,
								NULL);
		XmStringFree (string);

		string = XmStringCreate ((char *) "Select",UICharSetBold);
		button = XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordButton",xmPushButtonWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_WIDGET,
								XmNtopWidget,				button,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			10,
								XmNmarginHeight,			5,
								XmNtraversalOn,			False,
								XmNlabelString,			string,
								XmNuserData,				DBTableFieldIsNumeric,
								NULL);
		XmStringFree (string);
		xCoordTextF = XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordTextF",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) _RGISToolsConvertToPointSelectCBK,xCoordTextF);
		string = XmStringCreate ((char *) "X Coordinate:",UICharSetBold);
		XtVaCreateManagedWidget ("RGISToolsConvertToPointXCoordLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				button,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,				10,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			nameTextF,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			button,
								XmNlabelString,			string,
								NULL);
		XmStringFree (string);

		string = XmStringCreate ((char *) "Select",UICharSetBold);
		button = XtVaCreateManagedWidget ("RGISToolsConvertToPointYCoordButton",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,				DBTableFieldIsNumeric,
								NULL);
		XmStringFree (string);
		yCoordTextF = XtVaCreateManagedWidget ("RGISToolsConvertToPointYCoordTextF",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) _RGISToolsConvertToPointSelectCBK,yCoordTextF);
		string = XmStringCreate ((char *) "Y Coordinate:",UICharSetBold);
		XtVaCreateManagedWidget ("RGISToolsConvertToPointYCoordLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				button,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,				10,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			nameTextF,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			button,
								XmNlabelString,			string,
								NULL);
		XmStringFree (string);
		XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&convert);
		}
	convert = false;
	UIDialogFormPopup (dShell);
	while (UILoop ())
		{
		xText = XmTextFieldGetString (xCoordTextF);
		yText = XmTextFieldGetString (yCoordTextF);
		allowOk = (strlen (xText) > 0) && (strlen (yText) > 0);
		XtFree (xText);	XtFree (yText);
		XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
		}
	UIDialogFormPopdown (dShell);

	if (convert)
		{
		DBObjData *pntData = new DBObjData ("",DBTypeVectorPoint);

		pntData->Name (dbData->Name ());
		pntData->Document (DBDocSubject,dbData->Document (DBDocSubject));
		pntData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain));

		if (UIDataHeaderForm (pntData))
			{
			DBCoordinate coord;
			DBObjTableField *nField, *xField, *yField, *tblFLD, *pntFLD;
			DBObjRecord *tblRec, *pntRec, *symRec;
			DBObjTable *pntTable = pntData->Table (DBrNItems);
			DBObjTable *symbols	= pntData->Table (DBrNSymbols);
			DBObjTableField *symbolIDFLD = symbols->Field (DBrNSymbolID);
			DBObjTableField *fgFLD = symbols->Field (DBrNForeground);
			DBObjTableField *bgFLD = symbols->Field (DBrNBackground);
			DBObjTableField *stFLD = symbols->Field (DBrNStyle);
			DBObjTableField *coordFLD = pntTable->Field (DBrNCoord);
			DBObjTableField *symbolFLD = pntTable->Field (DBrNSymbol);
			DBRegion extent;

			symRec = symbols->Add ("Default Symbol");
			symbolIDFLD->Int (symRec,0);
			fgFLD->Int (symRec,1);
			bgFLD->Int (symRec,2);
			stFLD->Int (symRec,0);

			nText = XmTextFieldGetString (nameTextF);
			xText = XmTextFieldGetString (xCoordTextF);
			yText = XmTextFieldGetString (yCoordTextF);
			nField = _RGISToolsConvertToPointFields->Item (nText);
			xField = _RGISToolsConvertToPointFields->Item (xText);
			yField = _RGISToolsConvertToPointFields->Item (yText);
			XtFree (nText);	XtFree (xText);	XtFree (yText);
			for (tblRec = itemTable->First ();tblRec != (DBObjRecord *) NULL;tblRec = itemTable->Next ())
				{
				if (CMmathEqualValues (coord.X = xField->Float (tblRec),xField->FloatNoData ())) continue;
				if (CMmathEqualValues (coord.Y = yField->Float (tblRec),yField->FloatNoData ())) continue;
				if (nField == (DBObjTableField *) NULL) pntRec = pntTable->Add (tblRec->Name ());
				else pntRec = pntTable->Add (nField->String (tblRec));
				coordFLD->Coordinate (pntRec,coord);
				symbolFLD->Record (pntRec,symRec);
				extent.Expand (coord);
				}
			pntData->Extent (extent);
         pntData->Projection (DBMathGuessProjection (extent));
         pntData->Precision  (DBMathGuessPrecision  (extent));
			for (tblFLD = _RGISToolsConvertToPointFields->First ();tblFLD != (DBObjTableField *) NULL;tblFLD = _RGISToolsConvertToPointFields->Next ())
				if ((tblFLD != nField) && (tblFLD != xField) && (tblFLD != yField) && DBTableFieldIsVisible (tblFLD))
					{
					pntTable->AddField (pntFLD = new DBObjTableField (*tblFLD));
					pntFLD->Required (false);
					pntRec = pntTable->First ();
					for (tblRec = itemTable->First ();tblRec != (DBObjRecord *) NULL;tblRec = itemTable->Next ())
						{
						if (CMmathEqualValues (coord.X = xField->Float (tblRec),xField->FloatNoData ())) continue;
						if (CMmathEqualValues (coord.Y = yField->Float (tblRec),yField->FloatNoData ())) continue;
						switch (tblFLD->Type ())
							{
							case DBTableFieldString:	pntFLD->String	(pntRec,tblFLD->String (tblRec));	break;
							case DBTableFieldInt:		pntFLD->Int		(pntRec,tblFLD->Int (tblRec));		break;
							case DBTableFieldFloat:		pntFLD->Float	(pntRec,tblFLD->Float (tblRec));		break;
							case DBTableFieldDate:		pntFLD->Date	(pntRec,tblFLD->Date (tblRec));		break;
							default: CMmsgPrint (CMmsgAppError, "Invalid Field Type in: %s %d",__FILE__,__LINE__);		break;
							}
						pntRec = pntTable->Next ();
						}
					}
			workspace->CurrentData (pntData);
			}
		else delete pntData;
		}
	}
Exemple #9
0
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 ();
		}
	}
Exemple #10
0
DBInt UIDataHeaderForm(DBObjData *data) {
    char *text;
    DBInt i, edit;
    DBUnsigned var;
    static DBInt dataType, save, changed[10];
    static Widget dShell = NULL;
    static Widget nameTextF, subjectTextF, geoDomTextF, versionTextF, lastModL, ownerL;
    static Widget citRefText, citInstTextF, srcInstTextF, srcPersTextF, commentText;
    static Widget typeMenu;

    if (dShell == NULL) {
        XmString string, select;
        Widget mainForm, label, button, separator;

        var = 0;
        dShell = UIDialogForm((char *) "Data Header Information");
        mainForm = UIDialogFormGetMainForm(dShell);
        select = XmStringCreate((char *) "Select", UICharSetBold);
        string = XmStringCreate((char *) "Name:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormNameLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_FORM,
                                        XmNtopOffset, 10,
                                        XmNrightAttachment, XmATTACH_POSITION,
                                        XmNrightPosition, 25,
                                        XmNrightOffset, 10,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        nameTextF = XtVaCreateManagedWidget("UIDataHeaderFormNameText", xmTextFieldWidgetClass, mainForm,
                                            XmNtopAttachment, XmATTACH_FORM,
                                            XmNtopOffset, 10,
                                            XmNleftAttachment, XmATTACH_WIDGET,
                                            XmNleftWidget, label,
                                            XmNleftOffset, 5,
                                            XmNmaxLength, DBDataNameLen - 1,
                                            XmNcolumns, DBDataNameLen - 1,
                                            NULL);
        XtAddCallback(nameTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK, changed + var++);
        typeMenu = XmCreatePulldownMenu(mainForm, (char *) "UIDataHeaderFormTypeMenu", NULL, 0);
        for (i = 0; i < (int) (sizeof(_UIDataTypeList) / sizeof(UIButtonList)); ++i) {
            string = XmStringCreate(DBDataTypeString(_UIDataTypeList[i].ID), UICharSetNormal);
            _UIDataTypeList[i].Button = XtVaCreateManagedWidget("UIDataHeaderFormTypeButton", xmPushButtonGadgetClass,
                                                                typeMenu,
                                                                XmNuserData, _UIDataTypeList[i].ID,
                                                                XmNlabelString, string,
                                                                NULL);
            XmStringFree(string);
            XtAddCallback(_UIDataTypeList[i].Button, XmNactivateCallback, (XtCallbackProc) _UIDataHeaderFormButtonCBK,
                          &dataType);
        }
        string = XmStringCreate((char *) "Data Type:", UICharSetBold);
        typeMenu = XtVaCreateManagedWidget("UIDataHeaderFormTypeMenu", xmRowColumnWidgetClass, mainForm,
                                           XmNtopAttachment, XmATTACH_WIDGET,
                                           XmNtopWidget, nameTextF,
                                           XmNtopOffset, 2,
                                           XmNrightAttachment, XmATTACH_FORM,
                                           XmNrightOffset, 10,
                                           XmNsubMenuId, typeMenu,
                                           XmNlabelString, string,
                                           XmNrowColumnType, XmMENU_OPTION,
                                           XmNtraversalOn, false,
                                           NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) "Subject:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormSubjectLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, nameTextF,
                                        XmNtopOffset, 10,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        subjectTextF = XtVaCreateManagedWidget("UIDataHeaderFormSubjectField", xmTextFieldWidgetClass, mainForm,
                                               XmNtopAttachment, XmATTACH_WIDGET,
                                               XmNtopWidget, nameTextF,
                                               XmNtopOffset, 10,
                                               XmNleftAttachment, XmATTACH_WIDGET,
                                               XmNleftWidget, label,
                                               XmNleftOffset, 5,
                                               XmNmaxLength, DBDataSubjectLen - 1,
                                               XmNcolumns, DBDataSubjectLen - 1,
                                               NULL);
        XtAddCallback(subjectTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        button = XtVaCreateManagedWidget("UIDataHeaderFormSubjectSelectButton", xmPushButtonWidgetClass, mainForm,
                                         XmNtopAttachment, XmATTACH_WIDGET,
                                         XmNtopWidget, nameTextF,
                                         XmNtopOffset, 10,
                                         XmNleftAttachment, XmATTACH_WIDGET,
                                         XmNleftWidget, subjectTextF,
                                         XmNleftOffset, 5,
                                         XmNrightAttachment, XmATTACH_WIDGET,
                                         XmNrightWidget, typeMenu,
                                         XmNrightOffset, 20,
                                         XmNlabelString, select,
                                         XmNtraversalOn, false,
                                         XmNuserData, (XtArgVal) UIDatasetSubject,
                                         NULL);
        XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) _UIDataHeaderButtonCBK, subjectTextF);


        string = XmStringCreate((char *) "Geograhic Domain:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormGeoDomainLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, subjectTextF,
                                        XmNtopOffset, 10,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        geoDomTextF = XtVaCreateManagedWidget("UIDataHeaderFormGeoField", xmTextFieldWidgetClass, mainForm,
                                              XmNtopAttachment, XmATTACH_WIDGET,
                                              XmNtopWidget, subjectTextF,
                                              XmNtopOffset, 10,
                                              XmNleftAttachment, XmATTACH_WIDGET,
                                              XmNleftWidget, label,
                                              XmNleftOffset, 5,
                                              XmNmaxLength, DBDataSubjectLen - 1,
                                              XmNcolumns, DBDataSubjectLen - 1,
                                              NULL);
        XtAddCallback(geoDomTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        button = XtVaCreateManagedWidget("UIDataHeaderFormGeoDomainSelectButton", xmPushButtonWidgetClass, mainForm,
                                         XmNtopAttachment, XmATTACH_WIDGET,
                                         XmNtopWidget, subjectTextF,
                                         XmNtopOffset, 10,
                                         XmNleftAttachment, XmATTACH_WIDGET,
                                         XmNleftWidget, geoDomTextF,
                                         XmNleftOffset, 5,
                                         XmNrightAttachment, XmATTACH_WIDGET,
                                         XmNrightWidget, typeMenu,
                                         XmNrightOffset, 20,
                                         XmNlabelString, select,
                                         XmNuserData, (XtArgVal) UIDatasetGeoDomain,
                                         XmNtraversalOn, false,
                                         NULL);
        XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) _UIDataHeaderButtonCBK, geoDomTextF);


        versionTextF = XtVaCreateManagedWidget("UIDataHeaderFormVersionText", xmTextFieldWidgetClass, mainForm,
                                               XmNtopAttachment, XmATTACH_WIDGET,
                                               XmNtopWidget, subjectTextF,
                                               XmNtopOffset, 5,
                                               XmNrightAttachment, XmATTACH_FORM,
                                               XmNrightOffset, 10,
                                               XmNcolumns, DBDataVersionLen - 1,
                                               NULL);
        XtAddCallback(versionTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        string = XmStringCreate((char *) "Version:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, subjectTextF,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, versionTextF,
                                        XmNrightOffset, 5,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        separator = XtVaCreateManagedWidget("UIDataHeaderFormSeparator", xmSeparatorWidgetClass, mainForm,
                                            XmNtopAttachment, XmATTACH_WIDGET,
                                            XmNtopWidget, geoDomTextF,
                                            XmNtopOffset, 5,
                                            XmNleftAttachment, XmATTACH_FORM,
                                            XmNleftOffset, 20,
                                            XmNrightAttachment, XmATTACH_FORM,
                                            XmNrightOffset, 20,
                                            NULL);
        string = XmStringCreate((char *) "Citation Reference:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormCitRefLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, separator,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        citRefText = XtVaCreateManagedWidget("UIDataHeaderFormCitRefText", xmTextWidgetClass, mainForm,
                                             XmNtopAttachment, XmATTACH_WIDGET,
                                             XmNtopWidget, separator,
                                             XmNtopOffset, 5,
                                             XmNleftAttachment, XmATTACH_WIDGET,
                                             XmNleftWidget, label,
                                             XmNleftOffset, 5,
                                             XmNmaxLength, DBDataCitationRefLen - 1,
                                             XmNrows, DBDataCitationRefLen / DBDataNameLen,
                                             XmNcolumns, DBDataNameLen - 1,
                                             XmNeditMode, XmMULTI_LINE_EDIT,
                                             XmNwordWrap, true,
                                             NULL);
        XtAddCallback(citRefText, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextCBK, changed + var++);
        string = XmStringCreate((char *) "Citation Institute:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormInstRefLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, citRefText,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNalignment, XmALIGNMENT_END,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        citInstTextF = XtVaCreateManagedWidget("UIDataHeaderFormCitInstText", xmTextFieldWidgetClass, mainForm,
                                               XmNtopAttachment, XmATTACH_WIDGET,
                                               XmNtopWidget, citRefText,
                                               XmNtopOffset, 5,
                                               XmNleftAttachment, XmATTACH_WIDGET,
                                               XmNleftWidget, label,
                                               XmNleftOffset, 5,
                                               XmNmaxLength, DBDataCitationInstLen - 1,
                                               XmNcolumns, DBDataNameLen - 1,
                                               NULL);
        XtAddCallback(citInstTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        string = XmStringCreate((char *) "Source Institue:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormSourceInstLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, citInstTextF,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        srcInstTextF = XtVaCreateManagedWidget("UIDataHeaderFormSourceInstText", xmTextFieldWidgetClass, mainForm,
                                               XmNtopAttachment, XmATTACH_WIDGET,
                                               XmNtopWidget, citInstTextF,
                                               XmNtopOffset, 5,
                                               XmNleftAttachment, XmATTACH_WIDGET,
                                               XmNleftWidget, label,
                                               XmNleftOffset, 5,
                                               XmNmaxLength, DBDataSourceInstLen - 1,
                                               XmNcolumns, DBDataNameLen - 1,
                                               NULL);
        XtAddCallback(srcInstTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        string = XmStringCreate((char *) "Source Person:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormSourcePersonLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, srcInstTextF,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        srcPersTextF = XtVaCreateManagedWidget("UIDataHeaderFormSourcePersText", xmTextFieldWidgetClass, mainForm,
                                               XmNtopAttachment, XmATTACH_WIDGET,
                                               XmNtopWidget, srcInstTextF,
                                               XmNtopOffset, 5,
                                               XmNleftAttachment, XmATTACH_WIDGET,
                                               XmNleftWidget, label,
                                               XmNleftOffset, 5,
                                               XmNmaxLength, DBDataSourcePersonLen - 1,
                                               XmNcolumns, DBDataSourcePersonLen - 1,
                                               NULL);
        XtAddCallback(srcPersTextF, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextFieldCBK,
                      changed + var++);
        string = XmStringCreate((char *) "Last Modification:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, srcInstTextF,
                                        XmNtopOffset, 5,
                                        XmNleftAttachment, XmATTACH_WIDGET,
                                        XmNleftWidget, srcPersTextF,
                                        XmNleftOffset, 10,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) " ", UICharSetNormal);
        lastModL = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelGadgetClass, mainForm,
                                           XmNtopAttachment, XmATTACH_WIDGET,
                                           XmNtopWidget, srcInstTextF,
                                           XmNtopOffset, 5,
                                           XmNleftAttachment, XmATTACH_WIDGET,
                                           XmNleftWidget, label,
                                           XmNleftOffset, 5,
                                           XmNwidth, 100,
                                           XmNrecomputeSize, false,
                                           XmNlabelString, string,
                                           NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) "Last Modification:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, srcInstTextF,
                                        XmNtopOffset, 5,
                                        XmNleftAttachment, XmATTACH_WIDGET,
                                        XmNleftWidget, srcPersTextF,
                                        XmNleftOffset, 10,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) " ", UICharSetNormal);
        lastModL = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelGadgetClass, mainForm,
                                           XmNtopAttachment, XmATTACH_WIDGET,
                                           XmNtopWidget, srcInstTextF,
                                           XmNtopOffset, 5,
                                           XmNleftAttachment, XmATTACH_WIDGET,
                                           XmNleftWidget, label,
                                           XmNleftOffset, 5,
                                           XmNwidth, 100,
                                           XmNrecomputeSize, false,
                                           XmNlabelString, string,
                                           NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) "Owner:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, lastModL,
                                        XmNtopOffset, 5,
                                        XmNleftAttachment, XmATTACH_WIDGET,
                                        XmNleftWidget, srcPersTextF,
                                        XmNleftOffset, 10,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) " ", UICharSetNormal);
        ownerL = XtVaCreateManagedWidget("UIDataHeaderFormVersion", xmLabelGadgetClass, mainForm,
                                           XmNtopAttachment, XmATTACH_WIDGET,
                                           XmNtopWidget, lastModL,
                                           XmNtopOffset, 5,
                                           XmNleftAttachment, XmATTACH_WIDGET,
                                           XmNleftWidget, label,
                                           XmNleftOffset, 5,
                                           XmNwidth, 100,
                                           XmNrecomputeSize, false,
                                           XmNlabelString, string,
                                           NULL);
        XmStringFree(string);
        string = XmStringCreate((char *) "Comment:", UICharSetBold);
        label = XtVaCreateManagedWidget("UIDataHeaderFormCommentLabel", xmLabelWidgetClass, mainForm,
                                        XmNtopAttachment, XmATTACH_WIDGET,
                                        XmNtopWidget, ownerL,
                                        XmNtopOffset, 5,
                                        XmNrightAttachment, XmATTACH_WIDGET,
                                        XmNrightWidget, nameTextF,
                                        XmNrightOffset, 5,
                                        XmNlabelString, string,
                                        NULL);
        XmStringFree(string);
        commentText = XtVaCreateManagedWidget("UIDataHeaderFormCommentText", xmTextWidgetClass, mainForm,
                                              XmNtopAttachment, XmATTACH_WIDGET,
                                              XmNtopWidget, ownerL,
                                              XmNtopOffset, 5,
                                              XmNleftAttachment, XmATTACH_WIDGET,
                                              XmNleftWidget, label,
                                              XmNleftOffset, 5,
                                              XmNbottomAttachment, XmATTACH_FORM,
                                              XmNtopOffset, 10,
                                              XmNmaxLength, DBDataCommentLen - 1,
                                              XmNrows, DBDataCommentLen / DBDataNameLen,
                                              XmNcolumns, DBDataNameLen - 1,
                                              XmNeditMode, XmMULTI_LINE_EDIT,
                                              XmNwordWrap, true,
                                              NULL);
        XtAddCallback(commentText, XmNvalueChangedCallback, (XtCallbackProc) _UIDataHeaderTextCBK, changed + var++);
        XtAddCallback(UIDialogFormGetOkButton(dShell), XmNactivateCallback, (XtCallbackProc) UIAuxSetBooleanTrueCBK,
                      &save);
        XmStringFree(select);
    }

    edit = true;
    for (i = sizeof(_UIDataTypeList) / sizeof(UIButtonList) - 1; i >= 0; --i)
        if ((_UIDataTypeList[i].ID & data->Type()) == data->Type()) {
            XtSetSensitive(_UIDataTypeList[i].Button, true);
            XtVaSetValues(typeMenu, XmNmenuHistory, _UIDataTypeList[i].Button, NULL);
            dataType = _UIDataTypeList[i].ID;
        }
        else XtSetSensitive(_UIDataTypeList[i].Button, false);

    XtVaSetValues(nameTextF, XmNuserData, data->Name(), NULL);
    XmTextFieldSetString(nameTextF, data->Name());
    XmTextFieldSetEditable(nameTextF, edit);

    XtVaSetValues(subjectTextF, XmNuserData, data->Document(DBDocSubject), NULL);
    XmTextFieldSetString(subjectTextF, data->Document(DBDocSubject));
    XmTextFieldSetEditable(subjectTextF, edit);

    XtVaSetValues(geoDomTextF, XmNuserData, data->Document(DBDocGeoDomain), NULL);
    XmTextFieldSetString(geoDomTextF, data->Document(DBDocGeoDomain));
    XmTextFieldSetEditable(geoDomTextF, edit);

    XtVaSetValues(versionTextF, XmNuserData, data->Document(DBDocVersion), NULL);
    XmTextFieldSetString(versionTextF, data->Document(DBDocVersion));
    XmTextFieldSetEditable(versionTextF, edit);

    XtVaSetValues(citRefText, XmNuserData, data->Document(DBDocCitationRef), NULL);
    XmTextSetString(citRefText, data->Document(DBDocCitationRef));
    XmTextSetEditable(citRefText, edit);

    XtVaSetValues(citInstTextF, XmNuserData, data->Document(DBDocCitationInst), NULL);
    XmTextFieldSetString(citInstTextF, data->Document(DBDocCitationInst));
    XmTextFieldSetEditable(citInstTextF, edit);

    XtVaSetValues(srcInstTextF, XmNuserData, data->Document(DBDocSourceInst), NULL);
    XmTextFieldSetString(srcInstTextF, data->Document(DBDocSourceInst));
    XmTextFieldSetEditable(srcInstTextF, edit);

    XtVaSetValues(srcPersTextF, XmNuserData, data->Document(DBDocSourcePerson), NULL);
    XmTextFieldSetString(srcPersTextF, data->Document(DBDocSourcePerson));
    XmTextFieldSetEditable(srcPersTextF, edit);

    XtVaSetValues(commentText, XmNuserData, data->Document(DBDocComment), NULL);
    XmTextSetString(commentText, data->Document(DBDocComment));
    XmTextSetEditable(commentText, edit);

    if (data->LastModification().Year() != DBDefaultMissingIntVal)
        UIAuxSetLabelString (lastModL, data->LastModification().Get());
    else
        UIAuxSetLabelString (lastModL, (char *) " ");
    if ((data->Document(DBDocOwnerPerson) != (char *) NULL) && (strlen(data->Document(DBDocOwnerPerson)) > 0))
        UIAuxSetLabelString (ownerL, data->Document(DBDocOwnerPerson));
    else
        UIAuxSetLabelString (ownerL, (char  *) " ");
    save = false;
    XmProcessTraversal(nameTextF, XmTRAVERSE_CURRENT);
    UIDialogFormPopup(dShell);
    for (i = 0; i < (int) (sizeof(changed) / sizeof(int)); ++i) changed[i] = false;
    while (UILoop()) {
        var = 0;
        text = XmTextFieldGetString(nameTextF);
        if (strlen(text) == 0)
            XtSetSensitive(UIDialogFormGetOkButton(dShell), false);
        else {
            for (i = 0; i < (int) (sizeof(changed) / sizeof(int)); ++i)
                var = changed[i] ? var + 1 : var;
            XtSetSensitive(UIDialogFormGetOkButton(dShell), var > 0);
        }
        XtFree(text);
    }
    UIDialogFormPopdown(dShell);

    if (save) {
        text = XmTextFieldGetString(nameTextF);
        data->Name(text);
        XtFree(text);
        text = XmTextFieldGetString(subjectTextF);
        data->Document(DBDocSubject, text);
        XtFree(text);
        text = XmTextFieldGetString(geoDomTextF);
        data->Document(DBDocGeoDomain, text);
        XtFree(text);
        text = XmTextFieldGetString(versionTextF);
        data->Document(DBDocVersion, text);
        XtFree(text);
        text = XmTextGetString(citRefText);
        data->Document(DBDocCitationRef, text);
        XtFree(text);
        text = XmTextFieldGetString(citInstTextF);
        data->Document(DBDocCitationInst, text);
        XtFree(text);
        text = XmTextFieldGetString(srcInstTextF);
        data->Document(DBDocSourceInst, text);
        XtFree(text);
        text = XmTextFieldGetString(srcPersTextF);
        data->Document(DBDocSourcePerson, text);
        XtFree(text);
        text = XmTextGetString(commentText);
        data->Document(DBDocComment, text);
        XtFree(text);
        if (data->Type() != dataType) data->Type(dataType);
        return (true);
    }
    else return (false);
}
Exemple #11
0
UIAttribView::UIAttribView (DBObjData *data) : DBObject (data->Name (),sizeof (UIAttribView))

	{
	DBObjTableField *field;
	DBObjectLIST<DBObjTableField> *fields;
	Widget mainForm, scrolledW, rowCol, label;
	XmString string;
	Atom deleteWindowAtom = XmInternAtom(XtDisplay(UITopLevel ()),(char *) "WM_DELETE_WINDOW",FALSE);

	DataPTR = data;
	ItemTable = DataPTR->Table (DBrNItems);
	Name (UIAttribViewSTR);
	DShellWGT = XtVaCreatePopupShell ("UIAttribView",xmDialogShellWidgetClass,UITopLevel (),
								XmNkeyboardFocusPolicy, XmPOINTER,
								XmNtitle,               data->Name (),
								XmNtransient,           False,
								XmNminWidth,            400,
								XmNminHeight,           300,
								NULL);
	XmAddWMProtocolCallback (DShellWGT,deleteWindowAtom,(XtCallbackProc) _UIAttribViewDeleteCBK,(XtPointer) this);
	mainForm = XtVaCreateWidget ("UIAttribViewForm",xmFormWidgetClass,DShellWGT,
								XmNshadowThickness,			0,
								NULL);
	string = XmStringCreate ((char *) "Item:",UICharSetBold);
	label = XtVaCreateManagedWidget ("UIAttribViewNameLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_FORM,
								XmNtopOffset,           5,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,          10,
								XmNlabelString,         string,
								XmNrecomputeSize,       False,
								NULL);
	XmStringFree (string);
	string = XmStringCreate ((char *) "",UICharSetNormal);
	ItemNameWGT = XtVaCreateManagedWidget ("UIAttribViewNameText",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_FORM,
								XmNtopOffset,           5,
								XmNleftAttachment,      XmATTACH_WIDGET,
								XmNleftWidget,          label,
								XmNleftOffset,          5,
								XmNlabelString,         string,
								NULL);
	XmStringFree (string);
	scrolledW = XtVaCreateManagedWidget ("UIAttribViewScrolledW",xmScrolledWindowWidgetClass,mainForm,
								XmNtopAttachment,       XmATTACH_WIDGET,
								XmNtopWidget,           label,
								XmNtopOffset,           5,
								XmNleftAttachment,      XmATTACH_FORM,
								XmNleftOffset,          5,
								XmNrightAttachment,     XmATTACH_FORM,
								XmNrightOffset,         5,
								XmNbottomAttachment,    XmATTACH_FORM,
								XmNbottomOffset,        5,
								XmNheight,              150,
								XmNvisualPolicy,        XmCONSTANT,
								XmNscrollingPolicy,     XmAUTOMATIC,
								NULL);
	rowCol = XtVaCreateManagedWidget ("UIAttribViewRowColumn",xmRowColumnWidgetClass,scrolledW,
								XmNnumColumns,          2,
								XmNorientation,         XmHORIZONTAL,
								XmNrowColumnType,       XmWORK_AREA,
								NULL);
	NamesRowCol = XtVaCreateManagedWidget ("UIAttribViewNamesRowColumn",xmRowColumnWidgetClass,rowCol,
								XmNorientation,         XmVERTICAL,
								XmNrowColumnType,       XmWORK_AREA,
								XmNpacking,             XmPACK_COLUMN,
								XmNspacing,             0,
								NULL);
	FieldsRowCol = XtVaCreateManagedWidget ("UIAttribViewNamesRowColumn",xmRowColumnWidgetClass,rowCol,
								XmNorientation,         XmVERTICAL,
								XmNrowColumnType,       XmWORK_AREA,
								XmNspacing,             0,
								NULL);

	switch (DataPTR->Type ())
		{
		case DBTypeVectorPoint:
		case DBTypeVectorLine:
		case DBTypeVectorPolygon:
		case DBTypeGridDiscrete:
			fields = ItemTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());
			break;
		case DBTypeGridContinuous:
			{
			DBObjRecord *record;
			DBGridIF *gridIF = new DBGridIF (DataPTR);
			ItemTable = DataPTR->Table (DBrNLayers);
			for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ())
				NewField (record->Name (),gridIF->ValueFormat ());
			delete gridIF;
			} break;
		case DBTypeNetwork:
			{
			DBObjTable *cellTable = DataPTR->Table (DBrNCells);

			NewField ((char *) "Basin Name",(char *) "%s");
			fields = ItemTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());

			fields =  cellTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());
			} break;
		default:	break;
		}
	XtManageChild (mainForm);
	UILoop ();
	}
Exemple #12
0
int main (int argc,char **argv)

	{
	int argPos, argNum = argc;
	char *metaDB = (char *) NULL;
	int spin = true, progress = true;
	const char *modes [] = { (char *) "yes", (char *) "no", NULL };
	int codes [] = { true, false };
	Widget mainForm;
	RGISWorkspace *workspace;

	for (argPos = 1;argPos < argNum; )
		{
		if (CMargTest (argv [argPos],"-m","--metadb"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError, "Missing metadb argument!"); return (CMfailed); }
			metaDB = argv [argPos];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-p","--progress"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing progress mode!");   return (CMfailed); }
			if ((progress = CMoptLookup (modes,argv [argPos],true)) == DBFault)
				{ CMmsgPrint (CMmsgUsrError,"Invalid progress mode!");   return (CMfailed); }
			progress = codes [progress];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-s","--spin"))
			{
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing spin mode!");       return (CMfailed); }
			if ((spin = CMoptLookup (modes,argv [argPos],true)) == DBFault)
				{ CMmsgPrint (CMmsgUsrError,"Invalid spin mode!");	     return (CMfailed); }
			spin = codes [spin];
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-P","--planet"))
			{
			int planet;
			const char *planets [] = { "Earth", "Mars", "Venus", NULL };
			DBFloat radius [] = { 6371.2213, 6371.2213 * 0.53264, 6371.2213 * 0.94886 };

			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos)
				{ CMmsgPrint (CMmsgUsrError,"Missing planet!");	       return (CMfailed); }
			if ((planet = CMoptLookup (planets,argv [argPos],true)) == DBFault)
				{
				if (sscanf (argv [argPos],"%lf",radius) != 1)
					{ CMmsgPrint (CMmsgUsrError,"Invalid planet!");      return (CMfailed); }
				planet = 0;
				}
			DBMathSetGlobeRadius (radius [planet]);
			if ((argNum = CMargShiftLeft (argPos,argv,argc)) <= argPos) break;
			continue;
			}
		if (CMargTest (argv [argPos],"-h","--help"))
			{
			CMmsgPrint (CMmsgInfo, "rgis [options]");
			CMmsgPrint (CMmsgInfo, "     -m, --metadb   [meta database]");
			CMmsgPrint (CMmsgInfo, "     -p, --progress [yes|no]");
			CMmsgPrint (CMmsgInfo, "     -s, --spin     [yes|no]");
			CMmsgPrint (CMmsgInfo, "     -P, --planet   [Earth|Mars|Venus|radius]");
			CMmsgPrint (CMmsgInfo, "     -h, --help");
			return (DBSuccess);
			}
		if ((argv [argPos][0] == '-') && (strlen (argv [argPos]) > 1))
			{ CMmsgPrint (CMmsgUsrError, "Unknown option: %s!",argv [argPos]); return (DBFault); }
		argPos++;
		}

	workspace = new RGISWorkspace;
	mainForm = UIInitialize ((char *) "GHAAS V2.2 - RiverGIS",(char *) "GHAASrgis",(char *) "RGISMain.html",
									 RGISMainMenu,(void *) workspace,&argc,argv,720,500,(bool) spin,(bool) progress);

	UIDataset ((char *) "GHAASrgis",metaDB);

	XtVaSetValues (mainForm,XmNkeyboardFocusPolicy,		XmPOINTER, NULL);

	workspace->Initialize (mainForm);

	if (argNum > 1)
		{
		DBDataset *dataset;
		DBObjData *data;
		DBObjectLIST<DBObjMetaEntry> *metaList;
		DBObjMetaEntry *metaEntry;

		dataset  = UIDataset ();
		metaList = dataset->MetaList ();

		for (argPos = 1;argPos < argNum; ++argPos)
			{
			data = new DBObjData ();
			if (data->Read (argv [argPos]) == DBSuccess)
				{
				workspace->CurrentData (data);
				metaEntry = metaList->Item (data->Name ());
				metaEntry->FileName (data->FileName ());
				}
			else delete data;
			}
		}
	while (UILoop ());
	delete UIDataset ();
	return (DBSuccess);
	}
Exemple #13
0
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);
	}
Exemple #14
0
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;
		}
	}
Exemple #15
0
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;
		}
	}
Exemple #16
0
void RGISAnGNUXYPlotCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	FILE *file;
	char command [DBDataFileNameLen * 2 + DBStringLength];
	const char *ghaasDir;
	char *f0Text, *f1Text, fileName [12];
	int allowOk, fd;
	static int plot = false, logScale = false;
	DBDataset *dataset = UIDataset ();
	DBObjData *dbData  = dataset->Data ();
	DBObjTable *itemTable = dbData->Table (DBrNItems);
	static Widget dShell = (Widget) NULL, mainForm;
	static Widget field0TextF, field1TextF;
	Widget toggle;
	XmString string;

	if (dShell == (Widget) NULL)
		{
		Widget button;

		dShell = UIDialogForm ((char *) "Compare Fields",false);
		mainForm = UIDialogFormGetMainForm (dShell);

		string = XmStringCreate ((char *) "Select",UICharSetBold);
		button = XtVaCreateManagedWidget ("RGISEdiCompFieldsButton",xmPushButtonWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_FORM,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			10,
								XmNmarginHeight,			5,
								XmNtraversalOn,			False,
								XmNlabelString,			string,
								XmNuserData,				DBTableFieldIsNumeric,
								NULL);
		XmStringFree (string);
		field0TextF = XtVaCreateManagedWidget ("RGISEditCompField0TextF",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,field0TextF);
		string = XmStringCreate ((char *) "X Field:",UICharSetBold);
		XtVaCreateManagedWidget ("RGISEditCompFieldNameLabel",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				button,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,				10,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			field0TextF,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			button,
								XmNlabelString,			string,
								NULL);
		XmStringFree (string);

		string = XmStringCreate ((char *) "Select",UICharSetBold);
		button = XtVaCreateManagedWidget ("RGISEditCompField0Button",xmPushButtonWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_WIDGET,
								XmNtopWidget,				button,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			10,
								XmNmarginHeight,			5,
								XmNtraversalOn,			False,
								XmNlabelString,			string,
								XmNuserData,				DBTableFieldIsNumeric,
								NULL);
		XmStringFree (string);
		field1TextF = XtVaCreateManagedWidget ("RGISEditCompField1TextF",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,field1TextF);
		string = XmStringCreate ((char *) "Y Field:",UICharSetBold);
		XtVaCreateManagedWidget ("RGISEditCompField1Label",xmLabelWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_OPPOSITE_WIDGET,
								XmNtopWidget,				button,
								XmNleftAttachment,		XmATTACH_FORM,
								XmNleftOffset,				10,
								XmNrightAttachment,		XmATTACH_WIDGET,
								XmNrightWidget,			field1TextF,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_OPPOSITE_WIDGET,
								XmNbottomWidget,			button,
								XmNlabelString,			string,
								NULL);
		XmStringFree (string);
		string = XmStringCreate ((char *) "Logarithmic Scale",UICharSetBold);
		toggle = XtVaCreateManagedWidget ("RGISEditCompLogScaleToggle",xmToggleButtonWidgetClass,mainForm,
								XmNtopAttachment,			XmATTACH_WIDGET,
								XmNtopWidget,				button,
								XmNtopOffset,				10,
								XmNrightAttachment,		XmATTACH_FORM,
								XmNrightOffset,			10,
								XmNbottomAttachment,		XmATTACH_FORM,
								XmNbottomOffset,			10,
								XmNlabelString,			string,
								XmNhighlightThickness,	0,
								XmNshadowThickness,		0,
								XmNmarginWidth,			5,
								XmNset,						False,
								NULL);
 		XmStringFree (string);
 		XtAddCallback (toggle,XmNvalueChangedCallback,(XtCallbackProc) UIAuxSetToggleCBK, (XtPointer) &logScale);

		XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&plot);
		}
	plot = false;
	XtVaSetValues (field0TextF,XmNuserData, itemTable->Fields (), NULL);
	XtVaSetValues (field1TextF,XmNuserData, itemTable->Fields (), NULL);
	UIDialogFormPopup (dShell);
	while (UILoop ())
		{
		f0Text = XmTextFieldGetString (field0TextF);
		f1Text = XmTextFieldGetString (field1TextF);
		allowOk = (strlen (f0Text) > 0) && (strlen (f1Text) > 0);
		XtFree (f0Text);	XtFree (f1Text);
		XtSetSensitive (UIDialogFormGetOkButton (dShell),allowOk);
		}
	UIDialogFormPopdown (dShell);

	if (plot)
		{
		char buffer [256];
		DBInt intVal, rowID;
		DBFloat val;
		DBObjTableField *field0 = itemTable->Field (f0Text = XmTextFieldGetString (field0TextF));
		DBObjTableField *field1 = itemTable->Field (f1Text = XmTextFieldGetString (field1TextF));
		DBObjRecord *record;

		XtFree (f0Text);	XtFree (f1Text);
		if ((field0 == (DBObjTableField *) NULL) || (field1 == (DBObjTableField *) NULL))
			{ CMmsgPrint (CMmsgAppError, "Invalid Compare Fields in: %s %d",__FILE__,__LINE__);	return; }

		strcpy (fileName,"ghaasXXXXXX");
		if ((fd = mkstemp (fileName)) == DBFault)
			{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }

		if ((file = fdopen (fd,"w")) == (FILE *) NULL)
			{ CMmsgPrint (CMmsgSysError, "File Opening Error in: %s %d",__FILE__,__LINE__); return; }

		fprintf (file,"\"GHAASId\"\t\"RecordName\"\t\"Selected\"\t\"%s\"\t\"%s\"\n",field0->Name (),field1->Name ());
		for (rowID = 0;rowID < itemTable->ItemNum ();++rowID)
			{
			record = itemTable->Item (rowID);
			if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
			sprintf (buffer,"%d\t\"%s\"\t%d",record->RowID () + 1,record->Name (),
						(record->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected ? true : false);
			if (field0->Type () == DBTableFieldInt)
				{
				intVal = field0->Int (record);
				if (intVal == field0->IntNoData ()) continue;
				sprintf (buffer + strlen (buffer),"\t%d",intVal);
				}
			else
				{
				val = field0->Float (record);
				if (CMmathEqualValues (val,field0->FloatNoData ())) continue;
				sprintf (buffer + strlen (buffer),"\t%f",val);
				}
			if (field1->Type () == DBTableFieldInt)
				{
				intVal = field1->Int (record);
				if (intVal == field1->IntNoData ()) continue;
				sprintf (buffer + strlen (buffer),"\t%d",intVal);
				}
			else
				{
				val = field1->Float (record);
				if (CMmathEqualValues (val,field1->FloatNoData ())) continue;
				sprintf (buffer + strlen (buffer),"\t%f",val);
				}
			fprintf (file,"%s\n",buffer);
			}
		fclose (file);
		ghaasDir = getenv ("GHAAS_DIR");
		sprintf (command,"%s/Scripts/xy-plot.sh %s %s",ghaasDir != (const char *) NULL ? ghaasDir : ".",fileName,logScale ? "log" : "normal");
		system (command);
		unlink (fileName);
		}
	}
Exemple #17
0
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;
		}
	}