Пример #1
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);
	}
Пример #2
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;
		}
	}
Пример #3
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 ();
		}
	}
Пример #4
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);
}
Пример #5
0
int UISymbolEdit (DBObjTable *symbols,int symbolType)

	{
	int symNum;
	static int changed, save;
	static Widget dShell = NULL;
	XmString string;
	UISymbol **editSymbols;
	DBObjRecord *symRecord;

	if (dShell == NULL)
		{
		char symString [20];
		int depth;
		Pixel foreground, background;
		XGCValues xgcv;
		GC gc;
		Widget mainForm, scrolledW, list, label, button, text, foreMenu, backMenu, rowCol, symMenu;
		Pixmap markerPixmap, labelPixmap;

		dShell = UIDialogForm ((char *) "Symbol Edit");
		mainForm = UIDialogFormGetMainForm (dShell);
		scrolledW = XtVaCreateManagedWidget ("UISymScrolledWindow",xmScrolledWindowWidgetClass,mainForm,
													XmNtopAttachment,		XmATTACH_FORM,
													XmNleftAttachment,	XmATTACH_FORM,
													XmNrightAttachment,	XmATTACH_FORM,
													NULL);
		list = XtVaCreateManagedWidget (UISymListName + 1,xmListWidgetClass,scrolledW,
													XmNvisibleItemCount,	6,
													XmNselectionPolicy,	XmBROWSE_SELECT,
													XmNscrollBarDisplayPolicy,	XmSTATIC,
													NULL);
		XtAddCallback (list,XmNbrowseSelectionCallback,(XtCallbackProc) _UISymbolListSelectCBK,dShell);
		string = XmStringCreate ((char *) "Symbol",UICharSetNormal);
		label = XtVaCreateManagedWidget ("UISymbolLabel",xmLabelWidgetClass,mainForm,
													XmNtopAttachment,		XmATTACH_WIDGET,
													XmNtopWidget,			scrolledW,
													XmNleftAttachment,	XmATTACH_FORM,
													XmNlabelString,		string,
													NULL);
		XmStringFree (string);
		string = XmStringCreate ((char *) "Load Names",UICharSetNormal);
		button = XtVaCreateManagedWidget (UISymLoadNamesButtonName + 1,xmPushButtonWidgetClass,mainForm,
													XmNtopAttachment,		XmATTACH_WIDGET,
													XmNtopWidget,			label,
													XmNrightAttachment,	XmATTACH_FORM,
													XmNlabelString,		string,
													NULL);
		XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolLoadNamesCBK,list);
		XmStringFree (string);
		text = XtVaCreateManagedWidget (UISymTextFieldName + 1,xmTextFieldWidgetClass,mainForm,
													XmNtopAttachment,		XmATTACH_WIDGET,
													XmNtopWidget,			label,
													XmNleftAttachment,	XmATTACH_FORM,
													XmNrightAttachment,	XmATTACH_WIDGET,
													XmNrightWidget,		button,
													XmNrightOffset,		5,
													NULL);
		XtAddCallback (text,XmNvalueChangedCallback,(XtCallbackProc) _UISymbolTextValueChangedCBK,list);
		XtAddCallback (text,XmNvalueChangedCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);

		foreMenu = XmCreatePulldownMenu (mainForm,(char *) "UISymForegroundMenuPane",NULL,0);
		backMenu = XmCreatePulldownMenu (mainForm,(char *) "UISymBackgroundMenuPane",NULL,0);

		for (symNum = 0;symNum <  UIColorNum (UIColorStandard);symNum++)
			{
			foreground = UIColor (UIColorStandard,symNum);
			_UISymSetButtonString (symString,symNum);
			string = XmStringCreate (UIStandardColorName(symNum),UICharSetNormal);
			button =  XtVaCreateManagedWidget (symString + 1,xmPushButtonWidgetClass,foreMenu,
													XmNuserData,			symNum,
													XmNforeground,			foreground,
													XmNlabelString,		string,
													NULL);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolSetForegroundCBK,text);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);
			button =  XtVaCreateManagedWidget (symString + 1,xmPushButtonWidgetClass,backMenu,
													XmNuserData,			symNum,
													XmNforeground,			foreground,
													XmNlabelString,		string,
													NULL);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolSetBackgroundCBK,text);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);
			XmStringFree (string);
			}

		string = XmStringCreate ((char *) "Foreground:",UICharSetNormal);
		foreMenu = XtVaCreateManagedWidget (UISymForegroundMenuName + 1,xmRowColumnWidgetClass,mainForm,
													XmNtopAttachment,			XmATTACH_WIDGET,
													XmNtopWidget,				text,
													XmNrightAttachment,		XmATTACH_FORM,
													XmNsubMenuId,				foreMenu,
													XmNlabelString,			string,
													XmNrowColumnType,			XmMENU_OPTION,
													XmNtraversalOn,			false,
													NULL);
		XmStringFree (string);
		string = XmStringCreate ((char *) "Background:",UICharSetNormal);
		backMenu = XtVaCreateManagedWidget (UISymBackgroundMenuName + 1,xmRowColumnWidgetClass,mainForm,
													XmNtopAttachment,			XmATTACH_WIDGET,
													XmNtopWidget,				foreMenu,
													XmNrightAttachment,		XmATTACH_FORM,
													XmNsubMenuId,				backMenu,
													XmNlabelString,			string,
													XmNrowColumnType,			XmMENU_OPTION,
													XmNtraversalOn,			false,
													NULL);
		rowCol = XtVaCreateManagedWidget ("UISymbolRowCol",xmRowColumnWidgetClass,mainForm,
													XmNtopAttachment,			XmATTACH_WIDGET,
													XmNtopWidget,				backMenu,
													XmNrightAttachment,		XmATTACH_FORM,
													XmNbottomAttachment,		XmATTACH_FORM,
													NULL);
		XtVaGetValues (mainForm,XmNforeground,	&foreground,XmNbackground,	&background,NULL);
		xgcv.foreground = foreground;
		xgcv.background = background;
		xgcv.fill_style = FillTiled;
		gc = XCreateGC (XtDisplay (UITopLevel ()),XtWindow (UITopLevel ()),GCForeground | GCBackground | GCFillStyle,&xgcv);

		symMenu = XmCreatePulldownMenu (rowCol,(char *) "UISymShadeMenuPane",NULL,0);
		depth = DefaultDepth (XtDisplay (UITopLevel ()),DefaultScreen (XtDisplay (UITopLevel ())));
		for (symNum = 0;(xgcv.tile = UIPattern (symNum,foreground,background)) != (Pixmap) NULL;symNum++)
			{
			labelPixmap = XCreatePixmap (XtDisplay (UITopLevel ()),XtWindow (UITopLevel ()),96,24,depth);
			XChangeGC (XtDisplay (UITopLevel ()),gc,GCTile,&xgcv);
			XFillRectangle (XtDisplay (UITopLevel ()),labelPixmap,gc,0,0,96,24);
			XFreePixmap (XtDisplay (UITopLevel ()),xgcv.tile);

			_UISymSetButtonString(symString,symNum);
			button = XtVaCreateManagedWidget (symString + 1,xmPushButtonGadgetClass,symMenu,
													XmNuserData,				symNum,
													XmNlabelType,				XmPIXMAP,
													XmNlabelPixmap,			labelPixmap,
													NULL);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolSetStyleCBK,text);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);
			}
		string = XmStringCreate ((char *) "Shade:",UICharSetNormal);
		symMenu = XtVaCreateWidget (UISymShadeMenuName + 1,xmRowColumnWidgetClass,rowCol,
													XmNsubMenuId,				symMenu,
													XmNlabelString,			string,
													XmNrowColumnType,			XmMENU_OPTION,
													XmNtraversalOn,			false,
													NULL);
		XmStringFree (string);

		xgcv.foreground = background;
		xgcv.fill_style = FillSolid;
		XChangeGC (XtDisplay (UITopLevel ()),gc,GCForeground | GCFillStyle,&xgcv);
		symMenu = XmCreatePulldownMenu (rowCol,(char *) "UISymMarkerMenuPane",NULL,0);
		depth = DefaultDepth (XtDisplay (UITopLevel ()),DefaultScreen (XtDisplay (UITopLevel ())));
		for (symNum = 0;(markerPixmap = UIMarker (symNum,foreground,background)) != (Pixmap) NULL;symNum++)
			{
			labelPixmap = XCreatePixmap (XtDisplay (UITopLevel ()),XtWindow (UITopLevel ()),96,24,depth);
			XFillRectangle (XtDisplay (UITopLevel ()),labelPixmap,gc,0,0,96,24);
			XCopyArea (XtDisplay (UITopLevel ()),markerPixmap,labelPixmap,gc,0,0,11,11,42,6);
			XFreePixmap (XtDisplay (UITopLevel ()),markerPixmap);
			_UISymSetButtonString(symString,symNum);
			button = XtVaCreateManagedWidget (symString + 1,xmPushButtonGadgetClass,symMenu,
													XmNuserData,				symNum,
													XmNlabelType,				XmPIXMAP,
													XmNlabelPixmap,			labelPixmap,
													NULL);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolSetStyleCBK,text);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);
			}
		string = XmStringCreate ((char *) "Marker:",UICharSetNormal);
		symMenu = XtVaCreateWidget (UISymMarkerMenuName + 1,xmRowColumnWidgetClass,rowCol,
													XmNsubMenuId,				symMenu,
													XmNlabelString,			string,
													XmNrowColumnType,			XmMENU_OPTION,
													XmNtraversalOn,			false,
													NULL);
		XmStringFree (string);

		symMenu = XmCreatePulldownMenu (rowCol,(char *) "UISymLineMenuPane",NULL,0);
		depth = DefaultDepth (XtDisplay (UITopLevel ()),DefaultScreen (XtDisplay (UITopLevel ())));
		for (symNum = 0;symNum < 12;symNum++)
			{
			labelPixmap = XCreatePixmap (XtDisplay (UITopLevel ()),XtWindow (UITopLevel ()),96,24,depth);
			xgcv.foreground = background;
			xgcv.fill_style = FillSolid;
			XChangeGC (XtDisplay (UITopLevel ()),gc,GCForeground | GCFillStyle,&xgcv);
			XFillRectangle (XtDisplay (UITopLevel ()),labelPixmap,gc,0,0,96,24);
			xgcv.line_width = symNum & 0x03;
			switch (symNum >> 0x02)
				{
				case 0:	xgcv.line_style = LineSolid;		break;
				case 1:	xgcv.line_style = LineOnOffDash;	break;
				case 2:	xgcv.line_style = LineDoubleDash;	break;
				}
			xgcv.foreground = foreground;
			xgcv.background = UIColor (UIColorStandard,0);
			XChangeGC (XtDisplay (UITopLevel ()),gc,GCForeground | GCBackground | GCLineWidth | GCLineStyle,&xgcv);
			XDrawLine (XtDisplay (UITopLevel ()),labelPixmap,gc,0,12,96,12);
			_UISymSetButtonString(symString,symNum);
			button = XtVaCreateManagedWidget (symString + 1,xmPushButtonGadgetClass,symMenu,
													XmNuserData,				symNum,
													XmNlabelType,				XmPIXMAP,
													XmNlabelPixmap,			labelPixmap,
													NULL);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) _UISymbolSetStyleCBK,text);
			XtAddCallback (button,XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&changed);
			}
		string = XmStringCreate ((char *) "Line:",UICharSetNormal);
		symMenu = XtVaCreateWidget (UISymLineMenuName + 1,xmRowColumnWidgetClass,rowCol,
													XmNsubMenuId,				symMenu,
													XmNlabelString,			string,
													XmNrowColumnType,			XmMENU_OPTION,
													XmNtraversalOn,			false,
													NULL);
		XmStringFree (string);
		XtAddCallback (UIDialogFormGetOkButton (dShell),XmNactivateCallback,(XtCallbackProc) UIAuxSetBooleanTrueCBK,&save);
		}
Пример #6
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);
	}
Пример #7
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;
		}
	}
Пример #8
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);
		}
	}
Пример #9
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;
		}
	}
Пример #10
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;
		}
	}
Пример #11
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;
		}
	}
Пример #12
0
Widget UIDialogForm (char *dialogTitle) { return (UIDialogForm (dialogTitle,true)); }