home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c11 / lab04 / ex02 / baseline / gpsrcdoc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.2 KB  |  140 lines

  1. // gpsrcDoc.cpp : implementation of the CGpsrcDoc class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "gpsrc.h"
  6.  
  7. #include "gpsrcDoc.h"
  8. #include "MainFrm.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CGpsrcDoc
  18.  
  19. IMPLEMENT_DYNCREATE(CGpsrcDoc, CDocument)
  20.  
  21. BEGIN_MESSAGE_MAP(CGpsrcDoc, CDocument)
  22.     //{{AFX_MSG_MAP(CGpsrcDoc)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CGpsrcDoc construction/destruction
  30.  
  31. CGpsrcDoc::CGpsrcDoc()
  32. {
  33.     // TODO: add one-time construction code here
  34.  
  35.     m_pSock= NULL;
  36. }
  37.  
  38. CGpsrcDoc::~CGpsrcDoc()
  39. {
  40. }
  41.  
  42.  
  43. BOOL CGpsrcDoc::OnNewDocument()
  44. {
  45.     if (!CDocument::OnNewDocument())
  46.         return FALSE;
  47.  
  48.     // TODO: add reinitialization code here
  49.     // (SDI documents will reuse this document)
  50.  
  51.  
  52.     // Create some Longitude/Latitude test points.
  53.     m_LonLat.Add("122W:08:35 47N:52:36");
  54.     m_LonLat.Add("122W:15:18 47N:55:34");
  55.     m_LonLat.Add("122W:23:39 47N:54:22");
  56.     m_LonLat.Add("122W:27:05 47N:50:44");
  57.     m_LonLat.Add("122W:22:10 47N:45:47");
  58.     m_LonLat.Add("122W:17:45 47N:44:21");
  59.     m_LonLat.Add("122W:10:33 47N:42:48");
  60.     m_LonLat.Add("122W:06:57 47N:38:11");
  61.     m_LonLat.Add("122W:12:41 47N:36:39");
  62.     m_LonLat.Add("122W:22:10 47N:37:05");
  63.     m_LonLat.Add("122W:27:34 47N:42:22");
  64.     m_LonLat.Add("122W:30:50 47N:46:00");
  65.     m_LonLat.Add("122W:31:10 47N:48:32");
  66.     m_LonLat.Add("122W:27:14 47N:54:55");
  67.     m_LonLat.Add("122W:19:33 47N:54:08");
  68.     m_LonLat.Add("122W:19:04 47N:48:51");
  69.     m_LonLat.Add("122W:19:23 47N:42:29");
  70.     m_LonLat.Add("122W:19:23 47N:39:43");
  71.     m_LonLat.Add("122W:19:13 47N:35:26");
  72.     m_LonLat.Add("122W:19:39 47N:35:00");
  73.     m_LonLat.Add("122W:15:18 47N:41:09");
  74.     m_LonLat.Add("122W:15:18 47N:43:41");
  75.     m_LonLat.Add("122W:15:28 47N:51:17");
  76.     m_LonLat.Add("122W:14:09 47N:57:00");
  77.     m_LonLat.Add("122W:08:45 47N:56:39");
  78.  
  79.     // Initialize the lon,lat array index.
  80.     m_curLonLat= 0;
  81.  
  82.  
  83.     return TRUE;
  84. }
  85. void CGpsrcDoc::DeleteContents()
  86. {
  87.     m_strings.RemoveAll();
  88.     UpdateAllViews(NULL);    // refresh our screen.
  89. }
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CGpsrcDoc serialization
  93.  
  94. void CGpsrcDoc::Serialize(CArchive& ar)
  95. {
  96.     if (ar.IsStoring())
  97.     {
  98.         // TODO: add storing code here
  99.     }
  100.     else
  101.     {
  102.         // TODO: add loading code here
  103.     }
  104. }
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107. // CGpsrcDoc diagnostics
  108.  
  109. #ifdef _DEBUG
  110. void CGpsrcDoc::AssertValid() const
  111. {
  112.     CDocument::AssertValid();
  113. }
  114.  
  115. void CGpsrcDoc::Dump(CDumpContext& dc) const
  116. {
  117.     CDocument::Dump(dc);
  118. }
  119. #endif //_DEBUG
  120.  
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CGpsrcDoc commands
  123.  
  124. void CGpsrcDoc::SendPosition()
  125. {
  126.     if (m_pSock) 
  127.     {
  128.         CString lonlat= m_LonLat.GetAt(m_curLonLat);
  129.         m_strings.Add(lonlat);
  130.         UpdateAllViews(NULL);    // refresh our screen.
  131.  
  132.         // Recycle points if we need to.
  133.         if (++m_curLonLat>= m_LonLat.GetSize())
  134.             m_curLonLat= 0;
  135.  
  136.  
  137.     }
  138. }
  139.  
  140.