ConvIges2Kmg.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:4k
- // ConvIges2Kmg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "FileSwitch.h"
- #include "ConvIges2Kmg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CConvIges2Kmg
- IMPLEMENT_DYNCREATE(CConvIges2Kmg, CCmdTarget)
- CConvIges2Kmg::CConvIges2Kmg()
- {
- EnableAutomation();
-
- // To keep the application running as long as an OLE automation
- // object is active, the constructor calls AfxOleLockApp.
-
- AfxOleLockApp();
- }
- CConvIges2Kmg::~CConvIges2Kmg()
- {
- // To terminate the application when all objects created with
- // with OLE automation, the destructor calls AfxOleUnlockApp.
-
- AfxOleUnlockApp();
- }
- void CConvIges2Kmg::OnFinalRelease()
- {
- // When the last reference for an automation object is released
- // OnFinalRelease is called. The base class will automatically
- // deletes the object. Add additional cleanup required for your
- // object before calling the base class.
- CCmdTarget::OnFinalRelease();
- }
- BEGIN_MESSAGE_MAP(CConvIges2Kmg, CCmdTarget)
- //{{AFX_MSG_MAP(CConvIges2Kmg)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- BEGIN_DISPATCH_MAP(CConvIges2Kmg, CCmdTarget)
- //{{AFX_DISPATCH_MAP(CConvIges2Kmg)
- DISP_FUNCTION(CConvIges2Kmg, "BeginConverter", BeginConverter, VT_BOOL, VTS_BSTR)
- DISP_FUNCTION(CConvIges2Kmg, "EndConverter", EndConverter, VT_BOOL, VTS_NONE)
- DISP_FUNCTION(CConvIges2Kmg, "ConverterIges2Kmg", ConverterIges2Kmg, VT_BOOL, VTS_BSTR VTS_BSTR)
- DISP_FUNCTION(CConvIges2Kmg, "GetProgressInfo", GetProgressInfo, VT_BOOL, VTS_PR8 VTS_PBSTR)
- //}}AFX_DISPATCH_MAP
- END_DISPATCH_MAP()
- // Note: we add support for IID_IConvIges2Kmg to support typesafe binding
- // from VBA. This IID must match the GUID that is attached to the
- // dispinterface in the .ODL file.
- // {FED117A9-C501-4271-A7E0-38E09449FD07}
- static const IID IID_IConvIges2Kmg =
- { 0xfed117a9, 0xc501, 0x4271, { 0xa7, 0xe0, 0x38, 0xe0, 0x94, 0x49, 0xfd, 0x7 } };
- BEGIN_INTERFACE_MAP(CConvIges2Kmg, CCmdTarget)
- INTERFACE_PART(CConvIges2Kmg, IID_IConvIges2Kmg, Dispatch)
- END_INTERFACE_MAP()
- // {6B897F7D-3C31-4445-BD35-9E7034BC8BB3}
- IMPLEMENT_OLECREATE(CConvIges2Kmg, "FileSwitch.ConvIges2Kmg", 0x6b897f7d, 0x3c31, 0x4445, 0xbd, 0x35, 0x9e, 0x70, 0x34, 0xbc, 0x8b, 0xb3)
- /////////////////////////////////////////////////////////////////////////////
- // CConvIges2Kmg message handlers
- extern CFileSwitchApp theApp;
- extern CStdioFile g_CensorialFile; //监察转换进度的文件
- extern int g_mode;
- BOOL CConvIges2Kmg::BeginConverter(LPCTSTR strRegistryKey)
- {
- m_pProgress=new CProgressInfo;
- m_pCommand=new CCommandInfo;
- m_pConverter=new CKmgConverter2;
- m_pReader=new CIgesReader(m_pProgress,m_pCommand,m_pConverter);
- theApp.SetUserRegistryKey(strRegistryKey);
- return m_pReader->BeginConvert();
- }
- BOOL CConvIges2Kmg::EndConverter()
- {
- BOOL bSuccess=m_pReader->EndConvert();
- delete m_pProgress;
- delete m_pCommand;
- delete m_pReader;
- delete m_pConverter;
- return bSuccess;
- }
- BOOL CConvIges2Kmg::ConverterIges2Kmg(LPCTSTR strIgesFilename, LPCTSTR strKmgFilename)
- {
- m_pCommand->m_strSourceName=strIgesFilename;
- m_pCommand->m_strAimName=strKmgFilename;
- g_mode=0;
- //theApp.GetProfileInt("PARAMETER","CONVMODE",0);
- //if(g_mode!=1)
- //{
- // g_mode=0;
- //}
- //theApp.WriteProfileInt("PARAMETER","CONVMODE",0);
- _CONV_OPEN;
- BOOL bSucc=m_pReader->Parse();
- _CONV_CLOSE;
- return bSucc;
- }
- BOOL CConvIges2Kmg::GetProgressInfo(double FAR* pdProgress, BSTR FAR* pstrProgressTip)
- {
- double dProgress;
- CString strProgressTip;
- if(m_pProgress==NULL)
- {
- return FALSE;
- }
- m_pProgress->GetProgressInfo(dProgress,strProgressTip);
- *pstrProgressTip=(BSTR FAR)(LPCTSTR)strProgressTip;
- *pdProgress=dProgress;
- return TRUE;
- }