/***************************************************************************
** **
** QCustomPlot, an easy to use, modern plotting widget for Qt **
** Copyright (C) 2011-2022 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: https://www.qcustomplot.com/ **
** Date: 06.11.22 **
** Version: 2.1.1 **
****************************************************************************/
#include "qcustomplot.h"
/* including file 'src/vector2d.cpp' */
/* modified 2022-11-06T12:45:56, 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
没有合适的资源?快使用搜索试试~ 我知道了~
qt使用QCustomplot绘制cpu和内存使用率图
共1093个文件
idx:1056个
o:8个
cpp:8个
需积分: 5 8 下载量 163 浏览量
2023-09-07
09:06:19
上传
评论 1
收藏 17.75MB ZIP 举报
温馨提示
qt使用QCustomplot绘制cpu和内存使用率图,具体实现方法参考我的博客。
资源推荐
资源详情
资源评论
收起资源包目录
qt使用QCustomplot绘制cpu和内存使用率图 (1093个子文件)
qcustomplot.cpp 1.25MB
moc_qcustomplot.cpp 424KB
qrc_image.cpp 16KB
systemStatisticsWidget.cpp 8KB
moc_mainwindow.cpp 5KB
moc_systemStatisticsWidget.cpp 5KB
mainwindow.cpp 1KB
main.cpp 183B
Makefile.Debug 275KB
systemStatistics.exe 21.86MB
qcustomplot.h 303KB
moc_predefs.h 16KB
ui_systemStatisticsWidget.h 11KB
systemStatisticsWidget.h 4KB
ui_mainwindow.h 3KB
mainwindow.h 600B
qcustomplot.h.951B2D2CAFFA12BC.idx 815KB
qcustomplot.cpp.5DF36CB43BC30037.idx 650KB
qopenglext.h.54A6B2FFA43C15C2.idx 563KB
winuser.h.98B6CAB35EB38A8F.idx 390KB
winnt.h.9F779E8602C047DE.idx 317KB
random.tcc.7971F1A29E908C96.idx 312KB
wingdi.h.B1CADC176823C03A.idx 303KB
wincrypt.h.8A453F946C6079DC.idx 273KB
winbase.h.BFEC55DE7D8919D3.idx 235KB
random.h.D36A91656DF932AC.idx 211KB
mmsystem.h.8EC60380FC50DA67.idx 177KB
urlmon.h.84FED06CA988EE4C.idx 164KB
qnamespace.h.7C6818AD7A3ED5CA.idx 150KB
emmintrin.h.69755A2E4667BC52.idx 149KB
avx512fintrin.h.79FA3EBB0B55F511.idx 142KB
qmetatype.h.9F06D0172F5E0AC8.idx 141KB
msxml.h.BB1A7539E5C69CD5.idx 139KB
avx512vlintrin.h.ECE84EA4DE64D994.idx 138KB
avxintrin.h.A949A5AC114DCCBA.idx 120KB
qhash.h.A3B09F617027F9AD.idx 112KB
winioctl.h.69703D76B15962D3.idx 109KB
qopenglextrafunctions.h.C2856A7536B13FDD.idx 107KB
oaidl.h.173129361AABC6B9.idx 107KB
stl_algo.h.8DEB79B9F8F9B858.idx 106KB
winspool.h.128E89DA19BFF099.idx 104KB
qstring.h.D3346C37FE10574E.idx 98KB
objidl.h.9270B9CF8B01C83D.idx 96KB
oleauto.h.A0B5C90790AD7FF9.idx 95KB
gl.h.0D8A5CB00158D226.idx 90KB
winerror.h.57012C7AAF3C2F35.idx 89KB
qlocale.h.C697EDF48724BE0C.idx 89KB
qproperty.h.5019B45BED623018.idx 86KB
xmmintrin.h.364A73AC0B6B44A1.idx 84KB
qvarlengtharray.h.1DA7381A42B6E83D.idx 73KB
locale_facets_nonio.tcc.4C8EDAB705010807.idx 71KB
locale_facets.tcc.362421E549A1C498.idx 70KB
basic_string.h.5FFA785B849B0B4E.idx 70KB
qopenglfunctions.h.43184069B230DBEE.idx 69KB
qlist.h.5A457E4EDEDD9E89.idx 68KB
winnls.h.BFF1C488AC77427E.idx 68KB
qmap.h.F9B1800BD779787C.idx 68KB
objidlbase.h.402033CC383AE8FC.idx 68KB
stl_tree.h.81C26C86BF0FFE88.idx 67KB
qgraphicsitem.h.71BC01C98E206E43.idx 65KB
qstyleoption.h.26C4E1F0666A8A68.idx 65KB
qtextformat.h.2C2A772E12CF3685.idx 63KB
avx512vlbwintrin.h.F2EFD460E41928F4.idx 62KB
qstyle.h.9D30FFBC700A1DD9.idx 61KB
qevent.h.D4AD37137AEE701C.idx 61KB
qflags.h.D3ED76311C9EB460.idx 61KB
qcontiguouscache.h.4A33EAC2952ED0CB.idx 60KB
rpcndr.h.AEA422E9883C7F6C.idx 60KB
limits.3FEFE72336147264.idx 57KB
oleidl.h.FF03B539A71D5FBD.idx 55KB
avx512fp16intrin.h.6E81DEC3D9BB6AAF.idx 54KB
rpcdce.h.2D5F7587BDAF3E8C.idx 53KB
qdebug.h.38CB33ABAE3F83CD.idx 49KB
mmintrin.h.67900D68C1AF29C2.idx 48KB
securitybaseapi.h.3C1F6E649A3E49D2.idx 46KB
qgenericmatrix.h.CDCBAEA5B3503374.idx 45KB
qendian.h.3B7E93E67CFF4FB2.idx 45KB
shellapi.h.CF26237325CC5780.idx 45KB
wchar.h.7DA29A93B7213F00.idx 44KB
type_traits.25F355BAEDFD44E5.idx 44KB
qchar.h.4190798CBCE77106.idx 43KB
commdlg.h.8666B0CD33560886.idx 43KB
basic_string.tcc.0829788A5DE74ACC.idx 42KB
winreg.h.AB88901CFF42C57A.idx 42KB
qwidget.h.BBE521C012E49003.idx 42KB
winscard.h.CCC956EFA78D10B3.idx 41KB
avx512vlfp16intrin.h.8D4491FF04651DD4.idx 41KB
qsharedpointer_impl.h.8F2701D201275D36.idx 39KB
qbytearray.h.C4B6E4A9FAC662F7.idx 39KB
qstringbuilder.h.3033EA80AFA6B18C.idx 38KB
bcrypt.h.0B9B98ADE86ECEAF.idx 38KB
winsvc.h.EA0E03AEBE25F873.idx 38KB
qcolor.h.04C3DB90797EDF03.idx 37KB
stl_list.h.96226B8B74F3FDA4.idx 37KB
atomic.0F2D1D3A9E555BA1.idx 37KB
avx512bwintrin.h.86915310FEB6F8EC.idx 37KB
qvectornd.h.1FA3FD3FF147B6E4.idx 36KB
stl_algobase.h.AB597E6DAC4746DB.idx 36KB
qpainter.h.21B448A50DF534D2.idx 36KB
qfuture_impl.h.ECA7912255BFC85F.idx 36KB
共 1093 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
小灰灰搞电子
- 粉丝: 3w+
- 资源: 108
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功