本文整理汇总了C++中DBObjTableField类的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTableField类的具体用法?C++ DBObjTableField怎么用?C++ DBObjTableField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBObjTableField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _RGISGrpPanelNewCBK
static void _RGISGrpPanelNewCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
char *groupName;
DBDataset *dataset = UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group;
DBObjRecord *record;
if ((groupName = UIGetString ((char *) "Group Name",16)) == (char *) NULL) return;
if (groupTable == (DBObjTable *) NULL)
{
DBObjTable *items = dbData->Table (DBrNItems);
DBObjectLIST<DBObjTable> *tables = dbData->Tables ();
DBTableFieldDefinition fieldDefs [] = {
DBTableFieldDefinition (groupName, DBTableFieldInt,(char *) "%1d",sizeof (DBByte)),
DBTableFieldDefinition () };
tables->Add (groupTable = new DBObjTable (DBrNGroups,fieldDefs));
grpPanel->Groups (groupTable->Fields ());
group = groupTable->Field (groupName);
for (record = items->First ();record != (DBObjRecord *) NULL;record = items->Next ())
group->Int (groupTable->Add (record->Name ()),true);
}
else
{
groupTable->AddField (group = new DBObjTableField (groupName,DBTableFieldInt,"%1d",sizeof (DBByte)));
for (record = groupTable->First ();record != (DBObjRecord *) NULL;record = groupTable->Next ())
group->Int (record,true);
}
grpPanel->Add (group);
}
示例2: switch
DBObjRecord *DBVectorIF::Item (DBCoordinate coord) const
{
DBObjRecord *record, *retRecord = (DBObjRecord *) NULL;
switch (DataPTR->Type ())
{
case DBTypeVectorPoint:
{
DBFloat dist, minDist = DBHugeVal;
DBObjTableField *coordFLD = ItemTable->Field (DBrNCoord);
DBMathDistanceFunction distFunc = DBMathGetDistanceFunction (DataPTR);
for (record = FirstItem ();record != (DBObjRecord *) NULL;record = NextItem ())
{
dist = DBMathCoordinateDistance (distFunc,coord,coordFLD->Coordinate (record));
if (dist < minDist) { minDist = dist; retRecord = record; }
}
} break;
case DBTypeVectorLine: break;
case DBTypeVectorPolygon: break;
default: CMmsgPrint (CMmsgAppError, "Unknown Vector Data Type in: %s %d",__FILE__,__LINE__); break;
}
return (retRecord);
}
示例3: DBObject
DBObjData::DBObjData(DBObjData &data) : DBObject(data), DBDataHeader(data._Header()) {
DBObjTable *table;
DBObjRecord *record, *obj;
DBObjTableField *field;
DBObjectLIST<DBObjTableField> *fields;
strcpy(FileNameSTR, "");
TablesPTR = new DBObjectLIST<DBObjTable>(*data.TablesPTR);
DocsPTR = new DBObjectLIST<DBObjRecord>(*data.DocsPTR);
ArraysPTR = new DBObjectLIST<DBObjRecord>(*data.ArraysPTR);
DispPTR = new DBObjectLIST<DBObject>("Data Display");
LinkedDataPTR = (DBObjData *) NULL;
for (table = TablesPTR->First(); table != (DBObjTable *) NULL; table = TablesPTR->Next()) {
fields = table->Fields();
for (record = table->First(); record != (DBObjRecord *) NULL; record = table->Next()) {
for (field = fields->First(); field != (DBObjTableField *) NULL; field = fields->Next())
switch (field->Type()) {
case DBTableFieldTableRec:
case DBTableFieldDataRec:
if ((obj = field->Record(record)) != NULL)
field->Record(record, (DBObjRecord *) ((char *) NULL + obj->RowID()));
else field->Record(record, (DBObjRecord *) DBFault);
break;
}
}
}
BuildFields();
}
示例4: RedefineField
void DBObjTable::RedefineField(DBObjTableField *field, DBObjTableField *newField) {
DBInt recID, fieldID;
DBObjRecord *record, *oldRecord;
DBObjTableField *tmpField;
newField->StartByte(field->StartByte());
if (field->Length() != newField->Length()) {
RecordLengthVAR += (newField->Length() - field->Length());
for (fieldID = field->RowID() + 1; fieldID < FieldNum(); ++fieldID) {
tmpField = Field(fieldID);
tmpField->StartByte(tmpField->StartByte() + newField->Length() - field->Length());
}
}
for (recID = 0; recID < ItemNum(); recID++) {
record = Item(recID);
oldRecord = new DBObjRecord(*record);
if (field->Length() != newField->Length()) {
record->Realloc(RecordLengthVAR);
if (newField->StartByte() + newField->Length() < RecordLengthVAR)
memcpy(((char *) record->Data()) + newField->StartByte() + newField->Length(),
((char *) oldRecord->Data()) + field->StartByte() + field->Length(),
RecordLengthVAR - (newField->StartByte() + newField->Length()));
}
switch (newField->Type()) {
case DBTableFieldString:
newField->String(record, field->String(oldRecord));
break;
case DBTableFieldInt:
newField->Int(record, field->Int(oldRecord));
break;
case DBTableFieldFloat:
newField->Float(record, field->Float(oldRecord));
break;
case DBTableFieldDate:
newField->Date(record, field->Date(oldRecord));
break;
case DBTableFieldCoord:
newField->Coordinate(record, field->Coordinate(oldRecord));
break;
case DBTableFieldRegion:
newField->Region(record, field->Region(oldRecord));
break;
case DBTableFieldPosition:
newField->Position(record, field->Position(oldRecord));
break;
case DBTableFieldTableRec:
case DBTableFieldDataRec:
newField->Record(record, field->Record(oldRecord));
break;
}
delete oldRecord;
}
if (strcmp(field->Name(), newField->Name()) != 0) field->Name(newField->Name());
if (field->Type() != newField->Type()) field->Type(newField->Type());
if (field->FormatWidth() != newField->FormatWidth()) field->FormatWidth(newField->FormatWidth());
if ((field->Type() == DBTableFieldFloat) && (field->FormatDecimals() != field->FormatDecimals()))
field->FormatDecimals(newField->FormatDecimals());
if (field->Length() != newField->Length()) field->Length(newField->Length());
}
示例5: RGISAnNetworkToGridCBK
void RGISAnNetworkToGridCBK (Widget widget,RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
char *selection;
DBInt dataType;
DBDataset *dataset = UIDataset ();
DBObjData *netData = dataset->Data ();
DBObjTable *cellTable = netData->Table (DBrNCells);
DBObjTableField *field;
DBObjData *grdData;
static Widget select = NULL;
if (select == NULL) select = UISelectionCreate ((char *) "Field Selection");
selection = UISelectObject (select,(DBObjectLIST<DBObject> *) (cellTable->Fields ()),DBTableFieldIsSimple);
if (selection == (char *) NULL) return;
if ((field = cellTable->Field (selection)) == (DBObjTableField *) NULL)
{ CMmsgPrint (CMmsgAppError,"Corrupt Network Dataset in: %s %d",__FILE__,__LINE__); return; }
if (DBTableFieldIsCategory (field) && DBTableFieldIsNumeric (field))
{
DBObjData *tmpData;
tmpData = new DBObjData ("",DBTypeGrid);
tmpData->Document (DBDocGeoDomain,netData->Document (DBDocGeoDomain));
tmpData->Document (DBDocSubject,field->Name ());
if (UIDataHeaderForm (tmpData))
{
grdData = DBNetworkToGrid (netData,tmpData->Type ());
grdData->Name (tmpData->Name ());
grdData->Document (DBDocGeoDomain,tmpData->Document (DBDocGeoDomain));
grdData->Document (DBDocSubject,tmpData->Document (DBDocSubject));
grdData->Document (DBDocVersion,tmpData->Document (DBDocVersion));
grdData->Document (DBDocCitationRef,tmpData->Document (DBDocCitationRef));
grdData->Document (DBDocCitationInst,tmpData->Document (DBDocCitationInst));
grdData->Document (DBDocSourceInst,tmpData->Document (DBDocSourceInst));
grdData->Document (DBDocSourcePerson,tmpData->Document (DBDocSourcePerson));
grdData->Document (DBDocOwnerPerson,tmpData->Document (DBDocOwnerPerson));
grdData->Document (DBDocComment,tmpData->Document (DBDocComment));
delete tmpData;
}
else { return; }
}
else
{
if (DBTableFieldIsCategory (field)) dataType = DBTypeGridDiscrete;
else if (DBTableFieldIsNumeric (field)) dataType = DBTypeGridContinuous;
else
{
CMmsgPrint (CMmsgAppError,"Invalid field type in: %s %d",__FILE__,__LINE__);
return;
}
grdData = DBNetworkToGrid (netData,dataType);
if (UIDataHeaderForm (grdData) == false) { delete grdData; return; }
}
UIPauseDialogOpen ((char *) "Converting Network to Grid");
if (RGlibNetworkToGrid (netData,field,grdData) == DBSuccess) workspace->CurrentData (grdData);
else delete grdData;
UIPauseDialogClose ();
}
示例6: UIAuxSetLabelString
void UIAttribView::Draw (DBObjRecord *record)
{
DBObjTableField *field;
DBObjectLIST<DBObjTableField> *fields;
UIXYGraphShell *graphCLS;
if (record == (DBObjRecord *) NULL)
{
Cardinal i, numChildren;
WidgetList rowCols;
UIAuxSetLabelString (ItemNameWGT,(char *) "");
XtVaGetValues (FieldsRowCol,XmNchildren, &rowCols, XmNnumChildren, &numChildren,NULL);
for (i = 0;i < numChildren; ++i)
XmTextFieldSetString (XtNameToWidget (rowCols [i],"UIAttribViewTextField"),(char *) "");
return;
}
UIAuxSetLabelString (ItemNameWGT,record->Name ());
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) DrawField (field->Name (),field->String (record));
break;
case DBTypeGridContinuous:
{
DBCoordinate coord = *((DBCoordinate *) (record->Data ()));
DBGridIF *gridIF = new DBGridIF (DataPTR);
for (record = ItemTable->First ();record != (DBObjRecord *) NULL;record = ItemTable->Next ())
DrawField (record->Name (),gridIF->ValueString (record,coord));
delete gridIF;
} break;
case DBTypeNetwork:
{
DBObjTable *cellTable = DataPTR->Table (DBrNCells);
DBObjTableField *basinFLD = cellTable->Field (DBrNBasin);
DBObjRecord *basinRec;
if ((basinRec = ItemTable->Item (basinFLD->Int (record) - 1)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "BasinID Error in:%s %d",__FILE__,__LINE__); return; }
DrawField ((char *) "Basin Name",basinRec->Name ());
fields = ItemTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (basinRec));
fields = cellTable->Fields ();
for (field = fields->First ();field != (DBObjTableField *) NULL;field = fields->Next ())
if (DBTableFieldIsVisible (field) == true) DrawField (field->Name (),field->String (record));
} break;
default: break;
}
if ((graphCLS = (UIXYGraphShell *) DataPTR->Display (UIXYGraphShellStr)) != (UIXYGraphShell *) NULL)
graphCLS->Configure (record);
}
示例7: DBTableFieldIsOptional
DBInt DBTableFieldIsOptional(const DBObject *obj) {
DBObjTableField *tableField = (DBObjTableField *) obj;
switch (tableField->Type()) {
case DBTableFieldString:
case DBTableFieldInt:
case DBTableFieldFloat:
case DBTableFieldDate:
return (tableField->Required() ? false : true);
default:
return (false);
}
}
示例8: DBTableFieldIsVisible
DBInt DBTableFieldIsVisible(const DBObject *obj) {
DBObjTableField *tableField = (DBObjTableField *) obj;
switch (tableField->Type()) {
case DBTableFieldString:
case DBTableFieldInt:
case DBTableFieldFloat:
case DBTableFieldDate:
return (strlen(tableField->Format()) > 0 ? true : false);
default:
return (false);
}
}
示例9: Extent
DBRegion DBObjData::Extent(DBObjRecord *record) {
DBRegion extent;
DBCoordinate coord;
DBFloat delta;
DBObjTable *items;
DBObjTableField *field;
if (record == (DBObjRecord *) NULL) return (Extent());
switch (Type()) {
case DBTypeVectorPoint:
delta = pow((double) 10.0, (double) Precision());
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNCoord);
coord = field->Coordinate(record);
extent.Expand(coord + delta);
extent.Expand(coord - delta);
return (extent);
case DBTypeVectorLine:
case DBTypeVectorPolygon:
items = TablesPTR->Item(DBrNItems);
field = items->Field(DBrNRegion);
return (field->Region(record));
case DBTypeGridDiscrete:
case DBTypeGridContinuous:
return (Extent());
case DBTypeNetwork: {
DBInt cellID, cellNum;
DBObjRecord *cellRec;
DBNetworkIF *netIF = new DBNetworkIF(this);
cellRec = netIF->MouthCell(record);
cellNum = netIF->CellBasinCells(cellRec) + cellRec->RowID();
for (cellID = cellRec->RowID(); cellID < cellNum; ++cellID) {
cellRec = netIF->Cell(cellID);
extent.Expand(netIF->Center(cellRec) + (netIF->CellSize() / 2.0));
extent.Expand(netIF->Center(cellRec) - (netIF->CellSize() / 2.0));
}
delete netIF;
}
return (extent);
case DBTypeTable:
default:
return (extent);
}
}
示例10: RGISEditNetAddBasinXYCBK
void RGISEditNetAddBasinXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBInt basinID;
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBNetworkIF *netIF = new DBNetworkIF (dbData);
DBObjTable *itemTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = itemTable->Field (RGISNetMouthXCoord);
DBObjTableField *yCoordFLD = itemTable->Field (RGISNetMouthYCoord);
DBCoordinate coord;
DBObjRecord *basinRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,itemTable));
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISNetMouthXCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISNetMouthYCoord,DBTableFieldFloat,(char *) "%10.3f",sizeof (DBFloat4));
itemTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (basinID = 0;basinID < netIF->BasinNum ();++basinID)
{
basinRec = netIF->Basin (basinID);
if (UIPause (80 + basinID * 20 / netIF->BasinNum ())) goto Stop;
coord = netIF->Center (netIF->MouthCell (basinRec));
xCoordFLD->Float (basinRec,coord.X);
yCoordFLD->Float (basinRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例11: RGISEditPointAddXYCBK
void RGISEditPointAddXYCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)
{
DBDataset *dataset = UIDataset ();
DBObjData *dbData =dataset->Data ();
DBVPointIF *pntIF = new DBVPointIF (dbData);
DBObjTable *pointTable = dbData->Table (DBrNItems);
DBObjTableField *xCoordFLD = pointTable->Field (RGISEditPointXCoord);
DBObjTableField *yCoordFLD = pointTable->Field (RGISEditPointYCoord);
DBCoordinate coord;
DBObjRecord *pointRec;
UITable *tableCLS = (UITable *) dbData->Display (UITableName (dbData,pointTable));
widget = widget; workspace = workspace; callData = callData;
UIPauseDialogOpen ((char *) "Adding XY Coordinates");
if (xCoordFLD == NULL)
{
xCoordFLD = new DBObjTableField (RGISEditPointXCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (xCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (xCoordFLD);
UIPause (40);
}
if (yCoordFLD == NULL)
{
yCoordFLD = new DBObjTableField (RGISEditPointYCoord,DBTableFieldFloat,"%10.3f",sizeof (DBFloat4));
pointTable->AddField (yCoordFLD);
if (tableCLS != (UITable *) NULL) tableCLS->AddField (yCoordFLD);
UIPause (80);
}
for (pointRec = pntIF->FirstItem (); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem ())
{
if (UIPause (80 + pointRec->RowID () * 20 / pntIF->ItemNum ())) goto Stop;
coord = pntIF->Coordinate (pointRec);
xCoordFLD->Float (pointRec,coord.X);
yCoordFLD->Float (pointRec,coord.Y);
}
Stop:
UIPauseDialogClose ();
if (tableCLS != (UITable *) NULL) tableCLS->Draw ();
}
示例12: DeleteField
void DBObjTable::DeleteField(DBObjTableField *delField) {
DBInt i, recID, fieldID;
DBObjRecord *record;
DBObjTableField *field;
unsigned char *data;
for (fieldID = 0; fieldID < FieldPTR->ItemNum(); ++fieldID) {
field = FieldPTR->Item(fieldID);
if (field->StartByte() > delField->StartByte())
field->StartByte(field->StartByte() - delField->Length());
}
for (recID = 0; recID < ItemNum(); ++recID) {
record = Item(recID);
data = (unsigned char *) record->Data() + delField->StartByte();
for (i = 0; i < RecordLengthVAR - delField->StartByte() - delField->Length(); ++i)
data[i] = data[i + delField->Length()];
record->Realloc(RecordLengthVAR - delField->Length());
}
FieldPTR->Remove(delField);
RecordLengthVAR -= delField->Length();
delete delField;
}
示例13: RGlibPointSubbasinCenter
DBInt RGlibPointSubbasinCenter(DBObjData *pntData, DBObjData *netData) {
DBCoordinate massCoord;
DBVPointIF *pntIF = new DBVPointIF(pntData);
DBObjTable *pointTable = pntData->Table(DBrNItems);
DBObjTableField *massCoordXFLD = pointTable->Field(RGlibMassCoordX);
DBObjTableField *massCoordYFLD = pointTable->Field(RGlibMassCoordY);
DBNetworkIF *netIF = new DBNetworkIF(netData);
DBObjRecord *pointRec, *cellRec;
if (massCoordXFLD == NULL) {
massCoordXFLD = new DBObjTableField(RGlibMassCoordX, DBTableFieldFloat, "%10.3f", sizeof(DBFloat4));
pointTable->AddField(massCoordXFLD);
}
if (massCoordYFLD == NULL) {
massCoordYFLD = new DBObjTableField(RGlibMassCoordY, DBTableFieldFloat, "%10.3f", sizeof(DBFloat4));
pointTable->AddField(massCoordYFLD);
}
for (pointRec = pntIF->FirstItem(); pointRec != (DBObjRecord *) NULL; pointRec = pntIF->NextItem()) {
if ((pointRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) {
massCoordXFLD->Float(pointRec, massCoordXFLD->FloatNoData());
massCoordYFLD->Float(pointRec, massCoordYFLD->FloatNoData());
continue;
}
if (DBPause(pointRec->RowID() * 100 / pntIF->ItemNum())) goto Stop;
if ((cellRec = netIF->Cell(pntIF->Coordinate(pointRec))) == (DBObjRecord *) NULL)
massCoord = pntIF->Coordinate(pointRec);
else {
if (netIF->CellBasinCells(cellRec) > 1) {
massCoord.X = 0.0;
massCoord.Y = 0.0;
netIF->UpStreamSearch(cellRec, (DBNetworkACTION) _RGlibSubbasinCenterAction, &massCoord);
massCoord.X = massCoord.X / (DBFloat) netIF->CellBasinCells(cellRec);
massCoord.Y = massCoord.Y / (DBFloat) netIF->CellBasinCells(cellRec);
}
else massCoord = netIF->Center(cellRec);
}
massCoordXFLD->Float(pointRec, massCoord.X);
massCoordYFLD->Float(pointRec, massCoord.Y);
}
Stop:
if (pointRec != (DBObjRecord *) NULL) {
pointTable->DeleteField(massCoordXFLD);
pointTable->DeleteField(massCoordYFLD);
return (DBFault);
}
return (DBSuccess);
}
示例14: _RGISGrpPanelSaveCBK
static void _RGISGrpPanelSaveCBK (Widget widget,RGISGrpPanel *grpPanel,XmAnyCallbackStruct *callData)
{
DBInt rowID;
DBDataset *dataset= UIDataset ();
DBObjData *dbData = dataset->Data ();
DBObjTable *itemTable = dbData->Table (DBrNItems);
DBObjTable *groupTable = dbData->Table (DBrNGroups);
DBObjTableField *group;
DBObjRecord *itemRec, *groupRec;
UITable *tableCLS;
if (groupTable == (DBObjTable *) NULL) return;
group = grpPanel->Current ();
for (rowID = 0;rowID < groupTable->ItemNum ();++rowID)
{
groupRec = groupTable->Item (rowID);
itemRec = itemTable->Item (rowID);
group->Int (groupRec,(itemRec->Flags () & DBObjectFlagSelected) == DBObjectFlagSelected ? true : false);
}
if ((tableCLS = (UITable *) dbData->Display (UITableName (dbData,groupTable))) != (UITable *) NULL)
tableCLS->Draw ();
}
示例15: LoadPoints
DBInt LoadPoints (FILE *file,DBObjTable *points,DBRegion *extent)
{
DBInt swap = DBByteOrder (DBByteOrderLITTLE), pointNum = 0;;
DBObjTableField *coordField = points->Field (DBrNCoord);
DBObjRecord *record;
DBCoordinate coord;
if (coordField == (DBObjTableField *) NULL)
{
CMmsgPrint (CMmsgAppError, "Corrupt Point Data Block in: %s %d",__FILE__,__LINE__);
return (DBFault);
}
for (record = points->First ();record != (DBObjRecord *) NULL;record = (DBObjRecord *) points->Next ())
{
if (Read (file,swap) == DBFault) return (DBFault);
DBPause ((++pointNum * 100)/ points->ItemNum ());
coord.X = CoordX;
coord.Y = CoordY;
extent->Expand (coord);
coordField->Coordinate (record,coord);
}
return (DBSuccess);
}