spatialinfodlg.cpp
来自「用VC+SuperMap开发的校园GIS系统」· C++ 代码 · 共 162 行
CPP
162 行
// SpatialInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CampusGis.h"
#include "SpatialInfoDlg.h"
#include "sorecordset.h"
#include "sodatasetvector.h"
#include "sogeometry.h"
#include "sorect.h"
#include "sogeoline.h"
#include "sogeoregion.h"
#include "soselection.h"
#include "sopoint.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSpatialInfoDlg dialog
CSpatialInfoDlg::CSpatialInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSpatialInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSpatialInfoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSpatialInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSpatialInfoDlg)
DDX_Control(pDX, IDC_LAYERINFO, m_LayerInfo);
DDX_Control(pDX, IDC_LISTINFO, m_ListInfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSpatialInfoDlg, CDialog)
//{{AFX_MSG_MAP(CSpatialInfoDlg)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSpatialInfoDlg message handlers
BOOL CSpatialInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CRect rcClient;
GetClientRect(rcClient);//获得客户区的大小
m_ListInfo.InsertColumn(0,"字段名",LVCFMT_LEFT,rcClient.Width()/2,-1);
m_ListInfo.InsertColumn(1,"字段值",LVCFMT_LEFT,rcClient.Width()/2,-1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSpatialInfoDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
// CRect rc;
// GetClientRect(rc);
// if(::IsWindow(m_ListInfo.m_hWnd))
// {
// m_ListInfo.MoveWindow(rc);
// }
}
BOOL CSpatialInfoDlg::AddSpatialInfo(CSuperMap *pSupermap)
{
CsoRecordset recordset;
CsoGeometry geometry;
CsoRect rect;
CsoGeoLine geoline;
CsoGeoRegion georegion;
CString strName,strInfo;
int nItemIndex;
if(pSupermap->GetSelection().GetCount() > 0 && pSupermap->GetAction()==5/*scaSelect*/)
{
recordset=pSupermap->GetSelection().ToRecordset(false);
if(!recordset)
{
AfxMessageBox("数据集错误!");
return false;
}
}
strName=pSupermap->GetSelection().GetDataset().GetName();
m_LayerInfo.SetWindowText(strName);
geometry=recordset.GetGeometry();
if(!geometry)
{
AfxMessageBox("几何对象错误!");
return false;
}
else
{
rect=geometry.GetBounds();
if(!rect)
{
AfxMessageBox("区域对象错误!");
return false;
}
else
{
m_ListInfo.DeleteAllItems();
nItemIndex=m_ListInfo.InsertItem(0,_T("左上角的X"));
strInfo.Format("%f",rect.TopLeft().GetX());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(1,_T("左上角的Y"));
strInfo.Format("%f",rect.TopLeft().GetY());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(2,_T("右下角的X"));
strInfo.Format("%f",rect.BottomRight().GetX());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(3,_T("右下角的Y"));
strInfo.Format("%f",rect.BottomRight().GetY());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(4,_T("中心点的X"));
strInfo.Format("%f",rect.CenterPoint().GetX());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(5,_T("中心点的Y"));
strInfo.Format("%f",rect.BottomRight().GetY());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(6,_T("高度"));
strInfo.Format("%f",rect.Height());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
nItemIndex=m_ListInfo.InsertItem(7,_T("宽度"));
strInfo.Format("%f",rect.Width());
m_ListInfo.SetItemText(nItemIndex,1,strInfo);
strInfo=_T("");
if(geometry.GetType()==3 /*scgLine*/)
geoline=(CsoGeoLine )geometry;
else if(geometry.GetType()==5 /*scgRegion*/)
georegion=(CsoGeoRegion )geometry;
}
}
return true;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?