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.

167 lines
3.7 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: LocatorWnd.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of LocatorWnd.h
  13. //----------------------------------------------------------------------------
  14. #ifndef __LOCATOR__WND__H__INCLUDED__
  15. #define __LOCATOR__WND__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include "GenericWnd.h"
  20. #include "..\LgLib\Templ.h"
  21. #include "..\LgLib\LgAux.h"
  22. class CLocatorRegion : public CLgArray<CLgDPoint>
  23. {
  24. public:
  25. CLocatorRegion();
  26. CLocatorRegion( const CLocatorRegion& );
  27. virtual ~CLocatorRegion();
  28. public:
  29. virtual BOOL Add( CLgDPoint& data );
  30. virtual BOOL Remove( INT nIndex );
  31. virtual BOOL RemoveAll();
  32. public:
  33. BOOL Load( HANDLE hFile );
  34. BOOL Store( HANDLE hFile );
  35. public:
  36. void SetColor( COLORREF nColor ) { m_nColor = nColor; }
  37. COLORREF GetColor() { return m_nColor; }
  38. public:
  39. BOOL PtInRegion( CLgDPoint &dp );
  40. HRGN GetRgn() { return m_hRgn; }
  41. private:
  42. COLORREF m_nColor;
  43. private:
  44. BOOL UpdateRgn();
  45. HRGN m_hRgn;
  46. };
  47. class CLocatorRegionArray : public CLgArray<CLocatorRegion>
  48. {
  49. public:
  50. INT PtInRegion( CLgDPoint &dp );
  51. public:
  52. BOOL Load( LPCTSTR pFile );
  53. BOOL Store( LPCTSTR pFile );
  54. public:
  55. BOOL ProduceHiddenZones();
  56. private:
  57. struct VERTEX
  58. {
  59. double x, y, r;
  60. BOOL f;
  61. int n;
  62. };
  63. typedef VERTEX* LPVERTEX;
  64. struct SEGMENT
  65. {
  66. INT pPoints[2];
  67. INT nIndex;
  68. };
  69. typedef SEGMENT* LPSEGMENT;
  70. struct SEGMENTS
  71. {
  72. LPVERTEX pPoints;
  73. INT nCount;
  74. };
  75. typedef SEGMENTS* LPSEGMENTS;
  76. private:
  77. static int DBL_CMP(const double& a, const double& b, const double quality = 1e-10);
  78. static BOOL CrossProduct( LPVERTEX ln0, LPVERTEX ln1, LPVERTEX pCross, BOOL fCheck0 = TRUE, BOOL fCheck1 = TRUE );
  79. static BOOL PtInLine(LPVERTEX ln, VERTEX& p);
  80. static int comparePoints(const void *arg1, const void *arg2);
  81. static void AddPointToSegment(LPSEGMENTS pSegments, INT nIndex, LPVERTEX pPoint);
  82. static void StickSegments(LPSEGMENTS pSegments, INT nIndex);
  83. static int compareSegments(const void *arg1, const void *arg2);
  84. };
  85. class CLocatorWnd : public CGenericWnd
  86. {
  87. public:
  88. CLocatorWnd();
  89. virtual ~CLocatorWnd();
  90. public:
  91. BOOL Create( HWND hParentWnd, INT x, INT y, INT cx, INT cy );
  92. public:
  93. void SetRegionArray( CLocatorRegionArray *pRegionArray ) { m_RegionArray = *pRegionArray; }
  94. CLocatorRegionArray& GetRegionArray() { return m_RegionArray; }
  95. public:
  96. void SetBackground( HBITMAP hBitmap, BOOL bCopy = TRUE );
  97. public:
  98. BOOL ClearRegions();
  99. public:
  100. typedef enum{ EDIT_MODE_LINE, EDIT_MODE_POINT } EDIT_MODE;
  101. void SetEditMode( BOOL bEditMode, COLORREF nEditColor = RGB(0,0,0), EDIT_MODE eEditMode = EDIT_MODE_POINT );
  102. BOOL GetEditMode( COLORREF *pColor = NULL );
  103. private:
  104. virtual LRESULT OnMouseMove( WPARAM, LPARAM );
  105. virtual LRESULT OnLButtonUp( WPARAM, LPARAM );
  106. virtual LRESULT OnLButtonDown( WPARAM, LPARAM );
  107. virtual LRESULT OnRButtonUp( WPARAM, LPARAM );
  108. virtual LRESULT OnSize( WPARAM, LPARAM );
  109. virtual LRESULT OnDestroy( WPARAM, LPARAM );
  110. virtual void OnPaint( HDC );
  111. private:
  112. void OnDraw( HDC );
  113. private:
  114. POINT LocatorToClient( CLgDPoint& dp );
  115. CLgDPoint ClientToLocator( POINT& p );
  116. private:
  117. CLocatorRegionArray m_RegionArray;
  118. private:
  119. BOOL m_bEditMode;
  120. EDIT_MODE m_eEditMode;
  121. CLocatorRegion m_EditRegion;
  122. private:
  123. BOOL m_bEditStart;
  124. private:
  125. HDC m_hMemDC;
  126. HBITMAP m_hMemBitmap;
  127. private:
  128. HDC m_hBackgroundDC;
  129. HBITMAP m_hBackgroundBitmap;
  130. };
  131. #endif