131 lines
2.8 KiB
C++
131 lines
2.8 KiB
C++
#include "StdAfx.h"
|
|
#include "dbproxy.h"
|
|
#include "geassign.h"
|
|
#include "acgi.h"
|
|
#include "TDbCableWatch.h"
|
|
|
|
#define VERSION_TDBCABLEWATCH 1
|
|
|
|
const int PIX_100 = 50;
|
|
const int PIX_5 = 5;
|
|
|
|
void TDbCableWatch::PixelToWcs(int nPixel,double& dGet) const
|
|
{
|
|
ads_point ptScreenSize;
|
|
double nViewSize;
|
|
struct resbuf rb1,rb2;
|
|
acedGetVar(_T("ScreenSize"), &rb1);
|
|
acedGetVar(_T("ViewSize"), &rb2);
|
|
nViewSize = rb2.resval.rreal;
|
|
ads_point_set(rb1.resval.rpoint,ptScreenSize);
|
|
|
|
if (ptScreenSize[1] >= 1.0E-6 && nViewSize >= 1.0E-6)
|
|
dGet = (nViewSize / ptScreenSize[Y]) * nPixel;
|
|
}
|
|
|
|
TDbCableWatch::TDbCableWatch()
|
|
{
|
|
//{{AFX_ARX_DATA_INIT(TDbCableWatch)
|
|
//}}AFX_ARX_DATA_INIT
|
|
|
|
m_vtStart = AcGeVector3d::kXAxis;
|
|
m_vtNormal = AcGeVector3d::kZAxis;
|
|
m_pTextAng = new AcDbText;
|
|
m_bClosePan = FALSE;
|
|
}
|
|
|
|
TDbCableWatch::~TDbCableWatch()
|
|
{
|
|
if (m_pTextAng != NULL)
|
|
delete m_pTextAng;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
Acad::ErrorStatus TDbCableWatch::ExplodeOrDraw2d(XExplodeDraw &mode) const
|
|
{
|
|
XAcGiViewDraw* pXDraw = (XAcGiViewDraw*)&mode;
|
|
AcGiCommonDraw* pCDraw = pXDraw->GetCommonDraw();
|
|
if (pCDraw == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
assertReadEnabled();
|
|
// TODO: implement this function.
|
|
|
|
double dRadius = 0.0,dGet = 0.0;
|
|
PixelToWcs(PIX_100,dRadius);
|
|
|
|
if (!m_bClosePan)
|
|
{
|
|
pCDraw->rawGeometry()->circle(m_ptCen,dRadius,m_vtNormal);
|
|
AcGePoint3d pt[2];
|
|
AcGeVector3d vt = m_vtStart;
|
|
vt.normalize();
|
|
|
|
PixelToWcs(PIX_5,dGet);
|
|
for (int n = 0; n < (2*PI)/m_dAverageAng; ++n)
|
|
{
|
|
pt[0] = m_ptCen + (dRadius - dGet)*vt;
|
|
pt[1] = m_ptCen + (dRadius + dGet)*vt;
|
|
|
|
pCDraw->rawGeometry()->worldLine(pt);
|
|
vt.rotateBy(m_dAverageAng,m_vtNormal);
|
|
}
|
|
}
|
|
|
|
int nLen = (int)_tcslen(m_sText);
|
|
AcGiTextStyle style;
|
|
style.setFileName(_T("txt.shx"));
|
|
style.setBigFontFileName(_T(""));
|
|
PixelToWcs(2 * PIX_5,dGet);
|
|
style.setTextSize(dGet);
|
|
|
|
AcGeVector3d vtOffset = m_vtStart;
|
|
vtOffset.rotateBy(PI/4,m_vtNormal);
|
|
vtOffset.normalize();
|
|
|
|
PixelToWcs(4 * PIX_5,dGet);
|
|
AcGePoint3d ptPos = const_cast<AcGePoint3d&>(m_ptTextPosition);
|
|
ptPos += dGet * vtOffset;
|
|
|
|
pCDraw->rawGeometry()->text(ptPos,m_vtNormal,m_vtStart,m_sText,nLen,Adesk::kFalse,style);
|
|
|
|
return TDbCurveEntity::ExplodeOrDraw2d(mode);
|
|
}
|
|
|
|
void TDbCableWatch::SetCenPoint(const AcGePoint3d &pt)
|
|
{
|
|
m_ptCen = pt;
|
|
}
|
|
|
|
void TDbCableWatch::SetAverageAngle(double dAng)
|
|
{
|
|
m_dAverageAng = dAng;
|
|
}
|
|
|
|
void TDbCableWatch::SetStartVector(const AcGeVector3d& vt)
|
|
{
|
|
m_vtStart = vt;
|
|
}
|
|
|
|
void TDbCableWatch::SetNormal(const AcGeVector3d &vtNorm)
|
|
{
|
|
m_vtNormal = vtNorm;
|
|
}
|
|
|
|
void TDbCableWatch::GetNormal(AcGeVector3d &vtNorm)
|
|
{
|
|
vtNorm = m_vtNormal;
|
|
}
|
|
|
|
void TDbCableWatch::SetText(const AcGePoint3d& pt,LPCTSTR lpText)
|
|
{
|
|
m_ptTextPosition = pt;
|
|
m_sText = lpText;
|
|
}
|
|
|
|
void TDbCableWatch::SetPanState(BOOL bClose)
|
|
{
|
|
m_bClosePan = bClose;
|
|
} |