Processfile6.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:60k
源码类别:

CAD

开发平台:

Visual C++

  1. //      KMCAD40-FileSwitch-Processfile6.cpp-1.0 
  2. // KmgReader.cpp: implementation of the CKmgReader class.
  3. //
  4. //////////////////////////////////////////////////////////////////////
  5. //KMCAD40-FileSwitch-Processfile6.cpp-1.0 -> 1.1
  6. #include "stdafx.h"
  7. #include "DSSubst.h"
  8. #include "FileSwitch.h"
  9. #include "KmgReader.h"
  10. #include "Database.h"
  11. #include "Reader.h"
  12. #include "KmLayer.h"
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[]=__FILE__;
  16. #define new DEBUG_NEW
  17. #endif
  18. #define MODE_SIMPLEEST (1)
  19. #define MODE_NORMAL (2)
  20. extern CStdioFile g_CensorialFile;
  21. extern int g_mode;
  22. BOOL CKmgReader::processfile(CKmDataManager* pData)
  23. {
  24. int convmode=::AfxGetApp()->GetProfileInt(_T("Kmg2Dwg"),_T("ConvMode"),MODE_NORMAL);
  25. switch(convmode)
  26. {
  27. case MODE_SIMPLEEST:
  28. break;
  29. case MODE_NORMAL:
  30. break;
  31. default:
  32. convmode=MODE_NORMAL;
  33. break;
  34. }
  35. ::AfxGetApp()->WriteProfileInt(_T("Kmg2Dwg"),_T("ConvMode"),convmode);
  36. m_pProgress->SetProgressInfoAbsolute(0.10,"分析颜色...");
  37. if(!processcolor(pData))
  38. {
  39. _WRITE(str="转换颜色失败");
  40. return FALSE;
  41. }
  42. m_pProgress->SetProgressInfoAbsolute(0.11,"分析线宽...");
  43. if(!processlwidth(pData))
  44. {
  45. _WRITE(str="转换线宽失败");
  46. return FALSE;
  47. }
  48. /* //设定型文件
  49. adSetDefaultShapefile(&m_pConverter->adtb->shptb);
  50. strcpy(m_pConverter->adtb->shptb.name,"CHINESE");
  51. m_pConverter->adtb->shptb.height=0.0;
  52. m_pConverter->adtb->shptb.width=0.8;
  53. m_pConverter->adtb->shptb.angle=0.0;
  54. m_pConverter->adtb->shptb.flag2=0;
  55. m_pConverter->adtb->shptb.lastshapeheight= 5 ;
  56. strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
  57. strcpy(m_pConverter->adtb->shptb.file,"txt");
  58. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
  59. if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
  60. {
  61. _ERROR;
  62. }
  63. //设定型文件
  64. adSetDefaultShapefile(&m_pConverter->adtb->shptb);
  65. strcpy(m_pConverter->adtb->shptb.name,"CHINESE3");
  66. m_pConverter->adtb->shptb.height=0.0;
  67. m_pConverter->adtb->shptb.width=0.8;
  68. m_pConverter->adtb->shptb.angle=0.0;
  69. m_pConverter->adtb->shptb.flag2=0;
  70. m_pConverter->adtb->shptb.lastshapeheight= 5 ;
  71. strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
  72. strcpy(m_pConverter->adtb->shptb.file,"txt");
  73. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
  74. if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
  75. {
  76. _ERROR;
  77. }
  78. //设定型文件
  79. adSetDefaultShapefile(&m_pConverter->adtb->shptb);
  80. strcpy(m_pConverter->adtb->shptb.name,"CHINESE2");
  81. m_pConverter->adtb->shptb.height=0.0;
  82. m_pConverter->adtb->shptb.width=0.8;
  83. m_pConverter->adtb->shptb.angle=0.0;
  84. m_pConverter->adtb->shptb.flag2=0;
  85. m_pConverter->adtb->shptb.lastshapeheight= 5 ;
  86. strcpy(m_pConverter->adtb->shptb.bigfontname,"hztxt");
  87. strcpy(m_pConverter->adtb->shptb.file,"txt");
  88. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
  89. if(!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
  90. {
  91. _ERROR;
  92. }*/
  93. m_pProgress->SetProgressInfoAbsolute(0.12,"分析线形...");
  94. if(!processltype(pData))
  95. {
  96. _WRITE(str="转换线形失败");
  97. return FALSE;
  98. }
  99. m_pProgress->SetProgressInfoAbsolute(0.13,"分析层...");
  100. if(!processlayer(pData))
  101. {
  102. _WRITE(str="转换层失败");
  103. return FALSE;
  104. }
  105. if(!processwordstyle(pData))
  106. {
  107. _WRITE(str="转换文字样式失败");
  108. return FALSE;
  109. }
  110. if(!processdimstyle(pData))
  111. {
  112. _WRITE(str="转换尺寸样式失败");
  113. return FALSE;
  114. }
  115. m_pProgress->SetProgressInfoAbsolute(0.14,"分析块定义...");
  116. if(!processblockdef(pData))
  117. {
  118. _WRITE(str="转换块定义失败");
  119. return FALSE;
  120. }
  121. if(!processblockdefentity(pData))
  122. {
  123. _WRITE(str="转换块定义中的实体失败");
  124. return FALSE;
  125. }
  126. m_pProgress->SetProgressInfoAbsolute(0.30,"分析实体...");
  127. if(!processentity(pData))
  128. {
  129. _WRITE(str="转换实体失败");
  130. return FALSE;
  131. }
  132. m_pProgress->SetProgressInfoAbsolute(0.95,"识别图框...");
  133. if(!processlegend(pData))
  134. {
  135. _WRITE(str="转换图框失败");
  136. return FALSE;
  137. }
  138. return TRUE;
  139. }
  140. BOOL CKmgReader::processltype(CKmDataManager* pData)
  141. {
  142. // adStartLinetypeGet(m_pConverter->m_dwghandle);
  143. // if(adFindLinetypeByName(m_pConverter->m_dwghandle,"Continuous",m_pConverter->adtb->ltype.objhandle))
  144. // {
  145. // adDeleteLinetype(m_pConverter->m_dwghandle,m_pConverter->adtb->ltype.objhandle);
  146. // }
  147. AD_LTYPE adtbdata[15];
  148. for(int i=0;i<15;i++)
  149. {
  150. int kmtype;
  151. adSetDefaultLinetype(&adtbdata[i]);
  152. switch(i)
  153. {
  154. case 0:
  155. strcpy(adtbdata[i].name,"KM_SOLID");
  156. strcpy(adtbdata[i].text,"东方实线");
  157. adtbdata[i].numlinetypesegs=0;
  158. adtbdata[i].patternlength=0.0;
  159. kmtype=SOLID_LINE;
  160. break;
  161. case 1:
  162. strcpy(adtbdata[i].name,"KM_DASH");
  163. strcpy(adtbdata[i].text,"东方虚线");
  164. adtbdata[i].numlinetypesegs=2;
  165. adtbdata[i].patternlength=7.0;
  166. adtbdata[i].segdata[0].val=5.0;
  167. adtbdata[i].segdata[1].val=-2.0;
  168. kmtype=DASHED_LINE;
  169. break;
  170. case 2:
  171. strcpy(adtbdata[i].name,"KM_DOT");
  172. strcpy(adtbdata[i].text,"东方点线");
  173. adtbdata[i].numlinetypesegs=2;
  174. adtbdata[i].patternlength=4.0;
  175. adtbdata[i].segdata[0].val=2.0;
  176. adtbdata[i].segdata[1].val=-2.0;
  177. kmtype=DOT_LINE;
  178. break;
  179. case 3:
  180. strcpy(adtbdata[i].name,"KM_SPACE");
  181. strcpy(adtbdata[i].text,"东方间隔线");
  182. adtbdata[i].numlinetypesegs=2;
  183. adtbdata[i].patternlength=10.0;
  184. adtbdata[i].segdata[0].val=5.0;
  185. adtbdata[i].segdata[1].val=-7.0;
  186. kmtype=DASH_SPACE_LINE;
  187. break;
  188. case 4:
  189. strcpy(adtbdata[i].name,"KM_LONGDASH_SHORTDASH");
  190. strcpy(adtbdata[i].text,"东方长画短画线");
  191. adtbdata[i].numlinetypesegs=4;
  192. adtbdata[i].patternlength=17.0;
  193. adtbdata[i].segdata[0].val=10.0;
  194. adtbdata[i].segdata[1].val=-2.0;
  195. adtbdata[i].segdata[2].val=3.0;
  196. adtbdata[i].segdata[3].val=-2.0;
  197. kmtype=LONGDASH_SHORTDASH_LINE;
  198. break;
  199. case 5:
  200. strcpy(adtbdata[i].name,"KM_LONGDASH_2SHORTDASH");
  201. strcpy(adtbdata[i].text,"东方长画双短画线");
  202. adtbdata[i].numlinetypesegs=6;
  203. adtbdata[i].patternlength=22.0;
  204. adtbdata[i].segdata[0].val=10.0;
  205. adtbdata[i].segdata[1].val=-2.0;
  206. adtbdata[i].segdata[2].val=3.0;
  207. adtbdata[i].segdata[3].val=-2.0;
  208. adtbdata[i].segdata[4].val=3.0;
  209. adtbdata[i].segdata[5].val=-2.0;
  210. kmtype=LONGDASH_DSHORTDASH_LINE;
  211. break;
  212. case 6:
  213. strcpy(adtbdata[i].name,"KM_SHORTDASH_DOT");
  214. strcpy(adtbdata[i].text,"东方短画点线");
  215. adtbdata[i].numlinetypesegs=4;
  216. adtbdata[i].patternlength=10.0;
  217. adtbdata[i].segdata[0].val=5.0;
  218. adtbdata[i].segdata[1].val=-2.0;
  219. adtbdata[i].segdata[2].val=1.0;
  220. adtbdata[i].segdata[3].val=-2.0;
  221. kmtype=SHORTDASH_DOT_LINE;
  222. break;
  223. case 7:
  224. strcpy(adtbdata[i].name,"KM_2SHORTDASH_DOT");
  225. strcpy(adtbdata[i].text,"东方双短画点线");
  226. adtbdata[i].numlinetypesegs=6;
  227. adtbdata[i].patternlength=17.0;
  228. adtbdata[i].segdata[0].val=5.0;
  229. adtbdata[i].segdata[1].val=-2.0;
  230. adtbdata[i].segdata[2].val=5.0;
  231. adtbdata[i].segdata[3].val=-2.0;
  232. adtbdata[i].segdata[4].val=1.0;
  233. adtbdata[i].segdata[5].val=-2.0;
  234. kmtype=DDASH_DOT_LINE;
  235. break;
  236. case 8:
  237. strcpy(adtbdata[i].name,"KM_POINT");
  238. strcpy(adtbdata[i].text,"东方点划线");
  239. adtbdata[i].numlinetypesegs=4;
  240. adtbdata[i].patternlength=15.0;
  241. adtbdata[i].segdata[0].val=10.0;
  242. adtbdata[i].segdata[1].val=-2.0;
  243. adtbdata[i].segdata[2].val=1.0;
  244. adtbdata[i].segdata[3].val=-2.0;
  245. kmtype=POINT_LINE;
  246. break;
  247. case 9:
  248. strcpy(adtbdata[i].name,"KM_SHORTDASH_2DOT");
  249. strcpy(adtbdata[i].text,"东方短画双点线");
  250. adtbdata[i].numlinetypesegs=6;
  251. adtbdata[i].patternlength=13.0;
  252. adtbdata[i].segdata[0].val=5.0;
  253. adtbdata[i].segdata[1].val=-2.0;
  254. adtbdata[i].segdata[2].val=1.0;
  255. adtbdata[i].segdata[3].val=-2.0;
  256. adtbdata[i].segdata[4].val=1.0;
  257. adtbdata[i].segdata[5].val=-2.0;
  258. kmtype=SDASH_DDOT_LINE;
  259. break;
  260. case 10:
  261. strcpy(adtbdata[i].name,"KM_2SHORTDASH_2DOT");
  262. strcpy(adtbdata[i].text,"东方双短画双点线");
  263. adtbdata[i].numlinetypesegs=8;
  264. adtbdata[i].patternlength=20.0;
  265. adtbdata[i].segdata[0].val=5.0;
  266. adtbdata[i].segdata[1].val=-2.0;
  267. adtbdata[i].segdata[2].val=5.0;
  268. adtbdata[i].segdata[3].val=-2.0;
  269. adtbdata[i].segdata[4].val=1.0;
  270. adtbdata[i].segdata[5].val=-2.0;
  271. adtbdata[i].segdata[6].val=1.0;
  272. adtbdata[i].segdata[7].val=-2.0;
  273. kmtype=DDASH_DDOT_LINE;
  274. break;
  275. case 11:
  276. strcpy(adtbdata[i].name,"KM_POINT_POINT");
  277. strcpy(adtbdata[i].text,"东方双点划线");
  278. adtbdata[i].numlinetypesegs=6;
  279. adtbdata[i].patternlength=18.0;
  280. adtbdata[i].segdata[0].val=10.0;
  281. adtbdata[i].segdata[1].val=-2.0;
  282. adtbdata[i].segdata[2].val=1.0;
  283. adtbdata[i].segdata[3].val=-2.0;
  284. adtbdata[i].segdata[4].val=1.0;
  285. adtbdata[i].segdata[5].val=-2.0;
  286. kmtype=DOUBLE_POINT_LINE;
  287. break;
  288. case 12:
  289. strcpy(adtbdata[i].name,"KM_SHORTDASH_3DOT");
  290. strcpy(adtbdata[i].text,"东方短画三点线");
  291. adtbdata[i].numlinetypesegs=8;
  292. adtbdata[i].patternlength=16.0;
  293. adtbdata[i].segdata[0].val=5.0;
  294. adtbdata[i].segdata[1].val=-2.0;
  295. adtbdata[i].segdata[2].val=1.0;
  296. adtbdata[i].segdata[3].val=-2.0;
  297. adtbdata[i].segdata[4].val=1.0;
  298. adtbdata[i].segdata[5].val=-2.0;
  299. adtbdata[i].segdata[6].val=1.0;
  300. adtbdata[i].segdata[7].val=-2.0;
  301. kmtype=SDASH_TRIDOT_LINE;
  302. break;
  303. case 13:
  304. strcpy(adtbdata[i].name,"KM_2SHORTDASH_3DOT");
  305. strcpy(adtbdata[i].text,"东方双点画三点线");
  306. adtbdata[i].numlinetypesegs=10;
  307. adtbdata[i].patternlength=23.0;
  308. adtbdata[i].segdata[0].val=5.0;
  309. adtbdata[i].segdata[1].val=-2.0;
  310. adtbdata[i].segdata[2].val=5.0;
  311. adtbdata[i].segdata[3].val=-2.0;
  312. adtbdata[i].segdata[4].val=1.0;
  313. adtbdata[i].segdata[5].val=-2.0;
  314. adtbdata[i].segdata[6].val=1.0;
  315. adtbdata[i].segdata[7].val=-2.0;
  316. adtbdata[i].segdata[8].val=1.0;
  317. adtbdata[i].segdata[9].val=-2.0;
  318. kmtype=DDASH_TRIDOT_LINE;
  319. break;
  320. case 14:
  321. strcpy(adtbdata[i].name,"KM_3DOT");
  322. strcpy(adtbdata[i].text,"东方三点线");
  323. adtbdata[i].numlinetypesegs=8;
  324. adtbdata[i].patternlength=21.0;
  325. adtbdata[i].segdata[0].val=10.0;
  326. adtbdata[i].segdata[1].val=-2.0;
  327. adtbdata[i].segdata[2].val=1.0;
  328. adtbdata[i].segdata[3].val=-2.0;
  329. adtbdata[i].segdata[4].val=1.0;
  330. adtbdata[i].segdata[5].val=-2.0;
  331. adtbdata[i].segdata[6].val=1.0;
  332. adtbdata[i].segdata[7].val=-2.0;
  333. kmtype=DASH_TRIDOT_LINE ;
  334. break;
  335. }
  336. for(int j=0;j<adtbdata[i].numlinetypesegs;j++)
  337. {
  338. adHanclear(adtbdata[i].segdata[j].shapeentryobjhandle);
  339. adtbdata[i].segdata[j].complexshapecode=0;
  340. adtbdata[i].segdata[j].xoffset=0.0;
  341. adtbdata[i].segdata[j].yoffset=0.0;
  342. adtbdata[i].segdata[j].rotang=0.0;
  343. adtbdata[i].segdata[j].scale=0.0;
  344. adtbdata[i].segdata[j].shapeflag=0;
  345. adtbdata[i].segdata[j].stroffset=0;
  346. }
  347. adGenerateObjhandle(m_pConverter->m_dwghandle,adtbdata[i].objhandle);
  348. try
  349. {
  350. if (!adAddLinetype(m_pConverter->m_dwghandle,&adtbdata[i]))
  351. {
  352. _ERROR;
  353. continue;
  354. }
  355. }
  356. catch(...)
  357. {
  358. }
  359. m_altype.Add(adtbdata[i].objhandle,kmtype,0.0,0);
  360. }
  361. AD_OBJHANDLE *ohptr=adShadowObjhandlePtr(m_pConverter->m_dwghandle);
  362. m_altype.Add(ohptr[BYBLOCKLTPSHADOW],LTYPE_BYBLOCK,0.0,0);
  363. m_altype.Add(ohptr[BYLAYERLTPSHADOW],LTYPE_BYLAYER,0.0,0);
  364. return TRUE;
  365. }
  366. BOOL CKmgReader::processcolor(CKmDataManager* pData)
  367. {
  368. short ACI[240]=
  369. { 255,255,206,206,156,156,123,123,74 ,74 , //顶峰
  370. 255,255,206,206,156,156,123,123,74 ,74 ,
  371. 255,255,206,206,156,156,123,123,74 ,74 ,
  372. 255,255,206,206,156,156,123,123,74 ,74 ,
  373. 255,255,206,206,156,156,123,123,74 ,74 ,
  374. 189,255,156,206,115,156,90 ,123,57 ,74 ,
  375. 123,222,99 ,181,74 ,132,57 ,107,33 ,66 ,
  376. 57 ,189,49 ,156,33 ,115,24 ,90 ,16 ,57 ,
  377. 0  ,156,0  ,123,0  ,90 ,0  ,74 ,0  ,41 ,
  378. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  379. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  380. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  381. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,//低谷
  382. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  383. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  384. 0  ,123,0  ,99 ,0  ,74 ,0  ,57 ,0  ,33 ,
  385. 0  ,156,0  ,123,0  ,90 ,0  ,74 ,0  ,41 ,
  386. 57 ,189,49 ,156,33 ,115,24 ,90 ,16 ,57 ,
  387. 123,222,99 ,181,74 ,132,57 ,107,33 ,66 ,
  388. 189,255,156,206,115,156,90 ,123,57 ,74 ,
  389. 255,255,206,206,156,156,123,123,74 ,74 ,
  390. 255,255,206,206,156,156,123,123,74 ,74 ,
  391. 255,255,206,206,156,156,123,123,74 ,74 ,
  392. 255,255,206,206,156,156,123,123,74 ,74 
  393. };
  394. try
  395. {
  396. m_aColor.SetSize(256);
  397. }
  398. catch(CMemoryException* e)
  399. {
  400. TCHAR szCause[255];
  401. e->GetErrorMessage(szCause, 255);
  402. _WRITE(str=szCause);
  403. return FALSE;
  404. }
  405. catch(...)
  406. {
  407. _WRITE(str="颜色转换时发生未知错误");
  408. return FALSE;
  409. }
  410. m_aColor[1]=(int)RGB(255,0,0);
  411. m_aColor[2]=(int)RGB(255,255,0);
  412. m_aColor[3]=(int)RGB(0,255,0);
  413. m_aColor[4]=(int)RGB(0,255,255);
  414. m_aColor[5]=(int)RGB(0,0,255);
  415. m_aColor[6]=(int)RGB(255,0,255);
  416. m_aColor[7]=0;//黑/白缺省颜色是 7,白色或黑色(由背景色决定)。所有其他颜色必须由 ACI 编号指定(8 到 255)。
  417. m_aColor[8]=(int)RGB(132,130,132);
  418. m_aColor[9]=(int)RGB(198,195,198);
  419. int i;
  420. for(i=10;i<90;i++)
  421. {
  422. m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160*/i+150],ACI[/*i-10+320-240*/i+70]);
  423. }
  424. for(i=90;i<170;i++)
  425. {
  426. m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160-240*/i-90],ACI[/*i-10+320-240*/i+70]);
  427. }
  428. for(i=170;i<250;i++)
  429. {
  430. m_aColor[i]=(int)RGB(ACI[i-10],ACI[/*i-10+160-240*/i-90],ACI[/*i-10+320-240-240*/i-170]);
  431. }
  432. m_aColor[250]=(int)RGB(49,48,49);
  433. m_aColor[251]=(int)RGB(90,89,90);
  434. m_aColor[252]=(int)RGB(132,134,132);
  435. m_aColor[253]=(int)RGB(173,174,173);
  436. m_aColor[254]=(int)RGB(214,215,214);
  437. m_aColor[255]=(int)RGB(255,255,255);
  438. return TRUE;
  439. }
  440. BOOL CKmgReader::processlwidth(CKmDataManager* pData)
  441. {
  442. return TRUE;
  443. }
  444. BOOL CKmgReader::processlayer(CKmDataManager* pData)
  445. {
  446. KmLayer* pLayer;
  447. for(UINT i=0;i<pData->LayerNum();i++)
  448. {
  449. pLayer=pData->GetALayer(i);
  450. //void adSetDefaultLayer (AD_DB_HANDLE handle, PAD_LAY lay);
  451. adSetDefaultLayer(m_pConverter->m_dwghandle,&m_pConverter->adtb->lay);
  452. CString strName=m_pConverter->ConverterTabEntName(pLayer->GetName());
  453. strcpy(m_pConverter->adtb->lay.name,(char*)(LPCTSTR)strName);
  454. short scolor=1;
  455. for(int j=1;j<m_aColor.GetSize();j++)
  456. {
  457. if( (fabs(GetRValue(pLayer->GetColor())-GetRValue(m_aColor[j]))+
  458.  fabs(GetGValue(pLayer->GetColor())-GetGValue(m_aColor[j]))+
  459.  fabs(GetBValue(pLayer->GetColor())-GetBValue(m_aColor[j])))<20)
  460. {
  461. scolor=j;
  462. break;
  463. }
  464. }
  465. m_pConverter->adtb->lay.color=scolor;
  466. m_altype.Get(m_pConverter->adtb->lay.linetypeobjhandle,pLayer->GetLineType());
  467. short swidth=(short)(::GetLineWidthAsDouble(pLayer->GetLineWidth())*100.0);
  468. if(swidth<=5)swidth=5;
  469. else if(swidth<=9)swidth=9;
  470. else if(swidth<=13)swidth=13;
  471. else if(swidth<=15)swidth=15;
  472. else if(swidth<=18)swidth=18;
  473. else if(swidth<=20)swidth=20;
  474. else if(swidth<=25)swidth=25;
  475. else if(swidth<=30)swidth=30;
  476. else if(swidth<=35)swidth=35;
  477. else if(swidth<=40)swidth=40;
  478. else if(swidth<=50)swidth=50;
  479. else if(swidth<=53)swidth=53;
  480. else if(swidth<=60)swidth=60;
  481. else if(swidth<=70)swidth=70;
  482. else if(swidth<=80)swidth=80;
  483. else if(swidth<=90)swidth=90;
  484. else if(swidth<=100)swidth=100;
  485. else if(swidth<=106)swidth=106;
  486. else if(swidth<=120)swidth=120;
  487. else if(swidth<=140)swidth=140;
  488. else if(swidth<=158)swidth=158;
  489. else if(swidth<=200)swidth=200;
  490. else swidth=211;
  491. m_pConverter->adtb->lay.lineweight=swidth;
  492. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->lay.objhandle);
  493. m_pConverter->adtb->lay.flag=0;
  494. if(pLayer->IsFrozen())
  495. {
  496. //在kmcad2002中冻结层内的实体可见,而autocad中冻结层内的实体不可见,
  497. //因此为里保证在kmcad2002中可见的实体在autocad中也可见,层的冻结属性
  498. //不转换, by hq 2003.4.22.
  499. //m_pConverter->adtb->lay.flag|=AD_LAYER_FROZEN;
  500. }
  501. if(pLayer->IsOff())
  502. {
  503. m_pConverter->adtb->lay.flag|=AD_LAYER_LOCKED;
  504. }
  505. if (!adAddLayer(m_pConverter->m_dwghandle,&m_pConverter->adtb->lay))
  506. {
  507. _ERROR;
  508. continue;
  509. }
  510. m_alayer.Add(m_pConverter->adtb->lay.objhandle,pLayer->GetID(),0.0,FALSE);
  511. }
  512. return TRUE;
  513. }
  514. BOOL CKmgReader::processentityhead(CKmDataManager* pData,KmObject* pObj)
  515. {
  516. //1
  517. short scolor;
  518. if(pObj->color==COLOR_BYBLOCK)
  519. {
  520. scolor=AD_COLOR_BYBLOCK;
  521. }
  522. else if(pObj->color==COLOR_BYLAYER)
  523. {
  524. scolor=AD_COLOR_BYLAYER;
  525. }
  526. else
  527. {
  528. scolor=AD_COLOR_BYLAYER;
  529. for(int i=1;i<m_aColor.GetSize();i++)
  530. {
  531. if( (fabs(GetRValue(pObj->color)-GetRValue(m_aColor[i]))+
  532.  fabs(GetGValue(pObj->color)-GetGValue(m_aColor[i]))+
  533.  fabs(GetBValue(pObj->color)-GetBValue(m_aColor[i])))<20)
  534. {
  535. scolor=i;
  536. break;
  537. }
  538. }
  539. }
  540. //2
  541. short swidth=1;
  542. double dscale=1.0;
  543. AD_OBJHANDLE hltype;
  544. if((pObj)->width==ABS_THIN_WIDTH)
  545. {
  546. swidth=0;
  547. }
  548. else if((pObj)->width==LWIDTH_BYLAYER)
  549. {
  550. swidth=(short)AD_WEIGHT_BYLAYER;
  551. }
  552. else if((pObj)->width==LWIDTH_BYBLOCK)
  553. {
  554. swidth=(short)AD_WEIGHT_BYBLOCK;
  555. }
  556. else
  557. {
  558. swidth=(short)(::GetLineWidthAsDouble((pObj)->width)*100.0);
  559. if(swidth<=5)swidth=5;
  560. else if(swidth<=9)swidth=9;
  561. else if(swidth<=13)swidth=13;
  562. else if(swidth<=15)swidth=15;
  563. else if(swidth<=18)swidth=18;
  564. else if(swidth<=20)swidth=20;
  565. else if(swidth<=25)swidth=25;
  566. else if(swidth<=30)swidth=30;
  567. else if(swidth<=35)swidth=35;
  568. else if(swidth<=40)swidth=40;
  569. else if(swidth<=50)swidth=50;
  570. else if(swidth<=53)swidth=53;
  571. else if(swidth<=60)swidth=60;
  572. else if(swidth<=70)swidth=70;
  573. else if(swidth<=80)swidth=80;
  574. else if(swidth<=90)swidth=90;
  575. else if(swidth<=100)swidth=100;
  576. else if(swidth<=106)swidth=106;
  577. else if(swidth<=120)swidth=120;
  578. else if(swidth<=140)swidth=140;
  579. else if(swidth<=158)swidth=158;
  580. else if(swidth<=200)swidth=200;
  581. else swidth=211;
  582. }
  583. if(pObj->GetRuntimeClass()->IsDerivedFrom(RUNTIME_CLASS(KmCurve)))
  584. {
  585. m_altype.Get(hltype,((KmCurve*)pObj)->style);
  586. dscale=((KmCurve*)pObj)->GetLineScale();
  587. }
  588. else
  589. {
  590. m_altype.Get(hltype,SOLID_LINE);
  591. }
  592. //3
  593. AD_OBJHANDLE hlayer;
  594. m_alayer.Get(hlayer,pObj->GetLayerID());
  595. m_pConverter->WriteEnthead(scolor,swidth,dscale,hltype,hlayer);
  596. return TRUE;
  597. }
  598. BOOL CKmgReader::processentity_dim_blob(CDSSubst* pDSSubst,AD_VMADDR blob)
  599. {
  600. ASSERT(pDSSubst);
  601. //样式替代格式
  602. //1002 {
  603. /*  1070 编码
  604. / ___________具体的样式替代*/
  605. /*  1070 编码
  606. / ___________具体的样式替代*/
  607. //1002 }
  608. try
  609. {
  610. //extern  PAD_BLOB_CTRL ADCDECL adStartBlobWrite _((AD_VMADDR blob));
  611. //short adWriteExtendeddata (PAD_BLOB_CTRL bcptr, PAD_XD adxd);
  612. PAD_BLOB_CTRL bcptr=adStartBlobWrite(blob);
  613. if(bcptr==NULL)return FALSE;
  614. AD_XD adxd;
  615. //1001
  616. //ACAD
  617. //1000
  618. //DSTYLE
  619. adxd.xddxfnumber=1001;
  620. AD_OBJHANDLE objhandle;
  621. m_pConverter->GetAppHandle(&objhandle);
  622. adHancpy(adxd.xddata.xdappobjhandle,objhandle);
  623. adWriteExtendeddata(bcptr,&adxd);
  624. adxd.xddxfnumber=1000;
  625. strcpy(adxd.xddata.xdstring,"DSTYLE");
  626. adWriteExtendeddata(bcptr,&adxd);
  627. adxd.xddxfnumber=AD_XD_CONTROL;
  628. adxd.xddata.xdcontrol='{';
  629. adWriteExtendeddata(bcptr,&adxd);
  630. DSSubstVar dsvar;
  631. for(int i=0;i<pDSSubst->GetSubstVarNum();i++)
  632. {
  633. dsvar = pDSSubst->GetNoNSubstVar(i);
  634. //short adWriteExtendeddata (PAD_BLOB_CTRL bcptr, PAD_XD adxd);
  635. switch(dsvar.nDSID)
  636. {
  637. /*模板
  638. case DIM://KMCAD编码
  639. adxd.xddxfnumber=AD_XD_INT;
  640. adxd.xddata.xdint=;//ACAD编码
  641. adWriteExtendeddata(bcptr,&adxd);
  642. adxd.xddxfnumber=;//ACAD类型
  643. adxd.xddata.=dsvar.varValue.Val;// ACAD类型 KMCAD类型
  644. adWriteExtendeddata(bcptr,&adxd);
  645. break;
  646. */
  647. case DIMADEC://KMCAD编码
  648. adxd.xddxfnumber=AD_XD_INT;
  649. adxd.xddata.xdint=179;//ACAD编码
  650. adWriteExtendeddata(bcptr,&adxd);
  651. adxd.xddxfnumber=1070;//ACAD类型
  652. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  653. adWriteExtendeddata(bcptr,&adxd);
  654. break;
  655. case DIMALT://KMCAD编码
  656. adxd.xddxfnumber=AD_XD_INT;
  657. adxd.xddata.xdint=170;//ACAD编码
  658. adWriteExtendeddata(bcptr,&adxd);
  659. adxd.xddxfnumber=1070;//ACAD类型
  660. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  661. adWriteExtendeddata(bcptr,&adxd);
  662. break;
  663. case DIMALTD://KMCAD编码
  664. adxd.xddxfnumber=AD_XD_INT;
  665. adxd.xddata.xdint=171;//ACAD编码
  666. adWriteExtendeddata(bcptr,&adxd);
  667. adxd.xddxfnumber=1040;//ACAD类型
  668. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  669. adWriteExtendeddata(bcptr,&adxd);
  670. break;
  671. case DIMALTF://KMCAD编码
  672. adxd.xddxfnumber=AD_XD_INT;
  673. adxd.xddata.xdint=143;//ACAD编码
  674. adWriteExtendeddata(bcptr,&adxd);
  675. adxd.xddxfnumber=1040;//ACAD类型
  676. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  677. adWriteExtendeddata(bcptr,&adxd);
  678. break;
  679. case DIMALTRND://KMCAD编码
  680. adxd.xddxfnumber=AD_XD_INT;
  681. adxd.xddata.xdint=148;//ACAD编码
  682. adWriteExtendeddata(bcptr,&adxd);
  683. adxd.xddxfnumber=1040;//ACAD类型
  684. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  685. adWriteExtendeddata(bcptr,&adxd);
  686. break;
  687. case DIMAPOST://KMCAD编码
  688. adxd.xddxfnumber=AD_XD_INT;
  689. adxd.xddata.xdint=4;//ACAD编码
  690. adWriteExtendeddata(bcptr,&adxd);
  691. adxd.xddxfnumber=1000;//ACAD类型
  692. {
  693. CString strTemp=dsvar.varValue.bstrVal;
  694. ::strcpy(adxd.xddata.xdstring,(char*)(LPCTSTR)strTemp);// ACAD类型 KMCAD类型
  695. adWriteExtendeddata(bcptr,&adxd);
  696. }
  697. break;
  698. case DIMASZ://KMCAD编码
  699. adxd.xddxfnumber=AD_XD_INT;
  700. adxd.xddata.xdint=41;//ACAD编码
  701. adWriteExtendeddata(bcptr,&adxd);
  702. adxd.xddxfnumber=1040;//ACAD类型
  703. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  704. adWriteExtendeddata(bcptr,&adxd);
  705. break;
  706. case DIMZIN://KMCAD编码
  707. adxd.xddxfnumber=AD_XD_INT;
  708. adxd.xddata.xdint=78;//ACAD编码
  709. adWriteExtendeddata(bcptr,&adxd);
  710. adxd.xddxfnumber=1070;//ACAD类型
  711. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  712. adWriteExtendeddata(bcptr,&adxd);
  713. break;
  714. case DIMCEN://KMCAD编码
  715. adxd.xddxfnumber=AD_XD_INT;
  716. adxd.xddata.xdint=141;//ACAD编码
  717. adWriteExtendeddata(bcptr,&adxd);
  718. adxd.xddxfnumber=1040;//ACAD类型
  719. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  720. adWriteExtendeddata(bcptr,&adxd);
  721. break;
  722. case DIMCLRD://KMCAD编码
  723. adxd.xddxfnumber=AD_XD_INT;
  724. adxd.xddata.xdint=176;//ACAD编码
  725. adWriteExtendeddata(bcptr,&adxd);
  726. adxd.xddxfnumber=1070;//ACAD类型
  727. {
  728. int icolor=dsvar.varValue.intVal;
  729. if(icolor==COLOR_BYBLOCK)
  730. {
  731. icolor=AD_COLOR_BYBLOCK;
  732. }
  733. else if(icolor==COLOR_BYLAYER)
  734. {
  735. icolor=AD_COLOR_BYLAYER;
  736. }
  737. else
  738. {
  739. try
  740. {
  741. int icolorcompare=icolor;//颜色比较基准
  742. icolor=AD_COLOR_BYLAYER;
  743. for(int i=1;i<m_aColor.GetSize();i++)
  744. {
  745. if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
  746.  fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
  747.  fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
  748. {
  749. icolor=i;//i是ACI颜色码
  750. break;
  751. }
  752. }
  753. }
  754. catch(...)
  755. {
  756. icolor=AD_COLOR_BYLAYER;
  757. }
  758. }
  759. adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
  760. }
  761. adWriteExtendeddata(bcptr,&adxd);
  762. break;
  763. case DIMCLRE://KMCAD编码
  764. adxd.xddxfnumber=AD_XD_INT;
  765. adxd.xddata.xdint=177;//ACAD编码
  766. adWriteExtendeddata(bcptr,&adxd);
  767. adxd.xddxfnumber=1070;//ACAD类型
  768. {
  769. int icolor=dsvar.varValue.intVal;
  770. if(icolor==COLOR_BYBLOCK)
  771. {
  772. icolor=AD_COLOR_BYBLOCK;
  773. }
  774. else if(icolor==COLOR_BYLAYER)
  775. {
  776. icolor=AD_COLOR_BYLAYER;
  777. }
  778. else
  779. {
  780. try
  781. {
  782. int icolorcompare=icolor;//颜色比较基准
  783. icolor=AD_COLOR_BYLAYER;
  784. for(int i=1;i<m_aColor.GetSize();i++)
  785. {
  786. if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
  787.  fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
  788.  fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
  789. {
  790. icolor=i;//i是ACI颜色码
  791. break;
  792. }
  793. }
  794. }
  795. catch(...)
  796. {
  797. icolor=AD_COLOR_BYLAYER;
  798. }
  799. }
  800. adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
  801. }
  802. adWriteExtendeddata(bcptr,&adxd);
  803. break;
  804. case DIMCLRT://KMCAD编码
  805. adxd.xddxfnumber=AD_XD_INT;
  806. adxd.xddata.xdint=178;//ACAD编码
  807. adWriteExtendeddata(bcptr,&adxd);
  808. adxd.xddxfnumber=1070;//ACAD类型
  809. {
  810. int icolor=dsvar.varValue.intVal;
  811. if(icolor==COLOR_BYBLOCK)
  812. {
  813. icolor=AD_COLOR_BYBLOCK;
  814. }
  815. else if(icolor==COLOR_BYLAYER)
  816. {
  817. icolor=AD_COLOR_BYLAYER;
  818. }
  819. else
  820. {
  821. try
  822. {
  823. int icolorcompare=icolor;//颜色比较基准
  824. icolor=AD_COLOR_BYLAYER;
  825. for(int i=1;i<m_aColor.GetSize();i++)
  826. {
  827. if( (fabs(GetRValue(icolorcompare)-GetRValue(m_aColor[i]))+
  828.  fabs(GetGValue(icolorcompare)-GetGValue(m_aColor[i]))+
  829.  fabs(GetBValue(icolorcompare)-GetBValue(m_aColor[i])))<20)
  830. {
  831. icolor=i;//i是ACI颜色码
  832. break;
  833. }
  834. }
  835. }
  836. catch(...)
  837. {
  838. icolor=AD_COLOR_BYLAYER;
  839. }
  840. }
  841. adxd.xddata.xdint=icolor;// ACAD类型 KMCAD类型
  842. }
  843. adWriteExtendeddata(bcptr,&adxd);
  844. break;
  845. case DIMDLE://KMCAD编码
  846. adxd.xddxfnumber=AD_XD_INT;
  847. adxd.xddata.xdint=46;//ACAD编码
  848. adWriteExtendeddata(bcptr,&adxd);
  849. adxd.xddxfnumber=1040;//ACAD类型
  850. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  851. adWriteExtendeddata(bcptr,&adxd);
  852. break;
  853. case DIMDLI://KMCAD编码
  854. adxd.xddxfnumber=AD_XD_INT;
  855. adxd.xddata.xdint=43;//ACAD编码
  856. adWriteExtendeddata(bcptr,&adxd);
  857. adxd.xddxfnumber=1040;//ACAD类型
  858. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  859. adWriteExtendeddata(bcptr,&adxd);
  860. break;
  861. case DIMEXE://KMCAD编码
  862. adxd.xddxfnumber=AD_XD_INT;
  863. adxd.xddata.xdint=44;//ACAD编码
  864. adWriteExtendeddata(bcptr,&adxd);
  865. adxd.xddxfnumber=1040;//ACAD类型
  866. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  867. adWriteExtendeddata(bcptr,&adxd);
  868. break;
  869. case DIMEXO://KMCAD编码
  870. adxd.xddxfnumber=AD_XD_INT;
  871. adxd.xddata.xdint=42;//ACAD编码
  872. adWriteExtendeddata(bcptr,&adxd);
  873. adxd.xddxfnumber=1040;//ACAD类型
  874. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  875. adWriteExtendeddata(bcptr,&adxd);
  876. break;
  877. case DIMGAP://KMCAD编码
  878. adxd.xddxfnumber=AD_XD_INT;
  879. adxd.xddata.xdint=147;//ACAD编码
  880. adWriteExtendeddata(bcptr,&adxd);
  881. adxd.xddxfnumber=1040;//ACAD类型
  882. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  883. adWriteExtendeddata(bcptr,&adxd);
  884. break;
  885. case DIMLFAC://KMCAD编码
  886. adxd.xddxfnumber=AD_XD_INT;
  887. adxd.xddata.xdint=144;//ACAD编码
  888. adWriteExtendeddata(bcptr,&adxd);
  889. adxd.xddxfnumber=1040;//ACAD类型
  890. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  891. adWriteExtendeddata(bcptr,&adxd);
  892. break;
  893. case DIMLIM://KMCAD编码
  894. adxd.xddxfnumber=AD_XD_INT;
  895. adxd.xddata.xdint=72;//ACAD编码
  896. adWriteExtendeddata(bcptr,&adxd);
  897. adxd.xddxfnumber=1070;//ACAD类型
  898. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  899. adWriteExtendeddata(bcptr,&adxd);
  900. break;
  901. case DIMPOST://KMCAD编码
  902. adxd.xddxfnumber=AD_XD_INT;
  903. adxd.xddata.xdint=3;//ACAD编码
  904. adWriteExtendeddata(bcptr,&adxd);
  905. {
  906. adxd.xddxfnumber=1000;//ACAD类型
  907. CString strTemp=dsvar.varValue.bstrVal;
  908. ::strcpy(adxd.xddata.xdstring,(char*)(LPCTSTR)strTemp);// ACAD类型 KMCAD类型
  909. }
  910. adWriteExtendeddata(bcptr,&adxd);
  911. break;
  912. case DIMRND://KMCAD编码
  913. adxd.xddxfnumber=AD_XD_INT;
  914. adxd.xddata.xdint=45;//ACAD编码
  915. adWriteExtendeddata(bcptr,&adxd);
  916. adxd.xddxfnumber=1040;//ACAD类型
  917. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  918. adWriteExtendeddata(bcptr,&adxd);
  919. break;
  920. case DIMSAH://KMCAD编码
  921. adxd.xddxfnumber=AD_XD_INT;
  922. adxd.xddata.xdint=173;//ACAD编码
  923. adWriteExtendeddata(bcptr,&adxd);
  924. adxd.xddxfnumber=1070;//ACAD类型
  925. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  926. adWriteExtendeddata(bcptr,&adxd);
  927. break;
  928. case DIMSCALE://KMCAD编码
  929. adxd.xddxfnumber=AD_XD_INT;
  930. adxd.xddata.xdint=40;//ACAD编码
  931. adWriteExtendeddata(bcptr,&adxd);
  932. adxd.xddxfnumber=1040;//ACAD类型
  933. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  934. adWriteExtendeddata(bcptr,&adxd);
  935. break;
  936. case DIMSE1://KMCAD编码
  937. adxd.xddxfnumber=AD_XD_INT;
  938. adxd.xddata.xdint=75;//ACAD编码
  939. adWriteExtendeddata(bcptr,&adxd);
  940. adxd.xddxfnumber=1070;//ACAD类型
  941. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  942. adWriteExtendeddata(bcptr,&adxd);
  943. break;
  944. case DIMSE2://KMCAD编码
  945. adxd.xddxfnumber=AD_XD_INT;
  946. adxd.xddata.xdint=76;//ACAD编码
  947. adWriteExtendeddata(bcptr,&adxd);
  948. adxd.xddxfnumber=1070;//ACAD类型
  949. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  950. adWriteExtendeddata(bcptr,&adxd);
  951. break;
  952. case DIMTFAC://KMCAD编码
  953. adxd.xddxfnumber=AD_XD_INT;
  954. adxd.xddata.xdint=146;//ACAD编码
  955. adWriteExtendeddata(bcptr,&adxd);
  956. adxd.xddxfnumber=1040;//ACAD类型
  957. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  958. adWriteExtendeddata(bcptr,&adxd);
  959. break;
  960. case DIMTIH://KMCAD编码
  961. adxd.xddxfnumber=AD_XD_INT;
  962. adxd.xddata.xdint=73;//ACAD编码
  963. adWriteExtendeddata(bcptr,&adxd);
  964. adxd.xddxfnumber=1070;//ACAD类型
  965. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  966. adWriteExtendeddata(bcptr,&adxd);
  967. break;
  968. case DIMTM://KMCAD编码
  969. adxd.xddxfnumber=AD_XD_INT;
  970. adxd.xddata.xdint=48;//ACAD编码
  971. adWriteExtendeddata(bcptr,&adxd);
  972. adxd.xddxfnumber=1040;//ACAD类型
  973. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  974. adWriteExtendeddata(bcptr,&adxd);
  975. break;
  976. case DIMTOH://KMCAD编码
  977. adxd.xddxfnumber=AD_XD_INT;
  978. adxd.xddata.xdint=74;//ACAD编码
  979. adWriteExtendeddata(bcptr,&adxd);
  980. adxd.xddxfnumber=1070;//ACAD类型
  981. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  982. adWriteExtendeddata(bcptr,&adxd);
  983. break;
  984. case DIMTOFL://KMCAD编码
  985. adxd.xddxfnumber=AD_XD_INT;
  986. adxd.xddata.xdint=172;//ACAD编码
  987. adWriteExtendeddata(bcptr,&adxd);
  988. adxd.xddxfnumber=1070;//ACAD类型
  989. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  990. adWriteExtendeddata(bcptr,&adxd);
  991. break;
  992. case DIMTOL://KMCAD编码
  993. adxd.xddxfnumber=AD_XD_INT;
  994. adxd.xddata.xdint=71;//ACAD编码
  995. adWriteExtendeddata(bcptr,&adxd);
  996. adxd.xddxfnumber=1070;//ACAD类型
  997. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  998. adWriteExtendeddata(bcptr,&adxd);
  999. break;
  1000. case DIMTP://KMCAD编码
  1001. adxd.xddxfnumber=AD_XD_INT;
  1002. adxd.xddata.xdint=47;//ACAD编码
  1003. adWriteExtendeddata(bcptr,&adxd);
  1004. adxd.xddxfnumber=1040;//ACAD类型
  1005. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  1006. adWriteExtendeddata(bcptr,&adxd);
  1007. break;
  1008. case DIMTSZ://KMCAD编码
  1009. adxd.xddxfnumber=AD_XD_INT;
  1010. adxd.xddata.xdint=142;//ACAD编码
  1011. adWriteExtendeddata(bcptr,&adxd);
  1012. adxd.xddxfnumber=1040;//ACAD类型
  1013. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  1014. adWriteExtendeddata(bcptr,&adxd);
  1015. break;
  1016. case DIMTXT://KMCAD编码
  1017. adxd.xddxfnumber=AD_XD_INT;
  1018. adxd.xddata.xdint=140;//ACAD编码
  1019. adWriteExtendeddata(bcptr,&adxd);
  1020. adxd.xddxfnumber=1040;//ACAD类型
  1021. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  1022. adWriteExtendeddata(bcptr,&adxd);
  1023. break;
  1024. case DIMTVP://KMCAD编码
  1025. adxd.xddxfnumber=AD_XD_INT;
  1026. adxd.xddata.xdint=145;//ACAD编码
  1027. adWriteExtendeddata(bcptr,&adxd);
  1028. adxd.xddxfnumber=1040;//ACAD类型
  1029. adxd.xddata.xdreal=dsvar.varValue.dblVal;// ACAD类型 KMCAD类型
  1030. adWriteExtendeddata(bcptr,&adxd);
  1031. break;
  1032. case DIMSOXD://KMCAD编码
  1033. adxd.xddxfnumber=AD_XD_INT;
  1034. adxd.xddata.xdint=175;//ACAD编码
  1035. adWriteExtendeddata(bcptr,&adxd);
  1036. adxd.xddxfnumber=1070;//ACAD类型
  1037. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  1038. adWriteExtendeddata(bcptr,&adxd);
  1039. break;
  1040. case DIMTAD://KMCAD编码
  1041. adxd.xddxfnumber=AD_XD_INT;
  1042. adxd.xddata.xdint=77;//ACAD编码
  1043. adWriteExtendeddata(bcptr,&adxd);
  1044. adxd.xddxfnumber=1070;//ACAD类型
  1045. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1046. adWriteExtendeddata(bcptr,&adxd);
  1047. break;
  1048. case DIMTIX://KMCAD编码
  1049. adxd.xddxfnumber=AD_XD_INT;
  1050. adxd.xddata.xdint=174;//ACAD编码
  1051. adWriteExtendeddata(bcptr,&adxd);
  1052. adxd.xddxfnumber=1070;//ACAD类型
  1053. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1054. adWriteExtendeddata(bcptr,&adxd);
  1055. break;
  1056. case DIMAZIN://KMCAD编码
  1057. adxd.xddxfnumber=AD_XD_INT;
  1058. adxd.xddata.xdint=79;//ACAD编码
  1059. adWriteExtendeddata(bcptr,&adxd);
  1060. adxd.xddxfnumber=1070;//ACAD类型
  1061. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1062. adWriteExtendeddata(bcptr,&adxd);
  1063. break;
  1064. case DIMALTTD://KMCAD编码
  1065. adxd.xddxfnumber=AD_XD_INT;
  1066. adxd.xddata.xdint=274;//ACAD编码
  1067. adWriteExtendeddata(bcptr,&adxd);
  1068. adxd.xddxfnumber=1070;//ACAD类型
  1069. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1070. adWriteExtendeddata(bcptr,&adxd);
  1071. break;
  1072. case DIMALTTZ://KMCAD编码
  1073. adxd.xddxfnumber=AD_XD_INT;
  1074. adxd.xddata.xdint=286;//ACAD编码
  1075. adWriteExtendeddata(bcptr,&adxd);
  1076. adxd.xddxfnumber=1070;//ACAD类型
  1077. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1078. adWriteExtendeddata(bcptr,&adxd);
  1079. break;
  1080. case DIMALTU://KMCAD编码
  1081. adxd.xddxfnumber=AD_XD_INT;
  1082. adxd.xddata.xdint=273;//ACAD编码
  1083. adWriteExtendeddata(bcptr,&adxd);
  1084. adxd.xddxfnumber=1070;//ACAD类型
  1085. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1086. adWriteExtendeddata(bcptr,&adxd);
  1087. break;
  1088. case DIMALTZ://KMCAD编码
  1089. adxd.xddxfnumber=AD_XD_INT;
  1090. adxd.xddata.xdint=285;//ACAD编码
  1091. adWriteExtendeddata(bcptr,&adxd);
  1092. adxd.xddxfnumber=1070;//ACAD类型
  1093. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1094. adWriteExtendeddata(bcptr,&adxd);
  1095. break;
  1096. case DIMAUNIT://KMCAD编码
  1097. adxd.xddxfnumber=AD_XD_INT;
  1098. adxd.xddata.xdint=275;//ACAD编码
  1099. adWriteExtendeddata(bcptr,&adxd);
  1100. adxd.xddxfnumber=1070;//ACAD类型
  1101. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1102. adWriteExtendeddata(bcptr,&adxd);
  1103. break;
  1104. case DIMDEC://KMCAD编码
  1105. adxd.xddxfnumber=AD_XD_INT;
  1106. adxd.xddata.xdint=271;//ACAD编码
  1107. adWriteExtendeddata(bcptr,&adxd);
  1108. adxd.xddxfnumber=1070;//ACAD类型
  1109. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1110. adWriteExtendeddata(bcptr,&adxd);
  1111. break;
  1112. case DIMATFIT://KMCAD编码
  1113. adxd.xddxfnumber=AD_XD_INT;
  1114. adxd.xddata.xdint=289;//ACAD编码
  1115. adWriteExtendeddata(bcptr,&adxd);
  1116. adxd.xddxfnumber=1070;//ACAD类型
  1117. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1118. adWriteExtendeddata(bcptr,&adxd);
  1119. break;
  1120. case DIMJUST://KMCAD编码
  1121. adxd.xddxfnumber=AD_XD_INT;
  1122. adxd.xddata.xdint=280;//ACAD编码
  1123. adWriteExtendeddata(bcptr,&adxd);
  1124. adxd.xddxfnumber=1070;//ACAD类型
  1125. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1126. adWriteExtendeddata(bcptr,&adxd);
  1127. break;
  1128. case DIMSD1://KMCAD编码
  1129. adxd.xddxfnumber=AD_XD_INT;
  1130. adxd.xddata.xdint=281;//ACAD编码
  1131. adWriteExtendeddata(bcptr,&adxd);
  1132. adxd.xddxfnumber=1070;//ACAD类型
  1133. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  1134. adWriteExtendeddata(bcptr,&adxd);
  1135. break;
  1136. case DIMSD2://KMCAD编码
  1137. adxd.xddxfnumber=AD_XD_INT;
  1138. adxd.xddata.xdint=282;//ACAD编码
  1139. adWriteExtendeddata(bcptr,&adxd);
  1140. adxd.xddxfnumber=1070;//ACAD类型
  1141. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  1142. adWriteExtendeddata(bcptr,&adxd);
  1143. break;
  1144. case DIMTDEC://KMCAD编码
  1145. adxd.xddxfnumber=AD_XD_INT;
  1146. adxd.xddata.xdint=272;//ACAD编码
  1147. adWriteExtendeddata(bcptr,&adxd);
  1148. adxd.xddxfnumber=1070;//ACAD类型
  1149. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1150. adWriteExtendeddata(bcptr,&adxd);
  1151. break;
  1152. case DIMTOLJ://KMCAD编码
  1153. adxd.xddxfnumber=AD_XD_INT;
  1154. adxd.xddata.xdint=283;//ACAD编码
  1155. adWriteExtendeddata(bcptr,&adxd);
  1156. adxd.xddxfnumber=1070;//ACAD类型
  1157. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1158. adWriteExtendeddata(bcptr,&adxd);
  1159. break;
  1160. case DIMTZIN://KMCAD编码
  1161. adxd.xddxfnumber=AD_XD_INT;
  1162. adxd.xddata.xdint=284;//ACAD编码
  1163. adWriteExtendeddata(bcptr,&adxd);
  1164. adxd.xddxfnumber=1070;//ACAD类型
  1165. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1166. adWriteExtendeddata(bcptr,&adxd);
  1167. break;
  1168. case DIMLUNIT://KMCAD编码
  1169. adxd.xddxfnumber=AD_XD_INT;
  1170. adxd.xddata.xdint=277;//ACAD编码
  1171. adWriteExtendeddata(bcptr,&adxd);
  1172. adxd.xddxfnumber=1070;//ACAD类型
  1173. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1174. adWriteExtendeddata(bcptr,&adxd);
  1175. break;
  1176. case DIMUPT://KMCAD编码
  1177. adxd.xddxfnumber=AD_XD_INT;
  1178. adxd.xddata.xdint=288;//ACAD编码
  1179. adWriteExtendeddata(bcptr,&adxd);
  1180. adxd.xddxfnumber=1070;//ACAD类型
  1181. adxd.xddata.xdint=dsvar.varValue.boolVal;// ACAD类型 KMCAD类型
  1182. adWriteExtendeddata(bcptr,&adxd);
  1183. break;
  1184. case DIMFRAC://KMCAD编码
  1185. adxd.xddxfnumber=AD_XD_INT;
  1186. adxd.xddata.xdint=276;//ACAD编码
  1187. adWriteExtendeddata(bcptr,&adxd);
  1188. adxd.xddxfnumber=1070;//ACAD类型
  1189. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1190. adWriteExtendeddata(bcptr,&adxd);
  1191. break;
  1192. case DIMDSEP://KMCAD编码
  1193. adxd.xddxfnumber=AD_XD_INT;
  1194. adxd.xddata.xdint=278;//ACAD编码
  1195. adWriteExtendeddata(bcptr,&adxd);
  1196. adxd.xddxfnumber=1070;//ACAD类型
  1197. adxd.xddata.xdint=dsvar.varValue.cVal;// ACAD类型 KMCAD类型
  1198. adWriteExtendeddata(bcptr,&adxd);
  1199. break;
  1200. case DIMTMOVE://KMCAD编码
  1201. adxd.xddxfnumber=AD_XD_INT;
  1202. adxd.xddata.xdint=279;//ACAD编码
  1203. adWriteExtendeddata(bcptr,&adxd);
  1204. adxd.xddxfnumber=1070;//ACAD类型
  1205. adxd.xddata.xdint=dsvar.varValue.intVal;// ACAD类型 KMCAD类型
  1206. adWriteExtendeddata(bcptr,&adxd);
  1207. break;
  1208. case DIMLWD://KMCAD编码
  1209. adxd.xddxfnumber=AD_XD_INT;
  1210. adxd.xddata.xdint=371;//ACAD编码
  1211. adWriteExtendeddata(bcptr,&adxd);
  1212. {
  1213. adxd.xddxfnumber=1070;//ACAD类型
  1214. int width=dsvar.varValue.intVal;
  1215. if(width==ABS_THIN_WIDTH)
  1216. {
  1217. width=0;
  1218. }
  1219. else if(width==LWIDTH_BYLAYER)
  1220. {
  1221. width=AD_WEIGHT_BYLAYER;
  1222. }
  1223. else if(width==LWIDTH_BYBLOCK)
  1224. {
  1225. width=AD_WEIGHT_BYBLOCK;
  1226. }
  1227. else
  1228. {
  1229. width=(short)(::GetLineWidthAsDouble(width)*100.0);
  1230. if(width<=5)width=5;
  1231. else if(width<=9)width=9;
  1232. else if(width<=13)width=13;
  1233. else if(width<=15)width=15;
  1234. else if(width<=18)width=18;
  1235. else if(width<=20)width=20;
  1236. else if(width<=25)width=25;
  1237. else if(width<=30)width=30;
  1238. else if(width<=35)width=35;
  1239. else if(width<=40)width=40;
  1240. else if(width<=50)width=50;
  1241. else if(width<=53)width=53;
  1242. else if(width<=60)width=60;
  1243. else if(width<=70)width=70;
  1244. else if(width<=80)width=80;
  1245. else if(width<=90)width=90;
  1246. else if(width<=100)width=100;
  1247. else if(width<=106)width=106;
  1248. else if(width<=120)width=120;
  1249. else if(width<=140)width=140;
  1250. else if(width<=158)width=158;
  1251. else if(width<=200)width=200;
  1252. else width=211;
  1253. }
  1254. adxd.xddata.xdint=width;// ACAD类型 KMCAD类型
  1255. }
  1256. adWriteExtendeddata(bcptr,&adxd);
  1257. break;
  1258. case DIMLWE://KMCAD编码
  1259. adxd.xddxfnumber=AD_XD_INT;
  1260. adxd.xddata.xdint=372;//ACAD编码
  1261. adWriteExtendeddata(bcptr,&adxd);
  1262. {
  1263. adxd.xddxfnumber=1070;//ACAD类型
  1264. int width=dsvar.varValue.intVal;
  1265. if(width==ABS_THIN_WIDTH)
  1266. {
  1267. width=0;
  1268. }
  1269. else if(width==LWIDTH_BYLAYER)
  1270. {
  1271. width=AD_WEIGHT_BYLAYER;
  1272. }
  1273. else if(width==LWIDTH_BYBLOCK)
  1274. {
  1275. width=AD_WEIGHT_BYBLOCK;
  1276. }
  1277. else
  1278. {
  1279. width=(short)(::GetLineWidthAsDouble(width)*100.0);
  1280. if(width<=5)width=5;
  1281. else if(width<=9)width=9;
  1282. else if(width<=13)width=13;
  1283. else if(width<=15)width=15;
  1284. else if(width<=18)width=18;
  1285. else if(width<=20)width=20;
  1286. else if(width<=25)width=25;
  1287. else if(width<=30)width=30;
  1288. else if(width<=35)width=35;
  1289. else if(width<=40)width=40;
  1290. else if(width<=50)width=50;
  1291. else if(width<=53)width=53;
  1292. else if(width<=60)width=60;
  1293. else if(width<=70)width=70;
  1294. else if(width<=80)width=80;
  1295. else if(width<=90)width=90;
  1296. else if(width<=100)width=100;
  1297. else if(width<=106)width=106;
  1298. else if(width<=120)width=120;
  1299. else if(width<=140)width=140;
  1300. else if(width<=158)width=158;
  1301. else if(width<=200)width=200;
  1302. else width=211;
  1303. }
  1304. adxd.xddata.xdint=width;// ACAD类型 KMCAD类型
  1305. }
  1306. adWriteExtendeddata(bcptr,&adxd);
  1307. break;
  1308. case DIMTXSTY://KMCAD编码
  1309. {
  1310. UINT kmid=(UINT)dsvar.varValue.intVal;
  1311. AD_OBJHANDLE objhandle;
  1312. if(m_awordstyle.Get(objhandle,kmid))
  1313. {
  1314. adxd.xddxfnumber=AD_XD_INT;
  1315. adxd.xddata.xdint=340;//ACAD编码
  1316. adWriteExtendeddata(bcptr,&adxd);
  1317. adxd.xddxfnumber=1005;//ACAD类型
  1318. adHancpy(adxd.xddata.xdhandle,objhandle);
  1319. adWriteExtendeddata(bcptr,&adxd);
  1320. }
  1321. }
  1322. break;
  1323. default:
  1324. break;
  1325. }
  1326. }
  1327. adxd.xddxfnumber=AD_XD_CONTROL;
  1328. adxd.xddata.xdcontrol='}';
  1329. adWriteExtendeddata(bcptr,&adxd);
  1330. //extern  short  ADCDECL adEndBlobWrite _((PAD_BLOB_CTRL bcptr));
  1331. if(!adEndBlobWrite(bcptr))
  1332. {
  1333. return FALSE;
  1334. }
  1335. }
  1336. catch(...)
  1337. {
  1338. return FALSE;
  1339. }
  1340. return TRUE;
  1341. }
  1342. BOOL CKmgReader::processdimstyle(CKmDataManager* pData)
  1343. {
  1344. CString strTemp;
  1345. CDimStyle* dimstyle;
  1346. for(int index=0;index<pData->GetDimStyleNum();index++)
  1347. {
  1348. pData->GetNoNDimStyle(index,dimstyle);
  1349. if(!dimstyle)
  1350. {
  1351. continue;
  1352. }
  1353. adSetDefaultDimstyle(m_pConverter->m_dwghandle,&m_pConverter->adtb->dimst);
  1354. VARIANT var;
  1355. memset(&var,0,sizeof(VARIANT)); 
  1356. //  short  xrefindex;     /* index of xref from which this item came */
  1357. //  char   flag;                   /* flag for dimstyle */
  1358. //  char   purgedflag;             /* 1 if purged */
  1359. //  char   name[AD_MAX_STRLEN];               /* name of dimension style */
  1360. CString strName=m_pConverter->ConverterTabEntName(dimstyle->GetName());
  1361. strcpy(m_pConverter->adtb->dimst.name,(char*)(LPCTSTR)strName);
  1362. //  short  dimadec;
  1363. var=dimstyle->GetDimStlVar(DIMADEC);
  1364. m_pConverter->adtb->dimst.dimadec=var.intVal;
  1365. //  char   dimalt;                 /* these ds variables are the dim vars */
  1366. var=dimstyle->GetDimStlVar(DIMALT);
  1367. m_pConverter->adtb->dimst.dimalt=(char)var.boolVal;
  1368. //  char   dimaltd;                /* associated with the dimension style */
  1369. var=dimstyle->GetDimStlVar(DIMALTD);
  1370. m_pConverter->adtb->dimst.dimaltd=var.intVal;
  1371. //  double dimaltf;                /* currently being read from the */
  1372. var=dimstyle->GetDimStlVar(DIMALTF);
  1373. m_pConverter->adtb->dimst.dimaltf=var.dblVal;
  1374. //  double dimaltrnd;
  1375. var=dimstyle->GetDimStlVar(DIMALTRND);
  1376. m_pConverter->adtb->dimst.dimaltrnd=var.dblVal;
  1377. //  char   dimapost[AD_MAX_STRLEN];           /* dimstyle table (R11) */
  1378. var=dimstyle->GetDimStlVar(DIMAPOST);
  1379. strTemp.Empty();
  1380. strTemp=var.bstrVal;
  1381. strcpy((char*)m_pConverter->adtb->dimst.dimapost,(char*)(LPCTSTR)strTemp);
  1382. //  double dimasz;
  1383. var=dimstyle->GetDimStlVar(DIMASZ);
  1384. m_pConverter->adtb->dimst.dimasz=var.dblVal;
  1385. //  short  dimazin;
  1386. var=dimstyle->GetDimStlVar(DIMAZIN);
  1387. m_pConverter->adtb->dimst.dimazin=var.intVal;
  1388. //  double dimcen;
  1389. var=dimstyle->GetDimStlVar(DIMCEN);
  1390. m_pConverter->adtb->dimst.dimcen=var.dblVal;
  1391. //  short  dimclrd;
  1392. var=dimstyle->GetDimStlVar(DIMCLRD);
  1393. {
  1394. short scolor=1;
  1395. int iColor=var.intVal;
  1396. if(iColor==COLOR_BYLAYER)
  1397. {
  1398. scolor=AD_COLOR_BYLAYER;
  1399. }
  1400. else if(iColor==COLOR_BYBLOCK)
  1401. {
  1402. scolor=AD_COLOR_BYBLOCK;
  1403. }
  1404. else
  1405. {
  1406. for(int j=1;j<m_aColor.GetSize();j++)
  1407. {
  1408. if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
  1409.  fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
  1410.  fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
  1411. {
  1412. scolor=j;
  1413. break;
  1414. }
  1415. }
  1416. }
  1417. m_pConverter->adtb->dimst.dimclrd=scolor;
  1418. }
  1419. //  short  dimclre;
  1420. var=dimstyle->GetDimStlVar(DIMCLRE);
  1421. {
  1422. short scolor=1;
  1423. int iColor=var.intVal;
  1424. if(iColor==COLOR_BYLAYER)
  1425. {
  1426. scolor=AD_COLOR_BYLAYER;
  1427. }
  1428. else if(iColor==COLOR_BYBLOCK)
  1429. {
  1430. scolor=AD_COLOR_BYBLOCK;
  1431. }
  1432. else
  1433. {
  1434. for(int j=1;j<m_aColor.GetSize();j++)
  1435. {
  1436. if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
  1437.  fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
  1438.  fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
  1439. {
  1440. scolor=j;
  1441. break;
  1442. }
  1443. }
  1444. }
  1445. m_pConverter->adtb->dimst.dimclre=scolor;
  1446. }
  1447. //  short  dimclrt;
  1448. var=dimstyle->GetDimStlVar(DIMCLRT);
  1449. {
  1450. short scolor=1;
  1451. int iColor=var.intVal;
  1452. if(iColor==COLOR_BYLAYER)
  1453. {
  1454. scolor=AD_COLOR_BYLAYER;
  1455. }
  1456. else if(iColor==COLOR_BYBLOCK)
  1457. {
  1458. scolor=AD_COLOR_BYBLOCK;
  1459. }
  1460. else
  1461. {
  1462. for(int j=1;j<m_aColor.GetSize();j++)
  1463. {
  1464. if( (fabs(GetRValue(iColor)-GetRValue(m_aColor[j]))+
  1465.  fabs(GetGValue(iColor)-GetGValue(m_aColor[j]))+
  1466.  fabs(GetBValue(iColor)-GetBValue(m_aColor[j])))<20)
  1467. {
  1468. scolor=j;
  1469. break;
  1470. }
  1471. }
  1472. }
  1473. m_pConverter->adtb->dimst.dimclrt=scolor;
  1474. }
  1475. //  double dimdle;
  1476. var=dimstyle->GetDimStlVar(DIMDLE);
  1477. m_pConverter->adtb->dimst.dimdle=var.dblVal;
  1478. //  double dimdli;
  1479. var=dimstyle->GetDimStlVar(DIMDLI);
  1480. m_pConverter->adtb->dimst.dimdli=var.dblVal;
  1481. //  double dimexe;
  1482. var=dimstyle->GetDimStlVar(DIMEXE);
  1483. m_pConverter->adtb->dimst.dimexe=var.dblVal;
  1484. //  double dimexo;
  1485. var=dimstyle->GetDimStlVar(DIMEXO);
  1486. m_pConverter->adtb->dimst.dimexo=var.dblVal;
  1487. //  double dimgap;
  1488. var=dimstyle->GetDimStlVar(DIMGAP);
  1489. m_pConverter->adtb->dimst.dimgap=var.dblVal;
  1490. //  double dimlfac;
  1491. var=dimstyle->GetDimStlVar(DIMLFAC);
  1492. m_pConverter->adtb->dimst.dimlfac=var.dblVal;
  1493. //  char   dimlim;
  1494. var=dimstyle->GetDimStlVar(DIMLIM);
  1495. m_pConverter->adtb->dimst.dimlim=(char)var.boolVal;
  1496. //  char   dimpost[AD_MAX_STRLEN];
  1497. var=dimstyle->GetDimStlVar(DIMPOST);
  1498. strTemp.Empty();
  1499. strTemp=var.bstrVal;
  1500. strcpy((char*)m_pConverter->adtb->dimst.dimpost,(char*)(LPCTSTR)strTemp);
  1501. //  double dimrnd;
  1502. var=dimstyle->GetDimStlVar(DIMRND);
  1503. m_pConverter->adtb->dimst.dimrnd=var.dblVal;
  1504. //  char   dimsah;
  1505. var=dimstyle->GetDimStlVar(DIMSAH);
  1506. m_pConverter->adtb->dimst.dimsah=(char)var.boolVal;
  1507. //  double dimscale;
  1508. var=dimstyle->GetDimStlVar(DIMSCALE);
  1509. m_pConverter->adtb->dimst.dimscale=var.dblVal;
  1510. //  char   dimse1;
  1511. var=dimstyle->GetDimStlVar(DIMSE1);
  1512. m_pConverter->adtb->dimst.dimse1=(char)var.boolVal;
  1513. //  char   dimse2;
  1514. var=dimstyle->GetDimStlVar(DIMSE2);
  1515. m_pConverter->adtb->dimst.dimse2=(char)var.boolVal;
  1516. //  double dimtfac;
  1517. var=dimstyle->GetDimStlVar(DIMTFAC);
  1518. m_pConverter->adtb->dimst.dimtfac=var.dblVal;
  1519. //  char   dimtih;
  1520. var=dimstyle->GetDimStlVar(DIMTIH);
  1521. m_pConverter->adtb->dimst.dimtih=(char)var.boolVal;
  1522. //  double dimtm;
  1523. var=dimstyle->GetDimStlVar(DIMTM);
  1524. m_pConverter->adtb->dimst.dimtm=var.dblVal;
  1525. //  char   dimtoh;
  1526. var=dimstyle->GetDimStlVar(DIMTOH);
  1527. m_pConverter->adtb->dimst.dimtoh=(char)var.boolVal;
  1528. //  char   dimtofl;
  1529. var=dimstyle->GetDimStlVar(DIMTOFL);
  1530. m_pConverter->adtb->dimst.dimtofl=(char)var.boolVal;
  1531. //  char   dimtol;
  1532. var=dimstyle->GetDimStlVar(DIMTOL);
  1533. m_pConverter->adtb->dimst.dimtol=(char)var.boolVal;
  1534. //  double dimtp;
  1535. var=dimstyle->GetDimStlVar(DIMTP);
  1536. m_pConverter->adtb->dimst.dimtp=var.dblVal;
  1537. //  double dimtsz;
  1538. var=dimstyle->GetDimStlVar(DIMTSZ);
  1539. m_pConverter->adtb->dimst.dimtsz=var.dblVal;
  1540. //  double dimtxt;
  1541. var=dimstyle->GetDimStlVar(DIMTXT);
  1542. m_pConverter->adtb->dimst.dimtxt=var.dblVal;
  1543. //  double dimtvp;
  1544. var=dimstyle->GetDimStlVar(DIMTVP);
  1545. m_pConverter->adtb->dimst.dimtvp=var.dblVal;
  1546. //  char   dimsoxd;
  1547. var=dimstyle->GetDimStlVar(DIMSOXD);
  1548. m_pConverter->adtb->dimst.dimsoxd=(char)var.boolVal;
  1549. //  char   dimtad;
  1550. var=dimstyle->GetDimStlVar(DIMTAD);
  1551. m_pConverter->adtb->dimst.dimtad=var.intVal;
  1552. //  char   dimtix;
  1553. var=dimstyle->GetDimStlVar(DIMTIX);
  1554. m_pConverter->adtb->dimst.dimtix=var.intVal;
  1555. //  char   dimzin;
  1556. var=dimstyle->GetDimStlVar(DIMZIN);
  1557. m_pConverter->adtb->dimst.dimzin=var.intVal;
  1558. //  short  dimalttd;
  1559. var=dimstyle->GetDimStlVar(DIMALTTD);
  1560. m_pConverter->adtb->dimst.dimalttd=var.intVal;
  1561. //  char   dimalttz;
  1562. var=dimstyle->GetDimStlVar(DIMALTTZ);
  1563. m_pConverter->adtb->dimst.dimalttz=var.intVal;
  1564. //  short  dimaltu;
  1565. var=dimstyle->GetDimStlVar(DIMALTU);
  1566. m_pConverter->adtb->dimst.dimaltu=var.intVal;
  1567. //  char   dimaltz;
  1568. var=dimstyle->GetDimStlVar(DIMALTZ);
  1569. m_pConverter->adtb->dimst.dimaltz=var.intVal;
  1570. //  short  dimaunit;
  1571. var=dimstyle->GetDimStlVar(DIMAUNIT);
  1572. m_pConverter->adtb->dimst.dimaunit=var.intVal;
  1573. //  short  dimdec;
  1574. var=dimstyle->GetDimStlVar(DIMDEC);
  1575. m_pConverter->adtb->dimst.dimdec=var.intVal;
  1576. //  char   dimfit;
  1577. var=dimstyle->GetDimStlVar(DIMATFIT);
  1578. m_pConverter->adtb->dimst.dimfit=var.intVal;
  1579. //  char   dimjust;
  1580. var=dimstyle->GetDimStlVar(DIMJUST);
  1581. m_pConverter->adtb->dimst.dimjust=var.intVal;
  1582. //  char   dimsd1;
  1583. var=dimstyle->GetDimStlVar(DIMSD1);
  1584. m_pConverter->adtb->dimst.dimsd1=(char)var.boolVal;
  1585. //  char   dimsd2;
  1586. var=dimstyle->GetDimStlVar(DIMSD2);
  1587. m_pConverter->adtb->dimst.dimsd2=(char)var.boolVal;
  1588. //  short  dimtdec;
  1589. var=dimstyle->GetDimStlVar(DIMTDEC);
  1590. m_pConverter->adtb->dimst.dimtdec=var.intVal;
  1591. //  char   dimtolj;
  1592. var=dimstyle->GetDimStlVar(DIMTOLJ);
  1593. m_pConverter->adtb->dimst.dimtolj=var.intVal;
  1594. //  char   dimtzin;
  1595. var=dimstyle->GetDimStlVar(DIMTZIN);
  1596. m_pConverter->adtb->dimst.dimtzin=var.intVal;
  1597. //  short  dimunit;
  1598. var=dimstyle->GetDimStlVar(DIMLUNIT);
  1599. m_pConverter->adtb->dimst.dimunit=var.intVal;
  1600. //  char   dimupt;
  1601. var=dimstyle->GetDimStlVar(DIMUPT);
  1602. m_pConverter->adtb->dimst.dimupt=(char)var.boolVal;
  1603. //  short  dimfrac;
  1604. var=dimstyle->GetDimStlVar(DIMFRAC);
  1605. m_pConverter->adtb->dimst.dimfrac=var.intVal;
  1606. //  short  dimdsep;
  1607. var=dimstyle->GetDimStlVar(DIMDSEP);
  1608. m_pConverter->adtb->dimst.dimdsep=var.cVal;
  1609. //  short  dimtmove;
  1610. var=dimstyle->GetDimStlVar(DIMTMOVE);
  1611. m_pConverter->adtb->dimst.dimtmove=var.intVal;
  1612. //  short  dimlwd;
  1613. var=dimstyle->GetDimStlVar(DIMLWD);
  1614. {
  1615. int width=var.intVal;
  1616. int width2;
  1617. if(width==ABS_THIN_WIDTH)
  1618. {
  1619. width2=0;
  1620. }
  1621. else if(width==LWIDTH_BYLAYER)
  1622. {
  1623. width2=AD_WEIGHT_BYLAYER;
  1624. }
  1625. else if(width==LWIDTH_BYBLOCK)
  1626. {
  1627. width2=AD_WEIGHT_BYBLOCK;
  1628. }
  1629. else
  1630. {
  1631. width2=(short)(::GetLineWidthAsDouble(width)*100.0);
  1632. if(width2<=5)width2=5;
  1633. else if(width2<=9)width2=9;
  1634. else if(width2<=13)width2=13;
  1635. else if(width2<=15)width2=15;
  1636. else if(width2<=18)width2=18;
  1637. else if(width2<=20)width2=20;
  1638. else if(width2<=25)width2=25;
  1639. else if(width2<=30)width2=30;
  1640. else if(width2<=35)width2=35;
  1641. else if(width2<=40)width2=40;
  1642. else if(width2<=50)width2=50;
  1643. else if(width2<=53)width2=53;
  1644. else if(width2<=60)width2=60;
  1645. else if(width2<=70)width2=70;
  1646. else if(width2<=80)width2=80;
  1647. else if(width2<=90)width2=90;
  1648. else if(width2<=100)width2=100;
  1649. else if(width2<=106)width2=106;
  1650. else if(width2<=120)width2=120;
  1651. else if(width2<=140)width2=140;
  1652. else if(width2<=158)width2=158;
  1653. else if(width2<=200)width2=200;
  1654. else width2=211;
  1655. }
  1656. m_pConverter->adtb->dimst.dimlwd=width2;
  1657. }
  1658. //  short  dimlwe;
  1659. var=dimstyle->GetDimStlVar(DIMLWE);
  1660. {
  1661. int width=var.intVal;
  1662. int width2;
  1663. if(width==ABS_THIN_WIDTH)
  1664. {
  1665. width2=0;
  1666. }
  1667. else if(width==LWIDTH_BYLAYER)
  1668. {
  1669. width2=AD_WEIGHT_BYLAYER;
  1670. }
  1671. else if(width==LWIDTH_BYBLOCK)
  1672. {
  1673. width2=AD_WEIGHT_BYBLOCK;
  1674. }
  1675. else
  1676. {
  1677. width2=(short)(::GetLineWidthAsDouble(width)*100.0);
  1678. if(width2<=5)width2=5;
  1679. else if(width2<=9)width2=9;
  1680. else if(width2<=13)width2=13;
  1681. else if(width2<=15)width2=15;
  1682. else if(width2<=18)width2=18;
  1683. else if(width2<=20)width2=20;
  1684. else if(width2<=25)width2=25;
  1685. else if(width2<=30)width2=30;
  1686. else if(width2<=35)width2=35;
  1687. else if(width2<=40)width2=40;
  1688. else if(width2<=50)width2=50;
  1689. else if(width2<=53)width2=53;
  1690. else if(width2<=60)width2=60;
  1691. else if(width2<=70)width2=70;
  1692. else if(width2<=80)width2=80;
  1693. else if(width2<=90)width2=90;
  1694. else if(width2<=100)width2=100;
  1695. else if(width2<=106)width2=106;
  1696. else if(width2<=120)width2=120;
  1697. else if(width2<=140)width2=140;
  1698. else if(width2<=158)width2=158;
  1699. else if(width2<=200)width2=200;
  1700. else width2=211;
  1701. }
  1702. m_pConverter->adtb->dimst.dimlwe=width2;
  1703. }
  1704. //  shapefileobjhandle;
  1705. {
  1706. AD_OBJHANDLE handle;
  1707. var=dimstyle->GetDimStlVar(DIMTXSTY);
  1708. if(m_awordstyle.Get(handle,(UINT)var.intVal))
  1709. {
  1710. adHancpy(m_pConverter->adtb->dimst.shapefileobjhandle,handle);
  1711. }
  1712. }
  1713. //  AD_OBJHANDLE objhandle
  1714. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->dimst.objhandle);
  1715. //short  ADCDECL adAddDimstyle _((AD_DB_HANDLE handle,PAD_DIMSTYLE dimst));
  1716. if (!adAddDimstyle(m_pConverter->m_dwghandle,&m_pConverter->adtb->dimst))
  1717. {
  1718. _ERROR;
  1719. continue;
  1720. }
  1721. m_adimstyle.Add(m_pConverter->adtb->dimst.objhandle,dimstyle->GetID(),1.0,FALSE);
  1722. }
  1723. return TRUE;
  1724. }
  1725. BOOL CKmgReader::processwordstyle(CKmDataManager* pData)
  1726. {
  1727. CString strTemp;
  1728. CWordStyle ws;
  1729. for(int i=0;i<pData->GetWordStyleNum();i++)
  1730. {
  1731. ws=pData->GetWordStyle(i);
  1732. //void adSetDefaultShapefile (PAD_SHPTB shptb);
  1733. adSetDefaultShapefile(&m_pConverter->adtb->shptb);
  1734. // CString m_strFontName; //字体名称
  1735. // BOOL bTTF=TRUE;
  1736. {
  1737. strTemp.Empty();
  1738. strTemp=ws.GetFontName();
  1739. // CString strTemp2=strTemp;
  1740. // strTemp2.MakeLower();
  1741. // if(strTemp2.Find(".shx")!=-1)
  1742. // {
  1743. // bTTF=FALSE;
  1744. // }
  1745. int i=strTemp.Find(';');
  1746. if(i>=0&&i<strTemp.GetLength())
  1747. {
  1748. ::strcpy(m_pConverter->adtb->shptb.file,(char*)(LPCTSTR)strTemp.Left(i));
  1749. ::strcpy(m_pConverter->adtb->shptb.bigfontname,(char*)(LPCTSTR)strTemp.Right(strTemp.GetLength()-i-1));
  1750. }
  1751. else
  1752. {
  1753. ::strcpy(m_pConverter->adtb->shptb.file,(char*)(LPCTSTR)strTemp);
  1754. }
  1755. }
  1756. // double  m_dHeight; //字高
  1757. m_pConverter->adtb->shptb.height=ws.GetHeight();
  1758. // CString m_strName;
  1759. CString strName=m_pConverter->ConverterTabEntName(ws.GetName());
  1760. ::strcpy(m_pConverter->adtb->shptb.name,(char*)(LPCTSTR)strName);
  1761. // double  m_dWFactor; //字宽因子,为字宽和字高的比例
  1762. m_pConverter->adtb->shptb.width=/*ws.GetHeight()*/ws.GetWFactor();
  1763. // double  m_dPFactor; //字间距因子,为字间距与字宽的比例
  1764. // BYTE m_bDir; //方向,0,1,2,3分别表示0,90,180,270度。
  1765. if(ws.GetDirection()==1)
  1766. m_pConverter->adtb->shptb.angle=PI*0.5;
  1767. else if(ws.GetDirection()==2)
  1768. m_pConverter->adtb->shptb.angle=PI;
  1769. else if(ws.GetDirection()==3)
  1770. m_pConverter->adtb->shptb.angle=PI*1.5;
  1771. else 
  1772. m_pConverter->adtb->shptb.angle=0;
  1773. /* if(bTTF)
  1774. {
  1775. AD_VMADDR theblob;
  1776. PAD_BLOB_CTRL bcptr;
  1777. AD_XD badxd;
  1778. theblob=adCreateBlob();
  1779. bcptr=adStartBlobWrite(theblob);
  1780. {
  1781. badxd.xddxfnumber=1002;
  1782. badxd.xddata.xdcontrol='{';
  1783. adWriteExtendeddata(bcptr,&badxd);
  1784. }
  1785. if(!adStartRegappGet(m_pConverter->m_dwghandle))
  1786. {
  1787. _ERROR;
  1788. }
  1789. else if(!adGetRegapp(m_pConverter->m_dwghandle,&m_pConverter->adtb->app))
  1790. {
  1791. _ERROR;
  1792. }
  1793. else
  1794. {
  1795. adHancpy(badxd.xddata.xdappobjhandle,m_pConverter->adtb->app.objhandle);
  1796. badxd.xddxfnumber=1001;
  1797. adWriteExtendeddata(bcptr,&badxd);
  1798. }
  1799. {
  1800. badxd.xddxfnumber=1000;
  1801. try
  1802. {
  1803. ::memcpy(badxd.xddata.xdstring,(char*)(LPCTSTR)strTemp,strTemp.GetLength());
  1804. badxd.xddata.xdstring[strTemp.GetLength()]=0;
  1805. }
  1806. catch(...)
  1807. {
  1808. }
  1809. adWriteExtendeddata(bcptr,&badxd);
  1810. }
  1811. {
  1812. badxd.xddxfnumber=1002;
  1813. badxd.xddata.xdcontrol='}';
  1814. adWriteExtendeddata(bcptr,&badxd);
  1815. }
  1816. adEndBlobWrite(bcptr);
  1817. }*/
  1818. adGenerateObjhandle(m_pConverter->m_dwghandle,m_pConverter->adtb->shptb.objhandle);
  1819. //short adAddShapefile (AD_DB_HANDLE handle, PAD_SHPTB shptb);
  1820. if (!adAddShapefile(m_pConverter->m_dwghandle,&m_pConverter->adtb->shptb))
  1821. {
  1822. _ERROR;
  1823. continue;
  1824. }
  1825. m_awordstyle.Add(m_pConverter->adtb->shptb.objhandle,ws.GetID(),1.0,FALSE);
  1826. }
  1827. return TRUE;
  1828. }
  1829. BOOL CKmgReader::processlegend(CKmDataManager* pData)
  1830. {
  1831. KmLegend* pLegend=pData->GetLegend();
  1832. if(pLegend == NULL)
  1833. {
  1834. return FALSE;
  1835. }
  1836. CMatch2* match=new CMatch2;
  1837. //1.创建块定义
  1838. m_pConverter->ConverterEntity_KmBlockdef("KmLegend",match);
  1839. m_pConverter->SetBlockDataVassel(match->m_handle);
  1840. //2.增加AD_ENT_BLOCK
  1841. m_pConverter->AddBegBlkSign(0.0,0.0,0.0);
  1842. m_pConverter->ConverterKmLegend(pLegend->GetLocate().x,pLegend->GetLocate().y,pLegend->GetXLength(),pLegend->GetYLength());
  1843. KmBuffer buff;
  1844.     CShow* pShow = new CGDIShow((CWnd*)NULL);
  1845. pLegend->Draw(pShow,DRAWPRESENT,&buff);
  1846. int size=buff.GetLineBuffSize();
  1847. for(int j=0;j<size;j++)
  1848. {
  1849. if(!processentity_buf_line(pData,buff.GetLineEnt(j)))
  1850. {
  1851. _WRITE(str="转换buf直线失败");
  1852. }
  1853. }
  1854. size=buff.GetCircleBuffSize();
  1855. for(j=0;j<size;j++)
  1856. {
  1857. if(!processentity_buf_circle(pData,buff.GetCircleEnt(j)))
  1858. {
  1859. _WRITE(str="转换buf圆失败");
  1860. }
  1861. }
  1862. size=buff.GetRegionBuffSize();
  1863. for(j=0;j<size;j++)
  1864. {
  1865. if(!processentity_buf_region(pData,buff.GetRegionEnt(j)))
  1866. {
  1867. _WRITE(str="转换buf区域失败");
  1868. }
  1869. }
  1870. size=buff.GetTextBuffSize();
  1871. for(j=0;j<size;j++)
  1872. {
  1873. if(!processentity_buf_text(pData,buff.GetTextEnt(j)))
  1874. {
  1875. _WRITE(str="转换buf文字失败");
  1876. }
  1877. }
  1878. delete pShow;
  1879. buff.ClearKmBuffer();
  1880. //3.增加AD_ENT_ENDBLK
  1881. m_pConverter->AddEndBlkSign();
  1882. m_pConverter->ConverterEntity_AdInsert(0.0,0.0,0.0,1.0,1.0,1.0,0.0,match->m_handle);
  1883. delete match;
  1884. return TRUE;
  1885. }
  1886. BOOL CKmgReader::processblockdef(CKmDataManager* pData)
  1887. {
  1888. CMatch2* match=new CMatch2;
  1889. KmBlockDef* pDef=pData->GetFirstBlockDef();
  1890. while(pDef!=NULL)
  1891. {
  1892. match->m_id=pDef->GetID();
  1893. if(m_pConverter->ConverterEntity_KmBlockdef(pDef->GetName(),match))
  1894. {
  1895. m_ablock.Add(match->m_handle,match->m_id,1.0,FALSE);
  1896. }
  1897. pDef=pData->GetNextBlockDef();
  1898. }
  1899. delete match;
  1900. return TRUE;
  1901. }
  1902. //处理块嵌套因此与块定义分开处理
  1903. BOOL CKmgReader::processblockdefentity(CKmDataManager* pData)
  1904. {
  1905. KmBlockDef* pDef;
  1906. KmObject* pObj;
  1907. CMatch2* match;
  1908. POSITION pos=m_ablock.GetHeadPosition();
  1909. while(pos!=NULL)
  1910. {
  1911. match=m_ablock.GetNext(pos);
  1912. pDef=pData->GetBlockDef(match->m_id);
  1913. if(pDef!=NULL)
  1914. {
  1915. m_pConverter->SetBlockDataVassel(match->m_handle);
  1916. _ERROR;
  1917. m_pConverter->AddBegBlkSign(pDef->GetBasePt().x,pDef->GetBasePt().y,0);
  1918. for(UINT i=0;i<pDef->GetObjectNum();i++)
  1919. {
  1920. pDef->GetObjectAt(i,pObj);
  1921. if(!processentity(pData,pObj))
  1922. {
  1923. _ERROR;
  1924. _WRITE(str.Format("%s+%d+没有处理",pObj->Type(),pObj->GetObjectID().dwEntIndex));
  1925. }
  1926. }
  1927. m_pConverter->AddEndBlkSign();
  1928. _ERROR;
  1929. }
  1930. }
  1931. m_pConverter->SetModelDataVassel();
  1932. return TRUE;
  1933. }