[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-121-gac5d484)
The branch, master has been updated
via ac5d484934d355055328d48b2c16b8ed551ca912 (commit)
via 08db7a435330db92db7ce99267ca6c624481e053 (commit)
via 48c35116377abd95e0914e6f28c00c9786392e70 (commit)
via 5844e01ce1eff3d756d3c77c7a6981316a098cd1 (commit)
via 2ee50f8ed4a738880d3ca04fd5a27c66b89bc743 (commit)
from 373becd3a5156236963b82e7f9a27be8f90db0c4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
gschem/src/i_basic.c | 20 ++++++++++++---
gschem/src/i_callbacks.c | 23 ++++++++++++----
gschem/src/o_move.c | 51 ++++++++++++++++++++++++++++++++++++++
gschem/src/x_dialog.c | 1 -
libgeda/.gitignore | 3 +-
libgeda/include/prototype.h | 2 +
libgeda/include/prototype_priv.h | 11 ++++++++
libgeda/include/struct.h | 19 ++++++++------
libgeda/src/f_print.c | 2 -
libgeda/src/m_basic.c | 18 +------------
libgeda/src/o_arc_basic.c | 29 +++++++++++++++------
libgeda/src/o_attrib.c | 24 ++++++++++++++++++
libgeda/src/o_basic.c | 38 ++++++++++++++++++++++++++++
libgeda/src/o_box_basic.c | 18 +++++++++++++
libgeda/src/o_bus_basic.c | 16 ++++++++++++
libgeda/src/o_circle_basic.c | 18 +++++++++++++
libgeda/src/o_complex_basic.c | 18 +++++++++++++
libgeda/src/o_line_basic.c | 19 ++++++++++++++
libgeda/src/o_net_basic.c | 16 ++++++++++++
libgeda/src/o_path_basic.c | 20 +++++++++++++++
libgeda/src/o_picture.c | 18 +++++++++++++
libgeda/src/o_pin_basic.c | 18 +++++++++++++
libgeda/src/o_text_basic.c | 18 +++++++++++++
libgeda/src/s_toplevel.c | 2 +-
24 files changed, 373 insertions(+), 49 deletions(-)
=================
Commit Messages
=================
commit ac5d484934d355055328d48b2c16b8ed551ca912
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri Jan 2 22:14:14 2009 +0100
gschem: deploy the new resnap mode in o_move.c
If the selection contains only one element or one element with it's
attributes then we can use the resnap feature.
This functionality uses the new functions from the last commits to get
the object position and to check the attribute/object relation.
:100644 100644 972761b... eaeae6a... M gschem/src/o_move.c
commit 08db7a435330db92db7ce99267ca6c624481e053
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sat Dec 20 17:53:12 2008 +0100
libgeda: check whether a attribute is attached to an object
Simple test function added.
:100644 100644 33b1cf0... 6de2ed7... M libgeda/.gitignore
:100644 100644 e36ab76... 536d088... M libgeda/include/prototype.h
:100644 100644 63afdaa... 575c20b... M libgeda/src/o_attrib.c
commit 48c35116377abd95e0914e6f28c00c9786392e70
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sat Dec 20 17:49:31 2008 +0100
libgeda: functions to get the position of an object
added a function o_get_position() to get the world position
of an object.
The returned position is dependant on the object type.
For the box and picture object the lower left corner is used.
For line, net, bus, path, the first point is used.
For pin the whichend is used.
For circle and arc the center is returned.
Complex and text object return it's base coordinate.
:100644 100644 77f1123... e36ab76... M libgeda/include/prototype.h
:100644 100644 f107194... c32c40d... M libgeda/include/prototype_priv.h
:100644 100644 41a4b54... 37b7512... M libgeda/src/o_arc_basic.c
:100644 100644 32c0e10... b681b8b... M libgeda/src/o_basic.c
:100644 100644 4ef8392... 5c749de... M libgeda/src/o_box_basic.c
:100644 100644 7637f65... 4c1a899... M libgeda/src/o_bus_basic.c
:100644 100644 eb0c315... f572d68... M libgeda/src/o_circle_basic.c
:100644 100644 42a8f38... 00f6955... M libgeda/src/o_complex_basic.c
:100644 100644 351eaa1... d04fdf7... M libgeda/src/o_line_basic.c
:100644 100644 d9b50df... 3345cda... M libgeda/src/o_net_basic.c
:100644 100644 5b29223... deae1b4... M libgeda/src/o_path_basic.c
:100644 100644 67fb223... 6c90a4b... M libgeda/src/o_picture.c
:100644 100644 3ff8f86... 2b9ef71... M libgeda/src/o_pin_basic.c
:100644 100644 10ae34f... 6c5864b... M libgeda/src/o_text_basic.c
commit 5844e01ce1eff3d756d3c77c7a6981316a098cd1
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sun Nov 16 13:54:28 2008 +0100
gschem: use the new snap states to toggle
The previous snap grid ON/OFF now toggles through the three states
SNAP_OFF, SNAP_GRID and SNAP_RESNAP.
Updated all status bar messages and added an "R" to the displayed grid
if the SNAP_RESNAP mode is active.
:100644 100644 46ce380... f592c45... M gschem/src/i_basic.c
:100644 100644 5935512... 64fd915... M gschem/src/i_callbacks.c
:100644 100644 5a1aa67... a26d150... M gschem/src/x_dialog.c
commit 2ee50f8ed4a738880d3ca04fd5a27c66b89bc743
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sun Nov 16 12:50:17 2008 +0100
libgeda: new snap state and snap cleanups
Switched toplevel->snap into a enum type and use the newly added
states.
removed unused and broken function on_snap(). Removed misc
wrong comments about the snapping mechanism.
:100644 100644 cacb4f5... eb5ffb4... M libgeda/include/struct.h
:100644 100644 ee75fa5... 883da82... M libgeda/src/f_print.c
:100644 100644 1dafc02... b5ca7c7... M libgeda/src/m_basic.c
:100644 100644 2c6a8e6... 41a4b54... M libgeda/src/o_arc_basic.c
:100644 100644 d4631ef... e89bc2c... M libgeda/src/s_toplevel.c
=========
Changes
=========
commit ac5d484934d355055328d48b2c16b8ed551ca912
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri Jan 2 22:14:14 2009 +0100
gschem: deploy the new resnap mode in o_move.c
If the selection contains only one element or one element with it's
attributes then we can use the resnap feature.
This functionality uses the new functions from the last commits to get
the object position and to check the attribute/object relation.
diff --git a/gschem/src/o_move.c b/gschem/src/o_move.c
index 972761b..eaeae6a 100644
--- a/gschem/src/o_move.c
+++ b/gschem/src/o_move.c
@@ -301,6 +301,57 @@ void o_move_cancel (GSCHEM_TOPLEVEL *w_current)
*/
void o_move_motion (GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
{
+ TOPLEVEL *toplevel = w_current->toplevel;
+ GList *selection, *s_current;
+ OBJECT *object;
+ gint object_x, object_y;
+ gboolean resnap = FALSE;
+
+ selection = geda_list_get_glist( toplevel->page_current->selection_list );
+
+ /* realign the object if we are in resnap mode */
+ if (selection != NULL
+ && toplevel->snap == SNAP_RESNAP) {
+
+ if (g_list_length(selection) > 1) {
+ /* find an object that is not attached to any other object */
+ for (s_current = selection;
+ s_current != NULL;
+ s_current = g_list_next(s_current)) {
+ if (((OBJECT *) s_current->data)->attached_to == NULL) {
+ object = (OBJECT *) s_current->data;
+ resnap = TRUE;
+ break;
+ }
+ }
+
+ /* Only resnap single elements. This is also the case if
+ the selection contains one object and all other object
+ elements are attributes of the object element.*/
+ for (s_current = selection;
+ s_current != NULL && resnap == TRUE;
+ s_current = g_list_next(s_current)) {
+ if (!(object == (OBJECT *) s_current->data)
+ && !o_attrib_is_attached(toplevel,
+ (OBJECT *) s_current->data, object)) {
+ resnap = FALSE;
+ }
+ }
+ } else { /* single object */
+ resnap = TRUE;
+ object = (OBJECT *) selection->data;
+ }
+
+ /* manipulate w_x and w_y in a way that will lead to a position
+ of the object that is aligned with the grid */
+ if (resnap) {
+ if (o_get_position(toplevel, &object_x, &object_y, object)) {
+ w_x += snap_grid(toplevel, object_x) - object_x;
+ w_y += snap_grid(toplevel, object_y) - object_y;
+ }
+ }
+ }
+
o_move_invalidate_rubber (w_current, FALSE);
w_current->second_wx = w_x;
w_current->second_wy = w_y;
commit 08db7a435330db92db7ce99267ca6c624481e053
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sat Dec 20 17:53:12 2008 +0100
libgeda: check whether a attribute is attached to an object
Simple test function added.
diff --git a/libgeda/.gitignore b/libgeda/.gitignore
index 33b1cf0..6de2ed7 100644
--- a/libgeda/.gitignore
+++ b/libgeda/.gitignore
@@ -35,4 +35,5 @@ GSYMS
GTAGS
HTML
gschem.log
-
+docs/images/*png
+docs/images/*pdf
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index e36ab76..536d088 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -110,6 +110,7 @@ void o_arc_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery
OBJECT *o_attrib_search(GList *list, OBJECT *item);
void o_attrib_add(TOPLEVEL *toplevel, OBJECT *object, OBJECT *item);
void o_attrib_free(TOPLEVEL *toplevel, OBJECT *current);
+gboolean o_attrib_is_attached (TOPLEVEL *toplevel, OBJECT *attrib, OBJECT *object);
void o_attrib_attach(TOPLEVEL *toplevel, OBJECT *attrib, OBJECT *object, int set_color);
void o_attrib_attach_list(TOPLEVEL *toplevel, GList *attr_list, OBJECT *object, int set_color);
void o_attrib_free_all(TOPLEVEL *toplevel, GList *list);
diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index 63afdaa..575c20b 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -142,6 +142,30 @@ void o_attrib_free(TOPLEVEL *toplevel, OBJECT *current)
}
}
+
+/*! \brief Check whether a attrib is attached to another object
+ * \par Function Description
+ * This function checks whether the object \a attrib is attached to
+ * the \a object.
+ *
+ * \param [in] toplevel The TOPLEVEL object.
+ * \param [in] attrib The attribute to be checket.
+ * \param [in] object The object where you want to add item as an attribute.
+ * \return TRUE if attrib is an attribute of object, FALSE otherwise
+ */
+gboolean o_attrib_is_attached (TOPLEVEL *toplevel,
+ OBJECT *attrib, OBJECT *object)
+{
+ if (attrib == NULL || object == NULL)
+ return FALSE;
+
+ if (attrib->attached_to == object)
+ return TRUE;
+
+ return FALSE;
+}
+
+
/*! \brief Attach existing attribute to an object.
* \par Function Description
* Attach existing attribute to an object.
commit 48c35116377abd95e0914e6f28c00c9786392e70
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sat Dec 20 17:49:31 2008 +0100
libgeda: functions to get the position of an object
added a function o_get_position() to get the world position
of an object.
The returned position is dependant on the object type.
For the box and picture object the lower left corner is used.
For line, net, bus, path, the first point is used.
For pin the whichend is used.
For circle and arc the center is returned.
Complex and text object return it's base coordinate.
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 77f1123..e36ab76 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -144,6 +144,7 @@ void o_recalc_single_object(TOPLEVEL *toplevel, OBJECT *o_current);
void o_recalc_object_glist(TOPLEVEL *toplevel, GList *object_glist);
void o_set_line_options(TOPLEVEL *toplevel, OBJECT *o_current, OBJECT_END end, OBJECT_TYPE type, int width, int length, int space);
void o_set_fill_options(TOPLEVEL *toplevel, OBJECT *o_current, OBJECT_FILLING type, int width, int pitch1, int angle1, int pitch2, int angle2);
+gboolean o_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_translate_world (TOPLEVEL *toplevel, gint dx, gint dy, OBJECT *object);
void o_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object);
void o_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object);
diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index f107194..c32c40d 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -96,6 +96,7 @@ void o_arc_print_phantom(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius,
double o_arc_shortest_distance(OBJECT *object, int x, int y, int force_soild);
gboolean o_arc_within_sweep(ARC *arc, gint x, gint y);
void world_get_arc_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_arc_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_arc_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_attrib.c */
@@ -124,6 +125,7 @@ void o_box_print_mesh(TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int
void o_box_print_hatch(TOPLEVEL *toplevel, FILE *fp, int x, int y, int width, int height, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y);
double o_box_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_box_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_box_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_box_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_bus_basic.c */
@@ -131,6 +133,7 @@ OBJECT *o_bus_read(TOPLEVEL *toplevel, char buf[], unsigned int release_ver, uns
char *o_bus_save(OBJECT *object);
void o_bus_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y);
void world_get_bus_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_bus_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_bus_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_circle_basic.c */
@@ -147,6 +150,7 @@ void o_circle_print_mesh(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius,
void o_circle_print_hatch(TOPLEVEL *toplevel, FILE *fp, int x, int y, int radius, int color, int fill_width, int angle1, int pitch1, int angle2, int pitch2, int origin_x, int origin_y);
double o_circle_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_circle_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_circle_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_circle_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_complex_basic.c */
@@ -154,6 +158,7 @@ OBJECT *o_complex_read(TOPLEVEL *toplevel, char buf[], unsigned int release_ver,
char *o_complex_save(OBJECT *object);
double o_complex_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_complex_bounds(TOPLEVEL *toplevel, OBJECT *complex, int *left, int *top, int *right, int *bottom);
+gboolean o_complex_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_complex_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_line_basic.c */
@@ -167,6 +172,7 @@ void o_line_print_center(TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, i
void o_line_print_phantom(TOPLEVEL *toplevel, FILE *fp, int x1, int y1, int x2, int y2, int color, int line_width, int length, int space, int origin_x, int origin_y);
double o_line_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_line_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_line_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_line_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_net_basic.c */
@@ -174,6 +180,7 @@ OBJECT *o_net_read(TOPLEVEL *toplevel, char buf[], unsigned int release_ver, uns
char *o_net_save(OBJECT *object);
void o_net_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y);
void world_get_net_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_net_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_net_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_path_basic.c */
@@ -182,6 +189,7 @@ char *o_path_save(OBJECT *object);
void o_path_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y);
double o_path_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_path_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_path_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_path_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
@@ -192,6 +200,7 @@ void o_picture_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current,
int origin_x, int origin_y);
double o_picture_shortest_distance(OBJECT *object, int x, int y, int force_soild);
void world_get_picture_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_picture_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_picture_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_pin_basic.c */
@@ -199,6 +208,7 @@ OBJECT *o_pin_read(TOPLEVEL *toplevel, char buf[], unsigned int release_ver, uns
char *o_pin_save(OBJECT *object);
void o_pin_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y);
void world_get_pin_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *top, int *right, int *bottom);
+gboolean o_pin_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_pin_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* o_text_basic.c */
@@ -208,6 +218,7 @@ void o_text_print_text_string(FILE *fp, char *string, int unicode_count, gunicha
void o_text_print(TOPLEVEL *toplevel, FILE *fp, OBJECT *o_current, int origin_x, int origin_y, int unicode_count, gunichar *unicode_table);
double o_text_shortest_distance(OBJECT *object, int x, int y, int force_soild);
int world_get_text_bounds(TOPLEVEL *toplevel, OBJECT *o_current, int *left, int *top, int *right, int *bottom);
+gboolean o_text_get_position(TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object);
void o_text_recalc(TOPLEVEL *toplevel, OBJECT *o_current);
/* s_clib.c */
diff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c
index 41a4b54..37b7512 100644
--- a/libgeda/src/o_arc_basic.c
+++ b/libgeda/src/o_arc_basic.c
@@ -583,6 +583,23 @@ void world_get_arc_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left,
}
+/*! \brief get the position of the center point
+ * \par Function Description
+ * This function gets the position of the center point of an arc object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_arc_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->arc->x;
+ *y = object->arc->y;
+ return TRUE;
+}
/*! \brief
* \par Function Description
diff --git a/libgeda/src/o_basic.c b/libgeda/src/o_basic.c
index 32c0e10..b681b8b 100644
--- a/libgeda/src/o_basic.c
+++ b/libgeda/src/o_basic.c
@@ -262,6 +262,44 @@ void o_set_fill_options(TOPLEVEL *toplevel, OBJECT *o_current,
}
+/*! \brief get the base position of an object
+ * \par Function Description
+ * This function gets the position of an object in world coordinates.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_get_position (TOPLEVEL *toplevel, gint *x, gint *y, OBJECT *object)
+{
+ gboolean (*func) (TOPLEVEL*, int*, int*, OBJECT*) = NULL;
+
+ switch (object->type) {
+ case OBJ_LINE: func = o_line_get_position; break;
+ case OBJ_NET: func = o_net_get_position; break;
+ case OBJ_BUS: func = o_bus_get_position; break;
+ case OBJ_BOX: func = o_box_get_position; break;
+ case OBJ_PICTURE: func = o_picture_get_position; break;
+ case OBJ_CIRCLE: func = o_circle_get_position; break;
+ case OBJ_PLACEHOLDER:
+ case OBJ_COMPLEX: func = o_complex_get_position; break;
+ case OBJ_TEXT: func = o_text_get_position; break;
+ case OBJ_PATH: func = o_path_get_position; break;
+ case OBJ_PIN: func = o_pin_get_position; break;
+ case OBJ_ARC: func = o_arc_get_position; break;
+ default:
+ g_critical ("o_get_position: object %p has bad type '%c'\n",
+ object, object->type);
+ }
+
+ if (func != NULL) {
+ return (*func) (toplevel, x, y, object);
+ }
+ return FALSE;
+}
+
/*! \brief Translates an object in world coordinates
* \par Function Description
diff --git a/libgeda/src/o_box_basic.c b/libgeda/src/o_box_basic.c
index 4ef8392..5c749de 100644
--- a/libgeda/src/o_box_basic.c
+++ b/libgeda/src/o_box_basic.c
@@ -606,6 +606,24 @@ void world_get_box_bounds(TOPLEVEL *toplevel, OBJECT *object,
*right += halfwidth;
*bottom += halfwidth;
}
+
+/*! \brief get the position of the left bottom point
+ * \par Function Description
+ * This function gets the position of the bottom left point of a box object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_box_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = min(object->box->lower_x, object->box->upper_x);
+ *y = min(object->box->lower_y, object->box->upper_y);
+ return TRUE;
+}
/*! \brief Print BOX to Postscript document.
* \par Function Description
diff --git a/libgeda/src/o_bus_basic.c b/libgeda/src/o_bus_basic.c
index 7637f65..4c1a899 100644
--- a/libgeda/src/o_bus_basic.c
+++ b/libgeda/src/o_bus_basic.c
@@ -35,6 +35,22 @@
/*! Default setting for bus draw function. */
void (*bus_draw_func)() = NULL;
+/*! \brief get the position of the first bus point
+ * \par Function Description
+ * This function gets the position of the first point of a bus object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_bus_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ return o_line_get_position(toplevel, x, y, object);
+}
+
/*! \brief calculate and return the boundaries of a bus object
* \par Function Description
* This function calculates the object boudaries of a bus \a object.
diff --git a/libgeda/src/o_circle_basic.c b/libgeda/src/o_circle_basic.c
index eb0c315..f572d68 100644
--- a/libgeda/src/o_circle_basic.c
+++ b/libgeda/src/o_circle_basic.c
@@ -545,6 +545,24 @@ void world_get_circle_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left,
}
+/*! \brief get the position of the center point
+ * \par Function Description
+ * This function gets the position of the center point of a circle object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_circle_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->circle->center_x;
+ *y = object->circle->center_y;
+ return TRUE;
+}
+
/*! \brief Print circle to Postscript document.
* \par Function Description
* This function prints the circle described by the <B>o_current</B>
diff --git a/libgeda/src/o_complex_basic.c b/libgeda/src/o_complex_basic.c
index 42a8f38..00f6955 100644
--- a/libgeda/src/o_complex_basic.c
+++ b/libgeda/src/o_complex_basic.c
@@ -174,6 +174,24 @@ void world_get_complex_bounds(TOPLEVEL *toplevel, OBJECT *complex,
left, top, right, bottom);
}
+/*! \brief get the position of the complex base point
+ * \par Function Description
+ * This function gets the position of the base point of a complex object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_complex_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->complex->x;
+ *y = object->complex->y;
+ return TRUE;
+}
+
/*! \brief check whether an object is a attributes
* \par Function Description
* This function checks if an object should be promoted.
diff --git a/libgeda/src/o_line_basic.c b/libgeda/src/o_line_basic.c
index 351eaa1..d04fdf7 100644
--- a/libgeda/src/o_line_basic.c
+++ b/libgeda/src/o_line_basic.c
@@ -505,6 +505,25 @@ void world_get_line_bounds(TOPLEVEL *toplevel, OBJECT *object,
*bottom += halfwidth;
}
+/*! \brief get the position of the first line point
+ * \par Function Description
+ * This function gets the position of the first point of a line object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_line_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->line->x[0];
+ *y = object->line->y[0];
+ return TRUE;
+}
+
+
/*! \brief Print line to Postscript document.
* \par Function Description
* This function prints the line described by the <B>o_current</B>
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index d9b50df..3345cda 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -35,6 +35,22 @@
/*! Default setting for net draw function. */
void (*net_draw_func)() = NULL;
+/*! \brief get the position of the first net point
+ * \par Function Description
+ * This function gets the position of the first point of a net object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_net_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ return o_line_get_position(toplevel, x, y, object);
+}
+
/*! \brief calculate and return the boundaries of a net object
* \par Function Description
* This function calculates the object boudaries of a net \a object.
diff --git a/libgeda/src/o_path_basic.c b/libgeda/src/o_path_basic.c
index 5b29223..deae1b4 100644
--- a/libgeda/src/o_path_basic.c
+++ b/libgeda/src/o_path_basic.c
@@ -573,6 +573,26 @@ void world_get_path_bounds (TOPLEVEL *toplevel, OBJECT *object,
}
}
+/*! \brief get the position of the first path point
+ * \par Function Description
+ * This function gets the position of the first point of an path object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_path_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ if (object->path->num_sections == 0)
+ return FALSE;
+
+ *x = object->path->sections[0].x3;
+ *y = object->path->sections[0].y3;
+ return TRUE;
+}
/*! \brief Print a solid PATH to Postscript document.
* \par Function Description
diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c
index 67fb223..6c90a4b 100644
--- a/libgeda/src/o_picture.c
+++ b/libgeda/src/o_picture.c
@@ -418,6 +418,24 @@ void world_get_picture_bounds(TOPLEVEL *toplevel, OBJECT *object,
*bottom = max(object->picture->upper_y, object->picture->lower_y);
}
+
+/*! \brief get the position of the left bottom point
+ * \par Function Description
+ * This function gets the position of the bottom left point of a picture object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_picture_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = min(object->picture->lower_x, object->picture->upper_x);
+ *y = min(object->picture->lower_y, object->picture->upper_y);
+ return TRUE;
+}
/*! \brief Modify the description of a picture OBJECT.
* \par Function Description
diff --git a/libgeda/src/o_pin_basic.c b/libgeda/src/o_pin_basic.c
index 3ff8f86..2b9ef71 100644
--- a/libgeda/src/o_pin_basic.c
+++ b/libgeda/src/o_pin_basic.c
@@ -52,6 +52,24 @@ void world_get_pin_bounds(TOPLEVEL *toplevel, OBJECT *object, int *left, int *to
world_get_line_bounds( toplevel, object, left, top, right, bottom );
}
+/*! \brief get the position of a whichend of the pin object
+ * \par Function Description
+ * This function gets the position of the whichend side of a pin object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_pin_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->line->x[object->whichend];
+ *y = object->line->y[object->whichend];
+ return TRUE;
+}
+
/*! \brief create a new pin object
* \par Function Description
* This function creates and returns a new pin object.
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index 10ae34f..6c5864b 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -173,6 +173,24 @@ int world_get_text_bounds(TOPLEVEL *toplevel, OBJECT *o_current, int *left,
left, top, right, bottom);
}
+/*! \brief get the position of a text object
+ * \par Function Description
+ * This function gets the position of the base point of a text object.
+ *
+ * \param [in] toplevel The toplevel environment.
+ * \param [out] x pointer to the x-position
+ * \param [out] y pointer to the y-position
+ * \param [in] object The object to get the position.
+ * \return TRUE if successfully determined the position, FALSE otherwise
+ */
+gboolean o_text_get_position (TOPLEVEL *toplevel, gint *x, gint *y,
+ OBJECT *object)
+{
+ *x = object->text->x;
+ *y = object->text->y;
+ return TRUE;
+}
+
/*! \brief initialize the hash tables for the fonts
* \par Function Description
* This function initializes the two global hash tables <b>font_loaded</b>
commit 5844e01ce1eff3d756d3c77c7a6981316a098cd1
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sun Nov 16 13:54:28 2008 +0100
gschem: use the new snap states to toggle
The previous snap grid ON/OFF now toggles through the three states
SNAP_OFF, SNAP_GRID and SNAP_RESNAP.
Updated all status bar messages and added an "R" to the displayed grid
if the SNAP_RESNAP mode is active.
diff --git a/gschem/src/i_basic.c b/gschem/src/i_basic.c
index 46ce380..f592c45 100644
--- a/gschem/src/i_basic.c
+++ b/gschem/src/i_basic.c
@@ -167,8 +167,10 @@ void i_show_state(GSCHEM_TOPLEVEL *w_current, const char *message)
if(toplevel->show_hidden_text)
array[i--] = _("Show Hidden");
- if(!toplevel->snap)
+ if(toplevel->snap == SNAP_OFF)
array[i--] = _("Snap Off");
+ else if (toplevel->snap == SNAP_RESNAP)
+ array[i--] = _("Resnap Active");
if(message && message[0])
array[i] = message;
@@ -526,11 +528,21 @@ void i_update_grid_info (GSCHEM_TOPLEVEL *w_current)
if (!w_current->grid_label)
return;
-
- if (!toplevel->snap)
+
+ switch (toplevel->snap) {
+ case SNAP_OFF:
snap = g_strdup(_("OFF"));
- else
+ break;
+ case SNAP_GRID:
snap = g_strdup_printf("%d", toplevel->snap_size);
+ break;
+ case SNAP_RESNAP:
+ snap = g_strdup_printf("%dR", toplevel->snap_size);
+ break;
+ default:
+ g_critical("i_set_grid: toplevel->snap out of range: %d\n",
+ toplevel->snap);
+ }
if (w_current->grid == GRID_NONE) {
grid = g_strdup(_("OFF"));
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 5935512..64fd915 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -933,11 +933,11 @@ DEFINE_I_CALLBACK(edit_translate)
i_update_middle_button(w_current,
i_callback_edit_translate, _("Translate"));
- if (w_current->toplevel->snap == 0) {
+ if (w_current->toplevel->snap == SNAP_OFF) {
s_log_message(_("WARNING: Do not translate with snap off!\n"));
s_log_message(_("WARNING: Turning snap on and continuing "
"with translate.\n"));
- w_current->toplevel->snap = 1;
+ w_current->toplevel->snap = SNAP_GRID;
i_show_state(w_current, NULL); /* update status on screen */
}
@@ -3394,13 +3394,24 @@ DEFINE_I_CALLBACK(options_snap)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
- if (w_current->toplevel->snap) {
- w_current->toplevel->snap = 0;
+ /* toggle to the next snap state */
+ w_current->toplevel->snap = (w_current->toplevel->snap+1) % SNAP_STATE_COUNT;
+
+ switch (w_current->toplevel->snap) {
+ case SNAP_OFF:
s_log_message(_("Snap OFF (CAUTION!)\n"));
- } else {
- w_current->toplevel->snap = 1;
+ break;
+ case SNAP_GRID:
s_log_message(_("Snap ON\n"));
+ break;
+ case SNAP_RESNAP:
+ s_log_message(_("Snap back to the grid (CAUTION!)\n"));
+ break;
+ default:
+ g_critical("options_snap: toplevel->snap out of range: %d\n",
+ w_current->toplevel->snap);
}
+
i_show_state(w_current, NULL); /* update status on screen */
i_update_grid_info (w_current);
}
diff --git a/gschem/src/x_dialog.c b/gschem/src/x_dialog.c
index 5a1aa67..a26d150 100644
--- a/gschem/src/x_dialog.c
+++ b/gschem/src/x_dialog.c
@@ -2100,7 +2100,6 @@ void coord_display_update(GSCHEM_TOPLEVEL *w_current, int x, int y)
g_free(string);
SCREENtoWORLD(toplevel, x, y, &world_x, &world_y);
- /* TODO: Do we want to snap the coordinate display? */
world_x = snap_grid(toplevel, world_x);
world_y = snap_grid(toplevel, world_y);
commit 2ee50f8ed4a738880d3ca04fd5a27c66b89bc743
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Sun Nov 16 12:50:17 2008 +0100
libgeda: new snap state and snap cleanups
Switched toplevel->snap into a enum type and use the newly added
states.
removed unused and broken function on_snap(). Removed misc
wrong comments about the snapping mechanism.
diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h
index cacb4f5..eb5ffb4 100644
--- a/libgeda/include/struct.h
+++ b/libgeda/include/struct.h
@@ -80,20 +80,18 @@ typedef enum { F_OPEN_RC = 1,
F_OPEN_RESTORE_CWD = 4,
} FOpenFlags;
-/* these enum are constant to define :
- - the end of open line of an object ;
- - the type of the line of an object ;
- - the filling of a closed object. */
-/* used in struct st_object (predefined type OBJECT)*/
+/*! \brief line end style for an open line of an object */
typedef enum {END_NONE, END_SQUARE, END_ROUND} OBJECT_END;
+
+/*! \brief line style of lines, rect, circles, arcs */
typedef enum {TYPE_SOLID, TYPE_DOTTED, TYPE_DASHED, TYPE_CENTER, TYPE_PHANTOM, TYPE_ERASE} OBJECT_TYPE;
-typedef enum {FILLING_HOLLOW, FILLING_FILL, FILLING_MESH, FILLING_HATCH, FILLING_VOID} OBJECT_FILLING;
+/*! \brief fill style of objects like cirle, rect, path */
+typedef enum {FILLING_HOLLOW, FILLING_FILL, FILLING_MESH, FILLING_HATCH, FILLING_VOID} OBJECT_FILLING;
struct st_line {
int x[2];
int y[2];
-
};
struct st_point {
@@ -438,6 +436,9 @@ struct st_page {
};
+/*! \brief different kind of snapping mechanisms used in TOPLEVEL */
+typedef enum {SNAP_OFF, SNAP_GRID, SNAP_RESNAP, SNAP_STATE_COUNT} SNAP_STATE;
+
struct st_toplevel {
/* have to decided on component list stuff */
@@ -455,7 +456,9 @@ struct st_toplevel {
int init_top, init_bottom;
int width, height; /* height, width of window */
- int snap; /* Snap on/off*/
+
+ /*! \brief whether and how to snap to the current grid */
+ SNAP_STATE snap;
int override_color; /* used in doing selections */
diff --git a/libgeda/src/f_print.c b/libgeda/src/f_print.c
index ee75fa5..883da82 100644
--- a/libgeda/src/f_print.c
+++ b/libgeda/src/f_print.c
@@ -224,8 +224,6 @@ void f_print_footer(FILE *fp)
* \param [in] unicode_count Number of items in unicode table.
* \param [in] unicode_table Table of unicode items.
* \return void
- *
- * \todo what happens if snap is off? hack deal with this !!!!!!!!
*/
void f_print_objects (TOPLEVEL *toplevel, FILE *fp, const GList *obj_list,
int start_x, int start_y, float scale,
diff --git a/libgeda/src/m_basic.c b/libgeda/src/m_basic.c
index 1dafc02..b5ca7c7 100644
--- a/libgeda/src/m_basic.c
+++ b/libgeda/src/m_basic.c
@@ -206,10 +206,9 @@ int snap_grid(TOPLEVEL *toplevel, int input)
int p, m, n;
int sign, value, snap_grid;
- if (!toplevel->snap || (toplevel->snap_size <= 0)) {
+ if (toplevel->snap == SNAP_OFF || (toplevel->snap_size <= 0)) {
return(input);
}
-
snap_grid = toplevel->snap_size;
@@ -344,21 +343,6 @@ void set_window(TOPLEVEL *toplevel, PAGE *page,
page->to_world_y_constant = (fw1 - fw0) / fw;
}
-
-/*! \brief Checks if a point is snapped.
- * \par Function Description
- * This function checks if a point is snapped.
- *
- * \param [in] val The point to check.
- * \return 0 if point (x) is snapped, non-zero otherwise
- *
- * \note This function is unused for now.
- */
-int on_snap(int val)
-{
- return( (val / 100)*100 - val);
-}
-
/*! \brief */
typedef struct st_halfspace HALFSPACE;
diff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c
index 2c6a8e6..41a4b54 100644
--- a/libgeda/src/o_arc_basic.c
+++ b/libgeda/src/o_arc_basic.c
@@ -302,21 +302,15 @@ OBJECT *o_arc_read (TOPLEVEL *toplevel, char buf[],
return new_obj;
}
-/*! \brief
+/*! \brief create the string representation of an arc object
* \par Function Description
- * This function formats a string in the buffer <B>*buff</B> to describe
+ * This function formats a string in the buffer <B>*buf</B> to describe
* the arc object <B>*object</B>.
- * It follows the post-20000704 release file format that handle the
- * line type and filling options.
* A pointer to the new allocated and formated string is returned.
* The string must be freed at some point.
*
* \param [in] object
- * \return
- *
- * \todo EEK! there is a nasty non-snap bug here!
- * Basically the center isn't being snapped
- * in complex objects only it seems...
+ * \return the string representation of the arc object
*/
char *o_arc_save(OBJECT *object)
{
diff --git a/libgeda/src/s_toplevel.c b/libgeda/src/s_toplevel.c
index d4631ef..e89bc2c 100644
--- a/libgeda/src/s_toplevel.c
+++ b/libgeda/src/s_toplevel.c
@@ -61,7 +61,7 @@ TOPLEVEL *s_toplevel_new (void)
toplevel->width = 1;
toplevel->height = 1;
- toplevel->snap = 1;
+ toplevel->snap = SNAP_GRID;
toplevel->override_color = -1;
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs