void Chart::DrawYGrid(const fixed tic_step, const fixed zero, enum Style Style, const fixed unit_step, bool draw_units) { if (!tic_step) return; POINT line[2]; int xmin, ymin, xmax, ymax; for (fixed yval = zero; yval <= y_max; yval += tic_step) { xmin = rc.left; ymin = (int)((y_max - yval) * yscale) + rc.top; xmax = rc.right; ymax = ymin; line[0].x = xmin + BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval < y_max) && (ymin >= rc.top) && (ymin <= rc.bottom - BORDER_Y)) { StyleLine(line[0], line[1], Style); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval * unit_step / tic_step, unit_step); canvas.background_transparent(); canvas.text(xmin + IBLSCALE(8), ymin, unit_text); } } } for (fixed yval = zero - tic_step; yval >= y_min; yval -= tic_step) { xmin = rc.left; ymin = (int)((y_max - yval) * yscale) + rc.top; xmax = rc.right; ymax = ymin; line[0].x = xmin + BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval > y_min) && (ymin >= rc.top) && (ymin <= rc.bottom - BORDER_Y)) { StyleLine(line[0], line[1], Style); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval * unit_step / tic_step, unit_step); canvas.background_transparent(); canvas.text(xmin + IBLSCALE(8), ymin, unit_text); } } } }
void ChartRenderer::DrawXGrid(double tic_step, const Pen &pen, double unit_step, bool draw_units) { assert(tic_step > 0); canvas.Select(pen); canvas.Select(look.axis_value_font); canvas.SetBackgroundTransparent(); RasterPoint line[2]; /** the minimum next position of the text, to avoid overlapping */ int next_text = rc.left; /* increase tic step so graph not too crowded */ while ((x.max - x.min) / tic_step > 10) { tic_step *= 2; unit_step *= 2; } // bool do_units = ((x.max-zero)/tic_step)<10; line[0].y = rc.top; line[1].y = rc.bottom - padding_bottom; const int y = line[1].y - canvas.GetFontHeight(); auto start = (int)(x.min / tic_step) * tic_step; for (auto xval = start; xval <= x.max; xval += tic_step) { const int xmin = ScreenX(xval); line[0].x = line[1].x = xmin; // STYLE_THINDASHPAPER if (xmin >= rc.left + padding_left && xmin <= rc.right) { canvas.DrawLine(line[0], line[1]); if (draw_units && xmin >= next_text) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval * unit_step / tic_step, unit_step); canvas.DrawText(xmin, y, unit_text); next_text = xmin + canvas.CalcTextSize(unit_text).cx + Layout::GetTextPadding(); } } } }
void ChartRenderer::DrawYGrid(double tic_step, const Pen &pen, double unit_step, bool draw_units) { assert(tic_step > 0); canvas.Select(pen); canvas.Select(look.axis_value_font); canvas.SetBackgroundTransparent(); RasterPoint line[2]; /* increase tic step so graph not too crowded */ while ((y.max-y.min)/tic_step > 10) { tic_step *= 2; unit_step *= 2; } line[0].x = rc.left + padding_left; line[1].x = rc.right; const int x = line[0].x; auto start = (int)(y.min / tic_step) * tic_step; for (auto yval = start; yval <= y.max; yval += tic_step) { const int ymin = ScreenY(yval); line[0].y = line[1].y = ymin; // STYLE_THINDASHPAPER if (ymin >= rc.top && ymin <= rc.bottom - padding_bottom) { canvas.DrawLine(line[0], line[1]); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval * unit_step / tic_step, unit_step); canvas.DrawText(x, ymin, unit_text); } } } }
void Chart::DrawXGrid(const fixed tic_step, const fixed zero, enum Style Style, const fixed unit_step, bool draw_units) { if (!tic_step) return; POINT line[2]; int xmin, ymin, xmax, ymax; /** the minimum next position of the text, to avoid overlapping */ int next_text = rc.left; // bool do_units = ((x_max-zero)/tic_step)<10; for (fixed xval = zero; xval <= x_max; xval += tic_step) { xmin = (int)((xval - x_min) * xscale) + rc.left + BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax - BORDER_Y; // STYLE_THINDASHPAPER if ((xval < x_max) && (xmin >= rc.left + BORDER_X) && (xmin <= rc.right)) { StyleLine(line[0], line[1], Style); if (draw_units && xmin >= next_text) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval * unit_step / tic_step, unit_step); canvas.background_transparent(); canvas.text(xmin, ymax - IBLSCALE(17), unit_text); next_text = xmin + canvas.text_size(unit_text).cx + Layout::FastScale(2); } } } for (fixed xval = zero - tic_step; xval >= x_min; xval -= tic_step) { xmin = (int)((xval - x_min) * xscale) + rc.left + BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax - BORDER_Y; // STYLE_THINDASHPAPER if ((xval > x_min) && (xmin >= rc.left + BORDER_X) && (xmin <= rc.right)) { StyleLine(line[0], line[1], Style); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval * unit_step / tic_step, unit_step); canvas.background_transparent(); canvas.text(xmin, ymax - IBLSCALE(17), unit_text); } } } }
void Statistics::DrawYGrid(LKSurface& Surface, const RECT& rc, const double tic_step, const double zero, const int Style, const double unit_step, bool draw_units) { POINT line[2]; SIZE tsize; double yval; if(INVERTCOLORS || IsDithered()) Surface.SelectObject(LK_BLACK_PEN); int xmin, ymin, xmax, ymax; if (!tic_step) return; for (yval=zero; yval<= y_max; yval+= tic_step) { xmin = rc.left; ymin = (int)((y_max-yval)*yscale)+rc.top -BORDER_Y; xmax = rc.right; ymax = ymin; line[0].x = xmin+BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval< y_max) && (ymin>=rc.top) && (ymin<=rc.bottom-BORDER_Y)) { StyleLine(Surface, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval*unit_step/tic_step, unit_step); Surface.GetTextSize(unit_text, &tsize); Surface.SetBackgroundOpaque(); Surface.DrawText(xmin, ymin-tsize.cy/2, unit_text); Surface.SetBackgroundTransparent(); } } } for (yval=zero-tic_step; yval>= y_min; yval-= tic_step) { xmin = rc.left; ymin = (int)((y_max-yval)*yscale)+rc.top-BORDER_Y; xmax = rc.right; ymax = ymin; line[0].x = xmin+BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval> y_min) && (ymin>=rc.top) && (ymin<=rc.bottom-BORDER_Y)) { StyleLine(Surface, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval*unit_step/tic_step, unit_step); Surface.GetTextSize(unit_text, &tsize); Surface.SetBackgroundOpaque(); Surface.DrawText(xmin, ymin-tsize.cy/2, unit_text); Surface.SetBackgroundTransparent(); } } } }
void Statistics::DrawXGrid(LKSurface& Surface, const RECT& rc, const double tic_step, const double zero, const int Style, const double unit_step, bool draw_units) { if(INVERTCOLORS || IsDithered()) Surface.SelectObject(LK_BLACK_PEN); POINT line[2]; double xval; SIZE tsize; int xmin, ymin, xmax, ymax; if (!tic_step) return; LKASSERT(tic_step!=0); // bool do_units = ((x_max-zero)/tic_step)<10; for (xval=zero; xval<= x_max; xval+= tic_step) { xmin = (int)((xval-x_min)*xscale)+rc.left+BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax-BORDER_Y; // STYLE_THINDASHPAPER if ((xval< x_max) && (xmin>=rc.left+BORDER_X) && (xmin<=rc.right)) { StyleLine(Surface, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); Surface.GetTextSize(unit_text, &tsize); Surface.SetBackgroundOpaque(); Surface.DrawText(xmin-tsize.cx/2, ymax-tsize.cy, unit_text); Surface.SetBackgroundTransparent(); } } } for (xval=zero-tic_step; xval>= x_min; xval-= tic_step) { xmin = (int)((xval-x_min)*xscale)+rc.left+BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax-BORDER_Y; // STYLE_THINDASHPAPER if ((xval> x_min) && (xmin>=rc.left+BORDER_X) && (xmin<=rc.right)) { StyleLine(Surface, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); Surface.GetTextSize(unit_text, &tsize); Surface.SetBackgroundOpaque(); Surface.DrawText(xmin-tsize.cx/2, ymax-tsize.cy, unit_text); Surface.SetBackgroundTransparent(); } } } }
void Statistics::DrawYGrid(HDC hdc, const RECT rc, const double tic_step, const double zero, const int Style, const double unit_step, bool draw_units) { POINT line[2]; SIZE tsize; double yval; if(INVERTCOLORS) SelectObject(hdc, GetStockObject(BLACK_PEN)); int xmin, ymin, xmax, ymax; if (!tic_step) return; for (yval=zero; yval<= y_max; yval+= tic_step) { xmin = rc.left; ymin = (int)((y_max-yval)*yscale)+rc.top -BORDER_Y; xmax = rc.right; ymax = ymin; line[0].x = xmin+BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval< y_max) && (ymin>=rc.top) && (ymin<=rc.bottom-BORDER_Y)) { StyleLine(hdc, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); GetTextExtentPoint(hdc, unit_text, _tcslen(unit_text), &tsize); ExtTextOut(hdc, xmin, ymin-tsize.cy/2, ETO_OPAQUE, NULL, unit_text, _tcslen(unit_text), NULL); // SetBkMode(hdc, TRANSPARENT); } } } for (yval=zero-tic_step; yval>= y_min; yval-= tic_step) { xmin = rc.left; ymin = (int)((y_max-yval)*yscale)+rc.top-BORDER_Y; xmax = rc.right; ymax = ymin; line[0].x = xmin+BORDER_X; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax; // STYLE_THINDASHPAPER if ((yval> y_min) && (ymin>=rc.top) && (ymin<=rc.bottom-BORDER_Y)) { StyleLine(hdc, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, yval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); GetTextExtentPoint(hdc, unit_text, _tcslen(unit_text), &tsize); ExtTextOut(hdc, xmin, ymin-tsize.cy/2, ETO_OPAQUE, NULL, unit_text, _tcslen(unit_text), NULL); // SetBkMode(hdc, TRANSPARENT); } } } }
void Statistics::DrawXGrid(HDC hdc, const RECT rc, const double tic_step, const double zero, const int Style, const double unit_step, bool draw_units) { if(INVERTCOLORS) SelectObject(hdc, GetStockObject(BLACK_PEN)); POINT line[2]; double xval; SIZE tsize; int xmin, ymin, xmax, ymax; if (!tic_step) return; LKASSERT(tic_step!=0); // bool do_units = ((x_max-zero)/tic_step)<10; for (xval=zero; xval<= x_max; xval+= tic_step) { xmin = (int)((xval-x_min)*xscale)+rc.left+BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax-BORDER_Y; // STYLE_THINDASHPAPER if ((xval< x_max) && (xmin>=rc.left+BORDER_X) && (xmin<=rc.right)) { StyleLine(hdc, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); GetTextExtentPoint(hdc, unit_text, _tcslen(unit_text), &tsize); ExtTextOut(hdc, xmin-tsize.cx/2, ymax-tsize.cy , ETO_OPAQUE, NULL, unit_text, _tcslen(unit_text), NULL); SetBkMode(hdc, TRANSPARENT); } } } for (xval=zero-tic_step; xval>= x_min; xval-= tic_step) { xmin = (int)((xval-x_min)*xscale)+rc.left+BORDER_X; ymin = rc.top; xmax = xmin; ymax = rc.bottom; line[0].x = xmin; line[0].y = ymin; line[1].x = xmax; line[1].y = ymax-BORDER_Y; // STYLE_THINDASHPAPER if ((xval> x_min) && (xmin>=rc.left+BORDER_X) && (xmin<=rc.right)) { StyleLine(hdc, line[0], line[1], Style, rc); if (draw_units) { TCHAR unit_text[MAX_PATH]; FormatTicText(unit_text, xval*unit_step/tic_step, unit_step); // SetBkMode(hdc, OPAQUE); GetTextExtentPoint(hdc, unit_text, _tcslen(unit_text), &tsize); ExtTextOut(hdc, xmin-tsize.cx/2, ymax-tsize.cy, ETO_OPAQUE, NULL, unit_text, _tcslen(unit_text), NULL); SetBkMode(hdc, TRANSPARENT); } } } }