mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
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:
parent
c508cc29ed
commit
a7beccb6ca
5 changed files with 20 additions and 6 deletions
|
@ -63,6 +63,10 @@ namespace CalculatorApp::ViewModel
|
||||||
{
|
{
|
||||||
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
|
AnalysisErrorString = m_resourceLoader->GetString(L"KGFAnalysisNotSupported");
|
||||||
}
|
}
|
||||||
|
else if (graphEquation->AnalysisError == static_cast<int>(AnalysisErrorType::VariableIsNotX))
|
||||||
|
{
|
||||||
|
AnalysisErrorString = m_resourceLoader->GetString(L"KGFVariableIsNotX");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
NoError,
|
NoError,
|
||||||
AnalysisCouldNotBePerformed,
|
AnalysisCouldNotBePerformed,
|
||||||
AnalysisNotSupported
|
AnalysisNotSupported,
|
||||||
|
VariableIsNotX
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4070,6 +4070,10 @@
|
||||||
<data name="KGFAnalysisNotSupported" xml:space="preserve">
|
<data name="KGFAnalysisNotSupported" xml:space="preserve">
|
||||||
<value>Analysis is not supported for this function.</value>
|
<value>Analysis is not supported for this function.</value>
|
||||||
<comment>Error displayed when graph analysis is not supported or had an error.</comment>
|
<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>
|
||||||
<data name="Maxima" xml:space="preserve">
|
<data name="Maxima" xml:space="preserve">
|
||||||
<value>Maxima</value>
|
<value>Maxima</value>
|
||||||
|
|
|
@ -254,17 +254,22 @@ namespace GraphControl
|
||||||
vector<Equation ^> equationVector;
|
vector<Equation ^> equationVector;
|
||||||
equationVector.push_back(equation);
|
equationVector.push_back(equation);
|
||||||
UpdateGraphOptions(graph->GetOptions(), equationVector);
|
UpdateGraphOptions(graph->GetOptions(), equationVector);
|
||||||
|
bool variableIsNotX;
|
||||||
if (analyzer->CanFunctionAnalysisBePerformed())
|
if (analyzer->CanFunctionAnalysisBePerformed(variableIsNotX))
|
||||||
{
|
{
|
||||||
if (S_OK
|
if (S_OK
|
||||||
== analyzer->PerformFunctionAnalysis(
|
== 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());
|
Graphing::IGraphFunctionAnalysisData functionAnalysisData = m_solver->Analyze(analyzer.get());
|
||||||
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
|
return KeyGraphFeaturesInfo::Create(functionAnalysisData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (variableIsNotX)
|
||||||
|
{
|
||||||
|
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::VariableIsNotX);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);
|
return KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisErrorType::AnalysisNotSupported);
|
||||||
|
|
|
@ -16,9 +16,9 @@ namespace Graphing::Analyzer
|
||||||
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
|
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
|
||||||
{
|
{
|
||||||
virtual ~IGraphAnalyzer() = default;
|
virtual ~IGraphAnalyzer() = default;
|
||||||
virtual bool CanFunctionAnalysisBePerformed() = 0;
|
virtual bool CanFunctionAnalysisBePerformed(bool& variableIsNotX) = 0;
|
||||||
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
|
virtual HRESULT PerformFunctionAnalysis(NativeAnalysisType analysisType) = 0;
|
||||||
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
|
virtual HRESULT GetAnalysisTypeCaption(const AnalysisType type, std::wstring& captionOut) const = 0;
|
||||||
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
|
virtual HRESULT GetMessage(const GraphAnalyzerMessage msg, std::wstring& msgOut) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue