Processfile4.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:39k
- // KMCAD40-FileSwitch-Processfile4.cpp-1.0
- #include "stdafx.h"
- #include "DimStyle.h"
- #include "FileSwitch.h"
- #include "DwgReader.h"
- #include "KmSection.h"
- #include "DimCmn.h"
- #include "KmDim.h"
- #include "Vector.h"
- #include "Reader.h"
- #include <atlbase.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 CDwgReader::processentity_dim(AD_DB_HANDLE dwghandle)
- {
- if(m_ddimconvmode==1)
- {
- return processentity_dim_blockref(dwghandle);
- }
-
- if(adHansame(aden->dim.dimstyleobjhandle,NULLOBJHANDLE))
- {
- adHancpy(aden->dim.dimstyleobjhandle,m_hFirstDimStyle);
- }
-
- // AD_DIMTYPE_XORDDIM (this ordinate dimension is in the X direction)
- // AD_DIMTYPE_TEXTPOS (indicates the dim text is at a user-defined location).
- //dimflag尺寸类型
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.dimcloneinspt[0],aden->dim.dimcloneinspt[1],aden->dim.dimcloneinspt[2],1);
- //arcdefpt 尺寸坐标
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.arcdefpt[0],aden->dim.arcdefpt[1],aden->dim.arcdefpt[2],0.1);
- //defpt2 尺寸坐标
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.defpt2[0],aden->dim.defpt2[1],aden->dim.defpt2[2],0.2);
- //defpt3 尺寸坐标
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.defpt3[0],aden->dim.defpt3[1],aden->dim.defpt3[2],0.3);
- //defpt4 尺寸坐标
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.defpt4[0],aden->dim.defpt4[1],aden->dim.defpt4[2],0.4);
- //Dimtextmidpt尺寸文字中点
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.dimtextmidpt[0],aden->dim.dimtextmidpt[1],aden->dim.dimtextmidpt[2],0.5);
- //Dimlinedefpt尺寸文字定义点
- //调试使用 m_pConverter->ConverterEntiey_KmCircle(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1],aden->dim.dimlinedefpt[2],0.6);
- //Dimrotang尺寸角度
- //leaderlen 尺寸引出线长度
- //dimoblique 尺寸倾斜角度
- //dimtextrot 尺寸文字角度
- //dimtext 尺寸文字
- //Linespacingstyle行距风格 is either 1 (at least), or 2 (exact).
- //linespacingfactor 行距距离百分比0.25 to 4.0.
- switch(aden->dim.dimflag & ' 7')
- {
- case AD_DIMTYPE_ROTATED:
- if(!processentity_dim_rotated(dwghandle))//0
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_ALIGNED:
- if(!processentity_dim_aligned(dwghandle))//1
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_ANGULAR:
- if(!processentity_dim_angular(dwghandle))//2
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_DIAMETER:
- if(!processentity_dim_diameter(dwghandle))//3
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_RADIUS:
- if(!processentity_dim_radius(dwghandle))//4
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_ANGULAR3PT:
- if(!processentity_dim_angular3pt(dwghandle))//5
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- case AD_DIMTYPE_ORDINATE:
- if(!processentity_dim_ordinate(dwghandle))//6
- {
- return processentity_dim_blockref(dwghandle);
- }
- break;
- default:
- _WRITE(str="不可识别的尺寸类型");
- return processentity_dim_blockref(dwghandle);
- }
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_head(AD_DB_HANDLE dwghandle,KmObject* obj)
- {
- if(!obj->IsKindOf(RUNTIME_CLASS(KmDim)))
- {
- return FALSE;
- }
- UINT id;
- if(!m_adimstyle.Get(id,aden->dim.dimstyleobjhandle))
- {
- return FALSE;
- }
- CKmDataManager* pDataMgr=::GetActiveDataManager();
- if(!pDataMgr)
- {
- return FALSE;
- }
- CDimStyle* pDimStyle=pDataMgr->GetDimStyle(id);
- if(!pDimStyle)
- {
- return FALSE;
- }
- KmDim* pDim=(KmDim*)obj;
- if(!pDim->GetDSAMgr()->SetDsID(id,id))
- {
- return FALSE;
- }//注意id已经变化
- //转换样式替代
- if(adenhd->xdblob!=AD_VMNULL)
- {
- KmDimStlAcsMgr* pDimStlAccMgr=pDim->GetDSAMgr();
- {
- //BOOL ChangeWorkMode(DSAWorkMode nNewMode, DSAWorkMode &nOldMode);
- DSAWorkMode old;
- pDimStlAccMgr->ChangeWorkMode(DSA_WM_USER,old);
- /*{
- 尺寸样式代码的意思请参见资料DXF Reference Guide的第四十页
- }*/
- //样式替代格式
- //1002 {
- /* 1070 编码
- / ___________具体的样式替代*/
-
- /* 1070 编码
- / ___________具体的样式替代*/
- //1002 }
- BOOL bControlStart=FALSE;
- BOOL bControlCode=FALSE;
- int dControlCode=0;
- PAD_BLOB_CTRL bcptr;
- bcptr=adStartBlobRead(adenhd->xdblob);
- while(adReadExtendeddata(bcptr,adxd))
- {
- if(adxd->xddxfnumber==1000) //adxd->xddata.xdstring;
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if(adxd->xddxfnumber==1001) //adxd->xddata.xdappobjhandle
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if(adxd->xddxfnumber==1003) //adxd->xddata.xdentlayerobjhandle
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1005) //adxd->xddata.xdhandle
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1010) //adxd->xddata.xd3dpt[0],adxd->xddata.xd3dpt[1],adxd->xddata.xd3dpt[2]
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1040) //adxd->xddata.xdreal
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1070) //adxd->xddata.xdint
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- dControlCode=adxd->xddata.xdint;
- bControlCode=TRUE;
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1071) //adxd->xddata.xdlong;
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1002) //adxd->xddata.xdcontrol 123 '{' 125 '}'
- {
- if(adxd->xddata.xdcontrol=='{')
- {
- if(bControlStart==TRUE)
- {
- TRACE("错误的blob数据");
- }
- else
- {
- bControlStart=TRUE;
- }
- }
- else if(adxd->xddata.xdcontrol=='}')
- {
- if(bControlStart==TRUE)
- {
- bControlStart=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- }
- else if (adxd->xddxfnumber==1004) //for (i=0; i<adxd->xdbindatalength; i++)/* binary data */exampleprintf("%.02X",((unsigned)adxd->xddata.xdbindata[i]) & 255);exampleprintf("n");
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1011) //adxd->xddata.xdworldpos
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1012) //adxd->xddata.xdworlddisp
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1013) //adxd->xddata.xdworlddir
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1041) //adxd->xddata.xddist
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- else if (adxd->xddxfnumber==1042) //adxd->xddata.xdscale
- {
- if(bControlStart==TRUE)
- {
- if(bControlCode)
- {
- processentity_dim_blob(dwghandle,pDimStlAccMgr,dControlCode,adxd->xddxfnumber);bControlCode=FALSE;
- }
- else
- {
- TRACE("错误的blob数据");
- }
- }
- //else 忽略
- }
- }
- adEndBlobRead(bcptr);
- }
- }
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_tail(AD_DB_HANDLE dwghandle,KmObject* obj)
- {
- if(!obj->IsKindOf(RUNTIME_CLASS(KmDim)))
- {
- return FALSE;
- }
- UINT id;
- if(!m_adimstyle.Get(id,aden->dim.dimstyleobjhandle))
- {
- return FALSE;
- }
- CKmDataManager* pDataMgr=::GetActiveDataManager();
- if(!pDataMgr)
- {
- return FALSE;
- }
- CDimStyle* pDimStyle=pDataMgr->GetDimStyle(id);
- if(!pDimStyle)
- {
- return FALSE;
- }
- KmDim* pDim=(KmDim*)obj;
- CString str=aden->dim.dimtext;
- if(!str.IsEmpty())
- {
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- var=pDimStyle->GetDimStlVar(DIMTXSTY);
- CShape* pShape=m_ashape.Get((UINT)var.intVal);
- if(!pShape)
- {
- return FALSE;
- }
- double hight;
- if(!pDim->GetDSAMgr()->GetDsVar(DIMTXT,var))
- {//文字高度
- return FALSE;
- }
- hight=var.dblVal;
- //pDim->SetDimValType(VT_USER);
- KmText* pText;//"<>"表示尺寸的数值的问题由KmCAD解决
- pText=m_pConverter->ConverterEntiey_KmText(FALSE,aden->dim.dimtextmidpt[0],aden->dim.dimtextmidpt[1],aden->dim.dimtextmidpt[2],hight,aden->dim.dimtextrot*180/PI,pShape->m_dShapeWidth,1.0,pShape,str);
- if(pText==NULL)return FALSE;
- pDim->SetMultiKmText(pText);
- delete pText;
- }
- //AD_DIMTYPE_XORDDIM (this ordinate dimension is in the X direction)
- //AD_DIMTYPE_TEXTPOS (indicates the dim text is at a user-defined location).
- if(aden->dim.dimflag&AD_DIMTYPE_TEXTPOS)
- {
- pDim->SetDimTextPos(KmPoint(aden->dim.dimtextmidpt[0],aden->dim.dimtextmidpt[1]));
- pDim->SetTxtPosType(VT_USER);
- }
- if( fabs(aden->dim.dimtextrot)>0.0001 )//非零
- {
- pDim->SetTxtAngType(VT_USER);
- pDim->SetTxtAngOfUser(aden->dim.dimtextrot*180/PI);
- }
- //将组成尺寸的实体附加到尺寸上.
- double lscale;
- if(m_ablock.Get(id,aden->dim.blockheaderobjhandle))
- {
- KmBlockDef* pBlockDef=pDataMgr->GetBlockDef(id);
- if(!pBlockDef)return FALSE;
- KmObject* pObject=NULL;
- for(UINT index=0;index<pBlockDef->GetObjectNum();index++)
- {
- pBlockDef->GetObjectAt(index,pObject);
- if(!pObject)continue;
- KmObject* pCopy=(KmObject*)pObject->GetRuntimeClass()->CreateObject();
- pCopy->Copy(pObject);
- if(aden->dim.dimcloneinfopresent)
- {
- pCopy->Move(KmPoint(aden->dim.dimcloneinspt[0],aden->dim.dimcloneinspt[1]));
- }
- if(pDim->Add(pCopy)==NULL)
- {
- delete pCopy;
- }
- }
- pDim->EndAdd();
- }
- else
- {
- pDim->Refresh();
- }
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_blockref(AD_DB_HANDLE dwghandle)
- {
- UINT id;
- double lscale;
- m_ablock.Get(aden->dim.blockheaderobjhandle,id,lscale);
- int index=m_pConverter->ConverterEntiey_KmBlockref(aden->dim.dimcloneinspt[0],aden->dim.dimcloneinspt[1],aden->dim.dimcloneinspt[2],1,1,1,0,id,FALSE).dwEntIndex;
- _WRITE2(str.Format("尺寸%x%x%x%x%x%x%x%x转换为第%d号块引用",adenhd->enthandle[0],adenhd->enthandle[1],adenhd->enthandle[2],adenhd->enthandle[3],adenhd->enthandle[4],adenhd->enthandle[5],adenhd->enthandle[6],adenhd->enthandle[7],index));
- return TRUE;
- }
- void CDwgReader::processentity_dim_blob(AD_DB_HANDLE dwghandle,KmDimStlAcsMgr* &pDimStlAccMgr,int code,short datatype)
- {
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- CString strTemp;
- strTemp.Format("%dt%dn",code,datatype);
- TRACE(strTemp);
- strTemp.Empty();
- switch(code)
- {
- case 3://DIMPOST
- if(datatype!=1000)
- {
- TRACE("错误的数据");
- break;
- }
- strTemp=adxd->xddata.xdstring;
- {
- VARIANT varTmp;
- memset(&varTmp,0,sizeof(VARIANT));
- CComBSTR bstrTmp = strTemp;
- varTmp.vt = VT_BSTR;
- varTmp.bstrVal = bstrTmp.Copy();
- pDimStlAccMgr->SetDsVar(DIMPOST,varTmp);
- }
- break;
- case 4://DIMAPOST
- if(datatype!=1000)
- {
- TRACE("错误的数据");
- break;
- }
- strTemp=adxd->xddata.xdstring;
- {
- VARIANT varTmp;
- memset(&varTmp,0,sizeof(VARIANT));
- CComBSTR bstrTmp = strTemp;
- varTmp.vt = VT_BSTR;
- varTmp.bstrVal = bstrTmp.Copy();
- pDimStlAccMgr->SetDsVar(DIMAPOST,varTmp);
- }
- break;
- case 5://DIMBLK
- if(datatype!=1000)
- {
- TRACE("错误的数据");
- break;
- }
- strTemp=adxd->xddata.xdstring;
- //wait....
- break;
- case 6://DIMBLK1
- if(datatype!=1000)
- {
- TRACE("错误的数据");
- break;
- }
- strTemp=adxd->xddata.xdstring;
- //wait....
- break;
- case 7://DIMBLK2
- if(datatype!=1000)
- {
- TRACE("错误的数据");
- break;
- }
- strTemp=adxd->xddata.xdstring;
- //wait....
- break;
- case 40://DIMSCALE
- if(datatype!=1040)//adxd->xddata.xdreal
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMSCALE,var);
- break;
- case 41://DIMASZ
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMASZ,var);
- break;
- case 42://DIMEXO
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMEXO,var);
- break;
- case 43://DIMDLI
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMDLI,var);
- break;
- case 44://DIMEXE
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMEXE,var);
- break;
- case 45://DIMRND
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMRND,var);
- break;
- case 46://DIMDLE
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMDLE,var);
- break;
- case 47://DIMTP
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTP,var);
- break;
- case 48://DIMTM
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTM,var);
- break;
- case 140://DIMTXT
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTXT,var);
- break;
- case 141://DIMCEN
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMCEN,var);
- break;
- case 142://DIMTSZ
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTSZ,var);
- break;
- case 143://DIMALTF
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMALTF,var);
- break;
- case 144://DIMLFAC
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMLFAC,var);
- break;
- case 145://DIMTVP
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTVP,var);
- break;
- case 146://DIMTFAC
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMTFAC,var);
- break;
- case 147://DIMGAP
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMGAP,var);
- break;
- case 148://DIMALTRND
- if(datatype!=1040)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_R8;var.dblVal=adxd->xddata.xdreal;
- pDimStlAccMgr->SetDsVar(DIMALTRND,var);
- break;
- case 71://DIMTOL
- if(datatype!=1070)//adxd->xddata.xdint
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTOL,var);
- break;
- case 72://DIMLIM
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMLIM,var);
- break;
- case 73://DIMTIH
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTIH,var);
- break;
- case 74://DIMTOH
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTOH,var);
- break;
- case 75://DIMSE1
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSE1,var);
- break;
- case 76://DIMSE2
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSE2,var);
- break;
- case 77://DIMTAD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTAD,var);
- break;
- case 78://DIMZIN
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMZIN,var);
- break;
- case 79://DIMAZIN
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMAZIN,var);
- break;
- case 170://DIMALT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALT,var);
- break;
- case 171://DIMALTD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALTD,var);
- break;
- case 172://DIMTOFL
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTOFL,var);
- break;
- case 173://DIMSAH
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSAH,var);
- break;
- case 174://DIMTIX
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTIX,var);
- break;
- case 175://DIMSOXD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSOXD,var);
- break;
- case 176://DIMCLRD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- {
- try
- {
- if(var.intVal==AD_COLOR_BYBLOCK)
- {
- var.intVal=COLOR_BYBLOCK;//随块
- }
- else if(var.intVal==AD_COLOR_BYLAYER)
- {
- var.intVal=COLOR_BYLAYER;
- }
- else
- {
- if(var.intVal>=0 && var.intVal<m_aColor.GetSize())
- {
- var.intVal=m_aColor[var.intVal];
- }
- else
- {
- TRACE("errordata");
- }
- }
- }
- catch(...)
- {
- _WRITE(str="非法的颜色码");
- }
- }
- pDimStlAccMgr->SetDsVar(DIMCLRD,var);
- break;
- case 177://DIMCLRE
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=adxd->xddata.xdint;
- {
- try
- {
- if(var.intVal==AD_COLOR_BYBLOCK)
- {
- var.intVal=COLOR_BYBLOCK;//随块
- }
- else if(var.intVal==AD_COLOR_BYLAYER)
- {
- var.intVal=COLOR_BYLAYER;
- }
- else
- {
- if(var.intVal>=0 && var.intVal<m_aColor.GetSize())
- {
- var.intVal=m_aColor[var.intVal];
- }
- else
- {
- TRACE("errordata");
- }
- }
- }
- catch(...)
- {
- _WRITE(str="非法的颜色码");
- }
- }
- pDimStlAccMgr->SetDsVar(DIMCLRE,var);
- break;
- case 178://DIMCLRT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- {
- try
- {
- if(var.intVal==AD_COLOR_BYBLOCK)
- {
- var.intVal=COLOR_BYBLOCK;//随块
- }
- else if(var.intVal==AD_COLOR_BYLAYER)
- {
- var.intVal=COLOR_BYLAYER;
- }
- else
- {
- if(var.intVal>=0 && var.intVal<m_aColor.GetSize())
- {
- var.intVal=m_aColor[var.intVal];
- }
- else
- {
- TRACE("errordata");
- }
- }
- }
- catch(...)
- {
- _WRITE(str="非法的颜色码");
- }
- }
- pDimStlAccMgr->SetDsVar(DIMCLRT,var);
- break;
- case 179://DIMADEC
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMADEC,var);
- break;
- case 270://DIMUNIT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- // var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- // pDimStlAccMgr->SetDsVar(DIMUNIT,var); DIMUNIT是一个R13变量无需理会
- break;
- case 271://DIMDEC
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMDEC,var);
- break;
- case 272://DIMTDEC
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTDEC,var);
- break;
- case 273://DIMALTU
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALTU,var);
- break;
- case 274://DIMALTTD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALTTD,var);
- break;
- case 275://DIMAUNIT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMAUNIT,var);
- break;
- case 276://DIMFRAC
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMFRAC,var);
- break;
- case 277://DIMLUNIT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMLUNIT,var);
- break;
- case 278://DIMDSEP
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_I1;var.cVal=(char)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMDSEP,var);
- break;
- case 279://DIMTMOVE
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTMOVE,var);
- break;
- case 280://DIMJUST
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMJUST,var);
- break;
- case 281://DIMSD1
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSD1,var);
- break;
- case 282://DIMSD2
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMSD2,var);
- break;
- case 283://DIMTOLJ
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTOLJ,var);
- break;
- case 284://DIMTZIN
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMTZIN,var);
- break;
- case 285://DIMALTZ
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALTZ,var);
- break;
- case 286://DIMALTTZ
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMALTTZ,var);
- break;
- case 287://DIMFIT
- //已失效,但为了保持 AutoCAD 2000 以前版本的脚本和 AutoLISP 例程的完整性,仍然保留了它。在 AutoCAD 2000 中它已被 DIMATFIT 和 DIMTMOVE 所替代。
- /* if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMATFIT,var);*/
- break;
- case 288://DIMUPT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_BOOL;var.boolVal=(VARIANT_BOOL)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMUPT,var);
- break;
- case 289://DIMATFIT
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- pDimStlAccMgr->SetDsVar(DIMATFIT,var);
- break;
- case 340://DIMTXSTY
- if(datatype!=1005)
- {
- TRACE("错误的数据");
- break;
- }
- {
-
- AD_OBJHANDLE handle2;
- adHancpy(handle2,adxd->xddata.xdhandle);
- CMatch5* match;
- if(m_ashape.Get(handle2,match))
- {
- var.vt=VT_INT;var.intVal=(int)match->m_shape->m_KmWordStyleID;
- pDimStlAccMgr->SetDsVar(DIMTXSTY,var);
- }
- }
- break;
- case 341://DIMLDRBLK
- if(datatype!=1005)
- {
- TRACE("错误的数据");
- break;
- }
- //wait..
- break;
- case 342://DIMBLK
- if(datatype!=1005)
- {
- TRACE("错误的数据");
- break;
- }
- //wait..
- break;
- case 343://DIMBLK1
- if(datatype!=1005)
- {
- TRACE("错误的数据");
- break;
- }
- //wait..
- break;
- case 344://DIMBLK2
- if(datatype!=1005)
- {
- TRACE("错误的数据");
- break;
- }
- //wait..
- break;
- case 371://DIMLWD
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- {
- if((unsigned short)var.intVal==AD_WEIGHT_DEFAULT)
- {
- var.intVal=m_ilinewidthdefault;
- }
- else if((unsigned short)var.intVal==AD_WEIGHT_BYBLOCK)
- {
- var.intVal=LWIDTH_BYBLOCK;
- }
- else if((unsigned short)var.intVal==AD_WEIGHT_BYLAYER)
- {
- var.intVal=LWIDTH_BYLAYER;
- }
- else
- {
- var.intVal=::GetLineWidthAsInt(double(abs(var.intVal))/100.0);
- }
- }
- pDimStlAccMgr->SetDsVar(DIMLWD,var);
- break;
- case 372://DIMLWE
- if(datatype!=1070)
- {
- TRACE("错误的数据");
- break;
- }
- var.vt=VT_INT;var.intVal=(int)adxd->xddata.xdint;
- if((unsigned short)var.intVal==AD_WEIGHT_DEFAULT)
- {
- var.intVal=m_ilinewidthdefault;
- }
- else if((unsigned short)var.intVal==AD_WEIGHT_BYBLOCK)
- {
- var.intVal=LWIDTH_BYBLOCK;
- }
- else if((unsigned short)var.intVal==AD_WEIGHT_BYLAYER)
- {
- var.intVal=LWIDTH_BYLAYER;
- }
- else
- {
- var.intVal=::GetLineWidthAsInt(double(abs(var.intVal))/100.0);
- }
- pDimStlAccMgr->SetDsVar(DIMLWE,var);
- break;
- default:
- TRACE("没有处理的尺寸样式代码");
- break;
- }
- }
- BOOL CDwgReader::processentity_dim_rotated(AD_DB_HANDLE dwghandle)//0
- {
- KmSimpleDim* pSimpleDim=new KmSimpleDim;
- //the first extension line is specified by defpt2.
- //The second extension line is specified by defpt3,
- //and the dimension line is specified by dimlinedefpt.
- KmPoint p1(aden->dim.defpt2[0],aden->dim.defpt2[1]);
- KmPoint p2(aden->dim.defpt3[0],aden->dim.defpt3[1]);
- KmPoint p3(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- double ang[2];
- ang[0]=CalcPrecValue(aden->dim.dimrotang*180/PI+90, 0.001);
- ang[1]=0;
- if(!processentity_dim_head(dwghandle,pSimpleDim))
- {
- delete pSimpleDim;
- return FALSE;
- }
- pSimpleDim->GenerateDimNoTag(p3,ang,p1,p2,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pSimpleDim))
- {
- delete pSimpleDim;
- return FALSE;
- }
- m_pConverter->ConverterEntiey_KmObject(pSimpleDim);
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_aligned(AD_DB_HANDLE dwghandle)
- {
- KmSimpleDim* pSimpleDim=new KmSimpleDim;
- //the first extension line is specified by defpt2.
- //The second extension line is specified by defpt3,
- //and the dimension line is specified by dimlinedefpt.
- KmPoint p1(aden->dim.defpt2[0],aden->dim.defpt2[1]);
- KmPoint p2(aden->dim.defpt3[0],aden->dim.defpt3[1]);
- KmPoint p3(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- double ang[2];
- ang[0]=CalcPrecValue(GetVticAngKptBToKptE(p1,p2), 0.001);
- ang[1]=0;
- if(!processentity_dim_head(dwghandle,pSimpleDim))
- {
- delete pSimpleDim;
- return FALSE;
- }
- pSimpleDim->GenerateDimNoTag(p3,ang,p1,p2,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pSimpleDim))
- {
- delete pSimpleDim;
- return FALSE;
- }
- m_pConverter->ConverterEntiey_KmObject(pSimpleDim);
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_diameter(AD_DB_HANDLE dwghandle)
- {
- KmDiameterDim* pDiameterDim=new KmDiameterDim;
- //生成无目标尺寸
- //void GenerateDimNoTag(KmPoint kptCurPos, double dCurAng[], KmPoint kptTag1, KmPoint kptTag2);
- //defpt4 is the point selected on the circle or arc being dimensioned.
- //dimlinedefpt is the point on the circle exactly across from the selection point.
- //dimtextmidpt
- KmPoint p1(aden->dim.defpt4[0],aden->dim.defpt4[1]);
- KmPoint p2(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- KmPoint p3(aden->dim.dimtextmidpt[0],aden->dim.dimtextmidpt[1]);
- double ang[2];
- //ang[0]=GetVticAngKptBToKptE(p1,p2);
- ang[0]=GetAngKptBToKptE(p1,p2);
- ang[1]=0.0;
- if(!processentity_dim_head(dwghandle,pDiameterDim))
- {
- delete pDiameterDim;
- return FALSE;
- }
- {
- KmPoint p4=::OrthPt2Ln(p3,p1,p2);
- if(! ( fabs(p4.x-p3.x)<PRECISION && fabs(p4.y-p3.y)<PRECISION ) )
- {
- pDiameterDim->SetDLRelateTxt(FALSE);
- }
- }
- CString strTemp;
- {
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pDiameterDim->GetDSAMgr()->GetDsVar(DIMPOST,var);
- strTemp=var.bstrVal;
- if(( strTemp.Find("<>")==0 ) )
- {
- strTemp="%%c"+strTemp;
- }
- else if(strTemp.Find("<>")==-1)
- {
- strTemp="%%c<>"+strTemp;
- }
- }
- pDiameterDim->GenerateDimNoTag(p3,ang,p1,p2,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pDiameterDim))
- {
- delete pDiameterDim;
- return FALSE;
- }
- //如果没有前缀,自动增加%%c
- {
- VARIANT varTmp;
- memset(&varTmp,0,sizeof(VARIANT));
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pDiameterDim->GetDSAMgr()->GetDsVar(DIMPOST,var);
- CString strTemp2=var.bstrVal;
- if(strTemp2!=strTemp)
- {
- CComBSTR bstrTmp = strTemp;
- varTmp.vt = VT_BSTR;
- varTmp.bstrVal = bstrTmp.Copy();
- pDiameterDim->GetDSAMgr()->SetDsVar(DIMPOST,varTmp);
- }
- }
- m_pConverter->ConverterEntiey_KmObject(pDiameterDim);
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_ordinate(AD_DB_HANDLE dwghandle)
- {
- //坐标标注,暂不支持
- //defpt3 is the point which was selected.
- //defpt4 is the point indicating the endpoint of the leader.
- return FALSE;
- }
- BOOL CDwgReader::processentity_dim_radius(AD_DB_HANDLE dwghandle)
- {
- KmRadiusDim* pRadiusDim=new KmRadiusDim;
- //dimlinedefpt 圆心
- //defpt4 圆上点
- KmPoint p1(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- KmPoint p2(aden->dim.defpt4[0],aden->dim.defpt4[1]);
- KmPoint p3;p3.x=2*p1.x-p2.x;p3.y=2*p1.y-p2.y;
- KmPoint p4(aden->dim.dimtextmidpt[0],aden->dim.dimtextmidpt[1]);
- double ang[2];
- ang[0]=GetAngKptBToKptE(p1,p2);
- ang[1]=0;
- if(!processentity_dim_head(dwghandle,pRadiusDim))
- {
- delete pRadiusDim;
- return FALSE;
- }
- {
- KmPoint p5=::OrthPt2Ln(p4,p1,p2);
- if(!( fabs(p5.x-p4.x)<PRECISION && fabs(p5.y-p4.y)<PRECISION ) )
- {
- pRadiusDim->SetDLRelateTxt(FALSE);
- }
- }
- //如果没有前缀,自动增加R
- CString strTemp;
- {
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pRadiusDim->GetDSAMgr()->GetDsVar(DIMPOST,var);
- strTemp=var.bstrVal;
- if(( strTemp.Find("<>")==0 ) )
- {
- strTemp="R"+strTemp;
- }
- else if( strTemp.Find("<>")==-1 )
- {
- strTemp="R<>"+strTemp;
- }
- }
- pRadiusDim->GenerateDimNoTag(p4,ang,p2,p3,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pRadiusDim))
- {
- delete pRadiusDim;
- return FALSE;
- }
- {
- VARIANT varTmp;
- memset(&varTmp,0,sizeof(VARIANT));
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pRadiusDim->GetDSAMgr()->GetDsVar(DIMPOST,var);
- CString strTemp2=var.bstrVal;
- if(strTemp2!=strTemp)
- {
- CComBSTR bstrTmp = strTemp;
- varTmp.vt = VT_BSTR;
- varTmp.bstrVal = bstrTmp.Copy();
- pRadiusDim->GetDSAMgr()->SetDsVar(DIMPOST,varTmp);
- }
- }
- m_pConverter->ConverterEntiey_KmObject(pRadiusDim);
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_angular(AD_DB_HANDLE dwghandle)
- {
- KmVAngleDim* pVAngleDim=new KmVAngleDim;
- //角度标注
- //defpt2 and defpt3 are the endpoints of the first extension line.
- //dimlinedefpt and defpt4 are the endpoints of the second extension line.
- //arcdefpt specifies the dimension line arc.
- KmPoint p3(aden->dim.defpt2[0],aden->dim.defpt2[1]);
- KmPoint p4(aden->dim.defpt3[0],aden->dim.defpt3[1]);
- KmPoint p1(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- KmPoint p2(aden->dim.defpt4[0],aden->dim.defpt4[1]);
- KmPoint p5(aden->dim.arcdefpt[0],aden->dim.arcdefpt[1]);
- KmLine line1,line2;
- line1.SetBegin(p1);
- line1.SetEnd(p2);
- line2.SetBegin(p3);
- line2.SetEnd(p4);
- double sx[3];
- double sy[3];
- if(sec_i_LL(&line1,&line2,sx,sy,3)!=1)
- {
- delete pVAngleDim;
- return FALSE;
- }
- KmPoint p6(sx[0],sy[0]);
- double ang[2];
- if( ((p6.x-p1.x)*(p6.x-p1.x)+(p6.y-p1.y)*(p6.y-p1.y))>((p6.x-p2.x)*(p6.x-p2.x)+(p6.y-p2.y)*(p6.y-p2.y)))
- {
- ang[0]=GetAngKptBToKptE(p6,p1);
- }
- else
- {
- ang[0]=GetAngKptBToKptE(p6,p2);
- p1=p2;
- }
- if( ((p6.x-p3.x)*(p6.x-p3.x)+(p6.y-p3.y)*(p6.y-p3.y))>((p6.x-p4.x)*(p6.x-p4.x)+(p6.y-p4.y)*(p6.y-p4.y)))
- {
- ang[1]=GetAngKptBToKptE(p6,p3);
- }
- else
- {
- ang[1]=GetAngKptBToKptE(p6,p4);
- p3=p4;
- }
- pVAngleDim->SetVertex(p6);
- double angmid=(ang[0]+ang[1])*0.5*PI/180;
- double r=::sqrt( (p6.x-p1.x)*(p6.x-p1.x) + (p6.y-p1.y)*(p6.y-p1.y) );
- KmPoint pt;
- pt.x=p6.x+r*cos(angmid);
- pt.y=p6.y+r*sin(angmid);
- pVAngleDim->SetArcMid(pt);
- if(!processentity_dim_head(dwghandle,pVAngleDim))
- {
- delete pVAngleDim;
- return FALSE;
- }
- try
- {
- BOOL bHide1;
- BOOL bHide2;
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pVAngleDim->GetDSAMgr()->GetDsVar(DIMSD1,var);
- bHide1=var.boolVal;
- pVAngleDim->GetDSAMgr()->GetDsVar(DIMSD2,var);
- bHide2=var.boolVal;
- if( (bHide1&&(!bHide2)) || (bHide2&&(!bHide1)) )
- {//依据从起点 -> 控制点 -> 终点 逆时针旋转的原则处理
- double dAngle=GetAngKptBToKptE(p6,p5);
- if(Begin_Angle_End(dAngle,ang[0],ang[1],MESSAGE_CIRCLE_POSITIVE)=='n')
- {
- bHide1=!bHide1;
- bHide2=!bHide2;
- var.boolVal=bHide1;
- pVAngleDim->GetDSAMgr()->SetDsVar(DIMSD1,var);
- var.boolVal=bHide2;
- pVAngleDim->GetDSAMgr()->SetDsVar(DIMSD2,var);
- }
- }
- }
- catch(...)
- {
- } pVAngleDim->GenerateDimNoTag(p5,ang,p1,p3,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pVAngleDim))
- {
- delete pVAngleDim;
- return FALSE;
- }
- m_pConverter->ConverterEntiey_KmObject(pVAngleDim);
- return TRUE;
- }
- BOOL CDwgReader::processentity_dim_angular3pt(AD_DB_HANDLE dwghandle)
- {
- KmVAngleDim* pVAngleDim=new KmVAngleDim;
- //角度标注
- //defpt4 is the vertex of the angle.
- //defpt2 is the endpoint of the first extension line.
- //defpt3 is the endpoint of the second extension line.
- //dimlinedefpt specifies the arc for the dimension line.
- KmPoint p1(aden->dim.defpt4[0],aden->dim.defpt4[1]);
- KmPoint p3(aden->dim.defpt2[0],aden->dim.defpt2[1]);
- KmPoint p2(aden->dim.defpt3[0],aden->dim.defpt3[1]);
- KmPoint p4(aden->dim.dimlinedefpt[0],aden->dim.dimlinedefpt[1]);
- double ang[2];
- ang[0]=GetAngKptBToKptE(p1,p2);
- ang[1]=GetAngKptBToKptE(p1,p3);
- pVAngleDim->SetVertex(p1);
- double angmid=(ang[0]+ang[1])*0.5*PI/180;
- double r=::sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) );
- KmPoint pt;
- pt.x=p1.x+r*cos(angmid);
- pt.y=p1.y+r*sin(angmid);
- pVAngleDim->SetArcMid(pt);
- if(!processentity_dim_head(dwghandle,pVAngleDim))
- {
- delete pVAngleDim;
- return FALSE;
- }
- try
- {
- BOOL bHide1;
- BOOL bHide2;
- VARIANT var;
- memset(&var,0,sizeof(VARIANT));
- pVAngleDim->GetDSAMgr()->GetDsVar(DIMSD1,var);
- bHide1=var.boolVal;
- pVAngleDim->GetDSAMgr()->GetDsVar(DIMSD2,var);
- bHide2=var.boolVal;
- if( (bHide1&&(!bHide2)) || (bHide2&&(!bHide1)) )
- {//依据从起点 -> 控制点 -> 终点 逆时针旋转的原则处理
- double dAngle=GetAngKptBToKptE(p1,p4);
- if(Begin_Angle_End(dAngle,ang[0],ang[1],MESSAGE_CIRCLE_POSITIVE)=='n')
- {
- bHide1=!bHide1;
- bHide2=!bHide2;
- var.boolVal=bHide1;
- pVAngleDim->GetDSAMgr()->SetDsVar(DIMSD1,var);
- var.boolVal=bHide2;
- pVAngleDim->GetDSAMgr()->SetDsVar(DIMSD2,var);
- }
- }
- }
- catch(...)
- {
- }
- pVAngleDim->GenerateDimNoTag(p4,ang,p2,p3,FALSE,FALSE);
- if(!processentity_dim_tail(dwghandle,pVAngleDim))
- {
- delete pVAngleDim;
- return FALSE;
- }
- m_pConverter->ConverterEntiey_KmObject(pVAngleDim);
- return TRUE;
- }