Minsky: 3.17.0
equationDisplay.cc
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2023
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "cairoItems.h"
21 #include "equationDisplay.h"
22 #include "equationDisplay.rcd"
23 #include "equationDisplay.xcd"
24 
25 #include "equations.h"
26 #include "minsky.h"
27 #include "progress.h"
28 
29 #include "item.rcd"
30 #include "noteBase.rcd"
31 #include "port.rcd"
32 #include "minsky_epilogue.h"
33 
34 namespace minsky
35 {
36  bool EquationDisplay::redraw(int x0, int y0, int width, int height)
37  {
38  if (surface.get()) {
39  const BusyCursor busy(m);
40  const MathDAG::SystemOfEquations system(m);
41  cairo_rectangle(surface->cairo(),0,0,width,height);
42  cairo_clip(surface->cairo());
43  cairo_move_to(surface->cairo(),offsx,offsy);
44  cairo_scale(surface->cairo(),m_zoomFactor,m_zoomFactor);
45  system.renderEquations(*surface,height);
46  if (m.flags & Minsky::fullEqnDisplay_needed)
47  {
48  ecolab::cairo::Surface surf
49  (cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,NULL));
50  system.renderEquations(surf,std::numeric_limits<double>::max());
51  m_width=surf.width();
52  m_height=surf.height();
53  m.flags &= ~Minsky::fullEqnDisplay_needed;
54  }
55  return true;
56  }
57  return surface.get();
58  }
59 }
60 
bool redraw(int x0, int y0, int width, int height) override
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::EquationDisplay)
void renderEquations(ecolab::cairo::Surface &, double height) const
render equations into a cairo context