Updated APIs to use new GetClosePointData() from Graphing Engine. (#1250)

* Updated APIs to use new GetClosePointData() from Graphing Engine. Now specifiying precision on API consumption to aid with correct display and rounding.

* Updated function to be const-corect

* Updated to use correct APIs

* Converted TraceValue from Point to two doubles, point's X and Y was using float and conversion between float and doubles was causing unwanted rounding.

* Update to pch file and fixing typo

* Point to updated graphing version
This commit is contained in:
Quentin Al-Timimi
2020-06-30 15:08:54 -07:00
committed by GitHub
parent 2608a353de
commit 0175b51655
11 changed files with 81 additions and 80 deletions

View File

@@ -207,44 +207,15 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
GraphingControl->PlotGraph(false);
}
wstringstream GraphingCalculator::FormatTraceValue(double min, double max, float pointValue)
{
wstringstream traceValueString;
// Extract precision we will round to
auto precision = static_cast<int>(floor(log10(max - min)) - 3);
// Determine if we want to show scientific notation instead
if (precision <= -7 || precision >= 7)
{
traceValueString << scientific;
}
else
{
traceValueString << fixed;
}
// If we are rounding to a decimal place, set the precision
if (precision < 0)
{
traceValueString << setprecision(::min(7, abs(precision))) << pointValue;
}
else
{
traceValueString << setprecision(0) << pointValue;
}
return traceValueString;
}
void GraphingCalculator::OnTracePointChanged(Point newPoint)
void GraphingCalculator::OnTracePointChanged(double xPointValue, double yPointValue)
{
wstringstream traceValueString;
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
GraphingControl->GetDisplayRanges(&xAxisMin, &xAxisMax, &yAxisMin, &yAxisMax);
traceValueString << "(" << FormatTraceValue(xAxisMin, xAxisMax, newPoint.X).str() << ", " << FormatTraceValue(yAxisMin, yAxisMax, newPoint.Y).str() << ")";
traceValueString << "(" << xPointValue << ", ";
traceValueString << setprecision(15) << yPointValue << ")";
TraceValue->Text = ref new String(traceValueString.str().c_str());

View File

@@ -55,9 +55,9 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void OnZoomOutCommand(Object ^ parameter);
void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnShowTracePopupChanged(bool newValue);
void OnTracePointChanged(Windows::Foundation::Point newPoint);
void OnTracePointChanged(double xPointValue, double yPointValue);
void OnPointerPointChanged(Windows::Foundation::Point newPoint);
private:
void OnDataRequested(
@@ -104,8 +104,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
std::wstringstream FormatTraceValue(double min, double max, float pointValue);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
void GraphViewButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
void ShowShareError();
void OnGraphingCalculatorLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);