fatiando/fatiando — pull request #143 by leouieda (2014-11-20 14:30:12+00:00)
Title: Rewrote the Moulder class for interactive 2D gravity modeling

The `fatiando.gui.simple.Moulder` class created an interactive matplotlib window for drawing polygons and calculating their gravitational effect (using `fatiando.gravmag.talwani`). The functionality was very limited: could not edit polygons after they were drawn, orresume the app once the window was closed, or save the app state for loading later, etc.

I have rewritten the `Moulder` class to allow all of this. You can now:
* Move the polygon and its vertices
* Change the density
* Delete polygons and vertices
* Save the app state to a pickle file (`Moulder.save`)
* Save the predicted data to a text (XYZ) file (`Moulder.save_predicted`)
* Create a new instance of `Moulder` from the pickled state (`Moulder.load`)
* Insert a plot of the data and model into the IPython notebook (`Moulder.plot)

You can see this class in action in the 5th practical class of Geofísica 1: [pratica5.ipynb](http://nbviewer.ipython.org/github/leouieda/geofisica1/blob/master/notebooks/pratica5.ipynb). You'll to have this branch active on your local clone to run the notebook.

Here is a screenshot of the GUI window.

![figure 1_001](https://cloud.githubusercontent.com/assets/290082/5125841/497f42ee-70af-11e4-933a-99ea357e9d73.png)

## Problems and discussion

The new code breaks the `BasinTri` and `BasinTrap` classes that relied on the old `Moulder`.

I'm inclined to **delete these classes** (and the `Lasagne` class as well) because they can be easily replaced (and improved) by IPython widgets.

This raises the question: **Should we even keep the `fatiando.gui` package?** It is a tiny and virtually unused package. Things in it could easily be moved to other packages (`Moulder` could go into a `fatiando.gravmag`).

I think a better package structure would be to have `interactive` modules in the method packages (e.g., `gravmag.interactive`) where the GUIs and widgets could live.

I'd like some input on this, please, @birocoles, @eusoubrasileiro, @hbueno.

## TODO

- [ ] There is a problem when resizing the window and then calling plot.
Polygons get left out of the scene. Maybe make a "window close" callback that
removes the `animate` flags and redraws the scene?

## Checklist

- [ ] Make tests for new code
- [ ] Create/update docstrings
- [ ] Code follows PEP8 style conventions
- [ ] Code and docs have been spell-checked
- [ ] Changelog entry
- [ ] Documentation builds properly
- [ ] All tests pass
- [ ] Can be merged