1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-06-28 13:48:53 +03:00

When no instance is selected, show the polar coordinates of the current

pointer position relative to the user origin in the radius/angle fields.
This helps to make quick manual measurements, e.g., of clearances.

This also fixes the following bug:
- gui_canvas.c (refresh_pos): showed canvas coordinates instead of model
  coordinates



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5755 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-12-15 19:33:15 +00:00
parent 2a819a82d7
commit a830226830
6 changed files with 42 additions and 9 deletions

12
coord.c
View File

@ -131,17 +131,25 @@ struct coord rotate_r(struct coord c, unit_type r, double angle)
}
double theta(struct coord c, struct coord p)
double theta_vec(struct coord v)
{
double a;
a = atan2(p.y-c.y, p.x-c.x)/M_PI*180.0;
a = atan2(v.y, v.x)/M_PI*180.0;
if (a < 0)
a += 360.0;
return a;
}
double theta(struct coord c, struct coord p)
{
p.x -= c.x;
p.y -= c.y;
return theta_vec(p);
}
/* ----- sorting coordinates ----------------------------------------------- */

View File

@ -84,6 +84,7 @@ struct coord sub_vec(struct coord a, struct coord b);
struct coord neg_vec(struct coord v);
struct coord rotate_r(struct coord c, unit_type r, double angle);
double theta_vec(struct coord v);
double theta(struct coord c, struct coord p);
void swap_coord(unit_type *a, unit_type *b);

View File

@ -36,7 +36,7 @@
void (*highlight)(void) = NULL;
static struct coord curr_pos;
static struct coord curr_pos; /* canvas coordinates ! */
static struct coord user_origin = { 0, 0 };
static int dragging = 0;
@ -55,16 +55,28 @@ static void update_zoom(void)
static void update_pos(struct coord pos)
{
struct coord user;
unit_type diag;
set_with_units(status_set_sys_x, "X ", pos.x);
set_with_units(status_set_sys_y, "Y ", pos.y);
set_with_units(status_set_user_x, "x ", pos.x-user_origin.x);
set_with_units(status_set_user_y, "y ", pos.y-user_origin.y);
user.x = pos.x-user_origin.x;
user.y = pos.y-user_origin.y;
set_with_units(status_set_user_x, "x ", user.x);
set_with_units(status_set_user_y, "y ", user.y);
if (!selected_inst) {
diag = hypot(user.x, user.y);
set_with_units(status_set_r, "r = ", diag);
status_set_angle_xy(user);
}
}
void refresh_pos(void)
{
update_pos(curr_pos);
update_pos(canvas_to_coord(curr_pos.x, curr_pos.y));
}

View File

@ -155,6 +155,16 @@ void status_set_xy(struct coord coord)
}
void status_set_angle_xy(struct coord v)
{
if (!v.x && !v.y)
status_set_angle("a = 0 deg");
else
status_set_angle("a = %3.1f deg", theta_vec(v));
}
static void entry_color(GtkWidget *widget, const char *color)
{
GdkColor col;

View File

@ -85,6 +85,7 @@ void status_set_unit(const char *fmt, ...)
__attribute__((format(printf, 1, 2)));
void status_set_xy(struct coord coord);
void status_set_angle_xy(struct coord v);
void status_begin_reporting(void);

7
inst.c
View File

@ -23,6 +23,7 @@
#include "delete.h"
#include "gui_util.h"
#include "gui_status.h"
#include "gui_canvas.h"
#include "gui_tool.h"
#include "gui_meas.h"
#include "gui_inst.h"
@ -394,6 +395,7 @@ void inst_deselect(void)
status_set_angle("");
selected_inst = NULL;
edit_nothing();
refresh_pos();
}
@ -449,15 +451,14 @@ static void rect_status(struct coord a, struct coord b, unit_type width,
int rounded)
{
struct coord d = sub_vec(b, a);
double angle, r;
double r;
unit_type diag;
status_set_xy(d);
if (!d.x && !d.y)
status_set_angle("a = 0 deg");
else {
angle = theta(a, b);
status_set_angle("a = %3.1f deg", angle);
status_set_angle("a = %3.1f deg", theta(a, b));
}
if (d.x < 0)
d.x = -d.x;