📄 geoexpertview.cpp
字号:
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miPanTool);
}
void CGeoExpertView::OnUpdateMapToolSelect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miSelectTool);
}
void CGeoExpertView::OnUpdateMapToolRectangleselect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miRectSelectTool);
}
void CGeoExpertView::OnUpdateMapToolRadiusselect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miRadiusSelectTool);
}
void CGeoExpertView::OnUpdateMapToolPolygonselect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miPolygonSelectTool);
}
void CGeoExpertView::OnUpdateMapToolCenter(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miCenterTool);
}
void CGeoExpertView::OnViewProjection()
{
// TODO: Add your command handler code here
try {
VARIANT vHelpFile, vHelpID; // mark as optional since we don't have a helpfile
vHelpFile.vt = VT_ERROR;
vHelpFile.scode = DISP_E_PARAMNOTFOUND;
vHelpID.vt = VT_ERROR;
vHelpID.scode = DISP_E_PARAMNOTFOUND;
CMapXCoordSys csys = m_ctrlMapX.GetDisplayCoordSys();
csys.PickCoordSys(vHelpFile, vHelpID);
m_ctrlMapX.SetNumericCoordSys(csys);
}
catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
}
catch (COleException *e) {
e->ReportError();
e->Delete();
}
}
void CGeoExpertView::OnViewProperties()
{
// TODO: Add your command handler code here
try {
m_ctrlMapX.PropertyPage();
}
catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
}
catch (COleException *e) {
e->ReportError();
e->Delete();
}
}
void CGeoExpertView::OnMapToolInfotool()
{
// TODO: Add your command handler code here
m_ctrlMapX.SetCurrentTool(INFO_TOOL);
if (!m_bInfoDlg)
{
m_InfoDlg = new CInfoDlg;
m_InfoDlg->Create(IDD_INFO_DLG,NULL);
m_InfoDlg->ShowWindow(SW_SHOW);
m_InfoDlg->OnInitDlg();
m_bInfoDlg = TRUE;
}
}
void CGeoExpertView::OnViewLayercontrol()
{
// TODO: Add your command handler code here
try {
VARIANT vHelpFile, vHelpID; // mark as optional since we don't have a helpfile
vHelpFile.vt = VT_ERROR;
vHelpFile.scode = DISP_E_PARAMNOTFOUND;
vHelpID.vt = VT_ERROR;
vHelpID.scode = DISP_E_PARAMNOTFOUND;
CMapXLayers layers = m_ctrlMapX.GetLayers();
layers.LayersDlg(vHelpFile, vHelpID);
}
catch (COleDispatchException *e) {
e->ReportError();
e->Delete();
}
catch (COleException *e) {
e->ReportError();
e->Delete();
}
}
void CGeoExpertView::OnInfoToolUsed(short ToolNum, double X1, double Y1, double X2, double Y2, double Distance, BOOL Shift, BOOL Ctrl, BOOL *EnableDefault)
{
if (ToolNum == INFO_TOOL)
{
int iCount = 0;
iCount = m_ctrlMapX.GetLayers().GetCount();
CMapXPoint pt; //This point will be the center of our search
CMapXFeatures fs; //This will hold all of the features within our search
CMapXFeature f; //This will hold the customer feature we are currently
CMapXLayer layer;
pt.CreateDispatch(pt.GetClsid()); //Creates a dispatch for the point
pt.Set(X1,Y1); //Sets the coordinates into the point
double dLayerZoomMax,dLayerZoomMin;
double dMapZoom;
dMapZoom = m_ctrlMapX.GetZoom();
for (int i = 1; i <= iCount; i++)
{
layer = m_ctrlMapX.GetLayers().Item(i);
dLayerZoomMax = layer.GetZoomMax();
dLayerZoomMin = layer.GetZoomMin();
if ((dLayerZoomMax >= dMapZoom && dLayerZoomMin <= dMapZoom) || (dLayerZoomMax == 0 && dLayerZoomMin == 0))
{
fs = m_ctrlMapX.GetLayers().Item(i).SearchAtPoint(pt);
if(fs.GetCount() != 0)
{
CString buffer;
CMapXDataset ds;
f = fs.Item(1);
layer = f.GetLayer();
COleVariant layerVt;
layerVt.vt = VT_DISPATCH;
layerVt.pdispVal = layer.m_lpDispatch;
layerVt.pdispVal->AddRef();
ds = m_ctrlMapX.GetDatasets().Add(miDataSetLayer, layerVt);
m_InfoDlg->m_ctrlInfoList.DeleteAllItems();
COleVariant ValueVt;
int iFieldCount = ds.GetFields().GetCount();
for (int i = 0; i < iFieldCount; i++)
{
buffer = ds.GetFields().Item(i+1).GetName();
m_InfoDlg->m_ctrlInfoList.InsertItem(i,buffer);
COleVariant vVal;
for (int j = 0; j < iFieldCount; j++)
{
vVal = ds.GetValue(f.GetFeatureID(), j+1);
vVal.ChangeType(VT_BSTR);
buffer = vVal.bstrVal;
m_InfoDlg->m_ctrlInfoList.SetItemText(j,1,buffer);
} // end for (int j = 0; j < iFieldCount; j++)
} // end for (int i = 0; i < iFieldCount; i++)
break;
} // end if(fs.GetCount() != 0)
} // end if (dLayerZoomMax >= dMapZoom && dLayerZoomMin <= dMapZoom)
} // end for (int i = 1; i <= iCount; i++)
} // end if (ToolNum == INFO_TOOL)
}
void CGeoExpertView::OnUpdateMapToolInfotool(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (m_ctrlMapX.m_hWnd != NULL)
{
pCmdUI->Enable(TRUE);
}
else
{
pCmdUI->Enable(FALSE);
}
pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == INFO_TOOL);
}
void CGeoExpertView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
OnFileOpen();
}
//
void CGeoExpertView::OnToolTest()
{
/*
try
{
CMapXFeature f;
// create a new symbol or text feature
// first create the standalone feature object
f.CreateDispatch(f.GetClsid());
// attach standalone feature to map, as required in V3
f.Attach(m_ctrlMapX.GetDispatch());
///f.SetType(miFeatureTypeSymbol);
f.SetType(miFeatureTypeText);
f.SetCaption("Text");
// set the style and location of the feature
f.SetStyle(m_ctrlMapX.GetDefaultStyle());
f.GetPoint().Set(122.1419,37.4419);
// now add it to our layer
CMapXLayer layer = m_ctrlMapX.GetLayers().Item("Asia Capitals");
layer.AddFeature (f);
}
catch (COleDispatchException *e)
{
e->ReportError();
e->Delete();
}
catch (COleException *e)
{
e->ReportError();
e->Delete();
}
*/
CMapXLayers layers = m_ctrlMapX.GetLayers();
CMapXFeature ftr;
try
{
if (ftr.CreateDispatch(ftr.GetClsid()))
{
ftr = m_ctrlMapX.GetFeatureFactory().CreateSymbol();
ftr.SetStyle(m_ctrlMapX.GetDefaultStyle());
CMapXStyle style = ftr.GetStyle(); //获得图元的风格
//设置图元的风格,显示位图
style.SetSymbolType(miSymbolTypeBitmap);
//指定所要显示位图的存放位置
style.SetSymbolBitmapName("C:\\test.bmp");
//指定位图大小
style.SetSymbolBitmapSize(10); ////注意,不能大于48,否则出错
//设置为透明
style.SetSymbolBitmapTransparent(TRUE);
//指定需要显示图元的位置(经纬度位置)
ftr.GetPoint().Set(122.1419,37.4419);//学四东北角
layers.Item("Asia Capitals").AddFeature(ftr);
}
else
{
AfxThrowOleException(CO_E_CLASS_CREATE_FAILED);
}
}
catch (COleDispatchException *e)
{
e->ReportError();
e->Delete();
}
catch (COleException *e)
{
e->ReportError();
e->Delete();
}
}
void CGeoExpertView::OnViewTooltest()
{
// TODO: Add your command handler code here
OnToolTest();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -