mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps/shared] CurveView: implement CurveView::pixelLength(Axis)
This commit is contained in:
@@ -112,6 +112,10 @@ float CurveView::pixelHeight() const {
|
||||
return (m_curveViewRange->yMax() - m_curveViewRange->yMin()) / (m_frame.height() - 1);
|
||||
}
|
||||
|
||||
float CurveView::pixelLength(Axis axis) const {
|
||||
return axis == Axis::Horizontal ? pixelWidth() : pixelHeight();
|
||||
}
|
||||
|
||||
float CurveView::pixelToFloat(Axis axis, KDCoordinate p) const {
|
||||
return (axis == Axis::Horizontal) ?
|
||||
m_curveViewRange->xMin() + p * pixelWidth() :
|
||||
@@ -140,8 +144,7 @@ float CurveView::floatToPixel(Axis axis, float f) const {
|
||||
}
|
||||
|
||||
float CurveView::floatLengthToPixelLength(Axis axis, float f) const {
|
||||
float pixelLength = axis == Axis::Horizontal ? pixelWidth() : pixelHeight();
|
||||
float dist = f / pixelLength;
|
||||
float dist = f / pixelLength(axis);
|
||||
return clippedFloat(dist);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
void setForceOkDisplay(bool force) { m_forceOkDisplay = force; }
|
||||
float pixelWidth() const;
|
||||
float pixelHeight() const;
|
||||
float pixelLength(Axis axis) const;
|
||||
protected:
|
||||
CurveViewRange * curveViewRange() const { return m_curveViewRange; }
|
||||
void setCurveViewRange(CurveViewRange * curveViewRange);
|
||||
|
||||
Reference in New Issue
Block a user