#pragma once #include "acgi.h" #include #include "gs.h" #include "AcGsManager.h" #ifdef EARTHWORM_EXPORT #define DLLIMPEXP __declspec(dllexport) #else #define DLLIMPEXP __declspec(dllimport) #endif class AcGsManager; class OrbitGadgetEx : public AcGiDrawable { AcGsNode* m_pNode; AcGsView* m_pAcGsView; public: OrbitGadgetEx():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 }; class DLLIMPEXP CGsPreviewCtrlEx : public CStatic { public: //{{AFX_VIRTUAL(CGsPreviewCtrlEx) //}}AFX_VIRTUAL public: CGsPreviewCtrlEx() : CStatic(), mpManager(NULL), mpFactory(NULL), mpDevice(NULL), mpView(NULL), mpModel(NULL),mbModelCreated(false),mbPanning(false),mbOrbiting(false) { mZooming = false; mMouseDown = false; mMouseMoving = false; m_rcCell.SetRect(0,0,0,0); m_nMaxFlag = 0; } virtual ~CGsPreviewCtrlEx() {clearAll();} void init(HMODULE hRes, bool bCreateModel = true); void erasePreview(); void clearAll(); void SetCellRect(const CRect& rcCell){m_rcCell = rcCell;} void GetCellRect(CRect& rcCell){rcCell = m_rcCell;} void SetMaxFlag(int nFlag){m_nMaxFlag = nFlag;} int GetMaxFlag() const {return m_nMaxFlag;} AcGsView* view() { return mpView; } AcGsDevice* device() { return mpDevice; } AcGsModel* model() { return mpModel; } void setModel(AcGsModel* pModel); void RubberRectangle(CPoint startPt, CPoint endPt); protected: //{{AFX_MSG(CGsPreviewCtrlEx) 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 _MSC_VER < 1400 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 DECLARE_MESSAGE_MAP() public: void RefreshView(); void OnZoomExtents(AcDbDatabase* pDb); public: HCURSOR mhSavedCursor; HCURSOR mhPanCursor; HCURSOR mhCrossCursor; HCURSOR mhOrbitCursor; AcGsManager * mpManager; #if (ARX > 19) AcGsGraphicsKernel *mpFactory; #else AcGsClassFactory *mpFactory; #endif AcGsDevice * mpDevice; AcGsView * mpView; AcGsModel * mpModel; AcGsModel * mpGhostModel; OrbitGadgetEx mOrbitGadget; bool mbModelCreated; bool mbPanning; bool mbOrbiting; CPoint mStartPt; bool mZooming; bool mMouseDown; bool mMouseMoving; CPoint mEndPt; CRect m_rcCell; int m_nMaxFlag; }; //{{AFX_INSERT_LOCATION}}