首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

Qt、QCustomPlot、实时波形绘制、实时曲线绘制

后端 458.76KB 36 需要积分: 1
立即下载

资源介绍:

讲解见博客:https://blog.csdn.net/weixin_47488212/article/details/129299987 对于初学者而言,想要及时地做出一套上位机或实时波形显示界面,还是存在一定难度的,为了降低初学者的学习难度,亦方便其他研发人员的使用,笔者分享一套使用简单、功能强大的实时波形绘制控件,其基于Qt5与QCustomPlot实现。 在项目中必须包含QCustomPlot相关文件,笔者这里是直接包含qcustomplot.cpp、qcustomplot.h两个文件。另外在项目的.pro中,必须包含以下这句: QT += widgets printsupport 可以使用代码直接实例化WidgetPlot2D,或通过窗口提升,然后使用WidgetPlot2D绘制实时波形只需两步: ① 初始化波形名称:函数initGraphName(QStringList) ② 给对应的波形添加数据:函数addData(QString, double)
/*************************************************************************** ** ** ** QCustomPlot, an easy to use, modern plotting widget for Qt ** ** Copyright (C) 2011-2021 Emanuel Eichhammer ** ** ** ** 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: Emanuel Eichhammer ** ** Website/Contact: http://www.qcustomplot.com/ ** ** Date: 29.03.21 ** ** Version: 2.1.0 ** ****************************************************************************/ #include "qcustomplot.h" /* including file 'src/vector2d.cpp' */ /* modified 2021-03-29T02:30:44, size 7973 */ //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// QCPVector2D //////////////////////////////////////////////////////////////////////////////////////////////////// /*! \class QCPVector2D \brief Represents two doubles as a mathematical 2D vector This class acts as a replacement for QVector2D with the advantage of double precision instead of single, and some convenience methods tailored for the QCustomPlot library. */ /* start documentation of inline functions */ /*! \fn void QCPVector2D::setX(double x) Sets the x coordinate of this vector to \a x. \see setY */ /*! \fn void QCPVector2D::setY(double y) Sets the y coordinate of this vector to \a y. \see setX */ /*! \fn double QCPVector2D::length() const Returns the length of this vector. \see lengthSquared */ /*! \fn double QCPVector2D::lengthSquared() const Returns the squared length of this vector. In some situations, e.g. when just trying to find the shortest vector of a group, this is faster than calculating \ref length, because it avoids calculation of a square root. \see length */ /*! \fn double QCPVector2D::angle() const Returns the angle of the vector in radians. The angle is measured between the positive x line and the vector, counter-clockwise in a mathematical coordinate system (y axis upwards positive). In screen/widget coordinates where the y axis is inverted, the angle appears clockwise. */ /*! \fn QPoint QCPVector2D::toPoint() const Returns a QPoint which has the x and y coordinates of this vector, truncating any floating point information. \see toPointF */ /*! \fn QPointF QCPVector2D::toPointF() const Returns a QPointF which has the x and y coordinates of this vector. \see toPoint */ /*! \fn bool QCPVector2D::isNull() const Returns whether this vector is null. A vector is null if \c qIsNull returns true for both x and y coordinates, i.e. if both are binary equal to 0. */ /*! \fn QCPVector2D QCPVector2D::perpendicular() const Returns a vector perpendicular to this vector, with the same length. */ /*! \fn double QCPVector2D::dot() const Returns the dot/scalar product of this vector with the specified vector \a vec. */ /* end documentation of inline functions */ /*! Creates a QCPVector2D object and initializes the x and y coordinates to 0. */ QCPVector2D::QCPVector2D() : mX(0), mY(0) { } /*! Creates a QCPVector2D object and initializes the \a x and \a y coordinates with the specified values. */ QCPVector2D::QCPVector2D(double x, double y) : mX(x), mY(y) { } /*! Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified \a point. */ QCPVector2D::QCPVector2D(const QPoint &point) : mX(point.x()), mY(point.y()) { } /*! Creates a QCPVector2D object and initializes the x and y coordinates respective coordinates of the specified \a point. */ QCPVector2D::QCPVector2D(const QPointF &point) : mX(point.x()), mY(point.y()) { } /*! Normalizes this vector. After this operation, the length of the vector is equal to 1. If the vector has both entries set to zero, this method does nothing. \see normalized, length, lengthSquared */ void QCPVector2D::normalize() { if (mX == 0.0 && mY == 0.0) return; const double lenInv = 1.0/length(); mX *= lenInv; mY *= lenInv; } /*! Returns a normalized version of this vector. The length of the returned vector is equal to 1. If the vector has both entries set to zero, this method returns the vector unmodified. \see normalize, length, lengthSquared */ QCPVector2D QCPVector2D::normalized() const { if (mX == 0.0 && mY == 0.0) return *this; const double lenInv = 1.0/length(); return QCPVector2D(mX*lenInv, mY*lenInv); } /*! \overload Returns the squared shortest distance of this vector (interpreted as a point) to the finite line segment given by \a start and \a end. \see distanceToStraightLine */ double QCPVector2D::distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const { const QCPVector2D v(end-start); const double vLengthSqr = v.lengthSquared(); if (!qFuzzyIsNull(vLengthSqr)) { const double mu = v.dot(*this-start)/vLengthSqr; if (mu < 0) return (*this-start).lengthSquared(); else if (mu > 1) return (*this-end).lengthSquared(); else return ((start + mu*v)-*this).lengthSquared(); } else return (*this-start).lengthSquared(); } /*! \overload Returns the squared shortest distance of this vector (interpreted as a point) to the finite line segment given by \a line. \see distanceToStraightLine */ double QCPVector2D::distanceSquaredToLine(const QLineF &line) const { return distanceSquaredToLine(QCPVector2D(line.p1()), QCPVector2D(line.p2())); } /*! Returns the shortest distance of this vector (interpreted as a point) to the infinite straight line given by a \a base point and a \a direction vector. \see distanceSquaredToLine */ double QCPVector2D::distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const { return qAbs((*this-base).dot(direction.perpendicular()))/direction.length(); } /*! Scales this vector by the given \a factor, i.e. the x and y components are multiplied by \a factor. */ QCPVector2D &QCPVector2D::operator*=(double factor) { mX *= factor; mY *= factor; return *this; } /*! Scales this vector by the given \a divisor, i.e. the x and y components are divided by \a divisor. */ QCPVector2D &QCPVector2D::operator/=(double divisor) { mX /= divisor; mY /= divisor; return *this; } /*! Adds the given \a vector to this vector component-wise. */ QCPVector2D &QCPVector2D::operator+=(const QCPVector2D &vector) { mX += vector.mX; mY += vector.mY; return *this; } /*! subtracts the given \a vector from this vector component-wise. */ QCPVector2D &QCPVector2D::operator-=(const QCPVector2D

资源文件列表:

RealTimePlot.zip 大约有17个文件
  1. RealTimePlot/
  2. RealTimePlot/RealTimePlot.pro 1.19KB
  3. RealTimePlot/RealTimePlot.pro.user 23.75KB
  4. RealTimePlot/RealTimePlot.pro.user.392bdac.22 22.21KB
  5. RealTimePlot/image/
  6. RealTimePlot/image/pause.png 16.05KB
  7. RealTimePlot/image/player.png 107.48KB
  8. RealTimePlot/image.qrc 138B
  9. RealTimePlot/main.cpp 183B
  10. RealTimePlot/mainwindow.cpp 1.96KB
  11. RealTimePlot/mainwindow.h 501B
  12. RealTimePlot/mainwindow.ui 853B
  13. RealTimePlot/qcustomplot.cpp 1.25MB
  14. RealTimePlot/qcustomplot.h 301.72KB
  15. RealTimePlot/widgetplot2d.cpp 20.44KB
  16. RealTimePlot/widgetplot2d.h 1.29KB
  17. RealTimePlot/widgetplot2d.ui 10.99KB
0评论
提交 加载更多评论
其他资源 XCP协议的规范文档
XCP协议的原规范文档,主要包含了Part1-5共5个部分,其中第三部分又分为CAN、以太网和Sxl等。对于XCP协议的开发者和学习者有借鉴意义
Webyog SQLyog Ultimate
SQLyog123456
Deep Learning Tuning Playbook(中译版)
由五名研究人员和工程师组成的团队发布了《Deep Learning Tuning Playbook》,来自他们自己训练神经网络的实验结果以及工程师的一些实践建议,目前在Github上已有1.5k星。此版本为中文翻译版,提供给大家免费下载,因为本人知识水平有限,翻译过程中可能有误,随时欢迎大家指出错误,我会随时更正。
jdk1.8 源码( Linux)(1.4, 1.5, 1.6, 1.7都可以用)
jdk1.8 源码, Linux的同学可以用的上. 由于源码JDK是前版本的超集, 所以1.4, 1.5, 1.6, 1.7都可以用的上.
vb纯代码生成二维码源代码,支持低中高容错生成
vb纯代码生成二维码源代码,支持低中高容错生成
STM32F1使用HAL库DMA方式输出PWM例程(输出精确数量且可调周期与占空比)
STM32F1使用HAL库DMA方式输出PWM例程,可以输出精确数量且可调周期与占空比的方波。测试时请结合示波器或逻辑分析仪。本人另外写有一篇与本例程对应的分享文章,链接https://blog.csdn.net/qq_30267617/article/details/109466698,欢迎阅读讨论。 如果本资源下载需要积分了那就是系统擅自改的,我已经改回很多次了,实在没办法了。没有积分的请私聊我发送。
KSVD_for_denosing-master.zip
该资源是ksvd算法的源代码,本人亲测可用。可以先看看我的博客里关于ksvd的那篇文章,再运行代码,效果还是很不错的。
.net SideBar控件下载
第三方控件 SideBar // 命名空间 using Aptech.UI; // 添加组 sbFriends.AddGroup("我的好友"); sbFriends.AddGroup("陌生人"); // 添加项 SbItem item = new SbItem((string)dataReader["NickName"], (int)dataReader["FaceId"]); sbFriends.Groups[0].Items.Add(item);