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.

103 lines
2.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: HiddenZone.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of HiddenZone.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "HiddenZone.h"
  16. #include "..\..\LgLib\LgAux.h"
  17. #include "..\..\LgLib\Version.h"
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[]=__FILE__;
  21. #define new DEBUG_NEW
  22. #endif
  23. CHiddenZone::CHiddenZone()
  24. {
  25. m_pPoint = NULL;
  26. m_nPoint = 0;
  27. m_nType = 0;
  28. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CHiddenZone::CHiddenZone") );
  29. }
  30. CHiddenZone::~CHiddenZone()
  31. {
  32. RemoveAll();
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CHiddenZone::~CHiddenZone") );
  34. }
  35. BOOL CHiddenZone::Copy( CHiddenZone *pHiddenZone )
  36. {
  37. RemoveAll();
  38. for( int i = 0; i < pHiddenZone->GetCount(); i++ )
  39. Add( *pHiddenZone->GetAt(i) );
  40. return TRUE;
  41. }
  42. bool CHiddenZone::Add( CLgDPoint dPoint, int nIndex )
  43. {
  44. if( nIndex < 0 )
  45. return false;
  46. m_nPoint ++;
  47. m_pPoint = (CLgDPoint*) realloc( m_pPoint, sizeof(CLgDPoint) * m_nPoint );
  48. if( nIndex >= m_nPoint )
  49. nIndex = m_nPoint - 1;
  50. MoveMemory( &m_pPoint[ nIndex + 1], &m_pPoint[ nIndex ], m_nPoint - nIndex - 1 );
  51. m_pPoint[ nIndex ] = dPoint;
  52. return true;
  53. }
  54. bool CHiddenZone::Remove( int nIndex )
  55. {
  56. if( nIndex < 0 || nIndex >= m_nPoint )
  57. return false;
  58. MoveMemory( &m_pPoint[ nIndex ], &m_pPoint[ nIndex + 1 ], m_nPoint - nIndex - 1 );
  59. m_nPoint --;
  60. m_pPoint = (CLgDPoint*) realloc( m_pPoint, sizeof(CLgDPoint) * m_nPoint );
  61. return true;
  62. }
  63. void CHiddenZone::RemoveAll()
  64. {
  65. if( m_pPoint )
  66. {
  67. free( m_pPoint );
  68. m_pPoint = NULL;
  69. }
  70. m_nPoint = 0;
  71. }
  72. CLgDPoint *CHiddenZone::GetAt( int nIndex )
  73. {
  74. return ( nIndex >= 0 && nIndex < m_nPoint ) ? &m_pPoint[ nIndex ] : NULL;
  75. }
  76. CLgDPoint *CHiddenZone::operator[] ( int nIndex )
  77. {
  78. return GetAt( nIndex );
  79. }