A Gtk+ 2D Point Viewer

Ok, yet another widget. One of our cameras has an adjustable ADC gain that is approximated by a piecewise linear function – that is, points connected with lines. Because, I am the poor soul who should come up with a GUI to control this camera, I decided to visualize this in an intuitive way rather than falling back to boring spin buttons.

I remembered GIMP’s curve tool which is exactly what I had in mind, although the widget’s purpose is a bit different. Therefore, I pulled out the useful bits and mashed it together in the EggPiecewiseLinearView widget (yeah, what a name …).

At first, the view managed the data but I noticed soon, that this won’t scale very well. I refactored the data point management into its own EggDataPoints class just to recognize that this is also not exactly following the MVC pattern, because in the perfect MVC world the model (in my case the data points) would not control themselves. However, the Gtk people don’t seem to be active proponents of the MVC pattern either: The GtkAdjustment and GtkSpinButton relationship is pretty similar to EggDataPoints and EggPiecewiseLinearView. So, after a short discussion with a friend, I though to myself: “Ok, it’s not worth it, adding another layer”.

Using the widget and the data store is self-explanatory and somewhat documented by the test program.