http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> 软件开发 >> 正文

使用Visual C++ 6.0开发MAPGIS浏览器

作者:miles    文章来源:www.zahui.com    点击数:    更新时间:2007-7-12
摘要:
top+50 || point.y>=frc.bottom-50 ){
GetCursorPos(&point2);
point2.x+=dx; point2.y+=dy;
_WpToLp(&point,&xy1);
_GotoWindowFxy(xy1.x,xy1.y);
SetCursorPos(point2.x,point2.y);//0.5*(frc.left+frc.right),0.5*(frc.top+frc.bottom));
}
}

CGisView::OnMouseMove(nFlags, point);

}

void CCGisView_Demo1View::OnGotoanywhere()
{
gotoanywhere_flage=!gotoanywhere_flage;
}

void CCGisView_Demo1View::OnUpdateGotoanywhere(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(gotoanywhere_flage); // TODO: Add your command update UI handler code here

}

void CCGisView_Demo1View::OnStopallFlash()
{
_StopFlash(LIN);_StopFlash(PNT);_StopFlash(REG);
}
/*
void CCGisView_Demo1View::OnTry2()
{
//MessageBox("I am trying DDE Connection" ,"DDE OnTry2",MB_OK);
//OnStartFlash();
long *p;
short *pOldLst;
int i,ai;
LPTSTR pstr;
CString name;

char c[2];
c[0]='"'; c[1]='\0';

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];
name.Empty();
name="钻孔编号!=";
name=name+c;
name=name+"001";
name=name+c;
pstr = name.GetBuffer(name.GetLength());
MessageBox(pstr,pstr,MB_OK);
p=_AttAskToList0(ai,PNT,pstr);

//_ _AttAskToList(ai,PNT);
if(p!=NULL) {
_FlashPnt(ai,p+1,p[0]);
}
}
}
}
*/
BOOL CCGisView_Demo1View::OpenMap(char *prj)
{
CCGisView_Demo1App *ptApp;
short ai,i;
short *pOldLst;
short *pNewLst;
FILE *fp;
short fType;
CString name;
CString path;
int j,num_file;
LPTSTR p;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址
char dir[256];
//GetCurrentDirectory(200,dir);
TCHAR szFullPath[256];
TCHAR szDir[256];
TCHAR szDrive[256];
::GetModuleFileName(NULL,szFullPath,256);
_splitpath(szFullPath,szDrive,szDir,NULL,NULL);

name=szDrive;//dir;
//name=name.Left(2);
name=name+"\\mapgis32\\xzhmap";
path=name;
name=path+"\\"+prj;

//MessageBox(name,name,MB_OK);
if((fp=fopen(name,"r"))!=NULL) {
fscanf(fp,"%d\n",&num_file);
for(j=1;j<=num_file;j++) {
fscanf(fp,"%s\n",dir);
name=dir;
name.MakeUpper();
fType=-1;
if(name.Find(".WL")!=-1) fType=LIN;
if(name.Find(".WT")!=-1) fType=PNT;
if(name.Find(".WP")!=-1) fType=REG;
if(fType==-1) continue;
name=path+name;
p = name.GetBuffer(name.GetLength());

ai=_OpenArea(ptApp->m_AHInst,fType); //打开一个fType类型的空工作区
if(ai<=0) //失败则返回
return false;

if(!_LoadAFile(p/*"F:\\mapgis32\\yqmap\\china.wl"*/,ai,NULL,NULL,NULL))//_LoadFile(ai)) //装入文件到ai工作区,若失败则关闭工作区,然后返回
{
MessageBox(name,"文件不存在!!!",MB_OK);
_CloseArea(ai);
//return false;
continue;
}
_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
pNewLst=new short [pOldLst[0]+2];//
pNewLst[0]=pOldLst[0]+1;
for(i=1;i<=pOldLst[0];i++)
pNewLst[i]=pOldLst[i];
}
else
{
pNewLst=new short [2];
pNewLst[0]=1;
i=1;
}
pNewLst[i]=ai; //再添加新的工作区
_SetAreaList(pNewLst); //重新设置当前视窗口对应的工作区
delete[] pNewLst;
}
}
else {
MessageBox(name,"文件不存在!!!",MB_OK);
return false;
}
_RestoreWindow(); //复位当前视窗口
fclose(fp);
return true;
}

void CCGisView_Demo1View::OnQueryPnt()
{
long *p;
short *pOldLst;
int i,j,ai;
LPTSTR pstr;
ATT_STRU *stru;
char expStr[256];
char c[2];
PNT_INFO pnt_info;

c[0]='"'; c[1]='\0';

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];

if(_AType(ai)==PNT) {
if(_GetAttStru(ai,PNT,&stru))
if(_InputExpresion(hwnd,stru,expStr,256,"点属性查询",NULL))
{ //MessageBox(expStr,expStr,MB_OK);
p=_AttAskToList0(ai,PNT,expStr);

//_ _AttAskToList(ai,PNT);
if(p!=NULL) {
for(j=1;j<=p[0];j++) {
_FlashPnt(ai,p+j,1 /*p[0]*/);
_GetPntInfo(ai,*(p+j),&pnt_info);
_GotoWindowFxy(0.5*(pnt_info.rect.xmin+pnt_info.rect.xmax),
0.5*(pnt_info.rect.ymin+pnt_info.rect.ymax));

//_ViewARcd(NULL/*GetSafeHwnd()*/,ai,PNT,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");
_ViewCurAtt(ai,PNT,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");

}
}

}
}
}
}
}

void CCGisView_Demo1View::OnQueryLin()
{
long *p;
short *pOldLst;
int i,j,ai;
LPTSTR pstr;
ATT_STRU *stru;
char expStr[256];
LIN_INFO lin_info;
char c[2];
c[0]='"'; c[1]='\0';

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];

if(_AType(ai)==LIN) {
if(_GetAttStru(ai,LIN,&stru))
if(_InputExpresion(hwnd,stru,expStr,256,"线属性查询",NULL))
{ //MessageBox(expStr,expStr,MB_OK);
p=_AttAskToList0(ai,LIN,expStr);

//_ _AttAskToList(ai,PNT);
if(p!=NULL) {
for(j=1;j<=p[0];j++) {
_FlashLin(ai,p+j,1 /*p[0]*/);
_GetLinInfo(ai,*(p+j),&lin_info);
_GotoWindowFxy(0.5*(lin_info.rect.xmin+lin_info.rect.xmax),
0.5*(lin_info.rect.ymin+lin_info.rect.ymax));

//_ViewARcd(NULL/*GetSafeHwnd()*/,ai,PNT,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");
_ViewCurAtt(ai,LIN,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");

}
}

}
}
}
}
}

void CCGisView_Demo1View::OnQueryReg()
{
long *p;
short *pOldLst;

int i,j,ai;
LPTSTR pstr;
ATT_STRU *stru;
char expStr[256];
REG_INFO reg_info;

char c[2];
c[0]='"'; c[1]='\0';

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];

if(_AType(ai)==REG) {
if(_GetAttStru(ai,REG,&stru))
if(_InputExpresion(hwnd,stru,expStr,256,"区属性查询",NULL))
{ //MessageBox(expStr,expStr,MB_OK);
p=_AttAskToList0(ai,REG,expStr);

//_ _AttAskToList(ai,PNT);
if(p!=NULL) {
for(j=1;j<=p[0];j++) {
_FlashReg(ai,p+j,1 /*p[0]*/);
_GetRegInfo(ai,*(p+j),&reg_info);
_GotoWindowFxy(0.5*(reg_info.rect.xmin+reg_info.rect.xmax),
0.5*(reg_info.rect.ymin+reg_info.rect.ymax));

//_ViewARcd(NULL/*GetSafeHwnd()*/,ai,PNT,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");
_ViewCurAtt(ai,REG,*(p+j),"忻州地区滹沱河管理信息系统--浏览资料");

}
}

}
}
}
}
}


/*void CCGisView_Demo1View::OnTry3()
{
TCHAR szFullPath[256];
TCHAR szDir[256];
TCHAR szDrive[256];
::GetModuleFileName(NULL,szFullPath,256);
_splitpath(szFullPath,szDrive,szDir,NULL,NULL);
MessageBox(szFullPath,szDrive,MB_OK);
MessageBox(szFullPath,szDir,MB_OK);
::GetShortPathName(szFullPath,szDrive,256);
MessageBox(szFullPath,szDrive,MB_OK);


return;
}*/


void CCGisView_Demo1View::OnExtractPnt()
{
short *pOldLst;
short *pNewLst;
int i,j,ai,ai2,oldlist;
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
oldlist=pOldLst[0];
for(i=1;i<=oldlist;i++)
{//MessageBox("gdjfgdjgdj","daddad",MB_OK);
_GetAreaList(&pOldLst);
ai=pOldLst[i];
if(_AType(ai)==PNT)
{
ai2=_OpenArea(ptApp->m_AHInst,PNT); //打开一个fType类型的空工作区
if(ai2<=0) //失败则返回
{//MessageBox("1111111","daddad",MB_OK);
return;}
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
pNewLst=new short [pOldLst[0]+2];//
pNewLst[0]=pOldLst[0]+1;
for(j=1;j<=pOldLst[0];j++)
pNewLst[j]=pOldLst[j];
}
/* else
{
pNewLst=new short [2];
pNewLst[0]=1;
i=1;
}*/
pNewLst[j]=ai2; //再添加新的工作区
_SetAreaList(pNewLst); //重新设置当前视窗口对应的工作区
if(_AttAskToArea(ai,PNT,ai2))
{
//_SaveFile(ai2);
_CloseArea(ai2);
}
//MessageBox("adsasasas","daddad",MB_OK);
delete[] pNewLst;
}
}
_RestoreWindow(); //复位当前视窗口
}return;
}

void CCGisView_Demo1View::OnExtractLin()
{
short *pOldLst;
short *pNewLst;
int i,j,ai,ai2,oldlist;
// LPTSTR pstr;
// ATT_STRU *stru;
// char expStr[256];
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
// sprintf(expStr,"area==%d\n",pOldLst[0]);
// MessageBox(expStr,expStr,MB_OK);
oldlist=pOldLst[0];
for(i=1;i<=oldlist;i++)
{//MessageBox("gdjfgdjgdj","daddad",MB_OK);
_GetAreaList(&pOldLst);
ai=pOldLst[i];
if(_AType(ai)==LIN)
{
ai2=_OpenArea(ptApp->m_AHInst,LIN); //打开一个fType类型的空工作区
if(ai2<=0) //失败则返回
{//MessageBox("1111111","daddad",MB_OK);
return;}
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
pNewLst=new short [pOldLst[0]+2];//
pNewLst[0]=pOldLst[0]+1;
for(j=1;j<=pOldLst[0];j++)
pNewLst[j]=pOldLst[j];
}
/* else
{
pNewLst=new short [2];
pNewLst[0]=1;
i=1;
}*/
pNewLst[j]=ai2; //再添加新的工作区
_SetAreaList(pNewLst); //重新设置当前视窗口对应的工作区
if(_AttAskToArea(ai,LIN,ai2))
{
//_SaveFile(ai2);
_CloseArea(ai2);
}
//MessageBox("adsasasas","daddad",MB_OK);
delete[] pNewLst;
}
}

_RestoreWindow(); //复位当前视窗口
}return;
}

void CCGisView_Demo1View::OnExtractReg()
{
short *pOldLst;
short *pNewLst;
int i,j,ai,ai2,oldlist;
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
oldlist=pOldLst[0];//保存工作区数
for(i=1;i<=oldlist;i++)
{//MessageBox("gdjfgdjgdj","daddad",MB_OK);
_GetAreaList(&pOldLst);
ai=pOldLst[i];
if(_AType(ai)==REG)
{
ai2=_OpenArea(ptApp->m_AHInst,REG); //打开一个fType类型的空工作区
if(ai2<=0) //失败则返回
{//MessageBox("1111111","daddad",MB_OK);
return;}
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
pNewLst=new short [pOldLst[0]+2];//
pNewLst[0]=pOldLst[0]+1;
for(j=1;j<=pOldLst[0];j++)
pNewLst[j]=pOldLst[j];
}
/* else
{
pNewLst=new short [2];
pNewLst[0]=1;
i=1;
}*/
pNewLst[j]=ai2; //再添加新的工作区
_SetAreaList(pNewLst); //重新设置当前视窗口对应的工作区
if(_AttAskToArea(ai,REG,ai2))
{
//_SaveFile(ai2);
_CloseArea(ai2);
}
//MessageBox("adsasasas","daddad",MB_OK);
delete[] pNewLst;
}
}

_RestoreWindow(); //复位当前视窗口
} return;
}

void CCGisView_Demo1View::OnSelectarea()
{
CCGisView_Demo1App *ptApp;
int i,j;
short *tai;
CCGisView_Demo1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址
if(tai=_SelectAreaList(ptApp->m_AHInst,hwnd,-1,"选择显示图件")) {
if(pDoc->ptai!=NULL) delete pDoc->ptai;
pDoc->ptai=new short [tai[0]+1];
for(i=0;i<=tai[0];i++) pDoc->ptai[i]=tai[i];
_UpdateWindow();
}

 

}

void CCGisView_Demo1View::OnMapChina()
{
if(OpenMap("china.prj"))
GetParentFrame()->SetWindowText("中国地图");

}


void CCGisView_Demo1View::OnYqmapBasmap()
{
if(OpenMap("basemap.prj"))//地理底图.prj"))
GetParentFrame()->SetWindowText("地理底图");

}

void CCGisView_Demo1View::OnYqmapKcms()
{ if(OpenMap("channel.prj"))//渠系现状图.prj"))
GetParentFrame()->SetWindowText("渠系现状图");

}
void CCGisView_Demo1View::OnYqmapWaterquality()
{
if(OpenMap("burydep.prj"))
GetParentFrame()->SetWindowText("潜水埋深图");

}

void CCGisView_Demo1View::OnYqmapWrcd()
{
if(OpenMap("level.prj"))
GetParentFrame()->SetWindowText("潜水等水位线图");

}

void CCGisView_Demo1View::OnYqmapGeology()
{
if(OpenMap("borehole.prj"))
GetParentFrame()->SetWindowText("孔位布置图");

}

void CCGisView_Demo1View::OnYqmapEnvhydrogeo()
{
if(OpenMap("soilsalt.prj"))
GetParentFrame()->SetWindowText("土壤含盐量分布图");

}

void CCGisView_Demo1View::OnYqmapProfile()
{
if(OpenMap("yanzitu.prj"))
GetParentFrame()->SetWindowText("盐渍土分类图");

}

void CCGisView_Demo1View::OnYqmapRecharge()
{
if(OpenMap("tuzi.prj"))//土质分布图.prj"))
GetParentFrame()->SetWindowText("土质分布图");

}

void CCGisView_Demo1View::OnYqmapHydrogeo()
{
if(OpenMap("hydrog.prj"))//水文地质图.prj"))
GetParentFrame()->SetWindowText("水文地质图");

}

void CCGisView_Demo1View::OnYqmapKarstwaterlevel()
{
if(OpenMap("karst.prj"))//岩溶水等水位线图.prj"))
GetParentFrame()->SetWindowText("岩溶水等水位线图");
}

void CCGisView_Demo1View::OnYqmapHardness()
{
if( OpenMap("T_hard.prj"))//总硬度矿化度图.prj"))
GetParentFrame()->SetWindowText("总硬度矿化度图");
}
/*
void CCGisView_Demo1View::OnExecute()
{
pb.ExcuteServiceCmd("YQ0009");

}
*/
void CCGisView_Demo1View::OnConnectToDbs()
{
if(connectToDbs==false) {
pb.CMDCAD="MyPBApp";
pb.LinkToService();
if(pb.hConv==0L) {MessageBox(" 数据库系统未准备好 \n 启动后再试...",
"数据传输信息",MB_OK); return;}
}
//else pb.UnLinkToService();
connectToDbs=!connectToDbs;
}

void CCGisView_Demo1View::OnUpdateConnectToDbs(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(connectToDbs);
}
/*
void CCGisView_Demo1View::OnTry()
{
// TODO: Add your command handler code here

}
*/

void CCGisView_Demo1View::OnAreaSum()
{
short *pOldLst;
int i,j,ai;
LPTSTR pstr;
long *p;
double area_sum=0.0;
ATT_STRU *stru;
char *att;
char msg[200];
CString exp="面积>0.0";
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];
if(_AType(ai)==REG)
{
pstr = exp.GetBuffer(exp.GetLength());
p=_AttAskToList0(ai,REG,pstr);
if(p)
for(j=1;j<=p[0];j++) {
if(_GetAtt(ai,_AType(ai),p[j],&stru,&att)==1)
area_sum+=_GetFld(att,stru,"面积",NULL,NULL);
}
}
}

sprintf(msg," 总面积=%.3f \n",area_sum);
MessageBox(msg,"总面积统计",MB_OK);
}return;
}

void CCGisView_Demo1View::OnArcSum()
{
short *pOldLst;
int i,j,ai;
LPTSTR pstr;
long *p;
double area_sum=0.0;
ATT_STRU *stru;
char *att;
char msg[200];
CString exp="面积>0.0";
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];
if(_AType(ai)==REG)
{
pstr = exp.GetBuffer(exp.GetLength());
p=_AttAskToList0(ai,REG,pstr);
if(p)
for(j=1;j<=p[0];j++) {
if(_GetAtt(ai,_AType(ai),p[j],&stru,&att)==1)
area_sum+=_GetFld(att,stru,"周长",NULL,NULL);
}
}
}

sprintf(msg," 总周长=%.3f \n",area_sum);
MessageBox(msg,"总周长统计",MB_OK);
}return;
}

void CCGisView_Demo1View::OnLineSum()
{
short *pOldLst;
int i,j,ai;
LPTSTR pstr;
long *p;
double area_sum=0.0;
ATT_STRU *stru;
char *att;
char msg[200];
CString exp="长度>0.0";
CCGisView_Demo1App *ptApp;
ptApp=(CCGisView_Demo1App *)AfxGetApp(); //取当前应用程序对象地址

_GetAreaList(&pOldLst); //取当前视窗口对应的工作区,若没有,则pOldLst返回NULL
if(pOldLst) //pOldLst!=NULL,说明当前视窗口已经有对应的工作区,保存原来对应的工作区
{
for(i=1;i<=pOldLst[0];i++) {
ai=pOldLst[i];
if(_AType(ai)==LIN)
{
pstr = exp.GetBuffer(exp.GetLength());
p=_AttAskToList0(ai,LIN,pstr);
if(p)
for(j=1;j<=p[0];j++) {
if(_GetAtt(ai,_AType(ai),p[j],&stru,&att)==1)
area_sum+=_GetFld(att,stru,"长度",NULL,NULL);
}
}
}

sprintf(msg," 总线长度=%.3f \n",area_sum);
MessageBox(msg,"线长度统计",MB_OK);
}
return;
}

void CCGisView_Demo1View::OnQueryBore()
{ querybore_flage=!querybore_flage; }

void CCGisView_Demo1View::OnUpdateQueryBore(CCmdUI* pCmdUI)
{ pCmdUI->SetCheck(querybore_flage);
// TODO: Add your command update UI handler code here }

上一页  [1] [2] 

Tags:Visual C++,MAPGIS  
责任编辑:gissky
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图