📄 namegisview.cpp
字号:
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateHotelFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_HOTEL))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateBankFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_BANK))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateStationFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_GAS))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateMovieFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_MOVIE))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateRestFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_RESTAURANT))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateWCFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_WC))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdatePostFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_POST))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateLibraryFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_LIBRAY))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateBusStaFtr(CCmdUI* pCmdUI)
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
if (pMainWnd->m_environment.GetLayerVisible(MO_STATION))
pCmdUI->SetCheck(TRUE);
else
pCmdUI->SetCheck(FALSE);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowAllFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断当前地物的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_HOSPITAL);
// 如果没有显示,则显示所有地物
environment->SetLayerVisible(MO_BANK, !bVisibled, dScale);
environment->SetLayerVisible(MO_GAS, !bVisibled,dScale);
environment->SetLayerVisible(MO_HOSPITAL, !bVisibled, dScale);
environment->SetLayerVisible(MO_HOTEL, !bVisibled, dScale);
environment->SetLayerVisible(MO_LIBRAY, !bVisibled, dScale);
environment->SetLayerVisible(MO_MOVIE, !bVisibled,dScale);
environment->SetLayerVisible(MO_POST,!bVisibled, dScale);
environment->SetLayerVisible(MO_RESTAURANT, !bVisibled,dScale);
environment->SetLayerVisible(MO_SCHOOL, !bVisibled, dScale);
environment->SetLayerVisible(MO_SHOP, !bVisibled, dScale);
environment->SetLayerVisible(MO_STATION, !bVisibled, dScale);
environment->SetLayerVisible(MO_TOUR, !bVisibled, dScale);
environment->SetLayerVisible(MO_WC, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowShopFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断当前地物的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_SHOP);
environment->SetLayerVisible(MO_SHOP, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowTourFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断当前地物的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_TOUR);
environment->SetLayerVisible(MO_TOUR, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowSchoolFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断当前地物的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_SCHOOL);
environment->SetLayerVisible(MO_SCHOOL, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowHospitalFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断医院的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_HOSPITAL);
environment->SetLayerVisible(MO_HOSPITAL, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowHotelFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断宾馆的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_HOTEL);
environment->SetLayerVisible(MO_HOTEL, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowBankFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断银行的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_BANK);
environment->SetLayerVisible(MO_BANK, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowStationFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); //地图比例尺
// 判断加油站的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_GAS);
environment->SetLayerVisible(MO_GAS, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowMovieFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断电影音乐厅的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_MOVIE);
environment->SetLayerVisible(MO_MOVIE, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowRestaurantFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断餐馆的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_RESTAURANT);
environment->SetLayerVisible(MO_RESTAURANT, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowWCFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断WC的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_WC);
environment->SetLayerVisible(MO_WC, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowPostFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断邮局的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_POST);
environment->SetLayerVisible(MO_POST, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowLibraryFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断图书馆的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_LIBRAY);
environment->SetLayerVisible(MO_LIBRAY, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnShowBusStationFeature()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); // 地图比例尺
// 判断公交站点的显示状态
BOOL bVisibled = environment->GetLayerVisible(MO_SHOP);
environment->SetLayerVisible(MO_SHOP, !bVisibled, dScale);
m_Map.SetExtent(m_Map.GetExtent());
pMainWnd->ReloadLayerCtrlView();
}
//----------------------------------------------------------------------------------------------
//功能:缩放时,重新设置注记、符号的大小
void CNameGisView::ReLabelLayers()
{
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CEnvironment* environment = &(pMainWnd->m_environment);
double dScale = environment->CalcScale(&m_Map); //地图比例尺
/*if (environment->m_selectedSymbol != NULL)
{
environment->m_selectedSymbol.SetSize(ReCalcFontSize(environment->m_selectedSymbol.GetSize(), dScale));
}*/
//放大缩小时,循环设置图层的符号和注记
for (int i = 0; i < environment->m_nLayerNum; i ++)
{
//图层不显示,下一个循环
if (!environment->m_layerInfos[i].bVisible)
continue;
//重新设置注记
if (environment->m_layerInfos[i].bLable &&
environment->CalcScale(&m_Map)<environment->m_layerInfos[i].dScale)
{
CMoLabelPlacer myRD = environment->m_layerInfos[i].layer.GetRenderer();
if (myRD != NULL && myRD.GetField() != "")
{
CMoTextSymbol textSym(myRD.GetDefaultSymbol());
CMoFont fnt;
fnt.InitializeFont();
fnt.SetName(textSym.GetFont().GetName());
fnt.SetSize(ReCalcFontSize(
environment->m_layerInfos[i].nFontSize,dScale));
textSym.SetFont(fnt.GetFontDispatch());
}
else
{
if ( myRD == NULL)
{
//设置注记
myRD.CreateDispatch(_T("MapObjects2.LabelPlacer"));
}
if(myRD.GetField() == "")
myRD.SetField("名称");
myRD.SetDrawBackground(environment->m_layerInfos[i].bBackground) ;
myRD.SetAllowDuplicates(TRUE);
myRD.SetMaskLabels(FALSE);
if (environment->m_layerInfos[i].layer.GetShapeType() == moShapeTypeLine)
myRD.SetPlaceAbove(TRUE);
else
myRD.SetPlaceAbove(FALSE);
myRD.SetPlaceOn(TRUE);
CMoFont fnt;
fnt.InitializeFont();
fnt.SetName(pMainWnd->FONTNAME);
fnt.SetSize(ReCalcFontSize(
environment->m_layerInfos[i].nFontSize,dScale));
myRD.GetDefaultSymbol().SetFont(fnt.GetFontDispatch());
environment->m_layerInfos[i].layer.SetRenderer(myRD);
}
}
else
{
//显示比例尺小于注记显示比例尺,则不显示注记
if (environment->m_layerInfos[i].bLable)
{
CMoLabelPlacer myRD = environment->m_layerInfos[i].layer.GetRenderer();
if (myRD != NULL)
myRD.SetField("");
}
}
//重新设置图层的符号
if (environment->m_layerInfos[i].layer.GetSymbol() != NULL
&& environment->m_layerInfos[i].layer.GetShapeType() == moShapeTypePoint)
{
environment->m_layerInfos[i].layer.GetSymbol().SetSize(
ReCalcFontSize(environment->m_layerInfos[i].nSymSize, dScale));
}
}
//街道注记
if (environment->m_layerRoad)
{
CMoLabelPlacer roadRD = environment->m_layerRoad.GetRenderer();
if (dScale < 100000)
{
roadRD.SetField("名称");
CMoTextSymbol textSym(roadRD.GetDefaultSymbol());
CMoFont fnt;
fnt.InitializeFont();
fnt.SetName(textSym.GetFont().GetName());
fnt.SetSize(ReCalcFontSize(10,dScale));
textSym.SetFont(fnt.GetFontDispatch());
}
else
{
roadRD.SetField("");
}
}
}
//----------------------------------------------------------------------------------------------
// 功能:根据显示比例,返回符号和注记的大小。
// <param name="nSize">short,原始大小</param>
// <param name="dScale">double,当前显示比例</param>
// <returns>short,返回计算后的符号和注记的大小</returns>
short CNameGisView::ReCalcFontSize(short nSize,double dScale)
{
if (dScale > 15000)
return nSize;
if (dScale > 10000)
return (short)(nSize * 1.0);
return (short)(nSize * 1.0);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnZoomIn()
{
if(m_nCurTool == ID_MAP_ZOOMIN)
{
m_nCurTool = NULL;
m_Map.SetMousePointer(moArrow);
}
else
{
m_nCurTool = ID_MAP_ZOOMIN;
m_Map.SetMousePointer(moZoomIn);
}
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateZoomIn(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_nCurTool == ID_MAP_ZOOMIN);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnZoomOut()
{
if(m_nCurTool == ID_MAP_ZOOMOUT)
{
m_nCurTool = NULL;
m_Map.SetMousePointer(moArrow);
}
else
{
m_nCurTool = ID_MAP_ZOOMOUT;
m_Map.SetMousePointer(moZoomOut);
}
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdateZoomOut(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_nCurTool == ID_MAP_ZOOMOUT);
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnFullExtent()
{
m_Map.SetExtent(m_Map.GetFullExtent());
ReLabelLayers();
ReShowLayers();
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CHawkView* pHawkView = (CHawkView*)(pMainWnd->m_wndSplitter2.GetPane(1,0));
pHawkView->m_HawkMap.SetExtent(pHawkView->m_HawkMap.GetExtent());
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnPanMap()
{
if(m_nCurTool == ID_MAP_PAN)
{
m_nCurTool = NULL;
m_Map.SetMousePointer(moArrow);
}
else
{
m_nCurTool = ID_MAP_PAN;
m_Map.SetMousePointer(moPan);
}
}
//----------------------------------------------------------------------------------------------
void CNameGisView::OnUpdatePanMap(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_nCurTool == ID_MAP_PAN);
}
//----------------------------------------------------------------------------------------------
BEGIN_EVENTSINK_MAP(CNameGisView, CFormView)
ON_EVENT(CNameGisView, IDC_MAP1, DISPID_MOUSEDOWN, MouseDownMap1, VTS_I2 VTS_I2 VTS_I4 VTS_I4)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -