📄 mainfrm.cpp
字号:
Eng_SetLegend(theApp.GetMapPane()->m_map,theApp.GetLayerPane()->m_legend);
}
}
else
{
AfxMessageBox("输出shp失败!");
}
}
void CMainFrame::OnShapeText()
{
m_uID=ID_SHAPE_TEXT;
}
void CMainFrame::OnUpdateShapeText(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_uID==ID_SHAPE_TEXT);
}
void CMainFrame::OnShapeDelete()
{
theApp.GetMapPane()->m_oShape.DeleteShape();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnShapeClear()
{
switch(m_uID) //判断ID,不能放在shape类内
{
case ID_SHAPE_POINT:
theApp.GetMapPane()->m_oShape.mo_ReleasePoints();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_LINE:
theApp.GetMapPane()->m_oShape.mo_ReleaseLines();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_RECT:
theApp.GetMapPane()->m_oShape.mo_ReleaseRects();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_CIRCLE:
theApp.GetMapPane()->m_oShape.mo_ReleaseCircles();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_ELLIPSE:
theApp.GetMapPane()->m_oShape.mo_ReleaseEllipses();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_POLY:
theApp.GetMapPane()->m_oShape.mo_ReleasePolys();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
case ID_SHAPE_TEXT:
theApp.GetMapPane()->m_oShape.mo_ReleaseTexts();
theApp.GetMapPane()->m_oShape.SetSelNone();
break;
}
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnShapeSelect()
{
m_uID=ID_SHAPE_SELECT;
}
void CMainFrame::OnUpdateShapeSelect(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_uID==ID_SHAPE_SELECT);
}
void CMainFrame::OnShapeData()
{
theApp.GetMapPane()->m_oShape.Edit();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnShapeImport()
{
theApp.GetMapPane()->m_oShape.AddFromFile(theApp.GetMapPane()->m_map);
}
void CMainFrame::OnShapeClearAll()
{
theApp.GetMapPane()->m_oShape.mo_ReleasePoints();
theApp.GetMapPane()->m_oShape.mo_ReleaseLines();
theApp.GetMapPane()->m_oShape.mo_ReleaseRects();
theApp.GetMapPane()->m_oShape.mo_ReleaseCircles();
theApp.GetMapPane()->m_oShape.mo_ReleaseEllipses();
theApp.GetMapPane()->m_oShape.mo_ReleasePolys();
theApp.GetMapPane()->m_oShape.mo_ReleaseTexts();
theApp.GetMapPane()->m_oShape.SetSelNone();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnShapeSave()
{
CFileDialog fd(FALSE,"msf",NULL,OFN_EXPLORER|OFN_HIDEREADONLY,"Mapper图形文件(*.msf)|*.msf||",this);
if(fd.DoModal()!=IDOK)
return;
BOOL bSave=theApp.GetMapPane()->m_oShape.Save(fd.GetPathName());
if(bSave)
{
AfxMessageBox("保存完毕!");
}
else
{
AfxMessageBox("保存失败!");
}
}
void CMainFrame::OnShapeOpen()
{
CFileDialog fd(TRUE,"msf",NULL,OFN_EXPLORER|OFN_HIDEREADONLY,"Mapper图形文件(*.msf)|*.msf||",this);
if(fd.DoModal()!=IDOK)
return;
theApp.GetMapPane()->m_oShape.Read(fd.GetPathName());
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnSeisLiedu()
{
}
void CMainFrame::OnShapeQuery()
{
CMoLayers layers=theApp.GetMapPane()->m_map.GetLayers();
CMoMapLayer layer=layers.Item(COleVariant(TEXT(theApp.GetMapPane()->m_sQuery)));
if(LPDISPATCH(theApp.GetMapPane()->m_rsQuery)!=0)
theApp.GetMapPane()->m_oShape.AddFromQuery(layer,theApp.GetMapPane()->m_rsQuery);
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnSeisEq3Shp()
{
}
void CMainFrame::OnMapLayerDuplicate()
{
//直接循环
short i,n,count;
CStringArray saLayer;
CString si,sj;
BOOL bDup=TRUE;
n=0;
while(1)
{
bDup=FALSE;
saLayer.RemoveAll();
Eng_GetLayers(theApp.GetMapPane()->m_map,saLayer);
count=saLayer.GetSize();
sj=saLayer[n];
for(i=(count-1);i>=n+1;i--) //有可能有多个,从前向后,如果删除了,会出现下标超界
{
si=saLayer[i];
if(sj==si)
{
// AfxMessageBox(si);
theApp.GetMapPane()->m_map.GetLayers().Remove(i);
}
}
n++;
if(n>=count)
break;
}
Eng_SetLegend(theApp.GetMapPane()->m_map,theApp.GetLayerPane()->m_legend);
}
void CMainFrame::OnQueryInput()
{
short iLayer=theApp.GetLayerPane()->m_legend.getActiveLayer();
if(iLayer<0)
{
AfxMessageBox("必须先选择一个查询图层!");
return;
}
m_uID=ID_QUERY_INPUT;
//设置参数
CQueryInputDlg qid;
CMoRectangle rect=theApp.GetMapPane()->m_map.GetExtent();
qid.m_dLon=rect.GetCenter().GetX();
qid.m_dLat=rect.GetCenter().GetY();
if(qid.DoModal()!=IDOK)
return;
BeginWaitCursor();
/*
double pi=3.14159265/180.0;
double dy=111.133-0.559*cos(qid.m_dLat*2.0*pi); //纬度
double dx=111.413*cos(qid.m_dLat*pi)-0.094*cos(qid.m_dLat*3.0*pi);//经度
//创建椭圆
CMoEllipse ellipse;
ellipse.CreateDispatch(TEXT("MapObjects2.Ellipse"));
ellipse.SetLeft(qid.m_dLon-qid.m_dX/dx); //经度
ellipse.SetRight(qid.m_dLon+qid.m_dX/dx);
ellipse.SetTop(qid.m_dLat+qid.m_dY/dy); //纬度
ellipse.SetBottom(qid.m_dLat-qid.m_dY/dy);
*/
double pi=3.14159265/180.0;
double ry=111.133-0.559*cos(qid.m_dLat*2.0*pi); //纬度
double rx=111.413*cos(qid.m_dLat*pi)-0.094*cos(qid.m_dLat*3.0*pi);//经度
double dx=qid.m_dX/rx;
double dy=qid.m_dY/ry;
double x1=qid.m_dLon-dx;
double x2=qid.m_dLon+dx;
double y1=qid.m_dLat+dy;
double y2=qid.m_dLat-dy;
CMoEllipse ellipse;
ellipse.CreateDispatch(TEXT("MapObjects2.Ellipse"));
ellipse.SetLeft(x1); //经度
ellipse.SetRight(x2);
ellipse.SetTop(y1); //纬度
ellipse.SetBottom(y2);
//查询
if(ellipse.m_lpDispatch!=NULL)
{
//ellipse不能直接用,需要转换成poly
VARIANT va1;
VariantInit(&va1);
if(theApp.GetMapPane()->m_oQueryInput.m_lpDispatch!=NULL)
theApp.GetMapPane()->m_oQueryInput.CreateDispatch(TEXT("MapObjects2.Polygon"));
theApp.GetMapPane()->m_oQueryInput=ellipse.Buffer(0.0,va1);
//旋转
// Eng_RoatePoly(theApp.GetMapPane()->m_oQueryInput,270.0-qid.m_dAngle);
Eng_RoatePoly(theApp.GetMapPane()->m_oQueryInput,360.0-qid.m_dAngle);
CMoMapLayer layer=theApp.GetMapPane()->m_map.GetLayers().Item(COleVariant(iLayer));
theApp.GetMapPane()->m_sQuery=layer.GetName();
theApp.GetMapPane()->m_rsQuery = layer.SearchShape(theApp.GetMapPane()->m_oQueryInput, moAreaIntersect, TEXT(""));
VARIANT va;
VariantInit(&va);
va.vt = VT_NULL;
theApp.GetMapPane()->m_map.GetTrackingLayer().Refresh(true,va);
ellipse.ReleaseDispatch();
}
EndWaitCursor();
}
void CMainFrame::OnSeisEq3()
{
if(theApp.GetMapPane()->m_map.GetLayers().GetCount()<=0)
{
AfxMessageBox("先添加图层!");
return;
}
theApp.GetMapPane()->m_oSeis.Create(theApp.GetMapPane()->m_map);
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnMapHideAll()
{
short i,count=theApp.GetMapPane()->m_map.GetLayers().GetCount();
for(i=0;i<count;i++)
{
theApp.GetLayerPane()->m_legend.SetLayerVisible(&i,FALSE);
}
/*
CMoLayers layers=theApp.GetMapPane()->m_map.GetLayers();
for(i=0;i<count;i++)
{
switch(GetLayerType(layers,i))
{
case moMapLayer:
{
CMoMapLayer layer=layers.Item(COleVariant((short)i));
layer.SetVisible(FALSE);
}
break;
case moImageLayer:
{
CMoImageLayer layer=layers.Item(COleVariant((short)i));
layer.SetVisible(FALSE);
}
break;
}
}
Eng_SetLegend(theApp.GetMapPane()->m_map,theApp.GetLayerPane()->m_legend);
theApp.GetMapPane()->m_map.Refresh();
*/
}
void CMainFrame::OnMapShowAll()
{
short i,count=theApp.GetMapPane()->m_map.GetLayers().GetCount();
for(i=0;i<count;i++)
{
theApp.GetLayerPane()->m_legend.SetLayerVisible(&i,TRUE);
}
/*
CMoLayers layers=theApp.GetMapPane()->m_map.GetLayers();
for(i=0;i<count;i++)
{
switch(GetLayerType(layers,i))
{
case moMapLayer:
{
CMoMapLayer layer=layers.Item(COleVariant((short)i));
layer.SetVisible(TRUE);
}
break;
case moImageLayer:
{
CMoImageLayer layer=layers.Item(COleVariant((short)i));
layer.SetVisible(TRUE);
}
break;
}
}
Eng_SetLegend(theApp.GetMapPane()->m_map,theApp.GetLayerPane()->m_legend);
theApp.GetMapPane()->m_map.Refresh();
*/
}
void CMainFrame::OnMapShowInvert()
{
short i,count=theApp.GetMapPane()->m_map.GetLayers().GetCount();
for(i=0;i<count;i++)
{
theApp.GetLayerPane()->m_legend.SetLayerVisible(&i,!theApp.GetLayerPane()->m_legend.GetLayerVisible(&i));
}
}
void CMainFrame::OnSeisEq3Clear()
{
theApp.GetMapPane()->m_oSeis.DeleteAll();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnSeisGridClear()
{
theApp.GetMapPane()->m_oGrid.DeleteAll();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnSeisLieduClear()
{
}
void CMainFrame::OnSeisSunshi()
{
}
void CMainFrame::OnSeisSunshiClear()
{
theApp.GetMapPane()->m_rsSunshi0.ReleaseDispatch();
theApp.GetMapPane()->m_rsSunshi1.ReleaseDispatch();
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnSeisLieduQuery()
{
}
void CMainFrame::OnSeisGrid()
{
if(theApp.GetMapPane()->m_map.GetLayers().GetCount()<=0)
{
AfxMessageBox("先添加图层!");
return;
}
theApp.GetMapPane()->m_oGrid.Create(theApp.GetMapPane()->m_map);
theApp.GetMapPane()->m_map.Refresh();
}
void CMainFrame::OnShapeShapeQuery()
{
//从当前选择的对象进行查询
//必须选择一个图层
short iLayer=theApp.GetLayerPane()->m_legend.getActiveLayer();
if(iLayer<0)
{
AfxMessageBox("必须先选择一个图层!");
return;
}
CMoMapLayer layer=theApp.GetMapPane()->m_map.GetLayers().Item(COleVariant(iLayer));
theApp.GetMapPane()->m_sQuery=layer.GetName();
BeginWaitCursor();
//当前图形必须有选择对象
theApp.GetMapPane()->m_oShape.QueryFromShape(theApp.GetMapPane()->m_map,
layer,theApp.GetMapPane()->m_rsQuery);
EndWaitCursor();
}
void CMainFrame::OnSeisEq3ShpLevel()
{
}
void CMainFrame::OnSeisShp()
{
//标注的地震保存为shp文件
//create shp,mopoint
CFileDialog fd1(FALSE,"shp",NULL,OFN_EXPLORER|OFN_HIDEREADONLY,"shp文件(*.shp)|*.shp||",this);
if(fd1.DoModal()!=IDOK)
return;
CString sPathFile=fd1.GetPathName();
BeginWaitCursor();
if(theApp.GetMapPane()->m_oSeis.ExportShp(theApp.GetMapPane()->m_map,sPathFile))
{
COLORREF color;
int r,g,b;
Eng_GetRandInt(0,255,r,g,b);
color=RGB(r,g,b);
Eng_AddLayerMap(theApp.GetMapPane()->m_map,sPathFile,color);
Eng_SetLegend(theApp.GetMapPane()->m_map,theApp.GetLayerPane()->m_legend);
EndWaitCursor();
AfxMessageBox("处理完毕,并且已经增加到当前工程!");
}
else
{
AfxMessageBox("输出失败!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -