181 lines
5.0 KiB
C++
181 lines
5.0 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
|
|
|
|
#include "acgi.h"
|
|
#include "gs.h"
|
|
#include "acgs.h"
|
|
|
|
#ifdef EARTHWORM_EXPORT
|
|
#define DLLIMPEXP __declspec(dllexport)
|
|
#else
|
|
#define DLLIMPEXP __declspec(dllimport)
|
|
#endif
|
|
|
|
class OrbitGadget : public AcGiDrawable
|
|
{
|
|
AcGsNode* m_pNode;
|
|
AcGsView* m_pAcGsView;
|
|
public:
|
|
|
|
OrbitGadget() :m_pNode(NULL) {}
|
|
void setGsView(AcGsView* pView) { m_pAcGsView = pView; }
|
|
#if ARX > 17
|
|
virtual Adesk::UInt32 subSetAttributes(AcGiDrawableTraits * traits)
|
|
#else
|
|
virtual Adesk::UInt32 setAttributes(AcGiDrawableTraits * traits)
|
|
#endif
|
|
{
|
|
traits->setTrueColor(AcCmEntityColor(0, 200, 0));
|
|
return kDrawableNone;
|
|
}
|
|
#if ARX > 17
|
|
virtual Adesk::Boolean subWorldDraw(AcGiWorldDraw * wd)
|
|
#else
|
|
virtual Adesk::Boolean worldDraw(AcGiWorldDraw * wd)
|
|
#endif
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
#if ARX > 17
|
|
virtual void subViewportDraw(AcGiViewportDraw * pViewportDraw)
|
|
#else
|
|
virtual void viewportDraw(AcGiViewportDraw * pViewportDraw)
|
|
#endif
|
|
{
|
|
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 (ARX <= 19)
|
|
virtual void setGsNode(AcGsNode * gsnode)
|
|
{
|
|
m_pNode = gsnode;
|
|
}
|
|
virtual AcGsNode* gsNode(void) const
|
|
{
|
|
return m_pNode;
|
|
}
|
|
#endif
|
|
};
|
|
|
|
#define OBF_ORBIT 0x01
|
|
#define OBF_ZOOM 0x02
|
|
#define OBF_PAN 0x04
|
|
#define OBF_COTE 0x08
|
|
class DLLIMPEXP CGsPreviewCtrl : public CStatic
|
|
{
|
|
|
|
public:
|
|
DECLARE_DYNAMIC(CGsPreviewCtrl)
|
|
//{{AFX_VIRTUAL(CGsPreviewCtrl)
|
|
public:
|
|
virtual BOOL DestroyWindow();
|
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
//}}AFX_VIRTUAL
|
|
|
|
|
|
public:
|
|
CGsPreviewCtrl(int nOrbitFlag = 0);
|
|
virtual ~CGsPreviewCtrl()
|
|
{
|
|
clearAll();
|
|
}
|
|
void init(bool bCreateModel = true);
|
|
void erasePreview();
|
|
void clearAll();
|
|
|
|
void RefreshView();
|
|
void OnZoomExtents(AcDbDatabase* pDb);
|
|
|
|
void Invalidate(BOOL bErase = TRUE);
|
|
void InitFromCurrentView2D(const AcDbExtents& exts,bool bRestTarget = false);
|
|
void InitFromCurrentView3D(const AcDbExtents& exts,bool bRestTarget = false);
|
|
BOOL GetCurrentViewInfo(AcGePoint3d & ptPosition, AcGePoint3d & ptTarget, AcGeVector3d& vecUpVector, double& dFieldWidth, double& dFieldHeight);
|
|
BOOL GetCurrentViewInfo(const AcDbExtents& exts, AcGePoint3d & ptPosition, AcGePoint3d & ptTarget, AcGeVector3d& vecUpVector, double& dFieldWidth, double& dFieldHeight);
|
|
BOOL GetActiveViewPortInfo(double &dHeight, double &dWidth, AcGePoint3d &ptTarget, AcGeVector3d &vecViewDir, double &dViewTwist, BOOL bGetViewCenter);
|
|
BOOL Add(AcDbEntity* pEnt);
|
|
|
|
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; }
|
|
|
|
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);
|
|
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
|
|
#if ARX<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()
|
|
|
|
public:
|
|
HCURSOR mhSavedCursor;
|
|
HCURSOR mhPanCursor;
|
|
HCURSOR mhCrossCursor;
|
|
HCURSOR mhOrbitCursor;
|
|
HCURSOR mhEditCursor;
|
|
AcGsManager *mpManager;
|
|
#if (ARX > 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;
|
|
public:
|
|
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
|
};
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
#endif // !defined(AFX_GSPREVIEWCTRL_H__7DC11025_C827_11D2_B89C_080009DCA551__INCLUDED_)
|