[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-287-g6fac0c0)



The branch, master has been updated
       via  6fac0c0f99b51a845f8ab7be2c358f703a54d61f (commit)
       via  f958bbe344b9834291446858e884ee742927596f (commit)
      from  c2449384b9ecea7f2c9e2e17ffc20f836693ced8 (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
=========

 docs/scheme-api/geda-scheme.texi |    6 +++++
 gschem/scheme/gschem/window.scm  |    5 +++-
 gschem/src/g_window.c            |   44 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 3 deletions(-)


=================
 Commit Messages
=================

commit 6fac0c0f99b51a845f8ab7be2c358f703a54d61f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add 'snap-point' function to (gschem window) module.
    
    The snap-point function returns the closest on-grid position to a
    given point. Suggested by Luigi Palese.
    
    Affects-bug: lp-905294

:100644 100644 fe33768... f7b251c... M	docs/scheme-api/geda-scheme.texi
:100644 100644 62765ed... 3f2f300... M	gschem/scheme/gschem/window.scm
:100644 100644 799353b... c6b15e3... M	gschem/src/g_window.c

commit f958bbe344b9834291446858e884ee742927596f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Correct some comments.

:100644 100644 2996ce6... 799353b... M	gschem/src/g_window.c

=========
 Changes
=========

commit 6fac0c0f99b51a845f8ab7be2c358f703a54d61f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Add 'snap-point' function to (gschem window) module.
    
    The snap-point function returns the closest on-grid position to a
    given point. Suggested by Luigi Palese.
    
    Affects-bug: lp-905294

diff --git a/docs/scheme-api/geda-scheme.texi b/docs/scheme-api/geda-scheme.texi
index fe33768..f7b251c 100644
--- a/docs/scheme-api/geda-scheme.texi
+++ b/docs/scheme-api/geda-scheme.texi
@@ -1687,6 +1687,12 @@ form @samp{(x . y)}.  If the pointer is outside the display area,
 returns @samp{#f}.
 @end defun
 
+@defun snap-point point
+Snaps the given @var{point} to the current snap grid, i.e. returns the
+closest grid location to @var{point}.  Expects a point in the form
+@samp{(x . y)}, and returns a point in the same format.
+@end defun
+
 @node Key mapping
 @section Key mapping
 
diff --git a/gschem/scheme/gschem/window.scm b/gschem/scheme/gschem/window.scm
index 62765ed..3f2f300 100644
--- a/gschem/scheme/gschem/window.scm
+++ b/gschem/scheme/gschem/window.scm
@@ -1,6 +1,6 @@
 ;; gEDA - GPL Electronic Design Automation
 ;; gschem - gEDA Schematic Capture - Scheme API
-;; Copyright (C) 2010 Peter Brett <peter@xxxxxxxxxxxxx>
+;; Copyright (C) 2010-2011 Peter Brett <peter@xxxxxxxxxxxxx>
 ;;
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -28,3 +28,6 @@
 (define-public active-page %active-page)
 (define-public set-active-page! %set-active-page!)
 (define-public pointer-position %pointer-position)
+
+(define-public (snap-point point)
+  (%snap-point (car point) (cdr point)))
diff --git a/gschem/src/g_window.c b/gschem/src/g_window.c
index 799353b..c6b15e3 100644
--- a/gschem/src/g_window.c
+++ b/gschem/src/g_window.c
@@ -251,6 +251,42 @@ SCM_DEFINE (pointer_position, "%pointer-position", 0, 0, 0,
 }
 
 /*!
+ * \brief Snap a point to the snap grid.
+ * \par Function Description
+ * Snaps the point (\a x_s, \a y_s) to the snap grid, returning the
+ * snapped point position as a cons in the form:
+ *
+ * <code>(x . y)</code>
+ *
+ * This always snaps the given point to the grid, disregarding the
+ * current user snap settings.
+ *
+ * \note Scheme API: Implements the %snap-point procedure in the
+ * (gschem core window) module.
+ *
+ * \param x_s the x-coordinate of the point to be snapped to grid.
+ * \param y_s the y-coordinate of the point to be snapped to grid.
+ * \return the snapped coordinates.
+ */
+SCM_DEFINE (snap_point, "%snap-point", 2, 0, 0,
+            (SCM x_s, SCM y_s), "Get the current snap grid size.")
+{
+  SCM_ASSERT (scm_is_integer (x_s), x_s, SCM_ARG1, s_snap_point);
+  SCM_ASSERT (scm_is_integer (y_s), y_s, SCM_ARG2, s_snap_point);
+
+  /* We save and restore the current snap setting, because we want to
+   * *always* snap the requested cordinates. */
+  GSCHEM_TOPLEVEL *w_current = g_current_window ();
+  int save_snap = w_current->snap;
+  w_current->snap = SNAP_GRID;
+  int x = snap_grid (w_current, scm_to_int (x_s));
+  int y = snap_grid (w_current, scm_to_int (y_s));
+  w_current->snap = save_snap;
+
+  return scm_cons (scm_from_int (x), scm_from_int (y));
+}
+
+/*!
  * \brief Create the (gschem core window) Scheme module
  * \par Function Description
  * Defines procedures in the (gschem core window) module. The module
@@ -264,7 +300,8 @@ init_module_gschem_core_window ()
 
   /* Add them to the module's public definitions. */
   scm_c_export (s_current_window, s_active_page, s_set_active_page_x,
-                s_override_close_page_x, s_pointer_position, NULL);
+                s_override_close_page_x, s_pointer_position,
+                s_snap_point, NULL);
 
   /* Override procedures in the (geda core page) module */
   {

commit f958bbe344b9834291446858e884ee742927596f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    scheme-api: Correct some comments.

diff --git a/gschem/src/g_window.c b/gschem/src/g_window.c
index 2996ce6..799353b 100644
--- a/gschem/src/g_window.c
+++ b/gschem/src/g_window.c
@@ -224,7 +224,7 @@ SCM_DEFINE (override_close_page_x, "%close-page!", 1, 0, 0,
 }
 
 /*!
- * Get the current pointer position
+ * \brief Get the current pointer position
  * \par Function Description
  * Returns the current mouse pointer position, expressed in world
  * coordinates.  If the pointer is outside the schematic drawing area,
@@ -234,6 +234,9 @@ SCM_DEFINE (override_close_page_x, "%close-page!", 1, 0, 0,
  *
  * <code>(x . y)</code>
  *
+ * \note Scheme API: Implements the %pointer-position procedure in the
+ * (gschem core window) module.
+ *
  * \return The current pointer position, or SCM_BOOL_F.
  */
 SCM_DEFINE (pointer_position, "%pointer-position", 0, 0, 0,




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs