Processfile6.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:60k
- // KMCAD40-FileSwitch-Processfile6.cpp-1.0
- // KmgReader.cpp: implementation of the CKmgReader class.
- //
- //////////////////////////////////////////////////////////////////////
- //KMCAD40-FileSwitch-Processfile6.cpp-1.0 -> 1.1
- #include "stdafx.h"
- #include "DSSubst.h"
- #include "FileSwitch.h"
- #include "KmgReader.h"
- #include "Database.h"
- #include "Reader.h"
- #include "KmLayer.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- #define MODE_SIMPLEEST (1)
- #define MODE_NORMAL (2)
- extern CStdioFile g_CensorialFile;
- extern int g_mode;
- BOOL CKmgReader::processfile(CKmDataManager* pData)
- {
- int convmode=::AfxGetApp()->GetProfileInt(_T("Kmg2Dwg"),_T("ConvMode"),MODE_NORMAL);
- switch(convmode)
- {
- case MODE_SIMPLEEST:
- break;
- case MODE_NORMAL:
- break;
- default:
- convmode=MODE_NORMAL;
- break;
- }
- ::AfxGetApp()->WriteProfileInt(_T("Kmg2Dwg"),_T("ConvMode"),convmode);
- m_pProgress->SetProgressInfoAbsolute(0.10,"分析颜色...");
- if(!processcolor(pData))
- {
- _WRITE(str="转换颜色失败");
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.11,"分析线宽...");
- if(!processlwidth(pData))
- {
- _WRITE(str="转换线宽失败");
- return FALSE;
- }
- /* //设定型文件
- adSetDefaultShapefile(&m_pConverter->adtb->shptb);
- strcpy(m_pConverter->adtb->shptb.name,"CHINESE");
- m_pConverter->adtb->shptb.height=0.0;
- m_pConverter->adtb->shptb.width=0.8;
- m_pConverter->adtb->shptb.angle=0.0;
- m_pConverter->adtb->shptb.flag2=0;
- m_pConverter->adtb->shptb.lastshapeheight= 5 ;
- strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
- strcpy(m_pConverter->adtb->shptb.file,"txt");
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
- if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
- {
- _ERROR;
- }
- //设定型文件
- adSetDefaultShapefile(&m_pConverter->adtb->shptb);
- strcpy(m_pConverter->adtb->shptb.name,"CHINESE3");
- m_pConverter->adtb->shptb.height=0.0;
- m_pConverter->adtb->shptb.width=0.8;
- m_pConverter->adtb->shptb.angle=0.0;
- m_pConverter->adtb->shptb.flag2=0;
- m_pConverter->adtb->shptb.lastshapeheight= 5 ;
- strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
- strcpy(m_pConverter->adtb->shptb.file,"txt");
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
- if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
- {
- _ERROR;
- }
- //设定型文件
- adSetDefaultShapefile(&m_pConverter->adtb->shptb);
- strcpy(m_pConverter->adtb->shptb.name,"CHINESE2");
- m_pConverter->adtb->shptb.height=0.0;
- m_pConverter->adtb->shptb.width=0.8;
- m_pConverter->adtb->shptb.angle=0.0;
- m_pConverter->adtb->shptb.flag2=0;
- m_pConverter->adtb->shptb.lastshapeheight= 5 ;
- strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
- strcpy(m_pConverter->adtb->shptb.file,"txt");
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
- if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
- {
- _ERROR;
- }*/
- m_pProgress->SetProgressInfoAbsolute(0.12,"分析线形...");
- if(!processltype(pData))
- {
- _WRITE(str="转换线形失败");
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.13,"分析层...");
- if(!processlayer(pData))
- {
- _WRITE(str="转换层失败");
- return FALSE;
- }
- if(!processwordstyle(pData))
- {
- _WRITE(str="转换文字样式失败");
- return FALSE;
- }
- if(!processdimstyle(pData))
- {
- _WRITE(str="转换尺寸样式失败");
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.14,"分析块定义...");
- if(!processblockdef(pData))
- {
- _WRITE(str="转换块定义失败");
- return FALSE;
- }
- if(!processblockdefentity(pData))
- {
- _WRITE(str="转换块定义中的实体失败");
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.30,"分析实体...");
- if(!processentity(pData))
- {
- _WRITE(str="转换实体失败");
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.95,"识别图框...");
- if(!processlegend(pData))
- {
- _WRITE(str="转换图框失败");
- return FALSE;
- }
- return TRUE;
- }
- BOOL CKmgReader::processltype(CKmDataManager* pData)
- {
- // adStartLinetypeGet(m_pConverter->m_dwghandle);
- // if(adFindLinetypeByName(m_pConverter->m_dwghandle,"Continuous",m_pConverter->adtb->ltype.objhandle))
- // {
- // adDeleteLinetype(m_pConverter->m_dwghandle,m_pConverter->adtb->ltype.objhandle);
- // }
- AD_LTYPE adtbdata[15];
- for(int i=0;i<15;i++)
- {
- int kmtype;
- adSetDefaultLinetype(&adtbdata[i]);
- switch(i)
- {
- case 0:
- strcpy(adtbdata[i].name,"KM_SOLID");
- strcpy(adtbdata[i].text,"东方实线");
- adtbdata[i].numlinetypesegs=0;
- adtbdata[i].patternlength=0.0;
- kmtype=SOLID_LINE;
- break;
- case 1:
- strcpy(adtbdata[i].name,"KM_DASH");
- strcpy(adtbdata[i].text,"东方虚线");
- adtbdata[i].numlinetypesegs=2;
- adtbdata[i].patternlength=7.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- kmtype=DASHED_LINE;
- break;
- case 2:
- strcpy(adtbdata[i].name,"KM_DOT");
- strcpy(adtbdata[i].text,"东方点线");
- adtbdata[i].numlinetypesegs=2;
- adtbdata[i].patternlength=4.0;
- adtbdata[i].segdata[0].val=2.0;
- adtbdata[i].segdata[1].val=-2.0;
- kmtype=DOT_LINE;
- break;
- case 3:
- strcpy(adtbdata[i].name,"KM_SPACE");
- strcpy(adtbdata[i].text,"东方间隔线");
- adtbdata[i].numlinetypesegs=2;
- adtbdata[i].patternlength=10.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-7.0;
- kmtype=DASH_SPACE_LINE;
- break;
- case 4:
- strcpy(adtbdata[i].name,"KM_LONGDASH_SHORTDASH");
- strcpy(adtbdata[i].text,"东方长画短画线");
- adtbdata[i].numlinetypesegs=4;
- adtbdata[i].patternlength=17.0;
- adtbdata[i].segdata[0].val=10.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=3.0;
- adtbdata[i].segdata[3].val=-2.0;
- kmtype=LONGDASH_SHORTDASH_LINE;
- break;
- case 5:
- strcpy(adtbdata[i].name,"KM_LONGDASH_2SHORTDASH");
- strcpy(adtbdata[i].text,"东方长画双短画线");
- adtbdata[i].numlinetypesegs=6;
- adtbdata[i].patternlength=22.0;
- adtbdata[i].segdata[0].val=10.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=3.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=3.0;
- adtbdata[i].segdata[5].val=-2.0;
- kmtype=LONGDASH_DSHORTDASH_LINE;
- break;
- case 6:
- strcpy(adtbdata[i].name,"KM_SHORTDASH_DOT");
- strcpy(adtbdata[i].text,"东方短画点线");
- adtbdata[i].numlinetypesegs=4;
- adtbdata[i].patternlength=10.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- kmtype=SHORTDASH_DOT_LINE;
- break;
- case 7:
- strcpy(adtbdata[i].name,"KM_2SHORTDASH_DOT");
- strcpy(adtbdata[i].text,"东方双短画点线");
- adtbdata[i].numlinetypesegs=6;
- adtbdata[i].patternlength=17.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=5.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- kmtype=DDASH_DOT_LINE;
- break;
- case 8:
- strcpy(adtbdata[i].name,"KM_POINT");
- strcpy(adtbdata[i].text,"东方点划线");
- adtbdata[i].numlinetypesegs=4;
- adtbdata[i].patternlength=15.0;
- adtbdata[i].segdata[0].val=10.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- kmtype=POINT_LINE;
- break;
- case 9:
- strcpy(adtbdata[i].name,"KM_SHORTDASH_2DOT");
- strcpy(adtbdata[i].text,"东方短画双点线");
- adtbdata[i].numlinetypesegs=6;
- adtbdata[i].patternlength=13.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- kmtype=SDASH_DDOT_LINE;
- break;
- case 10:
- strcpy(adtbdata[i].name,"KM_2SHORTDASH_2DOT");
- strcpy(adtbdata[i].text,"东方双短画双点线");
- adtbdata[i].numlinetypesegs=8;
- adtbdata[i].patternlength=20.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=5.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- adtbdata[i].segdata[6].val=1.0;
- adtbdata[i].segdata[7].val=-2.0;
- kmtype=DDASH_DDOT_LINE;
- break;
- case 11:
- strcpy(adtbdata[i].name,"KM_POINT_POINT");
- strcpy(adtbdata[i].text,"东方双点划线");
- adtbdata[i].numlinetypesegs=6;
- adtbdata[i].patternlength=18.0;
- adtbdata[i].segdata[0].val=10.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- kmtype=DOUBLE_POINT_LINE;
- break;
- case 12:
- strcpy(adtbdata[i].name,"KM_SHORTDASH_3DOT");
- strcpy(adtbdata[i].text,"东方短画三点线");
- adtbdata[i].numlinetypesegs=8;
- adtbdata[i].patternlength=16.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- adtbdata[i].segdata[6].val=1.0;
- adtbdata[i].segdata[7].val=-2.0;
- kmtype=SDASH_TRIDOT_LINE;
- break;
- case 13:
- strcpy(adtbdata[i].name,"KM_2SHORTDASH_3DOT");
- strcpy(adtbdata[i].text,"东方双点画三点线");
- adtbdata[i].numlinetypesegs=10;
- adtbdata[i].patternlength=23.0;
- adtbdata[i].segdata[0].val=5.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=5.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- adtbdata[i].segdata[6].val=1.0;
- adtbdata[i].segdata[7].val=-2.0;
- adtbdata[i].segdata[8].val=1.0;
- adtbdata[i].segdata[9].val=-2.0;
- kmtype=DDASH_TRIDOT_LINE;
- break;
- case 14:
- strcpy(adtbdata[i].name,"KM_3DOT");
- strcpy(adtbdata[i].text,"东方三点线");
- adtbdata[i].numlinetypesegs=8;
- adtbdata[i].patternlength=21.0;
- adtbdata[i].segdata[0].val=10.0;
- adtbdata[i].segdata[1].val=-2.0;
- adtbdata[i].segdata[2].val=1.0;
- adtbdata[i].segdata[3].val=-2.0;
- adtbdata[i].segdata[4].val=1.0;
- adtbdata[i].segdata[5].val=-2.0;
- adtbdata[i].segdata[6].val=1.0;
- adtbdata[i].segdata[7].val=-2.0;
- kmtype=DASH_TRIDOT_LINE ;
- break;
- }
- for(int j=0;j<adtbdata[i].numlinetypesegs;j++)
- {
- adHanclear(adtbdata[i].segdata[j].shapeentryobjhandle);
- adtbdata[i].segdata[j].complexshapecode=0;
- adtbdata[i].segdata[j].xoffset=0.0;
- adtbdata[i].segdata[j].yoffset=0.0;
- adtbdata[i].segdata[j].rotang=0.0;
- adtbdata[i].segdata[j].scale=0.0;
- adtbdata[i].segdata[j].shapeflag=0;
- adtbdata[i].segdata[j].stroffset=0;
- }
- adGenerateObjhandle(m_pConverter->m_dwghandle,adtbdata[i].objhandle);
- try
- {
- if (!adAddLinetype(m_pConverter->m_dwghandle,&adtbdata[i]))
- {
- _ERROR;
- continue;
- }
- }
- catch(...)
- {
- }
- m_altype.Add(adtbdata[i].objhandle,kmtype,0.0,0);
- }
- AD_OBJHANDLE *ohptr=adShadowObjhandlePtr(m_pConverter->m_dwghandle);
- m_altype.Add(ohptr[BYBLOCKLTPSHADOW],LTYPE_BYBLOCK,0.0,0);
- m_altype.Add(ohptr[BYLAYERLTPSHADOW],LTYPE_BYLAYER,0.0,0);
- return TRUE;
- }
- BOOL CKmgReader::processcolor(CKmDataManager* pData)
- {
- short ACI[240]=
- { 255,255,206,206,156,156,123,123,74 ,74 , //顶峰
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 189,255,156,206,115,156,90 ,123,57 ,74 ,
- 123,222,99 ,181,74 ,132,57 ,107,33 ,66 ,
- 57 ,189,49 ,156,33 ,115,24 ,90 ,16 ,57 ,
- 0 ,156,0 ,123,0 ,90 ,0 ,74 ,0 ,41 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,//低谷
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,123,0 ,99 ,0 ,74 ,0 ,57 ,0 ,33 ,
- 0 ,156,0 ,123,0 ,90 ,0 ,74 ,0 ,41 ,
- 57 ,189,49 ,156,33 ,115,24 ,90 ,16 ,57 ,
- 123,222,99 ,181,74 ,132,57 ,107,33 ,66 ,
- 189,255,156,206,115,156,90 ,123,57 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74 ,
- 255,255,206,206,156,156,123,123,74 ,74
- };
- try
- {
- m_aColor.SetSize(256);
- }
- catch(CMemoryException* e)
- {
- TCHAR szCause[255];
- e->GetErrorMessage(szCause, 255);
- _WRITE(str=szCause);
- return FALSE;
- }
- catch(...)
- {
- _WRITE(str="颜色转换时发生未知错误");
- return FALSE;
- }
- m_aColor[1]=(int)RGB(255,0,0);
- m_aColor[2]=(int)RGB(255,255,0);
- m_aColor[3]=(int)RGB(0,255,0);
- m_aColor[4]=(int)RGB(0,255,255);
- m_aColor[5]=(int)RGB(0,0,255);
- m_aColor[6]=(int)RGB(255,0,255);
- m_aColor[7]=0;//黑/白缺省颜色是 7,白色或黑色(由背景色决定)。所有其他颜色必须由 ACI 编号指定(8 到 255)。
- m_aColor[8]=(int)RGB(132,130,132);
- m_aColor[9]=(int)RGB(198,195,198);
- int i;
- for(i=10;i<90;i++)
- {
- m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160*/i+150],ACI[/*i-10+320-240*/i+70]);
- }
- for(i=90;i<170;i++)
- {
- m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160-240*/i-90],ACI[/*i-10+320-240*/i+70]);
- }
- for(i=170;i<250;i++)
- {
- m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160-240*/i-90],ACI[/*i-10+320-240-240*/i-170]);
- }
- m_aColor[250]=(int)RGB(49,48,49);
- m_aColor[251]=(int)RGB(90,89,90);
- m_aColor[252]=(int)RGB(132,134,132);
- m_aColor[253]=(int)RGB(173,174,173);
- m_aColor[254]=(int)RGB(214,215,214);
- m_aColor[255]=(int)RGB(255,255,255);
- return TRUE;
- }
- BOOL CKmgReader::processlwidth(CKmDataManager* pData)
- {
- return TRUE;
- }
- BOOL CKmgReader::processlayer(CKmDataManager* pData)
- {
- KmLayer* pLayer;
- for(UINT i=0;i<pData->LayerNum();i++)
- {
- pLayer=pData->GetALayer(i);
- //void adSetDefaultLayer (AD_DB_HANDLE handle, PAD_LAY lay);
- adSetDefaultLayer(m_pConverter->m_dwghandle,&m_pConverter->adtb->lay);
- CString strName=m_pConverter->ConverterTabEntName(pLayer->GetName());
- strcpy(m_pConverter->adtb->lay.name,(char*)(LPCTSTR)strName);
- short scolor=1;
- for(int j=1;j<m_aColor.GetSize();j++)
- {
- if( (fabs(GetRValue(pLayer->GetColor())-GetRValue(m_aColor[j]))+
- fabs(GetGValue(pLayer->GetColor())-GetGValue(m_aColor[j]))+
- fabs(GetBValue(pLayer->GetColor())-GetBValue(m_aColor[j])))<20)
- {
- scolor=j;
- break;
- }
- }
- m_pConverter->adtb->lay.color=scolor;
- m_altype.Get(m_pConverter->adtb->lay.linetypeobjhandle,pLayer->GetLineType());
- short swidth=(short)(::GetLineWidthAsDouble(pLayer->GetLineWidth())*100.0);
- if(swidth<=5)swidth=5;
- else if(swidth<=9)swidth=9;
- else if(swidth<=13)swidth=13;
- else if(swidth<=15)swidth=15;
- else if(swidth<=18)swidth=18;
- else if(swidth<=20)swidth=20;
- else if(swidth<=25)swidth=25;
- else if(swidth<=30)swidth=30;
- else if(swidth<=35)swidth=35;
- else if(swidth<=40)swidth=40;
- else if(swidth<=50)swidth=50;
- else if(swidth<=53)swidth=53;
- else if(swidth<=60)swidth=60;
- else if(swidth<=70)swidth=70;
- else if(swidth<=80)swidth=80;
- else if(swidth<=90)swidth=90;
- else if(swidth<=100)swidth=100;
- else if(swidth<=106)swidth=106;
- else if(swidth<=120)swidth=120;
- else if(swidth<=140)swidth=140;
- else if(swidth<=158)swidth=158;
- else if(swidth<=200)swidth=200;
- else swidth=211;
- m_pConverter->adtb->lay.lineweight=swidth;
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->lay.objhandle);
- m_pConverter->adtb->lay.flag=0;
- if(pLayer->IsFrozen())
- {
- //在kmcad2002中冻结层内的实体可见,而autocad中冻结层内的实体不可见,
- //因此为里保证在kmcad2002中可见的实体在autocad中也可见,层的冻结属性
- //不转换, by hq 2003.4.22.
- //m_pConverter->adtb->lay.flag|=AD_LAYER_FROZEN;
- }
- if(pLayer->IsOff())
- {
- m_pConverter->adtb->lay.flag|=AD_LAYER_LOCKED;
- }
- if (!adAddLayer(m_pConverter->m_dwghandle,&m_pConverter->adtb->lay))
- {
- _ERROR;
- continue;
- }
- m_alayer.Add(m_pConverter->adtb->lay.objhandle,pLayer->GetID(),0.0,FALSE);
- }
- return TRUE;
- }
- BOOL CKmgReader::processentityhead(CKmDataManager* pData,KmObject* pObj)
- {
- //1
- short scolor;
- if(pObj->color==COLOR_BYBLOCK)
- {
- scolor=AD_COLOR_BYBLOCK;
- }
- else if(pObj->color==COLOR_BYLAYER)
- {
- scolor=AD_COLOR_BYLAYER;
- }
- else
- {
- scolor=AD_COLOR_BYLAYER;
- for(int i=1;i<m_aColor.GetSize();i++)
- {
- if( (fabs(GetRValue(pObj->color)-GetRValue(m_aColor[i]))+
- fabs(GetGValue(pObj->color)-GetGValue(m_aColor[i]))+
- fabs(GetBValue(pObj->color)-GetBValue(m_aColor[i])))<20)
- {
- scolor=i;
- break;
- }
- }
- }
- //2
- short swidth=1;
- double dscale=1.0;
- AD_OBJHANDLE hltype;
- if((pObj)->width==ABS_THIN_WIDTH)
- {
- swidth=0;
- }
- else if((pObj)->width==LWIDTH_BYLAYER)
- {
- swidth=(short)AD_WEIGHT_BYLAYER;
- }
- else if((pObj)->width==LWIDTH_BYBLOCK)
- {
- swidth=(short)AD_WEIGHT_BYBLOCK;
- }
- else
- {
- swidth=(short)(::GetLineWidthAsDouble((pObj)->width)*100.0);
- if(swidth<=5)swidth=5;
- else if(swidth<=9)swidth=9;
- else if(swidth<=13)swidth=13;
- else if(swidth<=15)swidth=15;
- else if(swidth<=18)swidth=18;
- else if(swidth<=20)swidth=20;
- else if(swidth<=25)swidth=25;
- else if(swidth<=30)swidth=30;
- else if(swidth<=35)swidth=35;
- else if(swidth<=40)swidth=40;
- else if(swidth<=50)swidth=50;
- else if(swidth<=53)swidth=53;
- else if(swidth<=60)swidth=60;
- else if(swidth<=70)swidth=70;
- else if(swidth<=80)swidth=80;
- else if(swidth<=90)swidth=90;
- else if(swidth<=100)swidth=100;
- else if(swidth<=106)swidth=106;
- else if(swidth<=120)swidth=120;
- else if(swidth<=140)swidth=140;
- else if(swidth<=158)swidth=158;
- else if(swidth<=200)swidth=200;
- else swidth=211;
- }
- if(pObj->GetRuntimeClass()->IsDerivedFrom(RUNTIME_CLASS(KmCurve)))
- {
- m_altype.Get(hltype,((KmCurve*)pObj)->style);
- dscale=((KmCurve*)pObj)->GetLineScale();
- }
- else
- {
- m_altype.Get(hltype,SOLID_LINE);
- }
- //3
- AD_OBJHANDLE hlayer;
- m_alayer.Get(hlayer,pObj->GetLayerID());
- m_pConverter->WriteEnthead(scolor,swidth,dscale,hltype,hlayer);
- return TRUE;
- }
- BOOL CKmgReader::processentity_dim_blob(CDSSubst* pDSSubst,AD_VMADDR blob)
- {
- ASSERT(pDSSubst);
- //样式替代格式
- //1002 {
- /* 1070 编码
- / ___________具体的样式替代*/
-
- /* 1070 编码
- / ___________具体的样式替代*/
- //1002 }
- try
- {
- //extern PAD_BLOB_CTRL ADCDECL adStartBlobWrite _((AD_VMADDR blob));
- //short adWriteExtendeddata (PAD_BLOB_CTRL bcptr, PAD_XD adxd);
- PAD_BLOB_CTRL bcptr=adStartBlobWrite(blob);
- if(bcptr==NULL)return FALSE;
- AD_XD adxd;
- //1001
- //ACAD
- //1000
- //DSTYLE
- adxd.xddxfnumber=1001;
- AD_OBJHANDLE objhandle;
- m_pConverter->GetAppHandle(&objhandle);
- adHancpy(adxd.xddata.xdappobjhandle,objhandle);
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1000;
- strcpy(adxd.xddata.xdstring,"DSTYLE");
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=AD_XD_CONTROL;
- adxd.xddata.xdcontrol='{';
- adWriteExtendeddata(bcptr,&adxd);
- DSSubstVar dsvar;
- for(int i=0;i<pDSSubst->GetSubstVarNum();i++)
- {
- dsvar = pDSSubst->GetNoNSubstVar(i);
- //short adWriteExtendeddata (PAD_BLOB_CTRL bcptr, PAD_XD adxd);
- switch(dsvar.nDSID)
- {
- /*模板
- case DIM://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=;//ACAD类型
- adxd.xddata.=dsvar.varValue.Val;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- */
- case DIMADEC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=179;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=170;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=171;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTF://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=143;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTRND://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=148;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMAPOST://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=4;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1000;//ACAD类型
- {
- CString strTemp=dsvar.varValue.bstrVal;
- ::strcpy(adxd.xddata.xdstring,(char*)(LPCTSTR)strTemp);// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- }
- break;
- case DIMASZ://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=41;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMZIN://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=78;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMCEN://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=141;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMCLRD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=176;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- {
- int icolor=dsvar.varValue.intVal;
- if(icolor==COLOR_BYBLOCK)
- {
- icolor=AD_COLOR_BYBLOCK;
- }
- else if(icolor==COLOR_BYLAYER)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- else
- {
- try
- {
- int icolorcompare=icolor;//颜色比较基准
- icolor=AD_COLOR_BYLAYER;
- for(int i=1;i<m_aColor.GetSize();i++)
- {
- if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
- fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
- fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
- {
- icolor=i;//i是ACI颜色码
- break;
- }
- }
- }
- catch(...)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- }
- adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMCLRE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=177;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- {
- int icolor=dsvar.varValue.intVal;
- if(icolor==COLOR_BYBLOCK)
- {
- icolor=AD_COLOR_BYBLOCK;
- }
- else if(icolor==COLOR_BYLAYER)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- else
- {
- try
- {
- int icolorcompare=icolor;//颜色比较基准
- icolor=AD_COLOR_BYLAYER;
- for(int i=1;i<m_aColor.GetSize();i++)
- {
- if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
- fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
- fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
- {
- icolor=i;//i是ACI颜色码
- break;
- }
- }
- }
- catch(...)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- }
- adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMCLRT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=178;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- {
- int icolor=dsvar.varValue.intVal;
- if(icolor==COLOR_BYBLOCK)
- {
- icolor=AD_COLOR_BYBLOCK;
- }
- else if(icolor==COLOR_BYLAYER)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- else
- {
- try
- {
- int icolorcompare=icolor;//颜色比较基准
- icolor=AD_COLOR_BYLAYER;
- for(int i=1;i<m_aColor.GetSize();i++)
- {
- if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
- fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
- fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
- {
- icolor=i;//i是ACI颜色码
- break;
- }
- }
- }
- catch(...)
- {
- icolor=AD_COLOR_BYLAYER;
- }
- }
- adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMDLE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=46;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMDLI://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=43;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMEXE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=44;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMEXO://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=42;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMGAP://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=147;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMLFAC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=144;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMLIM://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=72;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMPOST://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=3;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- {
- adxd.xddxfnumber=1000;//ACAD类型
- CString strTemp=dsvar.varValue.bstrVal;
- ::strcpy(adxd.xddata.xdstring,(char*)(LPCTSTR)strTemp);// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMRND://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=45;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSAH://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=173;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSCALE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=40;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSE1://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=75;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSE2://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=76;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTFAC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=146;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTIH://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=73;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTM://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=48;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTOH://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=74;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTOFL://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=172;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTOL://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=71;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTP://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=47;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTSZ://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=142;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTXT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=140;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTVP://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=145;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1040;//ACAD类型
- adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSOXD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=175;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTAD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=77;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTIX://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=174;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMAZIN://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=79;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTTD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=274;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTTZ://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=286;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTU://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=273;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMALTZ://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=285;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMAUNIT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=275;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMDEC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=271;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMATFIT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=289;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMJUST://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=280;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSD1://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=281;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMSD2://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=282;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTDEC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=272;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTOLJ://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=283;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTZIN://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=284;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMLUNIT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=277;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMUPT://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=288;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMFRAC://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=276;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMDSEP://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=278;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.cVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTMOVE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=279;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1070;//ACAD类型
- adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMLWD://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=371;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- {
- adxd.xddxfnumber=1070;//ACAD类型
- int width=dsvar.varValue.intVal;
- if(width==ABS_THIN_WIDTH)
- {
- width=0;
- }
- else if(width==LWIDTH_BYLAYER)
- {
- width=AD_WEIGHT_BYLAYER;
- }
- else if(width==LWIDTH_BYBLOCK)
- {
- width=AD_WEIGHT_BYBLOCK;
- }
- else
- {
- width=(short)(::GetLineWidthAsDouble(width)*100.0);
- if(width<=5)width=5;
- else if(width<=9)width=9;
- else if(width<=13)width=13;
- else if(width<=15)width=15;
- else if(width<=18)width=18;
- else if(width<=20)width=20;
- else if(width<=25)width=25;
- else if(width<=30)width=30;
- else if(width<=35)width=35;
- else if(width<=40)width=40;
- else if(width<=50)width=50;
- else if(width<=53)width=53;
- else if(width<=60)width=60;
- else if(width<=70)width=70;
- else if(width<=80)width=80;
- else if(width<=90)width=90;
- else if(width<=100)width=100;
- else if(width<=106)width=106;
- else if(width<=120)width=120;
- else if(width<=140)width=140;
- else if(width<=158)width=158;
- else if(width<=200)width=200;
- else width=211;
- }
- adxd.xddata.xdint=width;// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMLWE://KMCAD编码
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=372;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- {
- adxd.xddxfnumber=1070;//ACAD类型
- int width=dsvar.varValue.intVal;
- if(width==ABS_THIN_WIDTH)
- {
- width=0;
- }
- else if(width==LWIDTH_BYLAYER)
- {
- width=AD_WEIGHT_BYLAYER;
- }
- else if(width==LWIDTH_BYBLOCK)
- {
- width=AD_WEIGHT_BYBLOCK;
- }
- else
- {
- width=(short)(::GetLineWidthAsDouble(width)*100.0);
- if(width<=5)width=5;
- else if(width<=9)width=9;
- else if(width<=13)width=13;
- else if(width<=15)width=15;
- else if(width<=18)width=18;
- else if(width<=20)width=20;
- else if(width<=25)width=25;
- else if(width<=30)width=30;
- else if(width<=35)width=35;
- else if(width<=40)width=40;
- else if(width<=50)width=50;
- else if(width<=53)width=53;
- else if(width<=60)width=60;
- else if(width<=70)width=70;
- else if(width<=80)width=80;
- else if(width<=90)width=90;
- else if(width<=100)width=100;
- else if(width<=106)width=106;
- else if(width<=120)width=120;
- else if(width<=140)width=140;
- else if(width<=158)width=158;
- else if(width<=200)width=200;
- else width=211;
- }
- adxd.xddata.xdint=width;// ACAD类型 KMCAD类型
- }
- adWriteExtendeddata(bcptr,&adxd);
- break;
- case DIMTXSTY://KMCAD编码
- {
- UINT kmid=(UINT)dsvar.varValue.intVal;
- AD_OBJHANDLE objhandle;
- if(m_awordstyle.Get(objhandle,kmid))
- {
- adxd.xddxfnumber=AD_XD_INT;
- adxd.xddata.xdint=340;//ACAD编码
- adWriteExtendeddata(bcptr,&adxd);
- adxd.xddxfnumber=1005;//ACAD类型
- adHancpy(adxd.xddata.xdhandle,objhandle);
- adWriteExtendeddata(bcptr,&adxd);
- }
- }
- break;
- default:
- break;
- }
- }
- adxd.xddxfnumber=AD_XD_CONTROL;
- adxd.xddata.xdcontrol='}';
- adWriteExtendeddata(bcptr,&adxd);
- //extern short ADCDECL adEndBlobWrite _((PAD_BLOB_CTRL bcptr));
- if(!adEndBlobWrite(bcptr))
- {
- return FALSE;
- }
- }
- catch(...)
- {
- return FALSE;
- }
- return TRUE;
- }
- BOOL CKmgReader::processdimstyle(CKmDataManager* pData)
- {
- CString strTemp;
- CDimStyle* dimstyle;
- for(int index=0;index<pData->GetDimStyleNum();index++)
- {
- pData->GetNoNDimStyle(index,dimstyle);
- if(!dimstyle)
- {
- continue;
- }
- adSetDefaultDimstyle(m_pConverter->m_dwghandle,&m_pConverter->adtb->dimst);
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- // short xrefindex; /* index of xref from which this item came */
- // char flag; /* flag for dimstyle */
- // char purgedflag; /* 1 if purged */
- // char name[AD_MAX_STRLEN]; /* name of dimension style */
- CString strName=m_pConverter->ConverterTabEntName(dimstyle->GetName());
- strcpy(m_pConverter->adtb->dimst.name,(char*)(LPCTSTR)strName);
- // short dimadec;
- var=dimstyle->GetDimStlVar(DIMADEC);
- m_pConverter->adtb->dimst.dimadec=var.intVal;
- // char dimalt; /* these ds variables are the dim vars */
- var=dimstyle->GetDimStlVar(DIMALT);
- m_pConverter->adtb->dimst.dimalt=(char)var.boolVal;
- // char dimaltd; /* associated with the dimension style */
- var=dimstyle->GetDimStlVar(DIMALTD);
- m_pConverter->adtb->dimst.dimaltd=var.intVal;
- // double dimaltf; /* currently being read from the */
- var=dimstyle->GetDimStlVar(DIMALTF);
- m_pConverter->adtb->dimst.dimaltf=var.dblVal;
- // double dimaltrnd;
- var=dimstyle->GetDimStlVar(DIMALTRND);
- m_pConverter->adtb->dimst.dimaltrnd=var.dblVal;
- // char dimapost[AD_MAX_STRLEN]; /* dimstyle table (R11) */
- var=dimstyle->GetDimStlVar(DIMAPOST);
- strTemp.Empty();
- strTemp=var.bstrVal;
- strcpy((char*)m_pConverter->adtb->dimst.dimapost,(char*)(LPCTSTR)strTemp);
- // double dimasz;
- var=dimstyle->GetDimStlVar(DIMASZ);
- m_pConverter->adtb->dimst.dimasz=var.dblVal;
- // short dimazin;
- var=dimstyle->GetDimStlVar(DIMAZIN);
- m_pConverter->adtb->dimst.dimazin=var.intVal;
- // double dimcen;
- var=dimstyle->GetDimStlVar(DIMCEN);
- m_pConverter->adtb->dimst.dimcen=var.dblVal;
- // short dimclrd;
- var=dimstyle->GetDimStlVar(DIMCLRD);
- {
- short scolor=1;
- int iColor=var.intVal;
- if(iColor==COLOR_BYLAYER)
- {
- scolor=AD_COLOR_BYLAYER;
- }
- else if(iColor==COLOR_BYBLOCK)
- {
- scolor=AD_COLOR_BYBLOCK;
- }
- else
- {
- for(int j=1;j<m_aColor.GetSize();j++)
- {
- if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
- fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
- fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
- {
- scolor=j;
- break;
- }
- }
- }
- m_pConverter->adtb->dimst.dimclrd=scolor;
- }
- // short dimclre;
- var=dimstyle->GetDimStlVar(DIMCLRE);
- {
- short scolor=1;
- int iColor=var.intVal;
- if(iColor==COLOR_BYLAYER)
- {
- scolor=AD_COLOR_BYLAYER;
- }
- else if(iColor==COLOR_BYBLOCK)
- {
- scolor=AD_COLOR_BYBLOCK;
- }
- else
- {
- for(int j=1;j<m_aColor.GetSize();j++)
- {
- if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
- fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
- fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
- {
- scolor=j;
- break;
- }
- }
- }
- m_pConverter->adtb->dimst.dimclre=scolor;
- }
- // short dimclrt;
- var=dimstyle->GetDimStlVar(DIMCLRT);
- {
- short scolor=1;
- int iColor=var.intVal;
- if(iColor==COLOR_BYLAYER)
- {
- scolor=AD_COLOR_BYLAYER;
- }
- else if(iColor==COLOR_BYBLOCK)
- {
- scolor=AD_COLOR_BYBLOCK;
- }
- else
- {
- for(int j=1;j<m_aColor.GetSize();j++)
- {
- if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
- fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
- fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
- {
- scolor=j;
- break;
- }
- }
- }
- m_pConverter->adtb->dimst.dimclrt=scolor;
- }
- // double dimdle;
- var=dimstyle->GetDimStlVar(DIMDLE);
- m_pConverter->adtb->dimst.dimdle=var.dblVal;
- // double dimdli;
- var=dimstyle->GetDimStlVar(DIMDLI);
- m_pConverter->adtb->dimst.dimdli=var.dblVal;
- // double dimexe;
- var=dimstyle->GetDimStlVar(DIMEXE);
- m_pConverter->adtb->dimst.dimexe=var.dblVal;
- // double dimexo;
- var=dimstyle->GetDimStlVar(DIMEXO);
- m_pConverter->adtb->dimst.dimexo=var.dblVal;
- // double dimgap;
- var=dimstyle->GetDimStlVar(DIMGAP);
- m_pConverter->adtb->dimst.dimgap=var.dblVal;
- // double dimlfac;
- var=dimstyle->GetDimStlVar(DIMLFAC);
- m_pConverter->adtb->dimst.dimlfac=var.dblVal;
- // char dimlim;
- var=dimstyle->GetDimStlVar(DIMLIM);
- m_pConverter->adtb->dimst.dimlim=(char)var.boolVal;
- // char dimpost[AD_MAX_STRLEN];
- var=dimstyle->GetDimStlVar(DIMPOST);
- strTemp.Empty();
- strTemp=var.bstrVal;
- strcpy((char*)m_pConverter->adtb->dimst.dimpost,(char*)(LPCTSTR)strTemp);
- // double dimrnd;
- var=dimstyle->GetDimStlVar(DIMRND);
- m_pConverter->adtb->dimst.dimrnd=var.dblVal;
- // char dimsah;
- var=dimstyle->GetDimStlVar(DIMSAH);
- m_pConverter->adtb->dimst.dimsah=(char)var.boolVal;
- // double dimscale;
- var=dimstyle->GetDimStlVar(DIMSCALE);
- m_pConverter->adtb->dimst.dimscale=var.dblVal;
- // char dimse1;
- var=dimstyle->GetDimStlVar(DIMSE1);
- m_pConverter->adtb->dimst.dimse1=(char)var.boolVal;
- // char dimse2;
- var=dimstyle->GetDimStlVar(DIMSE2);
- m_pConverter->adtb->dimst.dimse2=(char)var.boolVal;
- // double dimtfac;
- var=dimstyle->GetDimStlVar(DIMTFAC);
- m_pConverter->adtb->dimst.dimtfac=var.dblVal;
- // char dimtih;
- var=dimstyle->GetDimStlVar(DIMTIH);
- m_pConverter->adtb->dimst.dimtih=(char)var.boolVal;
- // double dimtm;
- var=dimstyle->GetDimStlVar(DIMTM);
- m_pConverter->adtb->dimst.dimtm=var.dblVal;
- // char dimtoh;
- var=dimstyle->GetDimStlVar(DIMTOH);
- m_pConverter->adtb->dimst.dimtoh=(char)var.boolVal;
- // char dimtofl;
- var=dimstyle->GetDimStlVar(DIMTOFL);
- m_pConverter->adtb->dimst.dimtofl=(char)var.boolVal;
- // char dimtol;
- var=dimstyle->GetDimStlVar(DIMTOL);
- m_pConverter->adtb->dimst.dimtol=(char)var.boolVal;
- // double dimtp;
- var=dimstyle->GetDimStlVar(DIMTP);
- m_pConverter->adtb->dimst.dimtp=var.dblVal;
- // double dimtsz;
- var=dimstyle->GetDimStlVar(DIMTSZ);
- m_pConverter->adtb->dimst.dimtsz=var.dblVal;
- // double dimtxt;
- var=dimstyle->GetDimStlVar(DIMTXT);
- m_pConverter->adtb->dimst.dimtxt=var.dblVal;
- // double dimtvp;
- var=dimstyle->GetDimStlVar(DIMTVP);
- m_pConverter->adtb->dimst.dimtvp=var.dblVal;
- // char dimsoxd;
- var=dimstyle->GetDimStlVar(DIMSOXD);
- m_pConverter->adtb->dimst.dimsoxd=(char)var.boolVal;
- // char dimtad;
- var=dimstyle->GetDimStlVar(DIMTAD);
- m_pConverter->adtb->dimst.dimtad=var.intVal;
- // char dimtix;
- var=dimstyle->GetDimStlVar(DIMTIX);
- m_pConverter->adtb->dimst.dimtix=var.intVal;
- // char dimzin;
- var=dimstyle->GetDimStlVar(DIMZIN);
- m_pConverter->adtb->dimst.dimzin=var.intVal;
- // short dimalttd;
- var=dimstyle->GetDimStlVar(DIMALTTD);
- m_pConverter->adtb->dimst.dimalttd=var.intVal;
- // char dimalttz;
- var=dimstyle->GetDimStlVar(DIMALTTZ);
- m_pConverter->adtb->dimst.dimalttz=var.intVal;
- // short dimaltu;
- var=dimstyle->GetDimStlVar(DIMALTU);
- m_pConverter->adtb->dimst.dimaltu=var.intVal;
- // char dimaltz;
- var=dimstyle->GetDimStlVar(DIMALTZ);
- m_pConverter->adtb->dimst.dimaltz=var.intVal;
- // short dimaunit;
- var=dimstyle->GetDimStlVar(DIMAUNIT);
- m_pConverter->adtb->dimst.dimaunit=var.intVal;
- // short dimdec;
- var=dimstyle->GetDimStlVar(DIMDEC);
- m_pConverter->adtb->dimst.dimdec=var.intVal;
- // char dimfit;
- var=dimstyle->GetDimStlVar(DIMATFIT);
- m_pConverter->adtb->dimst.dimfit=var.intVal;
- // char dimjust;
- var=dimstyle->GetDimStlVar(DIMJUST);
- m_pConverter->adtb->dimst.dimjust=var.intVal;
- // char dimsd1;
- var=dimstyle->GetDimStlVar(DIMSD1);
- m_pConverter->adtb->dimst.dimsd1=(char)var.boolVal;
- // char dimsd2;
- var=dimstyle->GetDimStlVar(DIMSD2);
- m_pConverter->adtb->dimst.dimsd2=(char)var.boolVal;
- // short dimtdec;
- var=dimstyle->GetDimStlVar(DIMTDEC);
- m_pConverter->adtb->dimst.dimtdec=var.intVal;
- // char dimtolj;
- var=dimstyle->GetDimStlVar(DIMTOLJ);
- m_pConverter->adtb->dimst.dimtolj=var.intVal;
- // char dimtzin;
- var=dimstyle->GetDimStlVar(DIMTZIN);
- m_pConverter->adtb->dimst.dimtzin=var.intVal;
- // short dimunit;
- var=dimstyle->GetDimStlVar(DIMLUNIT);
- m_pConverter->adtb->dimst.dimunit=var.intVal;
- // char dimupt;
- var=dimstyle->GetDimStlVar(DIMUPT);
- m_pConverter->adtb->dimst.dimupt=(char)var.boolVal;
- // short dimfrac;
- var=dimstyle->GetDimStlVar(DIMFRAC);
- m_pConverter->adtb->dimst.dimfrac=var.intVal;
- // short dimdsep;
- var=dimstyle->GetDimStlVar(DIMDSEP);
- m_pConverter->adtb->dimst.dimdsep=var.cVal;
- // short dimtmove;
- var=dimstyle->GetDimStlVar(DIMTMOVE);
- m_pConverter->adtb->dimst.dimtmove=var.intVal;
- // short dimlwd;
- var=dimstyle->GetDimStlVar(DIMLWD);
- {
- int width=var.intVal;
- int width2;
- if(width==ABS_THIN_WIDTH)
- {
- width2=0;
- }
- else if(width==LWIDTH_BYLAYER)
- {
- width2=AD_WEIGHT_BYLAYER;
- }
- else if(width==LWIDTH_BYBLOCK)
- {
- width2=AD_WEIGHT_BYBLOCK;
- }
- else
- {
- width2=(short)(::GetLineWidthAsDouble(width)*100.0);
- if(width2<=5)width2=5;
- else if(width2<=9)width2=9;
- else if(width2<=13)width2=13;
- else if(width2<=15)width2=15;
- else if(width2<=18)width2=18;
- else if(width2<=20)width2=20;
- else if(width2<=25)width2=25;
- else if(width2<=30)width2=30;
- else if(width2<=35)width2=35;
- else if(width2<=40)width2=40;
- else if(width2<=50)width2=50;
- else if(width2<=53)width2=53;
- else if(width2<=60)width2=60;
- else if(width2<=70)width2=70;
- else if(width2<=80)width2=80;
- else if(width2<=90)width2=90;
- else if(width2<=100)width2=100;
- else if(width2<=106)width2=106;
- else if(width2<=120)width2=120;
- else if(width2<=140)width2=140;
- else if(width2<=158)width2=158;
- else if(width2<=200)width2=200;
- else width2=211;
- }
- m_pConverter->adtb->dimst.dimlwd=width2;
- }
- // short dimlwe;
- var=dimstyle->GetDimStlVar(DIMLWE);
- {
- int width=var.intVal;
- int width2;
- if(width==ABS_THIN_WIDTH)
- {
- width2=0;
- }
- else if(width==LWIDTH_BYLAYER)
- {
- width2=AD_WEIGHT_BYLAYER;
- }
- else if(width==LWIDTH_BYBLOCK)
- {
- width2=AD_WEIGHT_BYBLOCK;
- }
- else
- {
- width2=(short)(::GetLineWidthAsDouble(width)*100.0);
- if(width2<=5)width2=5;
- else if(width2<=9)width2=9;
- else if(width2<=13)width2=13;
- else if(width2<=15)width2=15;
- else if(width2<=18)width2=18;
- else if(width2<=20)width2=20;
- else if(width2<=25)width2=25;
- else if(width2<=30)width2=30;
- else if(width2<=35)width2=35;
- else if(width2<=40)width2=40;
- else if(width2<=50)width2=50;
- else if(width2<=53)width2=53;
- else if(width2<=60)width2=60;
- else if(width2<=70)width2=70;
- else if(width2<=80)width2=80;
- else if(width2<=90)width2=90;
- else if(width2<=100)width2=100;
- else if(width2<=106)width2=106;
- else if(width2<=120)width2=120;
- else if(width2<=140)width2=140;
- else if(width2<=158)width2=158;
- else if(width2<=200)width2=200;
- else width2=211;
- }
- m_pConverter->adtb->dimst.dimlwe=width2;
- }
- // shapefileobjhandle;
- {
- AD_OBJHANDLE handle;
- var=dimstyle->GetDimStlVar(DIMTXSTY);
- if(m_awordstyle.Get(handle,(UINT)var.intVal))
- {
- adHancpy(m_pConverter->adtb->dimst.shapefileobjhandle,handle);
- }
- }
- // AD_OBJHANDLE objhandle
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->dimst.objhandle);
- //short ADCDECL adAddDimstyle _((AD_DB_HANDLE handle,PAD_DIMSTYLE dimst));
- if (!adAddDimstyle(m_pConverter->m_dwghandle,&m_pConverter->adtb->dimst))
- {
- _ERROR;
- continue;
- }
- m_adimstyle.Add(m_pConverter->adtb->dimst.objhandle,dimstyle->GetID(),1.0,FALSE);
- }
- return TRUE;
- }
- BOOL CKmgReader::processwordstyle(CKmDataManager* pData)
- {
- CString strTemp;
- CWordStyle ws;
- for(int i=0;i<pData->GetWordStyleNum();i++)
- {
- ws=pData->GetWordStyle(i);
- //void adSetDefaultShapefile (PAD_SHPTB shptb);
- adSetDefaultShapefile(&m_pConverter->adtb->shptb);
- // CString m_strFontName; //字体名称
- // BOOL bTTF=TRUE;
- {
- strTemp.Empty();
- strTemp=ws.GetFontName();
- // CString strTemp2=strTemp;
- // strTemp2.MakeLower();
- // if(strTemp2.Find(".shx")!=-1)
- // {
- // bTTF=FALSE;
- // }
- int i=strTemp.Find(';');
- if(i>=0&&i<strTemp.GetLength())
- {
- ::strcpy(m_pConverter->adtb->shptb.file,(char*)(LPCTSTR)strTemp.Left(i));
- ::strcpy(m_pConverter->adtb->shptb.bigfontname,(char*)(LPCTSTR)strTemp.Right(strTemp.GetLength()-i-1));
- }
- else
- {
- ::strcpy(m_pConverter->adtb->shptb.file,(char*)(LPCTSTR)strTemp);
- }
- }
- // double m_dHeight; //字高
- m_pConverter->adtb->shptb.height=ws.GetHeight();
- // CString m_strName;
- CString strName=m_pConverter->ConverterTabEntName(ws.GetName());
- ::strcpy(m_pConverter->adtb->shptb.name,(char*)(LPCTSTR)strName);
- // double m_dWFactor; //字宽因子,为字宽和字高的比例
- m_pConverter->adtb->shptb.width=/*ws.GetHeight()*/ws.GetWFactor();
- // double m_dPFactor; //字间距因子,为字间距与字宽的比例
- // BYTE m_bDir; //方向,0,1,2,3分别表示0,90,180,270度。
- if(ws.GetDirection()==1)
- m_pConverter->adtb->shptb.angle=PI*0.5;
- else if(ws.GetDirection()==2)
- m_pConverter->adtb->shptb.angle=PI;
- else if(ws.GetDirection()==3)
- m_pConverter->adtb->shptb.angle=PI*1.5;
- else
- m_pConverter->adtb->shptb.angle=0;
- /* if(bTTF)
- {
- AD_VMADDR theblob;
- PAD_BLOB_CTRL bcptr;
- AD_XD badxd;
- theblob=adCreateBlob();
- bcptr=adStartBlobWrite(theblob);
- {
- badxd.xddxfnumber=1002;
- badxd.xddata.xdcontrol='{';
- adWriteExtendeddata(bcptr,&badxd);
- }
- if(!adStartRegappGet(m_pConverter->m_dwghandle))
- {
- _ERROR;
- }
- else if(!adGetRegapp(m_pConverter->m_dwghandle,&m_pConverter->adtb->app))
- {
- _ERROR;
- }
- else
- {
- adHancpy(badxd.xddata.xdappobjhandle,m_pConverter->adtb->app.objhandle);
- badxd.xddxfnumber=1001;
- adWriteExtendeddata(bcptr,&badxd);
- }
- {
- badxd.xddxfnumber=1000;
- try
- {
- ::memcpy(badxd.xddata.xdstring,(char*)(LPCTSTR)strTemp,strTemp.GetLength());
- badxd.xddata.xdstring[strTemp.GetLength()]=0;
- }
- catch(...)
- {
- }
- adWriteExtendeddata(bcptr,&badxd);
- }
- {
- badxd.xddxfnumber=1002;
- badxd.xddata.xdcontrol='}';
- adWriteExtendeddata(bcptr,&badxd);
- }
- adEndBlobWrite(bcptr);
- }*/
- adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
- //short adAddShapefile (AD_DB_HANDLE handle, PAD_SHPTB shptb);
- if (!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
- {
- _ERROR;
- continue;
- }
- m_awordstyle.Add(m_pConverter->adtb->shptb.objhandle,ws.GetID(),1.0,FALSE);
- }
- return TRUE;
- }
- BOOL CKmgReader::processlegend(CKmDataManager* pData)
- {
- KmLegend* pLegend=pData->GetLegend();
- if(pLegend == NULL)
- {
- return FALSE;
- }
- CMatch2* match=new CMatch2;
- //1.创建块定义
- m_pConverter->ConverterEntity_KmBlockdef("KmLegend",match);
- m_pConverter->SetBlockDataVassel(match->m_handle);
- //2.增加AD_ENT_BLOCK
- m_pConverter->AddBegBlkSign(0.0,0.0,0.0);
- m_pConverter->ConverterKmLegend(pLegend->GetLocate().x,pLegend->GetLocate().y,pLegend->GetXLength(),pLegend->GetYLength());
- KmBuffer buff;
- CShow* pShow = new CGDIShow((CWnd*)NULL);
- pLegend->Draw(pShow,DRAWPRESENT,&buff);
- int size=buff.GetLineBuffSize();
- for(int j=0;j<size;j++)
- {
- if(!processentity_buf_line(pData,buff.GetLineEnt(j)))
- {
- _WRITE(str="转换buf直线失败");
- }
- }
- size=buff.GetCircleBuffSize();
- for(j=0;j<size;j++)
- {
- if(!processentity_buf_circle(pData,buff.GetCircleEnt(j)))
- {
- _WRITE(str="转换buf圆失败");
- }
- }
- size=buff.GetRegionBuffSize();
- for(j=0;j<size;j++)
- {
- if(!processentity_buf_region(pData,buff.GetRegionEnt(j)))
- {
- _WRITE(str="转换buf区域失败");
- }
- }
- size=buff.GetTextBuffSize();
- for(j=0;j<size;j++)
- {
- if(!processentity_buf_text(pData,buff.GetTextEnt(j)))
- {
- _WRITE(str="转换buf文字失败");
- }
- }
- delete pShow;
- buff.ClearKmBuffer();
- //3.增加AD_ENT_ENDBLK
- m_pConverter->AddEndBlkSign();
- m_pConverter->ConverterEntity_AdInsert(0.0,0.0,0.0,1.0,1.0,1.0,0.0,match->m_handle);
- delete match;
- return TRUE;
- }
- BOOL CKmgReader::processblockdef(CKmDataManager* pData)
- {
- CMatch2* match=new CMatch2;
- KmBlockDef* pDef=pData->GetFirstBlockDef();
- while(pDef!=NULL)
- {
- match->m_id=pDef->GetID();
- if(m_pConverter->ConverterEntity_KmBlockdef(pDef->GetName(),match))
- {
- m_ablock.Add(match->m_handle,match->m_id,1.0,FALSE);
- }
- pDef=pData->GetNextBlockDef();
- }
- delete match;
- return TRUE;
- }
- //处理块嵌套因此与块定义分开处理
- BOOL CKmgReader::processblockdefentity(CKmDataManager* pData)
- {
- KmBlockDef* pDef;
- KmObject* pObj;
- CMatch2* match;
- POSITION pos=m_ablock.GetHeadPosition();
- while(pos!=NULL)
- {
- match=m_ablock.GetNext(pos);
- pDef=pData->GetBlockDef(match->m_id);
- if(pDef!=NULL)
- {
- m_pConverter->SetBlockDataVassel(match->m_handle);
- _ERROR;
- m_pConverter->AddBegBlkSign(pDef->GetBasePt().x,pDef->GetBasePt().y,0);
- for(UINT i=0;i<pDef->GetObjectNum();i++)
- {
- pDef->GetObjectAt(i,pObj);
- if(!processentity(pData,pObj))
- {
- _ERROR;
- _WRITE(str.Format("%s+%d+没有处理",pObj->Type(),pObj->GetObjectID().dwEntIndex));
- }
- }
- m_pConverter->AddEndBlkSign();
- _ERROR;
- }
- }
- m_pConverter->SetModelDataVassel();
- return TRUE;
- }