eXperiment robotics framework

Because ERF is a component system the widgets must be reusable in the most applications possible.

The simplest way to make this achievable to not clutter a GUI and implement it very simple is by using the Tree widget that is very common in directory browsing tasks.

Here is an example of a simple widget in the Item Browser. The code to add to the header:

struct GroundPlugin: public Plugin, public AuthorInfo {
    ...
    bool euclieanGrid; // the variable
    std::auto_ptr<fltk::ItemGroup> itemGroup; // the group where the variable is
    fltk::CheckButton * checkButton_euclieanGrid; // a button of the variable state
    ...
}

The code to add to the implementation:

// this is the code that is executed when the item is clicked
void callback_switch_boolean(fltk::Widget * w, void * arguments) {
    bool * bool_value = static_cast<bool*>(arguments);
    CheckButton * b = dynamic_cast<CheckButton*>(w);
    if (b) {
        b->value(b->value() ^ 1);
        *bool_value = b->value();
    };
}

// this is the case of a serializable class. If not serializable add this in the class constructor.
void Plugin::load(XE* xe_in){
    euclieanGrid = getBool(xe_in,"drawEuclideanGrid",1);
}

// this gets called after the load() and before the run()
void Plugin::init(){

    itemGroup = std::auto_ptr<fltk::ItemGroup>(MItems.addGroup("Ground",0));

    MItems.setCurrentGroup(itemGroup.get());

    checkButton_euclieanGrid = new CheckButton(0,0,100,23,"euclidean grid ?");
    checkButton_euclieanGrid->value(euclieanGrid);
    checkButton_euclieanGrid->callback(callback_switch_boolean, &euclieanGrid);

    itemGroup->add(this->checkButton_euclieanGrid);

    MItems.setCurrentGroup(tmpGrp);
}

The miarn project - written by Joao Xavier