Files
chenzhen 222dda1e43 1,新增“App_ThermalImageSystem”;
2,新增“Apps”;
3,新增“Common”;
4,新增“FileList”;
5,新增“MediaX”;
6,新增“OpenSource”;
7,新增“Samples”;
8,新增“SoftwareBusinessLines”.
2026-02-14 23:03:23 +08:00

251 lines
7.4 KiB
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QMessageBox>
#include <QFileDialog>
#include <QString>
#include <QDebug>
#include "commonhelper.h"
#include "frameless_helper.h"
#include <mmsystem.h>
#pragma comment(lib, "winmm")
#define MaxSize_IRSensorTool (4096*2048)
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle(tr(" ") );
// OpenGLView
//this->setAttribute(Qt::WA_Mapped);
//
m_bMousePressed = false;
// 初始化界面
InitStyle();
//
CustomPlot_TestFun();
// 加载信号槽函数连接
Connect();
}
MainWindow::~MainWindow()
{
Disconnect();
delete ui;
}
void MainWindow::Connect()
{
// 通用
connect(ui->m_pushButton_MinMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
connect(ui->m_pushButton_CloseMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
//
connect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
m_varTimer.setTimerType(Qt::PreciseTimer);
m_varTimer.start(10);
}
void MainWindow::Disconnect()
{
// 通用
disconnect(ui->m_pushButton_MinMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
disconnect(ui->m_pushButton_CloseMenu, &QPushButton::clicked, this, &MainWindow::OnButtonClicked);
//
m_varTimer.stop();
disconnect(&m_varTimer, &QTimer::timeout, this, &MainWindow::OnTimer);
}
void MainWindow::CustomPlot_TestFun()
{
//
//ui->m_pCustomPlot->setBackground(QColor(90,90,100,0) );
//ui->m_pCustomPlot->axisRect()->setBackground(QColor(90,90,100,0) );
/*
ui->m_pCustomPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables);
*/
ui->m_pCustomPlot->setInteractions(/*QCP::iRangeDrag | QCP::iRangeZoom |*/ QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables);
//
QLinearGradient plotGradient;
plotGradient.setStart(0, 0);
plotGradient.setFinalStop(0, 200);
plotGradient.setColorAt(0, QColor(0, 12, 40));//QColor(80, 80, 80)
plotGradient.setColorAt(1, QColor(0, 12, 40));//QColor(50, 50, 50)
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, 12);
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(0, 10.0);
ui->m_pCustomPlot->yAxis->setSubTicks(false);
ui->m_pCustomPlot->yAxis->ticker()->setTickCount(5);
// 画线
ui->m_pCustomPlot->addGraph();
ui->m_pCustomPlot->graph()->setPen(QPen(QBrush(QColor(255, 255, 255, 128)),5) );
ui->m_pCustomPlot->graph()->setBrush(QBrush(QColor(255, 255, 255, 128)) );
ui->m_pCustomPlot->addGraph();
ui->m_pCustomPlot->graph()->setPen(QPen(Qt::red));
QVector<double> x(13), y0(13), y1(13);
for (int i=0; i<=12; ++i)
{
x[i] = i;
y0[i] = 10*(i/12.0);
y1[i] = 10 - 10*(i/12.0);
}
ui->m_pCustomPlot->graph(0)->setData(x, y0);
ui->m_pCustomPlot->graph(1)->setData(x, y1);
/*
ui->m_pCustomPlot->addGraph();
ui->m_pCustomPlot->graph(1)->setPen(QPen(Qt::red));
// cp->graph(1)->setBrush(QBrush(QPixmap("./balboa.jpg"))); // same fill as we used for graph 0
ui->m_pCustomPlot->graph(1)->setLineStyle(QCPGraph::lsStepCenter);
ui->m_pCustomPlot->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::white, Qt::white, 7));
ui->m_pCustomPlot->graph(1)->setName("Bottom maxwell function");
*/
}
void MainWindow::OnButtonClicked()
{
// 最小化
if(sender() == ui->m_pushButton_MinMenu)
{
this->showMinimized();
}
// 退出程序
if(sender() == ui->m_pushButton_CloseMenu)
{
qApp->exit();
}
}
void MainWindow::OnComboxIndexChanged(int nIndex)
{
}
void MainWindow::InitStyle()
{
m_bMousePressed = false;
//安装事件监听器,让标题栏识别鼠标双击
ui->lblTitle->installEventFilter(this);
/*
this->setWindowFlags(/*Qt::FramelessWindowHint |*
Qt::WindowTitleHint |
Qt::WindowSystemMenuHint);
*/
FramelessHelper *pHelper = new FramelessHelper(this);
pHelper->activateOn(this); //激活当前窗体
pHelper->setTitleHeight(ui->wgtTitleBar->height()); //设置窗体的标题栏高度
CommonHelper::SetStyle("blue");//"blue"//"dark"
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
//if (ui->lblTitle == obj)
{
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
m_bMousePressed = true;
m_ptMouse = mouseEvent->globalPos() - pos();
mouseEvent->accept();
}
return true;
}
else if (event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (m_bMousePressed && this->windowState() != Qt::WindowMaximized)
{
if (mouseEvent->globalY() <= qApp->desktop()->availableGeometry().bottom())
{
move(mouseEvent->globalPos() - m_ptMouse);
mouseEvent->accept();
}
else
{
qApp->desktop()->cursor().setPos(
qApp->desktop()->cursor().pos().x(),
qApp->desktop()->availableGeometry().bottom()
);
}
}
return true;
}
else if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton)
{
m_bMousePressed = false;
mouseEvent->accept();
}
return true;
}
}
return QMainWindow::eventFilter(obj, event);
}
void MainWindow::OnTimer()
{
}