/*! \brief read a net object from a char buffer * \par Function Description * This function reads a net object from the buffer \a buf. * If the netobject was read successfully, a new net object is * allocated and appended to the \a object_list. * * \param [in] toplevel The TOPLEVEL object * \param [in] buf a text buffer (usually a line of a schematic file) * \param [in] release_ver The release number gEDA * \param [in] fileformat_ver a integer value of the file format * \return The object list, or NULL on error. * */ OBJECT *o_net_read (TOPLEVEL *toplevel, const char buf[], unsigned int release_ver, unsigned int fileformat_ver, GError **err) { OBJECT *new_obj; char type; int x1, y1; int x2, y2; int color; if (sscanf (buf, "%c %d %d %d %d %d\n", &type, &x1, &y1, &x2, &y2, &color) != 6) { g_set_error(err, EDA_ERROR, EDA_ERROR_PARSE, _("Failed to parse net object")); return NULL; } if (x1 == x2 && y1 == y2) { s_log_message (_("Found a zero length net [ %c %d %d %d %d %d ]\n"), type, x1, y1, x2, y2, color); } if (color < 0 || color > MAX_COLORS) { s_log_message (_("Found an invalid color [ %s ]\n"), buf); s_log_message (_("Setting color to default color\n")); color = DEFAULT_COLOR; } new_obj = geda_net_object_new (toplevel, type, color, x1, y1, x2, y2); return new_obj; }
/*! \brief create a copy of a net object * \par Function Description * This function creates a copy of the net object \a o_current. * * \param [in] toplevel The TOPLEVEL object * \param [in] o_current The object that is copied * \return a new net object */ OBJECT* geda_net_object_copy (TOPLEVEL *toplevel, OBJECT *o_current) { OBJECT *new_obj; /* make sure you fix this in pin and bus as well */ /* still doesn't work... you need to pass in the new values */ /* or don't update and update later */ /* I think for now I'll disable the update and manually update */ new_obj = geda_net_object_new (toplevel, OBJ_NET, o_current->color, o_current->line->x[0], o_current->line->y[0], o_current->line->x[1], o_current->line->y[1]); return new_obj; }
/*! \todo Finish function documentation!!! * \brief * \par Function Description * */ void o_move_check_endpoint(GschemToplevel *w_current, OBJECT * object) { GList *cl_current; CONN *c_current; OBJECT *other; int whichone; 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); if (!object) return; if (object->type != OBJ_NET && object->type != OBJ_PIN && object->type != OBJ_BUS) { fprintf(stderr, _("Got a non line object in o_move_check_endpoint\n")); return; } for (cl_current = object->conn_list; cl_current != NULL; cl_current = g_list_next(cl_current)) { c_current = (CONN *) cl_current->data; other = c_current->other_object; if (other == NULL) continue; /* really make sure that the object is not selected */ if (other->selected) continue; /* Catch pins, whos parent object is selected. */ if (other->parent != NULL && other->parent->selected) continue; if (c_current->type != CONN_ENDPOINT && (c_current->type != CONN_MIDPOINT || c_current->other_whichone == -1)) continue; if (/* (net)pin to (net)pin contact */ (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_NET && other->type == OBJ_PIN && other->pin_type == PIN_TYPE_NET)) { /* net to (net)pin contact */ /* (object->type == OBJ_NET && other->type == OBJ_PIN && other->pin_type == PIN_TYPE_NET) */ OBJECT *new_net; /* other object is a pin, insert a net */ new_net = geda_net_object_new (page->toplevel, OBJ_NET, NET_COLOR, c_current->x, c_current->y, c_current->x, c_current->y); s_page_append (page->toplevel, page, new_net); /* This new net object is only picked up for stretching later, * somewhat of a kludge. If the move operation is cancelled, these * new 0 length nets are removed by the "undo" operation invoked. */ } /* Only attempt to stretch nets and buses */ if (other->type != OBJ_NET && other->type != OBJ_BUS) continue; whichone = o_move_return_whichone (other, c_current->x, c_current->y); #if DEBUG printf ("FOUND: %s type: %d, whichone: %d, x,y: %d %d\n", other->name, c_current->type, whichone, c_current->x, c_current->y); printf("other x,y: %d %d\n", c_current->x, c_current->y); printf("type: %d return: %d real: [ %d %d ]\n", c_current->type, whichone, c_current->whichone, c_current->other_whichone); #endif if (whichone >= 0 && whichone <= 1) { w_current->stretch_list = s_stretch_add (w_current->stretch_list, other, whichone); } } }