📄 propertydlg.cpp
字号:
//-----------------------------------------------------------------------------
// (c) 2002 by Basler Vision Technologies
// Section: Vision Components
// Project: BCAM
// $Header: PropertyDlg.cpp, 7, 04.07.2006 15:48:33, Bartusch, P.$
//-----------------------------------------------------------------------------
/**
\file PropertyDlg.cpp
\brief Implementation of the CPropertyDlg class.
*/
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "resource.h"
#include "camera.h"
#include "utility.h"
#include "PropertyDlg.h"
#include "UploadDlg.h"
/*-------------------------------------------------------------------
* Function: ReportError
*
* Purpose: Show an error message box
*-------------------------------------------------------------------*/
static void ReportError(BcamException& e)
{
CString description;
if ( e.Context() != "" )
description += e.Context() + CString(" : ") + e.Description();
else
description += e.Description();
CString errorCode;
errorCode.Format("Error code: 0x%08x \n", e.Error() );
MessageBox( NULL, errorCode + description, "Error", MB_OK | MB_ICONINFORMATION );
}
////////////////////////////////////////////////////////////////////////////////////
//
// class CFormatPropertyPage
//
LRESULT CFormatPropertyPage::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
m_cbFormat.Attach(GetDlgItem(IDC_COMBO_FORMAT));
m_cbFrame_Color.Attach(GetDlgItem(IDC_COMBO_FRAMERATE));
m_cbMode.Attach(GetDlgItem(IDC_COMBO_MODE));
try
{
m_Camera.GetVideoMode(&m_CurrentFormat, &m_CurrentMode, &m_CurrentFrameRate);
if ( m_CurrentFormat == DCS_Format7 )
{
m_CurrentColorCode = m_Camera.FormatSeven[m_CurrentMode].ColorCoding();
assert ( m_CurrentFrameRate == DCS_IgnoreFrameRate );
}
else
{
m_CurrentColorCode = BcamUtility::ColorCode(m_CurrentFormat, m_CurrentMode);
}
m_OrigFormat = m_CurrentFormat;
m_OrigMode = m_CurrentMode;
m_OrigColorCode = m_CurrentColorCode;
m_OrigFrameRate = m_CurrentFrameRate;
GetFormats();
GetModes();
GetFramerates_Colors();
}
CATCH_REPORT();
return 0;
}
LRESULT CFormatPropertyPage::OnFormatChanged(WORD /* code */, WORD /*id*/, HWND /*hWND*/, BOOL& bHandled)
{
SetModified(TRUE);
try
{
assert( m_Idx2Format.find(m_cbFormat.GetCurSel()) != m_Idx2Format.end() );
m_CurrentFormat = m_Idx2Format[m_cbFormat.GetCurSel()];
GetModes();
GetFramerates_Colors();
}
CATCH_REPORT();
return 0;
}
LRESULT CFormatPropertyPage::OnModeChanged(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/, BOOL& bHandled)
{
SetModified(TRUE);
try
{
assert( m_Idx2Mode.find(m_cbMode.GetCurSel()) != m_Idx2Mode.end() );
m_CurrentMode = m_Idx2Mode[m_cbMode.GetCurSel()];
GetFramerates_Colors();
if ( m_CurrentFormat != DCS_Format7 )
ATLTRACE("Current Mode Changed: %s\n", BcamUtility::VideoResolutionName(m_CurrentFormat, m_CurrentMode));
else
ATLTRACE("Current Mode Changed: %d\n", m_CurrentMode);
}
CATCH_REPORT();
return 0;
}
LRESULT CFormatPropertyPage::OnRate_ColorChanged(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/, BOOL& bHandled)
{
SetModified(TRUE);
try
{
if ( m_CurrentFormat != DCS_Format7 )
{
assert ( m_Idx2FrameRate.find(m_cbFrame_Color.GetCurSel()) != m_Idx2FrameRate.end() );
m_CurrentFrameRate = m_Idx2FrameRate[m_cbFrame_Color.GetCurSel()];
ATLTRACE("Current FrameRate: %s\n", BcamUtility::VideoFrameRateName(m_CurrentFrameRate));
}
else
{
assert ( m_Idx2Color.find(m_cbFrame_Color.GetCurSel()) != m_Idx2Color.end() );
m_CurrentColorCode = m_Idx2Color[m_cbFrame_Color.GetCurSel()];
ATLTRACE("Current Color: %s\n", BcamUtility::ColorCodeName(m_CurrentColorCode));
}
}
CATCH_REPORT();
return 0;
}
BOOL CFormatPropertyPage::OnKillActive()
{
try
{
ATLTRACE("OnKillActive()\n");
if ( m_OrigFormat != m_CurrentFormat || m_OrigMode != m_CurrentMode
|| m_OrigFrameRate != m_CurrentFrameRate || m_OrigColorCode != m_CurrentColorCode )
{
// settings have changed.
// Reparametrize camera
// now the camera has suspended the continuos grab if it was active
if ( m_CurrentFormat != DCS_Format7 )
{
m_Camera.ParametrizeCamera(m_CurrentFormat, m_CurrentMode, m_CurrentFrameRate);
}
else
{
m_Camera.ParametrizeCamera(m_CurrentMode, m_CurrentColorCode, m_Camera.FormatSeven[m_CurrentMode].Position(), m_Camera.FormatSeven[m_CurrentMode].Size(), -1);
}
m_OrigMode = m_CurrentMode;
m_OrigFormat = m_CurrentFormat;
m_OrigFrameRate = m_CurrentFrameRate;
m_OrigColorCode = m_CurrentColorCode;
}
SetModified(FALSE);
}
CATCH_REPORT();
return TRUE;
}
void CFormatPropertyPage::GetFormats()
{
m_Idx2Format.clear();
m_cbFormat.ResetContent();
assert( m_cbFormat.GetCurSel() == -1 );
int idx = 0;
if ( m_Camera.IsVideoModeSupported(DCS_Format0) )
{
m_cbFormat.AddString("Format 0");
m_Idx2Format[idx] = DCS_Format0;
if ( m_CurrentFormat == DCS_Format0 )
m_cbFormat.SetCurSel(idx);
idx++;
}
if ( m_Camera.IsVideoModeSupported(DCS_Format1) )
{
m_cbFormat.AddString("Format 1");
m_Idx2Format[idx] = DCS_Format1;
if ( m_CurrentFormat == DCS_Format1 )
m_cbFormat.SetCurSel(idx);
idx++;
}
if ( m_Camera.IsVideoModeSupported(DCS_Format2) )
{
m_cbFormat.AddString("Format 2");
m_Idx2Format[idx] = DCS_Format2;
if ( m_CurrentFormat == DCS_Format2 )
m_cbFormat.SetCurSel(idx);
idx++;
}
if ( m_Camera.IsVideoModeSupported(DCS_Format7) )
{
m_cbFormat.AddString("Format 7");
m_Idx2Format[idx] = DCS_Format7;
if ( m_CurrentFormat == DCS_Format7 )
m_cbFormat.SetCurSel(idx);
idx++;
}
assert ( m_Idx2Format.size() != 0 );
if ( m_CurrentFormat == DCS_Format7 )
{
m_CurrentColorCode = m_Camera.FormatSeven[m_CurrentMode].ColorCoding();
}
else
{
m_CurrentColorCode = BcamUtility::ColorCode(m_CurrentFormat, m_CurrentMode);
}
}
void CFormatPropertyPage::GetModes()
{
m_Idx2Mode.clear();
m_cbMode.ResetContent();
assert(m_cbMode.GetCurSel() == -1 );
int idx = 0;
for (int mode = DCS_Mode0; (m_CurrentFormat != DCS_Format0 && mode <= DCS_Mode7) || mode <= DCS_Mode6; ++mode )
{
if ( m_Camera.IsVideoModeSupported(m_CurrentFormat, (DCSVideoMode) mode) )
{
if ( m_CurrentFormat != DCS_Format7 )
{
// currently we only support RGB8, YUV422 and Mono8 images
DCSColorCode code = BcamUtility::ColorCode(m_CurrentFormat, (DCSVideoMode) mode);
if ( code != DCSColor_Mono8 && code != DCSColor_YUV8_4_2_2 && code != DCSColor_RGB8 && code != DCSColor_Raw8 )
{
continue;
}
m_cbMode.AddString(BcamUtility::VideoResolutionName(m_CurrentFormat, (DCSVideoMode) mode));
}
else
{
CSize max = m_Camera.FormatSeven[mode].MaxSize();
CString s;
s.Format("Mode %d (%dx%d)", mode, max.cx, max.cy);
m_cbMode.AddString(s);
}
m_Idx2Mode[idx] = (DCSVideoMode) mode;
if ( m_CurrentMode == mode )
m_cbMode.SetCurSel(idx);
idx++;
}
}
assert ( m_Idx2Mode.size() != 0 );
if ( m_cbMode.GetCurSel() == -1 )
m_cbMode.SetCurSel(0);
m_CurrentMode = m_Idx2Mode[m_cbMode.GetCurSel()];
}
void CFormatPropertyPage::GetFramerates_Colors()
{
m_Idx2Color.clear();
m_Idx2FrameRate.clear();
m_cbFrame_Color.ResetContent();
assert( m_cbFrame_Color.GetCurSel() == -1 );
int idx = 0;
if ( m_CurrentFormat != DCS_Format7 )
{
::SetWindowText(GetDlgItem(IDC_STATIC_FRAMERATE), "Frame Rate");
for ( int rate = DCS_1_875fps; rate <= DCS_240fps; rate++ )
{
if ( m_Camera.IsVideoModeSupported(m_CurrentFormat, m_CurrentMode, (DCSVideoFrameRate) rate) )
{
m_cbFrame_Color.AddString(BcamUtility::VideoFrameRateName((DCSVideoFrameRate) rate));
m_Idx2FrameRate[idx] = (DCSVideoFrameRate) rate;
if ( rate == m_CurrentFrameRate )
m_cbFrame_Color.SetCurSel(idx);
idx++;
}
}
assert ( m_Idx2FrameRate.size() != 0 );
}
else
{
::SetWindowText(GetDlgItem(IDC_STATIC_FRAMERATE), "Color Coding");
for ( int color = DCSColor_Mono8; color <= DCSColor_Raw8; color++ )
{
if ( m_Camera.FormatSeven[m_CurrentMode].ColorCoding.IsSupported((DCSColorCode) color) )
{
m_cbFrame_Color.AddString(BcamUtility::ColorCodeName( (DCSColorCode) color));
m_Idx2Color[idx] = (DCSColorCode) color;
if ( color == m_CurrentColorCode )
m_cbFrame_Color.SetCurSel(idx);
idx++;
}
}
assert ( m_Idx2Color.size() != 0 );
}
if ( m_cbFrame_Color.GetCurSel() == -1 )
m_cbFrame_Color.SetCurSel(0);
if ( m_CurrentFormat != DCS_Format7 )
{
m_CurrentFrameRate = m_Idx2FrameRate[m_cbFrame_Color.GetCurSel()];
}
else
{
m_CurrentColorCode = m_Idx2Color[m_cbFrame_Color.GetCurSel()];
}
}
////////////////////////////////////////////////////////////////////////////////////
//
// class CTriggerPropertyPage
//
LRESULT CTriggerPropertyPage::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
m_ComboBoxMode.Attach(GetDlgItem(IDC_COMBOMODE));
m_ComboBoxPolarity.Attach(GetDlgItem(IDC_COMBOPOLARITY));
try
{
if ( ! m_Camera.Trigger.IsSupported() )
{
::EnableWindow(GetDlgItem(IDC_STATICMODE), FALSE);
::EnableWindow(GetDlgItem(IDC_STATICPOLARITY), FALSE);
::EnableWindow(GetDlgItem(IDC_CHECKENABLE), FALSE);
m_ComboBoxMode.EnableWindow(FALSE);
m_ComboBoxPolarity.EnableWindow(FALSE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -