Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emulation device&server. #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

build-tool-Desktop_Qt_5_9_0_MinGW_32bit-Debug/*
tool/build-digital_sensor_capture_tool-Desktop_Qt_5_9_0_MinGW_32bit-Debug/*
tool/build-comtool-Desktop_Qt_5_9_0_MinGW_32bit-Debug/*
ui/bin/*
tool/bin/*
video/bin/*
widget/bin/*
control/bin/*
other/bin/*
third/bin/*
tool/SensorCaptureTool/file/send.txt
tool/SensorCaptureTool/file/device.txt
8 changes: 4 additions & 4 deletions QWidgetDemo.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TEMPLATE = subdirs
SUBDIRS += control
SUBDIRS += tool
SUBDIRS += video
SUBDIRS += widget
SUBDIRS += ui
SUBDIRS += other
#SUBDIRS += video
#SUBDIRS += widget
#SUBDIRS += ui
#SUBDIRS += other
SUBDIRS += third
#网友提交的可能很多Qt版本不支持需要自行打开验证
#SUBDIRS += netfriend
609 changes: 609 additions & 0 deletions QWidgetDemo.pro.user

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions control/control.pro
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
TEMPLATE = subdirs
SUBDIRS += battery
SUBDIRS += devicebutton
SUBDIRS += devicesizetable
SUBDIRS += imageswitch
SUBDIRS += ipaddress
SUBDIRS += lightbutton
SUBDIRS += navbutton
#SUBDIRS += battery
#SUBDIRS += devicebutton
#SUBDIRS += devicesizetable
#SUBDIRS += imageswitch
#SUBDIRS += ipaddress
#SUBDIRS += lightbutton
#SUBDIRS += navbutton
SUBDIRS += savelog
SUBDIRS += saveruntime
SUBDIRS += smoothcurve
SUBDIRS += zhtopy
#SUBDIRS += zhtopy
18 changes: 9 additions & 9 deletions third/third.pro
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
TEMPLATE = subdirs
SUBDIRS += hotkey
SUBDIRS += shortcut
SUBDIRS += qwtdemo
#SUBDIRS += hotkey
#SUBDIRS += shortcut
#SUBDIRS += qwtdemo
SUBDIRS += qcustomplotdemo

#这个项目依赖QtDesigner模块,一般在arm上默认没有这个模块需要自行编译
#所以arm上如果没有QtDesigner模块不要加载下面这个子项目

lessThan(QT_MAJOR_VERSION, 5) {
SUBDIRS += designer
SUBDIRS -= hotkey
#SUBDIRS += designer
#SUBDIRS -= hotkey
}

#Qt6有些项目还不支持
greaterThan(QT_MAJOR_VERSION, 5) {
SUBDIRS -= hotkey
SUBDIRS -= shortcut
SUBDIRS -= qwtdemo
#SUBDIRS -= hotkey
#SUBDIRS -= shortcut
#SUBDIRS -= qwtdemo
}

win32 {
SUBDIRS += miniblink
#SUBDIRS += miniblink
}
48 changes: 48 additions & 0 deletions tool/SensorCaptureTool/3rd_qcustomplot/3rd_qcustomplot.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11
#lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11

#将当前目录加入到头文件路径
INCLUDEPATH += $$PWD
DEFINES += qcustomplot

#引入平滑曲线类
HEADERS += $$PWD/smoothcurve.h
SOURCES += $$PWD/smoothcurve.cpp

#没有定义任何版本则默认采用2.0
!contains(DEFINES, qcustomplot_v1_3) {
!contains(DEFINES, qcustomplot_v2_0) {
!contains(DEFINES, qcustomplot_v2_1) {
DEFINES += qcustomplot_v2_0
}}}

#定义了2.0版本在Qt5以上采用2.1
contains(DEFINES, qcustomplot_v2_0) {
!contains(DEFINES, qcustomplot_v2_1) {
greaterThan(QT_MAJOR_VERSION, 4) {
DEFINES -= qcustomplot_v1_3
DEFINES -= qcustomplot_v2_0
DEFINES += qcustomplot_v2_1
}}}

#根据定义的版本引入文件
contains(DEFINES, qcustomplot_v1_3) {
INCLUDEPATH += $$PWD/v1_3
HEADERS += $$PWD/v1_3/qcustomplot.h
SOURCES += $$PWD/v1_3/qcustomplot.cpp
} else {
contains(DEFINES, qcustomplot_v2_0) {
INCLUDEPATH += $$PWD/v2_0
HEADERS += $$PWD/v2_0/qcustomplot.h
SOURCES += $$PWD/v2_0/qcustomplot.cpp
} else {
INCLUDEPATH += $$PWD/v2_1
#引入对应修复不支持Qt6的头文件
greaterThan(QT_MAJOR_VERSION, 5) {
HEADERS += $$PWD/v2_1_6/qcustomplot.h
} else {
HEADERS += $$PWD/v2_1/qcustomplot.h
}
SOURCES += $$PWD/v2_1/qcustomplot.cpp
}}
120 changes: 120 additions & 0 deletions tool/SensorCaptureTool/3rd_qcustomplot/smoothcurve.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#include "smoothcurve.h"
#include "qdebug.h"

QPainterPath SmoothCurve::createSmoothCurve(const QVector<QPointF> &points)
{
QPainterPath path;
int len = points.count();
if (len < 2) {
return path;
}

QVector<QPointF> firstControlPoints;
QVector<QPointF> secondControlPoints;
calculateControlPoints(points, &firstControlPoints, &secondControlPoints);
path.moveTo(points[0].x(), points[0].y());

for (int i = 0; i < len - 1; ++i) {
path.cubicTo(firstControlPoints[i], secondControlPoints[i], points[i + 1]);
}

return path;
}

QPainterPath SmoothCurve::createSmoothCurve2(const QVector<QPointF> &points)
{
//采用Qt原生方法不做任何处理
int count = points.count();
if (count == 0) {
return QPainterPath();
}

QPainterPath path(points.at(0));
for (int i = 0; i < count - 1; ++i) {
//控制点的 x 坐标为 sp 与 ep 的 x 坐标和的一半
//第一个控制点 c1 的 y 坐标为起始点 sp 的 y 坐标
//第二个控制点 c2 的 y 坐标为结束点 ep 的 y 坐标
QPointF sp = points.at(i);
QPointF ep = points.at(i + 1);
QPointF c1 = QPointF((sp.x() + ep.x()) / 2, sp.y());
QPointF c2 = QPointF((sp.x() + ep.x()) / 2, ep.y());
path.cubicTo(c1, c2, ep);
}

return path;
}

void SmoothCurve::calculateFirstControlPoints(double *&result, const double *rhs, int n)
{
result = new double[n];
double *tmp = new double[n];
double b = 2.0;
result[0] = rhs[0] / b;

for (int i = 1; i < n; ++i) {
tmp[i] = 1 / b;
b = (i < n - 1 ? 4.0 : 3.5) - tmp[i];
result[i] = (rhs[i] - result[i - 1]) / b;
}

for (int i = 1; i < n; ++i) {
result[n - i - 1] -= tmp[n - i] * result[n - i];
}

delete tmp;
}

void SmoothCurve::calculateControlPoints(const QVector<QPointF> &datas,
QVector<QPointF> *firstControlPoints,
QVector<QPointF> *secondControlPoints)
{
int n = datas.count() - 1;
for (int i = 0; i < n; ++i) {
firstControlPoints->append(QPointF());
secondControlPoints->append(QPointF());
}

if (n == 1) {
(*firstControlPoints)[0].rx() = (2 * datas[0].x() + datas[1].x()) / 3;
(*firstControlPoints)[0].ry() = (2 * datas[0].y() + datas[1].y()) / 3;
(*secondControlPoints)[0].rx() = 2 * (*firstControlPoints)[0].x() - datas[0].x();
(*secondControlPoints)[0].ry() = 2 * (*firstControlPoints)[0].y() - datas[0].y();
return;
}

double *xs = 0;
double *ys = 0;
double *rhsx = new double[n];
double *rhsy = new double[n];

for (int i = 1; i < n - 1; ++i) {
rhsx[i] = 4 * datas[i].x() + 2 * datas[i + 1].x();
rhsy[i] = 4 * datas[i].y() + 2 * datas[i + 1].y();
}

rhsx[0] = datas[0].x() + 2 * datas[1].x();
rhsx[n - 1] = (8 * datas[n - 1].x() + datas[n].x()) / 2.0;
rhsy[0] = datas[0].y() + 2 * datas[1].y();
rhsy[n - 1] = (8 * datas[n - 1].y() + datas[n].y()) / 2.0;

calculateFirstControlPoints(xs, rhsx, n);
calculateFirstControlPoints(ys, rhsy, n);

for (int i = 0; i < n; ++i) {
(*firstControlPoints)[i].rx() = xs[i];
(*firstControlPoints)[i].ry() = ys[i];

if (i < n - 1) {
(*secondControlPoints)[i].rx() = 2 * datas[i + 1].x() - xs[i + 1];
(*secondControlPoints)[i].ry() = 2 * datas[i + 1].y() - ys[i + 1];
} else {
(*secondControlPoints)[i].rx() = (datas[n].x() + xs[n - 1]) / 2;
(*secondControlPoints)[i].ry() = (datas[n].y() + ys[n - 1]) / 2;
}
}

delete xs;
delete ys;
delete rhsx;
delete rhsy;
}
28 changes: 28 additions & 0 deletions tool/SensorCaptureTool/3rd_qcustomplot/smoothcurve.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef SMOOTHCURVE_H
#define SMOOTHCURVE_H

#include <QObject>
#include <QVector>
#include <QPointF>
#include <QPainterPath>

#ifdef quc
class Q_DECL_EXPORT SmoothCurve
#else
class SmoothCurve
#endif

{
public:
//创建平滑曲线路径
static QPainterPath createSmoothCurve(const QVector<QPointF> &points);
static QPainterPath createSmoothCurve2(const QVector<QPointF> &points);

private:
static void calculateFirstControlPoints(double *&result, const double *rhs, int n);
static void calculateControlPoints(const QVector<QPointF> &datas,
QVector<QPointF> *firstControlPoints,
QVector<QPointF> *secondControlPoints);
};

#endif // SMOOTHCURVE_H
Loading