1 Star 0 Fork 122

gl_21/QtSerialPortPlotter

forked from 觉皇/QtSerialPortPlotter 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mainwindow.hpp 7.05 KB
一键复制 编辑 原始数据 按行查看 历史
/***************************************************************************
** This file is part of Serial Port Plotter **
** **
** **
** Serial Port Plotter is a program for plotting integer data from **
** serial port using Qt and QCustomPlot **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Borislav **
** Contact: b.kereziev@gmail.com **
** Date: 29.12.14 **
****************************************************************************/
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include <QMainWindow>
#include <QtSerialPort/QtSerialPort>
#include <QSerialPortInfo>
#include "helpwindow.hpp"
#include "qcustomplot/qcustomplot.h"
#include "ui_mainwindow.h"
#include "settings.h"
#include "settingsdialog.h"
#include <QDebug>
#include "xlsxdocument.h"
#define START_MSG '$'
#define END_MSG ';'
#define WAIT_START 1
#define IN_MESSAGE 2
#define UNDEFINED 3
#define GCP_CUSTOM_LINE_COLORS 4
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_comboPort_currentIndexChanged(const QString &arg1); // Slot displays message on status bar
void replot(); // Slot for repainting the plot
void onNewDataArrived(QStringList newData); // Slot for new data from serial port
void saveStream(QStringList newData); // Save the received data to the opened file
void on_spinAxesMin_valueChanged(int arg1); // Changing lower limit for the plot
void on_spinAxesMax_valueChanged(int arg1); // Changing upper limit for the plot
void readData(); // Slot for inside serial port
void on_spinYStep_valueChanged(int arg1); // Spin box for changing Y axis tick step
void on_savePNGButton_clicked(); // Button for saving JPG
void onMouseMoveInPlot (QMouseEvent *event); // Displays coordinates of mouse pointer when clicked in plot in status bar
void on_spinPoints_valueChanged (int arg1); // Spin box controls how many data points are collected and displayed
void onMouseWheelInPlot(QWheelEvent *event); // Makes wheel mouse works while plotting
/* Used when a channel is selected (plot or legend) */
void channel_selection (void);
void legend_double_click (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
void on_actionConnect_triggered();
void on_actionDisconnect_triggered();
void on_actionHow_to_use_triggered();
void on_actionPause_Plot_triggered();
void on_actionClear_triggered();
void on_actionRecord_stream_triggered();
void on_pushButton_AutoScale_clicked();
void on_pushButton_ResetVisible_clicked();
void on_listWidget_Channels_itemDoubleClicked(QListWidgetItem *item);
void on_pushButton_ClearRecv_clicked();
void on_actionSettings_triggered();
signals:
void newData(QStringList data); // Emitted when new data has arrived
private:
Ui::MainWindow *ui;
QColor gui_colors[GCP_CUSTOM_LINE_COLORS];
QList<QColor> lineColorsList;
QStringList lineColorNamesStrList;
/* Main info */
bool connected = false; // Status connection variable
bool plotting = false; // Status plotting variable
int dataPointNumber = 0; // Keep track of data points
/* Channels of data (number of graphs) */
int channels = 0;
//
// excel
//
QXlsx::Document* xlsxDevice = nullptr;
uint32_t xlsxRow = 0;
void openCsvFile(void);
void closeCsvFile(void);
QTimer updateTimer; // Timer used for replotting the plot
QSerialPort *serialPort = nullptr; // Serial port; runs in this thread
QString receivedData; // Used for reading from the port
int STATE = WAIT_START; // State of recieiving message from port
void createUI(); // Populate the controls
void enable_com_controls (bool enable); // Enable/disable controls
void setupPlot(); // Setup the QCustomPlot
// Open the inside serial port with these parameter
void varInit();
protected:
void closeEvent(QCloseEvent* e) override;
bool eventFilter(QObject *watched, QEvent *event) override;
};
#endif // MAINWINDOW_HPP
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/gl__twentyone/QtSerialPortPlotter.git
git@gitee.com:gl__twentyone/QtSerialPortPlotter.git
gl__twentyone
QtSerialPortPlotter
QtSerialPortPlotter
main

搜索帮助