mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps]Make the curve view margins customisable
Change-Id: I7a632ae9ad98ae0b92a2259fa8465c3aecfbf570
This commit is contained in:
@@ -7,9 +7,14 @@
|
||||
|
||||
constexpr KDColor CurveView::k_axisColor;
|
||||
|
||||
CurveView::CurveView(CurveViewWindow * curveViewWindow) :
|
||||
CurveView::CurveView(CurveViewWindow * curveViewWindow, float topMarginFactor,
|
||||
float rightMarginFactor, float bottomMarginFactor, float leftMarginFactor) :
|
||||
View(),
|
||||
m_curveViewWindow(curveViewWindow)
|
||||
m_curveViewWindow(curveViewWindow),
|
||||
m_topMarginFactor(topMarginFactor),
|
||||
m_bottomMarginFactor(bottomMarginFactor),
|
||||
m_leftMarginFactor(leftMarginFactor),
|
||||
m_rightMarginFactor(rightMarginFactor)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,15 +29,17 @@ void CurveView::reload() {
|
||||
float CurveView::min(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
float range = axis == Axis::Horizontal ? m_curveViewWindow->xMax() - m_curveViewWindow->xMin() : m_curveViewWindow->yMax() - m_curveViewWindow->yMin();
|
||||
float absoluteMin = (axis == Axis::Horizontal ? m_curveViewWindow->xMin(): m_curveViewWindow->yMin());
|
||||
return absoluteMin - k_marginFactor*range;
|
||||
float absoluteMin = axis == Axis::Horizontal ? m_curveViewWindow->xMin(): m_curveViewWindow->yMin();
|
||||
float marginFactor = axis == Axis::Horizontal ? m_leftMarginFactor : m_bottomMarginFactor;
|
||||
return absoluteMin - marginFactor*range;
|
||||
}
|
||||
|
||||
float CurveView::max(Axis axis) const {
|
||||
assert(axis == Axis::Horizontal || axis == Axis::Vertical);
|
||||
float range = axis == Axis::Horizontal ? m_curveViewWindow->xMax() - m_curveViewWindow->xMin() : m_curveViewWindow->yMax() - m_curveViewWindow->yMin();
|
||||
float absoluteMax = (axis == Axis::Horizontal ? m_curveViewWindow->xMax() : m_curveViewWindow->yMax());
|
||||
return absoluteMax + k_marginFactor*range;
|
||||
float marginFactor = axis == Axis::Horizontal ? m_rightMarginFactor : m_topMarginFactor;
|
||||
return absoluteMax + marginFactor*range;
|
||||
}
|
||||
|
||||
float CurveView::gridUnit(Axis axis) const {
|
||||
|
||||
@@ -13,7 +13,8 @@ public:
|
||||
Horizontal = 0,
|
||||
Vertical = 1
|
||||
};
|
||||
CurveView(CurveViewWindow * curveViewWindow = nullptr);
|
||||
CurveView(CurveViewWindow * curveViewWindow = nullptr, float topMarginFactor = 0.0f,
|
||||
float rightMarginFactor = 0.0f, float bottomMarginFactor = 0.0f, float leftMarginFactor = 0.0f);
|
||||
void reload();
|
||||
protected:
|
||||
constexpr static KDColor k_axisColor = KDColor::RGB24(0x000000);
|
||||
@@ -42,7 +43,6 @@ protected:
|
||||
void computeLabels(Axis axis);
|
||||
void drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOrigin) const;
|
||||
private:
|
||||
constexpr static float k_marginFactor = 0.2f;
|
||||
int numberOfLabels(Axis axis) const;
|
||||
virtual float evaluateModelWithParameter(Model * curve, float t) const;
|
||||
/* Recursively join two dots (dichotomy). The method stops when the
|
||||
@@ -55,6 +55,10 @@ private:
|
||||
* anti alising. */
|
||||
void stampAtLocation(KDContext * ctx, KDRect rect, float pxf, float pyf, KDColor color) const;
|
||||
CurveViewWindow * m_curveViewWindow;
|
||||
float m_topMarginFactor;
|
||||
float m_bottomMarginFactor;
|
||||
float m_leftMarginFactor;
|
||||
float m_rightMarginFactor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Probability {
|
||||
|
||||
LawCurveView::LawCurveView() :
|
||||
CurveView(),
|
||||
CurveView(nullptr, 0.2f, 0.1f, 0.2f, 0.1f),
|
||||
m_law(nullptr),
|
||||
m_calculation(nullptr)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Statistics {
|
||||
|
||||
BoxView::BoxView(Data * data) :
|
||||
CurveView(&m_boxWindow),
|
||||
CurveView(&m_boxWindow, 0.0f, 0.2f, 0.4f, 0.2f),
|
||||
m_data(data),
|
||||
m_boxWindow(BoxWindow(data)),
|
||||
m_anyQuantileSelected(true),
|
||||
|
||||
@@ -145,7 +145,7 @@ float Data::xMax() {
|
||||
}
|
||||
|
||||
float Data::yMin() {
|
||||
return -k_marginFactor*m_yMax;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float Data::yMax() {
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
constexpr static int k_maxNumberOfPairs = 500;
|
||||
private:
|
||||
constexpr static int k_maxNumberOfBarsPerWindow = 300;
|
||||
constexpr static float k_marginFactor = 0.2f;
|
||||
float sumOfValuesBetween(float x1, float x2);
|
||||
bool scrollToSelectedBar();
|
||||
void initBarParameters();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Statistics {
|
||||
|
||||
HistogramView::HistogramView(Data * data) :
|
||||
CurveView(data),
|
||||
CurveView(data, 0.2f, 0.1f, 0.4f, 0.1f),
|
||||
m_data(data),
|
||||
m_selectedBins(true),
|
||||
m_bannerView(BannerView(data))
|
||||
|
||||
Reference in New Issue
Block a user