179 lines
6.0 KiB
C++
179 lines
6.0 KiB
C++
#ifndef __DBCAMERA_H
|
|
#define __DBCAMERA_H
|
|
//#include "DbEntity.h"
|
|
|
|
#define CAF_BACKON 0x01
|
|
#define CAF_FRONTON 0x02
|
|
#define CAF_ACTIVE 0x04 //自动刷新
|
|
#define CAF_PERSPECTIVE 0x08
|
|
#define CAF_FRONTCLIP_ATEYE 0x10 //前裁剪在相机处
|
|
|
|
|
|
class TViewportInfo
|
|
{
|
|
public:
|
|
TViewportInfo(){}
|
|
TViewportInfo (const TViewportInfo& vports) {
|
|
*this = vports;
|
|
}
|
|
TViewportInfo & operator = (const TViewportInfo &vports) {
|
|
VpID = vports.VpID;
|
|
ptLeft = vports.ptLeft;
|
|
ptRight = vports.ptRight;
|
|
return *this;
|
|
}
|
|
|
|
int VpID;
|
|
XPoint ptLeft;
|
|
XPoint ptRight;
|
|
static int CompareForSort(const TViewportInfo *p1, const TViewportInfo *p2);
|
|
static int CompareForFindById(const TViewportInfo *p1, const void *p2);
|
|
};
|
|
inline int FCompare(double e1, double e2)
|
|
{
|
|
if(fabs(e1-e2)<1.0E-6)
|
|
return 0;
|
|
if(e1>e2)
|
|
return 1;
|
|
return -1;
|
|
}
|
|
|
|
// 由下往上, 然后由左往右
|
|
inline int TViewportInfo::CompareForSort(const TViewportInfo *p1, const TViewportInfo *p2)
|
|
{
|
|
int nCode=FCompare(p1->ptLeft.y, p2->ptLeft.y);
|
|
if(!nCode) {
|
|
nCode=FCompare(p1->ptLeft.x, p2->ptLeft.x);
|
|
if(!nCode) {
|
|
nCode=FCompare(p1->ptRight.y, p2->ptRight.y);
|
|
if(!nCode)
|
|
nCode=FCompare(p1->ptRight.x, p2->ptRight.x);
|
|
}
|
|
}
|
|
return nCode;
|
|
}
|
|
|
|
inline int TViewportInfo::CompareForFindById(const TViewportInfo *p1, const void *p2)
|
|
{
|
|
const int *pp2=(const int *)p2;
|
|
if(p1->VpID==*pp2)
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
// TArch6标记
|
|
#define CAF_LOCATOR 0x20 //定位器,自动关闭透视,自动设置前裁剪
|
|
class TARCH_EXP TDbCamera: public TDbEntity {
|
|
friend int UpdCamera();
|
|
//friend TARCH_IMPEXP int EditCamera0(AcDbObjectId id);
|
|
|
|
DECLARE_TENTBASE();
|
|
ACRX_DECLARE_MEMBERS(TDbCamera);
|
|
private:
|
|
const static Adesk::UInt8 g_nVersion;
|
|
protected:
|
|
XPoint m_ptCamera, m_ptTarget;
|
|
double m_nLens, m_nFrontDist, m_nBackDist; //后裁剪可以<0, 前裁剪必须为正
|
|
Adesk::UInt8 m_nCameraFlag;
|
|
AcDbHardPointerId m_idBlock;
|
|
Adesk::UInt8 m_nVport; //视口序号, 1开始
|
|
|
|
static DList<AcDbObjectId> g_updIdArray;
|
|
|
|
// 导出参数, 作为Locator时
|
|
/*
|
|
XPoint GetLocatorC() const;
|
|
XPoint GetLocatorL() const;
|
|
XPoint GetLocatorR() const;
|
|
XPoint GetLocatorF() const;
|
|
XPoint GetLocatorB() const;
|
|
*/
|
|
public:
|
|
TDbCamera();
|
|
~TDbCamera();
|
|
virtual BOOL IsValid() const;
|
|
virtual void CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag);
|
|
|
|
virtual Adesk::Boolean subWorldDraw(AcGiWorldDraw *pWd);
|
|
virtual void subViewportDraw(AcGiViewportDraw* pMode);
|
|
virtual Adesk::UInt32 subViewportDrawLogicalFlags(AcGiViewportDraw * vd);
|
|
virtual Adesk::UInt32 subSetAttributes(AcGiDrawableTraits * traits);
|
|
|
|
// Overriden function from AcDbEntity
|
|
virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
|
|
virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler*);
|
|
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
|
|
virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler*);
|
|
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
|
|
virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const;
|
|
virtual Acad::ErrorStatus subGetStretchPoints(AcGePoint3dArray & stretchPoints) const;
|
|
virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);
|
|
virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset);
|
|
virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset);
|
|
//virtual Adesk::Boolean worldDraw(AcGiWorldDraw *pWd);
|
|
//virtual Acad::ErrorStatus explode(AcDbVoidPtrArray &entSet) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw2d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus ExplodeOrDraw3d(XExplodeDraw &dc) const;
|
|
virtual Acad::ErrorStatus subClose();
|
|
|
|
// drived from TDbEntity
|
|
virtual void GetTips(DList<TObjInfoUnit> &) const; //取动态属性显示数据
|
|
virtual Acad::ErrorStatus GetGripText(int i, CString &cs) const;
|
|
virtual const TCHAR *GetDefaultLayer() const;
|
|
virtual int GetCtrlToggleIndex()const{return 2;}//ok
|
|
|
|
BOOL TakePhoto(BOOL bFast=FALSE) const;
|
|
BOOL IsBackClipOn() const;
|
|
BOOL IsFrontClipOn() const;
|
|
BOOL IsActive() const;
|
|
BOOL IsPerspective() const;
|
|
BOOL IsFrontClipAtEye() const;
|
|
BOOL IsLocator() const;
|
|
XPoint GetCamera() const;
|
|
XPoint GetTarget() const;
|
|
XPoint GetBackClipPoint() const;
|
|
XPoint GetFrontClipPoint() const;
|
|
XPoint GetClipPoint(double nVal) const;
|
|
double GetBackClipDist() const;
|
|
double GetFrontClipDist() const;
|
|
double GetLatitude() const; // 0 ~ PI
|
|
double GetLongitude() const; // -PI/2 ~ PI/2
|
|
AcDbObjectId GetBlockId() const;
|
|
int GetAssociateViewport() const;
|
|
double GetLens() const;
|
|
double GetElevation(BOOL bCamera=TRUE) const;
|
|
|
|
void SetBackClipOn(BOOL bTrue);
|
|
void SetFrontClipOn(BOOL bTrue);
|
|
void SetClipPoint(XPoint ptClip, BOOL bFront);
|
|
void SetBackClipPoint(XPoint ptBackClip);
|
|
void SetFrontClipPoint(XPoint ptFrontClip);
|
|
void SetActive(BOOL bTrue);
|
|
void SetCamera(XPoint pt);
|
|
void SetTarget(XPoint pt);
|
|
void SetBackClipDist(double nDist);
|
|
void SetFrontClipDist(double nDist);
|
|
void SetLatitude(double val);
|
|
void SetLongitude(double val);
|
|
BOOL SetDefaultBlock();
|
|
BOOL SetBlock(AcDbObjectId id);
|
|
void SetAssociateViewport(int nId);
|
|
void SetLens(double val);
|
|
void SetElevation(double e, BOOL bCamera=TRUE);
|
|
void SetPerspective(BOOL bTrue);
|
|
void SetFrontClipAtEye(BOOL bTrue);
|
|
void SetLocator(BOOL bTrue);
|
|
|
|
|
|
static void BegUserCommand(const TCHAR *, BOOL bIsArxCommand);
|
|
static void EndUserCommand(const TCHAR *, BOOL bIsArxCommand);
|
|
static void ViewportChanged();
|
|
static void ResetIdArray();
|
|
};
|
|
|
|
extern TARCH_IMPEXP BOOL g_bMakingVideo;
|
|
#endif |