Hide
Meet people who work on similar things as you – get help if you need it Join Siafoo Now or Learn More

FTLK Transfer Function Atom Feed 0

In Brief A transfer function widget that allows you to map a value range to RGBA colors. It is useful for data visualization applications, especially volume rendering. I wrote this code for a volume data visualization class... in a couple of days so the code quality is fairly low. I no longer use FLTK so it is unlikely that I'll further improve this thing, so you are encouraged to edit and improve the code, here. There is also a wxPython version... more

A transfer function widget that allows you to map a value range to RGBA colors. It is useful for data visualization applications, especially volume rendering. I wrote this code for a volume data visualization class... in a couple of days so the code quality is fairly low. I no longer use FLTK so it is unlikely that I'll further improve this thing, so you are encouraged to edit and improve the code, here. There is also a wxPython version

If you happen to use the widget for something cool, send me a screenshot.

http://www.siafoo.net/image/125

The simplest application that uses this transfer function is:

# 's
 1#include "transfer_graph.hpp"
2#include <iostream>
3#include <FL/Fl.H>
4#include <FL/Fl_Double_Window.H>
5
6using namespace std;
7
8// Transfer function callback
9static void cb_colorChange(TransferGraph* o, void*)
10{
11 unsigned char rgba[4] = {0, 0, 0, 0};
12
13 o->getRGBFromValue(3.0f, rgba);
14
15 cout<<"Colors for Value 3.0f\t";
16
17 for(int i; i < 3; ++i)
18 cout<<(int)rgba[i]<<'\t';
19
20 cout<<endl;
21}
22
23int main(int argc, char **argv)
24{
25 Fl_Double_Window* w = new Fl_Double_Window(300, 200, "Transfer Function Test");
26
27 TransferGraph *tg = new TransferGraph(10, 10, 281, 143, "Transfer Function");
28 tg->callback((Fl_Callback*)cb_colorChange);
29 tg->when(FL_WHEN_CHANGED);
30
31 float range[2] = {0, 255.0};
32 tg->setValueRange(range);
33
34 w->end();
35
36 w->show(argc, argv);
37 return Fl::run();
38}

Compile with g++ tfunction.cpp -lfltk -o tfunction