730 lines
19 KiB
C++
730 lines
19 KiB
C++
#include "stdafx.h"
|
|
#include "rectMaker.h"
|
|
|
|
void CopyDbRect(TDbRect* pSR,TDbRect*pDR)
|
|
{
|
|
/*
|
|
pDR->SetRectFlag(pSR->GetRectFlag());
|
|
pDR->SetNormal(pSR->GetNormal());
|
|
pDR->SetSizeX(pSR->GetSizeX());
|
|
pDR->SetSizeY(pSR->GetSizeY());
|
|
pDR->SetSizeZ(pSR->GetSizeZ());
|
|
pDR->SetCenter(pSR->GetCenter());
|
|
pDR->SetRotation(pSR->GetRotation());
|
|
*/
|
|
CopyObject(*pSR, *pDR);
|
|
}
|
|
TRectJig::TRectJig(CCubicSetDlg*pD):pDlg(pD)
|
|
{
|
|
}
|
|
void TRectJig::SetStandardBaseType(int iType)//设置标准基点类型,跳过任意基点类型
|
|
{
|
|
double x=pRect->GetSizeX(),y=pRect->GetSizeY();
|
|
switch(iType){
|
|
case 0:distVector=XPoint(x/2,-y/2);break;
|
|
case 1:distVector=XPoint(0,0);break;
|
|
case 2:distVector=XPoint(x,0);break;
|
|
case 3:distVector=XPoint(x,-y);break;
|
|
case 4:distVector=XPoint(0,-y);break;
|
|
}
|
|
}
|
|
void TRectJig::UpdateData(XPoint ptInsert)
|
|
{
|
|
pRect->SetRotation(Ucs2Wcs(0.0));
|
|
pDlg->UpdateData();
|
|
if (pDlg->IsInsertMode())
|
|
{
|
|
SetStandardBaseType(pDlg->basePointType);
|
|
XVector3D vt=Ucs2Wcs(XVector3D(0,0,1),TRUE);
|
|
pRect->SetNormal(vt);
|
|
XPoint vt1(pDlg->length/2,-pDlg->width/2,0);
|
|
pRect->SetCenter(Ucs2Ecs(ptInsert-distVector+vt1,vt));
|
|
}
|
|
else if (ptCount==0)
|
|
pt=ptInsert;
|
|
else
|
|
{
|
|
XVector3D vt=Ucs2Wcs(XVector3D(0,0,1), TRUE);
|
|
XRectAngle box(pt, ptInsert);
|
|
XPoint ptCen;
|
|
Midpoint(pt, ptInsert, ptCen);
|
|
pRect->SetNormal(vt);
|
|
pRect->SetCenter(Ucs2Ecs(ptCen, vt));
|
|
pRect->SetSizeX(box.Width());
|
|
pRect->SetSizeY(box.Height());
|
|
pDlg->UpdateSize(box.Width(),box.Height());
|
|
}
|
|
pDlg->Init(*pRect);
|
|
}
|
|
void TRectJig::MakeIt()
|
|
{//执行拖制
|
|
ptCount=0;
|
|
pRect=NULL;
|
|
bool bContinue=true;
|
|
while(bContinue){
|
|
if (pRect==NULL)
|
|
{
|
|
pRect=new TDbRect;
|
|
pRect->SetSizeX(100);
|
|
pRect->SetSizeY(100);
|
|
}
|
|
int oldMode=pDlg->makeMode;
|
|
|
|
int status;
|
|
try {
|
|
status=DoIt();
|
|
}catch(...){
|
|
status=RTERROR;
|
|
}
|
|
|
|
if (status==RTNORM){//正常取点
|
|
if (!pDlg->IsInsertMode()){
|
|
ptCount++;
|
|
if (ptCount==1)
|
|
continue;
|
|
else
|
|
ptCount=0;
|
|
}
|
|
bContinue=pDlg->IsContinue();//one finished,make more?
|
|
if (pDlg->length<1E-6||pDlg->width<1E-6)//add by fxj 090410
|
|
setDispPrompt(_T("\n请输入合理数值!"));
|
|
else
|
|
pRect->AddToCSpace(Adesk::kTrue);
|
|
pRect=NULL;
|
|
} else if (status==RTKWORD){//用户键入命令
|
|
switch(nRetKey)
|
|
{
|
|
case 1://I/D,keyword mode
|
|
pDlg->UpdateMakeMode(pDlg->IsInsertMode()?0:1);
|
|
if (!pDlg->IsInsertMode()){//U
|
|
pRect->SetSizeX(100);
|
|
pRect->SetSizeY(100);
|
|
ptCount=0;
|
|
}
|
|
break;
|
|
case 2:
|
|
if (!pDlg->IsInsertMode()){//U,UNDO
|
|
pRect->SetSizeX(100);
|
|
pRect->SetSizeY(100);
|
|
ptCount=0;
|
|
}else{//F,对齐
|
|
TDbRect *pTempRect=new TDbRect;
|
|
CopyDbRect(pRect,pTempRect);
|
|
AcDbObjectId idTemp=pTempRect->AddToCSpace(Adesk::kTrue);
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
XPoint pt1, pt2, qt1, qt2;
|
|
|
|
pDlg->ShowWindow(SW_HIDE);
|
|
if (ads_getpoint(NULL, _T("\n对齐参考点:"), pt1)==RTNORM &&
|
|
ads_getpoint(pt1, _T("\n对齐参考轴:"), pt2)==RTNORM &&
|
|
ads_getpoint(NULL, _T("\n对齐目标点:"), qt1)==RTNORM &&
|
|
ads_getpoint(qt1, _T("\n对齐目标轴:"), qt2)==RTNORM) {
|
|
pt1=Ucs2Wcs(pt1);
|
|
pt2=Ucs2Wcs(pt2);
|
|
qt1=Ucs2Wcs(qt1);
|
|
qt2=Ucs2Wcs(qt2);
|
|
double nRot=CT_std_angle(ads_angle(qt1, qt2)-ads_angle(pt1, pt2));
|
|
ads_matrix matMov, matRot;
|
|
pt1.GetMoveMatrix(qt1, matMov);
|
|
qt1.GetRotationMatrix(nRot, matRot);
|
|
pRect->transformBy(AsAcGeMatrix3d(matMov));
|
|
pRect->transformBy(AsAcGeMatrix3d(matRot));
|
|
|
|
bContinue=pDlg->IsContinue();//one finished,make more?
|
|
pRect->AddToCSpace(Adesk::kTrue);
|
|
pRect=NULL;
|
|
}
|
|
pDlg->ShowWindow(SW_NORMAL);
|
|
acedGetAcadFrame()->SetFocus();
|
|
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if (pEnt) pEnt->erase();
|
|
OPENOBJ_END();
|
|
}
|
|
break;
|
|
case 3://T,改基点
|
|
{
|
|
TDbRect *pTempRect=new TDbRect;
|
|
CopyDbRect(pRect,pTempRect);
|
|
AcDbObjectId idTemp=pTempRect->AddToCSpace(Adesk::kTrue);
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
XPoint ptTemp;
|
|
pDlg->ShowWindow(SW_HIDE);
|
|
int nRet=XGetPoint(NULL, _T("\n输入插入点"), ptTemp);
|
|
pDlg->ShowWindow(SW_NORMAL);
|
|
acedGetAcadFrame()->SetFocus();
|
|
|
|
if (nRet==RTNORM)
|
|
{
|
|
pDlg->ResetBaseType();//清除标准基点类型
|
|
distVector=ptTemp-Ecs2Ucs(pRect->GetUpLeft(),Ucs2Wcs(XVector3D(0,0,1),TRUE));
|
|
}
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if (pEnt) pEnt->erase();
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
}else{
|
|
if (status==RTNONE){
|
|
if (pDlg->makeMode!=oldMode){//Dialog make mode changed
|
|
if (!pDlg->IsInsertMode()){
|
|
pRect->SetSizeX(100);
|
|
pRect->SetSizeY(100);
|
|
ptCount=0;
|
|
}
|
|
continue;
|
|
}else if (pDlg->bEditChanged){//Edit Control lose focus;
|
|
pDlg->bEditChanged=false;
|
|
continue;
|
|
}
|
|
}
|
|
bContinue=false;//Close Dialog,Esc or Enter None
|
|
if (pRect!=NULL)
|
|
delete pRect;
|
|
}
|
|
}
|
|
}
|
|
int TRectJig::DoIt()
|
|
{
|
|
int nRet;
|
|
if (!pDlg->IsInsertMode()){
|
|
if (ptCount==0){
|
|
setDispPrompt(_T("\n输入第一个角点或 [插入矩形(I)]<退出>:"));
|
|
INITGET_BEG(-1,_T("I"));
|
|
nRet=drag();
|
|
INITGET_END();
|
|
}else {
|
|
setDispPrompt(_T("\n输入第二个角点或 [插入矩形(I)/撤消第一个角点(U)]<退出>:"));
|
|
INITGET_BEG(-1,_T("I U"));
|
|
nRet=drag();
|
|
INITGET_END();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (pDlg->length<1E-6||pDlg->width<1E-6)//modified by fxj 090410//(LessEqual(pDlg->length,0)&&LessEqual(pDlg->width,0))
|
|
//{
|
|
// pDlg->length =100;
|
|
// pDlg->width = 100;
|
|
// setDispPrompt(_T("\n请输入合理数值!"));
|
|
// return RTNORM;
|
|
//}
|
|
setDispPrompt(_T("\n输入插入点或 [拖制矩形(D)/对齐(F)/改基点(T)]<退出>:"));
|
|
INITGET_BEG(-1,_T("D F T"));
|
|
nRet=drag();
|
|
INITGET_END();
|
|
}
|
|
if (nRet == AcEdJig::kCancel)
|
|
return RTCAN;
|
|
else if (nRet == AcEdJig::kNull)
|
|
return RTNONE;
|
|
else if (nRet <= 0)
|
|
return RTNORM;
|
|
else {
|
|
nRetKey=nRet;
|
|
return RTKWORD;
|
|
}
|
|
}
|
|
AcEdJig::DragStatus TRectJig::sampler()
|
|
{
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted
|
|
|AcEdJig::kNoNegativeResponseAccepted|AcEdJig::kNoZeroResponseAccepted));
|
|
if (pDlg->IsInsertMode())
|
|
setKeywordList(_T("D F T"));
|
|
else if (ptCount==0)
|
|
setKeywordList(_T("I"));
|
|
else
|
|
setKeywordList(_T("I U"));
|
|
|
|
XPoint ptTemp;
|
|
CPoint ptCursor;
|
|
if (GetCursorPos(&ptCursor)) {
|
|
acedGetAcadDwgView()->ScreenToClient(&ptCursor);
|
|
acedCoordFromPixelToWorld(ptCursor, ptTemp);
|
|
}
|
|
DragStatus stat=acquirePoint(ptTemp);//起始点与终点相同,使之不绘制橡皮线,使用acquirePoint(ptTemp)出现了不明错误
|
|
ptTemp=Wcs2Ucs(ptTemp);
|
|
if (stat==AcEdJig::kNormal&&ptTemp==oldPoint)
|
|
return AcEdJig::kNoChange;
|
|
oldPoint=ptTemp;
|
|
if (stat==AcEdJig::kNormal)
|
|
UpdateData(ptTemp);
|
|
return stat;
|
|
}
|
|
Adesk::Boolean TRectJig::update()
|
|
{
|
|
if ((!pDlg->IsInsertMode()&&ptCount==0)||
|
|
fabs(pRect->GetSizeX()*pRect->GetSizeY())<=_DIST_SNAP)
|
|
return Adesk::kFalse;
|
|
return Adesk::kTrue;
|
|
}
|
|
AcDbEntity* TRectJig::entity() const
|
|
{
|
|
return pRect;
|
|
}
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
// CCubicSetDlg dialog
|
|
BOOL CCubicSetDlg::b3D=FALSE;
|
|
BOOL CCubicSetDlg::bMore=TRUE;
|
|
short CCubicSetDlg::crossMode=0;
|
|
short CCubicSetDlg::makeMode=0;
|
|
double CCubicSetDlg::elev=0.0;
|
|
double CCubicSetDlg::height=0.0;
|
|
double CCubicSetDlg::length=100.0;
|
|
double CCubicSetDlg::width=100.0;
|
|
int CCubicSetDlg::basePointType=0;//中心
|
|
static UINT buttonID[]={ID_DRAG,ID_INSERT,
|
|
ID_3D,
|
|
ID_NOCROSS,ID_CROSSA,ID_CROSSB,ID_CROSSC,
|
|
ID_LEFTUP,ID_RIGHTUP,ID_RIGHTDOWN,ID_LEFTDOWN,ID_CENTER,
|
|
ID_MORE};
|
|
CCubicSetDlg::CCubicSetDlg(bool bCreating)
|
|
: CUIDlg(CCubicSetDlg::IDD, acedGetAcadFrame())
|
|
{
|
|
bCreate=bCreating;
|
|
bDlgClosing=false;
|
|
bInit=true;
|
|
bEditChanged=false;
|
|
if (basePointType<0||basePointType>4)
|
|
basePointType=0;//初始基点类型不能是非标准类型。
|
|
}
|
|
CCubicSetDlg::~CCubicSetDlg()
|
|
{
|
|
}
|
|
BOOL CCubicSetDlg::Create()
|
|
{
|
|
return CUIDlg::Create(CCubicSetDlg::IDD,acedGetAcadFrame());
|
|
}
|
|
void CCubicSetDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CUIDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CCubicSetDlg)
|
|
//}}AFX_DATA_MAP
|
|
if (pDX->m_bSaveAndValidate)
|
|
{//modified by fxj 090526
|
|
CString sHeight,sLength,sWidth,sElev;
|
|
|
|
DDX_Text(pDX, IDC_HEIGHT, sHeight);
|
|
DDX_Text(pDX, IDC_LENGTH, sLength);
|
|
DDX_Text(pDX, IDC_WIDTH, sWidth);
|
|
DDX_Text(pDX, IDC_ELEV, sElev);
|
|
|
|
height=_tstof(sHeight);
|
|
length=_tstof(sLength);
|
|
width=_tstof(sWidth);
|
|
elev=_tstof(sElev);
|
|
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_HEIGHT)->SetWindowText(Dist2Str(height));
|
|
GetDlgItem(IDC_LENGTH)->SetWindowText(Dist2Str(length));
|
|
GetDlgItem(IDC_WIDTH)->SetWindowText(Dist2Str(width));
|
|
GetDlgItem(IDC_ELEV)->SetWindowText(Dist2Str(elev));
|
|
}
|
|
}
|
|
void CCubicSetDlg::ResetBaseType()
|
|
{
|
|
switch(basePointType){
|
|
case 0:m_toolbar.CheckButton(ID_CENTER,FALSE);break;
|
|
case 1:m_toolbar.CheckButton(ID_LEFTUP,FALSE);break;
|
|
case 2:m_toolbar.CheckButton(ID_RIGHTUP,FALSE);break;
|
|
case 3:m_toolbar.CheckButton(ID_RIGHTDOWN,FALSE);break;
|
|
case 4:m_toolbar.CheckButton(ID_LEFTDOWN,FALSE);break;
|
|
}
|
|
basePointType=5;//任意基点
|
|
}
|
|
void CCubicSetDlg::UpdateMakeMode(int mode)//inform
|
|
{
|
|
makeMode=mode;
|
|
m_toolbar.CheckButton(buttonID[makeMode],TRUE);
|
|
GetDlgItem(IDC_WIDTH)->EnableWindow(makeMode!=0);
|
|
GetDlgItem(IDC_LENGTH)->EnableWindow(makeMode!=0);
|
|
if (makeMode==1){
|
|
m_toolbar.EnableButton(ID_LEFTUP,TRUE);
|
|
m_toolbar.EnableButton(ID_RIGHTUP,TRUE);
|
|
m_toolbar.EnableButton(ID_RIGHTDOWN,TRUE);
|
|
m_toolbar.EnableButton(ID_LEFTDOWN,TRUE);
|
|
m_toolbar.EnableButton(ID_CENTER,TRUE);
|
|
}else{
|
|
m_toolbar.EnableButton(ID_LEFTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_LEFTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_CENTER,FALSE);
|
|
}
|
|
}
|
|
void CCubicSetDlg::UpdateSize(double l,double w)
|
|
{
|
|
length=l;
|
|
width=w;
|
|
GetDlgItem(IDC_LENGTH)->SetWindowText(Dist2Str(l));
|
|
GetDlgItem(IDC_WIDTH)->SetWindowText(Dist2Str(w));
|
|
}
|
|
BEGIN_MESSAGE_MAP(CCubicSetDlg, CUIDlg)
|
|
//{{AFX_MSG_MAP(CCubicSetDlg)
|
|
ON_EN_KILLFOCUS(IDC_LENGTH, OnEdited)
|
|
ON_EN_KILLFOCUS(IDC_WIDTH,OnEdited)
|
|
ON_EN_KILLFOCUS(IDC_HEIGHT,OnEdited)
|
|
ON_EN_KILLFOCUS(IDC_ELEV,OnEdited)
|
|
ON_COMMAND(ID_NOCROSS,OnNoCross)
|
|
ON_COMMAND(ID_CROSSA,OnCrossA)
|
|
ON_COMMAND(ID_CROSSB,OnCrossB)
|
|
ON_COMMAND(ID_CROSSC,OnCrossC)
|
|
ON_COMMAND(ID_DRAG,OnDragMode)
|
|
ON_COMMAND(ID_INSERT,OnInsertMode)
|
|
ON_COMMAND(ID_3D,On3d)
|
|
ON_COMMAND(ID_MORE,OnMore)
|
|
|
|
ON_COMMAND(ID_LEFTUP,OnLeftUp)
|
|
ON_COMMAND(ID_LEFTDOWN,OnLeftDown)
|
|
ON_COMMAND(ID_RIGHTUP,OnRightUp)
|
|
ON_COMMAND(ID_RIGHTDOWN,OnRightDown)
|
|
ON_COMMAND(ID_CENTER,OnCenter)
|
|
|
|
ON_WM_CLOSE()
|
|
//}}AFX_MSG_MAP
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CCubicSetDlg::OnLeftUp()
|
|
{
|
|
basePointType=1;
|
|
}
|
|
void CCubicSetDlg::OnRightUp()
|
|
{
|
|
basePointType=2;
|
|
}
|
|
void CCubicSetDlg::OnRightDown()
|
|
{
|
|
basePointType=3;
|
|
}
|
|
void CCubicSetDlg::OnLeftDown()
|
|
{
|
|
basePointType=4;
|
|
}
|
|
void CCubicSetDlg::OnCenter()
|
|
{
|
|
basePointType=0;
|
|
}
|
|
void CCubicSetDlg::OnClose()
|
|
{
|
|
if (bCreate){
|
|
acedPostCommand(_T("\33"));
|
|
bDlgClosing=true;
|
|
}
|
|
else
|
|
SendMessage(WM_COMMAND,IDCANCEL);
|
|
}
|
|
void CCubicSetDlg::OnMore()
|
|
{
|
|
bMore=!bMore;
|
|
}
|
|
void CCubicSetDlg::On3d()
|
|
{
|
|
b3D=!b3D;
|
|
GetDlgItem(IDC_ELEV)->EnableWindow(b3D);
|
|
GetDlgItem(IDC_HEIGHT)->EnableWindow(b3D);
|
|
}
|
|
void CCubicSetDlg::OnNoCross()
|
|
{
|
|
crossMode=0;
|
|
}
|
|
void CCubicSetDlg::OnCrossA()
|
|
{
|
|
crossMode=1;
|
|
}
|
|
void CCubicSetDlg::OnCrossB()
|
|
{
|
|
crossMode=2;
|
|
}
|
|
void CCubicSetDlg::OnCrossC()
|
|
{
|
|
crossMode=3;
|
|
}
|
|
void CCubicSetDlg::OnDragMode()
|
|
{
|
|
makeMode=0;
|
|
GetDlgItem(IDC_WIDTH)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_LENGTH)->EnableWindow(FALSE);
|
|
m_toolbar.EnableButton(ID_LEFTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_LEFTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_CENTER,FALSE);
|
|
acedPostCommand(_T("\n"));
|
|
}
|
|
void CCubicSetDlg::OnInsertMode()
|
|
{
|
|
makeMode=1;
|
|
GetDlgItem(IDC_WIDTH)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_LENGTH)->EnableWindow(TRUE);
|
|
m_toolbar.EnableButton(ID_LEFTUP,TRUE);
|
|
m_toolbar.EnableButton(ID_RIGHTUP,TRUE);
|
|
m_toolbar.EnableButton(ID_RIGHTDOWN,TRUE);
|
|
m_toolbar.EnableButton(ID_LEFTDOWN,TRUE);
|
|
m_toolbar.EnableButton(ID_CENTER,TRUE);
|
|
acedPostCommand(_T("\n"));//INFORM RTNONE
|
|
}
|
|
void CCubicSetDlg::OnEdited()//解决关键字输入后有时仍需要按回车的问题(可能因为命令行键盘输入机制与全局键盘输入机制未能协调一致)
|
|
{
|
|
if (bInit)//第一个消息不处理
|
|
{
|
|
bInit=false;
|
|
return;
|
|
}
|
|
if (bDlgClosing)//最后一个消息不处理
|
|
return;
|
|
acedPostCommand(_T("\n"));
|
|
bEditChanged=true;
|
|
}
|
|
void CCubicSetDlg::Init(TDbRect&rect,bool bOut)
|
|
{
|
|
if (bOut)
|
|
{
|
|
if (!bCreate)//add by fxj 090415
|
|
{
|
|
if (length<1E-6 || width<1E-6)
|
|
{
|
|
|
|
adsout << _T("\n长或宽不能太小!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
XPoint ptCenter=rect.GetCenter(),ptBase0,ptBase1;
|
|
ptBase0=ptBase1=ptCenter;
|
|
if (!bCreate)//editing
|
|
{
|
|
switch(basePointType){
|
|
case 1:ptBase0=rect.GetUpLeft();break;
|
|
case 2:ptBase0=rect.GetUpRight();break;
|
|
case 3:ptBase0=rect.GetLowRight();break;
|
|
case 4:ptBase0=rect.GetLowLeft();break;
|
|
}
|
|
ptBase0.z=ptCenter.z;
|
|
}
|
|
rect.SetBaseFlag((TDbRect::BasePosition)basePointType);
|
|
rect.SetElevation(b3D?elev:0);
|
|
if (makeMode==1||!bCreate)//insert mode and editing
|
|
{
|
|
rect.SetSizeX(length);
|
|
rect.SetSizeY(width);
|
|
}
|
|
rect.SetSizeZ(b3D?height:0);
|
|
if (crossMode==0)
|
|
rect.SetRectFlag(0);
|
|
else if (crossMode==1)
|
|
rect.SetRectFlag(RF_DIA45);
|
|
else if (crossMode==2)
|
|
rect.SetRectFlag(RF_DIA135);
|
|
else
|
|
rect.SetRectFlag(RF_CROSSING);
|
|
if (!bCreate)//editing
|
|
{
|
|
switch(basePointType){
|
|
case 1:ptBase1=rect.GetUpLeft();break;
|
|
case 2:ptBase1=rect.GetUpRight();break;
|
|
case 3:ptBase1=rect.GetLowRight();break;
|
|
case 4:ptBase1=rect.GetLowLeft();break;
|
|
}
|
|
ptBase1.z=ptCenter.z;
|
|
ads_matrix mat;
|
|
ptBase1.GetMoveMatrix(ptBase0,mat);
|
|
rect.transformBy(AsAcGeMatrix3d(mat));
|
|
}
|
|
}else{
|
|
basePointType = (int)rect.GetBaseFlag();
|
|
elev=rect.GetElevation();
|
|
length=rect.GetSizeX();
|
|
width=rect.GetSizeY();
|
|
height=rect.GetSizeZ();
|
|
b3D=fabs(elev)>_DIST_SNAP||height>_DIST_SNAP;
|
|
if (rect.GetRectFlag()==0)
|
|
crossMode=0;
|
|
else if (rect.GetRectFlag()==RF_DIA45)
|
|
crossMode=1;
|
|
else if (rect.GetRectFlag()==RF_DIA135)
|
|
crossMode=2;
|
|
else
|
|
crossMode=3;
|
|
}
|
|
}
|
|
BOOL CCubicSetDlg::OnInitDialog()
|
|
{
|
|
CUIDlg::OnInitDialog();
|
|
if (!bCreate)
|
|
SetWindowText(_T("空间矩形编辑"));
|
|
GetDlgItem(IDC_ELEV)->EnableWindow(b3D);
|
|
GetDlgItem(IDC_HEIGHT)->EnableWindow(b3D);
|
|
if (bCreate){
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
CRect rect;
|
|
GetWindowRect(&rect);
|
|
SetWindowPos(NULL,rect.left,rect.top,rect.Width(),rect.Height()-22,0);
|
|
if (makeMode==0)//dragMode
|
|
{
|
|
GetDlgItem(IDC_LENGTH)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_WIDTH)->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
CreateToolBar();
|
|
UpdateData(false);
|
|
return TRUE;
|
|
}
|
|
void CCubicSetDlg::CreateToolBar()
|
|
{
|
|
CAcModuleResourceOverride vTmp;
|
|
m_toolbar.Create( WS_VISIBLE | WS_CHILD | CCS_TOP|TBSTYLE_TOOLTIPS
|
|
| CCS_ADJUSTABLE ,CRect(0,0,0,0),this, IDR_RECT);
|
|
|
|
TBBUTTON *pIndex, *pRTF_Button = new TBBUTTON[13];
|
|
pIndex = pRTF_Button;
|
|
for(long lIndex = 0; lIndex < 13; lIndex++)
|
|
{
|
|
memset(pIndex ,NULL, sizeof(TBBUTTON));
|
|
pIndex->iBitmap = lIndex;
|
|
pIndex->idCommand = buttonID[lIndex];
|
|
if (lIndex==2||lIndex==12)
|
|
pIndex->fsStyle=TBSTYLE_CHECK;
|
|
else
|
|
pIndex->fsStyle =TBSTYLE_CHECKGROUP;
|
|
pIndex->fsState = TBSTATE_ENABLED;
|
|
pIndex++;
|
|
}
|
|
|
|
CSize size(16, 15);
|
|
m_toolbar.SetButtonSize(size);
|
|
m_toolbar.AddButtons(13, pRTF_Button);
|
|
|
|
pIndex=new TBBUTTON;
|
|
memset(pIndex ,NULL, sizeof(TBBUTTON));
|
|
pIndex->fsStyle = TBSTYLE_SEP;
|
|
m_toolbar.InsertButton(2,pIndex);
|
|
m_toolbar.InsertButton(4,pIndex);
|
|
m_toolbar.InsertButton(9,pIndex);
|
|
m_toolbar.InsertButton(15,pIndex);
|
|
delete pIndex;
|
|
|
|
delete[] pRTF_Button;
|
|
|
|
m_toolbar.SetBitmapSize(size);
|
|
m_toolbar.ModifyStyle(0,TBSTYLE_FLAT);
|
|
m_toolbar.AddBitmap(13, IDR_RECT);
|
|
|
|
switch(basePointType){
|
|
case 0:m_toolbar.CheckButton(ID_CENTER,TRUE);break;
|
|
case 1:m_toolbar.CheckButton(ID_LEFTUP,TRUE);break;
|
|
case 2:m_toolbar.CheckButton(ID_RIGHTUP,TRUE);break;
|
|
case 3:m_toolbar.CheckButton(ID_RIGHTDOWN,TRUE);break;
|
|
case 4:m_toolbar.CheckButton(ID_LEFTDOWN,TRUE);break;
|
|
}
|
|
m_toolbar.CheckButton(buttonID[makeMode],TRUE);
|
|
m_toolbar.CheckButton(ID_3D,b3D);
|
|
m_toolbar.CheckButton(buttonID[crossMode+3],TRUE);
|
|
m_toolbar.CheckButton(ID_MORE,bMore);
|
|
|
|
if (!bCreate){
|
|
m_toolbar.EnableButton(ID_DRAG,FALSE);
|
|
m_toolbar.EnableButton(ID_INSERT,FALSE);
|
|
m_toolbar.EnableButton(ID_MORE,FALSE);
|
|
}
|
|
if (bCreate&&!IsInsertMode()){
|
|
m_toolbar.EnableButton(ID_LEFTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTUP,FALSE);
|
|
m_toolbar.EnableButton(ID_RIGHTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_LEFTDOWN,FALSE);
|
|
m_toolbar.EnableButton(ID_CENTER,FALSE);
|
|
}
|
|
}
|
|
BOOL CCubicSetDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
|
|
|
|
// if there is a top level routing frame then let it handle the message
|
|
if (GetRoutingFrame() != NULL) return FALSE;
|
|
|
|
// to be thorough we will need to handle UNICODE versions of the message also !!
|
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
|
//TCHAR szFullText[512];
|
|
CString strTipText;
|
|
// Zyu modify on 100723,消除64位编译警告
|
|
//UINT nID = pNMHDR->idFrom;
|
|
UINT nID = (UINT)pNMHDR->idFrom;
|
|
|
|
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
|
|
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) {
|
|
// idFrom is actually the HWND of the tool
|
|
//nID = ::GetDlgCtrlID((HWND)nID);
|
|
return FALSE;//Add by whl on 060308
|
|
}
|
|
|
|
if (nID != 0) {// will be zero on a separator
|
|
{
|
|
CAcModuleResourceOverride vTmp;
|
|
strTipText.LoadString(nID); //=szFullText;
|
|
}
|
|
|
|
#ifndef _UNICODE
|
|
if (pNMHDR->code == TTN_NEEDTEXTA) {
|
|
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
|
|
} else {
|
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#else
|
|
if (pNMHDR->code == TTN_NEEDTEXTA) {
|
|
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
|
|
} else {
|
|
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#endif
|
|
|
|
*pResult = 0;
|
|
|
|
// bring the tooltip window above other popup windows
|
|
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
|
|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
//COMMAND:
|
|
void CreateRectangle()
|
|
{
|
|
CCubicSetDlg dlg;
|
|
CAcModuleResourceOverride vTemp;
|
|
if (!dlg.Create())
|
|
return;
|
|
acedGetAcadFrame()->SetFocus();
|
|
TRectJig jig(&dlg);
|
|
CAcModuleResourceOverride resOverride(acedGetAcadResourceInstance());
|
|
jig.MakeIt();
|
|
dlg.DestroyWindow();
|
|
}
|
|
int EditRect(AcDbObjectId idRect)
|
|
{
|
|
OPENOBJ_BEGIN(idRect, AcDb::kForRead, TDbRect, pRect);
|
|
CAcModuleResourceOverride vTemp;
|
|
CCubicSetDlg dlg(false);
|
|
dlg.Init(*pRect,false);
|
|
if (dlg.DoModal()==IDOK) {
|
|
if (pRect->upgradeOpen()==Acad::eOk) {
|
|
pRect->assertWriteEnabled();
|
|
dlg.Init(*pRect);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
return RTNORM;
|
|
} |