Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: SurfaceCLD.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of SurfaceCLD.cpp
  13. //----------------------------------------------------------------------------
  14. // SurfaceCLD.cpp: implementation of the CSurfaceCLD class.
  15. //
  16. //////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "SurfaceCLD.h"
  19. #include "..\..\LgLib\LgAux.h"
  20. #include "..\..\LgLib\Version.h"
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char THIS_FILE[]=__FILE__;
  24. #define new DEBUG_NEW
  25. #endif
  26. CSurfaceCLD::CSurfaceCLD()
  27. {
  28. m_dRange = 100.0;
  29. m_dScale = 1.0;
  30. m_dDR = asin( 1.0 ) / 90.0;
  31. m_dCommonZero = 0;
  32. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSurfaceCLD::CSurfaceCLD") );
  33. }
  34. CSurfaceCLD::~CSurfaceCLD()
  35. {
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CSurfaceCLD::~CSurfaceCLD") );
  37. }
  38. void CSurfaceCLD::DrawTarget( double range, COLORREF color )
  39. {
  40. int hx = GetSize().cx / 2;
  41. int hy = GetSize().cy / 2;
  42. int x = (INT)( cos( m_dCommonZero * m_dDR ) * range * 2 * hx / ( m_dScale * m_dRange ) ) + hx;
  43. int y = (INT)( -sin( m_dCommonZero * m_dDR ) * range * 2 * hy / ( m_dScale * m_dRange ) ) + hy;
  44. int rx = (INT)( cos( m_dCommonZero * m_dDR ) * m_dRange * hx / ( m_dScale * m_dRange ) );
  45. int ry = (INT)( -sin( m_dCommonZero * m_dDR ) * m_dRange * hy / ( m_dScale * m_dRange ) );
  46. x -= rx;
  47. y -= ry;
  48. CPen pen( PS_SOLID, 1, color );
  49. CBrush brush( color );
  50. CPen *pPen = (CPen*)SelectObject( &pen );
  51. CBrush *pBrush = (CBrush*)SelectObject( &brush );
  52. CRect rect( x - 2, y - 2, x + 2, y + 2 );
  53. Ellipse( &rect );
  54. SelectObject( pPen );
  55. SelectObject( pBrush );
  56. }
  57. void CSurfaceCLD::Create( int cx, int cy, COLORREF color )
  58. {
  59. COLORREF LsgColor[] = { RGB( 0, 0x6F, 0 ), RGB( 0, 0x5F, 0 ), RGB( 0x7F, 0x7F, 0 ), RGB( 0x7F, 0x7F, 0x7F ) };
  60. CLgMemoryDC::Create( cx, cy, LsgColor[1] );
  61. int hx = GetSize().cx / 2;
  62. int hy = GetSize().cy / 2;
  63. // fill all field
  64. {
  65. CRect rect( 0, 0, GetSize().cx, GetSize().cy );
  66. CBrush brush( RGB( 0, 0x5F, 0 ) );
  67. FillRect( &rect, &brush );
  68. }
  69. // draw guarded line
  70. int x = (INT)( cos( m_dCommonZero * m_dDR ) * m_dRange * hx / ( m_dScale * m_dRange ) );
  71. int y = (INT)( -sin( m_dCommonZero * m_dDR ) * m_dRange * hy / ( m_dScale * m_dRange ) );
  72. CPen pen( PS_SOLID, 3, RGB( 0x7F, 0x7F, 0 ) );
  73. CPen *pPen = (CPen*)SelectObject( &pen );
  74. CBrush brush( RGB( 0x7F, 0x7F, 0 ) );
  75. CBrush *pBrush = (CBrush*)SelectObject( &brush );
  76. MoveTo( hx - x, hy - y );
  77. LineTo( hx + x, hy + y );
  78. CRect rect( hx - x - 5, hy - y - 5, hx - x + 5, hy - y + 5 );
  79. Ellipse( &rect );
  80. SelectObject( pBrush );
  81. SelectObject( pPen );
  82. }
  83. void CSurfaceCLD::SetRange( double dRange )
  84. {
  85. m_dRange = dRange;
  86. Create( GetSize().cx, GetSize().cy );
  87. }
  88. void CSurfaceCLD::SetCommonZero( double dCommonZero )
  89. {
  90. m_dCommonZero = dCommonZero;
  91. Create( GetSize().cx, GetSize().cy );
  92. }