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

CAD

开发平台:

Visual C++

  1. // ConvIges2Kmg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "FileSwitch.h"
  5. #include "ConvIges2Kmg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CConvIges2Kmg
  13. IMPLEMENT_DYNCREATE(CConvIges2Kmg, CCmdTarget)
  14. CConvIges2Kmg::CConvIges2Kmg()
  15. {
  16. EnableAutomation();
  17. // To keep the application running as long as an OLE automation 
  18. // object is active, the constructor calls AfxOleLockApp.
  19. AfxOleLockApp();
  20. }
  21. CConvIges2Kmg::~CConvIges2Kmg()
  22. {
  23. // To terminate the application when all objects created with
  24. //  with OLE automation, the destructor calls AfxOleUnlockApp.
  25. AfxOleUnlockApp();
  26. }
  27. void CConvIges2Kmg::OnFinalRelease()
  28. {
  29. // When the last reference for an automation object is released
  30. // OnFinalRelease is called.  The base class will automatically
  31. // deletes the object.  Add additional cleanup required for your
  32. // object before calling the base class.
  33. CCmdTarget::OnFinalRelease();
  34. }
  35. BEGIN_MESSAGE_MAP(CConvIges2Kmg, CCmdTarget)
  36. //{{AFX_MSG_MAP(CConvIges2Kmg)
  37. // NOTE - the ClassWizard will add and remove mapping macros here.
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. BEGIN_DISPATCH_MAP(CConvIges2Kmg, CCmdTarget)
  41. //{{AFX_DISPATCH_MAP(CConvIges2Kmg)
  42. DISP_FUNCTION(CConvIges2Kmg, "BeginConverter", BeginConverter, VT_BOOL, VTS_BSTR)
  43. DISP_FUNCTION(CConvIges2Kmg, "EndConverter", EndConverter, VT_BOOL, VTS_NONE)
  44. DISP_FUNCTION(CConvIges2Kmg, "ConverterIges2Kmg", ConverterIges2Kmg, VT_BOOL, VTS_BSTR VTS_BSTR)
  45.    DISP_FUNCTION(CConvIges2Kmg, "GetProgressInfo", GetProgressInfo, VT_BOOL, VTS_PR8 VTS_PBSTR)
  46. //}}AFX_DISPATCH_MAP
  47. END_DISPATCH_MAP()
  48. // Note: we add support for IID_IConvIges2Kmg to support typesafe binding
  49. //  from VBA.  This IID must match the GUID that is attached to the 
  50. //  dispinterface in the .ODL file.
  51. // {FED117A9-C501-4271-A7E0-38E09449FD07}
  52. static const IID IID_IConvIges2Kmg =
  53. { 0xfed117a9, 0xc501, 0x4271, { 0xa7, 0xe0, 0x38, 0xe0, 0x94, 0x49, 0xfd, 0x7 } };
  54. BEGIN_INTERFACE_MAP(CConvIges2Kmg, CCmdTarget)
  55. INTERFACE_PART(CConvIges2Kmg, IID_IConvIges2Kmg, Dispatch)
  56. END_INTERFACE_MAP()
  57. // {6B897F7D-3C31-4445-BD35-9E7034BC8BB3}
  58. IMPLEMENT_OLECREATE(CConvIges2Kmg, "FileSwitch.ConvIges2Kmg", 0x6b897f7d, 0x3c31, 0x4445, 0xbd, 0x35, 0x9e, 0x70, 0x34, 0xbc, 0x8b, 0xb3)
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CConvIges2Kmg message handlers
  61. extern CFileSwitchApp theApp;
  62. extern CStdioFile g_CensorialFile; //监察转换进度的文件
  63. extern int g_mode;
  64. BOOL CConvIges2Kmg::BeginConverter(LPCTSTR strRegistryKey) 
  65. {
  66. m_pProgress=new CProgressInfo; 
  67. m_pCommand=new CCommandInfo;  
  68. m_pConverter=new CKmgConverter2; 
  69. m_pReader=new CIgesReader(m_pProgress,m_pCommand,m_pConverter);       
  70. theApp.SetUserRegistryKey(strRegistryKey);
  71. return m_pReader->BeginConvert();
  72. }
  73. BOOL CConvIges2Kmg::EndConverter() 
  74. {
  75. BOOL bSuccess=m_pReader->EndConvert();
  76. delete m_pProgress; 
  77. delete m_pCommand;  
  78. delete m_pReader;       
  79. delete m_pConverter;    
  80. return bSuccess;
  81. }
  82. BOOL CConvIges2Kmg::ConverterIges2Kmg(LPCTSTR strIgesFilename, LPCTSTR strKmgFilename) 
  83. {
  84. m_pCommand->m_strSourceName=strIgesFilename;
  85. m_pCommand->m_strAimName=strKmgFilename;
  86. g_mode=0;
  87. //theApp.GetProfileInt("PARAMETER","CONVMODE",0);
  88. //if(g_mode!=1)
  89. //{
  90. // g_mode=0;
  91. //}
  92. //theApp.WriteProfileInt("PARAMETER","CONVMODE",0);
  93. _CONV_OPEN;
  94. BOOL bSucc=m_pReader->Parse();
  95. _CONV_CLOSE;
  96. return bSucc;
  97. }
  98. BOOL CConvIges2Kmg::GetProgressInfo(double FAR* pdProgress, BSTR FAR* pstrProgressTip) 
  99. {
  100. double dProgress;
  101. CString strProgressTip;
  102. if(m_pProgress==NULL)
  103. {
  104. return FALSE;
  105. }
  106. m_pProgress->GetProgressInfo(dProgress,strProgressTip);
  107. *pstrProgressTip=(BSTR FAR)(LPCTSTR)strProgressTip;
  108. *pdProgress=dProgress;
  109. return TRUE;
  110. }