void CBibitemView::OnEndlabeleditListFields(NMHDR* pNMHDR, LRESULT* pResult) { if (!m_Updating) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; if (pDispInfo->item.pszText != NULL) { int i = pDispInfo->item.iItem; CField* f = (CField*)m_ListFields.GetItemData(i); if (pDispInfo->item.iSubItem == 0) { // It's the field name f->SetName(pDispInfo->item.pszText); m_ListFields.SetItem(i, pDispInfo->item.iSubItem, LVIF_IMAGE, NULL, m_BibDef->GetRequired(m_BibItem->GetType(), pDispInfo->item.pszText), 0, 0, 0); } else if (pDispInfo->item.iSubItem == 1) { // It's the field value f->SetValue(pDispInfo->item.pszText); } m_ListFields.SetItemText(i, pDispInfo->item.iSubItem, pDispInfo->item.pszText); UpdateMissing(); *pResult = 1; SetModified(m_Modified || f->GetModified()); } else *pResult = 0; } else *pResult = 0; }
/** * Add a filter item */ CField * CBibList::AddFilter(CString name, CString cond) { CBibItem *filter = GetFilter(); if (!filter) filter = New(); CField *flt = filter->New(); flt->SetName(name); flt->SetValue(cond); return flt; }
void CShapefileFeatureClass::InitFields() { m_allFields.clear(); int iField; int lFieldnum =DBFGetFieldCount(m_dbfHandle); char szFieldName[20]; int nWidth, nPrecision; char chNativeType; DBFFieldType eDBFType; //获得属性字段的信息 for( iField = 0; m_dbfHandle != NULL && iField < lFieldnum; iField++ ) { CField *pField =new CField(); chNativeType = DBFGetNativeFieldType( m_dbfHandle, iField ); eDBFType = DBFGetFieldInfo( m_dbfHandle, iField, szFieldName, &nWidth, &nPrecision ); pField->SetName(szFieldName); pField->SetLength(nWidth); pField->SetPrecision(nPrecision); if( chNativeType == 'D' ) { /* XXX - mloskot: * Shapefile date has following 8-chars long format: 20060101. * OGR splits it as YYYY/MM/DD, so 2 additional characters are required. * Is this correct assumtion? What about time part of date? * Shouldn't this format look as datetime: YYYY/MM/DD HH:MM:SS * with 4 additional characters? */ pField->SetLength( nWidth + 2 ); pField->SetType( FTYPE_DATE ); } else if( eDBFType == FTDouble ) pField->SetType( FTYPE_DOUBLE); else if( eDBFType == FTInteger ) pField->SetType(FTYPE_LONG); else if(eDBFType==FTLogical) pField->SetType(FTYPE_BOOL); else pField->SetType( FTYPE_STRING); m_allFields.push_back(CFieldPtr(pField)); } }
void CBibitemView::OnInsertitemListFields(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if (!m_Updating) { CField* f = new CField(m_TmpItem); // Name CString tmp = m_ListFields.GetItemText(pNMListView->iItem, 0); f->SetName(tmp); m_TmpItem->AddTail((CObject*)f); m_ListFields.SetItemData(pNMListView->iItem, (DWORD)f); SetModified(TRUE); } *pResult = 0; }
void CBibitemView::OnPopupLocalurl() { CString f, fn; f.Format(_T("%s||"), AfxLoadString(IDS_STRING_ALLFILTER)); CFileDialogEx dlg(TRUE, NULL, fn, OFN_HIDEREADONLY | OFN_ENABLESIZING, f, this); if (dlg.DoModal() == IDOK) { CField *fi = m_TmpItem->Find(STR_LOCALURL); if (fi == NULL) { fi = m_TmpItem->New(); fi->SetName(STR_LOCALURL); fi->SetValue(EncodeFilename(dlg.GetPathName())); } else { CString val = fi->GetValue(); if (!val.IsEmpty()) val += _T("; ") + EncodeFilename(dlg.GetPathName()); else val = EncodeFilename(dlg.GetPathName()); fi->SetValue(val); } SetModified(); PopulateFields(); } }
int CBibitemView::AddField(CString name, CString value, BOOL edit) { BeginUpdate(); int i = m_ListFields.InsertItem(m_ListFields.GetItemCount(), name, R_UNKNOWN); CField *fi = new CField(m_TmpItem); fi->SetName(name); if (!value.IsEmpty()) { m_ListFields.SetItemText(i, 1, value); fi->SetValue(value); } m_TmpItem->AddTail((CObject*)fi); m_ListFields.SetItemData(i, (DWORD)fi); m_ListFields.EnsureVisible(i, FALSE); UINT is = m_ListFields.GetItemState(i, LVIF_STATE); m_ListFields.SetItemState(i, is | LVIS_SELECTED | LVIS_FOCUSED, LVIF_STATE); m_ListFields.SetFocus(); EndUpdate(); if (edit) CEdit* edt = m_ListFields.EditSubItem(i, 0); return i; }
void CShapefileFeatureClass::Init() { //获得矢量的图形类型 switch( m_shpHandle->nShapeType ) { case SHPT_POINT: case SHPT_POINTM: case SHPT_POINTZ: m_lshptype =GEOMETRY::geom::GEOS_POINT; break; case SHPT_ARC: case SHPT_ARCM: case SHPT_ARCZ: m_lshptype =GEOMETRY::geom::GEOS_MULTILINESTRING; break; case SHPT_MULTIPOINT: case SHPT_MULTIPOINTM: case SHPT_MULTIPOINTZ: m_lshptype =GEOMETRY::geom::GEOS_MULTIPOINT; break; case SHPT_POLYGON: case SHPT_POLYGONM: case SHPT_POLYGONZ: m_lshptype =GEOMETRY::geom::GEOS_POLYGON; break; default: m_lshptype =GEOMETRY::geom::GEOM_NULL; break; } int iField; int lFieldnum =DBFGetFieldCount(m_dbfHandle); char szFieldName[20]; int nWidth, nPrecision; char chNativeType; DBFFieldType eDBFType; //获得属性字段的信息 for( iField = 0; m_dbfHandle != NULL && iField < lFieldnum; iField++ ) { CField *pField =new CField(); chNativeType = DBFGetNativeFieldType( m_dbfHandle, iField ); eDBFType = DBFGetFieldInfo( m_dbfHandle, iField, szFieldName, &nWidth, &nPrecision ); pField->SetName(szFieldName); pField->SetLength(nWidth); pField->SetPrecision(nPrecision); if( chNativeType == 'D' ) { /* XXX - mloskot: * Shapefile date has following 8-chars long format: 20060101. * OGR splits it as YYYY/MM/DD, so 2 additional characters are required. * Is this correct assumtion? What about time part of date? * Shouldn't this format look as datetime: YYYY/MM/DD HH:MM:SS * with 4 additional characters? */ pField->SetLength( nWidth + 2 ); pField->SetType( FTYPE_DATE ); } else if( eDBFType == FTDouble ) pField->SetType( FTYPE_DOUBLE); else if( eDBFType == FTInteger ) pField->SetType(FTYPE_LONG); else pField->SetType( FTYPE_STRING); m_allFields.push_back(CFieldPtr(pField)); } //获得投影信息 ReadPrj(); //如果记录大于10000条,则建立空间索引 if(m_shpHandle->nRecords>=SPATIALINDEX_MIN_SHAPE) { BuildSpatialIndex(); } }
void CBibitemView::PopulateFields() { // At the moment nothing is selected m_SelField = -1; BeginUpdate(); int l = -1, c = -1; m_ListFields.GetEditPos(l, c); m_ListFields.DeleteAllItems(); POSITION h = m_TmpItem->GetHeadPosition(); CField* fi; int j = 0; for (int i = 0; i < m_TmpItem->GetCount(); i++) { fi = (CField*)m_TmpItem->GetNext(h); if (fi) { j = m_ListFields.InsertItem(j, fi->GetName(), m_BibDef->GetRequired(m_TmpItem->GetType(), fi->GetName())); m_ListFields.SetItemText(j, 1, fi->GetValue()); m_ListFields.SetItemData(j, (DWORD)fi); } if (h == NULL) break; } // Add all other fields CField *finew; CBibItem *bi = m_BibDef->FindType(m_TmpItem->GetType()); if (bi != NULL) { h = bi->GetHeadPosition(); for (i = 0; i < bi->GetCount(); i++) { fi = (CField*)bi->GetNext(h); if (fi != NULL && m_TmpItem->Find(fi->GetName()) == NULL) { finew = m_TmpItem->New(); finew->SetName(fi->GetName()); finew->SetModified(FALSE); j = m_ListFields.InsertItem(j, finew->GetName(), m_BibDef->GetRequired(m_TmpItem->GetType(), finew->GetName())); m_ListFields.SetItemText(j, 1, _T("")); m_ListFields.SetItemData(j, (DWORD)finew); } if (h == NULL) break; } } // Sort it LVSORTPARAM ss; ss.iHeader = 0; ss.pListView = &m_ListFields; ss.bSortAsc = TRUE; // Sort the list m_ListFields.SortItems(SortFunc, (LPARAM)&ss); m_SortAsc = FALSE; // Edit the last cell if any if (l > -1 && c > -1) { if (l >= m_ListFields.GetItemCount()) { m_ListFields.CancelEdit(TRUE); m_ListFields.EditSubItem(m_ListFields.GetItemCount()-1, c); } else m_ListFields.EditSubItem(l, c); } m_ListFields.UpdateEditor(); EndUpdate(); }