/*! \brief * \par Function Description * This function prints an arc when a dotted line type is required. * The arc is defined by its center in <B>x</B> and <B>y</B>, its * radius in <B>radius</B> and the start and end angles of the arc on the circle. * The postscript file is defined by the file pointer <B>fp</B>. * The parameter <B>length</B> is ignored whereas <B>arc_width</B> specifies * the diameter of the dots of the printed line and <B>space</B> the distance * between two dots. * * A negative value for <B>space</B> leads to an endless loop. * * All dimensions are in mils, except <B>angle1</B> and <B>angle2</B> in degrees. * * The function sets the color the line will be printed with. * * \param [in] toplevel The TOPLEVEL object. * \param [in] fp FILE pointer to postscript document. * \param [in] x * \param [in] y * \param [in] radius * \param [in] angle1 * \param [in] angle2 * \param [in] color * \param [in] arc_width * \param [in] capstyle * \param [in] length * \param [in] space * \param [in] origin_x * \param [in] origin_y */ void o_arc_print_dotted(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int capstyle, int length, int space, int origin_x, int origin_y) { int da, d; f_print_set_color(toplevel, fp, color); /*! \note * Depending on the radius of the arc, the <B>space</B> parameter is * changed into a small angle <B>da</B>. * Starting from <B>angle1</B> - the start angle - the dots are printed * along the arc by increments of this new angle. * * As <B>da</B> is rounded as an integer, it can take a null value which * will make the function enter an endless loop. In such a case, the arc * is printed solid. The <B>da</B> variable should never be negative * except if <B>space</B> is negative. */ /* Inverting angle2 if < 0 and changing angle1 accordingly */ /* the loop test assume that da > 0 */ if (angle2 < 0) { angle1 = angle1 + angle2; angle2 = -angle2; } da = (int) ((space * 180) / (M_PI * ((double) radius))); /* If da or db too small for arc to be displayed as dotted, draw a solid arc */ if (da <= 0) { o_arc_print_solid(toplevel, fp, x, y, radius, angle1, angle2, color, arc_width, capstyle, length, space, origin_x, origin_y); return; } fprintf(fp,"["); d = angle1; while (d < (angle2 + angle1)) { /*xa = ((double) x) + ((double) radius) * cos(d * M_PI / 180); ya = ((double) y) + ((double) radius) * sin(d * M_PI / 180); */ fprintf(fp,"[%d] ",d); d = d + da; } fprintf(fp,"] %d %d %d %d %d dashedarc %% dotted\n", x,y, radius, arc_width, capstyle); }
/*! \brief Print a solid circle to Postscript document. * \par Function Description * This function prints the outline of a circle when a solid line type * is required. The circle is defined by its center in (<B>x</B>, <B>y</B>) * and its radius in <B>radius</B>. It is printed with the color given * in <B>color</B>. * The parameters <B>length</B> and <B>space</B> are ignored. * * It uses the function #o_arc_print_solid() to print the outline. * Therefore it acts as an interface between the way a circle is defined * and the way an arc is defined. * * All dimensions are in mils. * * \param [in] toplevel The TOPLEVEL object. * \param [in] fp FILE pointer to Postscript document. * \param [in] x Center x coordinate of circle. * \param [in] y Center y coordinate of circle. * \param [in] radius Circle radius. * \param [in] color Circle color. * \param [in] circle_width Width of circle. * \param [in] length (unused). * \param [in] space (unused). * \param [in] origin_x Page x coordinate to place circle OBJECT. * \param [in] origin_y Page y coordinate to place circle OBJECT. */ void o_circle_print_solid(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int circle_width, int length, int space, int origin_x, int origin_y) { o_arc_print_solid(toplevel, fp, x, y, radius, 0, FULL_CIRCLE / 64, color, circle_width, -1, -1, origin_x, origin_y); }
/*! \brief * \par Function Description * This function prints an arc when a centered line type is required. * The arc is defined by its center in <B>x</B> and <B>y</B>, its radius in * <B>radius</B> and the start and end angles of the arc on the circle. * The postscript file is defined by the file pointer <B>fp</B>. * The parameter <B>arc_width</B> specifies the diameter of the dots and the width of the dashes of the printed line. * * A negative value for <B>space</B> or <B>length</B> leads to an endless loop. * * All dimensions are in mils, except <B>angle1</B> and <B>angle2</B> in degrees. * * The function sets the color in which the line will be printed with. * * \param [in] toplevel The TOPLEVEL object. * \param [in] fp FILE pointer to postscript document. * \param [in] x * \param [in] y * \param [in] radius * \param [in] angle1 * \param [in] angle2 * \param [in] color * \param [in] arc_width * \param [in] capstyle * \param [in] length * \param [in] space * \param [in] origin_x * \param [in] origin_y */ void o_arc_print_center(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int capstyle, int length, int space, int origin_x, int origin_y) { int da, db, a1, d; f_print_set_color(toplevel, fp, color); /*! \note * Depending on the radius of the arc, the <B>space</B> (resp. <B>length</B>) * parameter is changed into a small angle <B>da</B> (resp. <B>db</B>). * Starting from <B>angle1</B> - the start angle - the dashes are printed * along the arc by increments of these new angles. * * As <B>da</B> (resp. <B>db</B>) is rounded as an integer, it can take a null * value which will make the function enter an endless loop. In such a case, * the arc is printed solid. The <B>da</B> (resp. <B>db</B>) variable should never * be negative except if <B>space</B> (resp. <B>length</B>) is negative. * * It prints as many sets of dash-dot as possible. */ /* Inverting angle2 if < 0 and changing angle1 accordingly */ /* the loop test assume that da > 0 */ if (angle2 < 0) { angle1 = angle1 + angle2; angle2 = -angle2; } da = (int) ((length * 180) / (M_PI * ((double) radius))); db = (int) ((space * 180) / (M_PI * ((double) radius))); /* If da or db too small to be displayed, draw an arc */ if ((da <= 0) || (db <= 0)) { o_arc_print_solid(toplevel, fp, x, y, radius, angle1, angle2, color, arc_width, capstyle, length, space, origin_x, origin_y); return; } fprintf(fp, "["); d = angle1; while ((d + da + 2 * db) < (angle1 + angle2)) { a1 = d; d = d + da; fprintf(fp,"[%d %d] ",(int) a1, (int) a1 + da); d = d + db; /* xa = ((double) x) + ((double) radius) * cos(d * (M_PI / 180)); ya = ((double) y) + ((double) radius) * sin(d * (M_PI / 180)); */ fprintf(fp,"[%d] ",d); d = d + db; } /*! \note * When the above condition is no more satisfied, then it is not * possible to print a dash of length <B>length</B>. However two cases are possible : * <DL> * <DT>*</DT><DD>it is possible to print the dash and the dot * <DT>*</DT><DD>it is possible to print the dash or a part of the original dash * </DL> */ if ((d + da) < (angle1 + angle2)) { a1 = d; d = d + da; } else { a1 = d; d = d + da; } fprintf(fp,"[%d %d] ",(int) a1, (int) a1 + da); if ((d + db) < (angle1 + angle2)) { /* xa = ((double) x) + ((double) radius) * cos(d * (M_PI / 180)); ya = ((double) y) + ((double) radius) * sin(d * (M_PI / 180)); */ fprintf(fp,"[%d] ",d); } fprintf(fp,"] %d %d %d %d %d dashedarc %% center\n", x,y, radius, arc_width, capstyle); }
/*! \brief * \par Function Description * This function prints an arc when a dashed line type is required. * The arc is defined by its center in <B>x</B> and <B>y</B>, its radius * in <B>radius</B> and the start and end angles of the arc on the circle. * The postscript file is defined by the file pointer <B>fp</B>. * The parameter <B>arc_width</B> specifies the diameter of the dots of the printed line. * * A negative value for <B>space</B> or <B>length</B> leads to an endless loop. * * All dimensions are in mils, except <B>angle1</B> and <B>angle2</B> in degrees. * * The function sets the color the line will be printed with. * * \param [in] toplevel The TOPLEVEL object. * \param [in] fp FILE pointer to postscript document. * \param [in] x * \param [in] y * \param [in] radius * \param [in] angle1 * \param [in] angle2 * \param [in] color * \param [in] arc_width * \param [in] length * \param [in] space * \param [in] origin_x * \param [in] origin_y */ void o_arc_print_dashed(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int angle1, int angle2, int color, int arc_width, int length, int space, int origin_x, int origin_y) { int da, db, a1, a2, d; f_print_set_color(toplevel, fp, color); /*! \note * Depending on the radius of the arc, the <B>space</B> (resp. <B>length</B>) * parameter is changed into a small angle <B>da</B> (resp. <B>db</B>). * Starting from <B>angle1</B> - the start angle - the dashes are printed * along the arc by increments of these new angles. * * As <B>da</B> (resp. <B>db</B>) is rounded as an integer, it can take a * null value which will make the function enter an endless loop. In such a case, * the arc is printed solid. The <B>da</B> (resp. <B>db</B>) variable should never * be negative except if <B>space</B> (resp. <B>length</B>) is negative. * * It prints as many dashes of length <B>length</B> as possible. */ /* Inverting angle2 if < 0 and changing angle1 accordingly */ /* the loop test assume that da > 0 */ if (angle2 < 0) { angle1 = angle1 + angle2; angle2 = -angle2; } da = (int) ((length * 180) / (M_PI * ((double) radius))); db = (int) ((space * 180) / (M_PI * ((double) radius))); /* If da or db too small for arc to be displayed as dotted, draw a solid arc */ if ((da <= 0) || (db <= 0)) { o_arc_print_solid(toplevel, fp, x, y, radius, angle1, angle2, color, arc_width, length, space, origin_x, origin_y); return; } fprintf(fp,"["); d = angle1; while ((d + da + db) < (angle1 + angle2)) { a1 = d; d = d + da; fprintf(fp,"[%d %d] ", a1, a1+da); d = d + db; } /*! \note * When the above condition is no more satisfied, then it is not * possible to print a dash of length <B>length</B> and the following <B>space</B>. * However it may be possible to print the complete dash or a shorter one. */ if ((d + da) < (angle1 + angle2)) { a1 = d; a2 = da; } else { a1 = d; a2 = (angle1 + angle2) - d; } fprintf(fp,"[%d %d] ", a1, a1+da); fprintf(fp,"] %d %d %d %d dashedarc %% dashed\n", x,y, radius, arc_width); }