Updates ResetGrid to account for when equations are added during Manual Adjustment mode (#1231)
* updated the reset grid logic to track and set the initial range after an equation is added * When in manual adjustment mode and an equation is added, replot the graph when reset is called * remove members that are no longer needed * Added logic to include the PrepareGraph() and removed re-graphing in the ResetGrid method * skip SetDisplayRanges if TryInitialize returns a nullopt so there is no crash * Updated the logic to handle the case where the range is updated via settings * Fix bug with reset view hyperlink * Updated the logic for graph settings updating the graph range * Rebased with the latest, fixed issues with the rebase Author: Stephanie Anderl <46726333+sanderl@users.noreply.github.com> * Update the internals version of calculator to the latest so that the PrepareGraph API available
This commit is contained in:
parent
81ea002cf9
commit
76e33ef159
@ -29,7 +29,7 @@ jobs:
|
||||
downloadDirectory: $(Build.SourcesDirectory)
|
||||
vstsFeed: WindowsApps
|
||||
vstsFeedPackage: calculator-internals
|
||||
vstsPackageVersion: 0.0.40
|
||||
vstsPackageVersion: 0.0.44
|
||||
|
||||
- template: ./build-single-architecture.yaml
|
||||
parameters:
|
||||
|
@ -96,7 +96,7 @@ jobs:
|
||||
downloadDirectory: $(Build.SourcesDirectory)
|
||||
vstsFeed: WindowsApps
|
||||
vstsFeedPackage: calculator-internals
|
||||
vstsPackageVersion: 0.0.40
|
||||
vstsPackageVersion: 0.0.44
|
||||
|
||||
- powershell: |
|
||||
# Just modify this line to indicate where your en-us PDP file is. Leave the other lines alone.
|
||||
|
@ -118,22 +118,36 @@ namespace GraphControl
|
||||
{
|
||||
if (m_graph != nullptr && m_renderMain != nullptr)
|
||||
{
|
||||
if (auto renderer = m_graph->GetRenderer())
|
||||
if(auto renderer = m_graph->GetRenderer())
|
||||
{
|
||||
if (m_replot)
|
||||
HRESULT hr;
|
||||
|
||||
// Reset the Grid using the m_initialDisplayRange properties when the user was last in Manual Adjustment mode and an equation was added.
|
||||
// Reset the Grid using the TryPlotGraph method when the range is updated via Graph Settings. Return out of this block so we don't render 2 times.
|
||||
// Reset the Grid using the ResetRange() in all other cases.
|
||||
if (m_resetUsingInitialDisplayRange)
|
||||
{
|
||||
hr = renderer->SetDisplayRanges(m_initialDisplayRangeXMin, m_initialDisplayRangeXMax, m_initialDisplayRangeYMin, m_initialDisplayRangeYMax);
|
||||
m_resetUsingInitialDisplayRange = false;
|
||||
}
|
||||
else if (m_rangeUpdatedBySettings)
|
||||
{
|
||||
IsKeepCurrentView = false;
|
||||
m_replot = false;
|
||||
TryPlotGraph(false, false);
|
||||
|
||||
m_rangeUpdatedBySettings = false;
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
|
||||
return;
|
||||
}
|
||||
else if (SUCCEEDED(renderer->ResetRange()))
|
||||
else
|
||||
{
|
||||
hr = renderer->ResetRange();
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
|
||||
}
|
||||
|
||||
GraphViewChangedEvent(this, GraphViewChangedReason::Reset);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1097,18 +1111,31 @@ optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bo
|
||||
{
|
||||
if (keepCurrentView || IsKeepCurrentView)
|
||||
{
|
||||
auto renderer = m_graph->GetRenderer();
|
||||
double xMin, xMax, yMin, yMax;
|
||||
m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
renderer->GetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
auto initResult = m_graph->TryInitialize(graphingExp);
|
||||
m_graph->GetRenderer()->SetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
if (initResult != nullopt)
|
||||
{
|
||||
if (IsKeepCurrentView)
|
||||
{
|
||||
// PrepareGraph() populates the values of the graph after TryInitialize but before rendering. This allows us to get the range of the graph to be rendered.
|
||||
if (SUCCEEDED(renderer->PrepareGraph()))
|
||||
{
|
||||
// Get the initial display ranges from the graph that was just initialized to be used in ResetGrid if they user clicks the GraphView button.
|
||||
renderer->GetDisplayRanges(m_initialDisplayRangeXMin, m_initialDisplayRangeXMax, m_initialDisplayRangeYMin, m_initialDisplayRangeYMax);
|
||||
m_resetUsingInitialDisplayRange = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_replot = true;
|
||||
renderer->SetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
}
|
||||
|
||||
return initResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_replot = false;
|
||||
m_resetUsingInitialDisplayRange = false;
|
||||
return m_graph->TryInitialize(graphingExp);
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public enum class GraphViewChangedReason
|
||||
if (auto render = m_graph->GetRenderer())
|
||||
{
|
||||
render->SetDisplayRanges(xMin, xMax, yMin, yMax);
|
||||
m_replot = true;
|
||||
m_rangeUpdatedBySettings = true;
|
||||
if (m_renderMain)
|
||||
{
|
||||
m_renderMain->RunRenderPass();
|
||||
@ -352,7 +352,12 @@ public enum class GraphViewChangedReason
|
||||
Windows::UI::Core::CoreCursor ^ m_cachedCursor;
|
||||
int m_errorType;
|
||||
int m_errorCode;
|
||||
bool m_replot;
|
||||
bool m_resetUsingInitialDisplayRange;
|
||||
bool m_rangeUpdatedBySettings;
|
||||
double m_initialDisplayRangeXMin;
|
||||
double m_initialDisplayRangeXMax;
|
||||
double m_initialDisplayRangeYMin;
|
||||
double m_initialDisplayRangeYMax;
|
||||
|
||||
public:
|
||||
Windows::Storage::Streams::RandomAccessStreamReference ^ GetGraphBitmapStream();
|
||||
|
@ -98,6 +98,11 @@ namespace MockGraphingImpl
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual HRESULT PrepareGraph()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual HRESULT GetBitmap(std::shared_ptr<Graphing::IBitmap>& bitmapOut, bool& hasSomeMissingDataOut)
|
||||
{
|
||||
bitmapOut = std::make_shared<Bitmap>();
|
||||
|
@ -23,17 +23,7 @@ namespace Graphing::Renderer
|
||||
virtual HRESULT SetDpi(float dpiX, float dpiY) = 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, 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 ChangeRange(ChangeRangeAction action) = 0;
|
||||
@ -41,6 +31,7 @@ namespace Graphing::Renderer
|
||||
virtual HRESULT ResetRange() = 0;
|
||||
virtual HRESULT GetDisplayRanges(double& xMin, double& xMax, double& yMin, double& yMax) = 0;
|
||||
virtual HRESULT SetDisplayRanges(double xMin, double xMax, double yMin, double yMax) = 0;
|
||||
virtual HRESULT PrepareGraph() = 0;
|
||||
|
||||
virtual HRESULT GetBitmap(std::shared_ptr<Graphing::IBitmap>& bitmapOut, bool& hasSomeMissingDataOut) = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user