return 0;
}
+static void vertical(int* px, int* py, int dx, int dy, int d)
+{
+ /*
+ [cos90, -sin90] [0 -1] x
+ [sin90, cos90] [1 0] y
+ */
+
+ double R = sqrt(dx * dx + dy * dy);
+
+ *px = -dy * d / R;
+ *py = dx * d / R;
+}
+
+static void forward(int* px, int* py, int dx, int dy, int d)
+{
+ double R = sqrt(dx * dx + dy * dy);
+
+ *px = dx * d / R;
+ *py = dy * d / R;
+}
+
int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh)
{
ScfEcomponent* c;
cairo_set_source_rgb(cr, 0.5, 0.5, 0.0);
scf_logw("j: %ld, c->id: %ld, n_pins: %ld, ", j, c->id, c->n_pins);
+ int dx0;
+ int dy0;
+
+ int dx1;
+ int dy1;
+ int dx2;
+ int dy2;
+
+ int dx3;
+ int dy3;
+ int dx4;
+ int dy4;
switch (c->type) {
p = c->pins[SCF_EDA_Battery_POS];
if (p->y < c->y) {
- cairo_move_to(cr, c->x - 7, c->y - 5);
- cairo_line_to(cr, c->x + 7, c->y - 5);
+ cairo_move_to(cr, c->x - 8, c->y - 5);
+ cairo_line_to(cr, c->x + 8, c->y - 5);
+
+ cairo_move_to(cr, c->x, c->y - 5);
+ cairo_line_to(cr, p->x, p->y);
cairo_move_to(cr, c->x - 5, c->y + 5);
cairo_line_to(cr, c->x + 5, c->y + 5);
+
+ p = c->pins[SCF_EDA_Battery_NEG];
+ cairo_move_to(cr, c->x, c->y + 5);
+ cairo_line_to(cr, p->x, p->y);
+
} else {
+ cairo_move_to(cr, c->x - 7, c->y + 5);
+ cairo_line_to(cr, c->x + 7, c->y + 5);
+
+ cairo_move_to(cr, c->x, c->y + 5);
+ cairo_line_to(cr, p->x, p->y);
+
cairo_move_to(cr, c->x - 5, c->y - 5);
cairo_line_to(cr, c->x + 5, c->y - 5);
- cairo_move_to(cr, c->x - 7, c->y + 5);
- cairo_line_to(cr, c->x + 7, c->y + 5);
+ p = c->pins[SCF_EDA_Battery_NEG];
+ cairo_move_to(cr, c->x, c->y - 5);
+ cairo_line_to(cr, p->x, p->y);
}
- cairo_move_to(cr, c->x, c->y);
- cairo_line_to(cr, p->x, p->y);
-
- p = c->pins[SCF_EDA_Battery_NEG];
- cairo_move_to(cr, c->x, c->y);
- cairo_line_to(cr, p->x, p->y);
break;
case SCF_EDA_Resistor:
- cairo_rectangle(cr, c->x - 5, c->y - 5, 10, 10);
-
p = c->pins[0];
+
+ vertical(&dx0, &dy0, c->x - p->x, c->y - p->y, 4);
+ vertical(&dx1, &dy1, c->x - p->x, c->y - p->y, -8);
+ vertical(&dx2, &dy2, c->x - p->x, c->y - p->y, 8);
+
+ forward (&dx3, &dy3, c->x - p->x, c->y - p->y, -16);
+ forward (&dx4, &dy4, c->x - p->x, c->y - p->y, 16);
+
+ scf_logw("dx0: %d, dy0: %d\n", dx0, dy0);
+ scf_logw("dx1: %d, dy1: %d\n", dx1, dy1);
+ scf_logw("dx2: %d, dy2: %d\n", dx2, dy2);
+ scf_logw("dx3: %d, dy3: %d\n", dx3, dy3);
+ scf_logw("dx4: %d, dy4: %d\n", dx4, dy4);
+
+ cairo_move_to (cr, c->x, c->y);
+ cairo_rel_move_to(cr, dx0, dy0);
+ cairo_rel_line_to(cr, dx1, dy1);
+ cairo_rel_line_to(cr, dx4, dy4);
+ cairo_rel_line_to(cr, dx2, dy2);
+ cairo_rel_line_to(cr, dx3, dy3);
+
cairo_move_to(cr, c->x, c->y);
cairo_line_to(cr, p->x, p->y);