mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[shared] Keep graph units when using navigation
When using the Navigate menu on graphs, the grid units are computed using the normal graph's range, so that the units won't change. Change-Id: I8ff8853868e5c90319619a6271d6a7d87ae82ab0
This commit is contained in:
committed by
LeaNumworks
parent
80f3af389f
commit
4233f197d3
@@ -24,7 +24,7 @@ public:
|
||||
return computeGridUnit(k_minNumberOfXGridUnits, k_maxNumberOfXGridUnits, xMax() - xMin());
|
||||
}
|
||||
virtual float yGridUnit() const {
|
||||
return computeGridUnit(k_minNumberOfYGridUnits, k_maxNumberOfYGridUnits, yMax() - yMin());
|
||||
return computeGridUnit(k_minNumberOfYGridUnits, k_maxNumberOfYGridUnits, yMax() - yMin() + offscreenYAxis());
|
||||
}
|
||||
constexpr static float k_maxNumberOfXGridUnits = 18.0f;
|
||||
constexpr static float k_maxNumberOfYGridUnits = 13.0f;
|
||||
@@ -32,6 +32,7 @@ protected:
|
||||
constexpr static float k_minNumberOfXGridUnits = 7.0f;
|
||||
constexpr static float k_minNumberOfYGridUnits = 5.0f;
|
||||
private:
|
||||
virtual float offscreenYAxis() const { return 0.f; }
|
||||
/* The grid units is constrained to be a number of type: k*10^n with k = 1,2 or 5
|
||||
* and n a relative integer. The choice of x and y grid units depend on the
|
||||
* grid range.*/
|
||||
|
||||
@@ -37,9 +37,12 @@ void FunctionZoomAndPanCurveViewController::adaptCurveRange(bool viewWillAppear)
|
||||
float currentRange = m_interactiveRange->yMax() - m_interactiveRange->yMin();
|
||||
float newYMin = 0;
|
||||
if (viewWillAppear) {
|
||||
newYMin = currentYMin + ((float)ContentView::k_legendHeight)/((float)k_standardViewHeight)*currentRange;
|
||||
float rangeOffscreen = ((float)ContentView::k_legendHeight)/((float)k_standardViewHeight)*currentRange;
|
||||
newYMin = currentYMin + rangeOffscreen;
|
||||
m_interactiveRange->setOffscreenYAxis(rangeOffscreen);
|
||||
} else {
|
||||
newYMin = m_interactiveRange->yMax() - currentRange*((float)k_standardViewHeight)/(((float)k_standardViewHeight)-((float)ContentView::k_legendHeight));
|
||||
m_interactiveRange->setOffscreenYAxis(0.f);
|
||||
}
|
||||
m_interactiveRange->setYMin(newYMin);
|
||||
m_contentView.curveView()->reload();
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void setYMin(float f) override;
|
||||
void setYMax(float f) override;
|
||||
|
||||
void setOffscreenYAxis(float f) { m_offscreenYAxis = f; }
|
||||
|
||||
// Window
|
||||
void zoom(float ratio, float x, float y);
|
||||
void panWithVector(float x, float y);
|
||||
@@ -77,6 +79,9 @@ protected:
|
||||
constexpr static float NormalizedYHalfRange(float unit) { return 3.06f * unit; }
|
||||
InteractiveCurveViewRangeDelegate * m_delegate;
|
||||
private:
|
||||
float offscreenYAxis() const override { return m_offscreenYAxis; }
|
||||
|
||||
float m_offscreenYAxis;
|
||||
bool m_zoomAuto;
|
||||
bool m_zoomNormalize;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user