2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
5132 lines
166 KiB
C++
5132 lines
166 KiB
C++
#include "mainwindow.h"
|
||
#include "ui_mainwindow.h"
|
||
|
||
#include <QFile>
|
||
#include <QMessageBox>
|
||
#include <QFileDialog>
|
||
#include <QString>
|
||
#include <QDebug>
|
||
|
||
#include <QMenu>
|
||
#include <QAction>
|
||
#include <QComboBox>
|
||
#include <QStyledItemDelegate>
|
||
#include "UIHelp/commonhelper.h"
|
||
#include "UIHelp/frameless_helper.h"
|
||
#include "Protocal/Protocal_Cmds.h"
|
||
|
||
#include "FileOperator.h"
|
||
//#include "gdsetlicense.h"
|
||
|
||
#include "CommSerialDef.h"
|
||
#include "GdImageLib.h"
|
||
//using namespace GdImageLib;
|
||
|
||
#include "Logger.h"
|
||
|
||
#include <mmsystem.h>
|
||
#include <QDateTime>
|
||
|
||
#pragma comment(lib, "winmm")
|
||
|
||
int c_nWMemSize = DefaultMaxImageSize;
|
||
int c_nRMemSize = 16 * 1025;
|
||
int IMG_WIDTH = DefaultImageWidth;
|
||
int IMG_HEIGHT = DefaultImageHeight;
|
||
|
||
extern bool g_bExpertMode;
|
||
|
||
|
||
indexofX Test(FILE* fid, int x, int y, int nWidth, int nHeight)
|
||
{
|
||
indexofX resuleofX = {0, 0};
|
||
int count = 0;
|
||
int pSrcA[100];
|
||
double arg1 = 0;
|
||
double arg2 = 0;
|
||
long sum1 = 0;
|
||
long sum2 = 0;
|
||
int sum5 = 0;
|
||
int nLen = nWidth * nHeight;
|
||
int num = 100; //取100帧计算
|
||
double avg5 = 0;
|
||
double stv5 = 0;
|
||
int i = 0;
|
||
unsigned short* pSrcImg = (unsigned short*)malloc(sizeof(unsigned short) * nLen);
|
||
|
||
for (i = 0; i < num; i++)
|
||
{
|
||
fread(pSrcImg, sizeof(unsigned short)*nLen, 1, fid);
|
||
|
||
//求图像的均值
|
||
//resuleofX.arg5 = GetAvg(pSrcImg,nWidth,nHeight);
|
||
|
||
sum5 = sum5 + pSrcImg[x * nWidth + y];
|
||
pSrcA[i] = pSrcImg[x * nWidth + y];
|
||
}
|
||
|
||
resuleofX.arg5 = (sum5 * 1.0) / num; //求所取点的均值
|
||
avg5 = resuleofX.arg5;
|
||
i = 0;
|
||
sum5 = 0;
|
||
|
||
for (int j = 0; j < num; j++)
|
||
{
|
||
resuleofX.stv5 = resuleofX.stv5 + (pSrcA[j] - avg5) * (pSrcA[j] - avg5);
|
||
}
|
||
resuleofX.stv5 = sqrt(resuleofX.stv5 / num); //求时域标准差
|
||
|
||
/*printf("时域标准差:%-8.4f\n",stv5);
|
||
printf("均值:%-8.4f\n",avg5);*/
|
||
|
||
free(pSrcImg);
|
||
return resuleofX;
|
||
}
|
||
|
||
void QComboBox::wheelEvent(QWheelEvent* e)
|
||
{
|
||
|
||
}
|
||
|
||
MainWindow::MainWindow(QWidget* parent) :
|
||
QMainWindow(parent),
|
||
ui(new Ui::MainWindow)
|
||
{
|
||
// if(AddGDLicense())
|
||
// {
|
||
ui->setupUi(this);
|
||
|
||
// 初始化界面
|
||
InitStyle();
|
||
|
||
GLogger::GetInstance()->WriteInfo("initStyle");
|
||
// 初始化参数
|
||
InitPara();
|
||
|
||
GLogger::GetInstance()->WriteInfo("initPara");
|
||
// 加载信号槽函数连接
|
||
Connect();
|
||
// }
|
||
// else
|
||
// {
|
||
// CommonHelper::ShowMessageBoxError("软件未授权");
|
||
// return;
|
||
// }
|
||
|
||
ui->m_Btn_Settings->hide();
|
||
ui->m_Btn_ControlASCII->hide();
|
||
|
||
}
|
||
|
||
MainWindow::~MainWindow()
|
||
{
|
||
|
||
//质量评估窗口
|
||
//
|
||
//关闭线程
|
||
if (m_bThreadRunning_ImageQuality)
|
||
{
|
||
m_bThreadRunning_ImageQuality = false;
|
||
if (nullptr != m_ptrThread_ImageQuality)
|
||
{
|
||
m_ptrThread_ImageQuality->join();
|
||
delete m_ptrThread_ImageQuality;
|
||
m_ptrThread_ImageQuality = nullptr;
|
||
}
|
||
}
|
||
|
||
if (nullptr != m_pLineArrayValues)
|
||
{
|
||
delete [] m_pLineArrayValues;
|
||
m_pLineArrayValues = nullptr;
|
||
}
|
||
if (nullptr != m_pY8BadPointData)
|
||
{
|
||
delete [] m_pY8BadPointData;
|
||
m_pY8BadPointData = nullptr;
|
||
}
|
||
if (nullptr != m_pY16Data_B1)
|
||
{
|
||
delete [] m_pY16Data_B1;
|
||
m_pY16Data_B1 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pY8Data_B1)
|
||
{
|
||
delete [] m_pY8Data_B1;
|
||
m_pY8Data_B1 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pY16Data_B2)
|
||
{
|
||
delete [] m_pY16Data_B2;
|
||
m_pY16Data_B2 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pY8Data_B2)
|
||
{
|
||
delete [] m_pY8Data_B2;
|
||
m_pY8Data_B2 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pRGBA)
|
||
{
|
||
delete [] m_pRGBA;
|
||
m_pRGBA = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pY16Data_KList)
|
||
{
|
||
delete [] m_pY16Data_KList;
|
||
m_pY16Data_KList = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pY16Data_BPList)
|
||
{
|
||
delete [] m_pY16Data_BPList;
|
||
m_pY16Data_BPList = nullptr;
|
||
}
|
||
|
||
m_timerDrawLine.stop();
|
||
|
||
for (int i = 0; i < MAX_QUALITY_PARAMS; i++)
|
||
{
|
||
delete m_pPlotCommon[i];
|
||
}
|
||
|
||
|
||
//
|
||
StopThread_DealDeviceData();
|
||
StopThread_DealRawFileData();
|
||
StopThread_SendCmd();
|
||
|
||
//
|
||
if (nullptr != m_pSettingsPanel)
|
||
{
|
||
delete m_pSettingsPanel;
|
||
m_pSettingsPanel = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pSettingsControl)
|
||
{
|
||
delete m_pSettingsControl;
|
||
m_pSettingsControl = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pGetSystemCode)
|
||
{
|
||
delete m_pGetSystemCode;
|
||
m_pGetSystemCode = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pUnCoolDevSettings)
|
||
{
|
||
delete m_pUnCoolDevSettings;
|
||
m_pUnCoolDevSettings = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pOpenGLView)
|
||
{
|
||
delete m_pOpenGLView;
|
||
m_pOpenGLView = nullptr;
|
||
}
|
||
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
if (nullptr != m_recordThread[i])
|
||
{
|
||
delete m_recordThread[i];
|
||
m_recordThread[i] = nullptr;
|
||
}
|
||
}
|
||
|
||
if (nullptr != m_pDevCap)
|
||
{
|
||
delete m_pDevCap;
|
||
m_pDevCap = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_ImgProcBuf)
|
||
{
|
||
delete m_ImgProcBuf;
|
||
m_ImgProcBuf = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pTGAirthProcess->m_TGInfo.GuogaiB)
|
||
{
|
||
delete m_pTGAirthProcess->m_TGInfo.GuogaiB;
|
||
m_pTGAirthProcess->m_TGInfo.GuogaiB = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_pTGAirthProcess)
|
||
{
|
||
delete m_pTGAirthProcess;
|
||
m_pTGAirthProcess = nullptr;
|
||
}
|
||
|
||
if (m_SerialHelp != NULL)
|
||
{
|
||
delete m_SerialHelp;
|
||
m_SerialHelp = NULL;
|
||
}
|
||
|
||
if (m_pFileConvert)
|
||
{
|
||
delete m_pFileConvert;
|
||
m_pFileConvert = NULL;
|
||
}
|
||
if (m_pFileHexConvert)
|
||
{
|
||
delete m_pFileHexConvert;
|
||
m_pFileHexConvert = NULL;
|
||
}
|
||
|
||
if (m_pFileFun)
|
||
{
|
||
delete m_pFileFun;
|
||
m_pFileFun = NULL;
|
||
}
|
||
|
||
if (m_pHexBuf)
|
||
{
|
||
delete []m_pHexBuf;
|
||
m_pHexBuf = NULL;
|
||
}
|
||
|
||
Disconnect();
|
||
|
||
delete ui;
|
||
}
|
||
|
||
void MainWindow::InitPara()
|
||
{
|
||
//
|
||
//ui->m_lineEdit_FrameRate->setText(QString::number(conf->m_nFrameFre));
|
||
|
||
m_bRectDraw = false;
|
||
m_bShowRect = false;
|
||
|
||
m_bBackRectDraw = false;
|
||
m_bShowBackRect = false;
|
||
|
||
m_bMousePressed = false;
|
||
m_bFullScreen = false;
|
||
|
||
//
|
||
m_bTGSettings = false;
|
||
m_bConnectFlag = false;
|
||
m_SerialHelp = new SerialMovement(this);
|
||
m_SerialPortScan = new SerialPortScan(200);
|
||
m_SerialPortScan->ScanStart();
|
||
|
||
m_pFileConvert = new FileOperator;
|
||
m_bConvertRes = false;
|
||
|
||
m_pFileFun = new FileOperator;
|
||
m_bUpdateRes = false;
|
||
|
||
m_pFileHexConvert = new FileOperator;
|
||
m_bHexRes = false;
|
||
|
||
m_nScreenWidthMax = 1920;
|
||
m_nScreenHeightMax = 1080;
|
||
|
||
m_nOpenGLWidth = 640;;
|
||
m_nOpenGLHeight = 512;
|
||
|
||
m_bTGArithOpen = false;
|
||
// m_bTGArithOpen = true;
|
||
|
||
//
|
||
for (int i = 0; i < 9; i++)
|
||
{
|
||
QVector<QRgb> tmpVector;
|
||
|
||
for (int j = 0; j < 256; ++j)
|
||
{
|
||
int b = IRImage_ColorTable[i][j][0];
|
||
int g = IRImage_ColorTable[i][j][1];
|
||
int r = IRImage_ColorTable[i][j][2];
|
||
tmpVector.push_back(qRgb(r, g, b));
|
||
}
|
||
|
||
m_varColorTable.push_back(tmpVector);
|
||
}
|
||
|
||
//
|
||
m_bThreadRunning_CaptureDeviceData = false;
|
||
m_ptrThread_CaptureDeviceData = nullptr;
|
||
|
||
m_bThreadRunning_ProcessDeviceData = false;
|
||
m_ptrThread_ProcessDeviceData_Ch0 = nullptr;
|
||
m_ptrThread_ProcessDeviceData_Ch1 = nullptr;
|
||
|
||
m_bThreadRunning_FetchRawFileData = false;
|
||
m_ptrThread_FetchRawFileData = nullptr;
|
||
|
||
m_bThreadRunning_ProcessRawFileData = false;
|
||
m_ptrThread_ProcessRawFileData = nullptr;
|
||
|
||
m_bThreadRunning_ShowImg = false;
|
||
m_ptrThread_MappingData_Ch0 = nullptr;
|
||
m_ptrThread_MappingData_Ch1 = nullptr;
|
||
|
||
m_ptrThread_ShowImg = nullptr;
|
||
|
||
|
||
m_bThreadRunning_SendCmd = false;
|
||
m_ptrThread_SendCmd = nullptr;
|
||
|
||
m_pDevCap = nullptr;
|
||
|
||
m_pEUSetSystemType = SYSTEM_BUTT;
|
||
|
||
// 帧格式
|
||
m_pFrameParams = new FrameParams(nullptr);
|
||
memset(&m_varGFrameFormat, 0, sizeof(GFrameFormat));
|
||
memset(&m_varGFrameFormatCap, 0, sizeof(GFrameFormat_CPL64));
|
||
m_varGFrameFormat.nImageWidth = 640;
|
||
m_varGFrameFormat.nImageHeight = 512;
|
||
m_varGFrameFormat.nParamStartLine = 0;
|
||
m_varGFrameFormat.nParamLineCount = 0;
|
||
m_varGFrameFormat.nFrameRate = 25;
|
||
m_varGFrameFormat.nBytesOfPixel = 2;
|
||
m_varGFrameFormat.eBO = eBO_LittleEndian;
|
||
m_varGFrameFormat.ePT = ePT_Y16U;
|
||
|
||
m_varGFrameFormatCap.nCardNo = 0;
|
||
m_varGFrameFormatCap.nChannelNo = 0;
|
||
m_varGFrameFormatCap.DevType = eGDT_CameraLink;
|
||
m_varGFrameFormatCap.varFrameFormat = m_varGFrameFormat;
|
||
|
||
// 文件播放相关
|
||
m_strCurrentFilePath = "";
|
||
m_bRecyclePlay = false;
|
||
m_bBrowseFile = false;
|
||
m_bTriggerPausedState = false;
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i] = nullptr;
|
||
m_nProgressFrameCount[i] = 0;
|
||
}
|
||
m_nProgressFrameIndex = 0;
|
||
m_nProgressFrameCount_Sync = 0;
|
||
|
||
m_bUpdateProgress = false;
|
||
m_nProgress_FrameIndex = 0;
|
||
m_nProgress_FrameCount = 0;
|
||
|
||
|
||
//
|
||
m_bCaptureData = false;
|
||
m_bInjectData = false;
|
||
m_bEnableAurora = false;
|
||
|
||
|
||
// 设置面板
|
||
m_pSettingsPanel = new SettingsPanel(this);
|
||
m_pSettingsPanel->hide();
|
||
m_bShowSettingsPanel = false;
|
||
|
||
m_pSettingsControl = new SettingsControl(this);
|
||
m_pSettingsControl->hide();
|
||
m_bShowSettingsControl = false;
|
||
|
||
m_pGetSystemCode = new GetSystemCode(this);
|
||
m_bShowGetSystemCode = false;
|
||
|
||
m_pUnCoolDevSettings = new UnCoolDevSettings(this);
|
||
m_bShowUnCoolDev = false;
|
||
|
||
m_pOpenGLView = nullptr;
|
||
|
||
InitOpenGLView();
|
||
UpdateImgFormat();
|
||
|
||
//录像相关
|
||
m_bIsRecord = false;
|
||
QString strDirFile = QApplication::applicationDirPath();
|
||
strDirFile += "/VideoFile/";
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_recordThread[i] = new RecordThread;
|
||
m_recordThread[i]->setMaxSize(4096);
|
||
m_recordThread[i]->setRecordDir(strDirFile);//("D:/S7413-视频/");
|
||
m_recordThread[i]->init(c_nWMemSize);
|
||
m_recordThread[i]->setChannel(i);
|
||
m_recordThread[i]->SetImgSize(m_varGFrameFormat.nImageWidth * m_varGFrameFormat.nImageHeight * 2);
|
||
}
|
||
|
||
//
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_dFPS[i] = 0;
|
||
m_varCaptureData[i].InitQueue(c_nWMemSize, 6);
|
||
m_varY16Data[i].InitQueue(c_nWMemSize, 6);
|
||
m_varRawFileData[i].InitQueue(c_nWMemSize, 6);
|
||
}
|
||
|
||
m_varY8DataShow_IN.InitQueue(c_nWMemSize, 6);
|
||
|
||
m_pTGAirthProcess = new TGAirthProcess(this);
|
||
//
|
||
m_eUpgradeStatus = eUS_None;
|
||
m_bFiberLinked = false;
|
||
|
||
//
|
||
GLogger::GetInstance()->SetLogLevel(eLL_Info);
|
||
GLogger::GetInstance()->WriteDebug("test msg");
|
||
|
||
//设备采集
|
||
m_pDevCap = new GDeviceReader;
|
||
//
|
||
m_bOpenFile = false;
|
||
//播放定时器
|
||
m_iPlayState = 0;
|
||
// connect(&m_varTimerUpdate, &QTimer::timeout, this, &MainWindow::OnTimer_Play);
|
||
// m_varTimerUpdate.setTimerType(Qt::PreciseTimer);
|
||
// m_varTimerUpdate.start(1000 / conf->m_nFrameFre);
|
||
|
||
|
||
m_pTGAirthProcess->m_TGInfo.GuogaiB = new unsigned short[c_nWMemSize];
|
||
|
||
|
||
m_ImgProcBuf = new byte[c_nWMemSize];
|
||
memset(m_ImgProcBuf, 0, c_nWMemSize);
|
||
|
||
|
||
m_pOpenGLView->installEventFilter(this);
|
||
setMouseTracking(true);
|
||
|
||
|
||
//初始化图像质量评估
|
||
InitImageQualityAssess();
|
||
|
||
m_nColorIndex = 0;
|
||
|
||
//加载dat文件路径
|
||
QString strDatPath, strHexPath;
|
||
ConfigHelp::GetInstance()->LoadDatFilePath(strDatPath, strHexPath);
|
||
|
||
QString strDir = QApplication::applicationDirPath();
|
||
if (strDatPath.isEmpty())
|
||
{
|
||
m_strFilePathDat = strDir + "/dat";
|
||
|
||
QDir varDir(m_strFilePathDat);
|
||
if (!varDir.exists())
|
||
{
|
||
varDir.mkpath(m_strFilePathDat);
|
||
ConfigHelp::GetInstance()->WriteDatFilePath(m_strFilePathDat, m_strFilePathHexSave);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_strFilePathDat = strDatPath;
|
||
}
|
||
|
||
if (strHexPath.isEmpty())
|
||
{
|
||
m_strFilePathHexSave = strDir + "/hex";
|
||
|
||
QDir varDir(m_strFilePathHexSave);
|
||
if (!varDir.exists())
|
||
{
|
||
varDir.mkpath(m_strFilePathHexSave);
|
||
ConfigHelp::GetInstance()->WriteDatFilePath(m_strFilePathDat, m_strFilePathHexSave);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_strFilePathHexSave = strHexPath;
|
||
}
|
||
|
||
|
||
ui->m_textEdit_DatPath->setText(m_strFilePathDat);
|
||
ui->m_textEdit_HexSavePath->setText(m_strFilePathHexSave);
|
||
|
||
|
||
m_pHexBuf = new unsigned char[20 * 1024 * 1024];
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::InitImageQualityAssess()
|
||
{
|
||
|
||
m_bX16TimeSpaceDeviation = true;
|
||
m_bIsCaculateImageQuality = false;
|
||
|
||
m_pLineArrayValues = new double[MAX_QUALITY_PARAMS];
|
||
memset(m_pLineArrayValues, 0, sizeof(double)*MAX_QUALITY_PARAMS);
|
||
|
||
m_bThreadRunning_ImageQuality = false;
|
||
m_ptrThread_ImageQuality = nullptr;
|
||
|
||
m_varImageQualityParamData_IN.InitQueue(c_nWMemSize, 6);
|
||
|
||
//图像质量评估窗口
|
||
ui->m_stackedWidget_CalculateArea->setCurrentIndex(3);
|
||
ui->m_Rb_Y16->setChecked(true);
|
||
ui->m_Btn_Y16_Target->hide();
|
||
ui->m_Btn_Y16_Background->hide();
|
||
ui->m_Btn_Y16_AD_Up->hide();
|
||
ui->m_Btn_Y16_AD_Down->hide();
|
||
|
||
|
||
|
||
m_varImageAssessRect.xpos = ui->m_lineEdit_ImageQuality_AssessX->text().toShort();
|
||
m_varImageAssessRect.ypos = ui->m_lineEdit_ImageQuality_AssessY->text().toShort();
|
||
m_varImageAssessRect.width = ui->m_lineEdit_ImageQuality_AssessW->text().toShort();
|
||
m_varImageAssessRect.height = ui->m_lineEdit_ImageQuality_AssessH->text().toShort();
|
||
|
||
m_varImageAssessBackRect.xpos = ui->m_lineEdit_ImageQuality_AssessX_Back->text().toShort();
|
||
m_varImageAssessBackRect.ypos = ui->m_lineEdit_ImageQuality_AssessY_Back->text().toShort();
|
||
m_varImageAssessBackRect.width = ui->m_lineEdit_ImageQuality_AssessW_Back->text().toShort();
|
||
m_varImageAssessBackRect.height = ui->m_lineEdit_ImageQuality_AssessH_Back->text().toShort();
|
||
|
||
m_uLeftThrow = ui->m_lineEdit_Y8_Throw_Left->text().toShort();
|
||
m_uRightThrow = ui->m_lineEdit_Y8_Throw_Right->text().toShort();
|
||
|
||
//Y8坏点计算
|
||
m_varImageY8BadPoint.nImageWidth = ui->m_lineEdit_Y8_BadPoint_Width->text().toShort();
|
||
m_varImageY8BadPoint.nImageHeight = ui->m_lineEdit_Y8_BadPoint_Height->text().toShort();
|
||
m_varImageY8BadPoint.nWinHalf = ui->m_lineEdit_Y8_WinHalf->text().toInt();
|
||
m_varImageY8BadPoint.nThresh = ui->m_lineEdit_Y8_Thresh->text().toInt();
|
||
m_varImageY8BadPoint.nPos = ui->m_lineEdit_Y8_Pos->text().toInt();
|
||
|
||
//高低温本底
|
||
m_varImageX16Mix.nImageWidth = ui->m_lineEdit_ImgWidth->text().toShort();
|
||
m_varImageX16Mix.nImageHeight = ui->m_lineEdit_ImgHeight->text().toShort();
|
||
m_varImageX16Mix.nHighTempre = ui->m_lineEdit_T_High->text().toInt();
|
||
m_varImageX16Mix.nLowTempre = ui->m_lineEdit_T_Low->text().toInt();
|
||
|
||
|
||
// 限定输入框输入文本格式
|
||
// QRegExp rx("^-?(180|([1-9]?[0-9]|1[0-7][0-9])(\.\d{1,4})?)$");
|
||
ui->m_lineEdit_ImageQuality_AssessX->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_ImageQuality_AssessY->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_ImageQuality_AssessW->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_ImageQuality_AssessH->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
|
||
ui->m_lineEdit_Y8_Throw_Left->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_Y8_Throw_Right->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_Y8_WinHalf->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_Y8_Thresh->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
ui->m_lineEdit_Y8_Pos->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
|
||
|
||
|
||
//画曲线
|
||
//初始化曲线
|
||
InitCustomplot();
|
||
|
||
for (int i = 0; i < MAX_QUALITY_PARAMS; i++)
|
||
{
|
||
m_bIsDrawLines[i] = false;
|
||
}
|
||
|
||
for (int j = 0; j < MAX_QUALITY_PARAMS; j++)
|
||
{
|
||
m_pPlotCommon[j] = new QCustomPlotCommon(PONTNUM);
|
||
}
|
||
|
||
m_nFlag = 0;
|
||
|
||
//memset(m_pLineArrayValues,0,sizeof(m_pLineArrayValues));
|
||
memset(m_dLineBuff, 0, sizeof(m_dLineBuff));
|
||
|
||
connect(&m_timerDrawLine, &QTimer::timeout, this, &MainWindow::OnDrawLineTimer);
|
||
m_timerDrawLine.setTimerType(Qt::PreciseTimer);
|
||
//m_timerDrawLine.start(300);
|
||
|
||
//绘制曲线
|
||
///////////////////////
|
||
|
||
//B1和B2
|
||
m_pY16Data_B1 = new ushort[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY16Data_B1, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
m_pY8Data_B1 = new byte[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY8Data_B1, 0, MaxSize_IRSensorTool);
|
||
|
||
m_pY16Data_B2 = new ushort[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY16Data_B2, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
m_pY8Data_B2 = new byte[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY8Data_B2, 0, MaxSize_IRSensorTool);
|
||
|
||
m_pRGBA = new byte[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pRGBA, 0, MaxSize_IRSensorTool);
|
||
|
||
m_pY8BadPointData = new byte[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY8BadPointData, 0, MaxSize_IRSensorTool);
|
||
|
||
m_pY16Data_KList = new ushort[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY16Data_KList, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
m_pY16Data_BPList = new ushort[MaxSize_IRSensorTool + 4096];
|
||
memset(m_pY16Data_BPList, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::InitOpenGLView()
|
||
{
|
||
// if(m_pOpenGLView != NULL)
|
||
// {
|
||
// delete layoutIR;
|
||
// layoutIR = NULL;
|
||
// delete m_pOpenGLView;
|
||
// m_pOpenGLView = NULL;
|
||
// }
|
||
// m_pOpenGLView = new OpenGLView_IR;
|
||
// m_pOpenGLView->SetWH(IMG_WIDTH, IMG_HEIGHT);
|
||
// layoutIR = new QVBoxLayout(ui->m_openGLWidget_Capture0);
|
||
// layoutIR->addWidget(m_pOpenGLView);
|
||
// layoutIR->setMargin(0);
|
||
// layoutIR->setSpacing(0);
|
||
|
||
m_pOpenGLView = new OpenGLView;
|
||
m_pOpenGLView->Init(m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
|
||
QVBoxLayout* layoutVL = new QVBoxLayout(ui->m_openGLWidget_Capture0);
|
||
layoutVL->addWidget(m_pOpenGLView);
|
||
layoutVL->setMargin(0);
|
||
layoutVL->setSpacing(0);
|
||
|
||
}
|
||
|
||
bool MainWindow::ReadReg(UINT index, DWORD offset, UINT* outdata)
|
||
{
|
||
return 1;
|
||
}
|
||
|
||
bool MainWindow::WriteReg(UINT index, DWORD offset, UINT indata)
|
||
{
|
||
return 1;
|
||
}
|
||
|
||
void MainWindow::ResetUpgrade()
|
||
{
|
||
m_eUpgradeStatus = eUS_None;
|
||
}
|
||
|
||
enumUpgradeStatus MainWindow::GetUpgradeStatus()
|
||
{
|
||
return m_eUpgradeStatus;
|
||
}
|
||
|
||
bool MainWindow::SendUpgradeData(char* lpszCmd, int nLen)
|
||
{
|
||
if (!m_bCaptureData)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (8192 < nLen)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
uchar szSendDataBuffer[8192 * 4] = {0};
|
||
memset(szSendDataBuffer, 0, sizeof(szSendDataBuffer));
|
||
|
||
for (int i = 0; i < nLen; i++)
|
||
{
|
||
if (i < 1024)
|
||
{
|
||
szSendDataBuffer[4 * i + 3] = 0x80;
|
||
}
|
||
|
||
szSendDataBuffer[4 * i + 0] = lpszCmd[i];
|
||
}
|
||
|
||
int nSendSize = nLen * 4;
|
||
|
||
if (0 != nSendSize % c_nRMemSize)
|
||
{
|
||
nSendSize /= c_nRMemSize;
|
||
nSendSize *= c_nRMemSize;
|
||
nSendSize += c_nRMemSize;
|
||
}
|
||
|
||
nSendSize = c_nRMemSize;
|
||
|
||
|
||
|
||
return true;
|
||
}
|
||
|
||
void MainWindow::SetSystemType(EUSetSystemType type)
|
||
{
|
||
m_pEUSetSystemType = type;
|
||
|
||
switch (m_pEUSetSystemType)
|
||
{
|
||
case SYSTEM_FPGA_ISP2:
|
||
{
|
||
break;
|
||
}
|
||
case SYSTEM_FPGA_ISP3:
|
||
{
|
||
m_pSettingsControl->setVisible(false);
|
||
m_pSettingsPanel->showNormal();
|
||
break;
|
||
}
|
||
case SYSTEM_ASIC:
|
||
{
|
||
m_pSettingsPanel->setVisible(false);
|
||
m_pSettingsControl->showNormal();
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::Connect()
|
||
{
|
||
// connect(ui->m_dockWidget_TGSettings,SIGNAL(visibilityChanged(bool)),this,SLOT(OnSlotFetureChanged(bool)));
|
||
|
||
// 通用
|
||
connect(ui->m_Btn_MinMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_MaxMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_CloseMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
connect(ui->m_Btn_Settings, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Settings_TG, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImgQualityAssess, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_UnCool_Set, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_UnCoolSet_Exit, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_UnCoolDev, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ControlASCII, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_GetSystemCode, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//非制冷机芯串口控制
|
||
connect(ui->m_Btn_ComConnect, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(m_SerialPortScan, SIGNAL(onNewSerialPort(QStringList)), this, SLOT(onNewPortList(QStringList)));
|
||
|
||
connect(m_SerialHelp, SIGNAL(ShowSendCmd(QString)), this, SLOT(ShowSendCmd(QString)));
|
||
connect(m_SerialHelp, SIGNAL(ShowRecvData(QString)), this, SLOT(ShowRecvCmd(QString)));
|
||
connect(m_SerialHelp, SIGNAL(SigSendShowRecvData(QString)), this, SLOT(OnSlotShowRecvStr(QString)));
|
||
|
||
// connect(m_SerialHelp,SIGNAL(SendCoreInfo(CoreReturnInfo)),this, SLOT(DealCoreInfo(CoreReturnInfo)));
|
||
// connect(m_SerialHelp,SIGNAL(SendInquery()),this, SLOT(SendInquery()));
|
||
|
||
connect(ui->m_Btn_UnCoolSet_ExpertMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//按下
|
||
connect(ui->m_Btn_UnCoolSet_Compensation, &QPushButton::pressed, this, &MainWindow::OnButtonPressed);
|
||
connect(ui->m_Btn_UnCoolSet_Menu, &QPushButton::pressed, this, &MainWindow::OnButtonPressed);
|
||
connect(ui->m_Btn_UnCoolSet_Add, &QPushButton::pressed, this, &MainWindow::OnButtonPressed);
|
||
connect(ui->m_Btn_UnCoolSet_Min, &QPushButton::pressed, this, &MainWindow::OnButtonPressed);
|
||
connect(ui->m_Btn_UnCoolSet_No_Compensation, &QPushButton::pressed, this, &MainWindow::OnButtonPressed);
|
||
|
||
//弹起
|
||
connect(ui->m_Btn_UnCoolSet_Compensation, &QPushButton::released, this, &MainWindow::OnButtonReleased);
|
||
connect(ui->m_Btn_UnCoolSet_Menu, &QPushButton::released, this, &MainWindow::OnButtonReleased);
|
||
connect(ui->m_Btn_UnCoolSet_Add, &QPushButton::released, this, &MainWindow::OnButtonReleased);
|
||
connect(ui->m_Btn_UnCoolSet_Min, &QPushButton::released, this, &MainWindow::OnButtonReleased);
|
||
connect(ui->m_Btn_UnCoolSet_No_Compensation, &QPushButton::released, this, &MainWindow::OnButtonReleased);
|
||
|
||
//非制冷升级
|
||
connect(ui->m_Btn_Upgrade_OpenFile, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_StartUpgrade, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//非制冷文件转换
|
||
connect(ui->m_Btn_Select_Hex, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Select_Dat, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Start_ToDat, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(this, SIGNAL(SigConvertResult(QString)), this, SLOT(OnSlotConvertResult(QString)));
|
||
connect(this, SIGNAL(SigConvertProgress(int)), this, SLOT(OnSlotConvertProgress(int)));
|
||
connect(m_SerialHelp, SIGNAL(SigSendUpgradeData(int)), this, SLOT(OnSlotUpgradeData(int))/*,Qt::BlockingQueuedConnection*/);
|
||
|
||
connect(ui->m_Btn_Scan, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Start_ToHex, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Select_Save_Hex, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
|
||
|
||
// 视频采集
|
||
connect(ui->m_Btn_CaptureData, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Capture);
|
||
connect(ui->m_Btn_EnableRecord, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Capture);
|
||
|
||
// 视频回放(及注入)
|
||
connect(ui->m_checkBox_RecyclePlay, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
connect(ui->m_Btn_BrowseFile, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
connect(ui->m_playPauseBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
connect(ui->m_stopBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
connect(ui->m_forwardBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
connect(ui->m_nextBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
|
||
connect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
|
||
m_varTimer.setTimerType(Qt::PreciseTimer);
|
||
m_varTimer.start(40);
|
||
|
||
//调光
|
||
connect(ui->m_hSlider_brightness, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
connect(ui->m_hSlider_contrast, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
connect(ui->m_hSlider_IDE, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
connect(ui->m_hSlider_DDE, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
connect(ui->m_radioButton_LineTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_radioButton_MixTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_radioButton_HistTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Btn_TG_SetPara, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_TG);
|
||
connect(ui->m_Btn_TG_GetGuoGaiModel, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_TG);
|
||
connect(ui->m_Btn_TG_SW, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_TG);
|
||
|
||
// 数据帧参数
|
||
connect(m_pFrameParams, &FrameParams::sigConfirm_File, this, &MainWindow::OnConfirm_File);
|
||
connect(m_pFrameParams, &FrameParams::sigConfirm_CPL64, this, &MainWindow::OnConfirm_CPL64);
|
||
|
||
connect(this, &MainWindow::sigVideoRect, this, &MainWindow::OnConfirm_VideoRect);
|
||
connect(this, &MainWindow::sigBackVideoRect, this, &MainWindow::OnConfirm_BackVideoRect);
|
||
|
||
|
||
//图像质量评估
|
||
connect(ui->m_Btn_ArithSet, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
//数据格式
|
||
connect(ui->m_Rb_X, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Rb_X_Mix, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Rb_Y8, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Rb_Y16, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
|
||
//X,Y,W,MainWindow
|
||
connect(ui->m_Btn_ImageQualityAssess_SetRect, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImageQualityAssess_SetRect_Back, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImageQualityAssess_MoveLeft, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImageQualityAssess_MoveRight, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImageQualityAssess_MoveUp, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_ImageQualityAssess_MoveDown, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//计算区域 X数据
|
||
connect(ui->m_Ck_X_TimeDomain_Deviation, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_X_MeanValue, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Btn_X_MeanValue, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_X_TimeDomain_Deviation, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//X高低温组合数据
|
||
connect(ui->m_Ck_X_Mix_ResponseRatio, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_X_Mix_NETD, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Btn_X_Mix_NETD, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_X_Mix_ResponseRatio, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
connect(ui->m_Btn_XMix_Set, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_XMix_Calculate, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//Y8数据
|
||
connect(ui->m_Ck_Y8_AirSpace_Deviation, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y8_DynamicRange, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y8_MeanValue, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y8_MTF, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Btn_Y8_AirSpace_Deviation, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_DynamicRange, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_MeanValue, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_MTF, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_Throw_Left, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_Throw_Right, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
connect(ui->m_Btn_Y8_ParamSet, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_BadPointData_Load, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y8_BadPoint_Calculate, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
|
||
//Y16数据
|
||
connect(ui->m_Ck_Y16_AD, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y16_AirSpace_Deviation, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y16_MeanValue, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y16_Nonuniform, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y16_SignalNoiseRatio, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Ck_Y16_BadPoint, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
connect(ui->m_Btn_Y16_AD, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_AD_Down, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_AD_Up, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_AirSpace_Deviation, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_Background, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_MeanValue, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_Nonuniform, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_SignalNoiseRatio, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Y16_Target, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//加载高温本底
|
||
connect(ui->m_Btn_LoadHigh_File_B1, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Show_File_B1, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//加载低温本底
|
||
connect(ui->m_Btn_LoadLow_File_B2, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
connect(ui->m_Btn_Show_File_B2, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
//主线程UI显示参数值
|
||
connect(this, &MainWindow::sigSendQualityParamShow, this, &MainWindow::OnRecvQualityParamShow);
|
||
connect(this, &MainWindow::sigSendQualityImageShow, this, &MainWindow::OnRecvQualityImageShow);
|
||
|
||
connect(this, &MainWindow::sigSendFPS, this, &MainWindow::OnRecvFPS);
|
||
|
||
|
||
|
||
connect(ui->m_pushButtonImageFormatColorTableItem01, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem02, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem03, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem04, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem05, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem06, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem07, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem08, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
connect(ui->m_pushButtonImageFormatColorTableItem09, SIGNAL(clicked()), this, SLOT(OnColorTableClicked()));
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::Disconnect()
|
||
{
|
||
// 通用
|
||
disconnect(ui->m_Btn_MinMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_MaxMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_CloseMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_ImgQualityAssess, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_UnCool_Set, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_UnCoolSet_Exit, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_Settings, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_Settings_TG, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_UnCoolDev, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_ControlASCII, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
disconnect(ui->m_Btn_GetSystemCode, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
// 视频采集
|
||
disconnect(ui->m_Btn_CaptureData, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Capture);
|
||
disconnect(ui->m_Btn_EnableRecord, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Capture);
|
||
|
||
// 视频回放(及注入)
|
||
disconnect(ui->m_checkBox_RecyclePlay, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
disconnect(ui->m_Btn_BrowseFile, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
disconnect(ui->m_playPauseBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
disconnect(ui->m_stopBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
disconnect(ui->m_forwardBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
disconnect(ui->m_nextBtn, &QPushButton::clicked, this, &MainWindow::OnButtonClicked_Playback);
|
||
|
||
disconnect(ui->m_hSlider_brightness, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
disconnect(ui->m_hSlider_contrast, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
disconnect(ui->m_hSlider_IDE, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
disconnect(ui->m_hSlider_DDE, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
|
||
disconnect(ui->m_radioButton_LineTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
disconnect(ui->m_radioButton_MixTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
disconnect(ui->m_radioButton_HistTG, SIGNAL(toggled(bool)), this, SLOT(OnButtonIsChecked(bool)));
|
||
|
||
m_varTimer.stop();
|
||
disconnect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
|
||
|
||
// 数据帧参数
|
||
disconnect(m_pFrameParams, &FrameParams::sigConfirm_File, this, &MainWindow::OnConfirm_File);
|
||
disconnect(m_pFrameParams, &FrameParams::sigConfirm_CPL64, this, &MainWindow::OnConfirm_CPL64);
|
||
|
||
//图像质量评估
|
||
disconnect(ui->m_Btn_ArithSet, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
|
||
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::OnExitTimer()
|
||
{
|
||
qApp->exit();
|
||
}
|
||
|
||
void MainWindow::UpdateImgFormat()
|
||
{
|
||
IMG_WIDTH = m_varGFrameFormat.nImageWidth;
|
||
IMG_HEIGHT = m_varGFrameFormat.nImageHeight;
|
||
// for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
// {
|
||
// if(NULL != m_recordThread[i])
|
||
// {
|
||
// m_recordThread[i]->SetImgSize(IMG_WIDTH*IMG_HEIGHT*m_varGFrameFormat.PixelType_Count);
|
||
// }
|
||
|
||
// }
|
||
|
||
GLogger::GetInstance()->WriteInfo("InitOpenGLView pre");
|
||
if (m_pOpenGLView != NULL)
|
||
{
|
||
m_pOpenGLView->Init(m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
}
|
||
GLogger::GetInstance()->WriteInfo("InitOpenGLView end");
|
||
if (m_pDevCap != NULL)
|
||
{
|
||
m_pDevCap->SetCapInfo(m_varGFrameFormatCap);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
void MainWindow::OnConfirm_File(bool bOK, const GFrameFormat& varFrameFormat_File)
|
||
{
|
||
if (!bOK)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_varGFrameFormat = varFrameFormat_File;
|
||
|
||
ui->m_stopBtn->clicked();
|
||
|
||
//
|
||
QString strFileName = m_strCurrentFilePath;
|
||
|
||
m_pRawFileStream[0] = new FileStream(false, m_bRecyclePlay, strFileName, varFrameFormat_File, &MainWindow::OnProgress, this);
|
||
|
||
m_bOpenFile = true;
|
||
UpdateImgFormat();
|
||
|
||
ui->m_playPauseBtn->clicked();
|
||
}
|
||
|
||
void MainWindow::OnConfirm_CPL64(bool bOK, const GFrameFormat_CPL64& varFrameFormat_CPL64)
|
||
{
|
||
if (!bOK)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_varGFrameFormatCap = varFrameFormat_CPL64;
|
||
m_varGFrameFormat = varFrameFormat_CPL64.varFrameFormat;
|
||
|
||
UpdateImgFormat();
|
||
|
||
if (StartThread_DealDeviceData())
|
||
{
|
||
m_bCaptureData = true;
|
||
|
||
//录像功能
|
||
ui->m_Btn_EnableRecord->setEnabled(true);
|
||
SetPlayOrPauseButton(false);
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnConfirm_VideoRect(ImageAssessRect imageAssessRect)
|
||
{
|
||
ui->m_lineEdit_ImageQuality_AssessX->setText(QString::number(imageAssessRect.xpos));
|
||
ui->m_lineEdit_ImageQuality_AssessY->setText(QString::number(imageAssessRect.ypos));
|
||
ui->m_lineEdit_ImageQuality_AssessW->setText(QString::number(imageAssessRect.width));
|
||
ui->m_lineEdit_ImageQuality_AssessH->setText(QString::number(imageAssessRect.height));
|
||
}
|
||
|
||
void MainWindow::OnConfirm_BackVideoRect(ImageAssessRect BackRect)
|
||
{
|
||
ui->m_lineEdit_ImageQuality_AssessX_Back->setText(QString::number(BackRect.xpos));
|
||
ui->m_lineEdit_ImageQuality_AssessY_Back->setText(QString::number(BackRect.ypos));
|
||
ui->m_lineEdit_ImageQuality_AssessW_Back->setText(QString::number(BackRect.width));
|
||
ui->m_lineEdit_ImageQuality_AssessH_Back->setText(QString::number(BackRect.height));
|
||
}
|
||
|
||
void MainWindow::updateComSettings()
|
||
{
|
||
// 将界面上的的用户设置信息存入 串口参数设置 结构体
|
||
m_CurrentSettings.name = ui->m_Cb_Com->currentText();
|
||
m_CurrentSettings.baudRate = ui->m_Cb_BaudRate->currentText().toInt();
|
||
m_CurrentSettings.stringBaudRate = QString::number(m_CurrentSettings.baudRate);
|
||
m_CurrentSettings.dataBits = static_cast<QSerialPort::DataBits>(8);
|
||
|
||
switch (ui->m_Cb_Parity->currentIndex())
|
||
{
|
||
case 0:
|
||
m_CurrentSettings.parity = QSerialPort::Parity::NoParity;
|
||
break;
|
||
case 1:
|
||
m_CurrentSettings.parity = QSerialPort::Parity::EvenParity;
|
||
break;
|
||
case 2:
|
||
m_CurrentSettings.parity = QSerialPort::Parity::OddParity;
|
||
break;
|
||
case 3:
|
||
m_CurrentSettings.parity = QSerialPort::Parity::SpaceParity;
|
||
break;
|
||
case 4:
|
||
m_CurrentSettings.parity = QSerialPort::Parity::MarkParity;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
//m_CurrentSettings.parity =static_cast<QSerialPort::Parity>(0);
|
||
m_CurrentSettings.stopBits = static_cast<QSerialPort::StopBits>(1);
|
||
}
|
||
|
||
void MainWindow::onNewPortList(QStringList portName)
|
||
{
|
||
ui->m_Cb_Com->clear();
|
||
ui->m_Cb_Com->addItems(portName);
|
||
}
|
||
|
||
void MainWindow::SendInquery()
|
||
{
|
||
QString Data = m_SerialHelp->CmdInsertVal(1, Cmd_TurnPage, 10);
|
||
QString cmd = QString("%1 %2").arg(Cmd_Page_Turn).arg(Data);
|
||
m_SerialHelp->writeDateToMovement(Cmd_DefaultID, cmd);
|
||
}
|
||
|
||
void MainWindow::ShowSendCmd(QString str)
|
||
{
|
||
QString strShow = QString("Send: %1").arg(str);
|
||
ui->m_lineEdit_SendMsg->setText(strShow);
|
||
}
|
||
|
||
void MainWindow::ShowRecvCmd(QString str)
|
||
{
|
||
QString strShow = QString("Recv: %1").arg(str);
|
||
ui->m_lineEdit_RecvMsg->setText(strShow);
|
||
GLogger::GetInstance()->WriteInfo(strShow);
|
||
}
|
||
|
||
void MainWindow::OnSlotConvertResult(QString str)
|
||
{
|
||
ui->m_label_Result->setText(str);
|
||
}
|
||
|
||
void MainWindow::OnSlotConvertProgress(int value)
|
||
{
|
||
ui->m_progressBar_Convert->setValue(value);
|
||
}
|
||
|
||
void MainWindow::OnSlotUpgradeData(int nFrameNum)
|
||
{
|
||
uchar tmpBuf[1024];
|
||
int len;
|
||
m_pFileFun->GetFlashData(nFrameNum, tmpBuf, len);
|
||
uchar sendBuf[BUFF_SIZE];
|
||
int sendLen;
|
||
m_SerialHelp->PackageFlashDataReq(nFrameNum, len, tmpBuf, sendBuf, sendLen);
|
||
m_SerialHelp->WriteData((char*)sendBuf, sendLen);
|
||
|
||
ui->m_progressBar_Upgrade->setValue(nFrameNum);
|
||
// ui->m_label_Upgrade->setText(QString::number(nFrameNum));
|
||
}
|
||
|
||
void MainWindow::OnSlotShowRecvStr(QString str)
|
||
{
|
||
ui->m_label_showStr->setText(str);
|
||
}
|
||
|
||
void MainWindow::StartConvertThread(QString strSaveName)
|
||
{
|
||
//开启线程,读取flashData
|
||
std::thread readThread([ = ]()
|
||
{
|
||
this->ThreadFun(strSaveName);
|
||
});
|
||
|
||
readThread.detach();
|
||
}
|
||
|
||
void MainWindow::ThreadFun(QString strSaveName)
|
||
{
|
||
QFile file(strSaveName);
|
||
|
||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
||
{
|
||
//CommonHelper::ShowMessageBoxError(tr("打开文件夹失败!"));
|
||
emit SigConvertResult("保存文件失败");
|
||
}
|
||
else
|
||
{
|
||
unsigned char nFileNo = m_pFileConvert->m_iFileNo;
|
||
qint64 nFileSize = m_pFileConvert->m_size;
|
||
int nFrameCount = m_pFileConvert->m_nFrameCount;
|
||
int nCurrentConvertNum = 0;
|
||
while (nCurrentConvertNum < nFrameCount)
|
||
{
|
||
nCurrentConvertNum++;
|
||
uchar tmpBuf[MAX_UP_SIZE];
|
||
int len;
|
||
m_pFileConvert->GetConvertData(nCurrentConvertNum, tmpBuf, len);
|
||
|
||
QTextStream textStream(&file);
|
||
QString strSaveTxt = "";
|
||
|
||
for (int i = 0; i < len; i++)
|
||
{
|
||
strSaveTxt.insert(0, QString("%1").arg((tmpBuf[i]) & 0xFF, 2, 16, QLatin1Char('0')));
|
||
|
||
if ((i + 1) % 4 == 0)
|
||
{
|
||
strSaveTxt.insert(0, "0x");
|
||
strSaveTxt.append("\n");
|
||
textStream << strSaveTxt;
|
||
strSaveTxt.clear();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
emit SigConvertProgress(nCurrentConvertNum);
|
||
|
||
emit SigConvertResult("转换中...");
|
||
}
|
||
|
||
emit SigConvertResult("转换成功");
|
||
|
||
|
||
}// end while
|
||
|
||
|
||
|
||
file.close();
|
||
}
|
||
|
||
void MainWindow::OnButtonClicked()
|
||
{
|
||
// 最小化
|
||
if (sender() == ui->m_Btn_MinMenu)
|
||
{
|
||
this->showMinimized();
|
||
}
|
||
|
||
// 最大化
|
||
if (sender() == ui->m_Btn_MaxMenu)
|
||
{
|
||
if (isMaximized())
|
||
{
|
||
showNormal();
|
||
ui->m_Btn_MaxMenu->setToolTip("最大化");
|
||
ui->m_Btn_MaxMenu->setProperty("maximizeProperty", "maximize");
|
||
ui->m_Btn_MaxMenu->setStyle(QApplication::style());
|
||
}
|
||
else
|
||
{
|
||
|
||
if (!m_bTGSettings)
|
||
{
|
||
ui->m_Btn_Settings_TG->clicked();
|
||
}
|
||
showMaximized();
|
||
ui->m_Btn_MaxMenu->setToolTip("还原");
|
||
ui->m_Btn_MaxMenu->setProperty("maximizeProperty", "restore");
|
||
ui->m_Btn_MaxMenu->setStyle(QApplication::style());
|
||
}
|
||
}
|
||
|
||
// 退出程序
|
||
if (sender() == ui->m_Btn_CloseMenu)
|
||
{
|
||
m_iPlayState = 0;
|
||
if (m_bCaptureData)
|
||
{
|
||
OnButtonClicked_Capture();
|
||
}
|
||
|
||
connect(&m_varExitTimer, &QTimer::timeout, this, &MainWindow::OnExitTimer);
|
||
m_varExitTimer.setTimerType(Qt::PreciseTimer);
|
||
m_varExitTimer.start(500);
|
||
// qApp->exit();
|
||
}
|
||
|
||
// 设置面板
|
||
if (sender() == ui->m_Btn_Settings)
|
||
{
|
||
m_pSettingsPanel->showNormal();
|
||
}
|
||
//非制冷机芯
|
||
if (sender() == ui->m_Btn_UnCoolDev)
|
||
{
|
||
m_pUnCoolDevSettings->showNormal();
|
||
}
|
||
if (sender() == ui->m_Btn_ControlASCII)
|
||
{
|
||
m_pSettingsControl->showNormal();
|
||
}
|
||
if (sender() == ui->m_Btn_GetSystemCode)
|
||
{
|
||
m_pGetSystemCode->showNormal();
|
||
}
|
||
|
||
|
||
/*图像质量评估窗口*/
|
||
if (sender() == ui->m_Btn_ImgQualityAssess)
|
||
{
|
||
// //启动质量评估线程
|
||
m_bThreadRunning_ImageQuality = true;
|
||
m_ptrThread_ImageQuality = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ImageQualityParam, (void*)this));
|
||
|
||
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(2);
|
||
m_timerDrawLine.start(300);
|
||
m_bIsCaculateImageQuality = true;
|
||
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_ArithSet)
|
||
{
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(1);
|
||
m_timerDrawLine.stop();
|
||
m_bIsCaculateImageQuality = false;
|
||
|
||
// //关闭线程
|
||
if (m_bThreadRunning_ImageQuality)
|
||
{
|
||
m_bThreadRunning_ImageQuality = false;
|
||
if (nullptr != m_ptrThread_ImageQuality)
|
||
{
|
||
m_ptrThread_ImageQuality->join();
|
||
delete m_ptrThread_ImageQuality;
|
||
m_ptrThread_ImageQuality = nullptr;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
//非制冷机芯串口控制
|
||
{
|
||
if (sender() == ui->m_Btn_UnCool_Set)
|
||
{
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(3);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Exit)
|
||
{
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(1);
|
||
}
|
||
|
||
//非制冷机芯连接串口
|
||
if (sender() == ui->m_Btn_ComConnect)
|
||
{
|
||
m_bConnectFlag = !m_bConnectFlag;
|
||
if (m_bConnectFlag)
|
||
{
|
||
updateComSettings();
|
||
m_SerialHelp->setSerislPort(m_CurrentSettings);
|
||
if (m_SerialHelp->openSerialPort())
|
||
{
|
||
ui->m_Btn_ComConnect->setText("断开串口");
|
||
ui->m_Cb_BaudRate->setEnabled(false);
|
||
ui->m_Cb_Com->setEnabled(false);
|
||
ui->m_Cb_Parity->setEnabled(false);
|
||
|
||
// 点亮图标
|
||
ui->m_Lb_ConnectInfo->setPixmap(QPixmap(":/skin/image/connect.png"));
|
||
ui->m_Lb_ConnectInfo->setScaledContents(true);
|
||
}
|
||
else
|
||
{
|
||
m_bConnectFlag = false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_SerialHelp->closeSerialPort();
|
||
ui->m_Btn_ComConnect->setText("连接串口");
|
||
ui->m_Cb_BaudRate->setEnabled(true);
|
||
ui->m_Cb_Com->setEnabled(true);
|
||
ui->m_Cb_Parity->setEnabled(true);
|
||
|
||
// 熄灭图标
|
||
ui->m_Lb_ConnectInfo->setPixmap(QPixmap(":/skin/image/disconnect.png"));
|
||
ui->m_Lb_ConnectInfo->setScaledContents(true);
|
||
|
||
}
|
||
}
|
||
|
||
//非制冷机芯控制指令--专家菜单
|
||
if (sender() == ui->m_Btn_UnCoolSet_ExpertMenu)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_EXPERTMENU);
|
||
}
|
||
|
||
//新协议--打开文件
|
||
if (sender() == ui->m_Btn_Upgrade_OpenFile)
|
||
{
|
||
|
||
static QString s_DefaultFilePath = ".";
|
||
QString strFilePath = QFileDialog::getOpenFileName(this,
|
||
tr("文件另存为"), s_DefaultFilePath, tr("文本文档(*.hex) ;; 所有文件(*)"));
|
||
if (strFilePath == "")
|
||
{
|
||
return;
|
||
}
|
||
|
||
ui->m_textEdit_Upgrade_FilePath->setText(strFilePath);
|
||
|
||
if (m_pFileFun->Open(strFilePath))
|
||
{
|
||
m_bUpdateRes = true;
|
||
ui->m_Btn_StartUpgrade->setEnabled(true);
|
||
}
|
||
else
|
||
{
|
||
m_bUpdateRes = false;
|
||
CommonHelper::ShowMessageBoxError(tr("打开文件失败!"), this);
|
||
}
|
||
//路径:不包含文件名
|
||
int npos = strFilePath.lastIndexOf("/");
|
||
if (npos != -1)
|
||
{
|
||
s_DefaultFilePath = strFilePath.mid(0, npos);
|
||
}
|
||
|
||
|
||
}
|
||
//开始升级
|
||
if (sender() == ui->m_Btn_StartUpgrade)
|
||
{
|
||
if (!m_bUpdateRes)
|
||
{
|
||
CommonHelper::ShowMessageBoxError(tr("请先选择升级文件!"), this);
|
||
return;
|
||
}
|
||
|
||
// unsigned char nFileNo = m_pFileFun->m_iFileNo;
|
||
int nFileNo = ui->m_Upgrade_fileNum->text().toInt();
|
||
|
||
qint64 nFileSize = m_pFileFun->m_size;
|
||
int nFrameCount = m_pFileFun->m_nFrameCount;
|
||
|
||
ui->m_progressBar_Upgrade->setRange(0, nFrameCount);
|
||
|
||
int nFileCheckValueLen = 4;
|
||
|
||
unsigned char cmd[BUFF_SIZE] = {0};
|
||
int cmdLen = 0;
|
||
m_SerialHelp->PackageUpgradeReq(nFileNo, nFileSize, nFrameCount, m_pFileFun->m_FileCheckValue, nFileCheckValueLen, cmd, cmdLen);
|
||
m_SerialHelp->WriteData((char*)cmd, cmdLen);
|
||
|
||
}
|
||
|
||
//文件转换
|
||
//hex To Dat
|
||
if (sender() == ui->m_Btn_Select_Hex)
|
||
{
|
||
static QString s_DefaultFilePath = ".";
|
||
QString strFilePath = QFileDialog::getOpenFileName(this,
|
||
tr("hex文件"), s_DefaultFilePath, tr("文本文档(*.hex) ;; 所有文件(*)"));
|
||
if (strFilePath == "")
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_strFilePathHex = strFilePath;
|
||
ui->m_textEdit_HexPath->setText(m_strFilePathHex);
|
||
|
||
if (m_pFileConvert->OpenUXDatFile(strFilePath))
|
||
{
|
||
m_bConvertRes = true;
|
||
}
|
||
else
|
||
{
|
||
m_bConvertRes = false;
|
||
CommonHelper::ShowMessageBoxError(tr("打开文件失败!"), this);
|
||
}
|
||
|
||
//路径:不包含文件名
|
||
int npos = strFilePath.lastIndexOf("/");
|
||
if (npos != -1)
|
||
{
|
||
s_DefaultFilePath = strFilePath.mid(0, npos);
|
||
}
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_Select_Dat)
|
||
{
|
||
QString dir = QFileDialog::getExistingDirectory(this, tr("选择"), m_strFilePathDat, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||
if ((!dir.isEmpty()) && (dir != m_strFilePathDat))
|
||
{
|
||
m_strFilePathDat = dir;
|
||
ui->m_textEdit_DatPath->setText(dir);
|
||
ConfigHelp::GetInstance()->WriteDatFilePath(m_strFilePathDat, m_strFilePathHexSave);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Btn_Start_ToDat)
|
||
{
|
||
if (!m_bConvertRes)
|
||
{
|
||
CommonHelper::ShowMessageBoxError(tr("请先选择文件!"), this);
|
||
return;
|
||
}
|
||
|
||
int nFrameCount = m_pFileConvert->m_nFrameCount;
|
||
ui->m_progressBar_Convert->setRange(0, nFrameCount);
|
||
ui->m_progressBar_Convert->setValue(0);
|
||
ui->m_label_Result->setText("N/A");
|
||
|
||
int npos = m_strFilePathHex.lastIndexOf('/');
|
||
QString strFileName = m_strFilePathHex.right(m_strFilePathHex.length() - npos - 1);
|
||
if (strFileName.endsWith(".hex", Qt::CaseInsensitive)) //不区分大小写
|
||
{
|
||
strFileName.replace(".hex", ".dat", Qt::CaseInsensitive);
|
||
QString strSaveName = m_strFilePathDat + "/" + strFileName;
|
||
StartConvertThread(strSaveName);
|
||
}
|
||
else
|
||
{
|
||
CommonHelper::ShowMessageBoxError(tr("源文件不是hex文件"), this);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Btn_Scan)
|
||
{
|
||
static QString s_DefaultFilePath = ".";
|
||
QString strFilePath = QFileDialog::getOpenFileName(this,
|
||
tr("选择文件"), s_DefaultFilePath, tr("所有文件(*)"));
|
||
if (strFilePath == "")
|
||
{
|
||
return;
|
||
}
|
||
|
||
ui->m_textEdit_BitPath->setText(strFilePath);
|
||
ui->m_label_Result_ToHex->setText("");
|
||
|
||
}
|
||
if (sender() == ui->m_Btn_Select_Save_Hex)
|
||
{
|
||
QString dir = QFileDialog::getExistingDirectory(this, tr("选择"), m_strFilePathHexSave, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||
if ((!dir.isEmpty()) && (dir != m_strFilePathHexSave))
|
||
{
|
||
m_strFilePathHexSave = dir;
|
||
ui->m_textEdit_HexSavePath->setText(dir);
|
||
ConfigHelp::GetInstance()->WriteDatFilePath(m_strFilePathDat, m_strFilePathHexSave);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Btn_Start_ToHex)
|
||
{
|
||
ConvertToHexData();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
// 裁剪区域x,y,w,h设置
|
||
{
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_SetRect)
|
||
{
|
||
m_varImageAssessRect.xpos = ui->m_lineEdit_ImageQuality_AssessX->text().toShort();
|
||
m_varImageAssessRect.ypos = ui->m_lineEdit_ImageQuality_AssessY->text().toShort();
|
||
m_varImageAssessRect.width = ui->m_lineEdit_ImageQuality_AssessW->text().toShort();
|
||
m_varImageAssessRect.height = ui->m_lineEdit_ImageQuality_AssessH->text().toShort();
|
||
|
||
m_bShowRect = true;
|
||
|
||
int nX = m_varImageAssessRect.xpos;
|
||
int nY = m_varImageAssessRect.ypos;
|
||
int nW = m_varImageAssessRect.width;
|
||
int nH = m_varImageAssessRect.height;
|
||
|
||
LimitValue(nX, nY, nW, nH);
|
||
|
||
m_varImageAssessRect.xpos = nX;
|
||
m_varImageAssessRect.ypos = nY;
|
||
m_varImageAssessRect.width = nW;
|
||
m_varImageAssessRect.height = nH;
|
||
|
||
// emit sigVideoRect(m_varImageAssessRect);
|
||
//处理框选区域的图像
|
||
//画框
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_SetRect_Back)
|
||
{
|
||
m_varImageAssessBackRect.xpos = ui->m_lineEdit_ImageQuality_AssessX_Back->text().toShort();
|
||
m_varImageAssessBackRect.ypos = ui->m_lineEdit_ImageQuality_AssessY_Back->text().toShort();
|
||
m_varImageAssessBackRect.width = ui->m_lineEdit_ImageQuality_AssessW_Back->text().toShort();
|
||
m_varImageAssessBackRect.height = ui->m_lineEdit_ImageQuality_AssessH_Back->text().toShort();
|
||
m_bShowBackRect = true;
|
||
|
||
int nX = m_varImageAssessBackRect.xpos;
|
||
int nY = m_varImageAssessBackRect.ypos;
|
||
int nW = m_varImageAssessBackRect.width;
|
||
int nH = m_varImageAssessBackRect.height;
|
||
|
||
LimitValue(nX, nY, nW, nH);
|
||
|
||
m_varImageAssessBackRect.xpos = nX;
|
||
m_varImageAssessBackRect.ypos = nY;
|
||
m_varImageAssessBackRect.width = nW;
|
||
m_varImageAssessBackRect.height = nH;
|
||
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_MoveLeft)
|
||
{
|
||
m_varImageAssessRect.xpos = ui->m_lineEdit_ImageQuality_AssessX->text().toShort();
|
||
--m_varImageAssessRect.xpos;
|
||
//ui->m_lineEdit_ImageQuality_AssessX->setText(QString::number(--m_varImageAssessRect.xpos));
|
||
if (m_varImageAssessRect.xpos == 65535)
|
||
{
|
||
m_varImageAssessRect.xpos = 0;
|
||
}
|
||
|
||
ui->m_lineEdit_ImageQuality_AssessX->setText(QString::number(m_varImageAssessRect.xpos));
|
||
|
||
// emit sigVideoRect(m_varImageAssessRect);
|
||
//画框
|
||
}
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_MoveRight)
|
||
{
|
||
m_varImageAssessRect.xpos = ui->m_lineEdit_ImageQuality_AssessX->text().toShort();
|
||
++m_varImageAssessRect.xpos;
|
||
// ui->m_lineEdit_ImageQuality_AssessX->setText(QString::number(++m_varImageAssessRect.xpos));
|
||
|
||
if (m_varImageAssessRect.xpos + m_varImageAssessRect.width > m_varGFrameFormat.nImageWidth)
|
||
{
|
||
m_varImageAssessRect.xpos = m_varGFrameFormat.nImageWidth - m_varImageAssessRect.width;
|
||
}
|
||
|
||
ui->m_lineEdit_ImageQuality_AssessX->setText(QString::number(m_varImageAssessRect.xpos));
|
||
|
||
|
||
// emit sigVideoRect(m_varImageAssessRect);
|
||
//画框
|
||
}
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_MoveUp)
|
||
{
|
||
m_varImageAssessRect.ypos = ui->m_lineEdit_ImageQuality_AssessY->text().toShort();
|
||
--m_varImageAssessRect.ypos;
|
||
// ui->m_lineEdit_ImageQuality_AssessY->setText(QString::number(--m_varImageAssessRect.ypos));
|
||
if (m_varImageAssessRect.ypos == 65535)
|
||
{
|
||
m_varImageAssessRect.ypos = 0;
|
||
}
|
||
|
||
ui->m_lineEdit_ImageQuality_AssessY->setText(QString::number(m_varImageAssessRect.ypos));
|
||
//emit sigVideoRect(m_varImageAssessRect);
|
||
//画框
|
||
}
|
||
if (sender() == ui->m_Btn_ImageQualityAssess_MoveDown)
|
||
{
|
||
m_varImageAssessRect.ypos = ui->m_lineEdit_ImageQuality_AssessY->text().toShort();
|
||
++m_varImageAssessRect.ypos;
|
||
// ui->m_lineEdit_ImageQuality_AssessY->setText(QString::number(++m_varImageAssessRect.ypos));
|
||
if (m_varImageAssessRect.ypos + m_varImageAssessRect.height > m_varGFrameFormat.nImageHeight)
|
||
{
|
||
m_varImageAssessRect.ypos = m_varGFrameFormat.nImageHeight - m_varImageAssessRect.height;
|
||
}
|
||
|
||
ui->m_lineEdit_ImageQuality_AssessY->setText(QString::number(m_varImageAssessRect.ypos));
|
||
// emit sigVideoRect(m_varImageAssessRect);
|
||
//画框
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_Y8_Throw_Left)
|
||
{
|
||
m_uLeftThrow = ui->m_lineEdit_Y8_Throw_Left->text().toShort();
|
||
}
|
||
if (sender() == ui->m_Btn_Y8_Throw_Right)
|
||
{
|
||
m_uRightThrow = ui->m_lineEdit_Y8_Throw_Right->text().toShort();
|
||
}
|
||
if (sender() == ui->m_Btn_Y8_ParamSet)
|
||
{
|
||
if (ui->m_Btn_Y8_ParamSet->text() == "坏点参数设置")
|
||
{
|
||
ui->m_lineEdit_Y8_BadPoint_Width->setEnabled(false);
|
||
ui->m_lineEdit_Y8_BadPoint_Height->setEnabled(false);
|
||
ui->m_lineEdit_Y8_WinHalf->setEnabled(false);
|
||
ui->m_lineEdit_Y8_Thresh->setEnabled(false);
|
||
ui->m_lineEdit_Y8_Pos->setEnabled(false);
|
||
|
||
ui->m_Btn_Y8_ParamSet->setText("坏点参数修改");
|
||
}
|
||
else if (ui->m_Btn_Y8_ParamSet->text() == "坏点参数修改")
|
||
{
|
||
ui->m_lineEdit_Y8_BadPoint_Width->setEnabled(true);
|
||
ui->m_lineEdit_Y8_BadPoint_Height->setEnabled(true);
|
||
ui->m_lineEdit_Y8_WinHalf->setEnabled(true);
|
||
ui->m_lineEdit_Y8_Thresh->setEnabled(true);
|
||
ui->m_lineEdit_Y8_Pos->setEnabled(true);
|
||
ui->m_Btn_Y8_ParamSet->setText("坏点参数设置");
|
||
}
|
||
|
||
m_varImageY8BadPoint.nImageWidth = ui->m_lineEdit_Y8_BadPoint_Width->text().toShort();
|
||
m_varImageY8BadPoint.nImageHeight = ui->m_lineEdit_Y8_BadPoint_Height->text().toShort();
|
||
m_varImageY8BadPoint.nWinHalf = ui->m_lineEdit_Y8_WinHalf->text().toInt();
|
||
m_varImageY8BadPoint.nThresh = ui->m_lineEdit_Y8_Thresh->text().toInt();
|
||
m_varImageY8BadPoint.nPos = ui->m_lineEdit_Y8_Pos->text().toInt();
|
||
|
||
}
|
||
if (sender() == ui->m_Btn_Y8_BadPointData_Load)
|
||
{
|
||
QFileDialog varFileDialog(this);
|
||
varFileDialog.setWindowTitle(QString("%1").arg(tr("打开视频文件")));
|
||
varFileDialog.setDirectory(tr(""));
|
||
|
||
QString strExt = tr("Y8 files (*.dat *.raw);;all files (*.*) )");
|
||
varFileDialog.setNameFilter(strExt);
|
||
|
||
if (QFileDialog::Rejected == varFileDialog.exec())
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
QString strFullPath = varFileDialog.selectedFiles()[0];
|
||
|
||
//
|
||
QFile varFile(strFullPath);
|
||
|
||
if (!varFile.open(QIODevice::ReadOnly))
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
int nWantedDataSize = (m_varImageY8BadPoint.nImageWidth) * (m_varImageY8BadPoint.nImageHeight);
|
||
|
||
memset(m_pY8BadPointData, 0, MaxSize_IRSensorTool);
|
||
|
||
//int nReadDataSize = varFile.read((char*)m_pY8BadPointData, nWantedDataSize);
|
||
int nReadDataSize = varFile.read((char*)m_pY8BadPointData, nWantedDataSize);
|
||
|
||
varFile.close();
|
||
|
||
if (nReadDataSize != nWantedDataSize)
|
||
{
|
||
return;
|
||
}
|
||
|
||
GdImageLib::Grey8ToRGBA(m_pRGBA, m_pY8BadPointData, m_varImageY8BadPoint.nImageWidth, m_varImageY8BadPoint.nImageHeight, 0);
|
||
// //图像显示
|
||
m_pOpenGLView->UpdateImageData(m_pRGBA, true);
|
||
|
||
}
|
||
if (sender() == ui->m_Btn_Y8_BadPoint_Calculate)
|
||
{
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
int SPointCnt1[20] = {0};
|
||
byte* pMenuFlag11 = new byte[(m_varImageY8BadPoint.nImageWidth) * (m_varImageY8BadPoint.nImageHeight)];
|
||
|
||
//统计坏斑个数
|
||
BadPointsDll(m_pY8BadPointData, 640, 512, m_varImageY8BadPoint.nWinHalf, m_varImageY8BadPoint.nThresh, m_varImageY8BadPoint.nPos, SPointCnt1, pMenuFlag11);
|
||
|
||
for (int i = 0; i < 20; i++)
|
||
{
|
||
m_pLineArrayValues[15 + i] = SPointCnt1[i];
|
||
}
|
||
|
||
emit sigSendQualityParamShow(m_pLineArrayValues);
|
||
|
||
delete [] pMenuFlag11;
|
||
pMenuFlag11 = nullptr;
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_XMix_Set)
|
||
{
|
||
if (ui->m_Btn_XMix_Set->text() == "参数设置")
|
||
{
|
||
ui->m_lineEdit_ImgWidth->setEnabled(false);
|
||
ui->m_lineEdit_ImgHeight->setEnabled(false);
|
||
ui->m_lineEdit_T_High->setEnabled(false);
|
||
ui->m_lineEdit_T_Low->setEnabled(false);
|
||
|
||
ui->m_Btn_XMix_Set->setText("参数修改");
|
||
}
|
||
else if (ui->m_Btn_XMix_Set->text() == "参数修改")
|
||
{
|
||
ui->m_lineEdit_ImgWidth->setEnabled(true);
|
||
ui->m_lineEdit_ImgHeight->setEnabled(true);
|
||
ui->m_lineEdit_T_High->setEnabled(true);
|
||
ui->m_lineEdit_T_Low->setEnabled(true);
|
||
|
||
ui->m_Btn_XMix_Set->setText("参数设置");
|
||
}
|
||
|
||
m_varImageX16Mix.nImageWidth = ui->m_lineEdit_ImgWidth->text().toShort();
|
||
m_varImageX16Mix.nImageHeight = ui->m_lineEdit_ImgHeight->text().toShort();
|
||
m_varImageX16Mix.nHighTempre = ui->m_lineEdit_T_High->text().toInt();
|
||
m_varImageX16Mix.nLowTempre = ui->m_lineEdit_T_Low->text().toInt();
|
||
}
|
||
if (sender() == ui->m_Btn_XMix_Calculate || sender() == ui->m_Btn_X_Mix_ResponseRatio || sender() == ui->m_Btn_X_Mix_NETD)
|
||
{
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
|
||
indexofXHL resultHL;
|
||
|
||
resultHL = GetNETDrate(m_pY16Data_B1, m_pY16Data_B2, m_varImageX16Mix.nHighTempre, m_varImageX16Mix.nLowTempre, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight);
|
||
|
||
m_pLineArrayValues[2] = resultHL.rate; //X高低温组合数据 响应率
|
||
m_pLineArrayValues[3] = resultHL.NETD * 1000; //X高低温组合数据 NETD
|
||
|
||
// for(int i = 4; i <= MAX_QUALITY_PARAMS-1;i++)
|
||
// {
|
||
// m_pLineArrayValues[i] = 0;
|
||
// }
|
||
|
||
// m_pLineArrayValues[0] = 0;
|
||
// m_pLineArrayValues[1] = 0;
|
||
|
||
|
||
emit sigSendQualityParamShow(m_pLineArrayValues);
|
||
}
|
||
}
|
||
|
||
|
||
//X数据高低温组合
|
||
{
|
||
/*
|
||
* 读取B1数据
|
||
*/
|
||
if (sender() == ui->m_Btn_LoadHigh_File_B1)
|
||
{
|
||
QFileDialog varFileDialog(this);
|
||
varFileDialog.setWindowTitle(QString("%1").arg(tr("打开视频文件")));
|
||
varFileDialog.setDirectory(tr(""));
|
||
//varFileDialog.setOption(QFileDialog::DontUseNativeDialog);
|
||
|
||
QString strExt = tr("Y16 files (*.dat *.raw);;all files (*.*) )");
|
||
varFileDialog.setNameFilter(strExt);
|
||
|
||
if (QFileDialog::Rejected == varFileDialog.exec())
|
||
{
|
||
return;
|
||
}
|
||
|
||
{
|
||
QString strFullPath = varFileDialog.selectedFiles()[0];
|
||
|
||
//
|
||
QFile varFile(strFullPath);
|
||
|
||
if (!varFile.open(QIODevice::ReadOnly))
|
||
{
|
||
return;
|
||
}
|
||
|
||
|
||
int nWantedDataSize = (m_varImageX16Mix.nImageWidth) * (m_varImageX16Mix.nImageHeight) * 2;
|
||
|
||
memset(m_pY16Data_B1, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
int nReadDataSize = varFile.read((char*)m_pY16Data_B1, nWantedDataSize);
|
||
|
||
varFile.close();
|
||
|
||
if (nReadDataSize != nWantedDataSize)
|
||
{
|
||
return;
|
||
}
|
||
|
||
//GdImageLib::Map16BitTo8Bit(m_pY8Data_B1, (short*)m_pY16Data_B1, (m_varImageX16Mix.nImageWidth)*(m_varImageX16Mix.nImageHeight), 100, 100);
|
||
}
|
||
|
||
}
|
||
if (sender() == ui->m_Btn_Show_File_B1)
|
||
{
|
||
|
||
//调光
|
||
ImgDeMean((ushort*)m_pY16Data_B1, (ushort*)m_pY8Data_B1, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight);
|
||
BBHE_MixTiaoGuangDll((ushort*)m_pY16Data_B1, m_pY8Data_B1, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, m_pTGAirthProcess->m_MixMapPara, m_pTGAirthProcess->m_MixMapOut);
|
||
|
||
|
||
QImage varBmpImage = QImage(m_pY8Data_B1, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, QImage::Format_Indexed8);
|
||
varBmpImage.setColorTable(m_varColorTable.at(0));
|
||
|
||
varBmpImage = varBmpImage.convertToFormat(QImage::Format_RGBA8888);
|
||
|
||
memcpy(m_pRGBA, varBmpImage.bits(), (m_varImageX16Mix.nImageWidth) * (m_varImageX16Mix.nImageHeight) * 4);
|
||
|
||
// GdImageLib::Grey8ToRGBA(m_pRGBA, m_pY8Data_B1, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, 0);
|
||
//QImage imgRGBA = QImage((byte*)m_pRGBA, ui->m_label_Assess->width(), ui->m_label_Assess->height(), QImage::Format_RGBA8888);
|
||
|
||
m_pOpenGLView->UpdateImageData(m_pRGBA, true);
|
||
|
||
//QImage varImage = imgRGBA.scaled(ui->m_label_Assess->size(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);//放缩图片,以固定大小显示
|
||
// ui->m_label_Assess->setPixmap(QPixmap::fromImage(imgRGBA));
|
||
}
|
||
|
||
/*
|
||
* 读取B2数据
|
||
*/
|
||
if (sender() == ui->m_Btn_LoadLow_File_B2)
|
||
{
|
||
QFileDialog varFileDialog(this);
|
||
varFileDialog.setWindowTitle(QString("%1").arg(tr("打开视频文件")));
|
||
varFileDialog.setDirectory(tr(""));
|
||
//varFileDialog.setOption(QFileDialog::DontUseNativeDialog);
|
||
|
||
QString strExt = tr("Y16 files (*.dat *.raw);;all files (*.*) )");
|
||
varFileDialog.setNameFilter(strExt);
|
||
|
||
if (QFileDialog::Rejected == varFileDialog.exec())
|
||
{
|
||
return;
|
||
}
|
||
|
||
{
|
||
QString strFullPath = varFileDialog.selectedFiles()[0];
|
||
|
||
//
|
||
QFile varFile(strFullPath);
|
||
|
||
if (!varFile.open(QIODevice::ReadOnly))
|
||
{
|
||
return;
|
||
}
|
||
|
||
int nWantedDataSize = (m_varImageX16Mix.nImageWidth) * (m_varImageX16Mix.nImageHeight) * 2;
|
||
|
||
memset(m_pY16Data_B2, 0, MaxSize_IRSensorTool * 2);
|
||
|
||
int nReadDataSize = varFile.read((char*)m_pY16Data_B2, nWantedDataSize);
|
||
|
||
varFile.close();
|
||
|
||
if (nReadDataSize != nWantedDataSize)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// GdImageLib::Map16BitTo8Bit(m_pY8Data_B2, (short*)m_pY16Data_B2, (m_varImageX16Mix.nImageWidth)*(m_varImageX16Mix.nImageHeight), 100, 100);
|
||
}
|
||
|
||
|
||
}
|
||
if (sender() == ui->m_Btn_Show_File_B2)
|
||
{
|
||
//调光
|
||
ImgDeMean((ushort*)m_pY16Data_B2, (ushort*)m_pY8Data_B2, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight);
|
||
BBHE_MixTiaoGuangDll((ushort*)m_pY16Data_B2, m_pY8Data_B2, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, m_pTGAirthProcess->m_MixMapPara, m_pTGAirthProcess->m_MixMapOut);
|
||
|
||
|
||
QImage varBmpImage = QImage(m_pY8Data_B2, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, QImage::Format_Indexed8);
|
||
varBmpImage.setColorTable(m_varColorTable.at(0));
|
||
|
||
varBmpImage = varBmpImage.convertToFormat(QImage::Format_RGBA8888);
|
||
|
||
memcpy(m_pRGBA, varBmpImage.bits(), (m_varImageX16Mix.nImageWidth) * (m_varImageX16Mix.nImageHeight) * 4);
|
||
|
||
|
||
// GdImageLib::Grey8ToRGBA(m_pRGBA, m_pY8Data_B2, m_varImageX16Mix.nImageWidth, m_varImageX16Mix.nImageHeight, 1);
|
||
// QImage imgRGBA = QImage((Byte*)m_pRGBA, ui->m_label_Assess->width(), ui->m_label_Assess->height(), QImage::Format_RGBA8888);
|
||
|
||
m_pOpenGLView->UpdateImageData(m_pRGBA, true);
|
||
//QImage varImage = imgRGBA.scaled(ui->m_label_Assess->size(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);//放缩图片,以固定大小显示
|
||
// ui->m_label_Assess->setPixmap(QPixmap::fromImage(imgRGBA));
|
||
}
|
||
|
||
}
|
||
|
||
/*图像质量评估*/
|
||
|
||
|
||
// 调光设置窗口
|
||
if (sender() == ui->m_Btn_Settings_TG)
|
||
{
|
||
//m_bTGSettings = !m_bTGSettings;
|
||
|
||
int nAdjustWidth = ui->m_dockWidget_TGSettings->geometry().width();
|
||
//ui->m_dockWidget_TGSettings->setVisible(m_bTGSettings);
|
||
|
||
if (ui->m_dockWidget_TGSettings->isVisible())
|
||
{
|
||
m_bTGSettings = false;
|
||
ui->m_dockWidget_TGSettings->setVisible(false);
|
||
}
|
||
else
|
||
{
|
||
m_bTGSettings = true;
|
||
ui->m_dockWidget_TGSettings->setVisible(true);
|
||
}
|
||
|
||
|
||
QRect rc = this->geometry();
|
||
|
||
if (m_bTGSettings)
|
||
{
|
||
rc.setWidth(rc.width() + nAdjustWidth);
|
||
}
|
||
else
|
||
{
|
||
rc.setWidth(rc.width() - nAdjustWidth);
|
||
}
|
||
|
||
this->setGeometry(rc);
|
||
CommonHelper::FormInCenter(this);
|
||
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnButtonPressed()
|
||
{
|
||
if (sender() == ui->m_Btn_UnCoolSet_Compensation)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_COMPENSATION);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Menu)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_MENU);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Add)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_ADD);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Min)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_MIN);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_No_Compensation)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_NO_COMPENSATION);
|
||
}
|
||
}
|
||
|
||
|
||
void MainWindow::OnButtonReleased()
|
||
{
|
||
if (!m_bConnectFlag)
|
||
{
|
||
//CommonHelper::ShowMessageBoxError(tr("串口未开启!"));
|
||
return;
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Compensation)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_KEY_POPUP);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Menu)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_KEY_POPUP);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Add)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_KEY_POPUP);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_Min)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_KEY_POPUP);
|
||
}
|
||
if (sender() == ui->m_Btn_UnCoolSet_No_Compensation)
|
||
{
|
||
m_SerialHelp->writeCmdToolData(CMD_UNCOOL_KEY_POPUP);
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnSliderValueChanged(int nVal)
|
||
{
|
||
if (sender() == ui->m_hSlider_brightness)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.nBright = nVal;
|
||
QString str = QString("%1/100").arg(nVal);
|
||
ui->m_label_Bright->setText(str);
|
||
}
|
||
|
||
if (sender() == ui->m_hSlider_contrast)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.nContrast = nVal;
|
||
QString str = QString("%1/100").arg(nVal);
|
||
ui->m_label_Contrast->setText(str);
|
||
}
|
||
if (sender() == ui->m_hSlider_IDE)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.fHighImgPara = 1.0 * nVal / 20.0;
|
||
QString str = QString("%1/20").arg(nVal);
|
||
ui->m_label_IDE->setText(str);
|
||
}
|
||
if (sender() == ui->m_hSlider_DDE)
|
||
{
|
||
m_pTGAirthProcess->m_TGInfo.DDEParam = nVal;
|
||
QString str = QString("%1/16").arg(nVal);
|
||
ui->m_label_DDE->setText(str);
|
||
}
|
||
}
|
||
|
||
|
||
void MainWindow::OnButtonIsChecked(bool isCheck)
|
||
{
|
||
if (sender() == ui->m_radioButton_LineTG)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.MixMedthod = 0;
|
||
}
|
||
}
|
||
|
||
if (sender() == ui->m_radioButton_HistTG)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.MixMedthod = 1;
|
||
}
|
||
}
|
||
|
||
if (sender() == ui->m_radioButton_MixTG)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
m_pTGAirthProcess->m_MixMapPara.MixMedthod = 2;
|
||
}
|
||
}
|
||
|
||
//图像质量评估窗口
|
||
//数据格式
|
||
if (sender() == ui->m_Rb_X)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
ui->m_stackedWidget_CalculateArea->setCurrentIndex(0);
|
||
ShowY16BackRect(false);
|
||
//memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Rb_X_Mix)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
ui->m_stackedWidget_CalculateArea->setCurrentIndex(1);
|
||
ShowY16BackRect(false);
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Rb_Y8)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
ui->m_stackedWidget_CalculateArea->setCurrentIndex(2);
|
||
ShowY16BackRect(false);
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
}
|
||
}
|
||
if (sender() == ui->m_Rb_Y16)
|
||
{
|
||
if (isCheck)
|
||
{
|
||
ui->m_stackedWidget_CalculateArea->setCurrentIndex(3);
|
||
ShowY16BackRect(true);
|
||
//memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
}
|
||
}
|
||
|
||
//计算区域
|
||
{
|
||
if (sender() == ui->m_Ck_X_TimeDomain_Deviation)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
|
||
//绘制时域标准差曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
|
||
m_bIsDrawLines[0] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_X_MeanValue)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制均值曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
|
||
m_bIsDrawLines[1] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_X_Mix_ResponseRatio)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[2] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_X_Mix_NETD)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制X数据高低温组合---NETD曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[3] = isCheck;
|
||
}
|
||
|
||
//Y8
|
||
if (sender() == ui->m_Ck_Y8_AirSpace_Deviation)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y8数据--空域标准差曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[4] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y8_MeanValue)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y8数据--均值曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[5] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y8_DynamicRange)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y8数据--动态范围曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
|
||
m_bIsDrawLines[6] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y8_MTF)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y8数据--MTF曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[7] = isCheck;
|
||
}
|
||
|
||
//Y16
|
||
if (sender() == ui->m_Ck_Y16_AirSpace_Deviation)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--空域标准差曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[8] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y16_Nonuniform)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--非均匀校正残差曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[9] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y16_MeanValue)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--均值曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[10] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y16_SignalNoiseRatio)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--特定目标信噪比曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[11] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y16_BadPoint)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--坏点个数
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[14] = isCheck;
|
||
}
|
||
if (sender() == ui->m_Ck_Y16_AD)
|
||
{
|
||
QString cmd;
|
||
if (isCheck)
|
||
{
|
||
InitAllCurves();
|
||
//绘制Y16数据--图像上下AD差曲线
|
||
}
|
||
else
|
||
{
|
||
m_fOldMax = 0;
|
||
}
|
||
m_bIsDrawLines[12] = isCheck;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::OnButtonClicked_TG()
|
||
{
|
||
//调光参数设置
|
||
if (sender() == ui->m_Btn_TG_SW)
|
||
{
|
||
m_bTGArithOpen = !m_bTGArithOpen;
|
||
if (m_bTGArithOpen)
|
||
{
|
||
ui->m_Btn_TG_SW->setText("算法关闭");
|
||
ui->m_Btn_TG_SetPara->setEnabled(true);
|
||
|
||
m_pTGAirthProcess->Start();
|
||
}
|
||
else
|
||
{
|
||
ui->m_Btn_TG_SW->setText("算法开启");
|
||
ui->m_Btn_TG_SetPara->setEnabled(false);
|
||
m_pTGAirthProcess->Stop();
|
||
}
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_TG_SetPara)
|
||
{
|
||
if (ui->m_Btn_TG_SetPara->text() == "设置参数")
|
||
{
|
||
ui->m_Btn_TG_SetPara->setText("修改参数");
|
||
//更新参数
|
||
m_pTGAirthProcess->m_TGInfo.Y8MapIdx = ui->m_comboBox_TG_Y8_mapping_table->currentIndex();
|
||
m_pTGAirthProcess->m_TGInfo.DeGuoGaiArith = ui->m_checkBox_TG_DeGuoGai->isChecked();
|
||
m_pTGAirthProcess->m_TGInfo.IsTimeFilter = ui->m_checkBox_TG_tfFilter->isChecked();
|
||
m_pTGAirthProcess->m_TGInfo.TFSigma = ui->m_lineEdit_TG_tf_sigma->text().toInt();
|
||
m_pTGAirthProcess->m_TGInfo.DestripArithIdx = ui->m_comboBox_TG_Strip->currentIndex();
|
||
m_pTGAirthProcess->m_TGInfo.StripWeight = ui->m_lineEdit_TG_strip_weight_thresh->text().toInt();
|
||
m_pTGAirthProcess->m_TGInfo.StripStd = ui->m_lineEdit_TG_strip_std->text().toInt();
|
||
m_pTGAirthProcess->m_TGInfo.DenoiseArith = ui->m_comboBox_TG_Denoise_Arith->currentIndex();
|
||
m_pTGAirthProcess->m_TGInfo.DenoiseStd = ui->m_lineEdit_TG_Denoise_Std->text().toInt();
|
||
if (ui->m_radioButton_TG_DDE_Y16->isChecked())
|
||
{
|
||
m_pTGAirthProcess->m_TGInfo.DDEArith = 0;
|
||
}
|
||
else if (ui->m_radioButton_TG_DDE_Y8->isChecked())
|
||
{
|
||
m_pTGAirthProcess->m_TGInfo.DDEArith = 1;
|
||
}
|
||
m_pTGAirthProcess->m_TGInfo.DDEParam = 0;
|
||
m_pTGAirthProcess->m_TGInfo.IDEArith = ui->m_comboBox_TG_IDE_Arith->currentIndex();
|
||
//m_pTGAirthProcess->m_TGInfo.FlagT = 0;
|
||
m_pTGAirthProcess->m_TGInfo.DeBadPixel = ui->m_checkBox_TG_DeBadPixel->isChecked();
|
||
m_pTGAirthProcess->m_TGInfo.Clahe = ui->m_checkBox_TG_Clahe->isChecked();
|
||
m_pTGAirthProcess->m_MixMapPara.nY8MapMean = ui->m_lineEdit_TG_BBHE_y8_mean->text().toInt();
|
||
m_pTGAirthProcess->m_MixMapPara.nBBHELeft = ui->m_lineEdit_TG_BBHE_Lthresh->text().toInt();
|
||
m_pTGAirthProcess->m_MixMapPara.nBBHERight = ui->m_lineEdit_TG_BBHE_Rthresh->text().toInt();
|
||
m_pTGAirthProcess->m_MixMapPara.MapRange = ui->m_lineEdit_TG_Y8_range->text().toInt();
|
||
m_pTGAirthProcess->m_MixMapPara.nClaheWinSize = ui->m_lineEdit_TG_CLAHE_blocksize->text().toInt();
|
||
m_pTGAirthProcess->m_MixMapPara.nClaheLimit = ui->m_lineEdit_TG_CLAHE_cliplimit->text().toInt();
|
||
|
||
ui->m_groupBox_TG->setEnabled(false);
|
||
}
|
||
else if (ui->m_Btn_TG_SetPara->text() == "修改参数")
|
||
{
|
||
ui->m_Btn_TG_SetPara->setText("设置参数");
|
||
ui->m_groupBox_TG->setEnabled(true);
|
||
}
|
||
}
|
||
|
||
if (sender() == ui->m_Btn_TG_GetGuoGaiModel)
|
||
{
|
||
QString filePath = QFileDialog::getOpenFileName(this, "加载锅盖模板", filePath, "*.raw");
|
||
|
||
QFile file(filePath);
|
||
file.open(QFile::ReadOnly);
|
||
unsigned char* pTempData = new unsigned char[c_nWMemSize];
|
||
file.read((char*)pTempData, 2 * IMG_WIDTH * IMG_HEIGHT);
|
||
memcpy(m_pTGAirthProcess->m_TGInfo.GuogaiB, pTempData, sizeof(unsigned short)*IMG_WIDTH * IMG_HEIGHT);
|
||
m_pTGAirthProcess->m_TGInfo.GuoGaiModel = true;
|
||
|
||
delete [] pTempData;
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::OnButtonClicked_Playback()
|
||
{
|
||
// 循环播放
|
||
if (sender() == ui->m_checkBox_RecyclePlay)
|
||
{
|
||
m_bRecyclePlay = ui->m_checkBox_RecyclePlay->isChecked();
|
||
}
|
||
|
||
// 浏览文件(文件夹)
|
||
if (sender() == ui->m_Btn_BrowseFile)
|
||
{
|
||
if (!BrowseRawFile(false))
|
||
{
|
||
return;
|
||
}
|
||
|
||
QString strFilePath = m_strCurrentFilePath;
|
||
strFilePath = strFilePath.trimmed();
|
||
|
||
if (strFilePath.endsWith(".raw", Qt::CaseInsensitive) ||
|
||
strFilePath.endsWith(".dat", Qt::CaseInsensitive))
|
||
{
|
||
m_pFrameParams->SetFileType(true);
|
||
m_pFrameParams->SetCardCount(0);
|
||
m_pFrameParams->show();
|
||
m_pFrameParams->setAttribute(Qt::WA_ShowWithoutActivating);
|
||
}
|
||
else
|
||
{}
|
||
}
|
||
|
||
// 播放/暂停文件
|
||
if (m_bOpenFile && sender() == ui->m_playPauseBtn)
|
||
{
|
||
// qDebug() <<"m_bOpenFile &&sender() == ui->m_playPauseBtn";
|
||
// if (m_iPlayState == 0)
|
||
// {
|
||
// StartThread_DealRawFileData();
|
||
// m_iPlayState = 1;
|
||
// }
|
||
// else if (m_iPlayState == 2)
|
||
// {
|
||
// m_iPlayState = 1;
|
||
// SetPlayOrPauseButton(false);
|
||
// }
|
||
// else
|
||
// {
|
||
// m_iPlayState = 2;
|
||
// }
|
||
// return;
|
||
|
||
// 停止状态
|
||
if (nullptr == m_pRawFileStream[0]
|
||
#if MULTI_CHANNEL
|
||
|| nullptr == m_pRawFileStream[1]
|
||
#endif
|
||
)
|
||
{
|
||
|
||
OnConfirm_File(true, m_varGFrameFormat);
|
||
|
||
}
|
||
else // 播放/暂停状态
|
||
{
|
||
if (ePS_Play == m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Pause();
|
||
}
|
||
|
||
SetPlayOrPauseButton(true);
|
||
}
|
||
else
|
||
{
|
||
switch (m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
case ePS_Stop:
|
||
{
|
||
StartThread_DealRawFileData();
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Play();
|
||
}
|
||
break;
|
||
}
|
||
case ePS_Pause:
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Play();
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
SetPlayOrPauseButton(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 停止播放
|
||
if (m_bOpenFile && sender() == ui->m_stopBtn) // 文件
|
||
{
|
||
StopThread_DealRawFileData();
|
||
//GLogger::GetInstance()->WriteInfo("STOP");
|
||
if (nullptr != m_pRawFileStream[0])
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
if (nullptr != m_pRawFileStream[i])
|
||
{
|
||
m_pRawFileStream[i]->Stop();
|
||
|
||
delete m_pRawFileStream[i];
|
||
m_pRawFileStream[i] = nullptr;
|
||
}
|
||
}
|
||
}
|
||
m_iPlayState = 5;
|
||
// m_bOpenFile = false;
|
||
SetPlayOrPauseButton(true);
|
||
m_bUpdateProgress = false;
|
||
ui->m_label_Progress->setText("0/0");
|
||
ui->m_horizontalSlider_Progress->setValue(0);
|
||
UpdateImgFormat();
|
||
}
|
||
else if (m_bCaptureData && sender() == ui->m_stopBtn) //设备
|
||
{
|
||
StopThread_DealDeviceData();
|
||
SetPlayOrPauseButton(true);
|
||
UpdateImgFormat();
|
||
}
|
||
|
||
// 前一帧
|
||
if (m_bOpenFile && sender() == ui->m_forwardBtn)
|
||
{
|
||
if (nullptr == m_pRawFileStream[0]
|
||
#if MULTI_CHANNEL
|
||
|| nullptr == m_pRawFileStream[1]
|
||
#endif
|
||
)
|
||
{
|
||
return;
|
||
}
|
||
m_iPlayState = 4;
|
||
|
||
if (ePS_Play == m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Pause();
|
||
}
|
||
|
||
SetPlayOrPauseButton(true);
|
||
}
|
||
|
||
if (ePS_Pause == m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
// Previous
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Previous();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
// 后一帧
|
||
if (m_bOpenFile && sender() == ui->m_nextBtn)
|
||
{
|
||
if (nullptr == m_pRawFileStream[0]
|
||
#if MULTI_CHANNEL
|
||
|| nullptr == m_pRawFileStream[1]
|
||
#endif
|
||
)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_iPlayState = 3;
|
||
|
||
// static int s_nNext = 0;
|
||
// qDebug() << "next Frame" << s_nNext++;
|
||
|
||
if (ePS_Play == m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Pause();
|
||
}
|
||
|
||
|
||
SetPlayOrPauseButton(true);
|
||
}
|
||
|
||
if (ePS_Pause == m_pRawFileStream[0]->GetPlayState())
|
||
{
|
||
// Next
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_pRawFileStream[i]->Next();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnButtonClicked_Capture()
|
||
{
|
||
// 采集数据
|
||
if (sender() == ui->m_Btn_CaptureData)
|
||
{
|
||
if (!m_bCaptureData)
|
||
{
|
||
//ui->m_stopBtn->clicked();
|
||
// 停止文件播放
|
||
if (m_bOpenFile) // 文件
|
||
{
|
||
StopThread_DealRawFileData();
|
||
if (nullptr != m_pRawFileStream[0])
|
||
{
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
if (nullptr != m_pRawFileStream[i])
|
||
{
|
||
m_pRawFileStream[i]->Stop();
|
||
|
||
delete m_pRawFileStream[i];
|
||
m_pRawFileStream[i] = nullptr;
|
||
}
|
||
}
|
||
}
|
||
m_iPlayState = 5;
|
||
// m_bOpenFile = false;
|
||
SetPlayOrPauseButton(true);
|
||
m_bUpdateProgress = false;
|
||
ui->m_label_Progress->setText("0/0");
|
||
ui->m_horizontalSlider_Progress->setValue(0);
|
||
UpdateImgFormat();
|
||
|
||
m_bOpenFile = false;
|
||
}
|
||
|
||
|
||
|
||
m_pFrameParams->SetFileType(false);
|
||
m_pFrameParams->SetCardCount(3);
|
||
m_pFrameParams->show();
|
||
m_pFrameParams->setAttribute(Qt::WA_ShowWithoutActivating);
|
||
|
||
}
|
||
else
|
||
{
|
||
StopThread_DealDeviceData();
|
||
//正在录像就关闭
|
||
if (m_bIsRecord)
|
||
{
|
||
m_bIsRecord = false;
|
||
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_recordThread[i]->stopThread();
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
// 录像
|
||
if (m_bCaptureData && sender() == ui->m_Btn_EnableRecord)
|
||
{
|
||
bool bisRecord = !m_bIsRecord;
|
||
|
||
if (bisRecord)
|
||
{
|
||
m_bIsRecord = true;
|
||
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_recordThread[i]->SetImgSize(m_varGFrameFormat.nImageWidth * m_varGFrameFormat.nImageHeight * m_varGFrameFormat.nBytesOfPixel);
|
||
m_recordThread[i]->startThread();
|
||
}
|
||
m_pDevCap->ClearFrameCount();
|
||
ui->m_Btn_EnableRecord->setProperty("recordProperty", "stop");
|
||
ui->m_Btn_EnableRecord->setToolTip(tr("停止录像"));
|
||
|
||
}
|
||
else
|
||
{
|
||
m_bIsRecord = false;
|
||
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
m_recordThread[i]->stopThread();
|
||
ui->m_Btn_EnableRecord->setProperty("recordProperty", "start");
|
||
ui->m_Btn_EnableRecord->setToolTip(tr("开始录像"));
|
||
}
|
||
|
||
}
|
||
|
||
ui->m_Btn_EnableRecord->setStyle(QApplication::style());
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnComboxIndexChanged(int nIndex)
|
||
{
|
||
}
|
||
|
||
void MainWindow::showEvent(QShowEvent* event)
|
||
{
|
||
this->setAttribute(Qt::WA_Mapped);
|
||
QWidget::showEvent(event);
|
||
}
|
||
|
||
void MainWindow::InitStyle()
|
||
{
|
||
m_bMousePressed = false;
|
||
|
||
//安装事件监听器,让标题栏识别鼠标双击
|
||
ui->lblTitle->installEventFilter(this);
|
||
ui->m_openGLWidget_Capture0->installEventFilter(this);
|
||
|
||
this->setWindowFlags(Qt::FramelessWindowHint
|
||
| Qt::WindowSystemMenuHint
|
||
| Qt::WindowMinimizeButtonHint);
|
||
|
||
FramelessHelper* pHelper = new FramelessHelper(this);
|
||
pHelper->activateOn(this); //激活当前窗体
|
||
pHelper->setTitleHeight(ui->wgtTitleBar->height()); //设置窗体的标题栏高度
|
||
|
||
// QMenu *helpMenu = new QMenu(this);
|
||
// aboutAction = new QAction(tr("&关于..."), this);
|
||
// aboutAction->setShortcut(tr("F1"));
|
||
// connect(aboutAction, SIGNAL(triggered()), this, SLOT(helpAbout()));
|
||
// helpMenu->addAction(aboutAction);
|
||
// ui->m_Btn_Settings_TG->setMenu(helpMenu);
|
||
|
||
CommonHelper::SetStyle("blue");//"blue"//"dark"
|
||
|
||
|
||
if (g_bExpertMode)
|
||
{
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(1);
|
||
}
|
||
else
|
||
{
|
||
ui->stackedWidget_Ctrl->setCurrentIndex(0);
|
||
m_pUserControl = new UserControl(this);
|
||
layoutIR = new QVBoxLayout(ui->m_UserWidget);
|
||
layoutIR->addWidget(m_pUserControl);
|
||
layoutIR->setMargin(0);
|
||
layoutIR->setSpacing(0);
|
||
|
||
ui->m_Btn_Settings->setVisible(false);
|
||
ui->m_Btn_Settings->setEnabled(false);
|
||
ui->m_Btn_ControlASCII->setVisible(false);
|
||
ui->m_Btn_ControlASCII->setEnabled(false);
|
||
ui->m_Btn_GetSystemCode->setVisible(false);
|
||
ui->m_Btn_GetSystemCode->setEnabled(false);
|
||
}
|
||
|
||
int nAdjustWidth = ui->m_dockWidget_TGSettings->geometry().width();
|
||
ui->m_dockWidget_TGSettings->setVisible(false);
|
||
QRect rc = this->geometry();
|
||
|
||
m_nScreenWidthMax = rc.width();
|
||
m_nScreenHeightMax = rc.height();
|
||
|
||
rc.setWidth(rc.width() - nAdjustWidth);
|
||
|
||
this->setGeometry(rc);
|
||
CommonHelper::FormInCenter(this);
|
||
|
||
ui->m_pushButtonImageFormatColorTableItem01->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem02->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem03->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem04->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem05->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem06->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem07->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem08->installEventFilter(this);
|
||
ui->m_pushButtonImageFormatColorTableItem09->installEventFilter(this);
|
||
|
||
ui->m_Btn_StartUpgrade->setEnabled(false);
|
||
// ui->m_Btn_UnCoolDev->setVisible(false);
|
||
|
||
ui->m_Btn_UnCool_Set->hide();
|
||
ui->m_Btn_TG_SetPara->setEnabled(false);
|
||
|
||
}
|
||
|
||
void MainWindow::LimitValue(int& nX, int& nY, int& nW, int& nH)
|
||
{
|
||
nX = ((nX <= 0) ? 0 : nX);
|
||
nX = ((nX >= (m_varGFrameFormat.nImageWidth - 1)) ? (m_varGFrameFormat.nImageWidth - 1) : nX);
|
||
|
||
nY = ((nY <= 0) ? 0 : nY);
|
||
nY = ((nY >= (m_varGFrameFormat.nImageHeight - 1)) ? (m_varGFrameFormat.nImageHeight - 1) : nY);
|
||
|
||
nW = ((nW <= 0) ? 0 : nW);
|
||
nW = ((nW >= (m_varGFrameFormat.nImageWidth - 1 - nX)) ? (m_varGFrameFormat.nImageWidth - 1 - nX) : nW);
|
||
|
||
nH = ((nH <= 0) ? 0 : nH);
|
||
nH = ((nH >= (m_varGFrameFormat.nImageHeight - 1 - nY)) ? (m_varGFrameFormat.nImageHeight - 1 - nY) : nH);
|
||
}
|
||
|
||
bool MainWindow::eventFilter(QObject* obj, QEvent* event)
|
||
{
|
||
if (m_pOpenGLView == obj)
|
||
{
|
||
if (event->type() == QEvent::MouseButtonPress)
|
||
{
|
||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||
|
||
if (mouseEvent->button() == Qt::LeftButton)
|
||
{
|
||
m_bRectDraw = true;
|
||
m_varPointStart = mouseEvent->pos();
|
||
m_varPointEnd = m_varPointStart;
|
||
|
||
m_bShowRect = false;
|
||
|
||
}
|
||
if (mouseEvent->button() == Qt::RightButton)
|
||
{
|
||
m_bBackRectDraw = true;
|
||
|
||
m_varBackPointStart = mouseEvent->pos();
|
||
m_varBackPointEnd = m_varBackPointStart;
|
||
|
||
m_bShowBackRect = false;
|
||
}
|
||
return true;
|
||
}
|
||
if (event->type() == QEvent::MouseMove)
|
||
{
|
||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||
|
||
if (m_bRectDraw)
|
||
{
|
||
m_varPointEnd = mouseEvent->pos();
|
||
}
|
||
if (m_bBackRectDraw)
|
||
{
|
||
m_varBackPointEnd = mouseEvent->pos();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
else if (event->type() == QEvent::MouseButtonRelease)
|
||
{
|
||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||
|
||
if (mouseEvent->button() == Qt::LeftButton)
|
||
{
|
||
if (m_bRectDraw)
|
||
{
|
||
m_varPointEnd = mouseEvent->pos();
|
||
|
||
m_bRectDraw = false;
|
||
|
||
if (m_pOpenGLView)
|
||
{
|
||
int x = double(m_varPointStart.x() - m_pOpenGLView->PosX()) / m_pOpenGLView->ViewRatio();
|
||
int y = double(m_varPointStart.y() - m_pOpenGLView->PosY()) / m_pOpenGLView->ViewRatio();
|
||
int w = double(m_varPointEnd.x() - m_varPointStart.x()) / m_pOpenGLView->ViewRatio();
|
||
int h = double(m_varPointEnd.y() - m_varPointStart.y()) / m_pOpenGLView->ViewRatio();
|
||
|
||
LimitValue(x, y, w, h);
|
||
|
||
m_varImageAssessRect.xpos = x;
|
||
m_varImageAssessRect.ypos = y;
|
||
m_varImageAssessRect.width = w;
|
||
m_varImageAssessRect.height = h;
|
||
|
||
emit sigVideoRect(m_varImageAssessRect);
|
||
}
|
||
|
||
m_bShowRect = true;
|
||
}
|
||
}
|
||
if (mouseEvent->button() == Qt::RightButton)
|
||
{
|
||
if (m_bBackRectDraw)
|
||
{
|
||
m_varBackPointEnd = mouseEvent->pos();
|
||
m_bBackRectDraw = false;
|
||
|
||
if (m_pOpenGLView)
|
||
{
|
||
int x = double(m_varBackPointStart.x() - m_pOpenGLView->PosX()) / m_pOpenGLView->ViewRatio();
|
||
int y = double(m_varBackPointStart.y() - m_pOpenGLView->PosY()) / m_pOpenGLView->ViewRatio();
|
||
int w = double(m_varBackPointEnd.x() - m_varBackPointStart.x()) / m_pOpenGLView->ViewRatio();
|
||
int h = double(m_varBackPointEnd.y() - m_varBackPointStart.y()) / m_pOpenGLView->ViewRatio();
|
||
|
||
LimitValue(x, y, w, h);
|
||
|
||
m_varImageAssessBackRect.xpos = x;
|
||
m_varImageAssessBackRect.ypos = y;
|
||
m_varImageAssessBackRect.width = w;
|
||
m_varImageAssessBackRect.height = h;
|
||
|
||
emit sigBackVideoRect(m_varImageAssessBackRect);
|
||
}
|
||
|
||
m_bShowBackRect = true;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
#if 1
|
||
if (event->type() == QEvent::MouseButtonDblClick)
|
||
{
|
||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||
|
||
if (mouseEvent->button() == Qt::LeftButton)
|
||
{
|
||
if (!m_bFullScreen)
|
||
{
|
||
m_bFullScreen = true;
|
||
|
||
ui->m_openGLWidget_Capture0->setWindowFlag(Qt::Window);
|
||
ui->m_openGLWidget_Capture0->showFullScreen();
|
||
|
||
// ui->m_dockWidget_TGSettings->setVisible(false);
|
||
// ui->wgtTitleBar->hide();
|
||
// ui->PlayCtrlwidget->hide();
|
||
}
|
||
else
|
||
{
|
||
m_bFullScreen = false;
|
||
|
||
ui->m_openGLWidget_Capture0->setParent(this);
|
||
ui->gridLayout_5->addWidget(ui->m_openGLWidget_Capture0);
|
||
ui->gridLayout_5->addWidget(ui->PlayCtrlwidget);
|
||
ui->m_openGLWidget_Capture0->showNormal();
|
||
ui->m_openGLWidget_Capture0->setWindowFlag(Qt::SubWindow);
|
||
|
||
// ui->wgtTitleBar->show();
|
||
// ui->PlayCtrlwidget->show();
|
||
|
||
}
|
||
|
||
return true;
|
||
|
||
}
|
||
|
||
}
|
||
#endif
|
||
}
|
||
|
||
// 设置调色板
|
||
else if (ui->m_pushButtonImageFormatColorTableItem01 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(0);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem02 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(1);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem03 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(2);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem04 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(3);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem05 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(4);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem06 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(5);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem07 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(6);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem08 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(7);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
|
||
else if (ui->m_pushButtonImageFormatColorTableItem09 == obj)
|
||
{
|
||
if (event->type() == QEvent::Enter)
|
||
{
|
||
EnterColorTable(8);
|
||
setCursor(QCursor(Qt::PointingHandCursor));
|
||
}
|
||
if (event->type() == QEvent::Leave)
|
||
{
|
||
LeaveColorTable();
|
||
setCursor(QCursor(Qt::ArrowCursor));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
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 QMainWindow::eventFilter(obj, event);
|
||
}
|
||
|
||
void MainWindow::SetColorIndex(int value)
|
||
{
|
||
m_nColorIndex = value;
|
||
m_nOldColorIndex = value;
|
||
}
|
||
|
||
void MainWindow::EnterColorTable(int value)
|
||
{
|
||
m_nOldColorIndex = m_nColorIndex;
|
||
m_nColorIndex = value;
|
||
}
|
||
|
||
void MainWindow::LeaveColorTable()
|
||
{
|
||
m_nColorIndex = m_nOldColorIndex;
|
||
}
|
||
|
||
bool MainWindow::BrowseRawFile(bool p_bisDir)
|
||
{
|
||
QFileDialog varFileDialog(this);
|
||
|
||
if (!p_bisDir)
|
||
{
|
||
varFileDialog.setWindowTitle(/*QString("%1").fromLocal8Bit(*/ tr("读取raw文件"));
|
||
varFileDialog.setDirectory(tr(""));
|
||
|
||
QString strExt = tr("raw files (*.raw *.dat);;all files (*.*) )");
|
||
varFileDialog.setNameFilter(strExt);
|
||
|
||
if (QFileDialog::Accepted == varFileDialog.exec())
|
||
{
|
||
QString strDir = varFileDialog.selectedFiles()[0];
|
||
|
||
m_strCurrentFilePath = strDir;
|
||
|
||
return true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
varFileDialog.setWindowTitle(/*QString("%1").fromLocal8Bit(*/ tr("读取raw文件"));
|
||
varFileDialog.setDirectory(tr(""));
|
||
|
||
varFileDialog.setFileMode(QFileDialog::DirectoryOnly);
|
||
|
||
if (QFileDialog::Accepted == varFileDialog.exec())
|
||
{
|
||
QString strDir = varFileDialog.selectedFiles()[0];
|
||
|
||
m_strCurrentFilePath = strDir;
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
void MainWindow::SetPlayOrPauseButton(bool bPlay)
|
||
{
|
||
if (bPlay)
|
||
{
|
||
ui->m_playPauseBtn->setToolTip(tr("播放(空格)"));
|
||
ui->m_playPauseBtn->setProperty("playProperty", "play");
|
||
ui->m_playPauseBtn->setStyle(QApplication::style());
|
||
}
|
||
else
|
||
{
|
||
ui->m_playPauseBtn->setToolTip(tr("暂停(空格)"));
|
||
ui->m_playPauseBtn->setProperty("playProperty", "pause");
|
||
ui->m_playPauseBtn->setStyle(QApplication::style());
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnSlotFetureChanged(bool bl)
|
||
{
|
||
if (!bl)
|
||
{
|
||
int nAdjustWidth = ui->m_dockWidget_TGSettings->geometry().width();
|
||
QRect rc = this->geometry();
|
||
rc.setWidth(rc.width() - nAdjustWidth);
|
||
|
||
this->setGeometry(rc);
|
||
m_pOpenGLView->setGeometry(rc);
|
||
CommonHelper::FormInCenter(this);
|
||
}
|
||
else
|
||
{
|
||
// qDebug() <<"true";
|
||
}
|
||
}
|
||
|
||
void MainWindow::SetProgress(/*int iID, */int nFrameIndex, int nFrameCount)
|
||
{
|
||
// 切换暂停播放
|
||
if (-1 == nFrameIndex && -1 == nFrameCount)
|
||
{
|
||
m_bTriggerPausedState = true;
|
||
}
|
||
// 播放
|
||
else
|
||
{
|
||
m_nProgress_FrameIndex = nFrameIndex;
|
||
m_nProgress_FrameCount = nFrameCount;
|
||
|
||
// m_nProgressFrameIndex[iID] = nFrameIndex;
|
||
//m_nProgressFrameCount[iID] = nFrameCount;
|
||
//m_nProgressFrameIndex = 0;
|
||
|
||
#if MULTI_CHANNEL
|
||
if (m_nProgressFrameCount[0] > 0 && m_nProgressFrameCount[1] > 0)
|
||
{
|
||
m_nProgressFrameCount_Sync = m_nProgressFrameCount[0] < m_nProgressFrameCount[1] ? m_nProgressFrameCount[0] : m_nProgressFrameCount[1];
|
||
}
|
||
else if (m_nProgressFrameCount[0] > 0)
|
||
{
|
||
m_nProgressFrameCount_Sync = m_nProgressFrameCount[0];
|
||
}
|
||
else if (m_nProgressFrameCount[1] > 0)
|
||
{
|
||
m_nProgressFrameCount_Sync = m_nProgressFrameCount[1];
|
||
}
|
||
#else
|
||
m_nProgressFrameCount_Sync = nFrameCount;
|
||
#endif
|
||
|
||
m_bUpdateProgress = true;
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnProgress(/*int iID, */int nFrameIndex, int nFrameCount, void* pOwner)
|
||
{
|
||
MainWindow* pMainWindow = reinterpret_cast<MainWindow*>(pOwner);
|
||
|
||
if (nullptr != pMainWindow)
|
||
{
|
||
pMainWindow->SetProgress(/*iID,*/ nFrameIndex, nFrameCount);
|
||
}
|
||
}
|
||
|
||
void MainWindow::ImgShowProcess(unsigned char* pDstShow, unsigned char* pSrc, int nWidth, int nHeight)
|
||
{
|
||
GLogger::GetInstance()->WriteInfo("MainWindow:ImgShowProcess");
|
||
// m_pTGAirthProcess->m_MixMapPara.LeftDiscard = 1;
|
||
// m_pTGAirthProcess->m_MixMapPara.RightDiscard = 1;
|
||
|
||
BBHE_MixTiaoGuangDll((ushort*)pDstShow, pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, m_pTGAirthProcess->m_MixMapPara, m_pTGAirthProcess->m_MixMapOut);
|
||
|
||
//调光(此算法横向滚动灰阶图像有黑宽线)
|
||
//MixTiaoGuangDll((ushort*)pDstShow, pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, m_pTGAirthProcess->m_MixMapPara, m_pTGAirthProcess->m_MixMapOut);
|
||
|
||
GLogger::GetInstance()->WriteInfo("MainWindow:BBHE_MixTiaoGuangDll");
|
||
//Y8纠偏
|
||
//ManualAdjustBC(pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, 55, 90);
|
||
|
||
// GLogger::GetInstance()->WriteInfo("MainWindow:ManualAdjustBC");
|
||
|
||
//Y8映射
|
||
// Y8ImgMapping(pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, m_pTGAirthProcess->m_TGInfo.Y8MapIdx);
|
||
|
||
// GLogger::GetInstance()->WriteInfo("MainWindow:Y8ImgMapping");
|
||
|
||
}
|
||
|
||
void MainWindow::ImgUnsignedProcess(unsigned short* pSrc, unsigned char* pDst, int nWidth, int nHeight)
|
||
{
|
||
switch (m_varGFrameFormat.ePT)
|
||
{
|
||
case ePT_Y16U:
|
||
{
|
||
ImgDeMean((ushort*)pSrc, (ushort*)pDst, nWidth, nHeight);
|
||
//TODO:
|
||
//其他机芯算法
|
||
}
|
||
break;
|
||
case ePT_Y16:
|
||
{
|
||
ImgPreProcess((short*)pSrc, (ushort*)pDst, nWidth, nHeight);
|
||
ImgDeMean((ushort*)pDst, (ushort*)pDst, nWidth, nHeight);
|
||
//TODO:
|
||
//其他机芯算法
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::OnTimer()
|
||
{
|
||
// 更新进度
|
||
if (m_bUpdateProgress)
|
||
{
|
||
m_bUpdateProgress = false;
|
||
|
||
QString str = QString("%1/%2")
|
||
.arg(m_nProgress_FrameIndex)
|
||
.arg(m_nProgressFrameCount_Sync);
|
||
|
||
ui->m_label_Progress->setText(str);
|
||
|
||
double dProgress = double(m_nProgress_FrameIndex) / double(m_nProgressFrameCount_Sync);
|
||
int nProgress = 100 * dProgress;
|
||
|
||
ui->m_horizontalSlider_Progress->setValue(nProgress);
|
||
// QString str = QString("%1/%2")
|
||
// .arg(m_nProgress_FrameIndex)
|
||
// .arg(m_nProgress_FrameCount);
|
||
|
||
// ui->m_label_Progress->setText(str);
|
||
|
||
// double dProgress = double(m_nProgress_FrameIndex)/double(m_nProgress_FrameCount);
|
||
// int nProgress = 100*dProgress;
|
||
|
||
// ui->m_horizontalSlider_Progress->setValue(nProgress);
|
||
}
|
||
|
||
// 切换暂停
|
||
if (m_bTriggerPausedState)
|
||
{
|
||
m_bTriggerPausedState = false;
|
||
|
||
SetPlayOrPauseButton(true);
|
||
}
|
||
}
|
||
|
||
void MainWindow::ThreadEntry(ThreadRunFunPtr pRunFun, void* pOwner)
|
||
{
|
||
MainWindow* pThis = reinterpret_cast<MainWindow*>(pOwner);
|
||
|
||
if (NULL == pThis)
|
||
{
|
||
return;
|
||
}
|
||
|
||
(pThis->*pRunFun)();
|
||
}
|
||
|
||
|
||
void MainWindow::ThreadFun_CaptureDeviceData()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pReadData = new byte[c_nWMemSize];
|
||
|
||
std::chrono::system_clock::time_point tm2_2 = std::chrono::system_clock::now();
|
||
|
||
int nDataSize = 0;
|
||
GLogger::GetInstance()->WriteInfo("Dev start Capture");
|
||
while (m_bThreadRunning_CaptureDeviceData)
|
||
{
|
||
int nRes = 0;
|
||
|
||
for (int i = 0; i < CHANNEL_COUNT; i++)
|
||
{
|
||
if (m_pDevCap->GetFrame(pReadData, nDataSize, m_varGFrameFormatCap.nChannelNo))
|
||
{
|
||
m_varCaptureData[i].PushBack(pReadData, c_nWMemSize, nRes);;
|
||
}
|
||
}
|
||
QThread::msleep(1);
|
||
|
||
|
||
|
||
}
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
|
||
void MainWindow::ThreadFun_ProcessDeviceData_Ch0()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pFrameData = new byte[c_nWMemSize];
|
||
byte* pDst = new byte[c_nWMemSize];
|
||
|
||
|
||
while (m_bThreadRunning_ProcessDeviceData)
|
||
{
|
||
int nRes = 0;
|
||
|
||
int nFrameSize = 0;
|
||
|
||
if (!m_varCaptureData[0].GetFront(pFrameData, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||
|
||
continue;
|
||
}
|
||
|
||
if (m_bIsRecord && m_recordThread[0] != NULL)
|
||
{
|
||
m_recordThread[0]->onRecvData((char*)pFrameData);
|
||
}
|
||
|
||
|
||
if (ePT_Y8 == m_varGFrameFormat.ePT || ePT_RGBA32 == m_varGFrameFormat.ePT\
|
||
|| ePT_RGBA24 == m_varGFrameFormat.ePT || ePT_YUV422 == m_varGFrameFormat.ePT\
|
||
|| ePT_YUV420P == m_varGFrameFormat.ePT || ePT_YV12 == m_varGFrameFormat.ePT)
|
||
{
|
||
m_varY8DataShow_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
|
||
}
|
||
else
|
||
{
|
||
if (m_bTGArithOpen)
|
||
{
|
||
m_pTGAirthProcess->PushData(pFrameData, c_nWMemSize);
|
||
}
|
||
else
|
||
{
|
||
//图像预处理
|
||
ImgUnsignedProcess((ushort*)pFrameData, pDst, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
m_varY16Data[0].PushBack(pDst, c_nWMemSize, nRes);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
m_varImageQualityParamData_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
|
||
|
||
}
|
||
|
||
delete [] pFrameData;
|
||
pFrameData = nullptr;
|
||
delete [] pDst;
|
||
pDst = nullptr;
|
||
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
void MainWindow::ThreadFun_ProcessDeviceData_Ch1()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pFrameData = new byte[c_nWMemSize];
|
||
byte* pDst = new byte[c_nWMemSize];
|
||
|
||
while (m_bThreadRunning_ProcessDeviceData)
|
||
{
|
||
int nRes = 0;
|
||
|
||
int nFrameSize = 0;
|
||
|
||
if (!m_varCaptureData[1].GetFront(pFrameData, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||
|
||
continue;
|
||
}
|
||
|
||
if (m_bIsRecord && m_recordThread[1] != NULL)
|
||
{
|
||
m_recordThread[1]->onRecvData((char*)pFrameData);
|
||
}
|
||
|
||
if (ePT_Y8 == m_varGFrameFormat.ePT || ePT_RGBA32 == m_varGFrameFormat.ePT\
|
||
|| ePT_RGBA24 == m_varGFrameFormat.ePT || ePT_YUV422 == m_varGFrameFormat.ePT\
|
||
|| ePT_YUV420P == m_varGFrameFormat.ePT || ePT_YV12 == m_varGFrameFormat.ePT)
|
||
{
|
||
m_varY8DataShow_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
}
|
||
else
|
||
{
|
||
if (m_bTGArithOpen)
|
||
{
|
||
m_pTGAirthProcess->PushData(pFrameData, c_nWMemSize);
|
||
}
|
||
else
|
||
{
|
||
//图像预处理
|
||
ImgUnsignedProcess((ushort*)pFrameData, pDst, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
m_varY16Data[0].PushBack(pDst, c_nWMemSize, nRes);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
m_varImageQualityParamData_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
}
|
||
|
||
delete [] pFrameData;
|
||
pFrameData = nullptr;
|
||
delete [] pDst;
|
||
pDst = nullptr;
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
void MainWindow::ThreadFun_ImageQualityParam()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pFrameData = new byte[c_nWMemSize];
|
||
|
||
while (m_bThreadRunning_ImageQuality)
|
||
{
|
||
int nFrameSize = 0;
|
||
int nRes = 0;
|
||
|
||
if (m_bIsCaculateImageQuality) //只有调出图像质量评估界面才会计算相关参数
|
||
{
|
||
if (ePT_Y8 == m_varGFrameFormat.ePT)
|
||
{
|
||
if (!m_varImageQualityParamData_IN.GetFront(pFrameData, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
QThread::msleep(1);
|
||
|
||
continue;
|
||
}
|
||
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
|
||
indexofY8 indexOFY8;
|
||
|
||
if (m_varImageAssessRect.width > 0 && m_varImageAssessRect.height > 0)
|
||
{
|
||
|
||
QImage bmpImg = QImage(pFrameData, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, QImage::Format_Indexed8);
|
||
QImage varImageTar = bmpImg.copy(m_varImageAssessRect.xpos, m_varImageAssessRect.ypos, m_varImageAssessRect.width, m_varImageAssessRect.height);
|
||
indexOFY8 = GetIndexofY8(varImageTar.bits(), m_varImageAssessRect.width, m_varImageAssessRect.height, m_uLeftThrow, m_uRightThrow);
|
||
}
|
||
else
|
||
{
|
||
indexOFY8 = GetIndexofY8(pFrameData, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, m_uLeftThrow, m_uRightThrow);
|
||
}
|
||
|
||
m_pLineArrayValues[4] = indexOFY8.avg; //Y8数据 均值
|
||
m_pLineArrayValues[5] = indexOFY8.std_noise; //Y8数据 空域标准差
|
||
m_pLineArrayValues[6] = indexOFY8.grayrange; //Y8数据 动态范围
|
||
m_pLineArrayValues[7] = 88; //Y8数据 MTF
|
||
|
||
emit sigSendQualityParamShow(m_pLineArrayValues);
|
||
|
||
}
|
||
else if (ePT_Y16U == m_varGFrameFormat.ePT || ePT_Y16 == m_varGFrameFormat.ePT)
|
||
{
|
||
if (!m_varImageQualityParamData_IN.GetFront(pFrameData, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
QThread::msleep(1);
|
||
|
||
continue;
|
||
}
|
||
|
||
// memset(m_pLineArrayValues, 0, sizeof(double)*MAX_QUALITY_PARAMS);
|
||
|
||
indexofY16 resultY16;
|
||
|
||
int nTarRectEndPosX; //目标框的右下点坐标
|
||
int nTarRectEndPosY;
|
||
if (m_varImageAssessRect.width > 0 && m_varImageAssessRect.height > 0)
|
||
{
|
||
nTarRectEndPosX = m_varImageAssessRect.xpos + m_varImageAssessRect.width;
|
||
nTarRectEndPosY = m_varImageAssessRect.ypos + m_varImageAssessRect.height;
|
||
}
|
||
else
|
||
{
|
||
nTarRectEndPosX = m_varGFrameFormat.nImageWidth;
|
||
nTarRectEndPosY = m_varGFrameFormat.nImageHeight;
|
||
}
|
||
|
||
|
||
int nBackRectEndPosX; //均匀背景区域的右下点坐标
|
||
int nBackRectEndPosY;
|
||
|
||
if (m_varImageAssessBackRect.width > 0 && m_varImageAssessBackRect.height > 0)
|
||
{
|
||
nBackRectEndPosX = m_varImageAssessBackRect.xpos + m_varImageAssessBackRect.width;
|
||
nBackRectEndPosY = m_varImageAssessBackRect.ypos + m_varImageAssessBackRect.height;
|
||
}
|
||
else
|
||
{
|
||
nBackRectEndPosX = m_varGFrameFormat.nImageWidth;
|
||
nBackRectEndPosY = m_varGFrameFormat.nImageHeight;
|
||
}
|
||
|
||
|
||
resultY16 = GetIndexofY16((unsigned short*)pFrameData, m_varImageAssessRect.xpos, m_varImageAssessRect.ypos, \
|
||
nTarRectEndPosX, nTarRectEndPosY, \
|
||
m_varImageAssessBackRect.xpos, m_varImageAssessBackRect.ypos, \
|
||
nBackRectEndPosX, nBackRectEndPosY, \
|
||
m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
|
||
//计算坏点个数
|
||
int cnt = GetNumofBadpoint((unsigned short*)pFrameData, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
|
||
m_pLineArrayValues[8] = resultY16.std_noise; //Y16数据 空域标准差
|
||
m_pLineArrayValues[9] = resultY16.NUC * 100; //Y16数据 非均匀性
|
||
m_pLineArrayValues[10] = resultY16.avg; //Y16数据 均值
|
||
m_pLineArrayValues[11] = resultY16.SNR; //Y16数据 特定目标信噪比
|
||
m_pLineArrayValues[12] = resultY16.diff; //Y16数据 图像上下区域AD
|
||
m_pLineArrayValues[13] = 0; //Y16数据 数据动态范围 没有此参数的算法计算
|
||
m_pLineArrayValues[14] = cnt;
|
||
|
||
|
||
emit sigSendQualityParamShow(m_pLineArrayValues);
|
||
|
||
}
|
||
else if (ePT_X16 == m_varGFrameFormat.ePT)
|
||
{
|
||
|
||
if (!m_varImageQualityParamData_IN.GetFront(pFrameData, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
QThread::msleep(1);
|
||
|
||
continue;
|
||
}
|
||
|
||
// memset(m_pLineArrayValues,0,sizeof(double)*MAX_QUALITY_PARAMS);
|
||
|
||
indexofX resuleofX16;
|
||
|
||
double dAverage; //均值
|
||
double stv5; //时域标准差
|
||
|
||
if (m_varImageAssessRect.width > 0 && m_varImageAssessRect.height > 0) //目标区域不为0
|
||
{
|
||
|
||
QImage bmpImg = QImage(pFrameData, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, QImage::Format_Indexed8);
|
||
QImage varImageTar = bmpImg.copy(m_varImageAssessRect.xpos, m_varImageAssessRect.ypos, m_varImageAssessRect.width, m_varImageAssessRect.height);
|
||
|
||
//计算每一帧的均值
|
||
dAverage = GetAvg(varImageTar.bits(), m_varImageAssessRect.width, m_varImageAssessRect.height);
|
||
|
||
}
|
||
else //0时传整帧图像
|
||
{
|
||
//计算每一帧的均值
|
||
dAverage = GetAvg(pFrameData, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
|
||
}
|
||
|
||
//时域标准差
|
||
if (m_bThreadRunning_ProcessRawFileData) //处理视存储的频文件线程开启时
|
||
{
|
||
if (m_bX16TimeSpaceDeviation)
|
||
{
|
||
m_bX16TimeSpaceDeviation = false;
|
||
|
||
QString strFileName = m_pRawFileStream[0]->GetFileNameStr();
|
||
|
||
// QByteArray ba = strFileName.toLatin1();
|
||
// QByteArray ba = strFileName.toUtf8();
|
||
// const char * str1 = (const char *)ba.data();
|
||
|
||
std::string strName = strFileName.toStdString();
|
||
QTextCodec* codec = QTextCodec::codecForName("GB2312");
|
||
std::string name = codec->fromUnicode(strName.c_str()).data();
|
||
|
||
// FILE* pFile = fopen(ba.data(), "rb");
|
||
// FILE* pFile = fopen(str1, "rb");
|
||
FILE* pFile = fopen(name.c_str(), "rb");
|
||
|
||
if (pFile)
|
||
{
|
||
if (m_varImageAssessRect.width > 0 && m_varImageAssessRect.height > 0) //目标区域不为0
|
||
{
|
||
resuleofX16 = Test(pFile, m_varImageAssessRect.width, m_varImageAssessRect.height, m_varImageAssessRect.width, m_varImageAssessRect.height);
|
||
}
|
||
else
|
||
{
|
||
resuleofX16 = Test(pFile, 100, 100, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
// resuleofX16 = Test(pFile, 0, 0, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
}
|
||
|
||
|
||
|
||
fclose(pFile);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
stv5 = resuleofX16.stv5;
|
||
|
||
|
||
m_pLineArrayValues[0] = stv5; //X数据时域标准差
|
||
m_pLineArrayValues[1] = dAverage; //X数据均值
|
||
|
||
emit sigSendQualityParamShow(m_pLineArrayValues);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
delete [] pFrameData;
|
||
pFrameData = nullptr;
|
||
|
||
timeEndPeriod(1);
|
||
|
||
}
|
||
|
||
int MainWindow::ScaleImageFormat(BYTE* pSrc, int nSrcWidth, int nSrcHeight, BYTE* pDst, int nDstWidth, int nDstHeight, long lSrcType, long lDstType)
|
||
{
|
||
SwsContext* pImgResampleCtx = NULL;
|
||
|
||
AVPicture pFrameSrc, pFrameDst;
|
||
avpicture_fill(&pFrameSrc, pSrc, (AVPixelFormat)lSrcType, nSrcWidth, nSrcHeight);
|
||
|
||
avpicture_fill(&pFrameDst, pDst, (AVPixelFormat)lDstType, nDstWidth, nDstHeight);
|
||
|
||
pImgResampleCtx = sws_getContext(
|
||
nSrcWidth,
|
||
nSrcHeight,
|
||
(AVPixelFormat)lSrcType,
|
||
nDstWidth,
|
||
nDstHeight,
|
||
(AVPixelFormat)lDstType,
|
||
SWS_BILINEAR,
|
||
NULL,
|
||
NULL,
|
||
NULL
|
||
);
|
||
|
||
sws_scale(pImgResampleCtx, pFrameSrc.data, pFrameSrc.linesize, 0, nSrcHeight, pFrameDst.data, pFrameDst.linesize);
|
||
if (NULL != pImgResampleCtx)
|
||
{
|
||
sws_freeContext(pImgResampleCtx);
|
||
pImgResampleCtx = NULL;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
|
||
void MainWindow::ThreadFun_ShowData()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pSrc = new byte[c_nWMemSize];
|
||
byte* pDst = new byte[c_nWMemSize];
|
||
byte* pDstShow = new byte[c_nWMemSize];
|
||
|
||
//GLogger::GetInstance()->WriteInfo("start Mapping");
|
||
while (m_bThreadRunning_ShowImg)
|
||
{
|
||
int nRes = 0;
|
||
|
||
int nFrameSize = 0;
|
||
|
||
if (ePT_Y8 == m_varGFrameFormat.ePT || ePT_RGBA32 == m_varGFrameFormat.ePT\
|
||
|| ePT_RGBA24 == m_varGFrameFormat.ePT || ePT_YUV422 == m_varGFrameFormat.ePT\
|
||
|| ePT_YUV420P == m_varGFrameFormat.ePT || ePT_YV12 == m_varGFrameFormat.ePT) //Y8数据不经过一系列算法处理
|
||
{
|
||
if (!m_varY8DataShow_IN.GetFront(pSrc, nFrameSize))
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (m_bTGArithOpen)
|
||
{
|
||
if (!m_pTGAirthProcess->GetData(pSrc, nFrameSize)) //Y16数据经过一系列算法处理后得到的Y8
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//不调用各种调光算法--默认混合调光直接送显
|
||
if (!m_varY16Data[0].GetFront(pDstShow, nFrameSize)) //Y16数据经过一系列算法处理后得到的Y8
|
||
{
|
||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||
|
||
continue;
|
||
}
|
||
|
||
// //调光处理
|
||
ImgShowProcess(pDstShow, pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
QImage bmpImg;
|
||
|
||
if (ePT_RGBA32 == m_varGFrameFormat.ePT || ePT_RGBA24 == m_varGFrameFormat.ePT \
|
||
|| ePT_YUV422 == m_varGFrameFormat.ePT || ePT_YUV420P == m_varGFrameFormat.ePT\
|
||
|| ePT_YV12 == m_varGFrameFormat.ePT)
|
||
{
|
||
ScaleImageFormat(pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, pDst, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, AV_PIX_FMT_UYVY422, AV_PIX_FMT_RGBA);
|
||
bmpImg = QImage(pDst, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, QImage::Format_RGBA8888);
|
||
}
|
||
else
|
||
{
|
||
// memcpy(pDst,pSrc+640*2,c_nWMemSize-640*2);
|
||
bmpImg = QImage(pSrc, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight, QImage::Format_Indexed8);
|
||
|
||
bmpImg.setColorTable(m_varColorTable[m_nColorIndex]);
|
||
|
||
bmpImg = bmpImg.convertToFormat(QImage::Format_RGBA8888);
|
||
}
|
||
|
||
QImage varPaintImage = bmpImg;
|
||
|
||
if (m_pOpenGLView != NULL)
|
||
{
|
||
|
||
if (m_bRectDraw)
|
||
{
|
||
//用户正在拖曳鼠标绘制矩形框
|
||
int x = double(m_varPointStart.x() - m_pOpenGLView->PosX()) / m_pOpenGLView->ViewRatio();
|
||
int y = double(m_varPointStart.y() - m_pOpenGLView->PosY()) / m_pOpenGLView->ViewRatio();
|
||
int w = double(m_varPointEnd.x() - m_varPointStart.x()) / m_pOpenGLView->ViewRatio();
|
||
int h = double(m_varPointEnd.y() - m_varPointStart.y()) / m_pOpenGLView->ViewRatio();
|
||
|
||
LimitValue(x, y, w, h);
|
||
|
||
if (w > 0 && h > 0)
|
||
{
|
||
QPainter painter;
|
||
painter.begin(&varPaintImage);
|
||
painter.setRenderHint(QPainter::Antialiasing);
|
||
QPen pen(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
//图像质量评估框
|
||
|
||
QPen penNew(Qt::yellow, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(penNew);
|
||
painter.drawRect(x, y, w, h);
|
||
painter.end();
|
||
}
|
||
}
|
||
if (m_bBackRectDraw)
|
||
{
|
||
//用户正在拖曳鼠标绘制矩形框
|
||
int x = double(m_varBackPointStart.x() - m_pOpenGLView->PosX()) / m_pOpenGLView->ViewRatio();
|
||
int y = double(m_varBackPointStart.y() - m_pOpenGLView->PosY()) / m_pOpenGLView->ViewRatio();
|
||
int w = double(m_varBackPointEnd.x() - m_varBackPointStart.x()) / m_pOpenGLView->ViewRatio();
|
||
int h = double(m_varBackPointEnd.y() - m_varBackPointStart.y()) / m_pOpenGLView->ViewRatio();
|
||
|
||
LimitValue(x, y, w, h);
|
||
|
||
if (w > 0 && h > 0)
|
||
{
|
||
QPainter painter;
|
||
painter.begin(&varPaintImage);
|
||
painter.setRenderHint(QPainter::Antialiasing);
|
||
QPen pen(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
//图像质量评估框
|
||
|
||
QPen penNew(Qt::yellow, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(penNew);
|
||
painter.drawRect(x, y, w, h);
|
||
painter.end();
|
||
}
|
||
}
|
||
if (m_bShowRect)
|
||
{
|
||
//显示最终的矩形框
|
||
QPainter painter;
|
||
painter.begin(&varPaintImage);
|
||
painter.setRenderHint(QPainter::Antialiasing);
|
||
QPen pen(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
|
||
//图像质量评估框
|
||
if ((m_varImageAssessRect.width > 0) && (m_varImageAssessRect.height > 0))
|
||
{
|
||
QPen pen(Qt::red, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
painter.drawRect(m_varImageAssessRect.xpos, m_varImageAssessRect.ypos, m_varImageAssessRect.width, m_varImageAssessRect.height);
|
||
|
||
}
|
||
painter.end();
|
||
}
|
||
if (m_bShowBackRect)
|
||
{
|
||
// qDebug() << "m_bShowBackRect:"<<m_bShowBackRect;
|
||
//显示背景框
|
||
QPainter painter;
|
||
painter.begin(&varPaintImage);
|
||
painter.setRenderHint(QPainter::Antialiasing);
|
||
QPen pen(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
//图像质量评估框
|
||
if ((m_varImageAssessBackRect.width > 0) && (m_varImageAssessBackRect.height > 0))
|
||
{
|
||
QPen pen(Qt::blue, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||
painter.setPen(pen);
|
||
painter.drawRect(m_varImageAssessBackRect.xpos, m_varImageAssessBackRect.ypos, m_varImageAssessBackRect.width, m_varImageAssessBackRect.height);
|
||
}
|
||
painter.end();
|
||
}
|
||
|
||
|
||
m_pOpenGLView->UpdateImageData(varPaintImage.bits()/*, IMG_WIDTH*IMG_HEIGHT*3*/);
|
||
}
|
||
|
||
|
||
int nX = m_varImageAssessRect.xpos;
|
||
int nY = m_varImageAssessRect.ypos;
|
||
int nW = m_varImageAssessRect.width;
|
||
int nH = m_varImageAssessRect.height;
|
||
|
||
//对坐标及宽高进行范围约束
|
||
|
||
LimitValue(nX, nY, nW, nH);
|
||
|
||
if (nW > 0 && nH >= 0)
|
||
{
|
||
//从原始图像中截取区域图像
|
||
QImage varImageRect = bmpImg.copy(nX, nY, nW, nH);
|
||
|
||
//将图像送到质量分析界面进行显示
|
||
emit sigShowRectImage(varImageRect, nW, nH);
|
||
|
||
emit sigSendQualityImageShow(varImageRect, nW, nH);
|
||
}
|
||
|
||
if (m_bThreadRunning_CaptureDeviceData)
|
||
{
|
||
//m_dFPS[0] = m_pDevCap->GetFPS(0);
|
||
m_dFPS[0] = m_pDevCap->GetFPS(m_varGFrameFormatCap.nChannelNo);
|
||
QString str = QString::number(m_dFPS[0]);
|
||
str = "FPS:" + str;
|
||
emit sigSendFPS(str);
|
||
}
|
||
|
||
}
|
||
|
||
delete [] pSrc;
|
||
pSrc = nullptr;
|
||
|
||
delete [] pDst;
|
||
pDst = nullptr;
|
||
|
||
delete [] pDstShow;
|
||
pDstShow = nullptr;
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
void MainWindow::ThreadFun_FetchRawFileData()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pReadData0 = new byte[c_nWMemSize];
|
||
byte* pReadData1 = new byte[c_nWMemSize];
|
||
|
||
while (m_bThreadRunning_FetchRawFileData)
|
||
{
|
||
int nRes = 0;
|
||
|
||
m_mutexRawFile.lock();
|
||
if (nullptr != m_pRawFileStream[0])
|
||
{
|
||
if (m_varRawFileData[0].Size() < 5)
|
||
{
|
||
GCycleQueue& varQueueFrameData0 = m_pRawFileStream[0]->GetFrameQueue();
|
||
|
||
int nFrameSize = 0;
|
||
if (varQueueFrameData0.GetFront(pReadData0, nFrameSize))
|
||
{
|
||
m_varRawFileData[0].PushBack(pReadData0, c_nWMemSize, nRes);
|
||
}
|
||
}
|
||
}
|
||
#if MULTI_CHANNEL
|
||
if (nullptr != m_pRawFileStream[1])
|
||
{
|
||
if (m_varRawFileData[1].Size() < 5)
|
||
{
|
||
GCycleQueue& varQueueFrameData1 = m_pRawFileStream[1]->GetFrameQueue();
|
||
|
||
int nFrameSize = 0;
|
||
if (varQueueFrameData1.GetFront(pReadData1, nFrameSize))
|
||
{
|
||
m_varRawFileData[1].PushBack(pReadData1, c_nWMemSize, nRes);
|
||
}
|
||
}
|
||
}
|
||
#endif
|
||
|
||
m_mutexRawFile.unlock();
|
||
QThread::msleep(1);
|
||
|
||
}
|
||
|
||
|
||
delete [] pReadData0;
|
||
pReadData0 = nullptr;
|
||
|
||
delete [] pReadData1;
|
||
pReadData1 = nullptr;
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
void MainWindow::ThreadFun_ProcessRawFileData()
|
||
{
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pFrameData = new byte[c_nWMemSize];
|
||
byte* pDst = new byte[c_nWMemSize];
|
||
|
||
|
||
while (m_bThreadRunning_ProcessRawFileData)
|
||
{
|
||
int nFrameSize = 0;
|
||
int nRes = 0;
|
||
|
||
if (!m_varRawFileData[0].GetFront(pFrameData, nFrameSize))
|
||
{
|
||
QThread::msleep(1);
|
||
|
||
continue;
|
||
}
|
||
|
||
if (ePT_Y8 == m_varGFrameFormat.ePT || ePT_RGBA32 == m_varGFrameFormat.ePT\
|
||
|| ePT_RGBA24 == m_varGFrameFormat.ePT || ePT_YUV422 == m_varGFrameFormat.ePT\
|
||
|| ePT_YUV420P == m_varGFrameFormat.ePT || ePT_YV12 == m_varGFrameFormat.ePT)
|
||
{
|
||
m_varY8DataShow_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
// m_varY8DataShow_IN.PushBack(pFrameData,m_varGFrameFormat.nImageWidth*m_varGFrameFormat.nImageHeight,nRes);
|
||
|
||
}
|
||
else
|
||
{
|
||
// Y16入库
|
||
if (m_bTGArithOpen)
|
||
{
|
||
m_pTGAirthProcess->PushData(pFrameData, c_nWMemSize);
|
||
}
|
||
else
|
||
{
|
||
//图像预处理
|
||
ImgUnsignedProcess((ushort*)pFrameData, pDst, m_varGFrameFormat.nImageWidth, m_varGFrameFormat.nImageHeight);
|
||
m_varY16Data[0].PushBack(pDst, c_nWMemSize, nRes);
|
||
}
|
||
|
||
}
|
||
|
||
m_varImageQualityParamData_IN.PushBack(pFrameData, c_nWMemSize, nRes);
|
||
|
||
// m_varImageQualityParamData_IN.PushBack(pFrameData,m_varGFrameFormat.nImageWidth*m_varGFrameFormat.nImageHeight,nRes);
|
||
|
||
|
||
|
||
|
||
#if MULTI_CHANNEL
|
||
if (!m_varRawFileData[1].GetFront(pFrameData, nFrameSize))
|
||
{
|
||
QThread::msleep(1);
|
||
|
||
continue;
|
||
}
|
||
|
||
// Y16入库
|
||
m_varY16Data[1].PushBack(pFrameData, IMG_WIDTH * IMG_HEIGHT * 2, nRes);
|
||
#endif
|
||
}
|
||
|
||
delete [] pFrameData;
|
||
pFrameData = nullptr;
|
||
delete [] pDst;
|
||
pDst = nullptr;
|
||
|
||
|
||
timeEndPeriod(1);
|
||
}
|
||
|
||
|
||
|
||
void MainWindow::ThreadFun_SendCmd()
|
||
{
|
||
/*
|
||
timeBeginPeriod(1);
|
||
|
||
byte* pFrameData = new byte[5376*1024+4096];
|
||
|
||
while(m_bThreadRunning_SendCmd)
|
||
{
|
||
int nFrameSize = 0;
|
||
|
||
if(!m_bInjectData && m_bSendCmd)
|
||
{
|
||
m_bSendCmd = false;
|
||
|
||
int nSendDataLen = 0;
|
||
|
||
if(eSDT_AirthCtrlParams == m_eSDT)
|
||
{
|
||
nSendDataLen = 40;
|
||
}
|
||
else if(eSDT_InertialNavigationInfo_Position == m_eSDT)
|
||
{
|
||
nSendDataLen = 246+2+8;
|
||
}
|
||
else if(eSDT_InertialNavigationInfo_BJT == m_eSDT)
|
||
{
|
||
nSendDataLen = 52+8;
|
||
}
|
||
else if(eSDT_InertialNavigationInfo_SSD == m_eSDT)
|
||
{
|
||
nSendDataLen = 58+8;
|
||
}
|
||
|
||
SendUpgradeData((char*)m_szCmd, nSendDataLen);
|
||
}
|
||
}
|
||
|
||
delete [] pFrameData;
|
||
pFrameData = nullptr;
|
||
|
||
timeEndPeriod(1);
|
||
*/
|
||
}
|
||
|
||
bool MainWindow::StartThread_DealDeviceData()
|
||
{
|
||
StopThread_DealDeviceData();
|
||
|
||
if (m_pDevCap->StartCapture(m_varGFrameFormatCap))
|
||
{
|
||
|
||
GLogger::GetInstance()->WriteInfo("Card Open");
|
||
|
||
//
|
||
m_pTGAirthProcess->SetImgFormat(m_varGFrameFormat);
|
||
if (m_bTGArithOpen)
|
||
{
|
||
m_pTGAirthProcess->Start();
|
||
}
|
||
else
|
||
{
|
||
m_pTGAirthProcess->Stop();
|
||
}
|
||
|
||
m_bThreadRunning_ShowImg = true;
|
||
m_ptrThread_MappingData_Ch0 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ShowData, (void*)this));
|
||
|
||
m_bThreadRunning_ProcessDeviceData = true;
|
||
m_ptrThread_ProcessDeviceData_Ch0 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ProcessDeviceData_Ch0, (void*)this));
|
||
#if MULTI_CHANNEL
|
||
m_ptrThread_MappingData_Ch1 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_MappingData_Ch1, (void*)this));
|
||
m_ptrThread_ProcessDeviceData_Ch1 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ProcessDeviceData_Ch1, (void*)this));
|
||
|
||
#endif
|
||
//
|
||
m_bThreadRunning_CaptureDeviceData = true;
|
||
m_ptrThread_CaptureDeviceData = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_CaptureDeviceData, (void*)this));
|
||
|
||
// m_bThreadRunning_ImageQuality = true;
|
||
// m_ptrThread_ImageQuality = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ImageQualityParam, (void*)this));
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void MainWindow::StopThread_DealDeviceData()
|
||
{
|
||
|
||
m_bCaptureData = false;
|
||
// m_pDevCap->StopCapture();
|
||
m_pTGAirthProcess->Stop();
|
||
|
||
//
|
||
if (m_bThreadRunning_ShowImg)
|
||
{
|
||
m_bThreadRunning_ShowImg = false;
|
||
|
||
if (nullptr != m_ptrThread_ShowImg)
|
||
{
|
||
m_ptrThread_ShowImg->join();
|
||
|
||
delete m_ptrThread_ShowImg;
|
||
m_ptrThread_ShowImg = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_ptrThread_MappingData_Ch0)
|
||
{
|
||
m_ptrThread_MappingData_Ch0->join();
|
||
|
||
delete m_ptrThread_MappingData_Ch0;
|
||
m_ptrThread_MappingData_Ch0 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_ptrThread_MappingData_Ch1)
|
||
{
|
||
m_ptrThread_MappingData_Ch1->join();
|
||
|
||
delete m_ptrThread_MappingData_Ch1;
|
||
m_ptrThread_MappingData_Ch1 = nullptr;
|
||
}
|
||
}
|
||
|
||
//
|
||
if (m_bThreadRunning_ProcessDeviceData)
|
||
{
|
||
m_bThreadRunning_ProcessDeviceData = false;
|
||
|
||
if (nullptr != m_ptrThread_ProcessDeviceData_Ch0)
|
||
{
|
||
m_ptrThread_ProcessDeviceData_Ch0->join();
|
||
|
||
delete m_ptrThread_ProcessDeviceData_Ch0;
|
||
m_ptrThread_ProcessDeviceData_Ch0 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_ptrThread_ProcessDeviceData_Ch1)
|
||
{
|
||
m_ptrThread_ProcessDeviceData_Ch1->join();
|
||
|
||
delete m_ptrThread_ProcessDeviceData_Ch1;
|
||
m_ptrThread_ProcessDeviceData_Ch1 = nullptr;
|
||
}
|
||
}
|
||
|
||
//
|
||
if (m_bThreadRunning_CaptureDeviceData)
|
||
{
|
||
m_bThreadRunning_CaptureDeviceData = false;
|
||
|
||
if (nullptr != m_ptrThread_CaptureDeviceData)
|
||
{
|
||
m_ptrThread_CaptureDeviceData->join();
|
||
|
||
delete m_ptrThread_CaptureDeviceData;
|
||
m_ptrThread_CaptureDeviceData = nullptr;
|
||
}
|
||
}
|
||
if (m_bThreadRunning_ImageQuality)
|
||
{
|
||
m_bThreadRunning_ImageQuality = false;
|
||
if (nullptr != m_ptrThread_ImageQuality)
|
||
{
|
||
m_ptrThread_ImageQuality->join();
|
||
delete m_ptrThread_ImageQuality;
|
||
m_ptrThread_ImageQuality = nullptr;
|
||
}
|
||
}
|
||
|
||
m_pDevCap->StopCapture();
|
||
|
||
}
|
||
|
||
bool MainWindow::StartThread_DealRawFileData()
|
||
{
|
||
StopThread_DealRawFileData();
|
||
|
||
//调光算法开
|
||
m_pTGAirthProcess->SetImgFormat(m_varGFrameFormat);
|
||
|
||
if (m_bTGArithOpen)
|
||
{
|
||
m_pTGAirthProcess->Start();
|
||
}
|
||
else
|
||
{
|
||
m_pTGAirthProcess->Stop();
|
||
}
|
||
|
||
m_bThreadRunning_ShowImg = true;
|
||
// m_ptrThread_MappingData_Ch0 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_MappingData_Ch0, (void*)this));
|
||
m_ptrThread_ShowImg = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ShowData, (void*)this));
|
||
|
||
#if MULTI_CHANNEL
|
||
m_ptrThread_MappingData_Ch1 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_MappingData_Ch1, (void*)this));
|
||
m_ptrThread_ProcessDeviceData_Ch1 = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ProcessDeviceData_Ch1, (void*)this));
|
||
|
||
#endif
|
||
//
|
||
m_bThreadRunning_FetchRawFileData = true;
|
||
m_ptrThread_FetchRawFileData = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_FetchRawFileData, (void*)this));
|
||
|
||
//
|
||
m_bThreadRunning_ProcessRawFileData = true;
|
||
m_ptrThread_ProcessRawFileData = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ProcessRawFileData, (void*)this));
|
||
|
||
// m_bThreadRunning_ImageQuality = true;
|
||
// m_ptrThread_ImageQuality = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_ImageQualityParam, (void*)this));
|
||
|
||
m_bX16TimeSpaceDeviation = true;
|
||
|
||
return true;
|
||
}
|
||
|
||
void MainWindow::StopThread_DealRawFileData()
|
||
{
|
||
//
|
||
m_pTGAirthProcess->Stop();
|
||
|
||
if (m_bThreadRunning_ShowImg)
|
||
{
|
||
m_bThreadRunning_ShowImg = false;
|
||
|
||
if (nullptr != m_ptrThread_MappingData_Ch0)
|
||
{
|
||
m_ptrThread_MappingData_Ch0->join();
|
||
|
||
delete m_ptrThread_MappingData_Ch0;
|
||
m_ptrThread_MappingData_Ch0 = nullptr;
|
||
}
|
||
|
||
if (nullptr != m_ptrThread_MappingData_Ch1)
|
||
{
|
||
m_ptrThread_MappingData_Ch1->join();
|
||
|
||
delete m_ptrThread_MappingData_Ch1;
|
||
m_ptrThread_MappingData_Ch1 = nullptr;
|
||
}
|
||
|
||
|
||
if (nullptr != m_ptrThread_ShowImg)
|
||
{
|
||
m_ptrThread_ShowImg->join();
|
||
|
||
delete m_ptrThread_ShowImg;
|
||
m_ptrThread_ShowImg = nullptr;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
//
|
||
if (m_bThreadRunning_ProcessRawFileData)
|
||
{
|
||
m_bThreadRunning_ProcessRawFileData = false;
|
||
|
||
if (nullptr != m_ptrThread_ProcessRawFileData)
|
||
{
|
||
m_ptrThread_ProcessRawFileData->join();
|
||
|
||
delete m_ptrThread_ProcessRawFileData;
|
||
m_ptrThread_ProcessRawFileData = nullptr;
|
||
}
|
||
}
|
||
|
||
//
|
||
if (m_bThreadRunning_FetchRawFileData)
|
||
{
|
||
m_bThreadRunning_FetchRawFileData = false;
|
||
|
||
if (nullptr != m_ptrThread_FetchRawFileData)
|
||
{
|
||
m_ptrThread_FetchRawFileData->join();
|
||
|
||
delete m_ptrThread_FetchRawFileData;
|
||
m_ptrThread_FetchRawFileData = nullptr;
|
||
}
|
||
}
|
||
|
||
if (m_bThreadRunning_ImageQuality)
|
||
{
|
||
m_bThreadRunning_ImageQuality = false;
|
||
if (nullptr != m_ptrThread_ImageQuality)
|
||
{
|
||
m_ptrThread_ImageQuality->join();
|
||
delete m_ptrThread_ImageQuality;
|
||
m_ptrThread_ImageQuality = nullptr;
|
||
}
|
||
}
|
||
}
|
||
|
||
void MainWindow::StopThread_SendCmd()
|
||
{
|
||
//
|
||
if (m_bThreadRunning_SendCmd)
|
||
{
|
||
m_bThreadRunning_SendCmd = false;
|
||
|
||
if (nullptr != m_ptrThread_SendCmd)
|
||
{
|
||
m_ptrThread_SendCmd->join();
|
||
|
||
delete m_ptrThread_SendCmd;
|
||
m_ptrThread_SendCmd = nullptr;
|
||
}
|
||
}
|
||
}
|
||
|
||
bool MainWindow::StartThread_SendCmd()
|
||
{
|
||
StopThread_SendCmd();
|
||
|
||
m_bThreadRunning_SendCmd = true;
|
||
m_ptrThread_SendCmd = new std::thread(std::bind(&MainWindow::ThreadEntry, &MainWindow::ThreadFun_SendCmd, (void*)this));
|
||
|
||
return true;
|
||
}
|
||
|
||
|
||
|
||
/**此播放控制方式适用于多路,用以进行同步**/
|
||
void MainWindow::OnTimer_Play()
|
||
{
|
||
/*
|
||
if (m_bIsRecord)
|
||
{
|
||
ulong ulCap[2];
|
||
ulong ulRecord[2];
|
||
m_pDevCap->GetFrameCount(&ulCap[0]);
|
||
for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
{
|
||
ulRecord[i] = m_recordThread[i]->getFrameCont();
|
||
}
|
||
QString str = QString("录像计数 第一路:%1/%2 第二路:%3/%4").arg(ulRecord[0]).arg(ulCap[0]).arg(ulRecord[1]).arg(ulCap[1]);
|
||
ui->label_State->setText(str);
|
||
}
|
||
|
||
|
||
|
||
if (!m_bOpenFile || m_nProgressFrameCount_Sync <= 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
switch (m_iPlayState)
|
||
{
|
||
case 0:
|
||
break;
|
||
case 1://play
|
||
for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
{
|
||
m_pRawFileStream[i]->CurrentFrame(m_nProgressFrameIndex);
|
||
}
|
||
m_nProgressFrameIndex++;
|
||
if (m_nProgressFrameIndex >= m_nProgressFrameCount_Sync)
|
||
{
|
||
SetPlayOrPauseButton(true);
|
||
m_iPlayState = 2;
|
||
m_nProgressFrameIndex = 0;
|
||
if (m_bRecyclePlay)
|
||
{
|
||
m_iPlayState = 1;
|
||
SetPlayOrPauseButton(false);
|
||
}
|
||
}
|
||
m_bUpdateProgress = true;
|
||
break;
|
||
case 2://pause
|
||
SetPlayOrPauseButton(true);
|
||
break;
|
||
case 3://next
|
||
m_nProgressFrameIndex++;
|
||
if (m_nProgressFrameIndex >= m_nProgressFrameCount_Sync)
|
||
{
|
||
m_nProgressFrameIndex = 0;
|
||
}
|
||
for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
{
|
||
m_pRawFileStream[i]->CurrentFrame(m_nProgressFrameIndex);
|
||
}
|
||
m_iPlayState = 2;
|
||
SetPlayOrPauseButton(true);
|
||
m_bUpdateProgress = true;
|
||
break;
|
||
case 4://pro
|
||
m_nProgressFrameIndex--;
|
||
if (m_nProgressFrameIndex < 0)
|
||
{
|
||
m_nProgressFrameIndex = m_nProgressFrameCount_Sync - 1;
|
||
}
|
||
for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
{
|
||
m_pRawFileStream[i]->CurrentFrame(m_nProgressFrameIndex);
|
||
}
|
||
m_iPlayState = 2;
|
||
SetPlayOrPauseButton(true);
|
||
m_bUpdateProgress = true;
|
||
break;
|
||
case 5: //close
|
||
for(int i = 0;i<CHANNEL_COUNT;i++)
|
||
{
|
||
if(nullptr != m_pRawFileStream[i])
|
||
{
|
||
m_pRawFileStream[i]->Stop();
|
||
|
||
delete m_pRawFileStream[i];
|
||
m_pRawFileStream[i] = nullptr;
|
||
}
|
||
}
|
||
m_iPlayState = 0;
|
||
m_bOpenFile = false;
|
||
break;
|
||
}
|
||
*/
|
||
}
|
||
|
||
void MainWindow::InitCustomplot()
|
||
{
|
||
ui->m_pCustomPlot->setInteractions(/*QCP::iRangeDrag | QCP::iRangeZoom |*/ QCP::iSelectAxes |
|
||
QCP::iSelectLegend | QCP::iSelectPlottables);
|
||
|
||
ui->m_pCustomPlot->axisRect()->setupFullAxesBox();
|
||
|
||
QLinearGradient plotGradient;
|
||
|
||
plotGradient.setStart(0, 0);
|
||
|
||
plotGradient.setFinalStop(0, 350);
|
||
|
||
plotGradient.setColorAt(0, QColor(0, 12, 40));
|
||
|
||
plotGradient.setColorAt(1, QColor(0, 12, 40));
|
||
|
||
ui->m_pCustomPlot->setBackground(plotGradient);
|
||
|
||
//设置坐标背景色
|
||
|
||
//设置坐标颜色/坐标名称颜色
|
||
|
||
// 设置x/y轴文本色、轴线色、字体等
|
||
|
||
ui->m_pCustomPlot->xAxis->setTickLabelColor(Qt::white);
|
||
ui->m_pCustomPlot->xAxis->setLabelColor(QColor(0, 160, 230));
|
||
ui->m_pCustomPlot->xAxis->setBasePen(QPen(Qt::white));//(QColor(32, 178, 170)));
|
||
ui->m_pCustomPlot->xAxis->setTickPen(QPen(Qt::white));//(QColor(128, 0, 255)));
|
||
ui->m_pCustomPlot->xAxis->setSubTickPen(QPen((Qt::white)));//(QColor(255, 165, 0));
|
||
QFont xFont = ui->m_pCustomPlot->xAxis->labelFont();
|
||
xFont.setPixelSize(20);
|
||
ui->m_pCustomPlot->xAxis->setLabelFont(xFont);
|
||
//ui->m_pCustomPlot->xAxis->setLabel("X Axis");
|
||
|
||
ui->m_pCustomPlot->yAxis->setTickLabelColor(Qt::white);
|
||
ui->m_pCustomPlot->yAxis->setLabelColor(QColor(0, 160, 230));
|
||
ui->m_pCustomPlot->yAxis->setBasePen(QPen((Qt::white)));//QColor(32, 178, 170)));
|
||
ui->m_pCustomPlot->yAxis->setTickPen(QPen((Qt::white)));//QColor(128, 0, 255)));
|
||
ui->m_pCustomPlot->yAxis->setSubTickPen(QPen((Qt::white)));//QColor(255, 165, 0));
|
||
QFont yFont = ui->m_pCustomPlot->yAxis->labelFont();
|
||
yFont.setPixelSize(20);
|
||
ui->m_pCustomPlot->yAxis->setLabelFont(yFont);
|
||
// ui->m_pCustomPlot->yAxis->setLabel("Y Axis");
|
||
|
||
//
|
||
ui->m_pCustomPlot->xAxis->setRange(0, 50);
|
||
ui->m_pCustomPlot->xAxis->setSubTicks(false);
|
||
// ui->m_pCustomPlot->xAxis->ticker()->setTickCount(12);
|
||
ui->m_pCustomPlot->xAxis->grid()->setVisible(false);
|
||
|
||
ui->m_pCustomPlot->yAxis->setRange(-100, 100);
|
||
ui->m_pCustomPlot->yAxis->setSubTicks(false);
|
||
//ui->m_pCustomPlot->yAxis->ticker()->setTickCount(5);
|
||
|
||
}
|
||
|
||
void MainWindow::InitAllCurves()
|
||
{
|
||
ui->m_pCustomPlot->xAxis->setRange(0, 50);
|
||
ui->m_pCustomPlot->yAxis->setRange(-100, 100);
|
||
|
||
for (int i = 0; i < MAX_QUALITY_PARAMS; i++)
|
||
{
|
||
m_pPlotCommon[i]->InitCustomplot();
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnDrawLineTimer()
|
||
{
|
||
float fMax = 0;
|
||
ui->m_pCustomPlot->clearGraphs();
|
||
|
||
if (m_bIsDrawLines[0])
|
||
{
|
||
if (fabs(m_pLineArrayValues[0]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[0]);
|
||
m_pPlotCommon[0]->DrawCurve(ui->m_pCustomPlot, QColor(85, 170, 255), m_pLineArrayValues[0]);
|
||
}
|
||
if (m_bIsDrawLines[1])
|
||
{
|
||
if (fabs(m_pLineArrayValues[1]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[1]);
|
||
m_pPlotCommon[1]->DrawCurve(ui->m_pCustomPlot, QColor(255, 0, 0), m_pLineArrayValues[1]);
|
||
}
|
||
if (m_bIsDrawLines[2])
|
||
{
|
||
if (fabs(m_pLineArrayValues[2]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[2]);
|
||
m_pPlotCommon[2]->DrawCurve(ui->m_pCustomPlot, QColor(255, 170, 0), m_pLineArrayValues[2]);
|
||
}
|
||
if (m_bIsDrawLines[3])
|
||
{
|
||
if (fabs(m_pLineArrayValues[3]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[3]);
|
||
m_pPlotCommon[3]->DrawCurve(ui->m_pCustomPlot, QColor(170, 0, 255), m_pLineArrayValues[3]);
|
||
}
|
||
if (m_bIsDrawLines[4])
|
||
{
|
||
if (fabs(m_pLineArrayValues[4]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[4]);
|
||
m_pPlotCommon[4]->DrawCurve(ui->m_pCustomPlot, QColor(255, 0, 127), m_pLineArrayValues[4]);
|
||
}
|
||
if (m_bIsDrawLines[5])
|
||
{
|
||
if (fabs(m_pLineArrayValues[5]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[5]);
|
||
m_pPlotCommon[5]->DrawCurve(ui->m_pCustomPlot, QColor(170, 0, 0), m_pLineArrayValues[5]);
|
||
}
|
||
if (m_bIsDrawLines[6])
|
||
{
|
||
if (fabs(m_pLineArrayValues[6]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[6]);
|
||
m_pPlotCommon[6]->DrawCurve(ui->m_pCustomPlot, QColor(0, 255, 0), m_pLineArrayValues[6]);
|
||
}
|
||
if (m_bIsDrawLines[7])
|
||
{
|
||
if (fabs(m_pLineArrayValues[7]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[7]);
|
||
m_pPlotCommon[7]->DrawCurve(ui->m_pCustomPlot, QColor(170, 85, 127), m_pLineArrayValues[7]);
|
||
}
|
||
if (m_bIsDrawLines[8])
|
||
{
|
||
if (fabs(m_pLineArrayValues[8]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[8]);
|
||
m_pPlotCommon[8]->DrawCurve(ui->m_pCustomPlot, QColor(0, 255, 255), m_pLineArrayValues[8]);
|
||
}
|
||
if (m_bIsDrawLines[9])
|
||
{
|
||
if (fabs(m_pLineArrayValues[9]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[9]);
|
||
m_pPlotCommon[9]->DrawCurve(ui->m_pCustomPlot, QColor(170, 170, 0), m_pLineArrayValues[9]);
|
||
}
|
||
if (m_bIsDrawLines[10])
|
||
{
|
||
if (fabs(m_pLineArrayValues[10]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[10]);
|
||
m_pPlotCommon[10]->DrawCurve(ui->m_pCustomPlot, QColor(0, 160, 230), m_pLineArrayValues[10]);
|
||
}
|
||
if (m_bIsDrawLines[11])
|
||
{
|
||
if (fabs(m_pLineArrayValues[11]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[11]);
|
||
m_pPlotCommon[11]->DrawCurve(ui->m_pCustomPlot, QColor(255, 7, 177), m_pLineArrayValues[11]);
|
||
}
|
||
if (m_bIsDrawLines[12])
|
||
{
|
||
if (fabs(m_pLineArrayValues[12]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[12]);
|
||
m_pPlotCommon[12]->DrawCurve(ui->m_pCustomPlot, QColor(0, 110, 50), m_pLineArrayValues[12]);
|
||
// qDebug() << "m_pLineArrayValues[12]:"<<m_pLineArrayValues[12];
|
||
}
|
||
if (m_bIsDrawLines[13])
|
||
{
|
||
if (fabs(m_pLineArrayValues[13]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[13]);
|
||
m_pPlotCommon[13]->DrawCurve(ui->m_pCustomPlot, QColor(131, 160, 230), m_pLineArrayValues[13]);
|
||
}
|
||
if (m_bIsDrawLines[14])
|
||
{
|
||
if (fabs(m_pLineArrayValues[14]) > fMax)
|
||
fMax = fabs(m_pLineArrayValues[14]);
|
||
m_pPlotCommon[14]->DrawCurve(ui->m_pCustomPlot, QColor(255, 0, 0), m_pLineArrayValues[14]);
|
||
}
|
||
|
||
if (fMax >= m_fOldMax)
|
||
{
|
||
m_fOldMax = fMax;
|
||
// ui->customPlot->yAxis->setRange(-fMax-3,fMax+3);
|
||
ui->m_pCustomPlot->yAxis->setRange(-m_fOldMax - 3, m_fOldMax + 3);
|
||
ui->m_pCustomPlot->replot();//重绘图形
|
||
|
||
}
|
||
else
|
||
{
|
||
static int cnt = 0;
|
||
if (++cnt >= 20000)
|
||
{
|
||
m_fOldMax = 0;
|
||
cnt = 0;
|
||
}
|
||
|
||
ui->m_pCustomPlot->yAxis->setRange(-m_fOldMax - 3, m_fOldMax + 3);
|
||
ui->m_pCustomPlot->replot();//重绘图形
|
||
}
|
||
}
|
||
|
||
void MainWindow::OnRecvQualityParamShow(double* dataArray)
|
||
{
|
||
|
||
ui->m_Label_X_TimeDomain_Deviation->setText(QString::number(m_pLineArrayValues[0], 10, 2));
|
||
ui->m_Label_X_MeanValue->setText(QString::number(m_pLineArrayValues[1], 10, 2));
|
||
|
||
ui->m_Label_X_Mix_ResponseRatio->setText(QString::number(m_pLineArrayValues[2], 10, 2));
|
||
ui->m_Label_X_Mix_NETD->setText(QString::number(m_pLineArrayValues[3], 10, 2));
|
||
|
||
ui->m_Label_Y8_MeanValue->setText(QString::number(m_pLineArrayValues[4], 10, 2));
|
||
ui->m_Label_Y8_AirSpace_Deviation->setText(QString::number(m_pLineArrayValues[5], 10, 2));
|
||
ui->m_Label_Y8_DynamicRange->setText(QString::number(m_pLineArrayValues[6], 10, 2));
|
||
ui->m_Label_Y8_MTF->setText(QString::number(m_pLineArrayValues[7], 10, 2));
|
||
|
||
ui->m_Label_Y8_BadPoint->setText(QString::number(m_pLineArrayValues[15]));
|
||
ui->m_Label_Y8_BadPoint_1->setText(QString::number(m_pLineArrayValues[16]));
|
||
ui->m_Label_Y8_BadPoint_2->setText(QString::number(m_pLineArrayValues[17]));
|
||
ui->m_Label_Y8_BadPoint_3->setText(QString::number(m_pLineArrayValues[18]));
|
||
ui->m_Label_Y8_BadPoint_4->setText(QString::number(m_pLineArrayValues[19]));
|
||
ui->m_Label_Y8_BadPoint_5->setText(QString::number(m_pLineArrayValues[20]));
|
||
ui->m_Label_Y8_BadPoint_6->setText(QString::number(m_pLineArrayValues[21]));
|
||
ui->m_Label_Y8_BadPoint_7->setText(QString::number(m_pLineArrayValues[22]));
|
||
ui->m_Label_Y8_BadPoint_8->setText(QString::number(m_pLineArrayValues[23]));
|
||
ui->m_Label_Y8_BadPoint_9->setText(QString::number(m_pLineArrayValues[24]));
|
||
ui->m_Label_Y8_BadPoint_10->setText(QString::number(m_pLineArrayValues[25]));
|
||
ui->m_Label_Y8_BadPoint_11->setText(QString::number(m_pLineArrayValues[26]));
|
||
ui->m_Label_Y8_BadPoint_12->setText(QString::number(m_pLineArrayValues[27]));
|
||
ui->m_Label_Y8_BadPoint_13->setText(QString::number(m_pLineArrayValues[28]));
|
||
ui->m_Label_Y8_BadPoint_14->setText(QString::number(m_pLineArrayValues[29]));
|
||
ui->m_Label_Y8_BadPoint_15->setText(QString::number(m_pLineArrayValues[30]));
|
||
ui->m_Label_Y8_BadPoint_16->setText(QString::number(m_pLineArrayValues[31]));
|
||
ui->m_Label_Y8_BadPoint_17->setText(QString::number(m_pLineArrayValues[32]));
|
||
ui->m_Label_Y8_BadPoint_18->setText(QString::number(m_pLineArrayValues[33]));
|
||
ui->m_Label_Y8_BadPoint_19->setText(QString::number(m_pLineArrayValues[34]));
|
||
|
||
|
||
|
||
ui->m_Label_Y16_AirSpace_Deviation->setText(QString::number(m_pLineArrayValues[8], 10, 2));
|
||
ui->m_Label_Y16_Nonuniform->setText(QString::number(m_pLineArrayValues[9], 10, 4));
|
||
ui->m_Label_Y16_MeanValue->setText(QString::number(m_pLineArrayValues[10], 10, 2));
|
||
ui->m_Label_Y16_SignalNoiseRatio->setText(QString::number(m_pLineArrayValues[11], 10, 2));
|
||
ui->m_Label_Y16_AD->setText(QString::number(m_pLineArrayValues[12], 10, 2));
|
||
ui->m_Label_Y16_BadPoint->setText(QString::number(m_pLineArrayValues[14]));
|
||
|
||
}
|
||
|
||
void MainWindow::OnRecvQualityImageShow(QImage varImage, int nWidth, int nHeight)
|
||
{
|
||
|
||
|
||
if (ui->m_label_Assess->width() != nWidth || ui->m_label_Assess->height() != nHeight)
|
||
{
|
||
QImage varScaleImageRect = varImage.scaled(ui->m_label_Assess->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); //放缩图片,以固定大小显示
|
||
ui->m_label_Assess->setPixmap(QPixmap::fromImage(varScaleImageRect));
|
||
}
|
||
else
|
||
{
|
||
ui->m_label_Assess->setPixmap(QPixmap::fromImage(varImage));
|
||
}
|
||
|
||
|
||
}
|
||
|
||
void MainWindow::OnRecvFPS(QString fps)
|
||
{
|
||
ui->m_label_FPS->setText(fps);
|
||
}
|
||
|
||
void MainWindow::OnColorTableClicked()
|
||
{
|
||
QObject* pSender = sender();
|
||
if (pSender == ui->m_pushButtonImageFormatColorTableItem01)
|
||
{
|
||
SetColorIndex(0);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem02)
|
||
{
|
||
SetColorIndex(1);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem03)
|
||
{
|
||
SetColorIndex(2);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem04)
|
||
{
|
||
SetColorIndex(3);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem05)
|
||
{
|
||
SetColorIndex(4);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem06)
|
||
{
|
||
SetColorIndex(5);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem07)
|
||
{
|
||
SetColorIndex(6);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem08)
|
||
{
|
||
SetColorIndex(7);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(false);
|
||
}
|
||
else if (pSender == ui->m_pushButtonImageFormatColorTableItem09)
|
||
{
|
||
SetColorIndex(8);
|
||
ui->m_pushButtonImageFormatColorTableItem09->setChecked(true);
|
||
ui->m_pushButtonImageFormatColorTableItem01->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem03->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem04->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem05->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem06->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem07->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem08->setChecked(false);
|
||
ui->m_pushButtonImageFormatColorTableItem02->setChecked(false);
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::ShowY16BackRect(bool bl)
|
||
{
|
||
if (bl)
|
||
{
|
||
ui->m_labelX_Back->show();
|
||
ui->m_labelY_Back->show();
|
||
ui->m_labelW_BAck->show();
|
||
ui->m_labelH_Back->show();
|
||
ui->m_lineEdit_ImageQuality_AssessX_Back->show();
|
||
ui->m_lineEdit_ImageQuality_AssessY_Back->show();
|
||
ui->m_lineEdit_ImageQuality_AssessW_Back->show();
|
||
ui->m_lineEdit_ImageQuality_AssessH_Back->show();
|
||
ui->m_Btn_ImageQualityAssess_SetRect_Back->show();
|
||
|
||
}
|
||
else
|
||
{
|
||
ui->m_labelX_Back->hide();
|
||
ui->m_labelY_Back->hide();
|
||
ui->m_labelW_BAck->hide();
|
||
ui->m_labelH_Back->hide();
|
||
ui->m_lineEdit_ImageQuality_AssessX_Back->hide();
|
||
ui->m_lineEdit_ImageQuality_AssessY_Back->hide();
|
||
ui->m_lineEdit_ImageQuality_AssessW_Back->hide();
|
||
ui->m_lineEdit_ImageQuality_AssessH_Back->hide();
|
||
ui->m_Btn_ImageQualityAssess_SetRect_Back->hide();
|
||
}
|
||
|
||
}
|
||
|
||
void MainWindow::ConvertToHexData()
|
||
{
|
||
m_bHexRes = false;
|
||
|
||
ui->m_label_Result_ToHex->setText("N/A");
|
||
|
||
QString strfileName_Q = ui->m_textEdit_BitPath->toPlainText();
|
||
QFileInfo file(strfileName_Q);
|
||
bool isExist = file.isFile();
|
||
if (strfileName_Q == "" || !isExist)
|
||
return;
|
||
|
||
static QString s_DefaultFileName = "saveHex";
|
||
|
||
//路径:不包含文件名
|
||
int npos1 = strfileName_Q.lastIndexOf("/");
|
||
int npos2 = strfileName_Q.lastIndexOf(".");
|
||
|
||
if (npos1 != -1 && npos2 != -1)
|
||
{
|
||
s_DefaultFileName = strfileName_Q.mid(npos1, npos2 - npos1);
|
||
}
|
||
|
||
QString outName = m_strFilePathHexSave + "/" + s_DefaultFileName + QString(".hex");
|
||
unsigned long len;
|
||
// UpdataHead uh;
|
||
// QString fType = ui->m_Cb_fileFormat->currentText();
|
||
// int tmp = 10;
|
||
// if(fType.contains("0x",Qt::CaseInsensitive))
|
||
// tmp = 16;
|
||
// uh.devid = fType.toInt(NULL,tmp);
|
||
|
||
// QString fNum = ui->m_fileNum->text();
|
||
// tmp = 10;
|
||
// if(fNum.contains("0x",Qt::CaseInsensitive))
|
||
// tmp = 16;
|
||
// uh.softNum = fNum.toInt(NULL,tmp);
|
||
|
||
// uh.majVer = ui->m_fileMajV->text().toInt();
|
||
// uh.subVer = ui->m_fileSubV->text().toInt();
|
||
// uh.year = ui->m_year->text().toInt();
|
||
// uh.month = ui->m_month->text().toInt();
|
||
// uh.day = ui->m_day->text().toInt();
|
||
|
||
int fileFormat = ui->m_Cb_fileFormat->currentIndex();
|
||
EUFormatType formatType = EUFormatType(fileFormat);
|
||
switch (formatType)
|
||
{
|
||
case ETYPE_BIT:
|
||
{
|
||
if (m_pFileHexConvert->OpenBitFile(strfileName_Q))
|
||
{
|
||
m_bHexRes = true;
|
||
}
|
||
else
|
||
{
|
||
m_bHexRes = false;
|
||
}
|
||
break;
|
||
}
|
||
case ETYPE_OX:
|
||
{
|
||
if (m_pFileHexConvert->OpenOXDatFile(strfileName_Q))
|
||
{
|
||
m_bHexRes = true;
|
||
}
|
||
else
|
||
{
|
||
m_bHexRes = false;
|
||
}
|
||
|
||
break;
|
||
}
|
||
case ETYPE_UX:
|
||
{
|
||
if (m_pFileHexConvert->OpenUXDatFile(strfileName_Q))
|
||
{
|
||
m_bHexRes = true;
|
||
}
|
||
else
|
||
{
|
||
m_bHexRes = false;
|
||
}
|
||
|
||
break;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (m_bHexRes)
|
||
{
|
||
if (!m_pFileHexConvert->WriteDataToFile(outName))
|
||
{
|
||
CommonHelper::ShowMessageBoxError(tr("转换失败!"), this);
|
||
return;
|
||
}
|
||
|
||
ui->m_label_Result_ToHex->setText(tr("转换成功"));
|
||
}
|
||
else
|
||
{
|
||
CommonHelper::ShowMessageBoxError(tr("打开文件失败!"), this);
|
||
return;
|
||
}
|
||
|
||
}
|
||
|