/*! \brief draw rubbernet lines to the gc * \par Function Description * This function draws the rubbernets to the graphic context */ void o_net_draw_rubber(GSCHEM_TOPLEVEL *w_current) { int size = 0, w_magnetic_halfsize; if (w_current->toplevel->net_style == THICK) size = NET_WIDTH; gschem_cairo_set_source_color (w_current, x_color_lookup_dark (SELECT_COLOR)); if (w_current->magneticnet_mode) { if (w_current->magnetic_wx != -1 && w_current->magnetic_wy != -1) { w_magnetic_halfsize = max (4 * size, WORLDabs (w_current, MAGNETIC_HALFSIZE)); gschem_cairo_arc (w_current, size, w_current->magnetic_wx, w_current->magnetic_wy, w_magnetic_halfsize, 0, 360); } } /* Primary line */ gschem_cairo_line (w_current, END_NONE, size, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); /* Secondary line */ gschem_cairo_line (w_current, END_NONE, size, w_current->second_wx, w_current->second_wy, w_current->third_wx, w_current->third_wy); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1); }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_net_draw_stretch (GSCHEM_TOPLEVEL *w_current, int dx, int dy, int whichone, OBJECT *o_current) { int color; int dx1 = -1, dx2 = -1, dy1 = -1,dy2 = -1; if (o_current->line == NULL) { return; } if (o_current->saved_color != -1) { color = o_current->saved_color; } else { color = o_current->color; } if (whichone == 0) { dx1 = dx; dy1 = dy; dx2 = dy2 = 0; } else if (whichone == 1) { dx1 = dy1 = 0; dx2 = dx; dy2 = dy; } else { fprintf(stderr, _("Got an invalid which one in o_net_draw_stretch\n")); } gschem_cairo_line (w_current, END_NONE, 0, o_current->line->x[0] + dx1, o_current->line->y[0] + dy1, o_current->line->x[1] + dx2, o_current->line->y[1] + dy2); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (color)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1); }
/*! \brief Draw box from GSCHEM_TOPLEVEL object. * \par Function Description * This function draws the box from the variables in the GSCHEM_TOPLEVEL * 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 GSCHEM_TOPLEVEL object. */ void o_box_draw_rubber (GSCHEM_TOPLEVEL *w_current) { gschem_cairo_box (w_current, 0, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (SELECT_COLOR)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -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. * * The "drawing" parameter is used to indicate if this drawing should * immediately use the selected feedback mode and positioning constraints. * * With drawing=TRUE, the selected conditions are used immediately, * otherwise the conditions from the last drawing operation are used, * saving the new state for next time. * * This function should be called with drawing=TRUE when starting a * rubberbanding operation and when otherwise refreshing the rubberbanded * outline (e.g. after a screen redraw). For any undraw operation, should * be called with drawing=FALSE, ensuring that the undraw XOR matches the * mode and constraints of the corresponding "draw" operation. * * If any mode / constraint changes are made between a undraw, redraw XOR * pair, the latter (draw) operation must be called with drawing=TRUE. If * no mode / constraint changes were made between the pair, it is not * harmful to call the draw operation with "drawing=FALSE". * * \param [in] w_current GSCHEM_TOPLEVEL which we're drawing for. * \param [in] drawing Set to FALSE for undraw operations to ensure * matching conditions to a previous draw operation. */ void o_place_draw_rubber (GSCHEM_TOPLEVEL *w_current, int drawing) { TOPLEVEL *toplevel = w_current->toplevel; int diff_x, diff_y; int left, top, bottom, right; g_return_if_fail (toplevel->page_current->place_list != NULL); /* If drawing is true, then don't worry about the previous drawing * method and movement constraints, use with the current settings */ if (drawing) { w_current->last_drawb_mode = w_current->actionfeedback_mode; w_current->drawbounding_action_mode = (w_current->CONTROLKEY) ? 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; } } /* Draw with the appropriate mode */ if (w_current->last_drawb_mode == BOUNDINGBOX) { /* Find the bounds of the drawing to be done */ world_get_object_glist_bounds (toplevel, toplevel->page_current->place_list, &left, &top, &right, &bottom); gschem_cairo_box (w_current, 0, left + diff_x, top + diff_y, right + diff_x, bottom + diff_y); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (BOUNDINGBOX_COLOR)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1); } else { o_glist_draw_place (w_current, diff_x, diff_y, toplevel->page_current->place_list); } /* Save movement constraints and drawing method for any * corresponding undraw operation. */ w_current->last_drawb_mode = w_current->actionfeedback_mode; w_current->drawbounding_action_mode = (w_current->CONTROLKEY) ? CONSTRAINED : FREE; }
/*! \brief Draw a line object after applying translation. * \par Function Description * This function is used to draw the line object described by * <B>*o_current</B> after applying a translation on the two directions of * <B>dx</B> and <B>dy</B> in world units. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] dx Delta x coordinate for line. * \param [in] dy Delta y coordinate for line. * \param [in] o_current Line OBJECT to draw. */ void o_line_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current) { if (o_current->line == NULL) { return; } gschem_cairo_line (w_current, END_NONE, 0, o_current->line->x[0] + dx, o_current->line->y[0] + dy, o_current->line->x[1] + dx, o_current->line->y[1] + dy); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (o_current->color)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 0, -1, -1); }
/*! \brief Draw a box described by OBJECT with translation * \par Function Description * This function daws the box object described by <B>*o_current</B> translated * by the vector (<B>dx</B>,<B>dy</B>). * The translation vector is in world unit. * * The box is displayed with the color of the object. * * \param [in] w_current The GSCHEM_TOPLEVEL object. * \param [in] dx Delta x coordinate for box. * \param [in] dy Delta y coordinate for box. * \param [in] o_current Box OBJECT to draw. */ void o_box_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current) { if (o_current->box == NULL) { return; } gschem_cairo_box (w_current, 0, o_current->box->upper_x + dx, o_current->box->upper_y + dy, o_current->box->lower_x + dx, o_current->box->lower_y + dy); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (o_current->color)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, 1, -1, -1); }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_pin_draw_rubber (GSCHEM_TOPLEVEL *w_current) { int size = 0; /* Pins are always first created as net pins, use net pin width */ if (w_current->toplevel->net_style == THICK) size = PIN_WIDTH_NET; gschem_cairo_line (w_current, END_NONE, size, w_current->first_wx, w_current->first_wy, w_current->second_wx, w_current->second_wy); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (SELECT_COLOR)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1); }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_net_draw_place (GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_current) { int size = 0; if (o_current->line == NULL) { return; } if (w_current->toplevel->net_style == THICK) size = NET_WIDTH; gschem_cairo_line (w_current, END_NONE, size, o_current->line->x[0] + dx, o_current->line->y[0] + dy, o_current->line->x[1] + dx, o_current->line->y[1] + dy); gschem_cairo_set_source_color (w_current, x_color_lookup_dark (o_current->color)); gschem_cairo_stroke (w_current, TYPE_SOLID, END_NONE, size, -1, -1); }