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.

175 lines
4.3 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: ReportDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ReportDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // ReportDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "calibration.h"
  18. #include "CalibrationDlg.h"
  19. #include "ReportDlg.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. // CReportDlg dialog
  28. CReportDlg::CReportDlg(CWnd* pParent /*=NULL*/)
  29. : CDialog(CReportDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CReportDlg)
  32. //}}AFX_DATA_INIT
  33. m_pData = NULL;
  34. m_pSensorArray = NULL;
  35. }
  36. void CReportDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CReportDlg)
  40. DDX_Control(pDX, IDC_EDIT_RESULT, m_Edit);
  41. DDX_Control(pDX, IDC_DATA_LIST, m_List);
  42. DDX_Control(pDX, IDC_EDIT_REPORT, m_Report);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CReportDlg, CDialog)
  46. //{{AFX_MSG_MAP(CReportDlg)
  47. ON_LBN_SELCHANGE(IDC_DATA_LIST, OnSelchangeDataList)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CReportDlg message handlers
  52. BOOL CReportDlg::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. ASSERT( m_pData );
  56. CStringList list;
  57. m_pData->GetFolderList( list );
  58. POSITION pos = list.GetHeadPosition();
  59. while( pos )
  60. {
  61. CString str = list.GetNext( pos );
  62. CString namedStr = str;
  63. BOOL bFound = FALSE;
  64. for( int s =0; s < m_pSensorArray->GetSensorCount() && !bFound; s++ )
  65. {
  66. if( m_pSensorArray->GetSensor(s)->GetType() != CVisual::LGS )
  67. continue;
  68. CSensorLGS *pSensor = static_cast<CSensorLGS*>( m_pSensorArray->GetSensor(s) );
  69. CVideoCamera *pCamera = pSensor->GetVideoCamera();
  70. if( !pCamera )
  71. continue;
  72. for( int n = 0; n < pSensor->GetCalibrationNameArray().GetCount() && !bFound; n++ )
  73. {
  74. if( pSensor->GetCalibrationNameArray()[n] == str )
  75. {
  76. CString sname = pSensor->GetName();
  77. CString cname = *(pCamera->GetName());
  78. namedStr += " (\"" + sname + "\",\"" + cname + "\")";
  79. if( m_pRelation->pSensor == pSensor &&
  80. m_pRelation->pCamera == pCamera )
  81. namedStr += " current";
  82. bFound = TRUE;
  83. }
  84. }
  85. }
  86. int nIndex = m_List.AddString( namedStr );
  87. m_List.SetItemDataPtr( nIndex, new CString(str) );
  88. }
  89. m_List.SetCurSel( m_List.GetCount() - 1 );
  90. OnSelchangeDataList();
  91. return TRUE; // return TRUE unless you set the focus to a control
  92. // EXCEPTION: OCX Property Pages should return FALSE
  93. }
  94. void CReportDlg::OnSelchangeDataList()
  95. {
  96. int nIndex = m_List.GetCurSel();
  97. if( nIndex != LB_ERR )
  98. {
  99. CString *pName = (CString*)m_List.GetItemDataPtr( nIndex );
  100. if( !pName )
  101. return;
  102. CString path = m_pData->GetResultPath( *pName );
  103. CFile file;
  104. if( file.Open( path, CFile::modeRead ) )
  105. {
  106. LPSTR pBuffer = new CHAR[ file.GetLength()+1 ];
  107. file.Read( pBuffer, file.GetLength() );
  108. pBuffer[ file.GetLength() ] = '\0';
  109. m_Edit.SetWindowText( pBuffer );
  110. delete [] pBuffer;
  111. file.Close();
  112. m_Edit.EnableWindow( TRUE );
  113. }
  114. else
  115. {
  116. m_Edit.SetWindowText( _T("") );
  117. m_Edit.EnableWindow( FALSE );
  118. }
  119. path = m_pData->GetReportPath( *pName );
  120. if( file.Open( path, CFile::modeRead ) )
  121. {
  122. LPSTR pBuffer = new CHAR[ file.GetLength()+1 ];
  123. file.Read( pBuffer, file.GetLength() );
  124. pBuffer[ file.GetLength() ] = '\0';
  125. m_Report.SetWindowText( pBuffer );
  126. delete [] pBuffer;
  127. file.Close();
  128. m_Report.EnableWindow( TRUE );
  129. }
  130. else
  131. {
  132. m_Report.SetWindowText( _T("") );
  133. m_Report.EnableWindow( FALSE );
  134. }
  135. }
  136. }
  137. void CReportDlg::OnCancel()
  138. {
  139. for( int i = 0; i < m_List.GetCount(); i++ )
  140. {
  141. CString *pName = (CString*)m_List.GetItemDataPtr( i );
  142. if( !pName )
  143. continue;
  144. delete pName;
  145. }
  146. CDialog::OnCancel();
  147. }