You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
whellvalue/tpvs17/tpMain/QCamSettingDlg.cpp

199 lines
4.6 KiB
C++

#include "QCamSettingDlg.h"
#pragma execution_character_set("utf-8")
QCamSettingDlg::QCamSettingDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
setWindowIcon(QIcon(":/image/leaper"));
QGridLayout *pLayout = new QGridLayout(ui.widget);
m_pImgViewer = new RoiImgViewer(ui.widget);
m_pImgViewer->setObjectName("Imageview_Setting");
pLayout->addWidget(m_pImgViewer);
ui.widget->setLayout(pLayout);
connect(ui.m_pbSetRect, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbSetParam, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbOpen, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbSetting, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbTrigger, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.toolButton, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
}
QCamSettingDlg::~QCamSettingDlg()
{
if (m_pImgViewer)
{
delete m_pImgViewer;
m_pImgViewer = nullptr;
}
}
void QCamSettingDlg::onShowImage(QImage img)
{
if (m_pImgViewer)
{
m_pImgViewer->setImg(img);
}
}
void QCamSettingDlg::onInitWidget()
{
if (m_pCoreCtl)
{
QStringList lst = m_pCoreCtl->ICameraKeys();
if (lst.size() <= 0)
return;
m_curCamKey = lst.first();
ui.m_SerialNo->setText(m_curCamKey);
QMap<QString, QString> map = m_pCoreCtl->IGetCamShowNames();
QString strShow = map[m_curCamKey];
ui.m_ShowName->setText(strShow);
TP_CAMERA_OPTION camOpt;
m_pCoreCtl->IGetCameraOption(m_curCamKey, camOpt);
int h = camOpt.height;
int w = camOpt.width;
int e = camOpt.exposure;
int g = camOpt.gain;
// int h = 0, w = 0;;
// m_pCoreCtl->IGetHeight(m_curCamKey,h);
// m_pCoreCtl->IGetWidth(m_curCamKey, w);
// int e = 0, g = 0;
// m_pCoreCtl->IGetExposureTime(m_curCamKey, e);
// m_pCoreCtl->IGetGain(m_curCamKey, g);
ui.m_ImgWidth->setText(QString("%1").arg(w));
ui.m_ImgHeight->setText(QString("%1").arg(h));
ui.m_Expouse->setText(QString("%1").arg(e));
ui.m_Gain->setText(QString("%1").arg(g));
ui.lineEdit_3->setText(camOpt.folder);
{
int devType = camOpt.deviceType;
int index = 0;
switch (devType)
{
case 100:
index = 0;
onShowVirtualDir(true);
break;
case 140:
index = 1;
onShowVirtualDir(false);
break;
case 160:
index = 2;
onShowVirtualDir(false);
break;
default:
break;
}
ui.comboBox->setCurrentIndex(index);
}
{
emTpColorFormat color = camOpt.format;
if(color == TP_COLOR_Y800)
ui.m_Pixformat->setCurrentIndex(0);
else
ui.m_Pixformat->setCurrentIndex(1);
}
if (camOpt.status == TP_CAMERA_STATUS_STARTED)
{
EnableUI(false);
ui.m_pbOpen->setText(tr("关闭"));
ui.m_pbTrigger->setDisabled(false);
}
else {
ui.m_pbOpen->setText(tr("打开"));
EnableUI(true);
ui.m_pbTrigger->setDisabled(true);
}
}
}
Q_SLOT void QCamSettingDlg::onButtonClicked()
{
QString strObj = sender()->objectName();
if ("m_pbSetRect" == strObj)
{
int h = ui.m_ImgHeight->text().toInt();
int w = ui.m_ImgWidth->text().toInt();
int index = ui.m_Pixformat->currentIndex();
if (m_pCoreCtl)
{
emTpColorFormat colorf = index == 0 ? TP_COLOR_Y800 : TP_COLOR_RGB32;
m_pCoreCtl->ISetHeight(m_curCamKey, h);
m_pCoreCtl->ISetWidth(m_curCamKey, w);
//m_pCoreCtl->ISetPixelFormat();
m_pCoreCtl->saveConfig();
}
}
else if ("m_pbSetParam" == strObj)
{
int e = ui.m_Expouse->text().toInt();
int g = ui.m_Gain->text().toInt();
if (m_pCoreCtl)
{
m_pCoreCtl->ISetExposureTime(m_curCamKey, e);
m_pCoreCtl->ISetGain(m_curCamKey, g);
m_pCoreCtl->saveConfig();
}
}
else if ("m_pbOpen" == strObj)
{
if (m_pCoreCtl)
{
if (tr("关闭") == ui.m_pbOpen->text())
{
m_pCoreCtl->ICloseCamera(m_curCamKey);
ui.m_pbOpen->setText(tr("打开"));
EnableUI(true);
}
else
{
m_pCoreCtl->IOpenCamera(m_curCamKey);
m_pCoreCtl->IStartCamera(m_curCamKey);
ui.m_pbOpen->setText(tr("关闭"));
EnableUI(false);
}
}
}
else if ("m_pbSetting" == strObj)
{
}
else if ("m_pbTrigger" == strObj)
{
if (m_pCoreCtl)
m_pCoreCtl->ISnapImage(QStringList() << m_curCamKey);
}
else if ("toolButton" == strObj)
{
}
}
void QCamSettingDlg::onShowVirtualDir(bool bShow)
{
ui.label_4->setVisible(bShow);
ui.lineEdit_3->setVisible(bShow);
ui.m_pbSetting->setVisible(bShow);
}
void QCamSettingDlg::EnableUI(bool b)
{
ui.m_SerialNo->setDisabled(!b);
ui.m_ShowName->setDisabled(!b);
ui.comboBox->setDisabled(!b);
ui.m_Pixformat->setDisabled(!b);
ui.toolButton->setDisabled(!b);
ui.comboBox_3->setDisabled(!b);
ui.m_pbSetRect->setDisabled(!b);
ui.m_ImgWidth->setDisabled(!b);
ui.m_ImgHeight->setDisabled(!b);
}