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

CAD

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "FileSwitch.h"
  3. #include "DwgReader.h"
  4. #include "KmSection.h"
  5. #include "Reader.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. extern CStdioFile g_CensorialFile; //监察转换进度的文件
  12. extern int g_mode;
  13. BOOL CDwgReader::processobject_mlinestyle(AD_DB_HANDLE dwghandle)
  14. {
  15. CMatch4* match=new CMatch4;
  16. match->m_showmiter=adob->mlstyle.flag&AD_MLSTYLE_FILL_ON;
  17. match->m_startinner=adob->mlstyle.flag&AD_MLSTYLE_START_INNER_ARC;
  18. match->m_startline=adob->mlstyle.flag&AD_MLSTYLE_START_SQUARE;
  19. match->m_startouter=adob->mlstyle.flag&AD_MLSTYLE_START_ROUND;
  20. match->m_endinner=adob->mlstyle.flag&AD_MLSTYLE_END_INNER_ARC;
  21. match->m_endline=adob->mlstyle.flag&AD_MLSTYLE_END_SQUARE;
  22. match->m_endouter=adob->mlstyle.flag&AD_MLSTYLE_END_ROUND;
  23. match->m_showmiter=adob->mlstyle.flag&AD_MLSTYLE_SHOW_MITERS;
  24. PAD_BLOB_CTRL bcptr;
  25. //PAD_BLOB_CTRL adStartBlobRead (AD_VMADDR blob);
  26. bcptr=adStartBlobRead(adob->mlstyle.seginfoblob);
  27. AD_MLSTYLESEGINFO seginfo;
  28. for(unsigned short i=0;i<adob->mlstyle.linesinstyle;i++)
  29. {
  30. //short adReadMlstyleSeginfo (PAD_BLOB_CTRL bcptr,  PAD_MLSTYLESEGINFO seginfo);
  31. sReturnValue=adReadMlstyleSeginfo(bcptr,&seginfo);
  32. if(sReturnValue!=1)
  33. {
  34. delete match;
  35. _ERROR;
  36. return FALSE;
  37. }
  38. int icolor;
  39. try
  40. {
  41. if(seginfo.segcolor==AD_COLOR_BYBLOCK)
  42. {
  43. icolor=COLOR_BYBLOCK;//随块
  44. }
  45. else if(seginfo.segcolor==AD_COLOR_BYLAYER)
  46. {
  47. icolor=COLOR_BYLAYER;
  48. }
  49. else
  50. {
  51. if(seginfo.segcolor>=0 && seginfo.segcolor<m_aColor.GetSize())
  52. {
  53. icolor=m_aColor[seginfo.segcolor];
  54. }
  55. else
  56. {
  57. TRACE("errordata");
  58. }
  59. }
  60. }
  61. catch(...)
  62. {
  63. _WRITE(str="非法的颜色码");
  64. return FALSE;
  65. }
  66. match->segcolor.Add(icolor);
  67. if(seginfo.ltindex==0x7fff)//随层
  68. {
  69. match->segltyle.Add(LTYPE_BYLAYER);
  70. }
  71. else if(seginfo.ltindex==0x7ffe)//随块
  72. {
  73. match->segltyle.Add(LTYPE_BYBLOCK);
  74. }
  75. else
  76. {
  77. match->segltyle.Add(m_altype.Get(seginfo.ltindex));
  78. }
  79. }
  80. //short adEndBlobRead (PAD_BLOB_CTRL bcptr);
  81. sReturnValue=adEndBlobRead(bcptr);
  82. if(sReturnValue!=1)
  83. {
  84. delete match;
  85. _ERROR;
  86. return FALSE;
  87. }
  88. m_amltype.Add(adobhd->objhandle,match);
  89. return TRUE;
  90. }
  91. BOOL CDwgReader::processobject_layout(AD_DB_HANDLE dwghandle)
  92. {
  93. /*
  94. 页面设置对话框的数据
  95. typedef struct adplotsettingsobjstru {
  96.   char pagesetupname[AD_MAX_STRLEN]; //页面设置名
  97.   char printerorconfigfilename[AD_MAX_STRLEN]; //打印机配置名称
  98.   char papersize[AD_MAX_STRLEN]; //图纸尺寸
  99.   char plotviewname[AD_MAX_STRLEN]; //打印区域-视图名称
  100.   double leftmargin;bottommargin;rightmargin;topmargin;//图区域
  101.   double paperwidth;paperheight;//纸区域
  102.   double origin[2]; //打印偏移
  103.   double windowmin[2];windowmax[2];
  104.   double realworldunits; //打印比例
  105.   double drawingunits;
  106.   short  plotlayoutflag;
  107.   short  plotpaperunits;
  108.   short plotrotation;
  109.   short plottype;
  110.   char currentstylesheet[AD_MAX_STRLEN];//打印样式表
  111.   short scaletype;
  112.   double scalefactor;
  113.   double paperimageorigin[2];
  114. } AD_PLOTSETTINGS, *PAD_PLOTSETTINGS;
  115. */
  116. if(m_dplotstyleconvmode==1)
  117. {
  118. CString strPlotStyleSheet=adob->layout.plotsettings.currentstylesheet;
  119. CFileFind filefind;
  120. if(!filefind.FindFile(strPlotStyleSheet))
  121. {
  122. CString strTemp;
  123. TCHAR szFileName[MAX_PATH]; 
  124. ::GetModuleFileName(::GetModuleHandle(_T("FileSwitch.dll")),szFileName,MAX_PATH); 
  125. (*_tcsrchr(szFileName,'\'))=''; 
  126. CString strPath=szFileName;
  127. strPath+="\";
  128. strPath+="SUPPORT";
  129. strPath+="\";
  130. strTemp=strPath+"plotstyle.bak";
  131. strPath+=strPlotStyleSheet;
  132. if(filefind.FindFile(strPath))
  133. {
  134. ::CopyFile(strPath,strTemp,FALSE);//备份
  135. ::DeleteFile(strPath);
  136. }
  137. calculate_DefaultExamineFile(strPlotStyleSheet,"Plot Styles","SUPPORT");
  138. if(!filefind.FindFile(strPath))
  139. {
  140. if(filefind.FindFile(strTemp))
  141. {
  142. ::CopyFile(strTemp,strPath,FALSE);//恢复
  143. ::DeleteFile(strTemp);
  144. }
  145. }
  146. else if(filefind.FindFile(strTemp))
  147. {
  148. ::DeleteFile(strTemp);
  149. }
  150. strPlotStyleSheet=strPath;
  151. }
  152. if(filefind.FindFile(strPlotStyleSheet))
  153. {
  154. //extern  short  ADCDECL adReadPlotStyleTable _((char *pszInputFile, ADPLOTSTYLETABLE **ppTable));
  155. ADPLOTSTYLETABLE* pPlotStyleTable=NULL;
  156. sReturnValue=adReadPlotStyleTable((char*)(LPCTSTR)strPlotStyleSheet, &pPlotStyleTable);
  157. if(pPlotStyleTable)
  158. {
  159. if(sReturnValue!=1)
  160. {
  161. try
  162. {
  163. //extern  short  ADCDECL adFreePlotStyleTable _((ADPLOTSTYLETABLE *pTable));
  164. sReturnValue=adFreePlotStyleTable(pPlotStyleTable);
  165. if(sReturnValue!=1)
  166. {
  167. _WRITE2(str="释放打印样式错误");
  168. }
  169. }
  170. catch(...)
  171. {
  172. }
  173. }
  174. else
  175. {
  176. int iCurplotSheet=m_aPlotStyleTable.Add(pPlotStyleTable);
  177. if(strcmp(adob->layout.name,"Model"))
  178. {
  179. m_apaper.Add(adob->layout.pspaceblockrec,adob->layout.name,iCurplotSheet);
  180. }
  181. else
  182. {
  183. m_iModelPlotStyleTable=iCurplotSheet;
  184. }
  185. return TRUE;
  186. }
  187. }
  188. }
  189. }
  190. if(strcmp(adob->layout.name,"Model"))
  191. {
  192. m_apaper.Add(adob->layout.pspaceblockrec,adob->layout.name,-1);
  193. }
  194. return TRUE;
  195. }