-
- /* calculate position of axes */
-
- /* x-axis */
- if (ez.s_ycross == TRUE) { /* convert users' world-coord */
- xaxispos = ez.v_ycross; /* axis to its position in NDC */
- sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
- sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
- x = xgw_min;
- wc_to_ndc (x, xaxispos, &x, &xaxispos);
- } else
- xaxispos = ya_min;
-
- /* y-axis */
- if (ez.s_xcross == TRUE) { /* convert users' world-coord */
- yaxispos = ez.v_xcross; /* axis to its NDC position */
- sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
- sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
- y = ygw_min;
- wc_to_ndc (yaxispos, y, &yaxispos, &y);
- } else
- yaxispos = xa_min;
-
- /*-------------*/
- /* draw x-axis */
- /*-------------*/
-
- if (ez.o_xaxis == LINEAR) {
- sgp2_window (xp_min, yp_min, xp_max, yp_max);
- sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
-
- /* draw axis line */
-
- sgp2_color (ez.clr_axis);
- if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_xcross) {
- sgp2_move_abs (xa_min, xaxispos - charheight);
- sgp2_line_abs (xa_min, xaxispos + charheight);
- }
- sgp2_move_abs (xa_min, xaxispos);
- sgp2_line_abs (xa_max, xaxispos);
- if (ez.o_tag && !ez.o_grid && !ez.o_box) {
- sgp2_move_abs (xa_max, xaxispos - charheight);
- sgp2_line_abs (xa_max, xaxispos + charheight);
- }
-
- if (ez.o_grid == TRUE) {
- sgp2_color (ez.clr_grid);
- for (i = 0; i <= x_nint; i++) {
- sgp2_move_abs (xt_min + xn_tickinc * i, ya_max);
- sgp2_line_abs (xt_min + xn_tickinc * i, ya_min);
- }
- }
- sgp2_move_abs (xa_min + (xa_max-xa_min)/2 - strlen(ez.c_xlabel)*charwidth, xlbl_row);
- charsize (charwidth * 2.0, charheight * 2.0);
- settextclr (ez.clr_label, -1);
- sgp2_draw_text (ez.c_xlabel);
- charsize (charwidth, charheight);
- minorinc = xn_tickinc / (ez.o_xminortick + 1);
-
- for (i = 0; i <= x_nint; i++) {
- x = xt_min + xn_tickinc * i;
- sgp2_color (ez.clr_axis);
- sgp2_move_abs (x, xaxispos);
- sgp2_line_abs (x, xaxispos + xticklen);
- if (i != x_nint)
- for (j = 1; j <= ez.o_xminortick; j++) {
- x2 = x + minorinc * j;
- sgp2_move_abs (x2, xaxispos);
- sgp2_line_abs (x2, xaxispos + TICKRATIO * xticklen);
- }
- axis_near = FALSE;
- if (xaxispos + xtl_ofs > ya_min && ez.o_yaxis != NOAXIS) {
- double xw, x, y, d;
-
- xw = xgw_min + i * xw_tickinc;
- sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
- sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
- wc_to_ndc (xw, y, &x, &y);
- sgp2_window (xp_min, yp_min, xp_max, yp_max);
- sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
- d = x - yaxispos;
- if (ez.o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
- axis_near = TRUE;
- if (ez.o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
- axis_near = TRUE;
- }
-
- if (ez.o_xtlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
- numstr = str_skip_head (str, " ");
- sgp2_move_abs (x-strlen(numstr)*charwidth/2,xaxispos + xtl_ofs);
- settextclr (ez.clr_number, -1);
- sgp2_draw_text (numstr);
- }
- }
- } /* x - axis */
-
-
- /*--------*/
- /* y-axis */
- /*--------*/
-
- if (ez.o_yaxis == LINEAR) {
- sgp2_window (xp_min, yp_min, xp_max, yp_max);
- sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
-
- sgp2_color (ez.clr_axis);
- if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_ycross) {
- sgp2_move_abs (yaxispos - charwidth, ya_min);
- sgp2_line_abs (yaxispos + charwidth, ya_min);
- }
- sgp2_move_abs (yaxispos, ya_min);
- sgp2_line_abs (yaxispos, ya_max);
- if (ez.o_tag && !ez.o_grid && !ez.o_box) {
- sgp2_move_abs (yaxispos - charwidth, ya_max);
- sgp2_line_abs (yaxispos + charwidth, ya_max);
- }
-
- if (ez.o_grid == TRUE) {
- sgp2_color (ez.clr_grid);
- for (i = 0; i <= y_nint; i++) {
- y = yt_min + yn_tickinc * i;
- sgp2_move_abs (xa_max, y);
- sgp2_line_abs (xa_min, y);
- }
- }
- sgp2_move_abs (ylbl_col,ya_min + (ya_max-ya_min)/2 - strlen(ez.c_ylabel)*charheight);
- textangle (HALFPI);
- charsize (2 * charheight, 2 * charwidth); /* axis reversed */
- settextclr (ez.clr_label, -1);
- sgp2_draw_text (ez.c_ylabel);
- textangle (0.0);
- charsize (charwidth, charheight);
- minorinc = yn_tickinc / (ez.o_yminortick + 1);
-
- for (i = 0; i <= y_nint; i++) {
- y = yt_min + yn_tickinc * i;
- sgp2_color (ez.clr_axis);
- sgp2_move_abs (yaxispos, y);
- sgp2_line_abs (yaxispos + yticklen, y);
- if (i != y_nint)
- for (j = 1; j <= ez.o_yminortick; j++) {
- y2 = y + minorinc * j;
- sgp2_move_abs (yaxispos, y2);
- sgp2_line_abs (yaxispos + TICKRATIO * yticklen, y2);
- }
- axis_near = FALSE;
- if (yaxispos + ytl_ofs > xa_min && ez.o_xaxis != NOAXIS) {
- double yw, x, y, d;
-
- yw = ygw_min + i * yw_tickinc;
- sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
- sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
- wc_to_ndc (x, yw, &x, &y);
- sgp2_window (xp_min, yp_min, xp_max, yp_max);
- sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
- d = y - xaxispos;
- if (ez.o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
- axis_near = TRUE;
- if (ez.o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
- axis_near = TRUE;
- }
- if (ez.o_ytlabel == TRUE && axis_near == FALSE) {
- snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
- sgp2_move_abs (yaxispos + ytl_ofs, y - 0.5 * charheight);
- settextclr (ez.clr_number, -1);
- sgp2_draw_text (str);
- }
- }
- } /* y - axis */
+
+ if (o_grid == TRUE) {
+ m_pSGP->setColor (clr_grid);
+ for (i = 0; i <= x_nint; i++) {
+ m_pSGP->moveAbs (xt_min + xn_tickinc * i, ya_max);
+ m_pSGP->lineAbs (xt_min + xn_tickinc * i, ya_min);
+ }
+ }
+ m_pSGP->setTextSize (charheight * 1.5);
+ m_pSGP->setTextColor (clr_label, -1);\r
+ double wText, hText;\r
+ m_pSGP->getTextExtent (c_xlabel.c_str(), &wText, &hText);
+ m_pSGP->moveAbs (xa_min + (xa_max-xa_min)/2 - wText / 2, xlbl_row + charheight * 1.5);\r
+ m_pSGP->drawText (c_xlabel);
+ m_pSGP->setTextSize (charheight);
+ minorinc = xn_tickinc / (o_xminortick + 1);
+
+ for (i = 0; i <= x_nint; i++) {
+ x = xt_min + xn_tickinc * i;
+ m_pSGP->setColor (clr_axis);
+ m_pSGP->moveAbs (x, xaxispos);
+ m_pSGP->lineAbs (x, xaxispos + xticklen);
+ if (i != x_nint)
+ for (j = 1; j <= o_xminortick; j++) {
+ x2 = x + minorinc * j;
+ m_pSGP->moveAbs (x2, xaxispos);
+ m_pSGP->lineAbs (x2, xaxispos + TICKRATIO * xticklen);
+ }
+ axis_near = FALSE;
+ if (xaxispos + xtl_ofs > ya_min && o_yaxis != NOAXIS) {
+ double xw = xgw_min + i * xw_tickinc;
+ double x = convertWorldToNDC_X (xw);
+ double d = x - yaxispos;
+ if (o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
+ axis_near = TRUE;
+ if (o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
+ axis_near = TRUE;
+ }
+
+ if (o_xtlabel == TRUE && axis_near == FALSE) {
+ snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
+ numstr = str_skip_head (str, " ");
+ m_pSGP->moveAbs (x-strlen(numstr)*charwidth/2, xaxispos + xtl_ofs);
+ m_pSGP->setTextColor (clr_number, -1);
+ m_pSGP->drawText (numstr);
+ }
+ }
+ } // X - Axis
+
+
+ /*--------*/
+ /* y-axis */
+ /*--------*/
+
+ if (o_yaxis == LINEAR) {
+
+ m_pSGP->setColor (clr_axis);
+ if (o_tag && !o_grid && !o_box && s_ycross) {
+ m_pSGP->moveAbs (yaxispos - charwidth, ya_min);
+ m_pSGP->lineAbs (yaxispos + charwidth, ya_min);
+ }
+ m_pSGP->moveAbs (yaxispos, ya_min);
+ m_pSGP->lineAbs (yaxispos, ya_max);
+ if (o_tag && !o_grid && !o_box) {
+ m_pSGP->moveAbs (yaxispos - charwidth, ya_max);
+ m_pSGP->lineAbs (yaxispos + charwidth, ya_max);
+ }
+
+ if (o_grid == TRUE) {
+ m_pSGP->setColor (clr_grid);
+ for (i = 0; i <= y_nint; i++) {
+ y = yt_min + yn_tickinc * i;
+ m_pSGP->moveAbs (xa_max, y);
+ m_pSGP->lineAbs (xa_min, y);
+ }
+ }\r
+ m_pSGP->setTextAngle (HALFPI);
+ m_pSGP->setTextSize (1.5 * charheight);
+ m_pSGP->setTextColor (clr_label, -1);\r
+ double xExtent, yExtent;\r
+ m_pSGP->getTextExtent (c_ylabel.c_str(), &xExtent, &yExtent);\r
+ m_pSGP->moveAbs (ylbl_col, ya_min + (ya_max-ya_min)/2 - yExtent / 2);\r
+ m_pSGP->drawText (c_ylabel);\r
+ m_pSGP->setTextAngle (0.0);
+ m_pSGP->setTextSize (charheight);
+ minorinc = yn_tickinc / (o_yminortick + 1);
+
+ for (i = 0; i <= y_nint; i++) {
+ y = yt_min + yn_tickinc * i;
+ m_pSGP->setColor (clr_axis);
+ m_pSGP->moveAbs (yaxispos, y);
+ m_pSGP->lineAbs (yaxispos + yticklen, y);
+ if (i != y_nint)
+ for (j = 1; j <= o_yminortick; j++) {
+ y2 = y + minorinc * j;
+ m_pSGP->moveAbs (yaxispos, y2);
+ m_pSGP->lineAbs (yaxispos + TICKRATIO * yticklen, y2);
+ }
+ axis_near = FALSE;
+ if (yaxispos + ytl_ofs > xa_min && o_xaxis != NOAXIS) {
+ double yw = ygw_min + i * yw_tickinc;
+ double y = convertWorldToNDC_Y (yw);
+ double d = y - xaxispos;
+ if (o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
+ axis_near = TRUE;
+ if (o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
+ axis_near = TRUE;
+ }
+ if (o_ytlabel == TRUE && axis_near == FALSE) {
+ snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);\r
+ m_pSGP->moveAbs (yaxispos + ytl_ofs, y + 0.5 * charheight);\r
+ m_pSGP->setTextColor (clr_number, -1);\r
+ m_pSGP->drawText (str);
+ }
+ }
+ } // Y - Axis