home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / atltangram / atlmodel / atltangrammodel.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  120 lines

  1. // ATLTangramModel.h : Declaration of the CATLTangramModel
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #ifndef __ATLTANGRAMMODEL_H_
  14. #define __ATLTANGRAMMODEL_H_
  15.  
  16. #include "resource.h"       // main symbols
  17. #include "CPAtlModel.h"
  18. #include "ATLModel.h"
  19.  
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CATLTangramModel
  23. class ATL_NO_VTABLE CATLTangramModel :
  24.     public CComObjectRootEx<CComSingleThreadModel>,
  25.     public CComCoClass<CATLTangramModel, &CLSID_ATLTangramModel>,
  26.     public IConnectionPointContainerImpl<CATLTangramModel>,
  27.     public CProxyIATLTangramModelEvent<CATLTangramModel>,
  28.     public IATLTangramModel,
  29.     public IATLTangramTransform
  30. {
  31. public:
  32.     CATLTangramModel()
  33.     :   m_pVertices(NULL),
  34.         m_pTransformVertices(NULL),
  35.         m_cVertices(0),
  36.         m_dDegrees(0.0),        // Zero Degrees
  37.         m_cosDegrees(1.0),      // cos(0) = 1.0
  38.         m_sinDegrees(0.0)       // sin(0) = 0.0
  39.     {
  40.         m_ptdTranslate.x = 0.0 ;
  41.         m_ptdTranslate.y = 0.0 ;
  42.     }
  43.  
  44.     ~CATLTangramModel()
  45.     {
  46.         if (m_pVertices != NULL)
  47.         {
  48.             delete [] m_pVertices ;
  49.         }
  50.  
  51.         if (m_pTransformVertices != NULL)
  52.         {
  53.             delete [] m_pTransformVertices ;
  54.         }
  55.     }
  56.  
  57. #ifndef _LOCAL_SERVER
  58. DECLARE_REGISTRY_RESOURCEID(IDR_ATLTANGRAMMODEL)
  59. #else
  60. DECLARE_REGISTRY_RESOURCEID(IDR_IDRATLTANGRAMEXE)
  61. #endif
  62.  
  63. BEGIN_COM_MAP(CATLTangramModel)
  64.     COM_INTERFACE_ENTRY(IATLTangramModel)
  65.     COM_INTERFACE_ENTRY(IATLTangramTransform)
  66.     COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  67. END_COM_MAP()
  68.  
  69. BEGIN_CONNECTION_POINT_MAP(CATLTangramModel)
  70.     CONNECTION_POINT_ENTRY(IID_IATLTangramModelEvent)
  71. END_CONNECTION_POINT_MAP()
  72.  
  73.  
  74.  
  75. public:
  76.     // IATLTangramModel Methods
  77.     virtual HRESULT __stdcall GetNumberOfVertices(long* pNumVertices) ;
  78.     virtual HRESULT __stdcall GetVertices(long cVertices, TangramPoint2d* points) ;
  79.     virtual HRESULT __stdcall SetVertices(long cVertices, TangramPoint2d* points) ;
  80.  
  81.     // IATLTangramTransform
  82.     virtual HRESULT __stdcall Translate(double x, double y) ;
  83.     virtual HRESULT __stdcall GetTranslation(TangramPoint2d* point);
  84.     virtual HRESULT __stdcall Rotate(double fDegrees) ;
  85.     virtual HRESULT __stdcall GetRotation( double* pRotation) ;
  86.  
  87. // Internal Helper Functions
  88. private:
  89.     // Applies the current transform to the vertices.
  90.     void applyTransform() ;
  91.  
  92. // Members variables.
  93. private:
  94.     // Untransformed vertices in model co-ordinates.
  95.     TangramPoint2d* m_pVertices;
  96.  
  97.     // Transformed vertices in model co-ordintes.
  98.     TangramPoint2d* m_pTransformVertices ;
  99.  
  100.     // Number of vertices in this model.
  101.     int m_cVertices ;
  102.  
  103.     // Angle of rotation in degrees.
  104.     double m_dDegrees ;
  105.  
  106.     // Cache for the cos of the angle of rotation.
  107.     double m_cosDegrees;
  108.  
  109.     // Cache for the sin of the angle of rotation.
  110.     double m_sinDegrees;
  111.  
  112.     // Point to translate the origin.
  113.     TangramPoint2d m_ptdTranslate ;
  114.  
  115.     // Connection Point support
  116. //  IConnectionPoint* m_pConnectionPoint ;
  117. };
  118.  
  119. #endif //__ATLTANGRAMMODEL_H_
  120.