173 lines
3.3 KiB
C++
173 lines
3.3 KiB
C++
#include "wavyline.hpp"
|
|
#include "wavylinerenderer.hpp"
|
|
|
|
namespace ZShell::controls {
|
|
|
|
WavyLine::WavyLine(QQuickItem* parent)
|
|
: QCanvasPainterItem(parent)
|
|
, m_lineWidth(4)
|
|
, m_amplitudeMultiplier(0.5)
|
|
, m_frequency(6)
|
|
, m_startX(0)
|
|
, m_fullLength(0)
|
|
, m_color(Qt::white)
|
|
, m_waveProgress(0)
|
|
, m_pathType(Linear)
|
|
, m_startAngle(0)
|
|
, m_fullAngle(360)
|
|
, m_radius(-1)
|
|
, m_value(1) {
|
|
setFillColor(Qt::transparent);
|
|
setAlphaBlending(true);
|
|
}
|
|
|
|
QCanvasPainterItemRenderer* WavyLine::createItemRenderer() const {
|
|
return new WavyLineRenderer;
|
|
}
|
|
|
|
int WavyLine::lineWidth() const {
|
|
return m_lineWidth;
|
|
}
|
|
|
|
void WavyLine::setLineWidth(int lineWidth) {
|
|
if (m_lineWidth != lineWidth) {
|
|
m_lineWidth = lineWidth;
|
|
emit lineWidthChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::amplitudeMultiplier() const {
|
|
return m_amplitudeMultiplier;
|
|
}
|
|
|
|
void WavyLine::setAmplitudeMultiplier(qreal amplitudeMultiplier) {
|
|
if (!qFuzzyCompare(m_amplitudeMultiplier + 1.0, amplitudeMultiplier + 1.0)) {
|
|
m_amplitudeMultiplier = amplitudeMultiplier;
|
|
emit amplitudeMultiplierChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
int WavyLine::frequency() const {
|
|
return m_frequency;
|
|
}
|
|
|
|
void WavyLine::setFrequency(int frequency) {
|
|
if (m_frequency != frequency) {
|
|
m_frequency = frequency;
|
|
emit frequencyChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::startX() const {
|
|
return m_startX;
|
|
}
|
|
|
|
void WavyLine::setStartX(qreal startX) {
|
|
if (!qFuzzyCompare(m_startX + 1.0, startX + 1.0)) {
|
|
m_startX = startX;
|
|
emit startXChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::fullLength() const {
|
|
return m_fullLength;
|
|
}
|
|
|
|
void WavyLine::setFullLength(qreal fullLength) {
|
|
if (!qFuzzyCompare(m_fullLength + 1.0, fullLength + 1.0)) {
|
|
m_fullLength = fullLength;
|
|
emit fullLengthChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
QColor WavyLine::color() const {
|
|
return m_color;
|
|
}
|
|
|
|
void WavyLine::setColor(const QColor& color) {
|
|
if (m_color != color) {
|
|
m_color = color;
|
|
emit colorChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::waveProgress() const {
|
|
return m_waveProgress;
|
|
}
|
|
|
|
void WavyLine::setWaveProgress(qreal progress) {
|
|
if (!qFuzzyCompare(m_waveProgress + 1.0, progress + 1.0)) {
|
|
m_waveProgress = progress;
|
|
emit waveProgressChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
WavyLine::PathType WavyLine::pathType() const {
|
|
return m_pathType;
|
|
}
|
|
|
|
void WavyLine::setPathType(PathType pathType) {
|
|
if (m_pathType != pathType) {
|
|
m_pathType = pathType;
|
|
emit pathTypeChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::startAngle() const {
|
|
return m_startAngle;
|
|
}
|
|
|
|
void WavyLine::setStartAngle(qreal startAngle) {
|
|
if (!qFuzzyCompare(m_startAngle + 1.0, startAngle + 1.0)) {
|
|
m_startAngle = startAngle;
|
|
emit startAngleChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::fullAngle() const {
|
|
return m_fullAngle;
|
|
}
|
|
|
|
void WavyLine::setFullAngle(qreal fullAngle) {
|
|
if (!qFuzzyCompare(m_fullAngle + 1.0, fullAngle + 1.0)) {
|
|
m_fullAngle = fullAngle;
|
|
emit fullAngleChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::radius() const {
|
|
return m_radius;
|
|
}
|
|
|
|
void WavyLine::setRadius(qreal radius) {
|
|
if (!qFuzzyCompare(m_radius + 1.0, radius + 1.0)) {
|
|
m_radius = radius;
|
|
emit radiusChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
qreal WavyLine::value() const {
|
|
return m_value;
|
|
}
|
|
|
|
void WavyLine::setValue(qreal value) {
|
|
if (!qFuzzyCompare(m_value + 1.0, value + 1.0)) {
|
|
m_value = value;
|
|
emit valueChanged();
|
|
update();
|
|
}
|
|
}
|
|
|
|
} // namespace ZShell::controls
|