35void ChartPrintout::DrawPage(wxDC* dc,
int page) {
38 top_frame::Get()->GetAbstractPrimaryCanvas()->GetClientSize(&sx, &sy);
49 max_x += (2 * margin_x);
50 max_y += (2 * margin_y);
57 float scale_x = (float)(w / max_x);
58 float scale_y = (float)(h / max_y);
61 float actual_scale = wxMin(scale_x, scale_y);
64 float pos_x = (float)((w - (max_x * actual_scale)) / 2.0);
65 float pos_y = (float)((h - (max_y * actual_scale)) / 2.0);
67 pos_x = wxMax(pos_x, margin_x);
68 pos_y = wxMax(pos_y, margin_y);
71 dc->SetUserScale(actual_scale, actual_scale);
72 dc->SetDeviceOrigin((
long)pos_x, (
long)pos_y);
78 if (m_gl_bmp.IsOk()) {
80 mdc.SelectObject(m_gl_bmp);
81 dc->Blit(0, 0, m_gl_bmp.GetWidth(), m_gl_bmp.GetHeight(), &mdc, 0, 0);
82 mdc.SelectObject(wxNullBitmap);
88 wxBitmap* scratch_bitmap =
89 top_frame::Get()->GetAbstractPrimaryCanvas()->GetScratchBitmap();
90 mdc.SelectObject(*scratch_bitmap);
91 dc->Blit(0, 0, scratch_bitmap->GetWidth(), scratch_bitmap->GetHeight(),
94 mdc.SelectObject(wxNullBitmap);
101 int gsx = top_frame::Get()->GetWxGlCanvas()->GetSize().x;
102 int gsy = top_frame::Get()->GetWxGlCanvas()->GetSize().y;
104 unsigned char* buffer = (
unsigned char*)malloc(gsx * gsy * 4);
105 glReadPixels(0, 0, gsx, gsy, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
107 unsigned char* e = (
unsigned char*)malloc(gsx * gsy * 3);
110 for (
int p = 0; p < gsx * gsy; p++) {
111 e[3 * p + 0] = buffer[4 * p + 0];
112 e[3 * p + 1] = buffer[4 * p + 1];
113 e[3 * p + 2] = buffer[4 * p + 2];
118 wxImage image(gsx, gsy);
120 wxImage mir_imag = image.Mirror(
false);
121 m_gl_bmp = wxBitmap(mir_imag);
Generic Chart canvas base.
void GenerateGLbmp()
In OpenGL mode, make the bitmap capture of the screen before the print method starts as to be sure th...
Global variables stored in configuration file.
OpenGL chart rendering canvas.
Print chart canvas mix-in.
Abstract gFrame/MyFrame interface.