/*! \brief Draw arc from GschemToplevel object. * \par Function Description * This function draws the arc from the variables in the GschemToplevel * structure <B>*w_current</B>. * The center of the arc is at (<B>w_current->first_wx</B>, * <B>w_current->first_wy</B>), its radius equal to <B>w_current->distance</B>, * and the start and end angle are given by <B>w_current->second_wx</B> and * <B>w_current->second_wy</B>. * * \param [in] w_current The GschemToplevel object. */ void o_arc_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { double rad_angle; int rdx, rdy; double wwidth = 0; cairo_t *cr = eda_renderer_get_cairo_context (renderer); GArray *color_map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); eda_cairo_arc (cr, flags, wwidth, w_current->first_wx, w_current->first_wy, w_current->distance, w_current->second_wx, w_current->second_wy); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); /* draw the radius line */ rad_angle = ((double) w_current->second_wx) * M_PI / 180; rdx = (double) w_current->distance * cos (rad_angle); rdy = (double) w_current->distance * sin (rad_angle); eda_cairo_line (cr, flags, END_NONE, wwidth, w_current->first_wx, w_current->first_wy, w_current->first_wx + rdx, w_current->first_wy + rdy); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, wwidth, -1, -1); }
/*! \brief draw rubbernet lines to the gc * \par Function Description * This function draws the rubbernets to the graphic context */ void o_net_draw_rubber(GschemToplevel *w_current, EdaRenderer *renderer) { int size = NET_WIDTH, w_magnetic_halfsize; cairo_t *cr = eda_renderer_get_cairo_context (renderer); GArray *color_map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); gboolean magnetic_net_mode; g_return_if_fail (w_current != NULL); GschemPageView *page_view = gschem_toplevel_get_current_page_view (w_current); g_return_if_fail (page_view != NULL); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); magnetic_net_mode = gschem_options_get_magnetic_net_mode (w_current->options); if (magnetic_net_mode) { if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) { w_magnetic_halfsize = max (4 * size, gschem_page_view_WORLDabs (page_view, MAGNETIC_HALFSIZE)); eda_cairo_arc (cr, flags, size, w_current->magnetic_wx, w_current->magnetic_wy, w_magnetic_halfsize, 0, 360); } } /* Primary line */ eda_cairo_line (cr, flags, END_NONE, size, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); /* Secondary line */ eda_cairo_line (cr, flags, END_NONE, size, w_current->second_wx, w_current->second_wy, w_current->third_wx, w_current->third_wy); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, size, -1, -1); }
/*! \brief draw a rubberbus segment * \par Function Description * This function draws a bus segment from the point * (<B>first_wx</B>,<B>first_wy</B>) to the point * (<B>second_wx</B>,<B>second_wy</B>) from the <B>GschemToplevel</B> * structure. * * The function can be used to draw or erase the rubberbus on the screen. * * \param [in] w_current The GschemToplevel object */ void o_bus_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { int size = BUS_WIDTH; cairo_t *cr = eda_renderer_get_cairo_context (renderer); GArray *color_map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); eda_cairo_line (cr, flags, END_NONE, size, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, size, -1, -1); }
/*! \brief Draw circle from GschemToplevel object. * \par Function Description * This function draws the circle from the variables in the GschemToplevel * structure <B>*w_current</B>. * The center of the circle is at (<B>w_current->first_wx</B>, * <B>w_current->first_wy</B>) and its radius is in <B>w_current->distance</B>. * * It draws a horizontal radius segment on the right half of the circle and * the circle with the selection color. * * \param [in] w_current The GschemToplevel object. */ void o_circle_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { double wwidth = 0; cairo_t *cr = eda_renderer_get_cairo_context (renderer); GArray *color_map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); eda_cairo_center_arc (cr, flags, wwidth, wwidth, w_current->first_wx, w_current->first_wy, w_current->distance, 0, 360); eda_cairo_line (cr, flags, END_NONE, wwidth, w_current->first_wx, w_current->first_wy, w_current->first_wx + w_current->distance, w_current->first_wy); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, wwidth, -1, -1); }
/*! \brief Draw path creation preview. * \par Function Description * Draw a preview of the path currently being drawn, including a * helper line showing the control point of the node being drawn (if * applicable). */ void o_path_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { OBJECT object; int added_sections = 0; /* Draw a helper for when we're dragging a control point */ if (w_current->first_wx != w_current->second_wx || w_current->first_wy != w_current->second_wy) { double wwidth = 0; cairo_t *cr = eda_renderer_get_cairo_context (renderer); GArray *color_map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); eda_cairo_line (cr, flags, END_NONE, wwidth, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, wwidth, -1, -1); } /* Now draw the rest of the path */ /* Calculate any new sections */ added_sections = path_next_sections (w_current); /* Setup a fake object to pass the drawing routine */ memset (&object, 0, sizeof (OBJECT)); object.type = OBJ_PATH; object.color = SELECT_COLOR; object.line_width = 0; /* clamped to 1 pixel in circle_path */ object.path = w_current->temp_path; eda_renderer_draw (renderer, &object); /* Throw away the added sections again */ w_current->temp_path->num_sections -= added_sections; }