0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -2,7 +2,7 @@
namespace LimeReport {
void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
void LinesChart::paintChart(QPainter* painter, QRectF chartRect)
{
updateMinAndMaxValues();
@@ -11,64 +11,47 @@ void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
QRectF calcRect = horizontalLabelsRect(
painter,
chartRect.adjusted(
hPadding(chartRect) * 2 + valuesHMargin,
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect)*2),
-(hPadding(chartRect) * 2),
-vPadding(chartRect)
)
);
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
chartRect.height()
- (painter->fontMetrics().height() + vPadding(chartRect) * 2),
-(hPadding(chartRect) * 2), -vPadding(chartRect)));
qreal barsShift = calcRect.height();
paintVerticalGrid(
painter,
chartRect.adjusted(
hPadding(chartRect),
vPadding(chartRect) + valuesVMargin,
-hPadding(chartRect),
-(vPadding(chartRect) + barsShift)
)
);
paintSerialLines(
painter,
chartRect.adjusted(
hPadding(chartRect) * 2 + valuesHMargin,
vPadding(chartRect) + valuesVMargin,
-(hPadding(chartRect) * 2),
-(vPadding(chartRect)+barsShift)
)
);
paintVerticalGrid(painter,
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
-hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
paintSerialLines(painter,
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
vPadding(chartRect) + valuesVMargin,
-(hPadding(chartRect) * 2),
-(vPadding(chartRect) + barsShift)));
paintHorizontalLabels(painter, calcRect);
}
void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect){
for (int i = 0; i < valuesCount()-1; ++i){
QPoint startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i] * vStep
);
QPoint endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i+1] * vStep
);
void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
QRectF barsRect)
{
for (int i = 0; i < valuesCount() - 1; ++i) {
QPoint startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i] * vStep);
QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i + 1] * vStep);
drawSegment(painter, startPoint, endPoint, color_map[0]);
startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i+3] * vStep
);
endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i+3+1] * vStep
);
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i + 3] * vStep);
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i + 3 + 1] * vStep);
drawSegment(painter, startPoint, endPoint, color_map[1]);
startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i+6] * vStep
);
endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
(maxValue() * vStep+topShift) - designValues()[i+6+1] * vStep
);
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i + 6] * vStep);
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep + topShift) - designValues()[i + 6 + 1] * vStep);
drawSegment(painter, startPoint, endPoint, color_map[2]);
}
}
qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize) const
qreal LinesChart::calculatePos(const AxisData& data, qreal value, qreal rectSize) const
{
if (data.type() == AxisData::XAxis || (data.reverseDirection() && data.rangeMin() >= 0)) {
// Not flipping for minimum less than 0 because lower number is at the bottom.
@@ -78,10 +61,10 @@ qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize
}
}
void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect)
void LinesChart::paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect)
{
const AxisData &yAxisData = this->yAxisData();
const AxisData &xAxisData = this->xAxisData();
const AxisData& yAxisData = this->yAxisData();
const AxisData& xAxisData = this->xAxisData();
const qreal xAxisDiff = std::max(1.0, xAxisData.maxValue() - xAxisData.minValue());
const qreal hStep = barsRect.width() / xAxisDiff;
@@ -91,17 +74,17 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
pen.setWidth(4);
painter->setPen(pen);
const QList<qreal> &values = series->data()->values();
const QList<qreal>& values = series->data()->values();
qreal lastYValue = 0;
qreal lastXValue = barsRect.left() + hStep/2;
qreal lastXValue = barsRect.left() + hStep / 2;
if (!values.isEmpty()) {
// Calculate first point position on plot before loop
lastYValue = calculatePos(yAxisData, values.first(), barsRect.height());
}
for (int i = 0; i < values.count()-1; ++i ){
for (int i = 0; i < values.count() - 1; ++i) {
const qreal startY = lastYValue;
const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height());
const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height());
// Record last used Y position to only calculate new one
lastYValue = endY;
@@ -118,13 +101,14 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
{
if (valuesCount() == 0) return;
if (valuesCount() == 0)
return;
painter->save();
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setRenderHint(QPainter::Antialiasing, true);
if (m_chartItem->itemMode() == DesignMode){
const AxisData &yAxisData = this->yAxisData();
if (m_chartItem->itemMode() == DesignMode) {
const AxisData& yAxisData = this->yAxisData();
const qreal delta = yAxisData.delta();
const qreal hStep = barsRect.width() / valuesCount();
const qreal vStep = barsRect.height() / delta;
@@ -134,12 +118,11 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
return;
}
for (SeriesItem *series : m_chartItem->series()) {
for (SeriesItem* series : m_chartItem->series()) {
paintSeries(painter, series, barsRect);
}
painter->restore();
}
} //namespace LimeReport
} // namespace LimeReport