The Dataflow library contains an example GUI editor for dataflow networks. The editor is built on top of Dataflow.Blueprint, it can be used for any framework with Dataflow support. The capabilities of the editor are fairly limited at the moment - it's purpose is mainly to verify that something useful can be built on top of Dataflow.Blueprint layer.

The following is a screenshot of an older version of the editor:

blueprint_screenshot

You can find videos of a new version of the editor on blip.tv

It currently has the following capabilities:

  • there is a component bank with hardcoded (but easily extensible) components
  • you can click on a component to add it to the blueprint
  • you can drag the components around
  • you can connect ports that are Connectable
  • you can invoke components that are Invocable
  • a few of the components have a GUI element which can be interacted with

The new version of the GUI examples uses the glv library, which is included with dataflow. You can find the gui examples in the example/glv_gui directory.

At some point I will probably develop another version for the cppgui library being developed.

The main part of the code of one of the examples is as follows:

// Copyright 2007 Stjepan Rajko.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <glv.h>
#include <glv_pimpl_binding.h>

#include "blueprint_bank.hpp"
#include "blueprint_window.hpp"

#include <boost/dataflow/signals/component/function.hpp>
#include <boost/dataflow/signals/component/storage.hpp>
#include <boost/dataflow/signals/runtime_support.hpp>
#include <boost/dataflow/blueprint/component_bank.hpp>

namespace blueprint=boost::dataflow::blueprint;
namespace signals=boost::signals;
namespace df=boost::dataflow;

// A regular Dataflow.Signals component, sends and receives void(float)
class output_valuator : public signals::filter<output_valuator, void(float), boost::mpl::vector<void(float)> >, public glv::Slider
{
public:
    typedef glv::View runtime_base_class_type;
    output_valuator()
        : glv::Slider(glv::Rect(100,100))
    {
        anchor(glv::Place::CL);
    }
    void operator()(float x)
    {
        value(x);
        out(x);
    }
};

// A regular Dataflow.Signals component, receives void(float)
class input_valuator : public boost::signals::filter<input_valuator, void(float)>, public glv::Slider
{
public:
    typedef glv::View runtime_base_class_type;
    input_valuator()
        : glv::Slider(glv::Rect(100,100))
    {
        anchor(glv::Place::CL);
    }
public:
    bool onEvent(glv::Event::t e, glv::GLV& glv)
    {
        bool response = glv::Slider::onEvent(e, glv);
        out(value());
        return response;
    }
};

// A component_bank with some components
class example_bank : public blueprint::tag_component_bank<df::signals::tag>
{
public:
    example_bank()
    {
        // A storage initialized with a value of 0.5
        add_component<signals::storage<void(float)> >("sto", 0.5);
        // Output and input components
        add_component<output_valuator>("out");
        add_component<input_valuator>("in");
#ifndef BOOST_MSVC
        // a doubler (this doesn't compile on MSVC...)
        add_component<signals::function<void (float), float(float)> >
            ("x2", boost::function<float(float)>(boost::bind(std::multiplies<float>(), _1, 2)));
#endif
    }
};

int main()
{
    glv::GLV top;
	glv::Window win(640, 640, "GLV Blueprint GUI", &top);
    glv::Placer placer(top, glv::Direction::E, glv::Place::TL, 0, 0, 0);
    
    using namespace boost::dataflow::glv_gui;

    // create the blueprint and component windows
    blueprint_bank bank;
    blueprint_window window;

    // initialize the bank
    bank.set_bank(example_bank());
    bank.set_blueprint(window);
    
    placer << bank.view() << window;
    glv::Application::run();
}