Update Analysis after variables change (#1056)
* Updated Analyze Equation to set the current value of the variables before analysis * Updated SetGraphArgs to take in a graph parameter and use it in AnalyzeEquation()
This commit is contained in:
parent
915e0a8220
commit
d7e7f46c99
@ -199,6 +199,8 @@ namespace GraphControl
|
|||||||
{
|
{
|
||||||
if (auto graph = GetGraph(equation))
|
if (auto graph = GetGraph(equation))
|
||||||
{
|
{
|
||||||
|
SetGraphArgs(graph);
|
||||||
|
|
||||||
if (auto analyzer = graph->GetAnalyzer())
|
if (auto analyzer = graph->GetAnalyzer())
|
||||||
{
|
{
|
||||||
vector<Equation ^> equationVector;
|
vector<Equation ^> equationVector;
|
||||||
@ -300,7 +302,7 @@ namespace GraphControl
|
|||||||
if (initResult != nullopt)
|
if (initResult != nullopt)
|
||||||
{
|
{
|
||||||
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
||||||
SetGraphArgs();
|
SetGraphArgs(m_graph);
|
||||||
|
|
||||||
m_renderMain->Graph = m_graph;
|
m_renderMain->Graph = m_graph;
|
||||||
|
|
||||||
@ -329,7 +331,7 @@ namespace GraphControl
|
|||||||
if (initResult != nullopt)
|
if (initResult != nullopt)
|
||||||
{
|
{
|
||||||
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
UpdateGraphOptions(m_graph->GetOptions(), validEqs);
|
||||||
SetGraphArgs();
|
SetGraphArgs(m_graph);
|
||||||
|
|
||||||
m_renderMain->Graph = m_graph;
|
m_renderMain->Graph = m_graph;
|
||||||
co_await m_renderMain->RunRenderPassAsync();
|
co_await m_renderMain->RunRenderPassAsync();
|
||||||
@ -366,15 +368,15 @@ namespace GraphControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grapher::SetGraphArgs()
|
void Grapher::SetGraphArgs(shared_ptr<IGraph> graph)
|
||||||
{
|
{
|
||||||
if (m_graph != nullptr && m_renderMain != nullptr)
|
if (graph != nullptr && m_renderMain != nullptr)
|
||||||
{
|
{
|
||||||
critical_section::scoped_lock lock(m_renderMain->GetCriticalSection());
|
critical_section::scoped_lock lock(m_renderMain->GetCriticalSection());
|
||||||
|
|
||||||
for (auto variable : Variables)
|
for (auto variable : Variables)
|
||||||
{
|
{
|
||||||
m_graph->SetArgValue(variable->Key->Data(), variable->Value);
|
graph->SetArgValue(variable->Key->Data(), variable->Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,8 +445,7 @@ namespace GraphControl
|
|||||||
|
|
||||||
if (m_graph != nullptr && m_renderMain != nullptr)
|
if (m_graph != nullptr && m_renderMain != nullptr)
|
||||||
{
|
{
|
||||||
|
auto workItemHandler = ref new WorkItemHandler([this, variableName, newValue](IAsyncAction ^ action) {
|
||||||
auto workItemHandler = ref new WorkItemHandler([this, variableName, newValue](IAsyncAction ^ action) {
|
|
||||||
m_renderMain->GetCriticalSection().lock();
|
m_renderMain->GetCriticalSection().lock();
|
||||||
m_graph->SetArgValue(variableName->Data(), newValue);
|
m_graph->SetArgValue(variableName->Data(), newValue);
|
||||||
m_renderMain->GetCriticalSection().unlock();
|
m_renderMain->GetCriticalSection().unlock();
|
||||||
@ -453,7 +454,6 @@ namespace GraphControl
|
|||||||
});
|
});
|
||||||
|
|
||||||
ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::None);
|
ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::None);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public
|
|||||||
concurrency::task<void> TryPlotGraph(bool keepCurrentView, bool shouldRetry);
|
concurrency::task<void> TryPlotGraph(bool keepCurrentView, bool shouldRetry);
|
||||||
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation ^>& validEqs);
|
void UpdateGraphOptions(Graphing::IGraphingOptions& options, const std::vector<Equation ^>& validEqs);
|
||||||
std::vector<Equation ^> GetGraphableEquations();
|
std::vector<Equation ^> GetGraphableEquations();
|
||||||
void SetGraphArgs();
|
void SetGraphArgs(std::shared_ptr<Graphing::IGraph> graph);
|
||||||
std::shared_ptr<Graphing::IGraph> GetGraph(GraphControl::Equation ^ equation);
|
std::shared_ptr<Graphing::IGraph> GetGraph(GraphControl::Equation ^ equation);
|
||||||
void UpdateVariables();
|
void UpdateVariables();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user