409 lines
9.9 KiB
C++
409 lines
9.9 KiB
C++
#include "stdafx.h"
|
|
#include "FullScreenDlg.h"
|
|
#include "dbsymutl.h"
|
|
#include "dbcfilrs.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
CFullScreenDlg::CFullScreenDlg(CWnd* pParent /*=NULL*/)
|
|
: GlwCAcUiDialog(CFullScreenDlg::IDD, pParent), m_bUseModelSpace(TRUE)
|
|
{
|
|
//{{AFX_DATA_INIT(CFullScreenDlg)
|
|
//}}AFX_DATA_INIT
|
|
if (DocGetDrawMode()==DRAW_2D)
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_ZOOM|OBF_PAN);
|
|
else
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_ZOOM|OBF_PAN|OBF_ORBIT);
|
|
}
|
|
|
|
CFullScreenDlg::~CFullScreenDlg()
|
|
{
|
|
AcDbBlockTableRecord *pBlock=NULL;
|
|
Acad::ErrorStatus es=acdbOpenObject(pBlock, m_idBlock, AcDb::kForWrite);
|
|
if (pBlock && es==Acad::eOk) {
|
|
pBlock->erase();
|
|
pBlock->close();
|
|
}
|
|
}
|
|
|
|
void CFullScreenDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CFullScreenDlg)
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CFullScreenDlg, GlwCAcUiDialog)
|
|
//{{AFX_MSG_MAP(CFullScreenDlg)
|
|
ON_WM_ERASEBKGND()
|
|
ON_WM_CONTEXTMENU()
|
|
ON_COMMAND(ID_FLAT_SHADE, OnFlatShade)
|
|
ON_COMMAND(ID_FLAT_SHADE1, OnFlatShade1)
|
|
ON_COMMAND(ID_GROUND_SHADE, OnGroundShade)
|
|
ON_COMMAND(ID_GROUND_SHADE1, OnGroundShade1)
|
|
ON_COMMAND(ID_HIDE_WIRE, OnHideWire)
|
|
ON_COMMAND(ID_ESCAPE, OnEscape)
|
|
ON_COMMAND(ID_3DWIRE, On3dwire)
|
|
ON_COMMAND(ID_2DWIRE, On2dwire)
|
|
ON_WM_KEYDOWN()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
BOOL CFullScreenDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
m_menu.LoadMenu(IDR_FULLVIEW);
|
|
|
|
// 子类化控件对象
|
|
if (!m_wndViewCtrl.SubclassDlgItem(IDC_VIEWCONTROL, this))
|
|
{
|
|
// 错误时,结束对话框
|
|
EndDialog(IDCANCEL);
|
|
return FALSE;
|
|
}
|
|
|
|
// 取得屏幕尺寸
|
|
int iWidth = GetSystemMetrics(SM_CXSCREEN);
|
|
int iHeight = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
// 调整对话框和控件到屏幕尺寸
|
|
MoveWindow(0, 0, iWidth, iHeight, FALSE);
|
|
m_wndViewCtrl.MoveWindow(0, 0, iWidth, iHeight, FALSE);
|
|
|
|
// 初始化控件
|
|
m_wndViewCtrl.clearAll();
|
|
m_wndViewCtrl.init(true);
|
|
//m_wndViewCtrl.mbEnableOrbit=false;
|
|
{
|
|
// 取得当前视口的视
|
|
int iVPortNum = 0;
|
|
xg_setvar(_T("CMDECHO"), 0);
|
|
xg_getvar(_T("CVPORT"), &iVPortNum);
|
|
//acgsWriteViewToUndoController(iVPortNum);
|
|
AcGsView* pView = acgsGetGsView(iVPortNum, false);
|
|
// 取得控件中的视,设置视属性
|
|
AcGsView *pView1 = m_wndViewCtrl.view();
|
|
ASSERT(pView1);
|
|
//AcGsView::RenderMode mode;
|
|
if (!pView) {
|
|
//modify by xlc on 090806 R18移植
|
|
#if ADS<18
|
|
AcGsView::RenderMode mode=pView1->mode();
|
|
#else
|
|
AcGiVisualStyle mode=AcGiVisualStyle::kBasic;
|
|
pView1->visualStyle(mode);
|
|
#endif
|
|
//bCrt=true;
|
|
//pView=acgsGetGsView(iVPortNum, true);
|
|
//ASSERT(pView);
|
|
//mode = AcGsView::k2DOptimized;
|
|
double nWidth, nHeight;
|
|
AT_ScrSize(&nWidth, &nHeight);
|
|
XPoint vtViewDir;
|
|
VERIFY(xg_getvar(_T("VIEWDIR"), &vtViewDir)==RTNORM);
|
|
vtViewDir=Ucs2Wcs(vtViewDir, TRUE);
|
|
XPoint target;
|
|
VERIFY(xg_getvar(_T("VIEWCTR"), &target)==RTNORM);
|
|
int nViewMode=0;
|
|
xg_getvar(_T("VIEWMODE"), &nViewMode);
|
|
target=Ucs2Wcs(target);
|
|
XPoint camera=target+vtViewDir;
|
|
AcGeVector3d vtUp(0,0,1);
|
|
((AcGeVector3d &)vtViewDir).normalize();
|
|
if (vtViewDir.AsAcGeVector3d()==vtUp)
|
|
vtUp=AcGeVector3d(0,1,0);
|
|
//modify by xlc on 090806 R18移植
|
|
#if ADS<18
|
|
pView1->setMode(AcGsView::k2DOptimized);
|
|
#else
|
|
pView1->setVisualStyle(AcGiVisualStyle::k2DWireframe);
|
|
#endif
|
|
pView1->setView(camera, target, vtUp, nWidth, nHeight, (nViewMode&0x01)? AcGsView::kPerspective : AcGsView::kParallel);
|
|
} else {
|
|
#if ADS<18
|
|
pView1->setMode(pView->mode());
|
|
#else
|
|
pView1->setVisualStyle(pView->visualStyle());
|
|
#endif
|
|
AcGePoint3d position = pView->position();
|
|
AcGePoint3d target = pView->target();
|
|
AcGeVector3d upvector = pView->upVector();
|
|
double dWidth = pView->fieldWidth();
|
|
double dHeight = pView->fieldHeight();
|
|
pView1->setView(position, target, upvector, dWidth, dHeight, pView->isPerspective()? AcGsView::kPerspective : AcGsView::kParallel);
|
|
pView1->setEnableBackClip(pView->isBackClipped());
|
|
pView1->setBackClip(pView->backClip());
|
|
pView1->setEnableFrontClip(pView->isFrontClipped());
|
|
pView1->setFrontClip(pView->frontClip());
|
|
}
|
|
|
|
|
|
//k2DOptimized
|
|
// 取得视中的属性
|
|
//acedGetAcadDwgView()->LockWindowUpdate();
|
|
|
|
// 取得模型空间块表记录,并加入到控件视中
|
|
AcDbObjectId idMSpace = acdbSymUtil()->blockModelSpaceId(acdbCurDwg());
|
|
AcDbObjectIdArray idArray;
|
|
OPENOBJ_BEGIN(idMSpace, AcDb::kForRead, AcDbBlockTableRecord, pMspace);
|
|
if (!m_bUseModelSpace) {
|
|
AcDbBlockTableRecordIterator *pIterator=NULL;
|
|
VERIFY(pMspace->newIterator(pIterator)==Acad::eOk);
|
|
for (pIterator->start(); !pIterator->done(); pIterator->step()) { // 遍历块中实体
|
|
AcDbObjectId idObj;
|
|
if (pIterator->getEntityId(idObj)==Acad::eOk) {
|
|
idArray.append(idObj);
|
|
}
|
|
}
|
|
delete pIterator;
|
|
|
|
AcDbBlockTableRecord *pTempBlock = new AcDbBlockTableRecord;
|
|
pTempBlock->setName(_T("*U"));
|
|
const TCHAR *pszName=NULL;
|
|
pTempBlock->getName(pszName);
|
|
m_idBlock=AddBlock(pTempBlock, TRUE);
|
|
if (!m_idBlock) {
|
|
delete pTempBlock;
|
|
pTempBlock=NULL;
|
|
}
|
|
|
|
AcDbIdMapping idMap; // 定义映射对象
|
|
// 调用deepCloneObjects()函数将选中的目标复制到块表中;
|
|
if (pTempBlock && acdbCurDwg()->deepCloneObjects(idArray, m_idBlock, idMap)==Acad::eOk) {
|
|
pView1->add(pTempBlock, m_wndViewCtrl.model());
|
|
} else {
|
|
pView1->add(pMspace, m_wndViewCtrl.model());
|
|
}
|
|
} else {
|
|
pView1->add(pMspace, m_wndViewCtrl.model());
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
// 刷新控件显示
|
|
/*
|
|
AcGsModel *pModel=m_wndViewCtrl.model();
|
|
if (pModel)
|
|
pModel->invalidate(AcGsModel::kInvalidateViewportCache);
|
|
*/
|
|
//AcGsView *pView1=m_wndViewCtrl.view();
|
|
//if (pView1)
|
|
// pView1->invalidateCachedViewportGeometry();
|
|
m_wndViewCtrl.Invalidate();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CFullScreenDlg::OnEraseBkgnd(CDC* pDC)
|
|
{
|
|
// 不需要擦除背景, 减少闪烁
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CFullScreenDlg::DestroyWindow()
|
|
{
|
|
// 退出清除
|
|
if (IsWindow(m_wndViewCtrl.m_hWnd))
|
|
{
|
|
m_wndViewCtrl.clearAll();
|
|
acedGetAcadDwgView()->UnlockWindowUpdate();
|
|
acedCommand(RTSTR, _T("UNDO"), RTSTR, _T(""), RTNONE);
|
|
}
|
|
|
|
return CDialog::DestroyWindow();
|
|
}
|
|
|
|
|
|
|
|
//#include _T("FullScreenDlg.h")
|
|
|
|
|
|
|
|
void CFullScreenDlg::OnContextMenu(CWnd* pWnd, CPoint point)
|
|
{
|
|
// TODO: Add your message handler code here
|
|
CMenu *pMenu = m_menu.GetSubMenu(0);
|
|
if (pMenu) {
|
|
pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
|
|
point.x, point.y, this, NULL);
|
|
}
|
|
}
|
|
|
|
|
|
void CFullScreenDlg::Set3DView(
|
|
#if ADS<18
|
|
AcGsView::RenderMode mode
|
|
#else
|
|
AcGiVisualStyle mode
|
|
#endif
|
|
)
|
|
{
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_PAN|OBF_ZOOM|OBF_ORBIT);
|
|
AcGsView *pView=m_wndViewCtrl.view();
|
|
if (pView) {
|
|
DocSetDrawMode(DRAW_3D);
|
|
#if ADS<18
|
|
pView->setMode(mode);
|
|
#else
|
|
pView->setVisualStyle(mode);
|
|
#endif
|
|
AcGsModel *pModel=m_wndViewCtrl.model();
|
|
if (pModel)
|
|
pModel->invalidate(AcGsModel::kInvalidateAll);
|
|
//pView->invalidateCachedViewportGeometry();
|
|
m_wndViewCtrl.Invalidate();
|
|
}
|
|
}
|
|
|
|
void CFullScreenDlg::OnFlatShade()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kFlatShaded
|
|
#else
|
|
AcGiVisualStyle::kFlat
|
|
#endif
|
|
);
|
|
}
|
|
|
|
void CFullScreenDlg::OnFlatShade1()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kFlatShadedWithWireframe
|
|
#else
|
|
AcGiVisualStyle::kFlatWithEdges
|
|
#endif
|
|
);
|
|
}
|
|
|
|
void CFullScreenDlg::OnGroundShade()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kGouraudShaded
|
|
#else
|
|
AcGiVisualStyle::kGouraud
|
|
#endif
|
|
);
|
|
}
|
|
|
|
void CFullScreenDlg::OnGroundShade1()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kGouraudShadedWithWireframe
|
|
#else
|
|
AcGiVisualStyle::kGouraudWithEdges
|
|
#endif
|
|
);
|
|
|
|
}
|
|
|
|
void CFullScreenDlg::OnHideWire()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kHiddenLine
|
|
#else
|
|
AcGiVisualStyle::kHidden
|
|
#endif
|
|
);
|
|
|
|
}
|
|
|
|
void CFullScreenDlg::OnEscape()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
EndDialog(IDCANCEL);
|
|
|
|
}
|
|
|
|
void CFullScreenDlg::On3dwire()
|
|
{
|
|
Set3DView(
|
|
#if ADS<18
|
|
AcGsView::kWireframe
|
|
#else
|
|
AcGiVisualStyle::k3DWireframe
|
|
#endif
|
|
);
|
|
}
|
|
|
|
void CFullScreenDlg::On2dwire()
|
|
{
|
|
// TODO: Add your command handler code here
|
|
m_wndViewCtrl.SetOrbitFlag(OBF_PAN|OBF_ZOOM);
|
|
AcGsView *pView=m_wndViewCtrl.view();
|
|
if (pView) {
|
|
DocSetDrawMode(DRAW_2D);
|
|
|
|
AcGsModel *pModel=m_wndViewCtrl.model();
|
|
if (pModel)
|
|
pModel->invalidate(AcGsModel::kInvalidateAll);
|
|
|
|
//modify by xlc on 090806 R18移植
|
|
#if ADS<18
|
|
pView->setMode(AcGsView::k2DOptimized);
|
|
#else
|
|
pView->setVisualStyle(AcGiVisualStyle::k2DWireframe);
|
|
#endif
|
|
double nWidth=pView->fieldWidth();
|
|
double nHeight=pView->fieldHeight();
|
|
//AT_ScrSize(&nWidth, &nHeight);
|
|
XPoint vtViewDir(0,0,1);
|
|
XPoint target=pView->target();
|
|
//VERIFY(xg_getvar(_T("VIEWCTR"), &target)==RTNORM);
|
|
//target=Ucs2Wcs(target);
|
|
XPoint camera=target+vtViewDir;
|
|
AcGeVector3d vtUp(0,1,0);
|
|
pView->setView(camera, target, vtUp, nWidth, nHeight);
|
|
//pView->invalidateCachedViewportGeometry();
|
|
m_wndViewCtrl.Invalidate();
|
|
}
|
|
}
|
|
|
|
// 全屏显示当前视口,命令:FullScreenView
|
|
void FullScreenView()
|
|
{
|
|
// 判断当前是否为模型空间
|
|
int iTileMode = 0;
|
|
xg_getvar(_T("TILEMODE"), &iTileMode);
|
|
if (iTileMode == 0)
|
|
adsout << _T("\n请切换到模型空间使用该命令!");
|
|
|
|
//DList<TViewportInfo> vpInfo;
|
|
//ReadVports(vpInfo);
|
|
int nOldMode=DocGetDrawMode();
|
|
BOOL bUseMSpace=(nOldMode!=DRAW_2D+DRAW_3D);
|
|
|
|
int nDrawMode=IsExplode3D();
|
|
DocSetDrawMode(nDrawMode==0? DRAW_2D:DRAW_3D);
|
|
//DocSetDrawMode(DRAW_2D);
|
|
|
|
// 显示全屏窗口
|
|
CFullScreenDlg dlg(acedGetAcadFrame());
|
|
CAcModuleResourceOverride vTemp;
|
|
dlg.SetUseModelSpace(bUseMSpace);
|
|
dlg.DoModal();
|
|
DocSetDrawMode(nOldMode);
|
|
}
|
|
|
|
void CFullScreenDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
// TODO: Add your message handler code here and/or call default
|
|
|
|
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
|
|
}
|