/*! \brief Draw a line on screen. * \par Function Description * This function is used to draw a line on screen. The line is described * in the object which is referred by <B>o_current</B>. The line is displayed * according to the current state, described in the GSCHEM_TOPLEVEL object pointed * by <B>w_current</B>. * * It first checks if the object is valid or not. If not it returns and do * not output anything. That should never happen though. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] o_current The line OBJECT to draw. */ void o_line_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current) { int x1, y1, x2, y2; if (o_current->line == NULL) { return; } if (!o_line_visible (w_current, o_current->line, &x1, &y1, &x2, &y2)) { return; } gschem_cairo_line (w_current, o_current->line_end, o_current->line_width, x1, y1, x2, y2); gschem_cairo_set_source_color (w_current, o_drawing_color (w_current, o_current)); gschem_cairo_stroke (w_current, o_current->line_type, o_current->line_end, o_current->line_width, o_current->line_length, o_current->line_space); if (o_current->selected && w_current->draw_grips) { o_line_draw_grips (w_current, o_current); } }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_pin_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current) { TOPLEVEL *toplevel = w_current->toplevel; int x1, y1, x2, y2; int size = 0; OBJECT_END end; if (o_current->line == NULL) { return; } /* reuse line's routine */ if (!o_line_visible (w_current, o_current->line, &x1, &y1, &x2, &y2)) { return; } if (toplevel->pin_style == THICK) size = o_current->line_width; end = o_get_line_end (toplevel->print_output_capstyle); gschem_cairo_line (w_current, end, size, x1, y1, x2, y2); gschem_cairo_set_source_color (w_current, o_drawing_color (w_current, o_current)); gschem_cairo_stroke (w_current, TYPE_SOLID, end, size, -1, -1); /* draw the cue directly */ o_cue_draw_lowlevel(w_current, o_current, o_current->whichend); #if DEBUG printf("drawing pin\n"); #endif if (o_current->selected && w_current->draw_grips) { o_line_draw_grips (w_current, o_current); } }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_net_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current) { TOPLEVEL *toplevel = w_current->toplevel; int x1, y1, x2, y2; int size = 0; #if NET_DEBUG /* debug */ char *tempstring; GdkFont *font; #endif if (o_current == NULL) { return; } if (o_current->line == NULL) { return; } /* reuse line's routine */ if (!o_line_visible (w_current, o_current->line, &x1, &y1, &x2, &y2)) { return; } if (toplevel->net_style == THICK) size = NET_WIDTH; gschem_cairo_line (w_current, END_SQUARE, size, x1, y1, x2, y2); gschem_cairo_set_source_color (w_current, o_drawing_color (w_current, o_current)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_SQUARE, size, -1, -1); if (o_current->selected && w_current->draw_grips) { o_line_draw_grips (w_current, o_current); } }
/*! \brief Draw a box on the screen. * \par Function Description * This function is used to draw a box on screen. The box is described in * the OBJECT which is referred by <B>o_current</B>. The box is displayed * according to the current state, described in the GSCHEM_TOPLEVEL object * pointed by <B>w_current</B>. * * It first checks if the OBJECT pointed is valid or not. If not it * returns and do not output anything. That should never happen though. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] o_current BOX OBJECT to draw. */ void o_box_draw(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current) { int angle1, pitch1, angle2, pitch2; FILL_FUNC fill_func; if (o_current->box == NULL) { return; } /* * The drawing of the box is divided in two steps : first step is to * draw the outline, the second is to draw the filling pattern inside * (if any). Finally the function takes care of the grips. */ /* * The values describing the line type are extracted from the <B>o_current</B> * pointed structure. These are the width of the line, the field called * length and the field called space and the desired end type for the line. * * Depending on the type of the line that has to be used to draw the box * the appropriate function is called. Values of space and length are * adapted to the type of line. The possible functions are the following : * #o_box_draw_solid(), #o_box_draw_dotted(), #o_box_draw_dashed() and * #o_box_draw_phantom(). * * The combination <B>length</B> == 0 and <B>space</B> == 0 is avoided as it * lead to an endless loop in function called after. If such a case is * encountered the box is drawn as a solid box independently of its * initial type. */ /* * The values needed for the fill operation are taken from the * <B>o_current</B> pointed OBJECT. It include the type of fill required, * the width of the lines (if the fill use line) and angles and pitchs * for hatch based filling. * * Once again the width of the line is important as if it is equal to * 0 it may not be displayed. That is definetely not what we are looking for. * * Depending on the type of fill that has to be used inside the box the * appropriate function is called. Values of <B>angle1</B>, * <B>angle2</B>, <B>pitch1</B> and <B>pitch2</B> are adapted to the type of * filling. The possible functions are the following : * #o_box_fill_hollow(), #o_box_fill_fill(), #o_box_fill_mesh() and * #o_box_fill_hatch(). * * The combination <B>pitch1</B> <= 0 and <B>pitch2</B> <= 0 is avoided as * it lead to an endless loop in function called after. It happens when * the zoom factor is too small for two lines separated by the pitch * to be distinct. If such a case is encountered the circle is filled * hollow (e.q. not filled). */ angle1 = o_current->fill_angle1; pitch1 = o_current->fill_pitch1; angle2 = o_current->fill_angle2; pitch2 = o_current->fill_pitch2; switch (o_current->fill_type) { case FILLING_HOLLOW: angle1 = -1; angle2 = -1; pitch1 = 1; pitch2 = 1; /* this function is empty ! however if it do not use it we have to add * a test before the call. Simply putting a return here instead is not * possible as it would prevent any hollow box from having its grips * drawn */ fill_func = o_box_fill_hollow; break; case FILLING_FILL: angle1 = -1; angle2 = -1; pitch1 = 1; pitch2 = 1; fill_func = o_box_fill_fill; break; case FILLING_MESH: fill_func = o_box_fill_mesh; break; case FILLING_HATCH: angle2 = -1; pitch2 = 1; fill_func = o_box_fill_hatch; break; case FILLING_VOID: default: angle1 = -1; angle2 = -1; pitch1 = 1; pitch2 = 1; fill_func = o_box_fill_hollow; fprintf (stderr, _("Unknown type for box (fill)!\n")); } if ((pitch1 <= 0) || (pitch2 <= 0)) fill_func = o_box_fill_fill; (*fill_func) (w_current, o_drawing_color (w_current, o_current), o_current->box, o_current->fill_width, angle1, pitch1, angle2, pitch2); gschem_cairo_set_source_color (w_current, o_drawing_color (w_current, o_current)); gschem_cairo_box (w_current, o_current->line_width, o_current->box->lower_x, o_current->box->lower_y, o_current->box->upper_x, o_current->box->upper_y); if (o_current->fill_type == FILLING_FILL) cairo_fill_preserve (w_current->cr); gschem_cairo_stroke (w_current, o_current->line_type, o_current->line_end, o_current->line_width, o_current->line_length, o_current->line_space); if (o_current->selected && w_current->draw_grips) o_box_draw_grips (w_current, o_current); }