-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Key graph features #704
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
Merged
sanderl
merged 46 commits into
microsoft:feature/GraphingCalculator
from
sanderl:key-graph-features
Nov 12, 2019
Merged
Key graph features #704
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
530f2bc
Added IGraphAnalyzer
sanderl e23796a
Merged with feature/GraphingCalculator
sanderl 39809f8
Key Graph Features called and getting returned to the client. To do p…
sanderl e571935
Updated UpdateKeyGraphFeatures to add function analysis data to all p…
sanderl 2c9dfef
Update KGF when variables are updated
sanderl 900b9e8
Key graph features ui started
sanderl 85fedd9
Merge with feature/GraphingCalculator
sanderl 9670254
Added MathRichEditBox and started hooking up key graph features to th…
sanderl 21948ce
Updated EquationViewModel to include parity and periodicity
sanderl 16060bd
Updated key graph features to update the EquationViewModel
sanderl 93dc298
merged with feature graphing calculator and updated rich edit box to …
sanderl 024702c
updated key graph features to display more values
sanderl d147d0f
Key graph features populating uing MathRichEdit mode
sanderl 25bd16b
merged with feature/GraphingCalculator
sanderl 0f5f013
moved KeyGraphFeatures control to GraphingCalculator.xaml
sanderl 6d42c67
Use MathML formatting instead of MathRichEdit for strings passed back…
sanderl b7bc9c1
cleaned up project targeting and equation.h comments
sanderl 4cd7878
Updated equation edit box to populate for KeyGraphFeatures
sanderl 3e7693d
Fixed vcxproj files to have the correct targeting and certificates. K…
sanderl ebcb14a
Updated per PR feedback
sanderl a0c27d5
Update MathRichEditBox to detect if the string is a mathml string and…
sanderl 14d470b
fixed the issue where parity, periodicity and monotonicity could be s…
sanderl 0523a7a
updated key graph features edit box to populate with the correct expr…
sanderl 27f8a55
KGF control UI adjustments and error handling
sanderl b027291
Error control updates
sanderl cd3d63f
Error handling added when analysis fails
sanderl cc2b687
fixed alignment on rich edit boxes
sanderl 243a696
Add monotonicity direction into the mathml string and only have 1 ric…
sanderl 5cd8bd5
Set hover state on KGF EquationEditBox to change button opacity and f…
sanderl e7daa84
remove sideload package certificate info VS added
sanderl 35f1ff2
updated logic for setting error strings to be in the viewmodel
sanderl 0608945
Updated KeyGraphFeatures to populate dynamically using a ListView and…
sanderl 9cd5d20
Update periodicity to not show if it isn't supported
sanderl 23375b4
Fixed issue where y-intercept was using the x-intercept value
sanderl 1dde387
Remove ItemsControl ItemsContainerStyle
sanderl 3d60ace
Updated per pr feedback. Fixed bug where analysis error would not reset
sanderl 49a069b
Update MathRichEdit box to remove selection when focus is lost
sanderl 01d23a3
Updated mathrichedit to get LAF access for Dev, Release and Graphing …
sanderl a6c074b
Remove OnLostFocus in MathRichEdit, Change KGF ItemsControl back to L…
sanderl d9f02a9
Clean up styles for KGF and ensure the match the comps
sanderl dbb70a9
Moved formatoptions logic to the Grapher constructor and reverted Lin…
sanderl 6cbf3f6
Add copyright header to KGF Files
sanderl 95c37b4
fixed issue where asymptote values were not populating
sanderl 00231a7
Disable KGF button when there is no equation. Fixed issue where equat…
sanderl f785e6e
Removed formatoptions testing lines used for debugging
sanderl 55f6b1c
Merge branch 'feature/GraphingCalculator' into key-graph-features
sanderl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
312 changes: 311 additions & 1 deletion
312
src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,324 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #include "pch.h" | ||
| #include "EquationViewModel.h" | ||
| #include "CalcViewModel\Common\LocalizationSettings.h" | ||
| #include "CalcViewModel\GraphingCalculatorEnums.h" | ||
|
|
||
| using namespace CalculatorApp::Common; | ||
| using namespace Graphing; | ||
| using namespace Platform; | ||
| using namespace Platform::Collections; | ||
| using namespace std; | ||
| using namespace Windows::UI; | ||
| using namespace Windows::UI::Xaml; | ||
| using namespace Windows::Foundation::Collections; | ||
|
|
||
| namespace CalculatorApp::ViewModel | ||
| { | ||
| GridDisplayItems::GridDisplayItems() | ||
| : m_Expression{ "" } | ||
| , m_Direction{ "" } | ||
| { | ||
| } | ||
|
|
||
| KeyGraphFeaturesItem::KeyGraphFeaturesItem() | ||
| : m_Title{ "" } | ||
| , m_DisplayItems{ ref new Vector<String ^>() } | ||
| , m_GridItems{ ref new Vector<GridDisplayItems ^>() } | ||
| , m_IsText{ false } | ||
| { | ||
| } | ||
|
|
||
| EquationViewModel::EquationViewModel() | ||
| : m_LineColor{ nullptr }, m_KeyGraphFeaturesVisibility{ ::Visibility::Collapsed } | ||
| : m_LineColor{ nullptr } | ||
| , m_Expression{ "" } | ||
| , m_IsAnalysisUpdated{ false } | ||
| , m_Domain{ "" } | ||
| , m_Range{ "" } | ||
| , m_XIntercept{ "" } | ||
| , m_YIntercept{ "" } | ||
| , m_Parity{ -1 } | ||
| , m_PeriodicityDirection{ -1 } | ||
| , m_PeriodicityExpression{ "" } | ||
| , m_Minima{ ref new Vector<String ^>() } | ||
| , m_Maxima{ ref new Vector<String ^>() } | ||
| , m_InflectionPoints{ ref new Vector<String ^>() } | ||
| , m_Monotonicity{ ref new Map<String ^, String ^>() } | ||
| , m_VerticalAsymptotes{ ref new Vector<String ^>() } | ||
| , m_HorizontalAsymptotes{ ref new Vector<String ^>() } | ||
| , m_ObliqueAsymptotes{ ref new Vector<String ^>() } | ||
| , m_TooComplexFeatures{ -1 } | ||
| , m_AnalysisError{ 0 } | ||
| , m_AnalysisErrorVisible{ false } | ||
| , m_KeyGraphFeaturesItems{ ref new Vector<KeyGraphFeaturesItem ^>() } | ||
| , m_resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() } | ||
| { | ||
| } | ||
|
|
||
| void EquationViewModel::OnPropertyChanged(String ^ propertyName) | ||
| { | ||
| if (propertyName == L"IsAnalysisUpdated") | ||
| { | ||
| OnIsAnalysisUpdatedChanged(); | ||
| } | ||
| } | ||
|
|
||
| void EquationViewModel::OnIsAnalysisUpdatedChanged() | ||
| { | ||
| if (IsAnalysisUpdated) | ||
| { | ||
| if (AnalysisError != 0) | ||
| { | ||
| AnalysisErrorVisible = true; | ||
| if (AnalysisError == static_cast<int>(AnalysisErrorType::AnalysisCouldNotBePerformed)) | ||
| { | ||
| AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisCouldNotBePerformed"); | ||
| } | ||
| else if (AnalysisError == static_cast<int>(AnalysisErrorType::AnalysisNotSupported)) | ||
| { | ||
| AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported"); | ||
| } | ||
| return; | ||
| } | ||
| KeyGraphFeaturesItems->Clear(); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Domain"), Domain, m_resourceLoader->GetString(L"KGFDomainNone")); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Range"), Range, m_resourceLoader->GetString(L"KGFRangeNone")); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"XIntercept"), XIntercept, m_resourceLoader->GetString(L"KGFXInterceptNone")); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"YIntercept"), YIntercept, m_resourceLoader->GetString(L"KGFYInterceptNone")); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Minima"), Minima, m_resourceLoader->GetString(L"KGFMinimaNone")); | ||
| SetKeyGraphFeaturesItems(m_resourceLoader->GetString(L"Maxima"), Maxima, m_resourceLoader->GetString(L"KGFMaximaNone")); | ||
| SetKeyGraphFeaturesItems( | ||
| m_resourceLoader->GetString(L"InflectionPoints"), InflectionPoints, m_resourceLoader->GetString(L"KGFInflectionPointsNone")); | ||
| SetKeyGraphFeaturesItems( | ||
| m_resourceLoader->GetString(L"VerticalAsymptotes"), VerticalAsymptotes, m_resourceLoader->GetString(L"KGFVerticalAsymptotesNone")); | ||
| SetKeyGraphFeaturesItems( | ||
| m_resourceLoader->GetString(L"HorizontalAsymptotes"), HorizontalAsymptotes, m_resourceLoader->GetString(L"KGFHorizontalAsymptotesNone")); | ||
| SetKeyGraphFeaturesItems( | ||
| m_resourceLoader->GetString(L"ObliqueAsymptotes"), ObliqueAsymptotes, m_resourceLoader->GetString(L"KGFObliqueAsymptotesNone")); | ||
| SetParityStringProperty(); | ||
| SetPeriodicityStringProperty(); | ||
| SetMonotoncityStringProperty(); | ||
| SetTooComplexFeaturesErrorProperty(); | ||
|
|
||
| AnalysisErrorVisible = false; | ||
| IsAnalysisUpdated = false; | ||
| } | ||
| } | ||
|
|
||
| void EquationViewModel::SetKeyGraphFeaturesItems(String ^ title, String ^ expression, String ^ errorString) | ||
| { | ||
| KeyGraphFeaturesItem ^ item = ref new KeyGraphFeaturesItem(); | ||
| item->Title = title; | ||
| if (expression != L"") | ||
| { | ||
| item->DisplayItems->Append(expression); | ||
| item->IsText = false; | ||
| } | ||
| else | ||
| { | ||
| item->DisplayItems->Append(errorString); | ||
| item->IsText = true; | ||
| } | ||
| KeyGraphFeaturesItems->Append(item); | ||
| } | ||
|
|
||
| void EquationViewModel::SetKeyGraphFeaturesItems(String ^ title, IObservableVector<String ^> ^ expressionVector, String ^ errorString) | ||
| { | ||
| KeyGraphFeaturesItem ^ item = ref new KeyGraphFeaturesItem(); | ||
| item->Title = title; | ||
| if (expressionVector->Size != 0) | ||
| { | ||
| for (auto expression : expressionVector) | ||
| { | ||
| item->DisplayItems->Append(expression); | ||
| } | ||
| item->IsText = false; | ||
| } | ||
| else | ||
| { | ||
| item->DisplayItems->Append(errorString); | ||
| item->IsText = true; | ||
| } | ||
| KeyGraphFeaturesItems->Append(item); | ||
| } | ||
|
|
||
| void EquationViewModel::SetParityStringProperty() | ||
| { | ||
| KeyGraphFeaturesItem ^ parityItem = ref new KeyGraphFeaturesItem(); | ||
| parityItem->Title = m_resourceLoader->GetString(L"Parity"); | ||
| switch (Parity) | ||
| { | ||
| case 0: | ||
| parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityUnknown")); | ||
| break; | ||
| case 1: | ||
| parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityOdd")); | ||
| break; | ||
| case 2: | ||
| parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityEven")); | ||
| break; | ||
| case 3: | ||
| parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityNeither")); | ||
| break; | ||
| default: | ||
| parityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFParityUnknown")); | ||
|
|
||
| } | ||
| parityItem->IsText = true; | ||
|
|
||
| KeyGraphFeaturesItems->Append(parityItem); | ||
| } | ||
|
|
||
| void EquationViewModel::SetPeriodicityStringProperty() | ||
| { | ||
| KeyGraphFeaturesItem ^ periodicityItem = ref new KeyGraphFeaturesItem(); | ||
| periodicityItem->Title = m_resourceLoader->GetString(L"Periodicity"); | ||
| switch (PeriodicityDirection) | ||
| { | ||
| case 0: | ||
| // Periodicity is not supported or is too complex to calculate. | ||
| // Return out of this function without adding periodicity to KeyGraphFeatureItems. | ||
| // SetTooComplexFeaturesErrorProperty will set the too complex error when periodicity is supported and unknown | ||
| return; | ||
| case 1: | ||
| if (PeriodicityExpression == L"") | ||
| { | ||
| periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityUnknown")); | ||
| periodicityItem->IsText = true; | ||
| } | ||
| else | ||
| { | ||
| periodicityItem->DisplayItems->Append(PeriodicityExpression); | ||
| periodicityItem->IsText = false; | ||
| } | ||
| break; | ||
| case 2: | ||
| periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityNotPeriodic")); | ||
| periodicityItem->IsText = false; | ||
| break; | ||
| default: | ||
| periodicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFPeriodicityError")); | ||
| periodicityItem->IsText = true; | ||
| } | ||
|
|
||
| KeyGraphFeaturesItems->Append(periodicityItem); | ||
| } | ||
|
|
||
| void EquationViewModel::SetMonotoncityStringProperty() | ||
| { | ||
| KeyGraphFeaturesItem ^ monotonicityItem = ref new KeyGraphFeaturesItem(); | ||
| monotonicityItem->Title = m_resourceLoader->GetString(L"Monotonicity"); | ||
| if (Monotonicity->Size != 0) | ||
| { | ||
| for (auto item : Monotonicity) | ||
| { | ||
| GridDisplayItems ^ gridItem = ref new GridDisplayItems(); | ||
| gridItem->Expression = item->Key; | ||
|
|
||
| auto monotonicityType = item->Value->Data(); | ||
| switch (*monotonicityType) | ||
| { | ||
| case '0': | ||
| gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityUnknown"); | ||
| break; | ||
| case '1': | ||
| gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityIncreasing"); | ||
| break; | ||
| case '2': | ||
| gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityDecreasing"); | ||
| break; | ||
| case '3': | ||
| gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityConstant"); | ||
| break; | ||
| default: | ||
| gridItem->Direction = m_resourceLoader->GetString(L"KGFMonotonicityError"); | ||
| break; | ||
| } | ||
|
|
||
| monotonicityItem->GridItems->Append(gridItem); | ||
| } | ||
| monotonicityItem->IsText = false; | ||
| } | ||
| else | ||
| { | ||
| monotonicityItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFMonotonicityError")); | ||
| monotonicityItem->IsText = true; | ||
| } | ||
|
|
||
| KeyGraphFeaturesItems->Append(monotonicityItem); | ||
| } | ||
|
|
||
| void EquationViewModel::SetTooComplexFeaturesErrorProperty() | ||
| { | ||
| if (TooComplexFeatures <= 0) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| Platform::String ^ separator = ref new String(LocalizationSettings::GetInstance().GetListSeparator().c_str()); | ||
|
|
||
| wstring error; | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Domain) == KeyGraphFeaturesFlag::Domain) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Domain") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Range) == KeyGraphFeaturesFlag::Range) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Range") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Zeros) == KeyGraphFeaturesFlag::Zeros) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"XIntercept") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::YIntercept) == KeyGraphFeaturesFlag::YIntercept) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"YIntercept") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Parity) == KeyGraphFeaturesFlag::Parity) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Parity") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Periodicity) == KeyGraphFeaturesFlag::Periodicity) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Periodicity") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Minima) == KeyGraphFeaturesFlag::Minima) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Minima") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::Maxima) == KeyGraphFeaturesFlag::Maxima) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Maxima") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::InflectionPoints) == KeyGraphFeaturesFlag::InflectionPoints) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"InflectionPoints") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::VerticalAsymptotes) == KeyGraphFeaturesFlag::VerticalAsymptotes) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"VerticalAsymptotes") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::HorizontalAsymptotes) == KeyGraphFeaturesFlag::HorizontalAsymptotes) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"HorizontalAsymptotes") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::ObliqueAsymptotes) == KeyGraphFeaturesFlag::ObliqueAsymptotes) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"ObliqueAsymptotes") + separator + L" ")->Data()); | ||
| } | ||
| if ((TooComplexFeatures & KeyGraphFeaturesFlag::MonotoneIntervals) == KeyGraphFeaturesFlag::MonotoneIntervals) | ||
| { | ||
| error.append((m_resourceLoader->GetString(L"Monotonicity") + separator + L" ")->Data()); | ||
| } | ||
|
|
||
| KeyGraphFeaturesItem ^ tooComplexItem = ref new KeyGraphFeaturesItem(); | ||
| tooComplexItem->DisplayItems->Append(m_resourceLoader->GetString(L"KGFTooComplexFeaturesError")); | ||
| tooComplexItem->DisplayItems->Append(ref new String(error.substr(0, (error.length() - (separator->Length() + 1))).c_str())); | ||
| tooComplexItem->IsText = true; | ||
|
|
||
| KeyGraphFeaturesItems->Append(tooComplexItem); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.