/*! \brief * \par Function Description * This function reads a formatted text buffer describing an arc * in the gEDA file format and initializes the corresponding object. * * Depending on the version of the file format the data extraction is * performed differently : currently pre-20000704 and 20000704 on one * hand and post-20000704 file format version on the other hand are supported. * The version is specified in string pointed by <B>fileformat_ver</B>. * * To get information on the various file formats have a * look to the fileformats.html document. * * The object is initialized with the functions #o_set_line_options() and #o_set_fill_options(). * The second one is only used to put initialize unused values for an arc as an arc can not be filled. * * The arc is allocated initialized with the function #o_arc_new(). * * A negative or null radius is not allowed. * * \param [in] toplevel The TOPLEVEL object. * \param [in] buf * \param [in] release_ver * \param [in] fileformat_ver * \return */ OBJECT *o_arc_read (TOPLEVEL *toplevel, char buf[], unsigned int release_ver, unsigned int fileformat_ver) { OBJECT *new_obj; char type; int x1, y1; int radius; int start_angle, end_angle; int color; int arc_width, arc_length, arc_space; int arc_type; int arc_end; /*! \note * Depending on the version of the file format used to describe this arc, * the buffer is parsed differently. The unknown parameters of the less * restrictive - the oldest - file format are set to common values */ if(release_ver <= VERSION_20000704) { sscanf(buf, "%c %d %d %d %d %d %d", &type, &x1, &y1, &radius, &start_angle, &end_angle, &color); arc_width = 0; arc_end = END_NONE; arc_type = TYPE_SOLID; arc_space = -1; arc_length= -1; } else { sscanf(buf, "%c %d %d %d %d %d %d %d %d %d %d %d", &type, &x1, &y1, &radius, &start_angle, &end_angle, &color, &arc_width, &arc_end, &arc_type, &arc_length, &arc_space); } /* Error check */ if (radius <= 0) { s_log_message (_("Found a zero radius arc [ %c %d, %d, %d, %d, %d, %d ]\n"), type, x1, y1, radius, start_angle, end_angle, 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; } /* Allocation and initialization */ new_obj = o_arc_new(toplevel, OBJ_ARC, color, x1, y1, radius, start_angle, end_angle); o_set_line_options(toplevel, new_obj, arc_end, arc_type, arc_width, arc_length, arc_space); o_set_fill_options(toplevel, new_obj, FILLING_HOLLOW, -1, -1, -1, -1, -1); return new_obj; }
/*! \brief * \par Function Description * This function creates a new object representing an arc. * * The values of the <B>o_current</B> pointed OBJECT are then copied to the new object. * * The arc, the line options are initialized whereas the fill options are * initialized to passive values - as an arc can not be filled. * * \param [in] toplevel The TOPLEVEL object * \param [in] o_current * \return The new OBJECT */ OBJECT *o_arc_copy(TOPLEVEL *toplevel, OBJECT *o_current) { OBJECT *new_obj; new_obj = o_arc_new (toplevel, OBJ_ARC, o_current->color, o_current->arc->x, o_current->arc->y, o_current->arc->width / 2, o_current->arc->start_angle, o_current->arc->end_angle); o_set_line_options(toplevel, new_obj, o_current->line_end, o_current->line_type, o_current->line_width, o_current->line_length, o_current->line_space); o_set_fill_options(toplevel, new_obj, FILLING_HOLLOW, -1, -1, -1, -1, -1); return new_obj; }