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.

This commit is contained in:
Stephanie Anderl 2020-08-06 14:42:39 -07:00
commit a7beccb6ca
5 changed files with 20 additions and 6 deletions

View file

@ -63,6 +63,10 @@ namespace CalculatorApp::ViewModel
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
}
else if (graphEquation->AnalysisError == static_cast<int>(AnalysisErrorType::VariableIsNotX))
{
AnalysisErrorString = m_resourceLoader->GetString(L"KGFVariableIsNotX");
}
return;
}

View file

@ -23,6 +23,7 @@ namespace CalculatorApp
{
NoError,
AnalysisCouldNotBePerformed,
AnalysisNotSupported
AnalysisNotSupported,
VariableIsNotX
};
}

View file

@ -4070,6 +4070,10 @@
<data name="KGFAnalysisNotSupported" xml:space="preserve">
<value>Analysis is not supported for this function.</value>
<comment>Error displayed when graph analysis is not supported or had an error.</comment>
</data>
<data name="KGFVariableIsNotX" xml:space="preserve">
<value>Analysis is only supported for functions in the f(x) format. Example: y=x</value>
<comment>Error displayed when graph analysis detects the function format is not f(x).</comment>
</data>
<data name="Maxima" xml:space="preserve">
<value>Maxima</value>

View file

@ -254,17 +254,22 @@ namespace GraphControl
vector<Equation ^> equationVector;
equationVector.push_back(equation);
UpdateGraphOptions(graph->GetOptions(), equationVector);
if (analyzer->CanFunctionAnalysisBePerformed())
bool variableIsNotX;
if (analyzer->CanFunctionAnalysisBePerformed(variableIsNotX))
{
if (S_OK
== analyzer->PerformFunctionAnalysis(
(Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All))
(Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All)
&& !variableIsNotX)
{
Graphing::IGraphFunctionAnalysisData functionAnalysisData = m_solver->Analyze(analyzer.get());
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
}
}
else if (variableIsNotX)
{
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::VariableIsNotX);
}
else
{
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);

View file

@ -16,7 +16,7 @@ namespace Graphing::Analyzer
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
{
virtual ~IGraphAnalyzer() = default;
virtual bool CanFunctionAnalysisBePerformed() = 0;
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;