Patch to snap new objects to grid

  • From: Andre Majorel <amajorel@xxxxxxxxx>
  • To: yadex@xxxxxxxxxxxxx
  • Date: Wed, 2 Jul 2008 12:40:20 +0200

Newly created objects (rectangles and polygons) used to be centred
around the pointer coordinates. With this patch, they are centred
around the closest grid centre.

This means that, in most cases, the new vertices will be aligned
without you having to do anything.

When the snap-to-grid flag is off, new objects are centred around
the unrounded pointer coordinates as before.

This patch is against 1.7.902+ but should apply to 1.7.0. Let me
now if it doesn't.

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>
yadex-1.7-new-object-snap.diff

Newly created objects (rectangles and polygons) used to be centred
around the pointer coordinates. With this patch, they are centred around
the closest grid centre.

This means that, in most cases, the new vertices will be aligned without
you having to do anything.

When the snap-to-grid flag is off, new objects are centred around the
unrounded pointer coordinates as before.

This patch is against 1.7.902+ but should apply to 1.7.0.

 -- AYM 2008-07-02


--- src/editloop-2006-12-08.cc  2006-12-08 15:33:47.000000000 +0100
+++ src/editloop.cc     2008-07-02 10:43:55.000000000 +0200
@@ -608,7 +608,8 @@
             {
            /* code duplicated from 'F9' - I hate to do that */
            int savednum = NumLineDefs;
-           InsertStandardObject (e.pointer_x, e.pointer_y, r + 1);
+           InsertStandardObject (edit_mapx_snapped (&e, e.pointer_x),
+                                 edit_mapy_snapped (&e, e.pointer_y), r + 1);
            if (NumLineDefs > savednum)
               {
               ForgetSelection (&e.Selected);
@@ -723,7 +724,8 @@
         {
          e.modpopup->unset ();
         int savednum = NumLineDefs;
-        InsertStandardObject (e.pointer_x, e.pointer_y, r + 1);
+        InsertStandardObject (edit_mapx_snapped (&e, e.pointer_x),
+                              edit_mapy_snapped (&e, e.pointer_y), r + 1);
         if (NumLineDefs > savednum)
            {
            ForgetSelection (&e.Selected);

Other related posts:

  • » Patch to snap new objects to grid