/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void a_zoom_box_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_box (cr, flags, wwidth, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); eda_cairo_set_source_color (cr, ZOOM_BOX_COLOR, color_map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, wwidth, -1, -1); }
/*! \brief Draw picture from GschemToplevel object. * \par Function Description * This function draws the box from the variables in the GschemToplevel * structure <B>*w_current</B>. * One corner of the box is at (<B>w_current->first_wx</B>, * <B>w_current->first_wy</B>) and the second corner is at * (<B>w_current->second_wx</B>,<B>w_current->second_wy</B>. * * \param [in] w_current The GschemToplevel object. */ void o_picture_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { int left, top, width, height; 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); /* get the width/height and the upper left corner of the picture */ left = GET_PICTURE_LEFT (w_current); top = GET_PICTURE_TOP (w_current); width = GET_PICTURE_WIDTH (w_current); height = GET_PICTURE_HEIGHT (w_current); eda_cairo_box (cr, flags, wwidth, left, top - height, left + width, top); eda_cairo_set_source_color (cr, SELECT_COLOR, color_map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, wwidth, -1, -1); }
/*! \brief Draw a bounding box or outline for OBJECT placement * \par Function Description * This function draws either the OBJECTS in the place list * or a rectangle around their bounding box, depending upon the * currently selected w_current->actionfeedback_mode. This takes the * value BOUNDINGBOX or OUTLINE. * * The function applies manhatten mode constraints to the coordinates * before drawing if the CONTROL key is recording as being pressed in * the w_current structure. * * \param w_current GschemToplevel which we're drawing for. * \param renderer Renderer to use for drawing. */ void o_place_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer) { int diff_x, diff_y; cairo_t *cr = eda_renderer_get_cairo_context (renderer); 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); PAGE *page = gschem_page_view_get_page (page_view); g_return_if_fail (page != NULL); g_return_if_fail (page->place_list != NULL); /* Don't worry about the previous drawing method and movement * constraints, use with the current settings */ w_current->last_drawb_mode = w_current->actionfeedback_mode; w_current->drawbounding_action_mode = (w_current->CONTROLKEY && ! ((w_current->event_state == PASTEMODE) || (w_current->event_state == COMPMODE) || (w_current->event_state == TEXTMODE))) ? CONSTRAINED : FREE; /* Calculate delta of X-Y positions from buffer's origin */ diff_x = w_current->second_wx - w_current->first_wx; diff_y = w_current->second_wy - w_current->first_wy; /* Adjust the coordinates according to the movement constraints */ if (w_current->drawbounding_action_mode == CONSTRAINED ) { if (abs(diff_x) >= abs(diff_y)) { w_current->second_wy = w_current->first_wy; diff_y = 0; } else { w_current->second_wx = w_current->first_wx; diff_x = 0; } } /* Translate the cairo context to the required offset before drawing. */ cairo_save (cr); cairo_translate (cr, diff_x, diff_y); /* Draw with the appropriate mode */ if (w_current->last_drawb_mode == BOUNDINGBOX) { GArray *map = eda_renderer_get_color_map (renderer); int flags = eda_renderer_get_cairo_flags (renderer); int left, top, bottom, right; /* Find the bounds of the drawing to be done */ world_get_object_glist_bounds (page->toplevel, page->place_list, &left, &top, &right, &bottom); /* Draw box outline */ eda_cairo_box (cr, flags, 0, left, top, right, bottom); eda_cairo_set_source_color (cr, BOUNDINGBOX_COLOR, map); eda_cairo_stroke (cr, flags, TYPE_SOLID, END_NONE, 0, -1, -1); } else { GList *iter; for (iter = page->place_list; iter != NULL; iter = g_list_next (iter)) { eda_renderer_draw (renderer, (OBJECT *) iter->data); } } cairo_restore (cr); }