Esempio n. 1
0
void RGISAnalyseLineMSampleGridCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	DBInt layerID, layerNum;
	DBCoordinate coord;
	DBFloat realValue;
	DBDataset *dataset  = UIDataset ();
	DBObjData *dbData  = dataset->Data ();
	DBObjData *grdData  = dbData->LinkedData ();
	DBObjData *tblData;
	DBObjTable *table, *itemTable = dbData->Table (DBrNItems);
	DBObjTableField *lineIDFLD;
	DBObjTableField *layerIDFLD;
	DBObjTableField *layerNameFLD;
	DBObjTableField *fromValueFLD = (DBObjTableField *) NULL;
	DBObjTableField *toValueFLD = (DBObjTableField *) NULL;
	DBVLineIF	*lineIF = (DBVLineIF *)	 NULL;
	DBGridIF *gridIF;
	DBObjRecord *record, *layerRec, *tblRec;
	DBObjectLIST<DBObjTableField> *fields;

	widget = widget; callData = callData;

	gridIF = new DBGridIF (grdData);
	for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
		{
		layerRec = gridIF->Layer (layerID);
		if ((layerRec->Flags () & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
		}
	if (layerNum < 1)
		{ CMmsgPrint (CMmsgAppError, "No Layer to Process in: %s %d",__FILE__,__LINE__); delete gridIF; return; }


	tblData  = new DBObjData ("",DBTypeTable);
	tblData->Document (DBDocGeoDomain,dbData->Document (DBDocGeoDomain));
	tblData->Document (DBDocSubject,grdData->Document (DBDocSubject));

	if (UIDataHeaderForm (tblData) == false) { delete gridIF; delete tblData; return; }
	table = tblData->Table (DBrNItems);

	lineIF = new DBVLineIF (dbData);

	table->AddField (lineIDFLD =		new DBObjTableField ("GHAASPointID",DBTableFieldInt,	"%8d",sizeof (DBInt)));
	table->AddField (layerIDFLD =		new DBObjTableField ("LayerID",		DBTableFieldInt,	"%4d",sizeof (DBShort)));
	table->AddField (layerNameFLD =	new DBObjTableField ("LayerName",	DBTableFieldString,"%s",DBStringLength));
	table->AddField (fromValueFLD =	new DBObjTableField (RGISLineFromNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));
	table->AddField (toValueFLD =		new DBObjTableField (RGISLineToNodeValue,DBTableFieldFloat,gridIF->ValueFormat (),sizeof (DBFloat4)));

	grdData->Flags (DBObjectFlagProcessed,DBSet);
	UIPauseDialogOpen ((char *) "Sampling Grid(s)");
	for (layerID = 0;layerID < gridIF->LayerNum ();++layerID)
		{
		layerRec = gridIF->Layer (layerID);
		if ((layerRec->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
		for (record = itemTable->First ();record != (DBObjRecord *) NULL;record = itemTable->Next ())
			{
			if (UIPause ((layerRec->RowID () * itemTable->ItemNum () + record->RowID ()) * 100 / (itemTable->ItemNum () * gridIF->LayerNum ()))) goto Stop;
			if ((record->Flags () & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
			tblRec = table->Add (record->Name ());
			lineIDFLD->Int (tblRec,record->RowID () + 1);
			layerIDFLD->Int (tblRec,layerRec->RowID ());
			layerNameFLD->String (tblRec,layerRec->Name ());
			coord = lineIF->FromCoord (record);
			if (gridIF->Value (layerRec,coord,&realValue))
				fromValueFLD->Float (tblRec,realValue);
			coord = lineIF->ToCoord (record);
			if (gridIF->Value (layerRec,coord,&realValue))
				toValueFLD->Float (tblRec,realValue);
			}
		}
Stop:
	UIPauseDialogClose ();
	delete gridIF;
	delete lineIF;

	fields = new DBObjectLIST<DBObjTableField> ("Field List");
	fields->Add (new DBObjTableField (*lineIDFLD));
	fields->Add (new DBObjTableField (*layerIDFLD));
	table->ListSort (fields);
	workspace->CurrentData  (tblData);
	delete fields;
	}
Esempio n. 2
0
UIAttribView::UIAttribView (DBObjData *data) : DBObject (data->Name (),sizeof (UIAttribView))

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

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

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

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

			fields =  cellTable->Fields ();
			for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
				if (DBTableFieldIsVisible (field) == true)	NewField (field->Name (),field->Format ());
			} break;
		default:	break;
		}
	XtManageChild (mainForm);
	UILoop ();
	}