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.

137 lines
4.0 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: HiddenZoneList.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of HiddenZoneList.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "HiddenZoneList.h"
  16. #include "HiddenZone.h"
  17. #include "..\..\LgLib\LgAux.h"
  18. #include "..\..\LgLib\Version.h"
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char THIS_FILE[]=__FILE__;
  22. #define new DEBUG_NEW
  23. #endif
  24. BOOL CHiddenZoneList::Draw( CDC *pDC, CPoint *pCenter, double dScaleToPixel, double dRotateAngle )
  25. {
  26. // log info
  27. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CHiddenZoneList::Draw", "Start..." );
  28. const COLORREF LgsColor[] = { 0x00000000, 0x00AF0000, 0x00FF0000,
  29. 0x00AF00AF, 0x00FF00FF, 0x0000AF00 };
  30. double dz = 3.14 / 180.0 * dRotateAngle;
  31. for( INT i = 0; i < GetCount(); i ++ )
  32. {
  33. CLgDeviceLGS::LGS_HZ_POLYGON &polygon = GetAt(i);
  34. if( !polygon.GetCount() )
  35. continue;
  36. LPPOINT pZonePoint = new POINT[ polygon.GetCount() ];
  37. if( !pZonePoint )
  38. continue;
  39. for( int j = 0; j < polygon.GetCount(); j ++ )
  40. {
  41. CLgDPoint &point = polygon[ j % polygon.GetCount() ];
  42. // rotate hidden zone
  43. double xp = cos( dz ) * point.x + sin( dz ) * point.y;
  44. double yp = - sin( dz ) * point.x + cos( dz ) * point.y;
  45. pZonePoint[j].x = (int)(pCenter->x + xp * dScaleToPixel + 0.5);
  46. pZonePoint[j].y = (int)(pCenter->y + yp * dScaleToPixel + 0.5);
  47. }
  48. CPen pen( pOn[ polygon.bType ] ? PS_SOLID : PS_DOT, 1, LgsColor[ polygon.bType ] );
  49. CPen *pPen = (CPen*)pDC->SelectObject( &pen );
  50. INT nBkMode = pDC->SetBkMode( TRANSPARENT );
  51. if( pOn[polygon.bType] )
  52. {
  53. CBrush brush( HS_DIAGCROSS, LgsColor[polygon.bType] );
  54. CBrush *pBrush = (CBrush*)pDC->SelectObject( &brush );
  55. pDC->Polygon( pZonePoint, polygon.GetCount() );
  56. pDC->SelectObject( pBrush );
  57. }
  58. else
  59. {
  60. pDC->MoveTo( pZonePoint[polygon.GetCount()-1].x, pZonePoint[polygon.GetCount()-1].y );
  61. pDC->PolylineTo( pZonePoint, polygon.GetCount() );
  62. }
  63. pDC->SetBkMode( nBkMode );
  64. pDC->SelectObject( pPen );
  65. delete [] pZonePoint;
  66. }
  67. // log info
  68. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CHiddenZoneList::Draw", "Done" );
  69. return TRUE;
  70. }
  71. BOOL CDoplerHiddenZoneList::Draw( CDC *pDC, CPoint *pCenter, double dScaleToPixel, double dRotateAngle )
  72. {
  73. // draw hidden zones
  74. INT hx = dScaleToPixel;
  75. INT hy = dScaleToPixel;
  76. HDC hDC = pDC->GetSafeHdc();
  77. const double pi = asin(1.0) * 2.0;
  78. const double d2pi = pi / 180.0;
  79. HBRUSH hNullBrush = (HBRUSH)::GetStockObject( NULL_BRUSH );
  80. HBRUSH hNormalBrush = ::CreateHatchBrush(HS_DIAGCROSS, RGB(0x7F,0x7F,0x7F));
  81. HPEN hPen = ::CreatePen(PS_DOT, 1, RGB(0x7F,0x7F,0x7F));
  82. HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
  83. HBRUSH hBrush = bEnable ? hNormalBrush : hNullBrush;
  84. HBRUSH hOldBrush = (HBRUSH)::SelectObject(hDC, hBrush);
  85. INT nBkMode = ::SetBkMode( hDC, TRANSPARENT );
  86. for( INT i = 0; i < nCount; i++ )
  87. {
  88. CLgDeviceDopler::PDOPLER_MASK pMask1 = pMask + i;
  89. double dStartAngle = d2pi * (dRotateAngle + pMask1->nStartAngle);
  90. double dStopAngle = d2pi * (dRotateAngle + pMask1->nStopAngle);
  91. // rotate coordinates
  92. POINT p[2] =
  93. {
  94. { hx * cos( dStartAngle ) + pCenter->x,
  95. -hy * sin( dStartAngle ) + pCenter->y },
  96. { hx * cos( dStopAngle ) + pCenter->x,
  97. -hx * sin( dStopAngle ) + pCenter->y },
  98. };
  99. POINT sp = p[0];
  100. POINT ep = p[1];
  101. ::Pie( hDC, pCenter->x - hx, pCenter->y - hy, pCenter->x + hx, pCenter->y + hy, sp.x, sp.y, ep.x, ep.y );
  102. }
  103. ::SelectObject(hDC, hOldBrush);
  104. ::SetBkMode( hDC, nBkMode );
  105. ::DeleteObject(hNormalBrush);
  106. ::SelectObject(hDC, hOldPen);
  107. ::DeleteObject(hPen);
  108. return TRUE;
  109. }