Key graph features (#704)

* Added IGraphAnalyzer

* Key Graph Features called and getting returned to the client. To do put all strings into the Equation object

* Updated UpdateKeyGraphFeatures to add function analysis data to all properties in Equation object

* Update KGF when variables are updated

* Key graph features ui started

* Added MathRichEditBox and started hooking up key graph features to the UI

* Updated EquationViewModel to include parity and periodicity

* Updated key graph features to update the EquationViewModel

* updated key graph features to display more values

* Key graph features populating uing MathRichEdit mode

* moved KeyGraphFeatures control to GraphingCalculator.xaml

* Use MathML formatting instead of MathRichEdit for strings passed back from the engine

* cleaned up project targeting and equation.h comments

* Updated equation edit box to populate for KeyGraphFeatures

* Fixed vcxproj files to have the correct targeting and certificates. KGF Title strings moved to x:Uid instead of the code behind

* Updated per PR feedback

* Update MathRichEditBox to detect if the string is a mathml string and use the appropriate set method to set the text

* fixed the issue where parity, periodicity and monotonicity could be set with an old value if the next one is empty

* KGF control UI adjustments and error handling

* Error control updates

* Error handling added when analysis fails

* fixed alignment on rich edit boxes

* Add monotonicity direction into the mathml string and only have 1 richeditbox

* Set hover state on KGF EquationEditBox to change button opacity and fixed spacing in Monotonicity RichEditBox

* remove sideload package certificate info VS added

* updated logic for setting error strings to be in the viewmodel

* Updated KeyGraphFeatures to populate dynamically using a ListView and TemplateSelector

* Update periodicity to not show if it isn't supported

* Fixed issue where y-intercept was using the x-intercept value

* Remove ItemsControl ItemsContainerStyle

* Updated per pr feedback. Fixed bug where analysis error would not reset

* Update MathRichEdit box to remove selection when focus is lost

* Updated mathrichedit to get LAF access for Dev, Release and Graphing projects

* Remove OnLostFocus in MathRichEdit, Change KGF ItemsControl back to ListView

* Clean up styles for KGF and ensure the match the comps

* Moved formatoptions logic to the Grapher constructor and reverted LineColor.Text resource that was mistakenly taken out

* Add copyright header to KGF Files

* fixed issue where asymptote values were not populating

* Disable KGF button when there is no equation. Fixed issue where equation populated in a new equationtextbox after the previous one was deleted

* Removed formatoptions testing lines used for debugging
This commit is contained in:
Stephanie Anderl
2019-11-12 13:46:11 -08:00
committed by GitHub
parent 626bdf0de5
commit 442ed6a861
48 changed files with 2931 additions and 476 deletions

View File

@@ -3,6 +3,7 @@
#include "pch.h"
#include "Equation.h"
using namespace winrt::Windows::Foundation::Collections;
using namespace Platform;
using namespace std;
@@ -16,16 +17,84 @@ namespace GraphControl
// Remove mml: formatting specific to RichEditBox control, which is not understood by the graph engine.
static constexpr wstring_view s_mathPrefix = L"mml:";
DependencyProperty^ Equation::s_expressionProperty;
DependencyProperty ^ Equation::s_expressionProperty;
static constexpr auto s_propertyName_Expression = L"Expression";
DependencyProperty^ Equation::s_lineColorProperty;
DependencyProperty ^ Equation::s_lineColorProperty;
static constexpr auto s_propertyName_LineColor = L"LineColor";
DependencyProperty ^ Equation::s_isAnalysisUpdatedProperty;
static constexpr auto s_propertyName_IsAnalysisUpdated = L"IsAnalysisUpdated";
DependencyProperty ^ Equation::s_xInterceptProperty;
static constexpr auto s_propertyName_XIntercept = L"XIntercept";
DependencyProperty ^ Equation::s_yInterceptProperty;
static constexpr auto s_propertyName_YIntercept = L"YIntercept";
DependencyProperty ^ Equation::s_parityProperty;
static constexpr auto s_propertyName_Parity = L"Parity";
DependencyProperty ^ Equation::s_periodicityDirectionProperty;
static constexpr auto s_propertyName_PeriodicityDirection = L"PeriodicityDirection";
DependencyProperty ^ Equation::s_periodicityExpressionProperty;
static constexpr auto s_propertyName_PeriodicityExpression = L"PeriodicityExpression";
DependencyProperty ^ Equation::s_minimaProperty;
static constexpr auto s_propertyName_Minima = L"Minima";
DependencyProperty ^ Equation::s_maximaProperty;
static constexpr auto s_propertyName_Maxima = L"Maxima";
DependencyProperty ^ Equation::s_domainProperty;
static constexpr auto s_propertyName_Domain = L"Domain";
DependencyProperty ^ Equation::s_rangeProperty;
static constexpr auto s_propertyName_Range = L"Range";
DependencyProperty ^ Equation::s_inflectionPointsProperty;
static constexpr auto s_propertyName_InflectionPoints = L"InflectionPoints";
DependencyProperty ^ Equation::s_monotonicityProperty;
static constexpr auto s_propertyName_Monotonicity = L"Monotonicity";
DependencyProperty ^ Equation::s_verticalAsymptotesProperty;
static constexpr auto s_propertyName_VerticalAsymptotes = L"VerticalAsymptotes";
DependencyProperty ^ Equation::s_horizontalAsymptotesProperty;
static constexpr auto s_propertyName_HorizontalAsymptotes = L"HorizontalAsymptotes";
DependencyProperty ^ Equation::s_obliqueAsymptotesProperty;
static constexpr auto s_propertyName_ObliqueAsymptotes = L"ObliqueAsymptotes";
DependencyProperty ^ Equation::s_tooComplexFeaturesProperty;
static constexpr auto s_propertyName_TooComplexFeatures = L"TooComplexFeatures";
DependencyProperty ^ Equation::s_analysisErrorProperty;
static constexpr auto s_propertyName_AnalysisError = L"AnalysisError";
namespace EquationProperties
{
String^ Expression = StringReference(s_propertyName_Expression);
String^ LineColor = StringReference(s_propertyName_LineColor);
String ^ Expression = StringReference(s_propertyName_Expression);
String ^ LineColor = StringReference(s_propertyName_LineColor);
String ^ IsAnalysisUpdated = StringReference(s_propertyName_IsAnalysisUpdated);
String ^ XIntercept = StringReference(s_propertyName_XIntercept);
String ^ YIntercept = StringReference(s_propertyName_YIntercept);
String ^ Parity = StringReference(s_propertyName_Parity);
String ^ PeriodicityDirection = StringReference(s_propertyName_PeriodicityDirection);
String ^ PeriodicityExpression = StringReference(s_propertyName_PeriodicityExpression);
String ^ Minima = StringReference(s_propertyName_Minima);
String ^ Maxima = StringReference(s_propertyName_Maxima);
String ^ Domain = StringReference(s_propertyName_Domain);
String ^ Range = StringReference(s_propertyName_Range);
String ^ InflectionPoints = StringReference(s_propertyName_InflectionPoints);
String ^ Monotonicity = StringReference(s_propertyName_Monotonicity);
String ^ VerticalAsymptotes = StringReference(s_propertyName_VerticalAsymptotes);
String ^ HorizontalAsymptotes = StringReference(s_propertyName_HorizontalAsymptotes);
String ^ ObliqueAsymptotes = StringReference(s_propertyName_ObliqueAsymptotes);
String ^ TooComplexFeatures = StringReference(s_propertyName_TooComplexFeatures);
String ^ AnalysisError = StringReference(s_propertyName_AnalysisError);
}
void Equation::RegisterDependencyProperties()
@@ -36,9 +105,7 @@ namespace GraphControl
EquationProperties::Expression,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(
nullptr,
ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_lineColorProperty)
@@ -50,17 +117,167 @@ namespace GraphControl
EquationProperties::LineColor,
SolidColorBrush::typeid,
Equation::typeid,
ref new PropertyMetadata(
nullptr,
ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_isAnalysisUpdatedProperty)
{
s_isAnalysisUpdatedProperty = DependencyProperty::Register(
EquationProperties::IsAnalysisUpdated,
bool ::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_xInterceptProperty)
{
s_xInterceptProperty = DependencyProperty::Register(
EquationProperties::XIntercept,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_yInterceptProperty)
{
s_yInterceptProperty = DependencyProperty::Register(
EquationProperties::YIntercept,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_parityProperty)
{
s_parityProperty = DependencyProperty::Register(
EquationProperties::Parity,
int ::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_periodicityDirectionProperty)
{
s_periodicityDirectionProperty = DependencyProperty::Register(
EquationProperties::PeriodicityDirection,
int ::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_periodicityExpressionProperty)
{
s_periodicityExpressionProperty = DependencyProperty::Register(
EquationProperties::PeriodicityExpression,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_minimaProperty)
{
s_minimaProperty = DependencyProperty::Register(
EquationProperties::Minima,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_maximaProperty)
{
s_maximaProperty = DependencyProperty::Register(
EquationProperties::Maxima,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_domainProperty)
{
s_domainProperty = DependencyProperty::Register(
EquationProperties::Domain,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_rangeProperty)
{
s_rangeProperty = DependencyProperty::Register(
EquationProperties::Range,
String::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_inflectionPointsProperty)
{
s_inflectionPointsProperty = DependencyProperty::Register(
EquationProperties::InflectionPoints,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_monotonicityProperty)
{
s_monotonicityProperty = DependencyProperty::Register(
EquationProperties::Monotonicity,
IObservableMap<String ^, String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_verticalAsymptotesProperty)
{
s_verticalAsymptotesProperty = DependencyProperty::Register(
EquationProperties::VerticalAsymptotes,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_horizontalAsymptotesProperty)
{
s_horizontalAsymptotesProperty = DependencyProperty::Register(
EquationProperties::HorizontalAsymptotes,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_obliqueAsymptotesProperty)
{
s_obliqueAsymptotesProperty = DependencyProperty::Register(
EquationProperties::ObliqueAsymptotes,
IObservableVector<String ^>::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_tooComplexFeaturesProperty)
{
s_tooComplexFeaturesProperty = DependencyProperty::Register(
EquationProperties::TooComplexFeatures,
int ::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
if (!s_analysisErrorProperty)
{
s_analysisErrorProperty = DependencyProperty::Register(
EquationProperties::AnalysisError,
int ::typeid,
Equation::typeid,
ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&Equation::OnCustomDependencyPropertyChanged)));
}
}
void Equation::OnCustomDependencyPropertyChanged(DependencyObject^ obj, DependencyPropertyChangedEventArgs^ args)
void Equation::OnCustomDependencyPropertyChanged(DependencyObject ^ obj, DependencyPropertyChangedEventArgs ^ args)
{
if (auto eq = static_cast<Equation^>(obj))
if (auto eq = static_cast<Equation ^>(obj))
{
String^ propertyName = nullptr;
String ^ propertyName = nullptr;
if (args->Property == s_expressionProperty)
{
propertyName = EquationProperties::Expression;
@@ -69,6 +286,74 @@ namespace GraphControl
{
propertyName = EquationProperties::LineColor;
}
else if (args->Property == s_isAnalysisUpdatedProperty)
{
propertyName = EquationProperties::IsAnalysisUpdated;
}
else if (args->Property == s_xInterceptProperty)
{
propertyName = EquationProperties::XIntercept;
}
else if (args->Property == s_yInterceptProperty)
{
propertyName = EquationProperties::YIntercept;
}
else if (args->Property == s_parityProperty)
{
propertyName = EquationProperties::Parity;
}
else if (args->Property == s_periodicityDirectionProperty)
{
propertyName = EquationProperties::PeriodicityDirection;
}
else if (args->Property == s_periodicityExpressionProperty)
{
propertyName = EquationProperties::PeriodicityExpression;
}
else if (args->Property == s_minimaProperty)
{
propertyName = EquationProperties::Minima;
}
else if (args->Property == s_maximaProperty)
{
propertyName = EquationProperties::Maxima;
}
else if (args->Property == s_domainProperty)
{
propertyName = EquationProperties::Domain;
}
else if (args->Property == s_rangeProperty)
{
propertyName = EquationProperties::Range;
}
else if (args->Property == s_inflectionPointsProperty)
{
propertyName = EquationProperties::InflectionPoints;
}
else if (args->Property == s_monotonicityProperty)
{
propertyName = EquationProperties::Monotonicity;
}
else if (args->Property == s_verticalAsymptotesProperty)
{
propertyName = EquationProperties::VerticalAsymptotes;
}
else if (args->Property == s_horizontalAsymptotesProperty)
{
propertyName = EquationProperties::HorizontalAsymptotes;
}
else if (args->Property == s_obliqueAsymptotesProperty)
{
propertyName = EquationProperties::ObliqueAsymptotes;
}
else if (args->Property == s_tooComplexFeaturesProperty)
{
propertyName = EquationProperties::TooComplexFeatures;
}
else if (args->Property == s_analysisErrorProperty)
{
propertyName = EquationProperties::AnalysisError;
}
eq->PropertyChanged(eq, propertyName);
}
@@ -77,10 +362,7 @@ namespace GraphControl
wstring Equation::GetRequest()
{
wstringstream ss{};
ss << GetRequestHeader()
<< GetExpression()
<< GetLineColor()
<< L"</mfenced></mrow>";
ss << GetRequestHeader() << GetExpression() << GetLineColor() << L"</mfenced></mrow>";
return ss.str();
}

View File

@@ -17,6 +17,7 @@ namespace GraphControl
[Windows::UI::Xaml::Data::Bindable] public ref class Equation sealed : public Windows::UI::Xaml::FrameworkElement
{
public:
Equation()
{
}
@@ -60,17 +61,373 @@ namespace GraphControl
}
void set(Windows::UI::Xaml::Media::SolidColorBrush^ value)
{
if (value == nullptr || LineColor == nullptr || (value->Color.A != LineColor->Color.A) || (value->Color.R != LineColor->Color.R) || (value->Color.G != LineColor->Color.G)
|| (value->Color.B != LineColor->Color.B))
{
SetValue(s_lineColorProperty, value);
}
if (value == nullptr || LineColor == nullptr || (value->Color.A != LineColor->Color.A) || (value->Color.R != LineColor->Color.R)
|| (value->Color.G != LineColor->Color.G) || (value->Color.B != LineColor->Color.B))
SetValue(s_lineColorProperty, value);
}
}
#pragma endregion
internal:
event PropertyChangedEventHandler^ PropertyChanged;
#pragma region Key Graph Features
#pragma region bool IsAnalysisUpdated DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ IsAnalysisUpdatedProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_isAnalysisUpdatedProperty;
}
}
property bool IsAnalysisUpdated
{
bool get()
{
return static_cast<bool>(GetValue(s_isAnalysisUpdatedProperty));
}
void set(bool value)
{
SetValue(s_isAnalysisUpdatedProperty, value);
}
}
#pragma endregion
#pragma region Platform::String ^ XIntercept DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ XInterceptProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_xInterceptProperty;
}
}
property Platform::String^ XIntercept
{
Platform::String^ get()
{
return static_cast<Platform::String^>(GetValue(s_xInterceptProperty));
}
void set(Platform::String^ value)
{
SetValue(s_xInterceptProperty, value);
}
}
#pragma endregion
#pragma region Platform::String ^ YIntercept DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ YInterceptProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_yInterceptProperty;
}
}
property Platform::String^ YIntercept
{
Platform::String^ get()
{
return static_cast<Platform::String^>(GetValue(s_yInterceptProperty));
}
void set(Platform::String^ value)
{
SetValue(s_yInterceptProperty, value);
}
}
#pragma endregion
#pragma region int Parity DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ ParityProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_parityProperty;
}
}
property int Parity
{
int get()
{
return static_cast<int>(GetValue(s_parityProperty));
}
void set(int value)
{
SetValue(s_parityProperty, value);
}
}
#pragma endregion
#pragma region int Periodicity DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ PeriodicityDirectionProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_periodicityDirectionProperty;
}
}
property int PeriodicityDirection
{
int get()
{
return static_cast<int>(GetValue(s_periodicityDirectionProperty));
}
void set(int value)
{
SetValue(s_periodicityDirectionProperty, value);
}
}
#pragma endregion
#pragma region Platform::String ^ PeriodicityExpression DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ PeriodicityExpressionProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_periodicityExpressionProperty;
}
}
property Platform::String ^ PeriodicityExpression
{
Platform::String ^ get()
{
return static_cast<Platform::String ^>(GetValue(s_periodicityExpressionProperty));
}
void set(Platform::String ^ value)
{
SetValue(s_periodicityExpressionProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ Minima DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ MinimaProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_minimaProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ Minima
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_minimaProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_minimaProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ Maxima DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ MaximaProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_maximaProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ Maxima
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_maximaProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_maximaProperty, value);
}
}
#pragma endregion
#pragma region Platform::String ^ Domain DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ DomainProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_domainProperty;
}
}
property Platform::String^ Domain
{
Platform::String^ get()
{
return static_cast<Platform::String^>(GetValue(s_domainProperty));
}
void set(Platform::String^ value)
{
SetValue(s_domainProperty, value);
}
}
#pragma endregion
#pragma region Platform::String ^ Range DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ RangeProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_rangeProperty;
}
}
property Platform::String^ Range
{
Platform::String^ get()
{
return static_cast<Platform::String^>(GetValue(s_rangeProperty));
}
void set(Platform::String^ value)
{
SetValue(s_rangeProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ InflectionPoints DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ InflectionPointsProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_inflectionPointsProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ InflectionPoints
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_inflectionPointsProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_inflectionPointsProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IObservableMap < Platform::String ^, Platform::String ^ > ^ Monotonicity DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ MonotonicityProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_monotonicityProperty;
}
}
property Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ Monotonicity
{
Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^>(GetValue(s_monotonicityProperty));
}
void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::String ^> ^ value)
{
SetValue(s_monotonicityProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ VerticalAsymptotes DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ VerticalAsymptotesProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_verticalAsymptotesProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ VerticalAsymptotes
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_verticalAsymptotesProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_verticalAsymptotesProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ HorizontalAsymptotes DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ HorizontalAsymptotesProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_horizontalAsymptotesProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ HorizontalAsymptotes
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_horizontalAsymptotesProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_horizontalAsymptotesProperty, value);
}
}
#pragma endregion
#pragma region Windows::Foundation::Collections::IVector < Platform::String ^ > ^ ObliqueAsymptotes DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ ObliqueAsymptotesProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_obliqueAsymptotesProperty;
}
}
property Windows::Foundation::Collections::IVector<Platform::String^> ^ ObliqueAsymptotes
{
Windows::Foundation::Collections::IVector<Platform::String^> ^ get()
{
return static_cast<Windows::Foundation::Collections::IVector<Platform::String^> ^>(GetValue(s_obliqueAsymptotesProperty));
}
void set(Windows::Foundation::Collections::IVector<Platform::String^> ^ value)
{
SetValue(s_obliqueAsymptotesProperty, value);
}
}
#pragma endregion
#pragma region int TooComplexFeatures DependencyProperty
static property Windows::UI::Xaml::DependencyProperty^ TooComplexFeaturesProperty
{
Windows::UI::Xaml::DependencyProperty^ get()
{
return s_tooComplexFeaturesProperty;
}
}
property int TooComplexFeatures
{
int get()
{
return static_cast<int>(GetValue(s_tooComplexFeaturesProperty));
}
void set(int value)
{
SetValue(s_tooComplexFeaturesProperty, value);
}
}
#pragma endregion
#pragma region int AnalysisError DependencyProperty
static property Windows::UI::Xaml::DependencyProperty ^ AnalysisErrorProperty
{
Windows::UI::Xaml::DependencyProperty ^ get()
{
return s_analysisErrorProperty;
}
}
property int AnalysisError
{
int get()
{
return static_cast<int>(GetValue(s_analysisErrorProperty));
}
void set(int value)
{
SetValue(s_analysisErrorProperty, value);
}
}
#pragma endregion
internal : event PropertyChangedEventHandler ^ PropertyChanged;
std::wstring GetRequest();
@@ -84,5 +441,22 @@ namespace GraphControl
private:
static Windows::UI::Xaml::DependencyProperty ^ s_expressionProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_lineColorProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_isAnalysisUpdatedProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_xInterceptProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_yInterceptProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_parityProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_periodicityDirectionProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_periodicityExpressionProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_minimaProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_maximaProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_domainProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_rangeProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_inflectionPointsProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_monotonicityProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_verticalAsymptotesProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_horizontalAsymptotesProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_obliqueAsymptotesProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_tooComplexFeaturesProperty;
static Windows::UI::Xaml::DependencyProperty ^ s_analysisErrorProperty;
};
}

View File

@@ -8,6 +8,7 @@
namespace GraphControl
{
delegate void EquationChangedEventHandler();
delegate void VisibilityChangedEventHandler(Equation ^ sender);
public
ref class EquationCollection sealed : public Windows::Foundation::Collections::IObservableVector<GraphControl::Equation ^>
@@ -151,16 +152,16 @@ public
private:
void OnEquationPropertyChanged(GraphControl::Equation ^, Platform::String ^ propertyName)
{
if (propertyName == L"LineColor")
if (propertyName == EquationProperties::LineColor)
{
EquationStyleChanged();
}
else
else if (propertyName == EquationProperties::Expression)
{
EquationChanged();
}
}
private:
Platform::Collections::Vector<GraphControl::Equation ^> ^ m_vector;
std::vector<Windows::Foundation::EventRegistrationToken> m_tokens;

View File

@@ -3,6 +3,8 @@
#include "pch.h"
#include "Grapher.h"
#include "IBitmap.h"
#include "../../CalcViewModel/GraphingCalculatorEnums.h"
using namespace Graphing;
using namespace GraphControl;
@@ -37,6 +39,9 @@ namespace
constexpr auto s_X = L"x";
constexpr auto s_Y = L"y";
constexpr auto s_getGraphOpeningTags = L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>show2d</mi><mfenced separators=\"\">";
constexpr auto s_getGraphClosingTags = L"</mfenced></mrow></math>";
// Helper function for converting a pointer position to a position that the graphing engine will understand.
// posX/posY are the pointer position elements and width,height are the dimensions of the graph surface.
// The graphing engine interprets x,y position between the range [-1, 1].
@@ -61,6 +66,8 @@ namespace GraphControl
, m_Moving{ false }
{
m_solver->ParsingOptions().SetFormatType(FormatType::MathML);
m_solver->FormatOptions().SetFormatType(FormatType::MathML);
m_solver->FormatOptions().SetMathMLPrefix(wstring(L"mml"));
DefaultStyleKey = StringReference(s_defaultStyleKey);
@@ -380,7 +387,7 @@ namespace GraphControl
if (!validEqs.empty())
{
wstringstream ss{};
ss << L"<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><mi>show2d</mi><mfenced separators=\"\">";
ss << s_getGraphOpeningTags;
int numValidEquations = 0;
for (Equation ^ eq : validEqs)
@@ -393,7 +400,7 @@ namespace GraphControl
ss << eq->GetRequest();
}
ss << L"</mfenced></mrow></math>";
ss << s_getGraphClosingTags;
wstring request = ss.str();
unique_ptr<IExpression> graphExpression;
@@ -407,6 +414,7 @@ namespace GraphControl
m_renderMain->Graph = m_graph;
UpdateVariables();
UpdateKeyGraphFeatures();
}
}
}
@@ -420,6 +428,7 @@ namespace GraphControl
m_renderMain->Graph = m_graph;
UpdateVariables();
UpdateKeyGraphFeatures();
}
}
}
@@ -436,6 +445,105 @@ namespace GraphControl
}
}
shared_ptr<IGraph> Grapher::GetGraph(GraphControl::Equation ^ equation)
{
std::shared_ptr<Graphing::IGraph> graph = m_solver->CreateGrapher();
wstringstream ss{};
ss << s_getGraphOpeningTags;
ss << equation->GetRequest();
ss << s_getGraphClosingTags;
wstring request = ss.str();
unique_ptr<IExpression> graphExpression;
if (graphExpression = m_solver->ParseInput(request))
{
if (graph->TryInitialize(graphExpression.get()))
{
return graph;
}
}
return nullptr;
}
void Grapher::UpdateKeyGraphFeatures()
{
auto equations = GetValidEquations();
for (auto equation : equations)
{
equation->IsAnalysisUpdated = false;
if (auto graph = GetGraph(equation))
{
if (auto analyzer = graph->GetAnalyzer())
{
if (analyzer->CanFunctionAnalysisBePerformed())
{
if (S_OK
== analyzer->PerformFunctionAnalysis(
(Graphing::Analyzer::NativeAnalysisType)Graphing::Analyzer::PerformAnalysisType::PerformAnalysisType_All))
{
Graphing::IGraphFunctionAnalysisData functionAnalysisData = m_solver->Analyze(analyzer.get());
{
equation->XIntercept = ref new String(functionAnalysisData.Zeros.c_str());
equation->YIntercept = ref new String(functionAnalysisData.YIntercept.c_str());
equation->Domain = ref new String(functionAnalysisData.Domain.c_str());
equation->Range = ref new String(functionAnalysisData.Range.c_str());
equation->Parity = functionAnalysisData.Parity;
equation->PeriodicityDirection = functionAnalysisData.PeriodicityDirection;
equation->PeriodicityExpression = ref new String(functionAnalysisData.PeriodicityExpression.c_str());
equation->Minima = ConvertWStringVector(functionAnalysisData.Minima);
equation->Maxima = ConvertWStringVector(functionAnalysisData.Maxima);
equation->InflectionPoints = ConvertWStringVector(functionAnalysisData.InflectionPoints);
equation->Monotonicity = ConvertWStringIntMap(functionAnalysisData.MonotoneIntervals);
equation->VerticalAsymptotes = ConvertWStringVector(functionAnalysisData.VerticalAsymptotes);
equation->HorizontalAsymptotes = ConvertWStringVector(functionAnalysisData.HorizontalAsymptotes);
equation->ObliqueAsymptotes = ConvertWStringVector(functionAnalysisData.ObliqueAsymptotes);
equation->TooComplexFeatures = functionAnalysisData.TooComplexFeatures;
equation->AnalysisError = CalculatorApp::AnalysisErrorType::NoError;
equation->IsAnalysisUpdated = true;
continue;
}
}
}
else
{
equation->AnalysisError = CalculatorApp::AnalysisErrorType::AnalysisNotSupported;
equation->IsAnalysisUpdated = true;
continue;
}
}
}
equation->AnalysisError = CalculatorApp::AnalysisErrorType::AnalysisCouldNotBePerformed;
equation->IsAnalysisUpdated = true;
}
}
IObservableVector<String ^> ^ Grapher::ConvertWStringVector(vector<wstring> inVector)
{
Vector<String ^> ^ outVector = ref new Vector<String ^>();
for (auto v : inVector)
{
outVector->Append(ref new String(v.c_str()));
}
return outVector;
}
IObservableMap<String ^, String ^> ^ Grapher::ConvertWStringIntMap(map<wstring, int> inMap)
{
Map<String ^, String ^> ^ outMap = ref new Map<String ^, String ^>();
;
for (auto m : inMap)
{
outMap->Insert(ref new String(m.first.c_str()), m.second.ToString());
}
return outMap;
}
void Grapher::UpdateVariables()
{
auto updatedVariables = ref new Map<String ^, double>();

View File

@@ -7,6 +7,7 @@
#include "DirectX/RenderMain.h"
#include "Equation.h"
#include "EquationCollection.h"
#include "IGraphAnalyzer.h"
#include "IMathSolver.h"
#include "Common.h"
@@ -162,7 +163,7 @@ public
}
}
property Windows::Foundation::Point TraceLocation
property Windows::Foundation::Point TraceLocation
{
Windows::Foundation::Point get()
{
@@ -170,7 +171,6 @@ public
}
}
property Windows::Foundation::Point ActiveTraceCursorPosition
{
Windows::Foundation::Point get()
@@ -228,7 +228,9 @@ public
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation ^>& validEqs);
std::vector<Equation ^> GetValidEquations();
void SetGraphArgs();
std::shared_ptr<Graphing::IGraph> GetGraph(GraphControl::Equation ^ equation);
void UpdateVariables();
void UpdateKeyGraphFeatures();
void OnForceProportionalAxesChanged(Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ args);
@@ -247,6 +249,8 @@ public
void HandleTracingMovementTick(Object ^ sender, Object ^ e);
void HandleKey(bool keyDown, Windows::System::VirtualKey key);
Windows::Foundation::Collections::IObservableVector<Platform::String ^> ^ ConvertWStringVector(std::vector<std::wstring> inVector);
Windows::Foundation::Collections::IObservableMap<Platform::String ^, Platform::String ^> ^ ConvertWStringIntMap(std::map<std::wstring, int> inMap);
private:
DX::RenderMain ^ m_renderMain = nullptr;
@@ -283,7 +287,7 @@ public
bool m_KeysPressed[5];
bool m_Moving;
Windows::UI::Xaml::DispatcherTimer ^ m_TracingTrackingTimer;
Windows::UI::Xaml::DispatcherTimer ^ m_TracingTrackingTimer;
public:
Windows::Storage::Streams::RandomAccessStreamReference ^ GetGraphBitmapStream();