mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 19:49:58 +02:00
Merge "[apps/sequence] Draw term sum in graph view"
This commit is contained in:
@@ -19,6 +19,7 @@ void GraphController::viewWillAppear() {
|
||||
m_view.setVerticalCursor(false);
|
||||
m_view.setCursorView(&m_cursorView);
|
||||
m_view.setBannerView(&m_bannerView);
|
||||
m_view.setHighlight(-1.0f, -1.0f);
|
||||
FunctionGraphController::viewWillAppear();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,11 @@ GraphView::GraphView(SequenceStore * sequenceStore, InteractiveCurveViewRange *
|
||||
CurveViewCursor * cursor, BannerView * bannerView, View * cursorView) :
|
||||
FunctionGraphView(graphRange, cursor, bannerView, cursorView),
|
||||
m_sequenceStore(sequenceStore),
|
||||
m_verticalCursor(false)
|
||||
m_verticalCursor(false),
|
||||
m_highlightedDotStart(-1),
|
||||
m_highlightedDotEnd(-1),
|
||||
m_highlightColor(false),
|
||||
m_selectedSequence(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,6 +28,14 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
continue;
|
||||
}
|
||||
drawDot(ctx, rect, x, y, s->color());
|
||||
if (x >= m_highlightedDotStart && x <= m_highlightedDotEnd && s == m_selectedSequence) {
|
||||
KDColor color = m_highlightColor ? s->color() : KDColorBlack;
|
||||
if (y >= 0.0f) {
|
||||
drawSegment(ctx, rect, Axis::Vertical, x, 0.0f, y, color, 1);
|
||||
} else {
|
||||
drawSegment(ctx, rect, Axis::Vertical, x, y, 0.0f, color, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +44,36 @@ void GraphView::setVerticalCursor(bool verticalCursor) {
|
||||
m_verticalCursor = verticalCursor;
|
||||
}
|
||||
|
||||
void GraphView::reload() {
|
||||
FunctionGraphView::reload();
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
void GraphView::selectSequence(Sequence * sequence) {
|
||||
if (m_selectedSequence != sequence) {
|
||||
reload();
|
||||
m_selectedSequence = sequence;
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::setHighlight(int start, int end) {
|
||||
if (m_highlightedDotStart != start || m_highlightedDotEnd != end) {
|
||||
reload();
|
||||
m_highlightedDotStart = start;
|
||||
m_highlightedDotEnd = end;
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::setHighlightColor(bool highlightColor) {
|
||||
if (m_highlightColor != highlightColor) {
|
||||
reload();
|
||||
m_highlightColor = highlightColor;
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
float GraphView::evaluateModelWithParameter(Model * curve, float abscissa) const {
|
||||
Sequence * s = (Sequence *)curve;
|
||||
return s->evaluateAtAbscissa(abscissa, context());
|
||||
|
||||
@@ -12,11 +12,19 @@ public:
|
||||
Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, View * cursorView);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setVerticalCursor(bool verticalCursor);
|
||||
void reload() override;
|
||||
void selectSequence(Sequence * sequence);
|
||||
void setHighlight(int start, int end);
|
||||
void setHighlightColor(bool highlightColor);
|
||||
private:
|
||||
float evaluateModelWithParameter(Model * expression, float abscissa) const override;
|
||||
KDSize cursorSize() override;
|
||||
SequenceStore * m_sequenceStore;
|
||||
bool m_verticalCursor;
|
||||
int m_highlightedDotStart;
|
||||
int m_highlightedDotEnd;
|
||||
bool m_highlightColor;
|
||||
Sequence * m_selectedSequence;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ void TermSumController::viewWillAppear() {
|
||||
m_contentView.graphView()->setCursorView(&m_cursorView);
|
||||
m_contentView.graphView()->setBannerView(nullptr);
|
||||
m_contentView.graphView()->selectMainView(true);
|
||||
m_contentView.graphView()->setHighlightColor(false);
|
||||
m_contentView.graphView()->setHighlight(-1.0f,-1.0f);
|
||||
m_contentView.graphView()->reload();
|
||||
m_contentView.layoutSubviews();
|
||||
|
||||
@@ -101,6 +103,8 @@ bool TermSumController::handleEvent(Ion::Events::Event event) {
|
||||
TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app();
|
||||
float sum = m_sequence->sumOfTermsBetweenAbscissa(m_startSum, m_endSum, myApp->localContext());
|
||||
Complex::convertFloatToText(sum, buffer+2, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
|
||||
m_contentView.graphView()->setHighlightColor(true);
|
||||
m_contentView.graphView()->selectMainView(false);
|
||||
m_contentView.legendView()->setLegendText(buffer);
|
||||
}
|
||||
return false;
|
||||
@@ -121,6 +125,7 @@ bool TermSumController::moveCursorHorizontallyToPosition(int position) {
|
||||
m_contentView.legendView()->setSumSubscript(m_cursor->x());
|
||||
}
|
||||
if (m_step == 1) {
|
||||
m_contentView.graphView()->setHighlight(m_startSum, m_cursor->x());
|
||||
m_contentView.legendView()->setSumSuperscript(m_startSum, m_cursor->x());
|
||||
}
|
||||
m_graphRange->panToMakePointVisible(x, y, k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
@@ -128,6 +133,7 @@ bool TermSumController::moveCursorHorizontallyToPosition(int position) {
|
||||
}
|
||||
|
||||
void TermSumController::setSequence(Sequence * sequence) {
|
||||
m_contentView.graphView()->selectSequence(sequence);
|
||||
m_sequence = sequence;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user