void CStripsWindow::ShowData()
{
m_wndList.DeleteAllItems();
for ( int i = 0; i < m_pController->GetStripCount(); ++i )
{
CStrip* pStrip = m_pController->GetStrip(i);
CString str;
LVITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.iSubItem = 0;
lvItem.iItem = i;
lvItem.lParam = (LPARAM) pStrip;
str = pStrip->GetStripId();
lvItem.pszText = str.GetBuffer();
str.ReleaseBuffer();
m_wndList.InsertItem(&lvItem);
str = GetDateString(pStrip).Left(17);
m_wndList.SetItemText(i, 1, str);
if ( pStrip->GetSetupData() )
{
CSetupData* pData = pStrip->GetSetupData();
CStandPass* pLastPass = pData->GetPass(pData->GetPassCount() - 1);
str.Format(_T("%.2lf"), pLastPass->GetExitThickness() * 1e3);
m_wndList.SetItemText(i, 2, str);
str.Format(_T("%.0lf"), pLastPass->GetExitWidth() * 1e3);
m_wndList.SetItemText(i, 3, str);
}
}
/*if ( m_pController->GetActiveStripIndex() < 0 )
m_pController->SetActiveStripIndex(0);*/
m_wndList.SetFocus();
m_wndList.SetSelectionMark( m_pController->GetActiveStripIndex() );
m_wndList.SetItemState( m_pController->GetActiveStripIndex(), LVIS_SELECTED, LVIS_SELECTED );
m_wndList.SetItemState( m_pController->GetActiveStripIndex(), LVIS_FOCUSED, LVIS_FOCUSED );
}
void CStripsWindow::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
{
CMainFrame* pMainFrame = (CMainFrame*) GetParentFrame();
int nSel = m_wndList.GetSelectionMark();
if ( nSel == -1 )
pMainFrame->UpdateViews();
else
{
m_pController->SetActiveStripIndex(nSel);
CStrip* pStrip = m_pController->GetActiveStrip();
if ( m_pController != NULL && pStrip && pStrip->GetSetupData() )
{
if ( m_pController->GetActiveMillPassIndex() >= (pStrip->GetSetupData()->GetPassCount() / 2) ||
m_pController->GetActiveMillPassIndex() < 0 )
pMainFrame->SetActiveMillPassIndex( pStrip->GetMillPassMaxCount() - 1 );
else
pMainFrame->SetActiveMillPassIndex( m_pController->GetActiveMillPassIndex() - 1 );
}
else
if ( m_pController != NULL && pStrip && pStrip->GetMeasuredData() )
{
CMeasuredData* pData = pStrip->GetMeasuredData();
int nIndex = 0;
for ( auto pass : pData->GetAllMillPasses() )
{
if ( m_pController->GetActiveMillPassIndex() == pass.first )
break;
nIndex++;
}
if ( nIndex == pData->GetAllMillPasses().size() )
pMainFrame->SetActiveMillPassIndex(-1);
else
pMainFrame->SetActiveMillPassIndex(nIndex);
}
else
pMainFrame->SetActiveMillPassIndex(-1);
m_pController->SetActivePassIndex(0);
pMainFrame->SetStripSizeChanged(true);
pMainFrame->UpdateViewsStripSelectionChange();
}
}