⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertydlg.cpp

📁 BCAM 1394 Driver
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      return 0;
    }

    
    BOOL bEnabled = m_Camera.Trigger.OnOff();
    CheckDlgButton(IDC_CHECKENABLE, bEnabled ? BST_CHECKED : BST_UNCHECKED);
    ::EnableWindow(GetDlgItem(IDC_STATICMODE), bEnabled);
    m_ComboBoxMode.EnableWindow(bEnabled);
    ::EnableWindow(GetDlgItem(IDC_STATICPOLARITY), bEnabled);
    m_ComboBoxPolarity.EnableWindow(bEnabled);
    
    m_ComboBoxPolarity.AddString("Low Active");
    m_ComboBoxPolarity.AddString("High Active");
    
    if ( m_Camera.Trigger.IsSupported(inqPolarity) )
    {
      m_ComboBoxPolarity.SetCurSel(m_Camera.Trigger.Polarity());
    }
    else
    {
      m_ComboBoxPolarity.EnableWindow(FALSE);
      ::EnableWindow(GetDlgItem(IDC_STATICPOLARITY), FALSE);
      m_ComboBoxPolarity.SetCurSel(0);
    }
    
    DCSTriggerMode mode = (DCSTriggerMode) -1;
    if ( m_Camera.Trigger.IsSupported(inqReadOut) )
      mode = m_Camera.Trigger.Mode();
    int nModes = 0;
    for ( int i = 0; i < 4; i++ )
    {
      if ( m_Camera.Trigger.IsModeSupported( (DCSTriggerMode) i ) )
      {
        CString str;
        str.Format("Trigger Mode %d", i);
        m_ComboBoxMode.AddString(str);
        m_ComboBoxMode.SetItemData(nModes, i);
        if ( mode == i )
        {
          m_ComboBoxMode.SetCurSel( nModes);
        }
        nModes++;
      }
    }
    if ( nModes == 0 )
    {
      m_ComboBoxMode.EnableWindow(FALSE);
      ::EnableWindow(GetDlgItem(IDC_STATICMODE), FALSE);
    }
  }
  CATCH_REPORT();

  return 0;

}

LRESULT CTriggerPropertyPage::OnEnable(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/,  BOOL& bHandled)
{
  try
  {
    BOOL bEnable = IsDlgButtonChecked(IDC_CHECKENABLE) == BST_CHECKED;
    ::EnableWindow(GetDlgItem(IDC_STATICMODE), bEnable);
    m_ComboBoxMode.EnableWindow(bEnable);
    ::EnableWindow(GetDlgItem(IDC_STATICPOLARITY), bEnable && m_Camera.Trigger.IsSupported(inqPolarity));
    m_ComboBoxPolarity.EnableWindow(bEnable && m_Camera.Trigger.IsSupported(inqPolarity));
    
    SetModified(TRUE);
  } CATCH_REPORT();

  return 0;
}

LRESULT CTriggerPropertyPage::OnSelChange(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/,  BOOL& bHandled)
{
  SetModified(TRUE);

  return 0;
}

BOOL CTriggerPropertyPage::OnKillActive()
{
  try
  {

    bool bEnable = IsDlgButtonChecked(IDC_CHECKENABLE) == BST_CHECKED;

    m_Camera.Trigger.OnOff = bEnable;

    if ( bEnable )
    {
      if ( m_ComboBoxMode.GetCurSel() != -1 )
      {
        int mode = m_ComboBoxMode.GetItemData(m_ComboBoxMode.GetCurSel());
        m_Camera.Trigger.Mode = (DCSTriggerMode) mode;
      }

      if ( m_Camera.Trigger.IsSupported(inqPolarity) )
      {
        m_Camera.Trigger.Polarity = m_ComboBoxPolarity.GetCurSel() == 1 ? HighActive : LowActive;
      }
    }
  }
  CATCH_REPORT();
  return TRUE;
}


////////////////////////////////////////////////////////////////////////////////////
//
//    class CAdvancedPropertyPage
//

LRESULT CAdvancedPropertyPage::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
  m_ComboBoxTestImageMode.Attach(GetDlgItem(IDC_COMBOTESTIMAGEMODE));

  try
  {
    // testimage related stuff
  
    if ( ! m_Camera.TestImage.IsSupported() )
    {
      m_ComboBoxTestImageMode.EnableWindow(FALSE);
      ::EnableWindow(GetDlgItem(IDC_STATICTESTIMAGE), FALSE);
    }
    else
    {
      ImageOnMode currentTestImage = m_Camera.TestImage();
      m_ComboBoxTestImageMode.EnableWindow(TRUE);
      ::EnableWindow(GetDlgItem(IDC_STATICTESTIMAGE), TRUE);
      m_ComboBoxTestImageMode.AddString("Disabled");
      m_ComboBoxTestImageMode.SetItemData(0, 0);
      if ( currentTestImage == TestImage_Disabled )
        m_ComboBoxTestImageMode.SetCurSel(0);
      int idx = 1;
      for ( int i = 1; i < 7; i ++ )
      {
        if ( m_Camera.TestImage.IsSupported((Supported_t) i ) )
        {
          CString str;
          str.Format("Test Image %d", i);
          m_ComboBoxTestImageMode.AddString(str);
          m_ComboBoxTestImageMode.SetItemData(idx, i);
          if ( currentTestImage == i )
            m_ComboBoxTestImageMode.SetCurSel(idx);
          idx++;
        }
      }
    }
  }
  CATCH_REPORT();

  // shading correction

  m_ComboBoxShadingMode.Attach(GetDlgItem(IDC_COMBOSHADINGMODE));
  
  try
  {
    BOOL enable = m_Camera.ShadingCorrection.IsSupported();

    m_ComboBoxShadingMode.EnableWindow(enable);
    ::EnableWindow(GetDlgItem(IDC_STATICSHADING), enable);
    ::EnableWindow(GetDlgItem(IDC_UPLOAD_FILE), enable);
    ::EnableWindow(GetDlgItem(IDC_UPLOAD_CURRENT), enable && m_Camera.GetBitmap() );
    ::EnableWindow(GetDlgItem(IDC_STATICSHADINGMODE), enable);


    int idx = 0;
    if ( enable )
    {
      SCMode_t currentShadingMode = m_Camera.ShadingCorrection();

      for ( int i = -1; i <= SCM_1_5; i ++ )
      {
        CString str;
        bool add = false;
        switch ( i )
        {
       
        case SCM_Test:
          str = "Test Mode";
          add = m_Camera.ShadingCorrection.IsSupported();
          break;
        case SCM_Disabled:
          str = "Disabled";
          add = true;
          break;
        case SCM_1_3:
          str = "Shading Enabled (factor 1:3)";
          add = m_Camera.ShadingCorrection.IsSupported(inqSCM_1_3);
          break;
        case SCM_1_5:
          str = "Shading Enabled (factor 1:5)";
          add = m_Camera.ShadingCorrection.IsSupported(inqSCM_1_5);
          break;
        default:
          assert(false);
        }
        if ( add )
        {
          m_ComboBoxShadingMode.AddString(str);
          m_ComboBoxShadingMode.SetItemData(idx, i);
          if ( currentShadingMode == i )
            m_ComboBoxShadingMode.SetCurSel(idx);
          idx++;
        }
      }
    }
  }
  CATCH_REPORT();

  return 0;

}


LRESULT CAdvancedPropertyPage::OnSelChange(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/,  BOOL& bHandled)
{
  SetModified(TRUE);
  return 0;
}

LRESULT CAdvancedPropertyPage::OnClickedUploadCurrent(WORD /*code*/, WORD /*id*/, HWND /*hWnd*/,  BOOL& bHandled)
{
  assert ( m_Camera.ShadingCorrection.IsSupported() );
  assert ( m_Camera.GetBitmap() != NULL);

  try
  {

    UploadShadingTable(*m_Camera.GetBitmap());
  }
  CATCH_REPORT();

  return 0;
}


BOOL CAdvancedPropertyPage::OnKillActive()
{
  try
  {
    
    if ( m_ComboBoxTestImageMode.GetCurSel() != -1 )
    {
      m_Camera.TestImage = (ImageOnMode) m_ComboBoxTestImageMode.GetItemData(m_ComboBoxTestImageMode.GetCurSel());
    }

    if ( m_ComboBoxShadingMode.GetCurSel() != -1 )
    {
      m_Camera.ShadingCorrection = (SCMode_t) m_ComboBoxShadingMode.GetItemData(m_ComboBoxShadingMode.GetCurSel());
    }

  }
  CATCH_REPORT();
  return TRUE;
}

BOOL CAdvancedPropertyPage::UploadShadingTable(CBcamBitmap& bitmap)
{
  // check if the color code of the bitmap is MONO8
  if ( bitmap.GetColorCode() != DCSColor_Mono8 )
  {
    throw BcamException(E_WRONG_COLOR_FORMAT);
  }

  // check if the size of the bitmap matches the current image size
  DCSVideoFormat format;
  DCSVideoMode mode;
  m_Camera.GetVideoMode(&format, &mode, NULL);
  CSize size = format == DCS_Format7 ? m_Camera.FormatSeven[mode].Size() : BcamUtility::ImageSize(format, mode);
  if ( size != bitmap.GetSize() )
  {
    throw BcamException(E_SHADING_TABELE_DOES_NOT_MATCH);
  }

  // check, if the bitmap gives us a hint which shading mode to use with the shading table
  if ( bitmap.HasUserData() )
  {
    // select the mode
    for ( int i = 0; i < m_ComboBoxShadingMode.GetCount(); ++i )
    {
      if ( m_ComboBoxShadingMode.GetItemData(i) == bitmap.GetUserData() )
      {
        m_ComboBoxShadingMode.SetCurSel(i);
        break;
      }
    }
  }

  CUploadDlg* pUploadDialog = new CUploadDlg(m_Camera, bitmap);
  if ( pUploadDialog == NULL )
    throw BcamException(E_OUTOFMEMORY);
  
  BOOL ret = pUploadDialog->DoModal() != IDCANCEL;

  delete pUploadDialog;
  
  return ret;

}


////////////////////////////////////////////////////////////////////////////////////
//
//    class CPropertyDlg
//

CPropertyDlg::CPropertyDlg(CCamera& Camera) 
: dlgBase("Properties"), 
  m_InfoPropertyPage(Camera),
  m_FormatPropertyPage(Camera),
  m_TriggerPropertyPage(Camera),
  m_AdvancedPropertyPage(Camera)

{
  AddPage(m_InfoPropertyPage);
  AddPage(m_FormatPropertyPage);
  AddPage(m_TriggerPropertyPage);
  AddPage(m_AdvancedPropertyPage);
}

CPropertyDlg::~CPropertyDlg()
{

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -