GNOME Bugzilla – Bug 151092
GFig's Polar Grid: Independent Sector Spacing Control
Last modified: 2006-06-15 00:04:55 UTC
Trivial Request: The user should be able to change the sector spacing (select N sectors) without changing the track spacing (select N pixels thickness per track) I tried to produce an illustration with 128 segments around a circle, and GFIG was unable to do it. Optional Generalization: I imagine there are other tweaks one might want to do to grid spacing as well. (rotation, origin shifting, log scale, separate scale per axis, etc.) Optional Challenge: Another possible enhancement would be to make the radial grid have more sectors on outer tracks than inner tracks. (Using 3 as an approximation for pi, to maintain approximately equal sector spacing at various radii, split the sector in half every time the radius triples. So you might have 4 sectors in track 0, 8 sectors in tracks 1&2, 16 sectors in tracks 3-6, 32 in 7-14, 64 in 15-30, 128 in 31-62, etc. Changing the sector scale would simply split up these sectors (instead of 4, you could have up to about 32 in track zero, or down to 1 sector) This might be an option (checkbox) somewhere for more uniform sector spacing at varying radii. There are other possible grids, but I think these cover the most useful ones. (If I were drawing nautili, I might ask for a spiral grid:) @
A patch (against CVS HEAD!) would very much increase the likelihood of this ever going to be implemented.
Hmm. CVS head contains my majorly hacked version of gfig, which might or might not be in a usable state by the time 2.2 is released. (I've been putting most of my efforts into writing help docs recently.) However, I really haven't touched the grid code at all, so a patch to that code in the 2.0.4 version could easily be forward-ported to the version in cvs, and might turn out to be more useful than a patch to the cvs version.
Created attachment 34616 [details] [review] First attempt to make a Shaneyfelt-style polar-grid This patch implements a polar grid with reduced congestion near its center. Parameters in the selvals.opts struct control various aspects of the grid, including: * arbitrary track spacing (default 10) * arbitrary track spacing offset (default 0) * arbitrary maximum number of sectors (default 120) * arbitrary minimum spacing per sector (default 5) * arbitrary rotation (default 0) I didn't add gui control of the struct, as it seems the gui is in flux at the moment. Also, there's some roundoff error that affects the display by one pixel in places that should be fixed as time permits.
Now would be a good time to add this patch to CVS. I haven't tried the patch myself. Is the patch good enough and will it apply cleanly or do you think it needs further work?
The patch should be fine if someone cares to make the user interface control the data structure. (It will still work without GUI but you won't be able to change spacing/etc.) Also, I wrote some trivial code but haven't posted another patch to take care of roundoff because my build environment is broken and I don't have time to deal with it at the moment. The patch is simple, so anybody could do it: Wherever a float is used as an int, round first. (I tried a mock-up on Java and it works fine, so I expect everything will be fine with the C plugin) Sorry I haven't time to handle the remaining items, please feel free as I've got too much happening at the moment (visitors, conference, prepare new classes (I wanted to install GIMP 2.2 with the latest patches on Windows to fix gfig, but no time to build that either. I'd be thankful if that were built by someone this weekend) _-T
Comment on attachment 34616 [details] [review] First attempt to make a Shaneyfelt-style polar-grid The grid spacing should probably use the existing grid settings from GimpConfig.
It would be nice to have polar and isomorphic support throughout GIMP, supported by GimpConfig settings. However, the settings designed for rectangular grids won't do for all grid types.
Created attachment 48886 [details] [review] Complete patch against /gimp-2.2.7/plug-ins/gfig for Shaneyfelt-style polar grid. Complete patch against /gimp-2.2.7/plug-ins/gfig The user interface controls desired number of sectors and desired radius interval. It could easily be extended to control a few other parameters, just by adjusting these variables: grid_radius_min (shift outward all tracks) grid_rotation (shift counterclockwise all sectors) grid_granularity (control minimum sector size limit)
Comment on attachment 48886 [details] [review] Complete patch against /gimp-2.2.7/plug-ins/gfig for Shaneyfelt-style polar grid. Fixed.
Sven asked for a diff against CVS head in comment #1, it would be nice if you could provide one.
The patch against 2.2 will most probably apply cleanly against CVS HEAD.
I've tried this patch and it applies inded. The result looks nice, too. But there are two things that bother me: The center is only marked by one line now. This is a bit awkward, IMO it shoul be either three lines (the closest to 0, 120 and 240 degrees?) or four (0, 90, 180 and 270 respectively). Until I tried the patch, I thought that this was just something that changed the diaply of the grid (e.g. removes lines to make the display less crowded). But it removes the snap points as well - will this be controllable by the other parameters that aren't in the gui yet?
Three lines wouldn't scale as well. For example, you might want to divide the circle into 64 sectors (something I wanted to do for an illustration that inspired this enhancement. After experimentation, it seems to work best and most efficiently as submitted. Changes to it might be added as a separate enhancement request. I can think of endless other possible enhancements, as well. For efficiency of all grids, someone might consider drawing the grid once on a separate layer and not calculating again after that. For generality, one might consider generating arbitrary grid types from path intersections and voroni regions, but that would take some work and I don't know how efficient it would be. For better organization, one might consider to only show the options for the current type of grid. (e.g. rect grids could have different horizontal and vertical spacing, some offset of alignment relative to top, left, right, or center, arbitrary rotation, etc. and the same could go for iso, etc.) and the list goes on... To answer your question about control of snap points, You can control how tightly the grids can get together if you add a gui control the value of grid_granularity (minimum spacing per sector). Making gridlines and snap points different from one another would be confusing. I have tested the algorithm with various parameters (grid_granularity, grid_radius_min, grid_rotation) Just add GUI if you like them. That should solve the problem if you need tighter snap points. But it is how it is now to keep the user interface simple. If people have a need for the other features after using this, the groundwork is laid for many enhancements. After testing, I'm satisfied with the implementation as it is in the patch. _-T
Looks good to me (from a quick glimpse), why not just commit it? We can improve things later if there's a need to do so.
2005-07-13 Michael Schumacher <schumaml@cvs.gnome.org> * plug-ins/gfig/gfig-dialog.c * plug-ins/gfig/gfig-grid.c * plug-ins/gfig/gfig.h: applied a patch by Ted Shaneyfelt that addresses parts of bug 151092: less sectors on inner, more sectors on outer tracks.
How should we proceed with this? We have multiple additional enhancements in here... I'm going to remove the PATCH keyword, as I've applied it already. IMO the best way would be to make the new polar grid behaviour know on the mailing lists and ask direct people to this report if they want to make additions or changes.
The original request that I wrote has been completely satisfied: "Trivial Request: The user should be able to change the sector spacing (select N sectors) without changing the track spacing (select N pixels thickness per track) I tried to produce an illustration with 128 segments around a circle, and GFIG was unable to do it." It would be appropriate to close this and add the additional "Optional Challenges" and other items that were brought up later as separate enhancements, if desired. Most (if not all) of the remaining items could be applied to rectangular and isomorphic grids as well.
2005-07-20 Sven Neumann <sven@gimp.org> * plug-ins/gfig/gfig-grid.c: declare variables at the start of the scope. Apply GIMP coding style to the new polar grid code. Next time you submit a patch, please try to avoid such C99isms and adhere to the GIMP coding style. Thank you. Closing this bug as FIXED now. Feel free to open a new one for remaining issues.
The target milestone still shows 2.0, will it be moved to 2.4 now?
Oops - my mistake. I was reading version instead of target milestone. Sorry. Ignore.