1239 lines
31 KiB
C++
1239 lines
31 KiB
C++
#include "stdafx.h"
|
|
#include "actrans.h"
|
|
#include "gs.h"
|
|
#include "acgs.h"
|
|
#include "TchKernalGlobalFunc.h"
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
DList<AcDbObjectId> TDbCamera::g_updIdArray;
|
|
BOOL g_bMakingVideo=FALSE;
|
|
const Adesk::UInt8 TDbCamera::g_nVersion = 1;
|
|
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSCamera, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_CAMERA, "ATS_CAMERA图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
IMPLEMENT_TENTBASE(TDbCamera);
|
|
|
|
TDbCamera::TDbCamera()
|
|
{
|
|
m_nLens=26;
|
|
m_nFrontDist=0;
|
|
m_nBackDist=0;
|
|
m_nVport=0;
|
|
m_nCameraFlag=0;
|
|
}
|
|
|
|
|
|
TDbCamera::~TDbCamera()
|
|
{
|
|
}
|
|
|
|
BOOL TDbCamera::IsValid() const
|
|
{
|
|
BOOL bRet=TDbEntity::IsValid();
|
|
if(!bRet)
|
|
return bRet;
|
|
|
|
bRet=(!!m_idBlock && m_nLens>0 &&
|
|
m_ptCamera.Distance(m_ptTarget)>_DIST_SNAP
|
|
//&& m_nFrontDist > -_DIST_SNAP;
|
|
);
|
|
return bRet;
|
|
}
|
|
|
|
// 提供对格式刷的支持
|
|
void TDbCamera::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|
TDbCamera *pSrc=TDbCamera::cast(pSrcEntity);
|
|
if(pSrc) {
|
|
m_nLens=pSrc->m_nLens;
|
|
m_nFrontDist=pSrc->m_nFrontDist;
|
|
m_nBackDist=pSrc->m_nBackDist;
|
|
m_nCameraFlag=pSrc->m_nCameraFlag;
|
|
|
|
if(database()==NULL||
|
|
pSrcEntity->database()==NULL||
|
|
database()==pSrcEntity->database())//add by whl on 060317
|
|
{
|
|
m_idBlock=pSrc->m_idBlock;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
TDbCamera::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
|
|
}
|
|
|
|
// 从DWG读入数据:
|
|
Acad::ErrorStatus TDbCamera::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
if(nVer>g_nVersion) {// Version is too new
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
|
|
pFiler->readItem(&m_idBlock);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptCamera);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptTarget);
|
|
pFiler->readItem(&m_nCameraFlag);
|
|
pFiler->readItem(&m_nLens);
|
|
pFiler->readItem(&m_nFrontDist);
|
|
pFiler->readItem(&m_nBackDist);
|
|
pFiler->readItem(&m_nVport);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbCamera::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem(m_idBlock);
|
|
pFiler->writeItem((AcGePoint3d &)m_ptCamera);
|
|
pFiler->writeItem((AcGePoint3d &)m_ptTarget);
|
|
pFiler->writeItem(m_nCameraFlag);
|
|
pFiler->writeItem(m_nLens);
|
|
pFiler->writeItem(m_nFrontDist);
|
|
pFiler->writeItem(m_nBackDist);
|
|
pFiler->writeItem(m_nVport);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbCamera::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler);
|
|
if(es!=Acad::eOk)
|
|
return es;
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbCamera"))) {
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
int fieldsFlags=0;
|
|
resbuf rb;
|
|
XString sName;
|
|
double r1, r2, r3;
|
|
int n1, n2;
|
|
XPoint pt1, pt2;
|
|
while ((es == Acad::eOk)
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
|
switch (rb.restype) {
|
|
case AcDb::kDxfBlockName:
|
|
sName=rb.resval.rstring;
|
|
fieldsFlags |= 0x01;
|
|
break;
|
|
case AcDb::kDxfXCoord:
|
|
pt1=rb.resval.rpoint;
|
|
fieldsFlags |= 0x02;
|
|
break;
|
|
case AcDb::kDxfXCoord+1:
|
|
pt2=rb.resval.rpoint;
|
|
fieldsFlags |= 0x04;
|
|
break;
|
|
case AcDb::kDxfReal:
|
|
r1=rb.resval.rreal;
|
|
fieldsFlags |= 0x08;
|
|
break;
|
|
case AcDb::kDxfReal+1:
|
|
r2 = rb.resval.rreal;
|
|
fieldsFlags |= 0x10;
|
|
break;
|
|
case AcDb::kDxfReal+2:
|
|
r3 = rb.resval.rreal;
|
|
fieldsFlags |= 0x20;
|
|
break;
|
|
case AcDb::kDxfViewportNumber:
|
|
n1 = rb.resval.rint;
|
|
fieldsFlags |= 0x40;
|
|
break;
|
|
case AcDb::kDxfInt16:
|
|
n2 = rb.resval.rint;
|
|
fieldsFlags |= 0x8;
|
|
break;
|
|
//fall through intentional
|
|
default:
|
|
// An unrecognized group. Push it back so that
|
|
// the subclass can read it again.
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// At this point the es variable must contain eEndOfFile
|
|
// - either from readResBuf() or from pushback. If not,
|
|
// it indicates that an error happened and we should
|
|
// return immediately.
|
|
//
|
|
if (es != Acad::eEndOfFile)
|
|
return Acad::eInvalidResBuf;
|
|
|
|
if (!(fieldsFlags&0x02)) {
|
|
pFiler->setError(Acad::eMissingDxfField,
|
|
_T("\nMissing DXF group code: 10"));
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
if (!(fieldsFlags&0x04)) {
|
|
pFiler->setError(Acad::eMissingDxfField,
|
|
_T("\nMissing DXF group code: 11"));
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
AcDbObjectId id;
|
|
if(fieldsFlags&0x01)
|
|
id=::InitBlock(sName);
|
|
if(!id) {
|
|
id=::InitBlock(_T("_CAMERA"));
|
|
}
|
|
if(!id) {
|
|
pFiler->setError(Acad::eMissingDxfField,
|
|
_T("\nMissing DXF group code: 2"));
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
SetBlock(id);
|
|
m_ptCamera=pt1;
|
|
m_ptTarget=pt2;
|
|
|
|
if(fieldsFlags&0x08)
|
|
m_nLens=r1;
|
|
if(fieldsFlags&0x10)
|
|
m_nFrontDist=r2;
|
|
if(fieldsFlags&0x20)
|
|
m_nBackDist=r2;
|
|
if(fieldsFlags&0x40)
|
|
m_nVport=n1;
|
|
if(fieldsFlags&0x80)
|
|
m_nCameraFlag=n2;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbCamera::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es=TDbEntity::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbCamera"));
|
|
assert(es == Acad::eOk);
|
|
XString sName=GetSymbolName(m_idBlock);
|
|
pFiler->writeString(AcDb::kDxfBlockName, sName);
|
|
pFiler->writePoint3d(AcDb::kDxfXCoord, m_ptCamera);
|
|
pFiler->writePoint3d(AcDb::kDxfXCoord+1, m_ptTarget);
|
|
pFiler->writeDouble(AcDb::kDxfViewLensLength, m_nLens);
|
|
pFiler->writeDouble(AcDb::kDxfViewFrontClip, m_nFrontDist);
|
|
pFiler->writeDouble(AcDb::kDxfViewBackClip, m_nBackDist);
|
|
pFiler->writeInt16(AcDb::kDxfViewportNumber, m_nVport);
|
|
pFiler->writeInt16(AcDb::kDxfInt16, m_nCameraFlag);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
|
|
|
|
Adesk::Boolean TDbCamera::subWorldDraw(AcGiWorldDraw *pWd)
|
|
{
|
|
extern GEOAPI double g_nAcadVer;
|
|
if(g_bMakingVideo)
|
|
return Adesk::kFalse;
|
|
if(TchGeLib::g_nAcadVer<15.0499 || TchGeLib::g_nAcadVer>15.0599) {
|
|
// 避免2000i崩溃 modify on 2002/1/30
|
|
if(pWd->regenType()==kAcGiHideOrShadeCommand ||
|
|
pWd->regenType()==kAcGiRenderCommand)
|
|
return Adesk::kTrue;
|
|
}
|
|
return TDbEntity::subWorldDraw(pWd);
|
|
}
|
|
|
|
void TDbCamera::subViewportDraw(AcGiViewportDraw* pMode)
|
|
{
|
|
if(!g_bMakingVideo) {
|
|
TDbEntity::subViewportDraw(pMode);
|
|
return;
|
|
}
|
|
// 只允许顶视图显示
|
|
AcGiViewport &vp=pMode->viewport();
|
|
AcGePoint3d ptCamera, ptTarget;
|
|
vp.getCameraTarget(ptTarget);
|
|
vp.getCameraLocation(ptCamera);
|
|
AcGeVector3d vtViewDrt=ptCamera-ptTarget;
|
|
|
|
vtViewDrt.normalize();
|
|
if(vtViewDrt==AcGeVector3d(0,0,1)) {
|
|
XAcGiViewDraw dc(NULL, pMode);
|
|
pMode->subEntityTraits().setSelectionMarker(0);
|
|
ExplodeOrDraw2d(dc);
|
|
}
|
|
}
|
|
|
|
|
|
Adesk::UInt32 TDbCamera::subViewportDrawLogicalFlags(AcGiViewportDraw * vd)
|
|
{
|
|
Adesk::UInt32 nRet;
|
|
if(g_bMakingVideo)
|
|
nRet=AcDbEntity::subViewportDrawLogicalFlags(vd);
|
|
else
|
|
nRet = TDbEntity::subViewportDrawLogicalFlags(vd);
|
|
return nRet;
|
|
}
|
|
|
|
Adesk::UInt32 TDbCamera::subSetAttributes(AcGiDrawableTraits * traits)
|
|
{
|
|
Adesk::UInt32 nRet;
|
|
if(g_bMakingVideo)
|
|
nRet=AcDbEntity::subSetAttributes(traits);
|
|
else
|
|
nRet = TDbEntity::subSetAttributes(traits);
|
|
return nRet;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------
|
|
// Overriden functions for edit
|
|
// to do:
|
|
// 允许通过夹点改变边界
|
|
Acad::ErrorStatus TDbCamera::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
gripPoints.append(m_ptCamera);
|
|
gripPoints.append(m_ptTarget);
|
|
if(IsFrontClipOn() && !IsFrontClipAtEye()) {
|
|
XPoint ptFrontClip=GetFrontClipPoint();
|
|
gripPoints.append(ptFrontClip);
|
|
}
|
|
if(IsBackClipOn()) {
|
|
XPoint ptBackClip=GetBackClipPoint();
|
|
gripPoints.append(ptBackClip);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// stretch points is diffrent from grep points, with no midpoint included
|
|
Acad::ErrorStatus TDbCamera::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
stretchPoints.append(m_ptCamera);
|
|
stretchPoints.append(m_ptTarget);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
|
|
// Active when being rotated, scaled, moved, etc.
|
|
Acad::ErrorStatus TDbCamera::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::subTransformBy(xform);
|
|
((AcGePoint3d &)m_ptCamera).transformBy(xform);
|
|
((AcGePoint3d &)m_ptTarget).transformBy(xform);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus TDbCamera::subMoveGripPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
XVector3D vtNormal=Ucs2Wcs(XVector3D(0,0,1), TRUE);
|
|
AcGeVector3d vtNewOffset=offset.project(vtNormal.AsAcGeVector3d(),
|
|
AcGeVector3d(-vtNormal.x, -vtNormal.y, -vtNormal.z));
|
|
XPoint vtOffset=*(XPoint *)&vtNewOffset;
|
|
for (int i = 0; i < indices.length(); i++) {
|
|
int idx = indices[i];
|
|
switch(idx) {
|
|
case 0:
|
|
m_ptCamera += vtOffset;
|
|
if(GetCtrlToggle() && !IsLocator())
|
|
m_ptTarget += vtOffset;
|
|
break;
|
|
case 1:
|
|
m_ptTarget += vtOffset;
|
|
if(IsLocator())
|
|
m_ptCamera += vtOffset;
|
|
break;
|
|
case 2:
|
|
if(IsFrontClipOn() && !IsFrontClipAtEye()) {
|
|
XPoint ptFrontClip=GetFrontClipPoint();
|
|
ptFrontClip += vtOffset;
|
|
SetFrontClipPoint(ptFrontClip);
|
|
} else if(IsBackClipOn()) {
|
|
XPoint ptBackClip=GetBackClipPoint();
|
|
ptBackClip += vtOffset;
|
|
SetBackClipPoint(ptBackClip);
|
|
}
|
|
break;
|
|
case 3:
|
|
if(IsFrontClipOn() && !IsFrontClipAtEye() && IsBackClipOn()) {
|
|
XPoint ptBackClip=GetBackClipPoint();
|
|
ptBackClip += vtOffset;
|
|
SetBackClipPoint(ptBackClip);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
return es;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus TDbCamera::subMoveStretchPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
int nCount=indices.length();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
if(nCount>1) {
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(offset);
|
|
es=subTransformBy(mat);
|
|
} else
|
|
es = subMoveGripPointsAt(indices, offset);
|
|
return es;
|
|
}
|
|
|
|
// 取得夹点说明
|
|
Acad::ErrorStatus TDbCamera::GetGripText(int i, CString &cs) const
|
|
{
|
|
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
switch(i) {
|
|
case 0:
|
|
if(IsLocator())
|
|
cs=_T("移动视点");
|
|
else
|
|
cs=GetCtrlToggle()? _T("平移相机(Ctrl-移动视点)") : _T("移动视点(Ctrl-平移相机)");
|
|
break;
|
|
case 1:
|
|
cs=IsLocator()? _T("移动") : _T("移动目标");
|
|
break;
|
|
case 2:
|
|
if(IsFrontClipOn() && !IsFrontClipAtEye()) {
|
|
cs=_T("移动前裁剪面");
|
|
} else if(IsBackClipOn()) {
|
|
cs=_T("移动后裁剪面");
|
|
}
|
|
break;
|
|
case 3:
|
|
if(IsFrontClipOn() && !IsFrontClipAtEye() && IsBackClipOn()) {
|
|
cs=_T("移动后裁剪面");
|
|
}
|
|
break;
|
|
}
|
|
return es;
|
|
}
|
|
|
|
|
|
|
|
Acad::ErrorStatus TDbCamera::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
if(IsLocator()) {
|
|
TPushProperty vProp(this, dc);
|
|
XPoint ptC=m_ptTarget;
|
|
ptC.z=0;
|
|
XPoint ptL, ptR, ptF;
|
|
double nLong=GetLongitude();
|
|
ads_polar(ptC, nLong+PI/2, 500.0, ptL);
|
|
ads_polar(ptC, nLong-PI/2, 500.0, ptR);
|
|
ads_polar(ptC, nLong, 500.0, ptF);
|
|
dc << XLine(ptL, ptR) << XLine(ptR, ptF) << XLine(ptF, ptL);
|
|
dc << XCircle(ptC, 300.0);
|
|
return Acad::eOk;
|
|
}
|
|
return ExplodeOrDraw3d(dc);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbCamera::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
|
{
|
|
// extern double g_nAcadVer;
|
|
if(IsValid() && !IsLocator()) {
|
|
if(!!m_idBlock) {
|
|
TPushProperty vProp(this, dc);
|
|
|
|
//XAcGiViewDraw dc(pWd, NULL);
|
|
dc << XLine(m_ptCamera, m_ptTarget);
|
|
AcGeMatrix3d matRotY, matRotZ, matMove;
|
|
matRotY.setToRotation(-GetLatitude(), AcGeVector3d(0,1,0));
|
|
matRotZ.setToRotation(GetLongitude(), AcGeVector3d(0,0,1));
|
|
matMove.setToTranslation(m_ptCamera);
|
|
matMove.postMultBy(matRotZ);
|
|
matMove.postMultBy(matRotY);
|
|
//if(strcmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0) {
|
|
// AcGiCommonDraw *pDraw=((XAcGiViewDraw &)dc).GetCommonDraw();
|
|
//
|
|
//}
|
|
AcDbBlockReference blkInsert(AcGePoint3d(0,0,0), m_idBlock);
|
|
blkInsert.transformBy(matMove);
|
|
blkInsert.setPropertiesFrom(this);
|
|
dc.DrawEntity(blkInsert);
|
|
//blkInsert.worldDraw(pWd);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
#if 0
|
|
Acad::ErrorStatus
|
|
TDbCamera::explode(AcDbVoidPtrArray &entSet) const
|
|
{
|
|
return Acad::eOk;
|
|
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es=Acad::eInvalidInput;
|
|
if(!!m_idBlock) {
|
|
AcDbBlockReference blkInsert(AcGePoint3d(0,0,0), m_idBlock);
|
|
AcGeMatrix3d matRotY, matRotZ, matMove;
|
|
matRotY.setToRotation(GetLatitude(), AcGeVector3d(0,1,0));
|
|
matRotZ.setToRotation(GetLongitude(), AcGeVector3d(0,0,1));
|
|
matMove.setToTranslation(m_ptCamera);
|
|
matMove.postMultBy(matRotZ);
|
|
matMove.postMultBy(matRotY);
|
|
blkInsert.transformBy(matMove);
|
|
AcDbEntity *pEnt=(AcDbEntity *)blkInsert.clone();
|
|
ASSERT(pEnt);
|
|
entSet.append(pEnt);
|
|
es=Acad::eOk;
|
|
}
|
|
return es;
|
|
|
|
}
|
|
#endif
|
|
|
|
|
|
const TCHAR *TDbCamera::GetDefaultLayer() const
|
|
{
|
|
return LAY_VIEW;
|
|
}
|
|
|
|
|
|
|
|
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
|
void TDbCamera::GetTips(DList<TObjInfoUnit> &lstInfo) const
|
|
{
|
|
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("相机")));
|
|
lstInfo.Append(new TObjInfoUnit(_T("视点"), Point3d2Str(m_ptCamera)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("目标"), Point3d2Str(m_ptTarget)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("焦距"), Dist2Str(m_nLens)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("方位角"), Dist2Str(GetLongitude())));
|
|
lstInfo.Append(new TObjInfoUnit(_T("俯仰角"), Dist2Str(GetLatitude())));
|
|
XString sFrontClip(256);
|
|
if(IsFrontClipOn()) {
|
|
if(IsFrontClipAtEye()) sFrontClip=_T("在相机位置");
|
|
else sFrontClip=Dist2Str(m_nFrontDist);
|
|
} else sFrontClip=_T("关闭");
|
|
lstInfo.Append(new TObjInfoUnit(_T("前裁剪"), (const TCHAR *)sFrontClip));
|
|
lstInfo.Append(new TObjInfoUnit(_T("后裁剪"), IsBackClipOn()? (const TCHAR *)Dist2Str(m_nBackDist) : _T("关闭")));
|
|
lstInfo.Append(new TObjInfoUnit(_T("状态"), IsActive()? _T("联动") : _T("不联动")));
|
|
}
|
|
|
|
/*
|
|
XPoint TDbCamera::GetLocatorC() const
|
|
{
|
|
XPoint pt=m_ptTarget;
|
|
pt.z=0;
|
|
return pt;
|
|
}
|
|
|
|
XPoint TDbCamera::GetLocatorL() const
|
|
{
|
|
double nLong=GetLongtitude();
|
|
XPoint ptC=GetLocatorC();
|
|
XPoint pt;
|
|
ads_polar(ptC, nLong+PI/2, 500, pt);
|
|
return pt;
|
|
}
|
|
|
|
XPoint TDbCamera::GetLocatorR() const
|
|
{
|
|
double nLong=GetLongtitude();
|
|
XPoint ptC=GetLocatorC();
|
|
XPoint pt;
|
|
ads_polar(ptC, nLong-PI/2, 500, pt);
|
|
return pt;
|
|
}
|
|
|
|
XPoint TDbCamera::GetLocatorF() const
|
|
{
|
|
double nLong=GetLongtitude();
|
|
XPoint ptC=GetLocatorC();
|
|
XPoint pt;
|
|
ads_polar(ptC, nLong-PI/2, 500, pt);
|
|
return pt;
|
|
}
|
|
|
|
XPoint TDbCamera::GetLocatorB() const
|
|
{
|
|
XPoint pt=m_ptCamera;
|
|
pt.z=0;
|
|
return pt;
|
|
}
|
|
*/
|
|
|
|
|
|
XPoint
|
|
TDbCamera::GetFrontClipPoint() const
|
|
{
|
|
return GetClipPoint(m_nFrontDist);
|
|
}
|
|
|
|
XPoint
|
|
TDbCamera::GetBackClipPoint() const
|
|
{
|
|
return GetClipPoint(m_nBackDist);
|
|
}
|
|
|
|
// nDist>0 在ptTarget->ptCamera方向
|
|
// nDist<0 在ptCamera->ptTarget方向
|
|
XPoint
|
|
TDbCamera::GetClipPoint(double nDist) const
|
|
{
|
|
assertReadEnabled();
|
|
XVector3D vt=m_ptCamera-m_ptTarget;
|
|
((AcGeVector3d &)vt).normalize();
|
|
XVector3D vtBackClip=vt;
|
|
vtBackClip.Scale(nDist);
|
|
XPoint ptBackClip=m_ptTarget + vtBackClip;
|
|
return ptBackClip;
|
|
}
|
|
|
|
|
|
double
|
|
TDbCamera::GetBackClipDist() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nBackDist;
|
|
}
|
|
|
|
double
|
|
TDbCamera::GetFrontClipDist() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nFrontDist;
|
|
}
|
|
|
|
|
|
BOOL
|
|
TDbCamera::IsFrontClipAtEye() const
|
|
{
|
|
assertReadEnabled();
|
|
return ((m_nCameraFlag&CAF_FRONTCLIP_ATEYE)!=0);
|
|
}
|
|
|
|
BOOL
|
|
TDbCamera::IsBackClipOn() const
|
|
{
|
|
assertReadEnabled();
|
|
return ((m_nCameraFlag&CAF_BACKON)!=0);
|
|
}
|
|
|
|
BOOL
|
|
TDbCamera::IsFrontClipOn() const
|
|
{
|
|
assertReadEnabled();
|
|
return ((m_nCameraFlag&CAF_FRONTON)!=0);
|
|
}
|
|
|
|
BOOL TDbCamera::IsActive() const
|
|
{
|
|
assertReadEnabled();
|
|
return ((m_nCameraFlag&CAF_ACTIVE)!=0);
|
|
}
|
|
|
|
BOOL TDbCamera::IsPerspective() const
|
|
{
|
|
assertReadEnabled();
|
|
return ((m_nCameraFlag&CAF_PERSPECTIVE)!=0);
|
|
}
|
|
|
|
BOOL TDbCamera::IsLocator() const
|
|
{
|
|
return ((m_nCameraFlag&CAF_LOCATOR)!=0);
|
|
}
|
|
|
|
|
|
XPoint
|
|
TDbCamera::GetCamera() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptCamera;
|
|
}
|
|
|
|
XPoint
|
|
TDbCamera::GetTarget() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_ptTarget;
|
|
}
|
|
|
|
double
|
|
TDbCamera::GetLatitude() const //-PI/2 ~ PI/2
|
|
{
|
|
assertReadEnabled();
|
|
double nDist=m_ptTarget.Distance(m_ptCamera);
|
|
if(nDist<_DIST_SNAP)
|
|
return 0.0;
|
|
if(m_ptTarget.Distance2d(m_ptCamera)<_DIST_SNAP) {
|
|
return ((m_ptTarget.z > m_ptCamera.z)? PI/2 : -PI/2);
|
|
}
|
|
return asin((m_ptTarget.z-m_ptCamera.z)/nDist);
|
|
}
|
|
|
|
|
|
double
|
|
TDbCamera::GetLongitude() const // 0 ~ 2*PI
|
|
{
|
|
assertReadEnabled();
|
|
if(m_ptTarget.Distance2d(m_ptCamera)<_DIST_SNAP)
|
|
return 0.0;
|
|
return ads_angle(m_ptCamera, m_ptTarget);
|
|
}
|
|
|
|
AcDbObjectId
|
|
TDbCamera::GetBlockId() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idBlock;
|
|
}
|
|
|
|
void TARCH_IMPEXP ReadVports(DList<TViewportInfo> &vpInfo) //读取视口信息
|
|
{
|
|
int nTileMode;
|
|
xg_getvar(_T("TILEMODE"), &nTileMode);
|
|
if(!nTileMode)
|
|
return;
|
|
struct resbuf *rb=NULL;
|
|
|
|
TViewportInfo vports;
|
|
BOOL flag = FALSE;
|
|
if(acedVports(&rb) !=RTNORM)
|
|
return;
|
|
while(rb = rb->rbnext) {
|
|
if(rb->restype == RTSHORT) {
|
|
vports.VpID = rb->resval.rint;
|
|
flag = TRUE;
|
|
}
|
|
if(rb->restype == RTPOINT) {
|
|
if(flag) {
|
|
vports.ptLeft[X] = rb->resval.rpoint[0];
|
|
vports.ptLeft[Y] = rb->resval.rpoint[1];
|
|
vports.ptLeft[Z] = 0;
|
|
flag = FALSE;
|
|
} else {
|
|
vports.ptRight[X] = rb->resval.rpoint[0];
|
|
vports.ptRight[Y] = rb->resval.rpoint[1];
|
|
vports.ptRight[Z] = 0;
|
|
vpInfo.Append(new TViewportInfo(vports));
|
|
}
|
|
}
|
|
}
|
|
if(rb)
|
|
ads_relrb(rb);
|
|
}
|
|
int
|
|
TDbCamera::GetAssociateViewport() const
|
|
{
|
|
assertReadEnabled();
|
|
DList<TViewportInfo> lstViewports;
|
|
ReadVports(lstViewports);
|
|
lstViewports.QuickSort(TViewportInfo::CompareForSort);
|
|
int nIndex=m_nVport-1;
|
|
int nRet=0;
|
|
if(nIndex<0)
|
|
return 0;
|
|
if(nIndex<lstViewports.Length())
|
|
nRet=lstViewports[nIndex]->VpID;
|
|
return nRet;
|
|
}
|
|
|
|
double
|
|
TDbCamera::GetLens() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_nLens;
|
|
}
|
|
|
|
double
|
|
TDbCamera::GetElevation(BOOL bCamera) const
|
|
{
|
|
assertReadEnabled();
|
|
double nElev=bCamera? m_ptCamera.z : m_ptTarget.z;
|
|
return nElev;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetPerspective(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
m_nCameraFlag |= CAF_PERSPECTIVE;
|
|
else
|
|
m_nCameraFlag &= ~CAF_PERSPECTIVE;
|
|
}
|
|
|
|
void TDbCamera::SetLocator(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue) {
|
|
m_nCameraFlag |= CAF_LOCATOR;
|
|
m_nCameraFlag |= CAF_FRONTON;
|
|
m_nCameraFlag &= ~CAF_PERSPECTIVE;
|
|
m_nCameraFlag &= ~CAF_FRONTCLIP_ATEYE;
|
|
m_nFrontDist = m_ptTarget.Distance2d(m_ptCamera);
|
|
} else {
|
|
m_nCameraFlag &= ~CAF_LOCATOR;
|
|
}
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetFrontClipAtEye(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
m_nCameraFlag |= CAF_FRONTCLIP_ATEYE;
|
|
else
|
|
m_nCameraFlag &= ~CAF_FRONTCLIP_ATEYE;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetBackClipOn(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
m_nCameraFlag |= CAF_BACKON;
|
|
else
|
|
m_nCameraFlag &= ~CAF_BACKON;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetFrontClipOn(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
m_nCameraFlag |= CAF_FRONTON;
|
|
else
|
|
m_nCameraFlag &= ~CAF_FRONTON;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetFrontClipPoint(XPoint ptFrontClip)
|
|
{
|
|
assertWriteEnabled();
|
|
SetClipPoint(ptFrontClip, TRUE);
|
|
}
|
|
|
|
|
|
void
|
|
TDbCamera::SetBackClipPoint(XPoint ptBackClip)
|
|
{
|
|
assertWriteEnabled();
|
|
SetClipPoint(ptBackClip, FALSE);
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetClipPoint(XPoint ptClip, BOOL bFront)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoint ptOnSight;
|
|
XLine line(m_ptCamera, m_ptTarget);
|
|
ptClip.Project(&line, ptOnSight);
|
|
int nPrFlag=ptOnSight&XLine(m_ptCamera, m_ptTarget);
|
|
XVector3D vt1=ptOnSight-m_ptTarget;
|
|
XVector3D vt2=m_ptCamera-m_ptTarget;
|
|
double nVal=vt1&vt2; //逆视线为正,沿着视线为负
|
|
if(fabs(nVal)>1.0E-3)
|
|
nVal /= fabs(nVal);
|
|
else
|
|
nVal=0.0;
|
|
|
|
double nDist=m_ptTarget.Distance(ptOnSight)*nVal;
|
|
if(bFront)
|
|
m_nFrontDist=nDist;
|
|
else
|
|
m_nBackDist=nDist;
|
|
}
|
|
|
|
|
|
void
|
|
TDbCamera::SetActive(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
m_nCameraFlag |= CAF_ACTIVE;
|
|
else
|
|
m_nCameraFlag &= ~CAF_ACTIVE;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetCamera(XPoint pt)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptCamera=pt;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetTarget(XPoint pt)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptTarget=pt;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetBackClipDist(double nDist)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nBackDist=nDist;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetFrontClipDist(double nDist)
|
|
{
|
|
//ASSERT(nDist>-1.0E-3);
|
|
assertWriteEnabled();
|
|
m_nFrontDist=nDist;
|
|
}
|
|
|
|
|
|
void
|
|
TDbCamera::SetLongitude(double val)
|
|
{
|
|
assertWriteEnabled();
|
|
double nElev=m_ptTarget.z;
|
|
ads_polar(m_ptCamera, val, m_ptCamera.Distance2d(m_ptTarget), m_ptTarget);
|
|
m_ptTarget.z=nElev;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetAssociateViewport(int nId)
|
|
{
|
|
assertWriteEnabled();
|
|
if(nId>0) {
|
|
DList<TViewportInfo> lstViewports;
|
|
ReadVports(lstViewports);
|
|
lstViewports.QuickSort(TViewportInfo::CompareForSort);
|
|
if(lstViewports.FindNode(&nId, TViewportInfo::CompareForFindById)) {
|
|
m_nVport=lstViewports.CurPosition()+1;
|
|
} else {
|
|
m_nVport=0;
|
|
}
|
|
} else {
|
|
m_nVport=0;
|
|
}
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetLens(double val)
|
|
{
|
|
assertWriteEnabled();
|
|
if(val>0)
|
|
m_nLens=val;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetElevation(double e, BOOL bCamera)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bCamera) m_ptCamera.z=e;
|
|
else m_ptTarget.z=e;
|
|
}
|
|
|
|
void
|
|
TDbCamera::SetLatitude(double val)
|
|
{
|
|
assertWriteEnabled();
|
|
double nElevDiff=m_ptCamera.Distance2d(m_ptTarget)*tan(val);
|
|
m_ptTarget.z = m_ptCamera.z + nElevDiff;
|
|
}
|
|
|
|
BOOL
|
|
TDbCamera::SetDefaultBlock()
|
|
{
|
|
assertWriteEnabled();
|
|
XDbBlockTableRec blk(_T("_CAMERA"), AcDb::kForRead);
|
|
if(!blk) {
|
|
XString sFile(256);
|
|
if(!FindFile(_T("_CAMERA.DWG"), sFile))
|
|
return FALSE;
|
|
AcDbDatabase db(false, true);
|
|
#if ADS < 21
|
|
db.readDwgFile(sFile, _SH_DENYNO, false);
|
|
#else
|
|
db.readDwgFile(sFile, AcDbDatabase::kForReadAndAllShare, false);
|
|
#endif
|
|
if(acdbCurDwg()->insert(m_idBlock, _T("_CAMERA"), &db)!=Acad::eOk)
|
|
return FALSE;
|
|
} else {
|
|
m_idBlock=blk.m_pBlockTableRec->objectId();
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL
|
|
TDbCamera::SetBlock(AcDbObjectId id)
|
|
{
|
|
assertWriteEnabled();
|
|
XDbBlockTableRec blk(id, AcDb::kForRead);
|
|
if(!blk)
|
|
return FALSE;
|
|
m_idBlock=id;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
BOOL
|
|
TDbCamera::TakePhoto(BOOL bFast) const
|
|
{
|
|
assertReadEnabled();
|
|
int nTileMode=0;
|
|
xg_getvar(_T("TILEMODE"), &nTileMode);
|
|
if(!IsValid() || !nTileMode)
|
|
return FALSE;
|
|
if(!m_nVport)
|
|
return FALSE;
|
|
|
|
|
|
int nCurVp=0;
|
|
int nVportId=GetAssociateViewport();
|
|
if(!nVportId)
|
|
return FALSE;
|
|
AcGsView *pGsView=acgsGetGsView(nVportId, false);
|
|
if(pGsView && bFast) {
|
|
AcGePoint2d lowerLeft, upperRight;
|
|
pGsView->getViewport(lowerLeft,upperRight);
|
|
double nHeight=pGsView->fieldHeight();
|
|
double nWidth=pGsView->fieldWidth();
|
|
XVector3D vtDir=m_ptTarget-m_ptCamera;
|
|
AcGeVector3d vtUp(0,0,1);
|
|
if(vtDir.AsAcGeVector3d()==AcGeVector3d(0,0,1))
|
|
vtUp=AcGeVector3d(0,-1,0);
|
|
else if(vtDir.AsAcGeVector3d()==AcGeVector3d(0,0,-1))
|
|
vtUp=AcGeVector3d(0,1,0);
|
|
|
|
AcGePoint3d ptCam=pGsView->position();
|
|
AcGePoint3d ptTar=pGsView->target();
|
|
AcGeVector3d vt=ptTar-ptCam;
|
|
double nDist=vt.length();
|
|
XVector3D vt1=m_ptTarget-m_ptCamera;
|
|
((AcGeVector3d &)vt1).normalize();
|
|
vt1 *= nDist;
|
|
XPoint ptTarget=m_ptCamera+vt1;
|
|
|
|
pGsView->setView(m_ptCamera, ptTarget, vtUp,
|
|
nWidth, nHeight, IsPerspective()? AcGsView::kPerspective : AcGsView::kParallel );
|
|
pGsView->setEnableBackClip(IsBackClipOn()? true : false);
|
|
pGsView->setBackClip(GetBackClipDist());
|
|
pGsView->setEnableFrontClip(IsFrontClipOn()? true : false);
|
|
//view.setFrontClipAtEye((!IsFrontClipOn() || IsFrontClipAtEye())? true : false);
|
|
pGsView->setFrontClip(GetFrontClipDist());
|
|
//pGsView->zoom(GetLens());
|
|
pGsView->update();
|
|
return TRUE;
|
|
}
|
|
|
|
VERIFY(xg_getvar(_T("CVPORT"), &nCurVp)==RTNORM);
|
|
if(xg_setvar(_T("CVPORT"), nVportId)!=RTNORM)
|
|
return FALSE;
|
|
|
|
double nWidth, nHeight;
|
|
AT_ScrSize(&nWidth, &nHeight);
|
|
/*
|
|
AcGeMatrix3d matEye;
|
|
AcGeVector3d vtY(0,0,1); // WCS-Z
|
|
AcGeVector3d vtZ=(AcGeVector3d &)(m_ptCamera-m_ptTarget);
|
|
vtZ.normalize();
|
|
AcGeVector3d vtX=vtZ.crossProduct(vtY);
|
|
vtX.normalize();
|
|
matEye.setCoordSystem(m_ptCamera, vtX, vtY, vtZ);
|
|
AcGePoint3d ptCen=m_ptTarget;
|
|
ptCen.transformBy(matEye);
|
|
*/
|
|
AcDbViewTableRecord view;
|
|
XPoint vtViewDir=m_ptCamera-m_ptTarget;
|
|
view.setCenterPoint(AcGePoint2d(0,0));
|
|
view.setHeight( nHeight);
|
|
view.setWidth( nWidth );
|
|
view.setViewDirection(vtViewDir);
|
|
view.setPerspectiveEnabled(IsPerspective()? true : false);
|
|
view.setBackClipEnabled(IsBackClipOn()? true : false);
|
|
view.setBackClipDistance(GetBackClipDist());
|
|
view.setFrontClipEnabled(IsFrontClipOn()? true : false);
|
|
if(IsLocator())
|
|
view.setFrontClipAtEye(false);
|
|
else
|
|
view.setFrontClipAtEye((!IsFrontClipOn() || IsFrontClipAtEye())? true : false);
|
|
view.setFrontClipDistance(GetFrontClipDist());
|
|
view.setLensLength(GetLens());
|
|
view.setViewTwist(0.0);
|
|
view.setTarget(m_ptTarget);
|
|
if(IsLocator()) {
|
|
XPoint ptC=m_ptTarget, ptX, ptY;
|
|
ptC.z=0;
|
|
ptY=ptC; ptY.z=1000.0;
|
|
ads_polar(ptC, GetLongitude()-PI/2, 1000.0, ptX);
|
|
//view.setUcs(ptC, ptX, ptY);
|
|
}
|
|
|
|
BOOL bRet=(acedSetCurrentView( &view, NULL )==Acad::eOk);
|
|
/*
|
|
XPoint ptViewCen=m_ptTarget;
|
|
ads_trans(XPoint(ptViewCen), Groups(0), Groups(2), 0, ptViewCen);
|
|
view.setCenterPoint(ptViewCen.AsAcGePoint2d());
|
|
acedSetCurrentView( &view, NULL );
|
|
*/
|
|
|
|
if(1) { // Shade 方式下需要调用Camera来更新
|
|
XPushVar<int> osmode(_T("OSMODE"), 0);
|
|
XPushVar<int> cmdecho(_T("CMDECHO"), 0);
|
|
|
|
if(IsLocator()) {
|
|
XPoint ptC=m_ptTarget, ptX, ptY;
|
|
ptC.z=0;
|
|
ptY=ptC; ptY.z=1000.0;
|
|
ads_polar(ptC, GetLongitude()-PI/2, 1000.0, ptX);
|
|
ptC=Wcs2Ucs(ptC); ptX=Wcs2Ucs(ptX); ptY=Wcs2Ucs(ptY);
|
|
SHads_command(RTSTR, _T(".UCS"), RTSTR, _T("N"), RTSTR, _T("3"), RT3DPOINT, &ptC,
|
|
RT3DPOINT, &ptX, RT3DPOINT, &ptY, RTNONE);
|
|
}
|
|
XPoint ptCam=Wcs2Ucs(m_ptCamera),
|
|
ptTar=Wcs2Ucs(m_ptTarget);
|
|
if(!IsLocator())
|
|
SHads_command(RTSTR, _T("CAMERA"), RT3DPOINT, &ptCam, RT3DPOINT, &ptTar, RTNONE);
|
|
}
|
|
|
|
xg_setvar(_T("CVPORT"), nCurVp);
|
|
AcDbObjectId id=objectId();
|
|
/*
|
|
if(!!id && g_updIdArray.FindNode(&id, CompareObjectId))
|
|
g_updIdArray.Remove();
|
|
*/
|
|
return bRet;
|
|
}
|
|
|
|
//通知墙体已经被修改过
|
|
Acad::ErrorStatus TDbCamera::subClose()
|
|
{
|
|
Acad::ErrorStatus es = TDbEntity::subClose();
|
|
if(es==Acad::eOk && isModified() && database()==acdbCurDwg() && IsActive()) {
|
|
AcDbObjectId idOwner=ownerId();
|
|
if(idOwner==GetMSpaceId()) {
|
|
if(DocGetIsDwgBegin()) {
|
|
AcDbObjectId id=objectId();
|
|
if(!g_updIdArray.FindNode(&id, CompareObjectId))
|
|
g_updIdArray.Append(new AcDbObjectId(id));
|
|
}
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
void TDbCamera::BegUserCommand(const TCHAR *, BOOL)
|
|
{
|
|
g_updIdArray.Reset();
|
|
}
|
|
|
|
void TDbCamera::ViewportChanged()
|
|
{
|
|
PickSet lstCam(SS_FREE);
|
|
GetEntByDxf(lstCam, _T("ATS_CAMERA"), 0);
|
|
long nCount=lstCam.Length();
|
|
for(long n=0; n<nCount; n++) {
|
|
Entity ent=lstCam[n];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbCamera, pCam);
|
|
if(pCam) {
|
|
pCam->SetAssociateViewport(0);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
void TDbCamera::EndUserCommand(const TCHAR *szCmd, BOOL)
|
|
{
|
|
if(szCmd && _tcsicmp(szCmd, _T("COPYBASE"))==0 || _tcsicmp(szCmd, _T("COPYCLIP"))==0 ||
|
|
_tcsicmp(szCmd, _T("WBLOCK"))==0)
|
|
ResetIdArray();
|
|
else {
|
|
if(g_updIdArray.Length())
|
|
PostCommand(_T("(TUpdCamera) "), false);
|
|
}
|
|
return;
|
|
}
|
|
|
|
void TDbCamera::ResetIdArray()
|
|
{
|
|
TDbCamera::g_updIdArray.Reset();
|
|
}
|
|
|
|
int UpdCamera()
|
|
{
|
|
resbuf *gset=NULL, *pset=NULL;
|
|
int nRet=ads_ssgetfirst(&gset, &pset);
|
|
|
|
for(int i=0; i<TDbCamera::g_updIdArray.Length(); i++) {
|
|
OPENOBJ_BEGIN(*TDbCamera::g_updIdArray[i], AcDb::kForRead, TDbCamera, pCam);
|
|
if(pCam && pCam->IsActive())
|
|
pCam->TakePhoto(FALSE);
|
|
OPENOBJ_END();
|
|
}
|
|
TDbCamera::g_updIdArray.Reset();
|
|
|
|
if(nRet==RTNORM) {
|
|
ads_sssetfirst(NULL, NULL);
|
|
PickSet ss(SS_FREE);
|
|
if(gset) {
|
|
if(gset->restype==RTPICKS) {
|
|
ss = gset->resval.rlname;
|
|
}
|
|
ads_relrb(gset);
|
|
}
|
|
if(pset) {
|
|
if(pset->restype==RTPICKS) {
|
|
if(!ss) ss = pset->resval.rlname;
|
|
else ads_ssfree(pset->resval.rlname);
|
|
}
|
|
ads_relrb(pset);
|
|
}
|
|
if(!!ss)
|
|
ads_sssetfirst(ss, ss);
|
|
}
|
|
ads_retvoid();
|
|
return RTNORM;
|
|
}
|
|
|
|
//int EditCamera0(AcDbObjectId id);
|
|
|
|
void InitDbCamera(BOOL bTrue)
|
|
{
|
|
if(bTrue) {
|
|
TDbCamera::rxInit();
|
|
acrxBuildClassHierarchy();
|
|
TDbCamera::InitMatchProtocol(TRUE);
|
|
// TDbCamera::SetEditMethod(EditCamera0);
|
|
} else {
|
|
TDbCamera::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbCamera::desc());
|
|
}
|
|
}
|
|
|
|
|