-
Notifications
You must be signed in to change notification settings - Fork 65
[ graph ] Tangent toggle functionnality (#156) #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: upsilon-dev
Are you sure you want to change the base?
Changes from all commits
10750b7
380ae81
ca41a01
b27d22f
c5641b4
b3d690e
b1ee05f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,7 @@ GraphView::GraphView(InteractiveCurveViewRange * graphRange, | |
| } | ||
|
|
||
| void GraphView::reload() { | ||
| if (m_tangent) { | ||
| KDRect dirtyZone(KDRect(0, 0, bounds().width(), bounds().height()-m_bannerView->bounds().height())); | ||
| markRectAsDirty(dirtyZone); | ||
| } | ||
| markRectAsDirty(bounds()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you not using the AppsContainer reload function ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you use here the AppsContainer reload function, the app just crash when you enter in the graph mode ... |
||
| return FunctionGraphView::reload(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ TangentGraphController::TangentGraphController(Responder * parentResponder, Grap | |
| m_graphView(graphView), | ||
| m_bannerView(bannerView), | ||
| m_graphRange(curveViewRange), | ||
| m_record() | ||
| m_recordDelegate(nullptr) | ||
| { | ||
| } | ||
|
|
||
|
|
@@ -47,7 +47,7 @@ bool TangentGraphController::textFieldDidFinishEditing(TextField * textField, co | |
| if (myApp->hasUndefinedValue(text, floatBody)) { | ||
| return false; | ||
| } | ||
| ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_record); | ||
| ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_recordDelegate->getRecord()); | ||
| assert(function->plotType() == Shared::ContinuousFunction::PlotType::Cartesian); | ||
| double y = function->evaluate2DAtParameter(floatBody, myApp->localContext()).x2(); | ||
| m_cursor->moveTo(floatBody, floatBody, y); | ||
|
|
@@ -57,25 +57,25 @@ bool TangentGraphController::textFieldDidFinishEditing(TextField * textField, co | |
| return true; | ||
| } | ||
|
|
||
| void TangentGraphController::setRecord(Ion::Storage::Record record) { | ||
| m_graphView->selectRecord(record); | ||
| m_record = record; | ||
| void TangentGraphController::setRecordDelegate(Shared::FunctionActiveFunctionToggle * record) { | ||
| m_graphView->selectRecord(record->getRecord()); | ||
| m_recordDelegate = record; | ||
| } | ||
|
|
||
| void TangentGraphController::reloadBannerView() { | ||
| if (m_record.isNull()) { | ||
| if (m_recordDelegate->getRecord().isNull()) { | ||
| return; | ||
| } | ||
| FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(m_cursor, m_record, Shared::FunctionApp::app()->functionStore(), AppsContainer::sharedAppsContainer()->globalContext()); | ||
| GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(m_cursor, m_record); | ||
| FunctionBannerDelegate::reloadBannerViewForCursorOnFunction(m_cursor, m_recordDelegate->getRecord(), Shared::FunctionApp::app()->functionStore(), AppsContainer::sharedAppsContainer()->globalContext()); | ||
| GraphControllerHelper::reloadDerivativeInBannerViewForCursorOnFunction(m_cursor, m_recordDelegate->getRecord()); | ||
| constexpr size_t bufferSize = FunctionBannerDelegate::k_maxNumberOfCharacters + PrintFloat::charSizeForFloatsWithPrecision(Preferences::LargeNumberOfSignificantDigits); | ||
| char buffer[bufferSize]; | ||
| Poincare::Context * context = textFieldDelegateApp()->localContext(); | ||
|
|
||
| constexpr int precision = Preferences::MediumNumberOfSignificantDigits; | ||
| const char * legend = "a="; | ||
| int legendLength = strlcpy(buffer, legend, bufferSize); | ||
| ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_record); | ||
| ExpiringPointer<ContinuousFunction> function = App::app()->functionStore()->modelForRecord(m_recordDelegate->getRecord()); | ||
| double y = function->approximateDerivative(m_cursor->x(), context); | ||
| PoincareHelpers::ConvertFloatToText<double>(y, buffer + legendLength, bufferSize - legendLength, precision); | ||
| m_bannerView->aView()->setText(buffer); | ||
|
|
@@ -91,7 +91,7 @@ void TangentGraphController::reloadBannerView() { | |
| } | ||
|
|
||
| bool TangentGraphController::moveCursorHorizontally(int direction, int scrollSpeed) { | ||
| return privateMoveCursorHorizontally(m_cursor, direction, m_graphRange, k_numberOfCursorStepsInGradUnit, m_record); | ||
| return privateMoveCursorHorizontally(m_cursor, direction, m_graphRange, k_numberOfCursorStepsInGradUnit, m_recordDelegate->getRecord()); | ||
| } | ||
|
|
||
| bool TangentGraphController::handleEnter() { | ||
|
|
@@ -100,4 +100,31 @@ bool TangentGraphController::handleEnter() { | |
| return true; | ||
| } | ||
|
|
||
| bool TangentGraphController::handleEvent(Ion::Events::Event event) { | ||
| if (event == Ion::Events::Up) { | ||
| m_recordDelegate->moveUp(); | ||
| m_graphView->selectRecord(m_recordDelegate->getRecord()); | ||
| // TODO maybe do: Very ugly workaround... Needs something better to reload the data banner | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you try with the AppsContainer reload function ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup and it's not working (just tried xd). |
||
| moveCursorHorizontally(1); | ||
| moveCursorHorizontally(-1); | ||
|
|
||
| m_graphView->reload(); | ||
| reloadBannerView(); | ||
| viewWillAppear(); | ||
| return true; | ||
| } else if (event == Ion::Events::Down) { | ||
| m_recordDelegate->moveDown(); | ||
| m_graphView->selectRecord(m_recordDelegate->getRecord()); | ||
|
|
||
| moveCursorHorizontally(1); | ||
| moveCursorHorizontally(-1); | ||
|
|
||
| m_graphView->reload(); | ||
| reloadBannerView(); | ||
| viewWillAppear(); | ||
| return true; | ||
| } | ||
| return SimpleInteractiveCurveViewController::handleEvent(event); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #include "function_active_function_toggle.h" | ||
|
|
||
| Ion::Storage::Record Shared::FunctionActiveFunctionToggle::getRecord() { | ||
| if (m_functionStore == nullptr || m_functionStore->numberOfActiveFunctions() <= 0) { | ||
| return Ion::Storage::Record(); | ||
| } | ||
| return m_functionStore->activeRecordAtIndex(m_index); | ||
| } | ||
|
|
||
| void Shared::FunctionActiveFunctionToggle::moveUp() { | ||
| if (m_functionStore == nullptr) { | ||
| return; | ||
| } | ||
| m_index = m_functionStore->numberOfActiveFunctions() <= m_index + 1 ? 0 : m_index + 1; | ||
| } | ||
|
|
||
| void Shared::FunctionActiveFunctionToggle::moveDown() { | ||
| if (m_functionStore == nullptr) { | ||
| return; | ||
| } | ||
| m_index = 0 > m_index - 1 ? m_functionStore->numberOfActiveFunctions() - 1 : m_index - 1; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #ifndef FUNCTION_ACTIVE_FUNCTION_TOGGLE_H | ||
| #define FUNCTION_ACTIVE_FUNCTION_TOGGLE_H | ||
|
|
||
|
|
||
| #include "../../ion/include/ion/storage.h" | ||
| #include "function_store.h" | ||
|
|
||
| namespace Shared { | ||
|
|
||
| class FunctionActiveFunctionToggle { | ||
| public: | ||
| explicit FunctionActiveFunctionToggle(FunctionStore * store) : m_functionStore(store), m_index(0) {} | ||
|
|
||
| Ion::Storage::Record getRecord(); | ||
| void setCurrentIndex(int ni) { m_index = ni; } | ||
| void setFunctionStorePtr(FunctionStore * store) { m_functionStore = store; } | ||
| void moveUp(); | ||
| void moveDown(); | ||
|
|
||
| private: | ||
| FunctionStore * m_functionStore; | ||
| int m_index; | ||
|
|
||
| }; | ||
| } | ||
|
|
||
| #endif //FUNCTION_ACTIVE_FUNCTION_TOGGLE_H |
Uh oh!
There was an error while loading. Please reload this page.