1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 14:51:53 +02:00

sch2fig/: make *_poly vectors "const"; add tagging capability to gfx API

This commit is contained in:
Werner Almesberger 2016-08-01 10:12:29 -03:00
parent 1d3c7d635b
commit 065c82cf25
6 changed files with 32 additions and 7 deletions

View File

@ -116,7 +116,8 @@ static void paint(cairo_t *cr, int color, int fill_color)
/* ----- General items ----------------------------------------------------- */
static void cr_poly(void *ctx, int points, int x[points], int y[points],
static void cr_poly(void *ctx,
int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer)
{
struct cairo_ctx *cc = ctx;

View File

@ -84,7 +84,8 @@ static void fig_rect(void *ctx, int sx, int sy, int ex, int ey,
}
static void fig_poly(void *ctx, int points, int x[points], int y[points],
static void fig_poly(void *ctx,
int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer)
{
int i;
@ -152,6 +153,14 @@ static void fig_arc(void *ctx, int x, int y, int r, int sa, int ea,
}
static void fig_tag(void *ctx, const char *s,
int points, const int x[points], const int y[points])
{
printf("# href=\"%s\" alt=\"\"\n", s);
fig_poly(ctx, points, x, y, COLOR_NONE, COLOR_NONE, 999);
}
static void fig_text(void *ctx, int x, int y, const char *s, unsigned size,
enum text_align align, int rot, unsigned color, unsigned layer)
{
@ -275,6 +284,7 @@ const struct gfx_ops fig_ops = {
.circ = fig_circ,
.arc = fig_arc,
.text = fig_text,
.tag = fig_tag,
.text_width = fig_text_width,
.init = fig_init,
};

View File

@ -52,7 +52,7 @@ void gfx_rect(int sx, int sy, int ex, int ey,
}
void gfx_poly(int points, int x[points], int y[points],
void gfx_poly(int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer)
{
gfx_ops->poly(gfx_ctx, points, x, y, color, fill_color, layer);
@ -79,6 +79,14 @@ void gfx_text(int x, int y, const char *s, unsigned size,
}
void gfx_tag(const char *s,
unsigned points, const int x[points], int const y[points])
{
if (gfx_ops->tag)
gfx_ops->tag(gfx_ctx, s, points, x, y);
}
unsigned gfx_text_width(const char *s, unsigned size)
{
return gfx_ops->text_width(gfx_ctx, s, size);

View File

@ -25,7 +25,8 @@ struct gfx_ops {
int color, unsigned layer);
void (*rect)(void *ctx, int sx, int sy, int ex, int ey,
int color, int fill_color, unsigned layer);
void (*poly)(void *ctx, int points, int x[points], int y[points],
void (*poly)(void *ctx,
int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer);
void (*circ)(void *ctx, int x, int y, int r,
int color, int fill_color, unsigned layer);
@ -33,6 +34,8 @@ struct gfx_ops {
int color, int fill_color, unsigned layer);
void (*text)(void *ctx, int x, int y, const char *s, unsigned size,
enum text_align align, int rot, unsigned color, unsigned layer);
void (*tag)(void *ctx, const char *s,
int points, const int x[points], const int y[points]);
unsigned (*text_width)(void *ctx, const char *s, unsigned size);
void *(*init)(int argc, char *const *argv);
void (*new_sheet)(void *ctx);
@ -45,13 +48,15 @@ struct gfx_ops {
void gfx_line(int sx, int sy, int ex, int ey, int color, unsigned layer);
void gfx_rect(int sx, int sy, int ex, int ey,
int color, int fill_color, unsigned layer);
void gfx_poly(int points, int x[points], int y[points],
void gfx_poly(int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer);
void gfx_circ(int x, int y, int r, int color, int fill_color, unsigned layer);
void gfx_arc(int x, int y, int r, int sa, int ea,
int color, int fill_color, unsigned layer);
void gfx_text(int x, int y, const char *s, unsigned size,
enum text_align align, int rot, unsigned color, unsigned layer);
void gfx_tag(const char *s,
unsigned points, const int x[points], int const y[points]);
unsigned gfx_text_width(const char *s, unsigned size);
/* inititalization and termination */

View File

@ -153,7 +153,8 @@ void layer_rect(void *ctx, int sx, int sy, int ex, int ey,
}
void layer_poly(void *ctx, int points, int x[points], int y[points],
void layer_poly(void *ctx,
int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer)
{
struct layer *lc = ctx;

View File

@ -39,7 +39,7 @@ void layer_line(void *ctx, int sx, int sy, int ex, int ey,
int color, unsigned layer);
void layer_rect(void *ctx, int sx, int sy, int ex, int ey,
int color, int fill_color, unsigned layer);
void layer_poly(void *ctx, int points, int x[points], int y[points],
void layer_poly(void *ctx, int points, const int x[points], const int y[points],
int color, int fill_color, unsigned layer);
void layer_circ(void *ctx, int x, int y, int r,
int color, int fill_color, unsigned layer);