2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
457 lines
16 KiB
C++
457 lines
16 KiB
C++
#include "FrameParams.h"
|
|
#include "ui_FrameParams.h"
|
|
|
|
FrameParams::FrameParams(QWidget* parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::FrameParams)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
m_bFileType = true;
|
|
m_nCardCount = 0;
|
|
|
|
memset(&m_varFrameFormat_File, 0, sizeof(GFrameFormat));
|
|
memset(&m_varFrameFormat_CPL64, 0, sizeof(GFrameFormat_CPL64));
|
|
|
|
InitStyle();
|
|
|
|
Connect();
|
|
}
|
|
|
|
FrameParams::~FrameParams()
|
|
{
|
|
Disconnect();
|
|
|
|
delete ui;
|
|
}
|
|
|
|
void FrameParams::SetFileType(bool bFileType)
|
|
{
|
|
m_bFileType = bFileType;
|
|
}
|
|
|
|
void FrameParams::SetCardCount(int nCardCount)
|
|
{
|
|
if (nCardCount == m_nCardCount)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_nCardCount = (nCardCount > 3) ? 3 : nCardCount;
|
|
m_nCardCount = (nCardCount < 1) ? 1 : nCardCount;
|
|
|
|
ui->m_comboBox_CardNo->clear();
|
|
|
|
for (int i = 0; i < m_nCardCount; i++)
|
|
{
|
|
QString str = QString(" %1").arg(i);
|
|
ui->m_comboBox_CardNo->addItem(str);
|
|
}
|
|
}
|
|
|
|
void FrameParams::InitStyle()
|
|
{
|
|
m_bMousePressed = false;
|
|
|
|
//安装事件监听器,让标题栏识别鼠标双击
|
|
ui->lblTitle->installEventFilter(this);
|
|
ui->ParaTitleBar->installEventFilter(this);
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint
|
|
| Qt::WindowSystemMenuHint
|
|
| Qt::WindowMinimizeButtonHint);
|
|
|
|
this->setAttribute(Qt::WA_Mapped); // 解决Qt::FramelessWindowHint不能自主刷新问题
|
|
}
|
|
|
|
bool FrameParams::eventFilter(QObject* obj, QEvent* event)
|
|
{
|
|
//if (ui->lblTitle == obj)
|
|
{
|
|
if (event->type() == QEvent::MouseButtonPress)
|
|
{
|
|
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
|
|
|
if (mouseEvent->button() == Qt::LeftButton)
|
|
{
|
|
m_bMousePressed = true;
|
|
m_ptMouse = mouseEvent->globalPos() - pos();
|
|
mouseEvent->accept();
|
|
}
|
|
return true;
|
|
}
|
|
else if (event->type() == QEvent::MouseMove)
|
|
{
|
|
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
|
|
|
if (m_bMousePressed && this->windowState() != Qt::WindowMaximized)
|
|
{
|
|
if (mouseEvent->globalY() <= qApp->desktop()->availableGeometry().bottom())
|
|
{
|
|
move(mouseEvent->globalPos() - m_ptMouse);
|
|
mouseEvent->accept();
|
|
}
|
|
else
|
|
{
|
|
qApp->desktop()->cursor().setPos(
|
|
qApp->desktop()->cursor().pos().x(),
|
|
qApp->desktop()->availableGeometry().bottom()
|
|
);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
else if (event->type() == QEvent::MouseButtonRelease)
|
|
{
|
|
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
|
|
|
if (mouseEvent->button() == Qt::LeftButton)
|
|
{
|
|
m_bMousePressed = false;
|
|
mouseEvent->accept();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
return QDialog::eventFilter(obj, event);
|
|
}
|
|
|
|
void FrameParams::showEvent(QShowEvent* event)
|
|
{
|
|
UpdateUI(m_bFileType);
|
|
|
|
QWidget::showEvent(event);
|
|
}
|
|
|
|
void FrameParams::Connect()
|
|
{
|
|
connect(ui->m_pushButton_OK, &QPushButton::clicked, this, &FrameParams::OnButtonClicked);
|
|
connect(ui->m_pushButton_Cancel, &QPushButton::clicked, this, &FrameParams::OnButtonClicked);
|
|
|
|
connect(ui->m_comboBox_DevType, SIGNAL(activated(int)), this, SLOT(OnComboxIndexChanged_CtrlCmd(int)));
|
|
}
|
|
|
|
void FrameParams::Disconnect()
|
|
{
|
|
disconnect(ui->m_pushButton_OK, &QPushButton::clicked, this, &FrameParams::OnButtonClicked);
|
|
disconnect(ui->m_pushButton_Cancel, &QPushButton::clicked, this, &FrameParams::OnButtonClicked);
|
|
}
|
|
|
|
void FrameParams::UpdateUI(bool bFileType)
|
|
{
|
|
if (bFileType)
|
|
{
|
|
ui->lblTitle->setText("文件参数设置");
|
|
//
|
|
ui->m_label_CardNo->setEnabled(false);
|
|
ui->m_label_CardNo->setVisible(false);
|
|
ui->m_comboBox_CardNo->setEnabled(false);
|
|
ui->m_comboBox_CardNo->setVisible(false);
|
|
|
|
ui->m_label_ChannelNo->setEnabled(false);
|
|
ui->m_label_ChannelNo->setVisible(false);
|
|
ui->m_comboBox_ChannelNo->setEnabled(false);
|
|
ui->m_comboBox_ChannelNo->setVisible(false);
|
|
|
|
ui->m_label_DevType->setEnabled(false);
|
|
ui->m_label_DevType->setVisible(false);
|
|
ui->m_comboBox_DevType->setEnabled(false);
|
|
ui->m_comboBox_DevType->setVisible(false);
|
|
|
|
//
|
|
//ui->m_label_CardNo->setGeometry(0, 40, 120, 25);
|
|
//ui->m_comboBox_CardNo->setGeometry(130, 40, 100, 25);
|
|
|
|
//ui->m_label_ChannelNo->setGeometry(0, 70, 120, 25);
|
|
//ui->m_comboBox_ChannelNo->setGeometry(130, 70, 100, 25);
|
|
|
|
const int c_nYOffset = 60;
|
|
|
|
ui->m_label_ImageWidth->setGeometry(0, 100 - c_nYOffset, 120, 25);
|
|
ui->m_lineEdit_ImageWidth->setGeometry(130, 100 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_ImageHeight->setGeometry(0, 130 - c_nYOffset, 120, 25);
|
|
ui->m_lineEdit_ImageHeight->setGeometry(130, 130 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_CmdLinePos->setGeometry(0, 160 - c_nYOffset, 120, 25);
|
|
ui->m_lineEdit_CmdLinePos->setGeometry(130, 160 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_CmdLineCount->setGeometry(0, 190 - c_nYOffset, 120, 25);
|
|
ui->m_lineEdit_CmdLineCount->setGeometry(130, 190 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_PixelType->setGeometry(0, 220 - c_nYOffset, 120, 25);
|
|
ui->m_comboBox_PixelType->setGeometry(130, 220 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_PixelByteOrder->setGeometry(0, 250 - c_nYOffset, 120, 25);
|
|
ui->m_comboBox_PixelByteOrder->setGeometry(130, 250 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_FrameRate->setGeometry(0, 280 - c_nYOffset, 120, 25);
|
|
ui->m_lineEdit_FrameRate->setGeometry(130, 280 - c_nYOffset, 100, 25);
|
|
|
|
ui->m_label_FrameRate->setEnabled(true);
|
|
ui->m_label_FrameRate->setVisible(true);
|
|
ui->m_lineEdit_FrameRate->setEnabled(true);
|
|
ui->m_lineEdit_FrameRate->setVisible(true);
|
|
|
|
}
|
|
else
|
|
{
|
|
ui->lblTitle->setText("设备参数设置");
|
|
//
|
|
ui->m_label_CardNo->setEnabled(true);
|
|
ui->m_label_CardNo->setVisible(true);
|
|
ui->m_comboBox_CardNo->setEnabled(true);
|
|
ui->m_comboBox_CardNo->setVisible(true);
|
|
|
|
ui->m_label_ChannelNo->setEnabled(true);
|
|
ui->m_label_ChannelNo->setVisible(true);
|
|
ui->m_comboBox_ChannelNo->setEnabled(true);
|
|
ui->m_comboBox_ChannelNo->setVisible(true);
|
|
|
|
ui->m_label_DevType->setEnabled(true);
|
|
ui->m_label_DevType->setVisible(true);
|
|
ui->m_comboBox_DevType->setEnabled(true);
|
|
ui->m_comboBox_DevType->setVisible(true);
|
|
|
|
//
|
|
ui->m_label_DevType->setGeometry(0, 40, 120, 25);
|
|
ui->m_comboBox_DevType->setGeometry(130, 40, 100, 25);
|
|
|
|
ui->m_label_CardNo->setGeometry(0, 70, 120, 25);
|
|
ui->m_comboBox_CardNo->setGeometry(130, 70, 100, 25);
|
|
|
|
ui->m_label_ChannelNo->setGeometry(0, 100, 120, 25);
|
|
ui->m_comboBox_ChannelNo->setGeometry(130, 100, 100, 25);
|
|
|
|
ui->m_label_ImageWidth->setGeometry(0, 130, 120, 25);
|
|
ui->m_lineEdit_ImageWidth->setGeometry(130, 130, 100, 25);
|
|
|
|
ui->m_label_ImageHeight->setGeometry(0, 160, 120, 25);
|
|
ui->m_lineEdit_ImageHeight->setGeometry(130, 160, 100, 25);
|
|
|
|
ui->m_label_CmdLinePos->setGeometry(0, 190, 120, 25);
|
|
ui->m_lineEdit_CmdLinePos->setGeometry(130, 190, 100, 25);
|
|
|
|
ui->m_label_CmdLineCount->setGeometry(0, 220, 120, 25);
|
|
ui->m_lineEdit_CmdLineCount->setGeometry(130, 220, 100, 25);
|
|
|
|
ui->m_label_PixelType->setGeometry(0, 250, 120, 25);
|
|
ui->m_comboBox_PixelType->setGeometry(130, 250, 100, 25);
|
|
|
|
ui->m_label_PixelByteOrder->setGeometry(0, 280, 120, 25);
|
|
ui->m_comboBox_PixelByteOrder->setGeometry(130, 280, 100, 25);
|
|
|
|
ui->m_label_FrameRate->setGeometry(0, 310, 120, 25);
|
|
ui->m_lineEdit_FrameRate->setGeometry(130, 310, 100, 25);
|
|
|
|
// ui->m_label_FrameRate->setEnabled(false);
|
|
// ui->m_label_FrameRate->setVisible(false);
|
|
// ui->m_lineEdit_FrameRate->setEnabled(false);
|
|
// ui->m_lineEdit_FrameRate->setVisible(false);
|
|
}
|
|
}
|
|
|
|
void FrameParams::OnButtonClicked()
|
|
{
|
|
if (sender() == ui->m_pushButton_OK)
|
|
{
|
|
this->hide();
|
|
|
|
if (m_bFileType)
|
|
{
|
|
m_varFrameFormat_File.nImageWidth = ui->m_lineEdit_ImageWidth->text().toInt();
|
|
m_varFrameFormat_File.nImageHeight = ui->m_lineEdit_ImageHeight->text().toInt();
|
|
m_varFrameFormat_File.nParamStartLine = ui->m_lineEdit_CmdLinePos->text().toInt();
|
|
m_varFrameFormat_File.nParamLineCount = ui->m_lineEdit_CmdLineCount->text().toInt();
|
|
m_varFrameFormat_File.nFrameRate = ui->m_lineEdit_FrameRate->text().toInt();
|
|
m_varFrameFormat_File.nBytesOfPixel = 0;
|
|
m_varFrameFormat_File.eBO = (eByteOrder)(ui->m_comboBox_PixelByteOrder->currentIndex() + 1);
|
|
m_varFrameFormat_File.ePT = (ePixelType)(ui->m_comboBox_PixelType->currentIndex() + 1);
|
|
|
|
switch (m_varFrameFormat_File.ePT)
|
|
{
|
|
case ePT_Y8:
|
|
m_varFrameFormat_File.nBytesOfPixel = 1;
|
|
break;
|
|
case ePT_Y16U:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_Y16:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_X16:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_XMix16:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_RGBA24:
|
|
m_varFrameFormat_File.nBytesOfPixel = 3;
|
|
break;
|
|
case ePT_RGBA32:
|
|
m_varFrameFormat_File.nBytesOfPixel = 4;
|
|
break;
|
|
case ePT_YUV422:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_YUV420P:
|
|
case ePT_YV12:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2; //1.5
|
|
break;
|
|
default:
|
|
m_varFrameFormat_File.nBytesOfPixel = 2;
|
|
break;
|
|
}
|
|
|
|
emit sigConfirm_File(true, m_varFrameFormat_File);
|
|
}
|
|
else
|
|
{
|
|
m_varFrameFormat_CPL64.nCardNo = ui->m_comboBox_CardNo->currentIndex();
|
|
m_varFrameFormat_CPL64.nChannelNo = ui->m_comboBox_ChannelNo->currentIndex();
|
|
|
|
m_varFrameFormat_CPL64.DevType = (eGDeviceType)(ui->m_comboBox_DevType->currentIndex() + 1);
|
|
|
|
m_varFrameFormat_CPL64.varFrameFormat.nImageWidth = ui->m_lineEdit_ImageWidth->text().toInt();
|
|
m_varFrameFormat_CPL64.varFrameFormat.nImageHeight = ui->m_lineEdit_ImageHeight->text().toInt();
|
|
m_varFrameFormat_CPL64.varFrameFormat.nParamStartLine = ui->m_lineEdit_CmdLinePos->text().toInt();
|
|
m_varFrameFormat_CPL64.varFrameFormat.nParamLineCount = ui->m_lineEdit_CmdLineCount->text().toInt();
|
|
// m_varFrameFormat_CPL64.varFrameFormat.nFrameRate = 0;//ui->m_lineEdit_FrameRate->text().toInt();
|
|
m_varFrameFormat_CPL64.varFrameFormat.nFrameRate = ui->m_lineEdit_FrameRate->text().toInt();
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 0;
|
|
m_varFrameFormat_CPL64.varFrameFormat.eBO = (eByteOrder)(ui->m_comboBox_PixelByteOrder->currentIndex() + 1);
|
|
m_varFrameFormat_CPL64.varFrameFormat.ePT = (ePixelType)(ui->m_comboBox_PixelType->currentIndex() + 1);
|
|
|
|
switch (m_varFrameFormat_CPL64.varFrameFormat.ePT)
|
|
{
|
|
case ePT_Y8:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 1;
|
|
break;
|
|
case ePT_Y16U:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_Y16:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_X16:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_XMix16:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_RGBA24:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 3;
|
|
break;
|
|
case ePT_RGBA32:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 4;
|
|
break;
|
|
case ePT_YUV422:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
case ePT_YUV420P:
|
|
case ePT_YV12:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2; //1.5
|
|
break;
|
|
default:
|
|
m_varFrameFormat_CPL64.varFrameFormat.nBytesOfPixel = 2;
|
|
break;
|
|
}
|
|
|
|
emit sigConfirm_CPL64(true, m_varFrameFormat_CPL64);
|
|
}
|
|
}
|
|
|
|
if (sender() == ui->m_pushButton_Cancel)
|
|
{
|
|
this->hide();
|
|
|
|
if (m_bFileType)
|
|
{
|
|
emit sigConfirm_File(false, m_varFrameFormat_File);
|
|
}
|
|
else
|
|
{
|
|
emit sigConfirm_CPL64(false, m_varFrameFormat_CPL64);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FrameParams::on_m_comboBox_DevType_currentIndexChanged(int index)
|
|
{
|
|
switch (index)
|
|
{
|
|
case 0:
|
|
ui->m_comboBox_CardNo->setEnabled(true);
|
|
ui->m_comboBox_ChannelNo->setEnabled(true);
|
|
break;
|
|
|
|
case 1:
|
|
ui->m_comboBox_CardNo->setEnabled(false);
|
|
ui->m_comboBox_ChannelNo->setEnabled(false);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
void FrameParams::OnComboxIndexChanged_CtrlCmd(int nIndex)
|
|
{
|
|
if (sender() == ui->m_comboBox_DevType)
|
|
{
|
|
eGDeviceType devType;
|
|
devType = (eGDeviceType)(nIndex + 1);
|
|
switch (devType)
|
|
{
|
|
case eGDT_CameraLink:
|
|
{
|
|
ui->m_comboBox_CardNo->setEnabled(true);
|
|
ui->m_comboBox_ChannelNo->setEnabled(true);
|
|
|
|
ui->m_lineEdit_ImageWidth->setText(QString::number(640));
|
|
ui->m_lineEdit_ImageWidth->setEnabled(true);
|
|
|
|
ui->m_lineEdit_ImageHeight->setText(QString::number(512));
|
|
ui->m_lineEdit_ImageHeight->setEnabled(true);
|
|
|
|
break;
|
|
}
|
|
case eGDT_CPLToUSB:
|
|
{
|
|
ui->m_comboBox_CardNo->setEnabled(false);
|
|
ui->m_comboBox_ChannelNo->setEnabled(false);
|
|
|
|
ui->m_lineEdit_ImageWidth->setText(QString::number(640));
|
|
ui->m_lineEdit_ImageWidth->setEnabled(true);
|
|
|
|
ui->m_lineEdit_ImageHeight->setText(QString::number(512));
|
|
ui->m_lineEdit_ImageHeight->setEnabled(true);
|
|
|
|
break;
|
|
}
|
|
case eGDT_USB3:
|
|
{
|
|
ui->m_comboBox_CardNo->setEnabled(false);
|
|
ui->m_comboBox_ChannelNo->setEnabled(false);
|
|
|
|
ui->m_lineEdit_ImageWidth->setText(QString::number(1280));
|
|
// ui->m_lineEdit_ImageWidth->setEnabled(false);
|
|
ui->m_lineEdit_ImageWidth->setEnabled(true);
|
|
|
|
ui->m_lineEdit_ImageHeight->setText(QString::number(1024));
|
|
// ui->m_lineEdit_ImageHeight->setEnabled(false);
|
|
ui->m_lineEdit_ImageHeight->setEnabled(true);
|
|
|
|
|
|
ui->m_comboBox_PixelType->setCurrentIndex(5);
|
|
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|