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

CAD

开发平台:

Visual C++

  1. // KmgConverter.cpp: implementation of the CKmgConverter class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "FileSwitch.h"
  6. #include "KmgConverter.h"
  7. #include "KmLayer.h"
  8. #include "showdef.h"
  9. #include "entdef.h"
  10. #include "KmEntity.h"
  11. #include "Block.h"
  12. #include "WordStyle.h"
  13. #include "DwgReader.h"
  14. #ifdef _DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[]=__FILE__;
  17. #define new DEBUG_NEW
  18. #endif
  19. extern CStdioFile g_CensorialFile; //监察转换进度的文件
  20. extern int g_mode;
  21. BOOL CKmgConverter::ConverterPreSave_KmLegend(BOOL bRected,KmRect rectOutSide)
  22. {
  23. BOOL bFirst=TRUE;
  24. if(bRected)
  25. {
  26. bFirst=FALSE;
  27. }
  28. else
  29. {
  30. //转换图框
  31. int index;
  32. KmRect rect;
  33. KmObject* pObj;
  34. int DicNum = ::GetEntDicSize(); //获得字典项数量
  35. DICTIONARY_ITEM  DicItem; //实体字典表
  36. for(index=0;index<DicNum;index++)
  37. {//遍历字典项
  38. DicItem=::GetEntDicAt(index); //获得一个实体类型
  39. KmIteratorPtr pI(m_pDataManager->CreateIterator(DicItem));
  40. for(pI->First(); !pI->IsDone(); pI->Next())
  41. {//遍历实体列表
  42. pObj = pI->CurrentItem();
  43. if(pObj)
  44. {
  45. //仅供测试 KmRect rect2=pObj->GetRect();
  46. //仅供测试 CString str2;
  47. //仅供测试 str2.Format( "n%st%dt%lft%lft%lft%lf",pObj->GetObjectID().ClassID,pObj->GetObjectID().dwEntIndex,rect2.left,rect2.right,rect2.bottom,rect2.top);
  48. //仅供测试 _WRITE(str=str2);
  49. if(bFirst)
  50. {
  51. bFirst=FALSE;
  52. rect = pObj->GetRect();
  53. }
  54. else
  55. {
  56. rect |= pObj->GetRect();
  57. }
  58. }
  59. }
  60. }
  61. rectOutSide=rect;
  62. }
  63. if(bFirst)
  64. {
  65. m_pDataManager->GetLegend()->SetMainData(LEGEND_USER,0,FALSE,0,0,m_dSysDimScale,1,110,110,5);
  66. }
  67. else
  68. {
  69. rectOutSide.NormalizeRect();
  70. if(rectOutSide.Width()+rectOutSide.Height()<100*m_dSysDimScale)//禁止非法图幅
  71. {
  72. m_dSysDimScale=(rectOutSide.Width()+rectOutSide.Height())/200;
  73. }
  74. else if(rectOutSide.Width()+rectOutSide.Height()>4000*m_dSysDimScale)//禁止非法图幅
  75. {
  76. m_dSysDimScale=(rectOutSide.Width()+rectOutSide.Height())/3000;
  77. }
  78. m_pDataManager->GetLegend()->SetMainData(LEGEND_USER,0,FALSE,0,0,m_dSysDimScale,1,rectOutSide.Width()/m_dSysDimScale+10,rectOutSide.Height()/m_dSysDimScale+10,5);
  79. }
  80. m_pDataManager->GetLegend()->SetLocate(KmPoint(rectOutSide.left-5,rectOutSide.bottom-5));
  81. return TRUE;
  82. }