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: LoadDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LoadDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // LoadDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "Calibration.h"
  18. #include "CalibrationDlg.h"
  19. #include "LoadDlg.h"
  20. #include "..\DLIB\SensorLGS.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CLoadDlg dialog
  28. CLoadDlg::CLoadDlg(CWnd* pParent /*=NULL*/)
  29. : CDialog(CLoadDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CLoadDlg)
  32. //}}AFX_DATA_INIT
  33. m_pSensorArray = NULL;
  34. m_pData = NULL;
  35. }
  36. void CLoadDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CLoadDlg)
  40. DDX_Control(pDX, IDC_DATA_LIST, m_List);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CLoadDlg, CDialog)
  44. //{{AFX_MSG_MAP(CLoadDlg)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CLoadDlg message handlers
  49. BOOL CLoadDlg::OnInitDialog()
  50. {
  51. CDialog::OnInitDialog();
  52. CStringList list;
  53. m_pData->GetFolderList( list );
  54. POSITION pos = list.GetHeadPosition();
  55. while( pos )
  56. {
  57. CString str = list.GetNext( pos );
  58. CString namedStr = str;
  59. BOOL bFound = FALSE;
  60. for( int s = 0; s < m_pSensorArray->GetSensorCount() && !bFound; s++ )
  61. {
  62. if( m_pSensorArray->GetSensor(s)->GetType() != CVisual::LGS )
  63. continue;
  64. CSensorLGS *pSensor = static_cast<CSensorLGS*>( m_pSensorArray->GetSensor(s) );
  65. CVideoCamera *pCamera = pSensor->GetVideoCamera();
  66. if( !pCamera )
  67. continue;
  68. for( int n = 0; n < pSensor->GetCalibrationNameArray().GetCount() && !bFound; n++ )
  69. {
  70. if( pSensor->GetCalibrationNameArray()[n] == str )
  71. {
  72. CString sname = pSensor->GetName();
  73. CString cname = *(pCamera->GetName());
  74. namedStr += " (\"" + sname + "\",\"" + cname + "\")";
  75. if( m_pRelation->pSensor == pSensor &&
  76. m_pRelation->pCamera == pCamera )
  77. namedStr += " current";
  78. bFound = TRUE;
  79. }
  80. }
  81. }
  82. int nIndex = m_List.AddString( namedStr );
  83. m_List.SetItemDataPtr( nIndex, new CString(str) );
  84. }
  85. return TRUE;
  86. }
  87. void CLoadDlg::SetData(CSensorArray *pSensorArray, CCalibrationData *pData, RELATION *pRelation )
  88. {
  89. m_pData = pData;
  90. m_pSensorArray = pSensorArray;
  91. m_pRelation = pRelation;
  92. }
  93. void CLoadDlg::OnOK()
  94. {
  95. int nIndex = m_List.GetCurSel();
  96. if( nIndex != LB_ERR )
  97. {
  98. CString *pName = (CString*)m_List.GetItemDataPtr( nIndex );
  99. if( !pName )
  100. CDialog::OnCancel();
  101. else
  102. {
  103. m_Name = *pName;
  104. CDialog::OnOK();
  105. }
  106. }
  107. else
  108. CDialog::OnCancel();
  109. for( int i = 0; i < m_List.GetCount(); i++ )
  110. {
  111. CString *pName = (CString*)m_List.GetItemDataPtr( i );
  112. if( !pName )
  113. continue;
  114. delete pName;
  115. }
  116. }
  117. void CLoadDlg::OnCancel()
  118. {
  119. for( int i = 0; i < m_List.GetCount(); i++ )
  120. {
  121. CString *pName = (CString*)m_List.GetItemDataPtr( i );
  122. if( !pName )
  123. continue;
  124. delete pName;
  125. }
  126. CDialog::OnCancel();
  127. }