diff --git a/src/GraphControl/Control/Grapher.cpp b/src/GraphControl/Control/Grapher.cpp index 1e2b6c5..3bcb9e9 100644 --- a/src/GraphControl/Control/Grapher.cpp +++ b/src/GraphControl/Control/Grapher.cpp @@ -120,11 +120,20 @@ namespace GraphControl { if (auto renderer = m_graph->GetRenderer()) { - if (SUCCEEDED(renderer->ResetRange())) + if (m_replot) + { + IsKeepCurrentView = false; + m_replot = false; + TryPlotGraph(false, false); + + } + else if (SUCCEEDED(renderer->ResetRange())) { m_renderMain->RunRenderPass(); - GraphViewChangedEvent(this, GraphViewChangedReason::Reset); } + + GraphViewChangedEvent(this, GraphViewChangedReason::Reset); + return; } } } @@ -1093,10 +1102,13 @@ optional>> Grapher::TryInitializeGraph(bo auto initResult = m_graph->TryInitialize(graphingExp); m_graph->GetRenderer()->SetDisplayRanges(xMin, xMax, yMin, yMax); + m_replot = true; + return initResult; } else { + m_replot = false; return m_graph->TryInitialize(graphingExp); } } diff --git a/src/GraphControl/Control/Grapher.h b/src/GraphControl/Control/Grapher.h index e3a0389..438a08a 100644 --- a/src/GraphControl/Control/Grapher.h +++ b/src/GraphControl/Control/Grapher.h @@ -254,6 +254,7 @@ public enum class GraphViewChangedReason if (auto render = m_graph->GetRenderer()) { render->SetDisplayRanges(xMin, xMax, yMin, yMax); + m_replot = true; if (m_renderMain) { m_renderMain->RunRenderPass(); @@ -351,6 +352,7 @@ public enum class GraphViewChangedReason Windows::UI::Core::CoreCursor ^ m_cachedCursor; int m_errorType; int m_errorCode; + bool m_replot; public: Windows::Storage::Streams::RandomAccessStreamReference ^ GetGraphBitmapStream();