Converterfile3.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:2k
- // KmgConverter.cpp: implementation of the CKmgConverter class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "FileSwitch.h"
- #include "KmgConverter.h"
- #include "KmLayer.h"
- #include "showdef.h"
- #include "entdef.h"
- #include "KmEntity.h"
- #include "Block.h"
- #include "WordStyle.h"
- #include "DwgReader.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- extern CStdioFile g_CensorialFile; //监察转换进度的文件
- extern int g_mode;
- BOOL CKmgConverter::ConverterPreSave_KmLegend(BOOL bRected,KmRect rectOutSide)
- {
- BOOL bFirst=TRUE;
- if(bRected)
- {
- bFirst=FALSE;
- }
- else
- {
- //转换图框
- int index;
- KmRect rect;
- KmObject* pObj;
- int DicNum = ::GetEntDicSize(); //获得字典项数量
- DICTIONARY_ITEM DicItem; //实体字典表
- for(index=0;index<DicNum;index++)
- {//遍历字典项
- DicItem=::GetEntDicAt(index); //获得一个实体类型
- KmIteratorPtr pI(m_pDataManager->CreateIterator(DicItem));
- for(pI->First(); !pI->IsDone(); pI->Next())
- {//遍历实体列表
- pObj = pI->CurrentItem();
- if(pObj)
- {
- //仅供测试 KmRect rect2=pObj->GetRect();
- //仅供测试 CString str2;
- //仅供测试 str2.Format( "n%st%dt%lft%lft%lft%lf",pObj->GetObjectID().ClassID,pObj->GetObjectID().dwEntIndex,rect2.left,rect2.right,rect2.bottom,rect2.top);
- //仅供测试 _WRITE(str=str2);
- if(bFirst)
- {
- bFirst=FALSE;
- rect = pObj->GetRect();
- }
- else
- {
- rect |= pObj->GetRect();
- }
- }
- }
- }
- rectOutSide=rect;
- }
- if(bFirst)
- {
- m_pDataManager->GetLegend()->SetMainData(LEGEND_USER,0,FALSE,0,0,m_dSysDimScale,1,110,110,5);
- }
- else
- {
- rectOutSide.NormalizeRect();
- if(rectOutSide.Width()+rectOutSide.Height()<100*m_dSysDimScale)//禁止非法图幅
- {
- m_dSysDimScale=(rectOutSide.Width()+rectOutSide.Height())/200;
- }
- else if(rectOutSide.Width()+rectOutSide.Height()>4000*m_dSysDimScale)//禁止非法图幅
- {
- m_dSysDimScale=(rectOutSide.Width()+rectOutSide.Height())/3000;
- }
- m_pDataManager->GetLegend()->SetMainData(LEGEND_USER,0,FALSE,0,0,m_dSysDimScale,1,rectOutSide.Width()/m_dSysDimScale+10,rectOutSide.Height()/m_dSysDimScale+10,5);
- }
- m_pDataManager->GetLegend()->SetLocate(KmPoint(rectOutSide.left-5,rectOutSide.bottom-5));
- return TRUE;
- }