void ltGraph::SetResponseCurve( ltResponseCurve *curve ) { m_curve = curve; SetCurveName( curve->GetName() ); SetEquationText( curve->GetEquationText() ); }
void CMainDlg::UpdateEquation() { auto solution = m_solver.GetEquationRoots(); struct SolutionPrinter : boost::static_visitor<void> { CMainDlg & self; SolutionPrinter(CMainDlg &self) :self(self) { } void operator()(NoRealRoots) { self.SetSolutionText(L"No real roots"); } void operator()(InfiniteNumberOfRoots) { self.SetSolutionText(L"Infinite number of roots"); } void operator()(double root) { self.SetSolutionText((boost::wformat(L"One root: %1%") % root).str()); } void operator()(const std::pair<double, double> & roots) { self.SetSolutionText((boost::wformat(L"Two roots: %1% and %2%") % roots.first % roots.second).str()); } }; SolutionPrinter printer(*this); solution.apply_visitor(printer); auto ToSignedString = [](double value) { std::wostringstream strm; strm << std::abs(value); return ((value < 0) ? L"- " : L"+ ") + strm.str(); }; SetEquationText((boost::wformat(L"%1%x\u00b2 %2%x %3% = 0") % m_solver.GetQuadraticCoeff() % ToSignedString(m_solver.GetLinearCoeff()) % ToSignedString(m_solver.GetConstantCoeff())).str()); }