From a0f98ca76b674afd4b4399677c5e25fbb34c254d Mon Sep 17 00:00:00 2001 From: Stephanie Anderl <46726333+sanderl@users.noreply.github.com> Date: Tue, 15 Sep 2020 14:27:22 -0700 Subject: [PATCH] Improved error handing for function analysis for functions in the f(y) format (#1338) * Updated the CanFunctionAnalysisBePerformed api to use the updated one with variableIsNotX error handling. Updated the UI to reflect the new descriptive error case to show an informative error. * Fixed spacing and updated the moved the variableIsNotX check up into the parent if statement * Update the internals version to match the version needed to support this change --- build/pipelines/templates/build-app-internal.yaml | 2 +- .../templates/prepare-release-internalonly.yaml | 2 +- .../GraphingCalculator/EquationViewModel.cpp | 4 ++++ src/CalcViewModel/GraphingCalculatorEnums.h | 3 ++- src/Calculator/Resources/en-US/Resources.resw | 4 ++++ src/GraphControl/Control/Grapher.cpp | 8 ++++++-- src/GraphingInterfaces/IGraphAnalyzer.h | 12 ++++++------ 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/build/pipelines/templates/build-app-internal.yaml b/build/pipelines/templates/build-app-internal.yaml index 4418395..08d38a1 100644 --- a/build/pipelines/templates/build-app-internal.yaml +++ b/build/pipelines/templates/build-app-internal.yaml @@ -29,7 +29,7 @@ jobs: downloadDirectory: $(Build.SourcesDirectory) vstsFeed: WindowsInboxApps vstsFeedPackage: calculator-internals - vstsPackageVersion: 0.0.49 + vstsPackageVersion: 0.0.50 - template: ./build-single-architecture.yaml parameters: diff --git a/build/pipelines/templates/prepare-release-internalonly.yaml b/build/pipelines/templates/prepare-release-internalonly.yaml index 945de53..be286c6 100644 --- a/build/pipelines/templates/prepare-release-internalonly.yaml +++ b/build/pipelines/templates/prepare-release-internalonly.yaml @@ -80,7 +80,7 @@ jobs: downloadDirectory: $(Build.SourcesDirectory) vstsFeed: WindowsInboxApps vstsFeedPackage: calculator-internals - vstsPackageVersion: 0.0.49 + vstsPackageVersion: 0.0.50 - powershell: | # Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone. diff --git a/src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp b/src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp index 666f55e..50592aa 100644 --- a/src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp +++ b/src/CalcViewModel/GraphingCalculator/EquationViewModel.cpp @@ -63,6 +63,10 @@ namespace CalculatorApp::ViewModel { AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported"); } + else if (graphEquation->AnalysisError == static_cast(AnalysisErrorType::VariableIsNotX)) + { + AnalysisErrorString = m_resourceLoader->GetString(L"KGFVariableIsNotX"); + } return; } diff --git a/src/CalcViewModel/GraphingCalculatorEnums.h b/src/CalcViewModel/GraphingCalculatorEnums.h index 5cf136a..8093f4a 100644 --- a/src/CalcViewModel/GraphingCalculatorEnums.h +++ b/src/CalcViewModel/GraphingCalculatorEnums.h @@ -23,6 +23,7 @@ namespace CalculatorApp { NoError, AnalysisCouldNotBePerformed, - AnalysisNotSupported + AnalysisNotSupported, + VariableIsNotX }; } diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index b4b9941..d8ec8d5 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -4019,6 +4019,10 @@ Analysis is not supported for this function. Error displayed when graph analysis is not supported or had an error. + + Analysis is only supported for functions in the f(x) format. Example: y=x + Error displayed when graph analysis detects the function format is not f(x). + Maxima Title for KeyGraphFeatures Maxima Property diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index 2c75e20..1132eda 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -254,8 +254,8 @@ namespace GraphControl vector equationVector; equationVector.push_back(equation); UpdateGraphOptions(graph->GetOptions(), equationVector); - - if (analyzer->CanFunctionAnalysisBePerformed()) + bool variableIsNotX; + if (analyzer->CanFunctionAnalysisBePerformed(variableIsNotX) && !variableIsNotX) { if (S_OK == analyzer->PerformFunctionAnalysis( @@ -265,6 +265,10 @@ namespace GraphControl return KeyGraphFeaturesInfo::Create(functionAnalysisData); } } + else if (variableIsNotX) + { + return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::VariableIsNotX); + } else { return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported); diff --git a/src/GraphingInterfaces/IGraphAnalyzer.h b/src/GraphingInterfaces/IGraphAnalyzer.h index 4bd962c..5b5e012 100644 --- a/src/GraphingInterfaces/IGraphAnalyzer.h +++ b/src/GraphingInterfaces/IGraphAnalyzer.h @@ -15,10 +15,10 @@ namespace Graphing::Analyzer struct IGraphAnalyzer : public NonCopyable, public NonMoveable { - virtual ~IGraphAnalyzer() = default; - virtual bool CanFunctionAnalysisBePerformed() = 0; - virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0; - virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0; - virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0; + virtual ~IGraphAnalyzer() = default; + virtual bool CanFunctionAnalysisBePerformed(bool& variableIsNotX) = 0; + virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0; + virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0; + virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0; }; -} \ No newline at end of file +}