diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2014-08-20 10:34:08 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2014-08-20 10:34:08 -0700 |
commit | 9e9699b4c1e76d6d699d7c199775f3d8e134d5e5 (patch) | |
tree | 4989c9dc49800642ae57ed72c9670ad72c79c843 /grc/gui/Utils.py | |
parent | 84ce73af3dca41b8acec6d59fca65901e1fe0045 (diff) | |
parent | 00709699b217bc6b6b866ffad6d9a8c1e9497ae8 (diff) |
Merge remote-tracking branch 'gnuradio-wg-grc/grc_snap_blocks_to_grid'
Diffstat (limited to 'grc/gui/Utils.py')
-rw-r--r-- | grc/gui/Utils.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index ebd5aefca7..9a0a59cda7 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -from Constants import POSSIBLE_ROTATIONS +from Constants import POSSIBLE_ROTATIONS, CANVAS_GRID_SIZE from Cheetah.Template import Template import pygtk pygtk.require('2.0') @@ -108,3 +108,11 @@ def parse_template(tmpl_str, **kwargs): # print tmpl_str # print str(kwargs['param'].get_error_messages()) return str(Template(tmpl_str, kwargs)) + +def align_to_grid(coor): + _align = lambda: int(round(x / (1.0 * CANVAS_GRID_SIZE)) * CANVAS_GRID_SIZE) + try: + return [_align() for x in coor] + except TypeError: + x = coor + return _align()
\ No newline at end of file |