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.

153 lines
3.4 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: RelationDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of RelationDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // RelationDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "calibration.h"
  18. #include "RelationDlg.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CRelationDlg dialog
  26. CRelationDlg::CRelationDlg(CWnd* pParent /*=NULL*/)
  27. : CDialog(CRelationDlg::IDD, pParent)
  28. {
  29. //{{AFX_DATA_INIT(CRelationDlg)
  30. // NOTE: the ClassWizard will add member initialization here
  31. //}}AFX_DATA_INIT
  32. m_pSensorArray = NULL;
  33. ::ZeroMemory( &m_Relation, sizeof(m_Relation) );
  34. }
  35. void CRelationDlg::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CRelationDlg)
  39. DDX_Control(pDX, IDC_LIST_RELATION, m_List);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CRelationDlg, CDialog)
  43. //{{AFX_MSG_MAP(CRelationDlg)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CRelationDlg message handlers
  48. BOOL CRelationDlg::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. ASSERT( m_pSensorArray );
  52. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  53. {
  54. CSensor *pSensor = m_pSensorArray->GetSensor( i );
  55. ASSERT( pSensor );
  56. if( pSensor->GetType() == CSensor::LGS )
  57. {
  58. CVideoCamera *pCamera = pSensor->GetVideoCamera();
  59. if( pCamera && pCamera->GetType()==VC_PTZ )
  60. {
  61. CString str;
  62. str.Format( _T("%s <-> %s"), (LPCTSTR)pSensor->GetName(), (LPCTSTR)*((CVideoCameraPTZ*)pCamera)->GetName() );
  63. int nIndex = m_List.AddString( str );
  64. RELATION *pRelation = new RELATION;
  65. pRelation->pCamera = pCamera;
  66. pRelation->pSensor = pSensor;
  67. m_List.SetItemDataPtr( nIndex, pRelation );
  68. }
  69. }
  70. }
  71. if( m_Relation.pCamera && m_Relation.pSensor )
  72. {
  73. for( i = 0; i < m_List.GetCount(); i++ )
  74. {
  75. RELATION *pRelation = (RELATION*)m_List.GetItemDataPtr( i );
  76. if( pRelation->pCamera == m_Relation.pCamera &&
  77. pRelation->pSensor == m_Relation.pSensor )
  78. {
  79. m_List.SetCurSel( i );
  80. break;
  81. }
  82. }
  83. }
  84. else
  85. m_List.SetCurSel( -1 );
  86. return TRUE;
  87. }
  88. void CRelationDlg::SetSensorArray(CSensorArray *pSensorArray)
  89. {
  90. m_pSensorArray = pSensorArray;
  91. }
  92. void CRelationDlg::OnOK()
  93. {
  94. BOOL bSuccess;
  95. int nIndex = m_List.GetCurSel();
  96. if( nIndex != LB_ERR )
  97. {
  98. m_Relation = *(RELATION*)m_List.GetItemDataPtr( nIndex );
  99. bSuccess = TRUE;
  100. }
  101. else
  102. {
  103. m_Relation.pCamera = NULL;
  104. m_Relation.pSensor = NULL;
  105. bSuccess = TRUE;
  106. }
  107. for( int i = 0; i < m_List.GetCount(); i++ )
  108. {
  109. RELATION *pRelation = (RELATION*)m_List.GetItemDataPtr( i );
  110. delete pRelation;
  111. }
  112. if( bSuccess )
  113. CDialog::OnOK();
  114. else
  115. CDialog::OnCancel();
  116. }
  117. void CRelationDlg::OnCancel()
  118. {
  119. for( int i = 0; i < m_List.GetCount(); i++ )
  120. {
  121. RELATION *pRelation = (RELATION*)m_List.GetItemDataPtr( i );
  122. delete pRelation;
  123. }
  124. CDialog::OnCancel();
  125. }