162 lines
4.6 KiB
C++
162 lines
4.6 KiB
C++
#if !defined(AFX_GSPREVIEWCTRL_H__7DC11025_C827_11D2_B89C_080009DCA551__INCLUDED_)
|
|
#define AFX_GSPREVIEWCTRL_H__7DC11025_C827_11D2_B89C_080009DCA551__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
// GsPreviewCtrl.h : header file
|
|
//
|
|
#include "acgi.h"
|
|
#include "gs.h"
|
|
#include "acgs.h"
|
|
#include <math.h>
|
|
// Simple lighweight drawable to do orbit glyph
|
|
//
|
|
class TARCH_EXP OrbitGadget : public AcGiDrawable
|
|
{
|
|
AcGsNode* m_pNode;
|
|
AcGsView* m_pAcGsView;
|
|
public:
|
|
|
|
OrbitGadget():m_pNode(NULL) {}
|
|
void setGsView(AcGsView* pView) {m_pAcGsView=pView;}
|
|
|
|
virtual Adesk::UInt32 subSetAttributes (AcGiDrawableTraits * traits)
|
|
{
|
|
traits->setTrueColor (AcCmEntityColor(0,200,0));
|
|
return kDrawableNone;
|
|
}
|
|
virtual Adesk::Boolean subWorldDraw (AcGiWorldDraw * wd)
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
virtual void subViewportDraw (AcGiViewportDraw * pViewportDraw)
|
|
{
|
|
AcGsDCRect view_rect;
|
|
m_pAcGsView->getViewport (view_rect);
|
|
|
|
int nViewportX = (view_rect.m_max.x - view_rect.m_min.x) + 1;
|
|
int nViewportY = (view_rect.m_max.y - view_rect.m_min.y) + 1;
|
|
AcGeMatrix3d scale = m_pAcGsView->viewingMatrix() * m_pAcGsView->worldToDeviceMatrix().inverse();
|
|
AcGeVector3d viewDir = m_pAcGsView->target()-m_pAcGsView->position();
|
|
const double radius = min (nViewportX, nViewportY) * 0.4f*scale.scale();
|
|
|
|
pViewportDraw->geometry().circle(m_pAcGsView->target(),radius,viewDir);
|
|
return;
|
|
}
|
|
virtual Adesk::Boolean isPersistent (void) const
|
|
{
|
|
return Adesk::kFalse;
|
|
};
|
|
virtual AcDbObjectId id (void) const
|
|
{
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
#if (ADS <= 19)
|
|
virtual void setGsNode (AcGsNode * gsnode)
|
|
{
|
|
m_pNode = gsnode;
|
|
}
|
|
virtual AcGsNode* gsNode (void) const
|
|
{
|
|
return m_pNode;
|
|
}
|
|
#endif
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGsPreviewCtrl window
|
|
|
|
#define OBF_ORBIT 0x01
|
|
#define OBF_ZOOM 0x02
|
|
#define OBF_PAN 0x04
|
|
class TARCH_EXP CGsPreviewCtrl : public CStatic
|
|
{
|
|
|
|
public:
|
|
DECLARE_DYNAMIC(ATSCGsPreviewCtrl)
|
|
// Overrides
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CGsPreviewCtrl)
|
|
public:
|
|
virtual BOOL DestroyWindow();
|
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
//}}AFX_VIRTUAL
|
|
|
|
|
|
public:
|
|
CGsPreviewCtrl(int nOrbitFlag=0);
|
|
virtual ~CGsPreviewCtrl() {
|
|
clearAll();
|
|
//::SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
}
|
|
void init(bool bCreateModel = true);
|
|
void erasePreview();
|
|
void clearAll();
|
|
|
|
void Invalidate(BOOL bErase=TRUE);
|
|
|
|
AcGsView* view() { return mpView; }
|
|
AcGsDevice* device() { return mpDevice; }
|
|
AcGsModel* model() { return mpModel; }
|
|
void setModel(AcGsModel* pModel);
|
|
void SetOrbitFlag(int nFlag) { mOrbitFlag=nFlag; }
|
|
int GetOrbitFlag() { return mOrbitFlag; }
|
|
void SetAngStep(double val) { mAngStep=val;}
|
|
void SetDistStep(double val) { mDistStep=val;}
|
|
// Generated message map functions
|
|
protected:
|
|
//{{AFX_MSG(CGsPreviewCtrl)
|
|
afx_msg void OnPaint();
|
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
|
|
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
|
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
|
|
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
|
|
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
|
#if ADS<17
|
|
afx_msg UINT OnNcHitTest(CPoint point);
|
|
#else
|
|
afx_msg LRESULT OnNcHitTest(CPoint point);
|
|
#endif
|
|
afx_msg void OnSetFocus(CWnd* pOldWnd);
|
|
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
|
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
|
|
//}}AFX_MSG
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
protected:
|
|
HCURSOR mhSavedCursor;
|
|
HCURSOR mhPanCursor;
|
|
HCURSOR mhCrossCursor;
|
|
HCURSOR mhOrbitCursor;
|
|
AcGsManager *mpManager;
|
|
#if (ADS > 19)
|
|
AcGsGraphicsKernel *mpFactory;
|
|
#else
|
|
AcGsClassFactory *mpFactory;
|
|
#endif
|
|
AcGsDevice *mpDevice;
|
|
AcGsView *mpView;
|
|
AcGsModel *mpModel;
|
|
AcGsModel *mpGhostModel;
|
|
OrbitGadget mOrbitGadget;
|
|
bool mbModelCreated;
|
|
bool mbPanning;
|
|
bool mbOrbiting;
|
|
CPoint mStartPt;
|
|
|
|
int mOrbitFlag;
|
|
|
|
double mDistStep; //移动最小距离
|
|
double mAngStep; //最小旋转角度
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
|
|
#endif // !defined(AFX_GSPREVIEWCTRL_H__7DC11025_C827_11D2_B89C_080009DCA551__INCLUDED_)
|