In 2011, I wrote a curve editor with Qt for our MMORPG project. Unfortunately, something happened and this program was not been used finally. Last week, a colleague said he didn’t find a Qt widget for curve editing. So I opensource mine on Github.
The spline library I used is from http://people.sc.fsu.edu/~jburkardt/c_src/spline/spline.html. In 2007, I used it to resample wiimote’s accelerometer’s data for hmm to recognize hand gestures, the recognition accuracy could be 95%. In the editor, I implemented the Cubic Spline editing. You could implement more type of curves as you need.
The curve editing widget is a Qt OpenGL widget. In it you can add / delete control points by right-clicking mouse, drag a control point to edit the curve, scale the viewport with mousewheel.
Compile the Demo
I use cmake as the build system for all my cross-platform projects, so does this curve editor. It can generate most compiler IDE project files and help you to config it. For Qt projects, you don’t need to care about configing moc, qmake.
As Qt and cmake installed, go to the project’s folder in Terminal, and use the following commands:
mkdir build cd build cmake -G Xcode ..
The commands generate Xcode project file. Then you could open, compile and run it. All the things about project setting have been done by cmake.
By the way, the folder “build” is not required, but it could help you to separate your code, config and other files that you want to track with revision control tools from the generated files by cmake.
If you use Visual Studio on Windows, like VS 2010, the last command could be:
cmake -G "Visual Studio 10" ..
For other compiler, please read cmake’s document about generators.