-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add log axes * Remove dead file * Fix c++ formatting
- Loading branch information
Showing
7 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "logAxis.h" | ||
#include <algorithm> | ||
|
||
#include <cmath> | ||
#include <iostream> | ||
|
||
LogAxis::LogAxis() : Axis() {} | ||
|
||
std::vector<float> LogAxis::convert(QList<double> points) const | ||
{ | ||
std::vector<float> result(points.length()); | ||
|
||
auto min = log(minimum()); | ||
auto max = log(maximum()); | ||
|
||
std::transform(points.begin(), points.end(), result.begin(), | ||
[min, max](const auto x) { return -1.0f + 2 * (log(x) - min) / (max - min); }); | ||
|
||
return result; | ||
} | ||
|
||
double LogAxis::tick(int index, int count) const | ||
{ | ||
auto min = log(minimum()); | ||
auto max = log(maximum()); | ||
|
||
return exp(min + (double)index / ((double)count - 1.0) * (max - min)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "axis.h" | ||
#include "axisTickLabels.h" | ||
#include <QQuick3DGeometry> | ||
#include <QVector3D> | ||
|
||
class LogAxis : public Axis | ||
{ | ||
Q_OBJECT | ||
QML_NAMED_ELEMENT(LogAxis) | ||
|
||
public: | ||
LogAxis(); | ||
std::vector<float> convert(QList<double> values) const override; | ||
double tick(int index, int count) const override; | ||
|
||
Q_SIGNALS: | ||
void dataChanged(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters