parent
2b98d59329
commit
e4cb943bf5
@ -0,0 +1,42 @@
|
||||
#ifndef LIBTCPCLIENT_H
|
||||
#define LIBTCPCLIENT_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include "libTcp.h"
|
||||
#include <QThread>
|
||||
|
||||
class TPTcpClient;
|
||||
class lpTcpClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lpTcpClient(const TP_TCP_CLIENT_PARAM& init_param,
|
||||
QObject *parent = 0);
|
||||
~lpTcpClient();
|
||||
|
||||
void IGetVersion(QString &version);
|
||||
void IGetClientStatus(TP_CLIENT_STATUS& clistatus);
|
||||
void ISendMessage(TP_PROTOCOL_MESSAGE& msg);
|
||||
void ISendBinaryData(TP_PROTOCOL_MESSAGE& msg, QByteArray& binaryData);
|
||||
|
||||
void onStartDevice();
|
||||
void onStopDevice();
|
||||
signals:
|
||||
void signal_connected();
|
||||
void signal_disconnected();
|
||||
|
||||
void signal_message_receive(QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||||
void signal_data_send_completed(QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||||
void signal_data_recv_completed(QSharedPointer<TP_PROTOCOL_MESSAGE>,
|
||||
QSharedPointer<QByteArray> );
|
||||
|
||||
void signal_device_start();
|
||||
void signal_send_binary_data(QSharedPointer<TP_PROTOCOL_MESSAGE>,QSharedPointer<QByteArray>);
|
||||
void signal_send_package(QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||||
|
||||
private:
|
||||
QThread tcp_thread_;
|
||||
};
|
||||
#endif // LIBTCPCLIENT_GLOBAL_H
|
||||
@ -0,0 +1,48 @@
|
||||
#ifndef LIBTCPSERVER_H
|
||||
#define LIBTCPSERVER_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
//#if defined(LIBTCPSERVER_LIBRARY)
|
||||
//# define LIBTCPSERVERSHARED_EXPORT Q_DECL_EXPORT
|
||||
//#else
|
||||
# define LIBTCPSERVERSHARED_EXPORT Q_DECL_IMPORT
|
||||
//#endif
|
||||
|
||||
#include "libTcp.h"
|
||||
#include <QTcpServer>
|
||||
|
||||
class TPTcpServer;
|
||||
|
||||
class lpTcpServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lpTcpServer(const TP_TCP_SERVER_PARAM& init_param,
|
||||
QObject *parent = 0);
|
||||
~lpTcpServer();
|
||||
|
||||
ClientsStatusMap IGetClientsStatus();
|
||||
const TpServerStatus IGetServerStatus() { return server_status_; }
|
||||
|
||||
void IGetVersion(QString& version);
|
||||
bool IStartServer();
|
||||
void IStopServer();
|
||||
void ISendMessage(const QString& strClient, TP_PROTOCOL_MESSAGE& msg);
|
||||
void ISendBinaryData(const QString& strClient, TP_PROTOCOL_MESSAGE& msg, QByteArray& binaryData);
|
||||
signals:
|
||||
void signal_client_connected(const QString&);
|
||||
void signal_client_disconnected(const QString&);
|
||||
|
||||
void signal_message_received(const QString&, QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||||
void signal_data_send_completed(QSharedPointer<TP_PROTOCOL_MESSAGE>);
|
||||
void signal_data_recv_completed(const QString& , QSharedPointer<TP_PROTOCOL_MESSAGE>, QSharedPointer<QByteArray> );
|
||||
void signal_data_recv_completed_client(QSharedPointer<TP_PROTOCOL_MESSAGE>, QSharedPointer<QByteArray>);
|
||||
private:
|
||||
QSharedPointer<TPTcpServer> tcp_server_{nullptr};
|
||||
QHostAddress listen_addr_;
|
||||
quint16 listen_port_;
|
||||
TpServerStatus server_status_;
|
||||
};
|
||||
#endif // LIBTCPSERVER_H
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,132 @@
|
||||
#include "QAlgParamDlg.h"
|
||||
#include "qshowimg.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "lpGlobalConfig.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
QAlgParamDlg::QAlgParamDlg(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
connect(ui.m_pbShowBackImage, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
||||
connect(ui.m_pbApply, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
||||
connect(ui.m_pbExit, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
||||
ui.label->setVisible(false);
|
||||
}
|
||||
|
||||
QAlgParamDlg::~QAlgParamDlg()
|
||||
{
|
||||
}
|
||||
|
||||
Q_SLOT void QAlgParamDlg::onButtonClicked()
|
||||
{
|
||||
QString strObj = sender()->objectName();
|
||||
if (strObj == "m_pbShowBackImage")
|
||||
{
|
||||
QShowImg m_showImgDlg(this);
|
||||
m_showImgDlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
||||
m_showImgDlg.setWindowModality(Qt::ApplicationModal);
|
||||
m_showImgDlg.setAttribute(Qt::WA_ShowModal, true);
|
||||
m_showImgDlg.setWindowIcon(QIcon(":/image/leaper"));
|
||||
QString DstPath = ".\\user\\background.png";
|
||||
connect(&m_showImgDlg, SIGNAL(sgChangeImg()), this, SLOT(onChangeBG()));
|
||||
connect(this, SIGNAL(sgChangeBG(QString)), &m_showImgDlg, SLOT(setPicPath(QString)));
|
||||
m_showImgDlg.setPicPath(DstPath);
|
||||
m_showImgDlg.exec();
|
||||
}
|
||||
else if (strObj == "m_pbApply")
|
||||
{
|
||||
getParam();
|
||||
ui.label->setVisible(true);
|
||||
m_timeID = startTimer(1000);
|
||||
emit sgParamChange();
|
||||
}
|
||||
else if (strObj == "m_pbExit")
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QAlgParamDlg::showEvent(QShowEvent *event)
|
||||
{
|
||||
setParam();
|
||||
}
|
||||
|
||||
void QAlgParamDlg::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_timeID == event->timerId())
|
||||
{
|
||||
killTimer(m_timeID);
|
||||
m_timeID = 0;
|
||||
ui.label->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
void QAlgParamDlg::setParam()
|
||||
{
|
||||
ui.checkBox->setChecked(lpGlobalConfig::instance()->algParam.m_UseBackground == 0 ? false : true);
|
||||
ui.checkBox_equal->setChecked(lpGlobalConfig::instance()->algParam.m_bUseEqual);
|
||||
ui.spinBox_filterSize->setValue(lpGlobalConfig::instance()->algParam.m_filterSize);
|
||||
|
||||
ui.spinBox_circle_ACThres->setValue(lpGlobalConfig::instance()->algParam.m_Circle_ACThres);
|
||||
ui.spinBox_circle_EdgeWidth->setValue(lpGlobalConfig::instance()->algParam.m_Circle_EdgeWidth);
|
||||
ui.comboBox_transform->setCurrentIndex(lpGlobalConfig::instance()->algParam.m_Circle_Polarity);
|
||||
//ui.checkBox_ratio->setChecked(lpGlobalConfig::instance()->algParam.m_RatioDetectType==0?false:true);
|
||||
|
||||
}
|
||||
|
||||
void QAlgParamDlg::getParam()
|
||||
{
|
||||
lpGlobalConfig::instance()->algParam.m_UseBackground = ui.checkBox->isChecked();
|
||||
lpGlobalConfig::instance()->algParam.m_bUseEqual = ui.checkBox_equal->isChecked();
|
||||
lpGlobalConfig::instance()->algParam.m_filterSize = ui.spinBox_filterSize->value();
|
||||
|
||||
lpGlobalConfig::instance()->algParam.m_Circle_ACThres = ui.spinBox_circle_ACThres->value();
|
||||
lpGlobalConfig::instance()->algParam.m_Circle_EdgeWidth = ui.spinBox_circle_EdgeWidth->value();
|
||||
lpGlobalConfig::instance()->algParam.m_Circle_Polarity = ui.comboBox_transform->currentIndex();
|
||||
//lpGlobalConfig::instance()->algParam.m_RatioDetectType = ui.checkBox_ratio->isChecked();
|
||||
|
||||
lpGlobalConfig::instance()->save();
|
||||
}
|
||||
|
||||
Q_SLOT void QAlgParamDlg::onChangeBG()
|
||||
{
|
||||
QFileDialog fileDialog;
|
||||
fileDialog.setWindowTitle(tr("请选择您的背景图"));
|
||||
fileDialog.setNameFilter("Picture(*.bmp *.jpg *.png)");
|
||||
fileDialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
if (fileDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
QStringList backgroundFile = fileDialog.selectedFiles();
|
||||
if (backgroundFile.size() > 0)
|
||||
{
|
||||
QString DstPath = QApplication::applicationDirPath() + "\\user\\background.png";
|
||||
QString sourcePath = backgroundFile.at(0);
|
||||
DstPath.replace("\\", "/");
|
||||
if (sourcePath == DstPath) {
|
||||
// //return;
|
||||
// //return true;
|
||||
}
|
||||
if (!QFile::exists(sourcePath)) {
|
||||
//return false;
|
||||
}
|
||||
QDir *createfile = new QDir;
|
||||
bool exist = createfile->exists(DstPath);
|
||||
if (exist) {
|
||||
//if (converFileIfExist){
|
||||
createfile->remove(DstPath);
|
||||
//}
|
||||
}
|
||||
if (!QFile::copy(sourcePath, DstPath)) {
|
||||
//return false;
|
||||
}
|
||||
//emit sgChangeBG(DstPath);
|
||||
QMessageBox infobox(QMessageBox::Information, tr("提示"), tr("背景图更新完成,请重启本软件."), QMessageBox::Yes, NULL);
|
||||
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
||||
infobox.setButtonText(QMessageBox::Yes, tr("确认"));
|
||||
infobox.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#ifndef _QALGPARAMDLG_H_
|
||||
#define _QALGPARAMDLG_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_QAlgParamDlg.h"
|
||||
|
||||
class QAlgParamDlg : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QAlgParamDlg(QWidget *parent = Q_NULLPTR);
|
||||
~QAlgParamDlg();
|
||||
Q_SLOT void onButtonClicked();
|
||||
signals:
|
||||
void sgParamChange();
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
void setParam();
|
||||
void getParam();
|
||||
Q_SLOT void onChangeBG();
|
||||
private:
|
||||
Ui::QAlgParamDlg ui;
|
||||
int m_timeID{ 0 };
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,294 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QAlgParamDlg</class>
|
||||
<widget class="QWidget" name="QAlgParamDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>331</width>
|
||||
<height>286</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>算法参数设置</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>圆半径大小过滤:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_filterSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>检测背景图更换:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_pbShowBackImage">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>查看检测背景</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>二级圆定位:</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_circle_ACThres">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>边缘宽度:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_circle_EdgeWidth">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBox_transform">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>从深到浅</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>从浅到深</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>边缘对比度:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>边缘转换:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_equal">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>是否使用图像增强</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>是否使用背景图找圆算法</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>参数已生效!!!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_pbApply">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>应用</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_pbExit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>退出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue