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:
parent
2608a353de
commit
0175b51655
@ -29,7 +29,7 @@ jobs:
|
|||||||
downloadDirectory: $(Build.SourcesDirectory)
|
downloadDirectory: $(Build.SourcesDirectory)
|
||||||
vstsFeed: WindowsApps
|
vstsFeed: WindowsApps
|
||||||
vstsFeedPackage: calculator-internals
|
vstsFeedPackage: calculator-internals
|
||||||
vstsPackageVersion: 0.0.44
|
vstsPackageVersion: 0.0.45
|
||||||
|
|
||||||
- template: ./build-single-architecture.yaml
|
- template: ./build-single-architecture.yaml
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -96,7 +96,7 @@ jobs:
|
|||||||
downloadDirectory: $(Build.SourcesDirectory)
|
downloadDirectory: $(Build.SourcesDirectory)
|
||||||
vstsFeed: WindowsApps
|
vstsFeed: WindowsApps
|
||||||
vstsFeedPackage: calculator-internals
|
vstsFeedPackage: calculator-internals
|
||||||
vstsPackageVersion: 0.0.44
|
vstsPackageVersion: 0.0.45
|
||||||
|
|
||||||
- powershell: |
|
- powershell: |
|
||||||
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.
|
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.
|
||||||
|
@ -207,44 +207,15 @@ void GraphingCalculator::OnEquationsVectorChanged(IObservableVector<EquationView
|
|||||||
GraphingControl->PlotGraph(false);
|
GraphingControl->PlotGraph(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
wstringstream GraphingCalculator::FormatTraceValue(double min, double max, float pointValue)
|
void GraphingCalculator::OnTracePointChanged(double xPointValue, double yPointValue)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
wstringstream traceValueString;
|
wstringstream traceValueString;
|
||||||
|
|
||||||
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
|
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
|
||||||
GraphingControl->GetDisplayRanges(&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());
|
TraceValue->Text = ref new String(traceValueString.str().c_str());
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
|
|||||||
void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnShareClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
|
||||||
void OnShowTracePopupChanged(bool newValue);
|
void OnShowTracePopupChanged(bool newValue);
|
||||||
void OnTracePointChanged(Windows::Foundation::Point newPoint);
|
void OnTracePointChanged(double xPointValue, double yPointValue);
|
||||||
void OnPointerPointChanged(Windows::Foundation::Point newPoint);
|
void OnPointerPointChanged(Windows::Foundation::Point newPoint);
|
||||||
private:
|
private:
|
||||||
void OnDataRequested(
|
void OnDataRequested(
|
||||||
@ -105,7 +105,6 @@ public ref class GraphingCalculator sealed : public Windows::UI::Xaml::Data::INo
|
|||||||
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
|
void OnEquationFormatRequested(Platform::Object ^ sender, CalculatorApp::Controls::MathRichEditBoxFormatRequest ^ e);
|
||||||
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void GraphMenuFlyoutItem_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
|
||||||
std::wstringstream FormatTraceValue(double min, double max, float pointValue);
|
|
||||||
void GraphViewButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void GraphViewButton_Click(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
void ShowShareError();
|
void ShowShareError();
|
||||||
void OnGraphingCalculatorLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
void OnGraphingCalculatorLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||||
|
@ -649,7 +649,7 @@ namespace GraphControl
|
|||||||
if (m_renderMain->Tracing)
|
if (m_renderMain->Tracing)
|
||||||
{
|
{
|
||||||
TracingChangedEvent(true);
|
TracingChangedEvent(true);
|
||||||
TracingValueChangedEvent(m_renderMain->TraceValue);
|
TracingValueChangedEvent(m_renderMain->XTraceValue, m_renderMain->YTraceValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ public
|
|||||||
delegate void TracingChangedEventHandler(bool newValue);
|
delegate void TracingChangedEventHandler(bool newValue);
|
||||||
|
|
||||||
public
|
public
|
||||||
delegate void TracingValueChangedEventHandler(Windows::Foundation::Point value);
|
delegate void TracingValueChangedEventHandler(double xPointValue, double yPointValue);
|
||||||
public
|
public
|
||||||
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);
|
delegate void PointerValueChangedEventHandler(Windows::Foundation::Point value);
|
||||||
|
|
||||||
@ -82,13 +82,6 @@ public enum class GraphViewChangedReason
|
|||||||
void ZoomFromCenter(double scale);
|
void ZoomFromCenter(double scale);
|
||||||
void ResetGrid();
|
void ResetGrid();
|
||||||
|
|
||||||
property Windows::Foundation::Point TraceValue
|
|
||||||
{
|
|
||||||
Windows::Foundation::Point get()
|
|
||||||
{
|
|
||||||
return m_renderMain->TraceValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property Windows::Foundation::Point TraceLocation
|
property Windows::Foundation::Point TraceLocation
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,6 @@ namespace GraphControl::DX
|
|||||||
, m_nearestPointRenderer{ &m_deviceResources }
|
, m_nearestPointRenderer{ &m_deviceResources }
|
||||||
, m_backgroundColor{ {} }
|
, m_backgroundColor{ {} }
|
||||||
, m_swapChainPanel{ panel }
|
, m_swapChainPanel{ panel }
|
||||||
, m_TraceValue(Point(0, 0))
|
|
||||||
, m_TraceLocation(Point(0, 0))
|
, m_TraceLocation(Point(0, 0))
|
||||||
, m_Tracing(false)
|
, m_Tracing(false)
|
||||||
{
|
{
|
||||||
@ -157,21 +156,28 @@ namespace GraphControl::DX
|
|||||||
critical_section::scoped_lock lock(m_criticalSection);
|
critical_section::scoped_lock lock(m_criticalSection);
|
||||||
|
|
||||||
int formulaId = -1;
|
int formulaId = -1;
|
||||||
float nearestPointLocationX, nearestPointLocationY;
|
double outNearestPointValueX, outNearestPointValueY;
|
||||||
double nearestPointValueX, nearestPointValueY, rhoValueOut, thetaValueOut, tValueOut;
|
float outNearestPointLocationX, outNearestPointLocationY;
|
||||||
|
double rhoValueOut, thetaValueOut, tValueOut;
|
||||||
|
|
||||||
|
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
|
||||||
|
m_graph->GetRenderer()->GetDisplayRanges(xAxisMin, xAxisMax, yAxisMin, yAxisMax);
|
||||||
|
double precision = this->GetPrecision(xAxisMax, xAxisMin);
|
||||||
|
|
||||||
m_Tracing = m_graph->GetRenderer()->GetClosePointData(
|
m_Tracing = m_graph->GetRenderer()->GetClosePointData(
|
||||||
trackPoint.X,
|
trackPoint.X,
|
||||||
trackPoint.Y,
|
trackPoint.Y,
|
||||||
|
precision,
|
||||||
formulaId,
|
formulaId,
|
||||||
nearestPointLocationX,
|
outNearestPointLocationX,
|
||||||
nearestPointLocationY,
|
outNearestPointLocationY,
|
||||||
nearestPointValueX,
|
outNearestPointValueX,
|
||||||
nearestPointValueY,
|
outNearestPointValueY,
|
||||||
rhoValueOut,
|
rhoValueOut,
|
||||||
thetaValueOut,
|
thetaValueOut,
|
||||||
tValueOut)
|
tValueOut)
|
||||||
== S_OK;
|
== S_OK;
|
||||||
m_Tracing = m_Tracing && !isnan(nearestPointLocationX) && !isnan(nearestPointLocationY);
|
m_Tracing = m_Tracing && !isnan(outNearestPointLocationX) && !isnan(outNearestPointLocationY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -181,6 +187,22 @@ namespace GraphControl::DX
|
|||||||
return m_Tracing;
|
return m_Tracing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the precision value by computing the max and min
|
||||||
|
/// through this formula:
|
||||||
|
/// 10^(floor(log(max-min))-3)
|
||||||
|
/// https://github.com/microsoft/calculator/issues/998
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="maxAxis">max axis</param>
|
||||||
|
/// <param name="minAxis">min axis</param>
|
||||||
|
/// <returns>the precision value</returns>
|
||||||
|
double RenderMain::GetPrecision(const double maxAxis, const double minAxis)
|
||||||
|
{
|
||||||
|
double exponent = static_cast<double>(floor(log10(maxAxis - minAxis)) - 3);
|
||||||
|
double precision = pow(10, exponent);
|
||||||
|
return precision;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderMain::SetPointRadius(float radius)
|
void RenderMain::SetPointRadius(float radius)
|
||||||
{
|
{
|
||||||
m_nearestPointRenderer.SetRadius(radius);
|
m_nearestPointRenderer.SetRadius(radius);
|
||||||
@ -297,23 +319,27 @@ namespace GraphControl::DX
|
|||||||
}
|
}
|
||||||
|
|
||||||
int formulaId = -1;
|
int formulaId = -1;
|
||||||
float nearestPointLocationX, nearestPointLocationY;
|
double outNearestPointValueX, outNearestPointValueY;
|
||||||
double nearestPointValueX, nearestPointValueY, rhoValueOut, thetaValueOut, tValueOut;
|
double rhoValueOut, thetaValueOut, tValueOut;
|
||||||
|
float outNearestPointLocationX, outNearestPointLocationY;
|
||||||
|
double xAxisMin, xAxisMax, yAxisMin, yAxisMax;
|
||||||
|
renderer->GetDisplayRanges(xAxisMin, xAxisMax, yAxisMin, yAxisMax);
|
||||||
|
double precision = this->GetPrecision(xAxisMax, xAxisMin);
|
||||||
if (renderer->GetClosePointData(
|
if (renderer->GetClosePointData(
|
||||||
trackPoint.X,
|
trackPoint.X,
|
||||||
trackPoint.Y,
|
trackPoint.Y,
|
||||||
|
precision,
|
||||||
formulaId,
|
formulaId,
|
||||||
nearestPointLocationX,
|
outNearestPointLocationX,
|
||||||
nearestPointLocationY,
|
outNearestPointLocationY,
|
||||||
nearestPointValueX,
|
outNearestPointValueX,
|
||||||
nearestPointValueY,
|
outNearestPointValueY,
|
||||||
rhoValueOut,
|
rhoValueOut,
|
||||||
thetaValueOut,
|
thetaValueOut,
|
||||||
tValueOut)
|
tValueOut)
|
||||||
== S_OK)
|
== S_OK)
|
||||||
{
|
{
|
||||||
if (!isnan(nearestPointLocationX) && !isnan(nearestPointLocationY))
|
if (!isnan(outNearestPointLocationX) && !isnan(outNearestPointLocationY))
|
||||||
{
|
{
|
||||||
auto lineColors = m_graph->GetOptions().GetGraphColors();
|
auto lineColors = m_graph->GetOptions().GetGraphColors();
|
||||||
|
|
||||||
@ -323,11 +349,12 @@ namespace GraphControl::DX
|
|||||||
m_nearestPointRenderer.SetColor(D2D1::ColorF(dotColor.R * 65536 + dotColor.G * 256 + dotColor.B, 1.0));
|
m_nearestPointRenderer.SetColor(D2D1::ColorF(dotColor.R * 65536 + dotColor.G * 256 + dotColor.B, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_TraceLocation = Point(nearestPointLocationX, nearestPointLocationY);
|
m_TraceLocation = Point(outNearestPointLocationX, outNearestPointLocationY);
|
||||||
m_nearestPointRenderer.Render(m_TraceLocation);
|
m_nearestPointRenderer.Render(m_TraceLocation);
|
||||||
m_Tracing = true;
|
m_Tracing = true;
|
||||||
m_TraceLocation = Point(nearestPointLocationX, nearestPointLocationY);
|
m_TraceLocation = Point(outNearestPointLocationX, outNearestPointLocationY);
|
||||||
m_TraceValue = Point(nearestPointValueX, nearestPointValueY);
|
m_XTraceValue = outNearestPointValueX;
|
||||||
|
m_YTraceValue = outNearestPointValueY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -94,11 +94,19 @@ namespace GraphControl::DX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property Windows::Foundation::Point TraceValue
|
property double XTraceValue
|
||||||
{
|
{
|
||||||
Windows::Foundation::Point get()
|
double get()
|
||||||
{
|
{
|
||||||
return m_TraceValue;
|
return m_XTraceValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property double YTraceValue
|
||||||
|
{
|
||||||
|
double get()
|
||||||
|
{
|
||||||
|
return m_YTraceValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +151,7 @@ namespace GraphControl::DX
|
|||||||
void OnCompositionScaleChanged(Windows::UI::Xaml::Controls::SwapChainPanel ^ sender, Object ^ args);
|
void OnCompositionScaleChanged(Windows::UI::Xaml::Controls::SwapChainPanel ^ sender, Object ^ args);
|
||||||
void OnSizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
void OnSizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||||
|
|
||||||
|
double GetPrecision(const double maxAxis, const double minAxis);
|
||||||
private:
|
private:
|
||||||
DX::DeviceResources m_deviceResources;
|
DX::DeviceResources m_deviceResources;
|
||||||
NearestPointRenderer m_nearestPointRenderer;
|
NearestPointRenderer m_nearestPointRenderer;
|
||||||
@ -179,8 +188,9 @@ namespace GraphControl::DX
|
|||||||
Windows::Foundation::IAsyncAction ^ m_inputLoopWorker = nullptr;
|
Windows::Foundation::IAsyncAction ^ m_inputLoopWorker = nullptr;
|
||||||
Windows::UI::Core::CoreIndependentInputSource ^ m_coreInput = nullptr;
|
Windows::UI::Core::CoreIndependentInputSource ^ m_coreInput = nullptr;
|
||||||
|
|
||||||
// What is the current trace value
|
double m_XTraceValue;
|
||||||
Windows::Foundation::Point m_TraceValue;
|
double m_YTraceValue;
|
||||||
|
|
||||||
|
|
||||||
// And where is it located on screen
|
// And where is it located on screen
|
||||||
Windows::Foundation::Point m_TraceLocation;
|
Windows::Foundation::Point m_TraceLocation;
|
||||||
|
@ -40,6 +40,7 @@ namespace MockGraphingImpl
|
|||||||
virtual HRESULT GetClosePointData(
|
virtual HRESULT GetClosePointData(
|
||||||
double inScreenPointX,
|
double inScreenPointX,
|
||||||
double inScreenPointY,
|
double inScreenPointY,
|
||||||
|
double precision,
|
||||||
int& formulaIdOut,
|
int& formulaIdOut,
|
||||||
float& xScreenPointOut,
|
float& xScreenPointOut,
|
||||||
float& yScreenPointOut,
|
float& yScreenPointOut,
|
||||||
@ -52,11 +53,9 @@ namespace MockGraphingImpl
|
|||||||
formulaIdOut = 0;
|
formulaIdOut = 0;
|
||||||
xScreenPointOut = 0;
|
xScreenPointOut = 0;
|
||||||
yScreenPointOut = 0;
|
yScreenPointOut = 0;
|
||||||
|
precision = 0;
|
||||||
xValueOut = 0;
|
xValueOut = 0;
|
||||||
yValueOut = 0;
|
yValueOut = 0;
|
||||||
rhoValueOut = 0;
|
|
||||||
thetaValueOut = 0;
|
|
||||||
tValueOut = 0;
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +109,7 @@ namespace MockGraphingImpl
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_xMin;
|
double m_xMin;
|
||||||
double m_xMax;
|
double m_xMax;
|
||||||
|
@ -7,3 +7,5 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
@ -23,7 +23,7 @@ namespace Graphing::Renderer
|
|||||||
virtual HRESULT SetDpi(float dpiX, float dpiY) = 0;
|
virtual HRESULT SetDpi(float dpiX, float dpiY) = 0;
|
||||||
|
|
||||||
virtual HRESULT DrawD2D1(ID2D1Factory* pDirect2dFactory, ID2D1RenderTarget* pRenderTarget, bool& hasSomeMissingDataOut) = 0;
|
virtual HRESULT DrawD2D1(ID2D1Factory* pDirect2dFactory, ID2D1RenderTarget* pRenderTarget, bool& hasSomeMissingDataOut) = 0;
|
||||||
virtual HRESULT GetClosePointData(double inScreenPointX, double inScreenPointY, int& formulaIdOut, float& xScreenPointOut, float& yScreenPointOut, double& xValueOut, double& yValueOut, double& rhoValueOut, double& thetaValueOut, double& tValueOut) = 0;
|
virtual HRESULT GetClosePointData(double inScreenPointX, double inScreenPointY, double precision, int& formulaIdOut, float& xScreenPointOut, float& yScreenPointOut, double& xValueOut, double& yValueOut, double& rhoValueOut, double& thetaValueOut, double& tValueOut) = 0;
|
||||||
|
|
||||||
virtual HRESULT ScaleRange(double centerX, double centerY, double scale) = 0;
|
virtual HRESULT ScaleRange(double centerX, double centerY, double scale) = 0;
|
||||||
virtual HRESULT ChangeRange(ChangeRangeAction action) = 0;
|
virtual HRESULT ChangeRange(ChangeRangeAction action) = 0;
|
||||||
@ -34,6 +34,5 @@ namespace Graphing::Renderer
|
|||||||
virtual HRESULT PrepareGraph() = 0;
|
virtual HRESULT PrepareGraph() = 0;
|
||||||
|
|
||||||
virtual HRESULT GetBitmap(std::shared_ptr<Graphing::IBitmap>& bitmapOut, bool& hasSomeMissingDataOut) = 0;
|
virtual HRESULT GetBitmap(std::shared_ptr<Graphing::IBitmap>& bitmapOut, bool& hasSomeMissingDataOut) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user