Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2008-07-12 18:15:37


Author: srajko
Date: 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
New Revision: 47367
URL: http://svn.boost.org/trac/boost/changeset/47367

Log:
glv gui for dataflow.signals and dataflow.managed initial commit
Added:
   sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp (contents, props changed)
   sandbox/SOC/2007/signals/boost/dataflow/managed/runtime_support.hpp (contents, props changed)
   sandbox/SOC/2007/signals/boost/dataflow/managed/support.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/COPYRIGHT (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_abstract_binding.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_behavior.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_carbon.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_fltk.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_glut.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_color.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_conf.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_core.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_draw.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_layout.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_observer_pattern.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_rect.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_sliders.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_texture.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_textview.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_util.h (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp | 16 ++++
   sandbox/SOC/2007/signals/boost/dataflow/managed/component.hpp | 3
   sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp | 18 +++++
   sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp | 36 +++++++++++
   sandbox/SOC/2007/signals/boost/dataflow/support/runtime.hpp | 13 ++++
   sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj | 116 ++++++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 | 1
   sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/Jamfile.v2 | 3
   sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/Jamfile.v2 | 2
   sandbox/SOC/2007/signals/libs/dataflow/test/managed/Jamfile | 4 +
   10 files changed, 203 insertions(+), 9 deletions(-)

Modified: sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/blueprint/component.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -26,11 +26,18 @@
     virtual bool is_invocable()=0;
     virtual size_t num_ports() const=0;
     virtual port & get_port(int port_num)=0;
-
+
     virtual std::auto_ptr<component> copy() const=0;
     virtual ~component() {};
 };
 
+template<typename Base>
+class based_component : public component
+{
+public:
+ virtual Base *get_pointer()=0;
+};
+
 namespace detail
 {
     template<typename T, typename Tag, typename Enable=void>
@@ -57,12 +64,15 @@
 }
 
 template<typename Component, typename Tag=default_tag>
-class component_t : public component
+class component_t : public based_component<typename runtime_base_class<Component>::type>
 {
+ typedef typename runtime_base_class<Component>::type runtime_base_class_type;
 public:
     component_t() {component_t_();}
     template<typename T0>
     component_t(const T0 &t0) : c(t0) {component_t_();}
+ template<typename T0>
+ component_t(T0 &t0) : c(t0) {component_t_();}
     component_t(const component_t &rhs) : c(rhs.c)
     { component_t_(); }
     
@@ -87,6 +97,8 @@
         return std::auto_ptr<component>(new component_t<Component, Tag>(*this));
     }
     Component &get() {return c;}
+ virtual runtime_base_class_type *get_pointer()
+ { return static_cast<runtime_base_class_type *>(&c); };
 private:
     void component_t_()
     {

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/component.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/component.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/component.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -13,8 +13,7 @@
 class component
 {
 public:
- component(network &network_context) : m_network_context(network_context), m_topological_sort_index(0)
- {};
+ component(network &network_context);
     virtual ~component(){}
     network &network_context()
     { return m_network_context; }

Added: sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/fusion_component.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,57 @@
+// Copyright 2008 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)
+
+#ifndef BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
+#define BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
+
+#include <boost/dataflow/support/fusion_component.hpp>
+#include <boost/dataflow/managed/port.hpp>
+#include <boost/dataflow/managed/component.hpp>
+#include <boost/mpl/map.hpp>
+
+namespace boost { namespace dataflow { namespace managed {
+
+template<typename InOutType>
+struct component_traits
+ : public dataflow::fusion_component_traits<
+ fusion::vector<
+ managed::port<InOutType, ports::consumer> &,
+ managed::port<InOutType, ports::producer> &
+ >,
+ mpl::map< >,
+ managed::tag>
+{
+ template<typename Component>
+ static typename component_traits::fusion_ports get_ports(Component &component)
+ {
+ return typename component_traits::fusion_ports(
+ component.consumer_port(),
+ component.producer_port());
+ };
+};
+
+template<typename InOutType>
+class fusion_component : public component
+{
+public:
+ typedef component_traits<InOutType> dataflow_traits;
+
+ fusion_component(network &n)
+ : component(n)
+ , m_consumer_port(*this)
+ , m_producer_port(*this)
+ {}
+ port<InOutType, ports::consumer> &consumer_port()
+ { return m_consumer_port; }
+ port<InOutType, ports::producer> &producer_port()
+ { return m_producer_port; }
+protected:
+ port<InOutType, ports::consumer> m_consumer_port;
+ port<InOutType, ports::producer> m_producer_port;
+};
+
+} } }
+
+#endif // BOOST_DATAFLOW_MANAGED_FUSION_COMPONENT_HPP
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/network.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -10,6 +10,7 @@
 #include <set>
 
 #include <boost/dataflow/managed/component.hpp>
+#include <boost/graph/adjacency_list.hpp>
 
 namespace boost { namespace dataflow { namespace managed {
 
@@ -26,7 +27,20 @@
 
 class network
 {
+ struct node_t
+ {
+ component *ptr;
+ };
+ typedef boost::adjacency_list<
+ boost::vecS, boost::vecS, boost::bidirectionalS, node_t> graph_type;
+
 public:
+ void register_component(component *c)
+ {
+ graph_type::vertex_descriptor v = add_vertex(m_graph);
+ m_graph[v].ptr = c;
+ m_descriptor_map[c]=v;
+ }
     void notify_change(component &changed)
     {
         m_changed.insert(&changed);
@@ -55,10 +69,12 @@
         }
     }
 private:
+ graph_type m_graph;
+ std::map<component *, graph_type::vertex_descriptor> m_descriptor_map;
     changed_type m_changed;
 };
 
-void notify_change(component &c)
+inline void notify_change(component &c)
 {
     c.network_context().notify_change(c);
 }

Modified: sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/port.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -6,8 +6,10 @@
 #ifndef BOOST_DATAFLOW_MANAGED_PORT_HPP
 #define BOOST_DATAFLOW_MANAGED_PORT_HPP
 
+#include <boost/dataflow/support/binary_operation.hpp>
+#include <boost/dataflow/support/complemented_port.hpp>
 #include <boost/dataflow/managed/component.hpp>
-#include <boost/dataflow/support/tags.hpp>
+#include <boost/dataflow/managed/support.hpp>
 #include <set>
 #include <stdexcept>
 
@@ -46,9 +48,16 @@
 }
 
 template<typename T>
+struct producer_port_traits
+ : public dataflow::complemented_port_traits<ports::producer, port<T, ports::consumer>, tag>
+{};
+
+template<typename T>
 class port<T, ports::producer> : public port_base
 {
 public:
+ typedef producer_port_traits<T> dataflow_traits;
+
     port(component &component_context) : port_base(component_context)
     {
     };
@@ -70,9 +79,15 @@
 };
 
 template<typename T>
+struct consumer_port_traits
+ : public dataflow::complemented_port_traits<ports::consumer, port<T, ports::producer>, tag>
+{};
+
+template<typename T>
 class port<T, ports::consumer> : public port_base
 {
 public:
+ typedef consumer_port_traits<T> dataflow_traits;
     port(component &component_context)
         : port_base(component_context), m_producer(0)
     {
@@ -94,6 +109,23 @@
     friend void disconnect<T>(port<T, ports::producer> &producer, port<T, ports::consumer> &consumer);
 };
 
-} } }
+} // namespace managed
+
+namespace extension {
+
+ template<typename T>
+ struct binary_operation_impl<managed::producer_port_traits<T>, managed::consumer_port_traits<T>, operations::connect>
+ {
+ typedef void result_type;
+
+ template<typename Producer, typename Consumer>
+ result_type operator()(Producer &producer, Consumer &consumer)
+ {
+ managed::connect(producer, consumer);
+ }
+ };
+}
+
+} }
 
 #endif // BOOST_DATAFLOW_MANAGED_PORT_HPP
\ No newline at end of file

Added: sandbox/SOC/2007/signals/boost/dataflow/managed/runtime_support.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/runtime_support.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,15 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to 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)
+
+#ifndef DATAFLOW_MANAGED_RUNTIME_SUPPORT_HPP
+#define DATAFLOW_MANAGED_RUNTIME_SUPPORT_HPP
+
+#include <boost/dataflow/support/runtime.hpp>
+#include <boost/dataflow/managed/support.hpp>
+
+DATAFLOW_RUNTIME_PROPERTY(managed::tag, const char *, "Dataflow.Managed")
+DATAFLOW_RUNTIME_PROPERTY(managed::tag, int, 20)
+
+#endif // DATAFLOW_MANAGED_RUNTIME_SUPPORT_HPP

Added: sandbox/SOC/2007/signals/boost/dataflow/managed/support.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/managed/support.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,17 @@
+// Copyright 2008 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)
+
+#ifndef BOOST_DATAFLOW_MANAGED_SUPPORT_HPP
+#define BOOST_DATAFLOW_MANAGED_SUPPORT_HPP
+
+#include <boost/dataflow/support/tags.hpp>
+
+namespace boost { namespace dataflow { namespace managed {
+
+struct tag : public default_tag {};
+
+} } }
+
+#endif // BOOST_DATAFLOW_MANAGED_SUPPORT_HPP
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/boost/dataflow/support/runtime.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/runtime.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/runtime.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -7,6 +7,7 @@
 #define DATAFLOW_RUNTIME_HPP
 
 #include <boost/dataflow/support/tags.hpp>
+#include <boost/dataflow/utility/enable_if_type.hpp>
 
 #include <string>
 
@@ -18,6 +19,18 @@
     struct property;
 } // namespace runtime
 
+template<typename T, typename Enable=void>
+struct runtime_base_class
+{
+ typedef void type;
+};
+
+template<typename T>
+struct runtime_base_class<T, typename utility::enable_if_type<typename T::runtime_base_class_type>::type>
+{
+ typedef typename T::runtime_base_class_type type;
+};
+
 class runtime_info
 {
 public:

Modified: sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/dataflow.xcodeproj/project.pbxproj 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -122,6 +122,8 @@
                 089321B50D7BB26100F16965 /* examples.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = examples.qbk; sourceTree = "<group>"; };
                 089321B60D7BB28000F16965 /* examples.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = examples.qbk; sourceTree = "<group>"; };
                 089321BB0D7BB38D00F16965 /* examples.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = examples.qbk; sourceTree = "<group>"; };
+ 0896A06B0E16CE380094DF6D /* fusion_component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = fusion_component.hpp; sourceTree = "<group>"; };
+ 0896A0700E16D11D0094DF6D /* test_fusion_component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_fusion_component.cpp; sourceTree = "<group>"; };
                 08998BA10D8B2094006ED577 /* specific_tracking_consumer_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = specific_tracking_consumer_example.cpp; sourceTree = "<group>"; };
                 089AE57F0D79C5CF00AB9DA8 /* bind_mem_fn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bind_mem_fn.hpp; sourceTree = "<group>"; };
                 089AE5830D79C7CB00AB9DA8 /* bind_object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bind_object.hpp; sourceTree = "<group>"; };
@@ -148,7 +150,37 @@
                 08A0B43D0D21EDDE0054AD32 /* blueprint_component.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = blueprint_component.hpp; sourceTree = "<group>"; };
                 08A0B5710D220CCF0054AD32 /* introduction.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = introduction.qbk; sourceTree = "<group>"; };
                 08A0E54C0D7A7674009B11DD /* quick_start_examples.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = quick_start_examples.cpp; sourceTree = "<group>"; };
+ 08A15D250E290EA0005AE94D /* support.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = support.hpp; sourceTree = "<group>"; };
+ 08A15D2B0E29108B005AE94D /* runtime_support.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = runtime_support.hpp; sourceTree = "<group>"; };
+ 08A15D6F0E2914C3005AE94D /* test_managed_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_managed_port.cpp; sourceTree = "<group>"; };
                 08A364C10E129DC7001E6002 /* test_dynamic_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_dynamic_port.cpp; sourceTree = "<group>"; };
+ 08A438900E295AE7009845FD /* component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = component.cpp; sourceTree = "<group>"; };
+ 08A439B80E295B8B009845FD /* Jamfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.jam; path = Jamfile; sourceTree = "<group>"; };
+ 08A6B2650E25A566005539F2 /* blueprint_bank.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blueprint_bank.cpp; sourceTree = "<group>"; };
+ 08A6B2660E25A566005539F2 /* blueprint_bank.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = blueprint_bank.hpp; sourceTree = "<group>"; };
+ 08A6B2670E25A566005539F2 /* blueprint_component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blueprint_component.cpp; sourceTree = "<group>"; };
+ 08A6B2680E25A566005539F2 /* blueprint_component.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = blueprint_component.hpp; sourceTree = "<group>"; };
+ 08A6B2690E25A566005539F2 /* blueprint_window.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blueprint_window.cpp; sourceTree = "<group>"; };
+ 08A6B26A0E25A566005539F2 /* blueprint_window.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = blueprint_window.hpp; sourceTree = "<group>"; };
+ 08A6B26B0E25A566005539F2 /* glvgui_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glvgui_example.cpp; sourceTree = "<group>"; };
+ 08A6B26C0E25A566005539F2 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
+ 08A6B2990E25A6A5005539F2 /* glv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv.h; sourceTree = "<group>"; };
+ 08A6B29A0E25A6A5005539F2 /* glv_abstract_binding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_abstract_binding.h; sourceTree = "<group>"; };
+ 08A6B29B0E25A6A5005539F2 /* glv_behavior.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_behavior.h; sourceTree = "<group>"; };
+ 08A6B29C0E25A6A5005539F2 /* glv_binding_carbon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_binding_carbon.h; sourceTree = "<group>"; };
+ 08A6B29D0E25A6A5005539F2 /* glv_binding_fltk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_binding_fltk.h; sourceTree = "<group>"; };
+ 08A6B29E0E25A6A5005539F2 /* glv_binding_glut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_binding_glut.h; sourceTree = "<group>"; };
+ 08A6B29F0E25A6A5005539F2 /* glv_color.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_color.h; sourceTree = "<group>"; };
+ 08A6B2A00E25A6A5005539F2 /* glv_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_conf.h; sourceTree = "<group>"; };
+ 08A6B2A10E25A6A5005539F2 /* glv_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_core.h; sourceTree = "<group>"; };
+ 08A6B2A20E25A6A5005539F2 /* glv_draw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_draw.h; sourceTree = "<group>"; };
+ 08A6B2A30E25A6A5005539F2 /* glv_layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_layout.h; sourceTree = "<group>"; };
+ 08A6B2A40E25A6A5005539F2 /* glv_observer_pattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_observer_pattern.h; sourceTree = "<group>"; };
+ 08A6B2A50E25A6A5005539F2 /* glv_rect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_rect.h; sourceTree = "<group>"; };
+ 08A6B2A60E25A6A5005539F2 /* glv_sliders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_sliders.h; sourceTree = "<group>"; };
+ 08A6B2A70E25A6A5005539F2 /* glv_texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_texture.h; sourceTree = "<group>"; };
+ 08A6B2A80E25A6A5005539F2 /* glv_textview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_textview.h; sourceTree = "<group>"; };
+ 08A6B2A90E25A6A5005539F2 /* glv_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glv_util.h; sourceTree = "<group>"; };
                 08A82B550E11EBF500AAB117 /* dynamic_port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dynamic_port.hpp; sourceTree = "<group>"; };
                 08AD8AB50D84DF31008A9764 /* test_has_call_operator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_has_call_operator.cpp; sourceTree = "<group>"; };
                 08AD8AC40D84E3A9008A9764 /* has_call_operator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = has_call_operator.hpp; sourceTree = "<group>"; };
@@ -158,6 +190,7 @@
                 08BD9AFB0CEB9D330069AFE2 /* get_port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = get_port.hpp; sourceTree = "<group>"; };
                 08BD9B090CEB9E3D0069AFE2 /* port.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = port.hpp; sourceTree = "<group>"; };
                 08C3EEA20C625AE30074AB9E /* simple_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simple_example.cpp; sourceTree = "<group>"; };
+ 08C617FB0E27E39500FC4F24 /* glvgui_logic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glvgui_logic.cpp; sourceTree = "<group>"; };
                 08C675970C13A03E00D85379 /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
                 08C8FA0F0E130E9B00FE64F3 /* dynamic_port_t.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dynamic_port_t.hpp; sourceTree = "<group>"; };
                 08C8FA140E13112D00FE64F3 /* test_dynamic_port.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_dynamic_port.cpp; sourceTree = "<group>"; };
@@ -334,10 +367,12 @@
                 080DD7560C13908400EEB53D = {
                         isa = PBXGroup;
                         children = (
+ 08A439340E295B35009845FD /* build */,
                                 0800AC390C8CAAC300994538 /* boost-build.jam */,
                                 0800AC3A0C8CAAC300994538 /* Jamfile.v2 */,
                                 0800AC3B0C8CAAC300994538 /* project-root.jam */,
                                 08FC25BA0C45B60E00F59CDD /* dataflow */,
+ 08A4388E0E295AAB009845FD /* src */,
                                 08FD5DE40C1BA60700F00877 /* doc */,
                                 08668C4D0C19A16300ACB19A /* example */,
                                 08C675960C13A03E00D85379 /* test */,
@@ -355,6 +390,7 @@
                 08668C4D0C19A16300ACB19A /* example */ = {
                         isa = PBXGroup;
                         children = (
+ 08A6B2640E25A566005539F2 /* glv_gui */,
                                 08668C4F0C19A16300ACB19A /* Jamfile.v2 */,
                                 08EBA7590CFF8B6D0080E225 /* example.cpp */,
                                 08FFDD6E0CEB709A009318A8 /* blueprint */,
@@ -414,6 +450,9 @@
                                 089C08A40E0AFA7200397123 /* component.hpp */,
                                 089C08A50E0AFAA500397123 /* port.hpp */,
                                 089C08BB0E0AFDF400397123 /* network.hpp */,
+ 0896A06B0E16CE380094DF6D /* fusion_component.hpp */,
+ 08A15D250E290EA0005AE94D /* support.hpp */,
+ 08A15D2B0E29108B005AE94D /* runtime_support.hpp */,
                         );
                         path = managed;
                         sourceTree = "<group>";
@@ -424,6 +463,7 @@
                                 089C08AC0E0AFB7800397123 /* Jamfile */,
                                 089C08AE0E0AFBB600397123 /* test_port.cpp */,
                                 089C098C0E0B11FF00397123 /* test_network.cpp */,
+ 0896A0700E16D11D0094DF6D /* test_fusion_component.cpp */,
                         );
                         path = managed;
                         sourceTree = "<group>";
@@ -443,6 +483,81 @@
                         path = cppgui_gui;
                         sourceTree = "<group>";
                 };
+ 08A4388E0E295AAB009845FD /* src */ = {
+ isa = PBXGroup;
+ children = (
+ 08A4388F0E295AD6009845FD /* managed */,
+ );
+ name = src;
+ path = ../../src;
+ sourceTree = SOURCE_ROOT;
+ };
+ 08A4388F0E295AD6009845FD /* managed */ = {
+ isa = PBXGroup;
+ children = (
+ 08A438900E295AE7009845FD /* component.cpp */,
+ );
+ path = managed;
+ sourceTree = "<group>";
+ };
+ 08A439340E295B35009845FD /* build */ = {
+ isa = PBXGroup;
+ children = (
+ 08A439B70E295B8B009845FD /* managed */,
+ );
+ name = build;
+ path = ..;
+ sourceTree = SOURCE_ROOT;
+ };
+ 08A439B70E295B8B009845FD /* managed */ = {
+ isa = PBXGroup;
+ children = (
+ 08A439B80E295B8B009845FD /* Jamfile */,
+ );
+ path = managed;
+ sourceTree = "<group>";
+ };
+ 08A6B2640E25A566005539F2 /* glv_gui */ = {
+ isa = PBXGroup;
+ children = (
+ 08C617FB0E27E39500FC4F24 /* glvgui_logic.cpp */,
+ 08A6B2980E25A6A5005539F2 /* glv */,
+ 08A6B2650E25A566005539F2 /* blueprint_bank.cpp */,
+ 08A6B2660E25A566005539F2 /* blueprint_bank.hpp */,
+ 08A6B2670E25A566005539F2 /* blueprint_component.cpp */,
+ 08A6B2680E25A566005539F2 /* blueprint_component.hpp */,
+ 08A6B2690E25A566005539F2 /* blueprint_window.cpp */,
+ 08A6B26A0E25A566005539F2 /* blueprint_window.hpp */,
+ 08A6B26B0E25A566005539F2 /* glvgui_example.cpp */,
+ 08A6B26C0E25A566005539F2 /* Jamfile.v2 */,
+ );
+ path = glv_gui;
+ sourceTree = "<group>";
+ };
+ 08A6B2980E25A6A5005539F2 /* glv */ = {
+ isa = PBXGroup;
+ children = (
+ 08A6B2990E25A6A5005539F2 /* glv.h */,
+ 08A6B29A0E25A6A5005539F2 /* glv_abstract_binding.h */,
+ 08A6B29B0E25A6A5005539F2 /* glv_behavior.h */,
+ 08A6B29C0E25A6A5005539F2 /* glv_binding_carbon.h */,
+ 08A6B29D0E25A6A5005539F2 /* glv_binding_fltk.h */,
+ 08A6B29E0E25A6A5005539F2 /* glv_binding_glut.h */,
+ 08A6B29F0E25A6A5005539F2 /* glv_color.h */,
+ 08A6B2A00E25A6A5005539F2 /* glv_conf.h */,
+ 08A6B2A10E25A6A5005539F2 /* glv_core.h */,
+ 08A6B2A20E25A6A5005539F2 /* glv_draw.h */,
+ 08A6B2A30E25A6A5005539F2 /* glv_layout.h */,
+ 08A6B2A40E25A6A5005539F2 /* glv_observer_pattern.h */,
+ 08A6B2A50E25A6A5005539F2 /* glv_rect.h */,
+ 08A6B2A60E25A6A5005539F2 /* glv_sliders.h */,
+ 08A6B2A70E25A6A5005539F2 /* glv_texture.h */,
+ 08A6B2A80E25A6A5005539F2 /* glv_textview.h */,
+ 08A6B2A90E25A6A5005539F2 /* glv_util.h */,
+ );
+ path = glv;
+ sourceTree = "<group>";
+ };
                 08C675960C13A03E00D85379 /* test */ = {
                         isa = PBXGroup;
                         children = (
@@ -769,6 +884,7 @@
                 08F5FF060D07082200FDBAEE /* blueprint */ = {
                         isa = PBXGroup;
                         children = (
+ 08A15D6F0E2914C3005AE94D /* test_managed_port.cpp */,
                                 08F5FF070D07082200FDBAEE /* Jamfile.v2 */,
                                 08F5FF130D070A1400FDBAEE /* test_port.cpp */,
                                 08F49BFE0D08AD9400D0CF0E /* test_component.cpp */,

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -7,6 +7,7 @@
 build-project signals ;
 build-project blueprint ;
 build-project fltk_gui ;
+build-project glv_gui ;
 #build-project cppgui_gui ;
 
 project dataflow/example

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/fltk_gui/Jamfile.v2 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -11,7 +11,7 @@
 lib shell32 : : <name>shell32 ;
 lib advapi32 : : <name>Advapi32 ;
 
-project dataflow/example/blueprint
+project dataflow/example/fltk_gui
     : requirements
       <include>../../../..
       <library>/boost/signals//boost_signals/<link>static
@@ -26,4 +26,5 @@
       <toolset>msvc:<library>advapi32
     ;
 
+
 exe fltk_gui_example : fltk_gui_example.cpp BlueprintWindow.cpp BlueprintBank.cpp BlueprintComponent.cpp ;

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/Jamfile.v2 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,29 @@
+# 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)
+
+import os ;
+
+lib glv : : <name>glv ;
+
+project dataflow/example/glv_gui
+ : requirements
+ <include>../../../..
+ <include>glv
+ <library>glv
+ <library>/boost/signals//boost_signals/<link>static
+ <define>BOOST_ALL_NO_LIB=1
+ <toolset>darwin:<linkflags>"-framework AGL"
+ <toolset>darwin:<linkflags>"-framework GLUT"
+ <toolset>darwin:<linkflags>"-framework OpenGL"
+ ;
+
+local sources =
+ blueprint_bank
+ blueprint_window
+ blueprint_component
+ ;
+
+exe glv_example : glvgui_example.cpp $(sources).cpp ;
+exe glv_logic : glvgui_logic.cpp $(sources).cpp ;
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.cpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,49 @@
+// 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 "blueprint_bank.hpp"
+#include "blueprint_window.hpp"
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+class component_button : public glv::Button
+{
+public:
+ component_button(blueprint_bank &bank, const std::string &label)
+ : glv::Button(glv::Rect(60, 60), false), m_label(label), m_bank(bank)
+ {
+ glv::Label *l = new glv::Label(label);
+ l->pos(glv::Place::TL,0,20);
+ l->size(20);
+ *this << *l;
+ }
+ void spawn()
+ {
+ m_bank.m_blueprint->add_component(m_bank.m_bank[m_label], m_label);
+ }
+private:
+ std::string m_label;
+ blueprint_bank &m_bank;
+};
+
+bool spawn_component(glv::View * v, glv::GLV & glv)
+{
+ component_button * b = static_cast<component_button *>(v);
+
+ b->spawn();
+ return false;
+}
+
+void blueprint_bank::rearrange()
+{
+ for(blueprint::component_bank::iterator it=m_bank.begin(); it!=m_bank.end(); it++)
+ {
+ m_component_buttons.push_back(new component_button(*this, it->c_str()));
+ m_component_buttons.back()(glv::Event::MouseDown, spawn_component);
+ m_layout << m_component_buttons.back();
+ }
+}
+
+} } }

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_bank.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,57 @@
+// 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)
+
+
+#ifndef BLUEPRINT_COMPONENT_BANK_HPP
+#define BLUEPRINT_COMPONENT_BANK_HPP
+
+#include <boost/dataflow/blueprint/component_bank.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <glv.h>
+#include <glv_binding_glut.h>
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+class blueprint_window;
+
+class blueprint_bank
+{
+public:
+ blueprint_bank()
+ : m_view(glv::Rect(70, 600))
+ , m_layout(m_view, glv::Direction::S, glv::Place::TL, 5, 5, 5)
+ {
+ m_view.colors().back.set(0);
+ };
+
+ void set_bank(const blueprint::component_bank &bank)
+ {
+ m_bank = bank;
+ rearrange();
+ }
+ void set_blueprint(blueprint_window &blueprint)
+ {
+ m_blueprint = &blueprint;
+ }
+
+ glv::View &view()
+ { return m_view; }
+
+ typedef boost::ptr_vector<glv::Button> component_buttons_type;
+private:
+ void rearrange();
+ blueprint_window * m_blueprint;
+ blueprint::component_bank m_bank;
+ glv::View m_view;
+ glv::Placer m_layout;
+
+ component_buttons_type m_component_buttons;
+ friend class component_button;
+};
+
+} } }
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.cpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,81 @@
+// 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 "blueprint_component.hpp"
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+bool blueprint_invoke_button::onEvent(glv::Event::t e, glv::GLV& glv)
+{
+ bool response = glv::Button::onEvent(e, glv);
+ if(e == glv::Event::MouseUp)
+ static_cast<blueprint_component *>(parent)->invoke();
+ return response;
+}
+
+bool blueprint_component_port::onEvent(glv::Event::t e, glv::GLV& glv)
+{
+ bool result = glv::Button::onEvent(e, glv);
+ switch(e)
+ {
+ case glv::Event::MouseUp:
+ blueprint().register_port_click(this);
+ default:
+ break;
+ }
+ return result;
+}
+
+blueprint_component::blueprint_component(const std::string &name, blueprint::component &c, id_type id)
+ : glv::View(glv::Rect(100, 100))
+ , m_left_buttons(glv::Rect(20, 100))
+ , m_right_buttons(glv::Rect(20, 100))
+ , m_layout(*this, glv::Direction::E, glv::Place::CL, 0, 50, 0)
+ , m_left_layout(m_left_buttons,glv::Direction::S, glv::Place::TL, 0, 0, 0)
+ , m_right_layout(m_right_buttons,glv::Direction::S, glv::Place::TL, 0, 0, 0)
+{
+ glv::Label *l = new glv::Label(name);
+ l->size(20);
+ l->pos(glv::Place::TL,20,20);
+ *this << *l;
+ m_layout << m_left_buttons << m_invoke_button << m_right_buttons;
+ (*this) (glv::Event::MouseDrag, glv::Behavior::mouseMove);
+
+ // BlueprintComponent_(label);
+ set_component(c, id);
+}
+
+void blueprint_component::set_component(blueprint::component &c, id_type id)
+{
+ m_component=&c;
+ m_id = id;
+
+ if(c.is_invocable())
+ m_invoke_button.enable(glv::Visible);
+ else
+ m_invoke_button.disable(glv::Visible);
+
+ blueprint::based_component<glv::View> *view_component = dynamic_cast<blueprint::based_component<glv::View> *>(&c);
+ if(view_component)
+ {
+ std::cout << "View" << std::endl;
+ glv::View *view = view_component->get_pointer();
+ *this << *view;
+ extent(100,200);
+ }
+ else
+ std::cout << "Not View" << std::endl;
+
+ for (size_t i=0; i<c.num_ports(); i++)
+ if (c.get_port(i).traits().category().is<ports::producer>())
+ m_right_layout << *(new blueprint_component_port(i));
+ else
+ m_left_layout << *(new blueprint_component_port(i));
+}
+
+blueprint_component *blueprint_component::m_currently_constructed;
+
+} } }

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_component.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,74 @@
+// 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)
+
+#ifndef BLUEPRINT_COMPONENT_HPP
+#define BLUEPRINT_COMPONENT_HPP
+
+#include "glv.h"
+#include "blueprint_window.hpp"
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+class blueprint_invoke_button : public glv::Button
+{
+public:
+ blueprint_invoke_button()
+ : glv::Button(glv::Rect(60,60), false)
+ {}
+private:
+ bool onEvent(glv::Event::t e, glv::GLV& glv);
+};
+
+class blueprint_component : public glv::View
+{
+ typedef blueprint::network::component_type id_type;
+public:
+ blueprint_component(const std::string &name, blueprint::component &c, id_type id);
+ void set_component(blueprint::component &c, id_type id);
+ void gui_begin();
+ void gui_end();
+ void invoke() {m_component->invoke();}
+ id_type id() {return m_id;}
+private:
+ static blueprint_component *m_currently_constructed;
+ blueprint::component *m_component;
+ std::string m_name;
+ id_type m_id;
+ glv::View m_left_buttons, m_right_buttons;
+ glv::Placer m_layout, m_left_layout, m_right_layout;
+ blueprint_invoke_button m_invoke_button;
+};
+
+class blueprint_component_port
+ : public glv::Button
+{
+public:
+ blueprint_component_port(size_t id)
+ : glv::Button(glv::Rect(20,20), false), m_id(id)
+ {
+ *this << new glv::Label(">");
+ }
+ bool onEvent(glv::Event::t e, glv::GLV& glv);
+ blueprint_component &component()
+ { return *static_cast<blueprint_component *>(parent->parent); }
+ int center_x_root()
+ { return width()/2 + left() + parent->left() + parent->parent->left();}
+ int center_y_root()
+ { return height()/2 + top() + parent->top() + parent->parent->top();}
+ size_t id() {return m_id;}
+ glv::space_t drag_x()
+ { return m_mouse_x; }
+ glv::space_t drag_y()
+ { return m_mouse_y; }
+private:
+ blueprint_window &blueprint()
+ { return *static_cast<blueprint_window *>(parent->parent->parent); }
+ size_t m_id;
+ glv::space_t m_mouse_x, m_mouse_y;
+};
+
+} } }
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.cpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,148 @@
+// 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 "blueprint_window.hpp"
+#include "blueprint_component.hpp"
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+blueprint_window::blueprint_window()
+ : glv::View(glv::Rect(800, 600))
+ , m_layout(*this, glv::Direction::E, glv::Place::TL, 5, 5, 5)
+ , m_dragged(NULL)
+{
+ this->colors().back.set(0);
+ m_next_created_x = 100;
+ m_next_created_y = 50;
+}
+
+void blueprint_window::add_component(std::auto_ptr<blueprint::component> c, const std::string &name)
+{
+ std::cout << "Adding component" << name << std::endl;
+ blueprint_component *bc = new blueprint_component(name, *c, m_network.add_component(c));
+ add_component_helper(*bc);
+}
+
+void blueprint_window::add_component(boost::function<blueprint::component *()> f, const std::string &name)
+{
+ std::cout << "Adding component" << name << std::endl;
+
+ std::auto_ptr<blueprint::component> c(f());
+ blueprint_component *bc = new blueprint_component(name, *c, m_network.add_component(c));
+ add_component_helper(*bc);
+
+/* gui::wnd<blueprint_component> bc = gui::create<blueprint_component>
+ ( gui::_pos = std::make_pair(m_next_created_x, m_next_created_y)
+ , gui::_size = std::make_pair(100, 100)
+ , gui::_text = name
+ , gui::_parent = this_);*/
+
+// std::auto_ptr<blueprint::component> c(f());
+// blueprint::network::component_type id = m_network.add_component(c);
+// bc->set_component(m_network[id], id);
+
+
+// add_component_helper(*bc);
+}
+
+void blueprint_window::add_component_helper(blueprint_component &bc)
+{
+ m_layout << bc;
+}
+
+
+void blueprint_window::register_port_click(blueprint_component_port *port)
+{
+ if(m_dragged)
+ {
+ std::cout << "Attempting connect..." << std::endl;
+ if (m_network.are_connectable(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id()))
+ {
+ m_network.add_connection(m_dragged->component().id(), m_dragged->id(), port->component().id(), port->id(), true);
+ m_connections.push_back(connection(m_dragged, port));
+ }
+ else
+ std::cout << "Ports not connectable" << std::endl;
+ m_dragged = NULL;
+ }
+ else
+ {
+ std::cout << "Initiating connect - click on destination port to make connection" << std::endl;
+ m_dragged = port;
+ }
+}
+
+void blueprint_window::onDraw()
+{
+ glv::draw::begin(glv::draw::Lines);
+/* if(m_dragged)
+ {
+ glv::draw::color(1, 0, 0); // set color to red
+ glv::draw::vertex(m_dragged->center_x_root(),m_dragged->center_y_root());
+ glv::draw::vertex(m_dragged->drag_x() - left(), m_dragged->drag_y() - top());
+ }*/
+ for (std::vector<connection>::iterator it=m_connections.begin(); it!=m_connections.end(); it++)
+ {
+ glv::draw::color(0, 1, 0);
+ glv::draw::vertex(it->first->center_x_root(), it->first->center_y_root());
+ glv::draw::vertex(it->second->center_x_root(), it->second->center_y_root());
+ }
+ glv::draw::end();
+}
+
+namespace detail
+{
+ double distance(int x0, int y0, int x1, int y1)
+ {
+ int dx = x1 - x0;
+ int dy = y1 - y0;
+ return sqrt(dx*dx+dy*dy);
+ }
+
+ double distance(int x0, int y0, int x1, int y1, int xp, int yp)
+ {
+ int dx = x1 - x0;
+ int dy = y1 - y0;
+ if (dx==0 && dy==0)
+ return distance(x0, y0, xp, yp);
+
+ double r = double((xp - x0) * dx + (yp - y0) * dy) / (dx*dx + dy*dy);
+ if (r<0)
+ return distance(x0, y0, xp, yp);
+ else if (r>1)
+ return distance(x1, y1, xp, yp);
+ else
+ return distance((1-r)*x0 + r*x1, (1-r)*y0 + r*y1, xp, yp);
+ }
+}
+
+/*
+int blueprint_window::handle(int event)
+{
+ if (fltk::Window::handle(event))
+ return 1;
+ bool found=false;
+ if(event == fltk::PUSH)
+ for (std::vector<Connection>::iterator it=m_connections.begin(); it!=m_connections.end(); it++)
+ if (detail::distance(
+ it->first->center_x_root(),
+ it->first->center_y_root(),
+ it->second->center_x_root(),
+ it->second->center_y_root(),
+ fltk::event_x(),
+ fltk::event_y()) < 3)
+ {
+ m_selected = it;
+ found = true;
+ }
+ if (!found)
+ m_selected = std::vector<Connection>::iterator();
+ redraw();
+ return 0;
+}*/
+
+
+} } }
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/blueprint_window.hpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,51 @@
+// 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)
+
+#ifndef BLUEPRINT_WINDOW_HPP
+#define BLUEPRINT_WINDOW_HPP
+
+#include "glv.h"
+#include "glv_binding_glut.h"
+
+#include <boost/dataflow/blueprint/network.hpp>
+#include <boost/dataflow/signals/runtime_support.hpp>
+
+namespace boost { namespace dataflow { namespace glv_gui {
+
+class blueprint_component;
+class blueprint_component_port;
+
+class connection
+ : public std::pair<blueprint_component_port *, blueprint_component_port *>
+{
+public:
+ connection(blueprint_component_port *p1, blueprint_component_port *p2)
+ : std::pair<blueprint_component_port *, blueprint_component_port *>(p1, p2)
+ {}
+};
+
+class blueprint_window
+ : public glv::View
+{
+public:
+ blueprint_window();
+ void add_component(std::auto_ptr<blueprint::component> c, const std::string &name);
+ void add_component(boost::function<blueprint::component *()> f, const std::string &name);
+ void register_port_click(blueprint_component_port *port);
+private:
+ void onDraw();
+ void add_component_helper(blueprint_component &bc);
+ blueprint::network m_network;
+ std::vector<blueprint_component *> m_components;
+ blueprint_component_port *m_dragged;
+ std::vector<connection> m_connections;
+ std::vector<connection>::iterator m_selected;
+ int m_next_created_x;
+ int m_next_created_y;
+ glv::Placer m_layout;
+};
+
+} } }
+#endif
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/COPYRIGHT
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/COPYRIGHT 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,40 @@
+GLV AUTHORSHIP AND COPYRIGHT NOTICE
+
+Authors
+---------------------------------------------------------------------------
+
+Main design and development by Lance Putnam, Wesley Smith, and Graham Wakefield with contributions from:
+ Eric Newman,
+ Alex Norman,
+ Stephen Pope,
+ and others,
+all at the Graduate Program in Media Arts and Technology (MAT) at the University of California, Santa Barbara (UCSB).
+
+Contact: Lance Putnam (ljputnam_at_[hidden])
+
+
+
+License
+---------------------------------------------------------------------------
+
+Copyright (C) 2006-2008. The Regents of the University of California (REGENTS).
+All Rights Reserved.
+
+Permission to use, copy, modify, distribute, and distribute modified versions
+of this software and its documentation without fee and without a signed
+licensing agreement, is hereby granted, provided that the above copyright
+notice, the list of contributors, this paragraph and the following two paragraphs
+appear in all copies, modifications, and distributions.
+
+IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
+OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
+HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
+MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,34 @@
+#ifndef INC_GLV_H
+#define INC_GLV_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+/*! \mainpage GLV - OpenGL GUI library
+
+ \section intro_sec Introduction
+
+ GLV (short for GL View) is an OpenGL based GUI library, currently for OSX,
+ Win32, and Linux. The ideal is to create a reasonably efficient,
+ multi-platform API that makes it simple for the end-user developer to
+ create an application's graphical user interface entirely using GPU-based
+ OpenGL instructions, thus freeing CPU resources for other work
+ (e.g. audio DSP).
+
+*/
+
+/*
+ helpful include file to include all of GLV at once
+*/
+
+// GLV core:
+#include "glv_core.h"
+#include "glv_behavior.h"
+#include "glv_layout.h"
+
+// widgets:
+#include "glv_sliders.h"
+#include "glv_textview.h"
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_abstract_binding.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_abstract_binding.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,67 @@
+#ifndef INC_GLV_ABSTRACT_BINDING_H
+#define INC_GLV_ABSTRACT_BINDING_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+namespace glv{
+
+class GLV;
+
+
+class AbstractWindow{
+
+public:
+ AbstractWindow(unsigned int width=800, unsigned int height=600, char * title="GLV Window", GLV * glv=0, double framerate=40.0);
+ virtual ~AbstractWindow(){}
+
+ void fullscreen(bool on);
+ void fullscreenToggle();
+ void resize(int w, int h);
+ void show(bool v);
+ void hideCursor(bool hide=true);
+
+ void setGLV(GLV & g);
+
+ double fps(){ return mFPS; }
+ unsigned int height(){ return h; }
+ unsigned int width(){ return w; }
+
+ GLV * glv;
+
+protected:
+ double mFPS;
+ char * mLabel;
+ unsigned int w, h, wwin, hwin;
+ bool mFullscreen;
+ bool mVisible;
+ bool mIsActive;
+ bool mHideCursor;
+
+ bool shouldDraw(); // if the GLV views should be drawn
+
+ // These virtuals should be overridden for the specific bindings
+ virtual void platformFullscreen(){}
+ virtual void platformHideCursor(bool hide){}
+ virtual void platformResize(int width, int height){} // platform specific resize stuff
+ virtual void platformShowHide(){} // platform specific show/hide stuff
+};
+
+
+
+class AbstractApplication{
+public:
+
+ static void run();
+ static void quit();
+// static void windowNotify(Notifier * sender, void * userdata);
+
+protected:
+ static AbstractWindow *focusedWindow;
+};
+
+
+} // glv::
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_behavior.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_behavior.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,44 @@
+#ifndef INC_GLV_BEHAVIOR_H
+#define INC_GLV_BEHAVIOR_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_core.h"
+
+namespace glv{
+
+namespace Behavior{
+
+ static bool mouseMove(View * v, GLV & glv){
+ if(glv.mouse.right()){
+ v->move(glv.mouse.dx(), glv.mouse.dy());
+ }
+ return false;
+ }
+
+ static bool mouseResize(View * v, GLV & glv){
+ if(glv.mouse.middle()){
+
+ float dx = glv.mouse.dx();
+ float dy = glv.mouse.dy();
+ float mx = glv.mouse.xRel() / v->w;
+ float my = glv.mouse.yRel() / v->h;
+
+ if(mx < 0.5){
+ v->resizeLeftTo(v->l + dx);
+ my < 0.5 ? v->resizeTopTo(v->t + dy) : v->resizeBottomTo(v->bottom() + dy);
+ }
+ else{
+ v->resizeRightTo(v->right() + dx);
+ my < 0.5 ? v->resizeTopTo(v->t + dy) : v->resizeBottomTo(v->bottom() + dy);
+ }
+ v->fixNegativeExtent();
+ }
+ return false;
+ }
+
+} // Behavior::
+} // glv::
+
+#endif

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_carbon.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_carbon.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,69 @@
+#ifndef INC_GLV_BINDING_CARBON_H
+#define INC_GLV_BINDING_CARBON_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#define GLV_CARBON_PATH_DEFAULT_FONT "/Library/Frameworks/GLV.framework/Versions/A/Resources/ProFontWindows.ttf"
+
+typedef ::Rect CarbonRect;
+
+#include "glv_core.h"
+#include "glv_abstract_binding.h"
+
+//#include <Carbon/Carbon.h>
+#include <AGL/agl.h>
+#include <map>
+#include <string>
+
+namespace glv {
+
+class Application : public AbstractApplication
+{
+public:
+
+ static void run();
+ static void quit();
+
+protected:
+
+ static EventHandlerRef * carbonApplicationHandlerRef;
+ static OSStatus carbonApplicationHandler(EventHandlerCallRef nextHandler, EventRef e, void * udata);
+
+};
+
+#define CARBON_TITLEBARHEIGHT (24)
+
+class Window : public AbstractWindow
+{
+public:
+
+ Window(unsigned int width=800, unsigned int height=600, char * title="GLV Window", GLV * glv=0, double framerate=40);
+ virtual ~Window();
+
+protected:
+ virtual void platformResize(int width, int height); // called at tail of AbstractWindow::resize()
+ virtual void platformShowHide(); // called at tail of AbstractWindow::show()
+
+ // Carbon window pointer:
+ WindowRef windowRef;
+
+ // Carbon event system callbacks:
+ EventLoopTimerUPP timerUPP;
+ static OSStatus carbonWindowHandler(EventHandlerCallRef nextHandler, EventRef e, void * udata);
+ static pascal void carbonWindowDrawHandler(EventLoopTimerRef inTimer, void * userData);
+
+ // OpenGL driver & state:
+ AGLContext aglcontext;
+ CarbonRect rectport;
+ GDHandle graphicsdevice;
+ GLint attrib[64];
+ AGLPixelFormat pixelformat;
+
+ std::map<UInt32, std::string> eventClassDescription;
+ std::map<UInt32, std::string> eventKindDescription;
+};
+
+} // namespace
+
+#endif
\ No newline at end of file

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_fltk.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_fltk.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,65 @@
+#ifndef INC_GLV_BINDING_FLTK_H
+#define INC_GLV_BINDING_FLTK_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_core.h"
+#include "glv_abstract_binding.h"
+
+#include <FL/Fl.H>
+#include <FL/Fl_Gl_Window.H>
+#include <FL/gl.h>
+
+//#define GLV_KEY_BACKSPACE FL_BackSpace
+//#define GLV_KEY_DELETE FL_Delete
+//#define GLV_KEY_ENTER FL_Enter
+//#define GLV_KEY_ESC FL_Escape
+//#define GLV_KEY_TAB FL_Tab
+//#define GLV_KEY_PAUSE FL_Pause
+//#define GLV_KEY_SCROLL_LOCK FL_Scroll_Lock
+//#define GLV_KEY_HOME FL_Home
+//#define GLV_KEY_LEFT FL_Left
+//#define GLV_KEY_UP FL_Up
+//#define GLV_KEY_RIGHT FL_Right
+//#define GLV_KEY_DOWN FL_Down
+//#define GLV_KEY_PAGE_UP FL_Page_Up
+//#define GLV_KEY_PAGE_DOWN FL_Page_Down
+//#define GLV_KEY_END FL_End
+//#define GLV_KEY_PRINT FL_Print
+//#define GLV_KEY_INSERT FL_Insert
+//#define GLV_KEY_NUM_LOCK FL_Num_Lock
+//#define GLV_KEY_F FL_F /* use GLV_KEY_F + n for function key n */
+
+namespace glv {
+
+class Application : public AbstractApplication{
+public:
+ static void run();
+ static void quit();
+protected:
+
+};
+
+class Window : public AbstractWindow, public Fl_Gl_Window{
+public:
+ Window(unsigned int width = 800, unsigned int height = 600, char * title = "GLV Window", double framerate = 40.0);
+ virtual ~Window();
+
+protected:
+ bool mFullscreenDeferred;
+ void draw(); // FLTK draw callback
+ int handle(int event); // FLTK event callback
+ void resize(int l, int t, int w, int h); // FLTK resize callback
+ void fltkFullscreen(); // FLTK fullscreen called at start of draw loop
+ static void scheduleDraw(void * userdata);
+
+ virtual void platformFullscreen(); // defers fullscreen to draw loop for thread safety
+ virtual void platformResize(int width, int height); // called at tail of AbstractWindow::resize()
+ virtual void platformShowHide(); // called at tail of AbstractWindow::show()
+};
+
+} // namespace
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_glut.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_binding_glut.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,48 @@
+#ifndef INC_GLV_BINDING_GLUT_H
+#define INC_GLV_BINDING_GLUT_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_core.h"
+#include "glv_abstract_binding.h"
+
+#if defined (__APPLE__) || defined (OSX)
+ #include <GLUT/glut.h>
+#endif
+#if defined(__linux__)
+ #include <GL/glut.h>
+#endif
+#ifdef WIN32
+ #include <?/glut.h>
+#endif
+
+namespace glv {
+
+class Application : public AbstractApplication{
+public:
+ static void run();
+ static void quit();
+
+protected:
+};
+
+class Window : public AbstractWindow{
+public:
+ Window(unsigned int width=800, unsigned int height=600, char * title="GLV Window", GLV * glv=0, double framerate=40);
+ virtual ~Window();
+
+ void draw(); // GLUT draw function
+
+protected:
+
+ virtual void platformFullscreen();
+ virtual void platformHideCursor(bool hide);
+ virtual void platformResize(int width, int height); // called at tail of AbstractWindow::resize()
+ virtual void platformShowHide(); // called at tail of AbstractWindow::show()
+};
+
+} // namespace
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_color.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_color.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,125 @@
+#ifndef INC_GLV_COLOR_H
+#define INC_GLV_COLOR_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_util.h"
+#include <stdio.h>
+
+namespace glv {
+
+class HSV;
+
+/// An RGBA color.
+struct Color{
+
+ float r; ///< Red component in [0, 1]
+ float g; ///< Green component in [0, 1]
+ float b; ///< Blue component in [0, 1]
+ float a; ///< Alpha component in [0, 1]
+
+ /// @param[in] r red component
+ /// @param[in] g green component
+ /// @param[in] b blue component
+ /// @param[in] a alpha component
+ Color(float r, float g, float b, float a = 1.f);
+
+ /// @param[in] gray red/green/blue components
+ /// @param[in] a alpha component
+ Color(float gray=1.f, float a=1.f);
+
+ Color(const HSV& hsv, float a=1.f);
+
+ // Setters
+
+ Color& operator= (const HSV& hsv);
+
+ void set(float r, float g, float b, float a); ///< Set r, g, b, and a components
+ void set(float r, float g, float b); ///< Set r, g, and b components
+ void set(const Color& other, float rgbScale=1); ///< Copy another Color's colors
+ void set(float gray); ///< Set as gray color
+ void set(float gray, float alpha); ///< Set as gray color with alpha
+ void invert(); ///< Invert colors
+ void scale(float amount); ///< Scale r, g, and b values
+
+ /// Set color from HSV values in [0, 1]
+ void setHSV(float h, float s, float v);
+
+ /// Get HSV values in [0, 1] from color
+ void getHSV(float &h, float &s, float &v) const;
+
+ /// Set color from H value in [0, 6] and SV values in [0, 1].
+ void setHSV6(float h, float s, float v);
+
+ /// Get H value in [0, 6] and SV values in [0, 1] from color.
+ void getHSV6(float &h, float &s, float &v) const;
+
+ void print(const char * append="\n", FILE * fp=stdout) const;
+};
+
+
+struct HSV{
+
+ float h, s, v;
+
+ HSV(): h(0), s(1), v(1){}
+ HSV(float h, float s, float v): h(h), s(s), v(v){}
+ HSV(const Color& c){ *this = c; }
+
+ HSV& operator=(const Color& c){
+ c.getHSV(h, s, v); return *this;
+ }
+};
+
+
+
+// Implementation ______________________________________________________________
+
+inline Color::Color(float r, float g, float b, float a)
+: r(r), g(g), b(b), a(a)
+{}
+
+inline Color::Color(float v, float a)
+: r(v), g(v), b(v), a(a)
+{}
+
+inline Color::Color(const HSV& hsv, float a)
+: a(a)
+{
+ setHSV(hsv.h, hsv.s, hsv.v);
+}
+
+
+inline Color& Color::operator=(const HSV& hsv){
+ setHSV(hsv.h, hsv.s, hsv.v); return *this;
+}
+
+inline void Color::set(float re, float gr, float bl, float al){
+ r = re; g = gr; b = bl; a = al;
+}
+
+inline void Color::set(float re, float gr, float bl){ set(re, gr, bl, a); }
+
+inline void Color::set(const Color & c, float rgbScale){
+ set(c.r, c.g, c.b, c.a);
+ scale(rgbScale);
+}
+inline void Color::set(float v){ set(v,v,v); }
+inline void Color::set(float v, float al){ set(v,v,v,al); }
+inline void Color::invert(){ set(1.f - r, 1.f - g, 1.f - b); }
+inline void Color::scale(float v){ set(r*v, g*v, b*v); }
+
+inline void Color::setHSV(float h, float s, float v){
+ setHSV6(h * 6.f, s, v);
+}
+
+inline void Color::getHSV(float &h, float &s, float &v) const{
+ getHSV6(h,s,v);
+ h *= 0.166666667f; // 0..1
+}
+
+} // glv::
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_conf.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_conf.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,78 @@
+#ifndef INC_GLV_CONF_H
+#define INC_GLV_CONF_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#define GLV_VERSION "0.79"
+#define GLV_MAX_MOUSE_BUTTONS 8
+
+
+// Macros for binding GLV to a specific platform's windowing system.
+// Type "#include GLV_BINDING_H" in the source files that need it.
+#ifndef GLV_BINDING_H
+ #if defined (__APPLE__) || defined (OSX)
+ #define GLV_BINDING_H "glv_binding_carbon.h"
+ #endif
+ #if defined(__linux__)
+ #define GLV_BINDING_H "glv_binding_glut.h"
+ #endif
+ #ifdef WIN32
+ #define GLV_BINDING_H ""
+ #endif
+#endif
+
+
+// OpenGL platform-dependent includes
+#if defined (__APPLE__) || defined (OSX)
+
+ #define GLV_PLATFORM "OSX"
+
+ //#include <Carbon/Carbon.h>
+ //#include <AGL/agl.h>
+ //#include <AGL/aglRenderers.h>
+ #include <OpenGL/OpenGL.h>
+ #include <OpenGL/gl.h>
+ #include <OpenGL/glext.h>
+ #include <OpenGL/glu.h>
+
+ #define C2CFSTR(cstr) CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingMacRoman)
+
+ #define GLV_PLATFORM_INIT\
+ GLint MacHackVBL = 1;\
+ CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &MacHackVBL);
+
+#endif
+
+#if defined(__linux__)
+
+ #define GLV_PLATFORM "UNIX"
+
+ #include <GL/gl.h>
+ #include <GL/glu.h>
+ #include <time.h>
+
+ #define GLV_PLATFORM_INIT
+
+#endif
+
+#ifdef WIN32
+
+ #define GLV_PLATFORM "WIN32"
+
+ #include <windows.h>
+
+ #include <gl/gl.h>
+ #include <gl/glu.h>
+
+ #pragma comment( lib, "winmm.lib")
+ #pragma comment( lib, "opengl32.lib" )
+ #pragma comment( lib, "glu32.lib" )
+
+ #define GLV_PLATFORM_INIT
+
+#endif
+
+
+
+#endif

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_core.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_core.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,578 @@
+#ifndef INC_GLV_CORE_H
+#define INC_GLV_CORE_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_rect.h"
+#include "glv_observer_pattern.h"
+#include "glv_color.h"
+#include "glv_draw.h"
+
+#include <map>
+#include <string>
+#include <list>
+
+namespace glv {
+
+class GLV;
+class View;
+
+/// Type for graphical space values, i.e. dimensions, extents, positions, etc..
+typedef float space_t;
+
+/// Type for View rectangle geometry
+typedef TRect<space_t> Rect;
+
+/// Type for a drawing callback
+typedef void (*drawCallback)(View * v);
+
+/// Type for an event callback
+
+/// The first parameter is the View receiving the event and the second is the
+/// GLV context sending the event. The function returns true if the event is
+/// to be bubbled up to the receiver's parent View.
+typedef bool (*eventCallback)(View * v, GLV& glv);
+
+/// Type for a list of event callbacks
+typedef std::list<eventCallback> eventCallbackList;
+
+
+
+/// View property flags
+enum{
+ Visible =1<<0, /**< Whether to draw myself */
+ DrawBack =1<<1, /**< Whether to draw back rect */
+ DrawBorder =1<<2, /**< Whether to draw border */
+ CropChildren =1<<3, /**< Whether to crop children when drawing */
+ CropSelf =1<<4, /**< Whether to crop own drawing routine(s) */
+ FocusHighlight =1<<5, /**< Whether to highlight border when focused */
+ HitTest =1<<6 /**< Whether View can be clicked */
+};
+
+
+
+/// Direction types
+struct Direction{
+
+ /// Direction enumeration
+ enum{
+ N = 1<<0, /**< North */
+ E = 1<<1, /**< East */
+ S = 1<<2, /**< South */
+ W = 1<<3 /**< West */
+ };
+
+ Direction(): val(0){}
+ Direction(int v): val(v){}
+ operator int(){ return val; }
+ int val;
+};
+
+
+
+/// Recognized event types.
+namespace Event{
+
+ /// Event type enum
+ enum t{
+ Null = 0, /**< No event */
+
+ // core events
+ Quit, /**< Application quit */
+
+ // view events
+ GetFocus, /**< View got focus */
+ LoseFocus, /**< View lost focus */
+
+ // mouse events
+ MouseDown, /**< Mouse button pressed */
+ MouseUp, /**< Mouse button released */
+ MouseMove, /**< Mouse has moved */
+ MouseDrag, /**< Mouse has moved with a button pressed */
+ MouseWheel, /**< Mouse wheel moved */
+
+ // keyboard events
+ KeyDown, /**< Keyboard key pressed*/
+ KeyUp, /**< Keyboard key released */
+ KeyRepeat, /**< Keyboard key auto-repeated */
+
+ // window events
+ // WindowActivated,
+ // WindowDeactivated,
+ Unused, /**< Add to this for runtime event types */
+ NumTypes /**< Number of event types */
+ };
+
+ /// Returns a string of event type.
+ const char * string(const Event::t e);
+}
+
+
+
+/// Constants of keyboard keys.
+namespace Key{
+ enum t{
+
+ // Standard ASCII non-printable characters
+ Enter =3, /**< */
+ BackSpace =8, /**< */
+ Tab =9, /**< */
+ Return =13, /**< */
+ Escape =27, /**< */
+ Delete =127, /**< */
+
+ // Non-standard, but common keys.
+ F1=256, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
+ Insert, Left, Up, Right, Down, PageDown, PageUp, End, Home,
+ };
+}
+
+
+
+/// Placement types
+namespace Place{
+ enum t{
+ TC=1<<0, /**< Top-center */
+ TR=1<<1, /**< Top-right */
+ CR=1<<2, /**< Center-right */
+ BR=1<<3, /**< Bottom-right */
+ BC=1<<4, /**< Bottom-center */
+ BL=1<<5, /**< Bottom-left */
+ CL=1<<6, /**< Center-left */
+ TL=1<<7, /**< Top-left */
+ CC=1<<8 /**< Center-center */
+ };
+}
+
+
+
+/// Holds keyboard state.
+class Keyboard{
+ friend class GLV;
+public:
+
+ /// Constructor.
+ Keyboard();
+ ~Keyboard(){}
+
+ int key() const; ///< Returns key code (non-shifted character) of last key event.
+ int keyAsNumber() const;///< Returns decimal number correlating to key code
+ bool alt() const; ///< Whether an alt key is down.
+ bool caps() const; ///< Whether capslock is down.
+ bool ctrl() const; ///< Whether a ctrl key is down.
+ bool meta() const; ///< Whether a meta (e.g. windows, apple) key is down.
+ bool shift() const; ///< Whether a shift key is down.
+ bool isDown() const; ///< Whether last event was button down.
+ bool isNumber() const; ///< Whether key is a number key
+ bool key(int k) const; ///< Whether the last key was 'k'.
+
+ void alt (bool state); ///< Set alt key state.
+ void caps (bool state); ///< Set alt key state.
+ void ctrl (bool state); ///< Set ctrl key state.
+ void meta (bool state); ///< Set meta key state.
+ void shift(bool state); ///< Set shift key state.
+
+ void print(); ///< Print keyboard state to stdout.
+
+protected:
+ int mKeycode; // last key event key number
+ bool mIsDown; // last key event state (pressed or released)
+ bool mModifiers[5]; // Modifier key state array (shift, alt, ctrl, caps, meta)
+};
+
+
+
+/// Holds mouse state.
+class Mouse{
+friend class GLV;
+public:
+
+ /// Mouse button enumeration
+ enum{ Left = 0, Middle, Right, Extra = (GLV_MAX_MOUSE_BUTTONS - 1) };
+
+ /// Constructor.
+ Mouse();
+ ~Mouse(){};
+
+ // Accessors
+ space_t x() const; ///< Current x position.
+ space_t y() const; ///< Current y position.
+ space_t x(int button) const; ///< Get button's last down x position.
+ space_t y(int button) const; ///< Get button's last down y position.
+ space_t w() const; ///< Current wheel position.
+
+ space_t dx() const; ///< Current x velocity.
+ space_t dy() const; ///< Current y velocity.
+ space_t dw() const; ///< Current wheel velocity.
+ space_t ddx() const; ///< Current x acceleration.
+ space_t ddy() const; ///< Current y acceleration.
+ space_t ddw() const; ///< Current wheel acceleration.
+
+ space_t xRel() const; ///< Current x position relative to current listener.
+ space_t yRel() const; ///< Current y position relative to current listener.
+
+ int button() const; ///< Last event button number.
+ int clicks() const; ///< Number of sequential clicks of buttons.
+ bool isDown() const; ///< Whether last event was button down.
+ bool isDown(int button) const; ///< Whether button is currently down.
+ bool left() const; ///< Whether left button is currently down.
+ bool middle() const; ///< Whether middle button is currently down.
+ bool right() const; ///< Whether right button is currently down.
+
+
+ void setContext(View * v); ///< Translate relative pos into sub-View.
+ void unsetContext(View * v);///< Translate relative pos out of sub-View.
+
+ void print(); ///< Print out information about Mouse to stdout
+
+protected:
+
+ // Current (0) and previous (1,2) absolute mouse positions
+ space_t mX[3], mY[3], mW[3];
+
+ // Mouse coords in the current listener's relative coordinate space.
+ space_t mXRel, mYRel;
+
+ bool b[GLV_MAX_MOUSE_BUTTONS]; // button-down states
+ space_t bx[GLV_MAX_MOUSE_BUTTONS]; // button-down absolute coordinates
+ space_t by[GLV_MAX_MOUSE_BUTTONS];
+
+ int mButton;
+ int mClicks;
+ bool mIsDown;
+
+ void bufferPos(space_t newPos, space_t * prev3Pos);
+ void pos(int x1, int y1);
+ void posRel(space_t relx, space_t rely);
+ void updateButton(int btn, bool pressed, int clicks);
+};
+
+
+
+/// Color style for View appearance.
+class StyleColor{
+public:
+ StyleColor();
+
+ enum{ BlackOnWhite, Gray, WhiteOnBlack };
+
+ Color back; ///< Background
+ Color border; ///< Border outline
+ Color fore; ///< Foreground
+ Color text; ///< Text
+
+ void set(int preset);
+ void hsv(float h, float s=1, float v=1);
+};
+
+
+
+/// Overall appearance scheme.
+class Style : public SmartPointer{
+public:
+ Style(bool deletable): SmartPointer(deletable){}
+
+ StyleColor color; ///< Color style
+
+ /// Get reference to standard style
+ static Style& standard(){
+
+ // Note: This uses a Construct On First Use Idiom to avoid unpredictable
+ // static initialization order. The memory allocated will get freed from
+ // the heap when the program exits.
+ static Style* ans = new Style(false);
+ return *ans;
+ }
+};
+
+
+
+/// The base class of all GUI elements.
+class View : public Rect, public Notifier {
+
+friend class GLV;
+
+public:
+
+ /// @param[in] left Initial left edge position
+ /// @param[in] top Initial top edge position
+ /// @param[in] width Initial width
+ /// @param[in] height Initial height
+ /// @param[in] cb Drawing callback
+ View(space_t left, space_t top, space_t width, space_t height, drawCallback cb=0);
+
+
+ /// @param[in] rect Rect geometry of View
+ /// @param[in] anchor Anchor place
+ /// @param[in] cb Drawing callback
+ View(const Rect& rect=Rect(200, 200), Place::t anchor=Place::TL, drawCallback cb=0);
+
+ virtual ~View();
+
+ // Doubly linked tree list of views
+ // TODO: move this stuff to a Node sub-class
+ View * parent; ///< My parent view
+ View * child; ///< My first child (next to be drawn)
+ View * sibling; ///< My next sibling view (drawn after all my children)
+ void add(View & child); ///< Add a child view to myself, and update linked lists
+ void makeLastSibling();
+ void remove(); ///< Remove myself from the parent view, and update linked lists
+
+ /// Add a child view to myself
+ View& operator << (View& child){ add( child); return *this; }
+ View& operator << (View* child){ add(*child); return *this; }
+
+
+ /// Map of event callback sequences.
+ std::map<Event::t, eventCallbackList> callbackLists;
+
+ drawCallback draw; ///< Drawing callback
+
+
+ // const methods
+ bool absToRel(View * target, space_t& x, space_t& y) const;
+
+ StyleColor& colors() const;
+ int enabled(int prop) const; ///< Returns whether a property is set
+ int visible() const; ///< Returns whether View is visible
+ int numEventCallbacks(Event::t e) const; ///< Returns number of registered callbacks
+ void printDescendents() const; ///< Print tree of descendent Views to stdout
+ void printFlags() const;
+
+ /// Get style
+ Style& style() const { return *mStyle; }
+
+
+
+ /// Set anchor translation factors
+ View& anchor(space_t mx, space_t my);
+
+ /// Set anchor place on parent
+ View& anchor(Place::t parentPlace);//{ mAnchor = parentPlace; return *this; }
+
+ /// Append callback to a specific event type callback sequence.
+ void appendCallback(Event::t type, eventCallback cb);
+
+ /// Append callback to a specific event type callback sequence.
+ View& operator()(Event::t e, eventCallback cb){
+ appendCallback(e, cb);
+ return *this;
+ }
+
+ /// Creates own copy of current style
+ void cloneStyle();
+
+ /// Force to remain in parent
+ void constrainWithinParent();
+
+ /// Disable property flag(s)
+ View& disable(int prop);
+
+ /// Enable property flag(s)
+ View& enable(int prop);
+
+ /// Returns View under these absolute coordinates or 0 if none.
+
+ /// The coordinates are modified to be relative to the returned View's.
+ ///
+ View * findTarget(space_t& x, space_t& y);
+
+ /// Set whether I'm focused
+ void focused(bool b);
+
+ /// Translate constraining within parent.
+ void move(space_t x, space_t y);
+
+ /// Set first callback for a specific event type.
+ void on(Event::t e, eventCallback cb = 0);
+
+ /// Main drawing callback
+ virtual void onDraw();
+
+ /// Main event callback
+ virtual bool onEvent(Event::t e, GLV& glv);
+
+ /// Resize callback
+ virtual void onResize(space_t dx, space_t dy);
+
+ /// Set position according to a specific place on rect
+ View& pos(Place::t p, space_t x=0, space_t y=0);
+
+ /// Set property flag(s) to a specfic value
+ View& property(int prop, bool v);
+
+ /// Toggle property flag(s)
+ View& toggle(int prop);
+
+ /// Set parent resize stretch factors
+ View& stretch(space_t mx, space_t my){ mStretchX=mx; mStretchY=my; return *this; }
+
+ /// Set pointer to style
+ void style(Style * style);
+
+
+protected:
+ int mFlags; // Property flags
+ Style * mStyle; // Visual appearance
+ space_t mAnchorX, mAnchorY; // Position anchoring factors when parent is resized
+ space_t mStretchX, mStretchY; // Stretch factors when parent is resized
+ bool mFocused; // Whether I have focus
+
+ void drawBack() const; ///< Draw the back rect
+ void drawBorder() const; ///< Draw the border
+
+ void reanchor(space_t dx, space_t dy); // Reanchor when parent resizes
+};
+
+
+/// The top-level View.
+
+///
+///
+class GLV : public View{
+public:
+
+ /// @param[in] cb My drawing callback
+ /// @param[in] width Initial width
+ /// @param[in] height Initial height
+ GLV(drawCallback cb = 0, space_t width = 800, space_t height = 600);
+
+ Mouse mouse; ///< Current mouse state
+ Keyboard keyboard; ///< Current keyboard state
+
+
+ /// GLV MAIN RENDER LOOP: draw all Views in the GLV
+ /// The assumption is that we are inside an OpenGL context of size [w, h]
+ virtual void drawGLV(unsigned int w, unsigned int h);
+
+ /// Draws all acive widgest in the GLV
+ void drawWidgets(unsigned int w, unsigned int h);
+
+ void eventType(Event::t e){ mEventType = e; }
+ Event::t eventType() const { return mEventType; }
+
+ /// Clears color and depth buffers. Prepares OpenGL context for draw loop
+ void preamble(unsigned int w, unsigned int h);
+
+ /// Update input event state; called by external event handlers.
+ /// be sure to set the eventType first!
+ void propagateEvent();
+
+ /// set current event target:
+ void setFocus(View * v);
+
+ void setKeyDown(int keycode); // Sets keyboard and GLV event state
+ void setKeyUp(int keycode); // Sets keyboard and GLV event state
+
+ /// this function will modify the input coordinates to be relative to the target view's origin
+ void setMouseDown(space_t& x, space_t& y, int button, int clicks);
+
+ /// this function will modify the input coordinates to be relative to the target view's origin
+ void setMouseDrag(space_t& x, space_t& y);
+
+ // LJP: Deprecated. This doesn't work right when multiple buttons are held down.
+ void setMouseDrag(space_t& x, space_t& y, int button, int clicks);
+
+ void setMousePos(int x, int y, space_t relx, space_t rely);
+
+ /// this function will modify the input coordinates to be relative to the target view's origin
+ void setMouseUp(space_t& x, space_t& y, int button, int clicks);
+
+ void setMouseMove(space_t& x, space_t& y);
+
+ void setMouseWheel(int wheelDelta); // Sets mouse and GLV event state
+
+protected:
+ View * mFocusedView; // current focused widget
+ Event::t mEventType; // current event type
+
+ // Returns whether the event should be bubbled to parent
+ bool doEventCallbacks(View& target, glv::Event::t e);
+
+ void doFocusCallback(bool get); // Call get or lose focus callback of focused view
+};
+
+
+
+
+
+
+
+// Implementation ______________________________________________________________
+
+// View
+inline int View::enabled(int prop) const { return mFlags & prop; }
+inline int View::visible() const { return enabled(Visible); }
+
+inline View& View::disable (int prop){ mFlags &=~prop; return *this; }
+inline View& View::enable (int prop){ mFlags |= prop; return *this; }
+inline View& View::property(int prop, bool v){ v ? enable(prop) : disable(prop); return *this; }
+inline View& View::toggle (int prop){ mFlags ^= prop; return *this; }
+
+// Keyboard
+inline int Keyboard::key() const { return mKeycode; }
+inline int Keyboard::keyAsNumber() const { return key() - 48; }
+inline bool Keyboard::isDown() const { return mIsDown; }
+inline bool Keyboard::isNumber() const { return (key() >= '0') && (key() <= '9'); }
+inline bool Keyboard::alt() const { return mModifiers[1]; };
+inline bool Keyboard::caps() const { return mModifiers[3]; };
+inline bool Keyboard::ctrl() const { return mModifiers[2]; };
+inline bool Keyboard::meta() const { return mModifiers[4]; };
+inline bool Keyboard::shift() const { return mModifiers[0]; };
+inline bool Keyboard::key(int k) const { return mKeycode == k; }
+inline void Keyboard::alt (bool state){mModifiers[1] = state;}
+inline void Keyboard::caps (bool state){mModifiers[3] = state;}
+inline void Keyboard::ctrl (bool state){mModifiers[2] = state;}
+inline void Keyboard::meta (bool state){mModifiers[4] = state;}
+inline void Keyboard::shift(bool state){mModifiers[0] = state;}
+
+// Mouse
+inline space_t Mouse::x() const { return mX[0]; }
+inline space_t Mouse::y() const { return mY[0]; }
+inline space_t Mouse::x(int button) const { return bx[button]; }
+inline space_t Mouse::y(int button) const { return by[button]; }
+inline space_t Mouse::w() const { return mW[0]; }
+inline space_t Mouse::dx() const { return mX[0] - mX[1]; }
+inline space_t Mouse::dy() const { return mY[0] - mY[1]; }
+inline space_t Mouse::dw() const { return mW[0] - mW[1]; }
+inline space_t Mouse::ddx() const { return mX[0] - 2 * mX[1] + mX[2]; }
+inline space_t Mouse::ddy() const { return mY[0] - 2 * mY[1] + mY[2];; }
+inline space_t Mouse::ddw() const { return mW[0] - 2 * mW[1] + mW[2];; }
+inline space_t Mouse::xRel() const { return mXRel; }
+inline space_t Mouse::yRel() const { return mYRel; }
+inline int Mouse::button() const { return mButton; }
+inline int Mouse::clicks() const { return mClicks; }
+inline bool Mouse::isDown() const { return mIsDown; }
+inline bool Mouse::isDown(int button) const { return b[button]; }
+inline bool Mouse::left() const { return b[Left]; }
+inline bool Mouse::middle() const { return b[Middle]; }
+inline bool Mouse::right() const { return b[Right]; }
+
+inline void Mouse::setContext(View * v){
+ mXRel -= v->l;
+ mYRel -= v->t;
+}
+inline void Mouse::unsetContext(View * v){
+ mXRel += v->l;
+ mYRel += v->t;
+}
+inline void Mouse::pos(int x, int y) {
+ bufferPos((space_t)x, mX);
+ bufferPos((space_t)y, mY);
+}
+inline void Mouse::bufferPos(space_t newPos, space_t * pos){
+ pos[2] = pos[1];
+ pos[1] = pos[0];
+ pos[0] = newPos;
+}
+inline void Mouse::posRel(space_t relx, space_t rely){
+ mXRel = relx; mYRel = rely;
+}
+
+
+
+} // glv::
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_draw.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_draw.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,359 @@
+#ifndef INC_GLV_DRAW_H
+#define INC_GLV_DRAW_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include <math.h>
+#include "glv_conf.h"
+#include "glv_color.h"
+
+namespace glv {
+
+/// Drawing routines.
+namespace draw{
+
+const double C_PI = 4. * atan(1.);
+const double C_2PI = 2. * C_PI;
+
+#ifdef check
+ #undef check
+#endif
+
+// primitives
+enum{
+ LineLoop = GL_LINE_LOOP,
+ LineStrip = GL_LINE_STRIP,
+ Lines = GL_LINES,
+ Points = GL_POINTS,
+ TriangleFan = GL_TRIANGLE_FAN,
+ TriangleStrip = GL_TRIANGLE_STRIP,
+ Triangles = GL_TRIANGLES,
+ QuadStrip = GL_QUAD_STRIP,
+ Quads = GL_QUADS
+};
+
+// capabilities (for disable() and enable())
+enum{
+ Blend = GL_BLEND,
+ DepthTest = GL_DEPTH_TEST,
+ LineSmooth = GL_LINE_SMOOTH,
+ LineStipple = GL_LINE_STIPPLE,
+ PolygonSmooth = GL_POLYGON_SMOOTH,
+ PointSmooth = GL_POINT_SMOOTH,
+ ScissorTest = GL_SCISSOR_TEST
+};
+
+// attribute masks
+enum{
+ ColorBufferBit = GL_COLOR_BUFFER_BIT,
+ DepthBufferBit = GL_DEPTH_BUFFER_BIT,
+ EnableBit = GL_ENABLE_BIT,
+ ViewPortBit = GL_VIEWPORT_BIT
+};
+
+enum{
+ Model = GL_MODELVIEW,
+ Projection = GL_PROJECTION,
+ Texture = GL_TEXTURE
+};
+
+struct Glyph{
+ enum{ Once=(1<<7), Dot1=(1<<5), Dot2=(2<<5), MaskDots=96, MaskSize=31 };
+
+ const unsigned char field;
+ float x[8], y[8];
+
+ unsigned char dots(){ return (field & MaskDots) >> 5; }
+ unsigned char once(){ return (field ) >> 7; }
+ unsigned char size(){ return (field & MaskSize) ; }
+};
+
+
+
+// Basic rendering commands
+void begin(int primitive); ///< Begin vertex group delimitation
+void clear(int mask); ///< Clear drawing buffers
+void clearColor(float r, float g, float b, float a=1); ///< Set clear color
+void color(float gray, float a=1); ///< Set current draw color
+void color(float r, float g, float b, float a=1); ///< Set current draw color
+void color(const Color& c); ///< Set current draw color
+void color(const Color& c, float a); ///< Set current draw color, but override alpha component
+void disable(int cap); ///< Disable a rendering capability
+void enable(int cap); ///< Enable a rendering capability
+void end(); ///< End vertex group delimitation
+void identity(); ///< Load identity transform matrix
+void lineStipple(char factor, short pattern); ///< Specify line stipple pattern
+void lineWidth(float val); ///< Set width of lines
+void matrixMode(int mode); ///< Set current transform matrix
+void ortho(float l, float r, float b, float t); ///< Set orthographic projection mode
+void pointSize(float val); ///< Set size of points
+void pop(); ///< Pop current transform matrix stack
+void pop(int matrixMode); ///< Pop a transform matrix stack also setting as current matrix
+void pop2D(); ///< Pop 2-D pixel space
+void pop3D(); ///< Pop 3-D signed normalized cartesian space
+void popAttrib(); ///< Pop last pushed attributes from stack
+void push(); ///< Push current transform matrix stack
+void push(int matrixMode); ///< Push a transform matrix stack also setting as current matrix
+template <class T> void push2D(T w, T h); ///< Push 2-D pixel space
+template <class T> void push3D(T w, T h, T near=0.1, T far=100); ///< Push 3-D signed normalized cartesian space
+void pushAttrib(int attribs); ///< Push current attributes onto stack
+void rotate(float degx, float degy, float degz);
+void rotateX(float deg);
+void rotateY(float deg);
+void rotateZ(float deg);
+void scale(float x, float y, float z=1.f);
+void scissor(float x, float y, float w, float h);
+void translate(float x, float y, float z=0.f);
+void translateX(float x);
+void translateY(float y);
+void translateZ(float z);
+void viewport(float x, float y, float w, float h);
+
+void vertex(float x, float y, float z=0);
+
+template <class T>
+void vertexY(T * ys, unsigned long len, T xInc=1, int prim = LineStrip);
+
+template <class T>
+void vertex(T * xs, T * ys, unsigned long len, int prim = LineStrip);
+
+
+// icons
+void check (float l, float t, float r, float b);
+void frame (float l, float t, float r, float b);
+void minus (float l, float t, float r, float b);
+void plus (float l, float t, float r, float b);
+void rect (float l, float t, float r, float b);
+void triangleR (float l, float t, float r, float b);
+void triangleL (float l, float t, float r, float b);
+void triangleU (float l, float t, float r, float b);
+void triangleD (float l, float t, float r, float b);
+void x (float l, float t, float r, float b);
+
+/// Parallel horizontal and vertical lines
+void grid(float l, float t, float w, float h, float divx, float divy, bool incEnds=true);
+
+void linePattern(float l, float t, float w, float h, int n, const char * pat="/");
+
+/// Parallel horizontal lines
+void linesH(float l, float t, float w, float h, int n);
+
+/// Converts a float to its pixel value.
+inline int pix(float v);
+
+/// Regular polygon
+void pgon(float l, float t, float w, float h, int sides, float angleNorm=0);
+
+void shape(int prim, float x0, float y0, float x1, float y1);
+void shape(int prim, float x0, float y0, float x1, float y1, float x2, float y2);
+void shape(int prim, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3);
+
+void spokes(float l, float t, float w, float h, int sides, float angleNorm=0);
+
+/// Sends vertex calls for a printable ascii character.
+
+/// This function must be called within a begin(Lines) and end().
+/// The coordinate system is an 8x8 grid with top-left at (0,0).
+bool character(int c, float dx=0, float dy=0);
+
+/// Draws a text string, including new lines and tabs.
+
+/// The spacing between characters is fixed at 8 units.
+///
+void text(const char * s, float l=0, float t=0, float lineSpacing=1, unsigned int tabSpaces=4);
+
+
+
+
+
+// Implementation ______________________________________________________________
+
+inline void check(float l, float t, float r, float b){
+ shape(LineStrip, l,0.5*(t+b), l+(r-l)*0.3,b, r,t);
+}
+
+inline void frame(float l, float t, float r, float b){
+ shape(LineLoop, l, t, l, b, r, b, r, t);
+}
+
+inline void minus(float l, float t, float r, float b){
+ float my = 0.5*(t+b);
+ shape(Lines, l,my, r,my);
+}
+
+// [-2,-1) -> -1.5
+// [-1, 0) -> -0.5
+// [ 0, 1) -> 0.5
+// [ 1, 2) -> 1.5
+inline int pix(float v){ return v>=0 ? (int)(v+0.5) : (int)(v-0.5); }
+
+inline void plus(float l, float t, float r, float b){
+ float mx = 0.5*(l+r);
+ float my = 0.5*(t+b);
+ shape(Lines, mx,t, mx,b, l,my, r,my);
+}
+
+inline void rect(float l, float t, float r, float b){
+ glRectf(r, b, l, t);
+}
+
+inline void shape(int primitive, float x0, float y0, float x1, float y1){
+ begin(primitive);
+ vertex(x0, y0); vertex(x1, y1);
+ end();
+}
+
+inline void shape(int primitive, float x0, float y0, float x1, float y1, float x2, float y2){
+ begin(primitive);
+ vertex(x0, y0); vertex(x1, y1); vertex(x2, y2);
+ end();
+}
+
+inline void shape(int primitive, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3){
+ begin(primitive);
+ vertex(x0, y0); vertex(x1, y1); vertex(x2, y2); vertex(x3, y3);
+ end();
+}
+
+inline void triangleD(float l, float t, float r, float b){
+ shape(Triangles, 0.5*(l+r),b, r,t, l,t);
+}
+
+inline void triangleL(float l, float t, float r, float b){
+ shape(Triangles, l,0.5*(t+b), r,b, r,t);
+}
+
+inline void triangleR(float l, float t, float r, float b){
+ shape(Triangles, r,0.5*(t+b), l,t, l,b);
+}
+
+inline void triangleU(float l, float t, float r, float b){
+ shape(Triangles, 0.5*(l+r),t, l,b, r,b);
+}
+
+inline void x(float l, float t, float r, float b){
+ shape(Lines, l,t, r,b, l,b, r,t);
+}
+
+
+
+
+
+
+// core drawing routines
+inline void color(float v, float a){ color(v,v,v,a); }
+
+inline void color(const Color& c){ color(c.r, c.g, c.b, c.a); }
+
+inline void color(const Color& c, float a){ color(c.r, c.g, c.b, a); }
+
+inline void pop(int mode){ matrixMode(mode); pop(); }
+inline void push(int mode){ matrixMode(mode); push(); }
+
+inline void rotate(float degx, float degy, float degz){
+ rotateX(degx); rotateY(degy); rotateZ(degz);
+}
+
+inline void translateX(float x){ translate(x, 0, 0); }
+inline void translateY(float y){ translate(0, y, 0); }
+inline void translateZ(float z){ translate(0, 0, z); }
+
+template <class T>
+void vertexY(T * ys, unsigned long len, T xInc=1, int prim = LineStrip){
+ begin(prim);
+ for(unsigned long i=0; i<len; ++i) vertex((float)(xInc * i), (float)ys[i]);
+ end();
+}
+
+template <class T>
+void vertex(T * xs, T * ys, unsigned long len, int prim){
+ begin(prim);
+ for(unsigned long i=0; i<len; ++i) vertex((float)xs[i], (float)ys[i]);
+ end();
+}
+
+
+
+// platform dependent
+
+inline void begin(int primitive){ glBegin(primitive); }
+inline void clear(int mask){ glClear(mask); }
+inline void clearColor(float r, float g, float b, float a){ glClearColor(r,g,b,a); }
+inline void color(float r, float g, float b, float a){ glColor4f(r,g,b,a); }
+inline void disable(int cap){ glDisable(cap); }
+inline void enable(int cap){ glEnable(cap); }
+inline void end(){ glEnd(); }
+
+// we need to push and pop matrices and viewport bit
+template <class T>
+void push2D(T w, T h){
+
+ disable(DepthTest);
+ disable(PolygonSmooth); // to ensure polygon edges blend properly
+
+ enable(Blend);
+ enable(LineSmooth);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ push(Projection); pushAttrib(ViewPortBit); identity();
+ viewport(0, 0, w, h);
+ ortho(0, w, h, 0); // flat 2D world dimension L,R,B,T
+
+ push(Model); identity();
+}
+
+
+inline void pop2D(){
+ popAttrib(); // for popping GL_VIEWPORT_BIT
+ pop(Projection);
+ pop(Model);
+}
+
+
+template <class T>
+void push3D(T w, T h, T near, T far){
+ //pushAttrib(DepthBufferBit);
+ pushAttrib(ColorBufferBit | DepthBufferBit | EnableBit);
+ enable(DepthTest);
+
+ push(Projection); identity();
+ gluPerspective(45, w/(GLfloat)h, near, far);
+
+ push(Model); identity();
+ translate(0, 0, -2.42);
+}
+
+
+inline void pop3D(){
+ popAttrib(); // for popping GL_DEPTH_BUFFER_BIT
+ pop(Projection);
+ pop(Model);
+}
+
+inline void identity(){ glLoadIdentity(); }
+inline void lineStipple(char factor, short pattern){ glLineStipple(factor, pattern); }
+inline void lineWidth(float v){ glLineWidth(v); }
+inline void matrixMode(int mode){ glMatrixMode(mode); }
+inline void ortho(float l, float r, float b, float t){ gluOrtho2D(l,r,b,t); }
+inline void pointSize(float v){ glPointSize(v); }
+inline void push(){ glPushMatrix(); }
+inline void pushAttrib(int attribs){ glPushAttrib(attribs); }
+inline void pop() { glPopMatrix(); }
+inline void popAttrib(){ glPopAttrib(); }
+inline void rotateX(float deg){ glRotatef(deg, 1.f, 0.f, 0.f); }
+inline void rotateY(float deg){ glRotatef(deg, 0.f, 1.f, 0.f); }
+inline void rotateZ(float deg){ glRotatef(deg, 0.f, 0.f, 1.f); }
+inline void scale(float x, float y, float z){ glScalef(x,y,z); }
+inline void scissor(float x, float y, float w, float h){ glScissor((GLint)x,(GLint)y,(GLsizei)w,(GLsizei)h); }
+inline void translate(float x, float y, float z){ glTranslatef(x,y,z); }
+inline void viewport(float x, float y, float w, float h){ glViewport((GLint)x,(GLint)y,(GLsizei)w,(GLsizei)h); }
+inline void vertex(float x, float y, float z){ glVertex3f(x,y,z); }
+
+} // end namespace draw
+
+} // end namespace glv
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_layout.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_layout.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,134 @@
+#ifndef INC_GLV_LAYOUT_H
+#define INC_GLV_LAYOUT_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_core.h"
+
+
+namespace glv{
+
+/// View placer
+
+/// A Placer is used for aligning a series of views. It can position views
+/// according to an absolute increment and/or increment relative to the views'
+/// geometric extent.
+class Placer{
+public:
+
+ Placer(space_t absX=0, space_t absY=0);
+
+ Placer(View& parent, Direction dir, Place::t align, space_t x, space_t y, space_t pad=4);
+
+ /// Set a view's position
+ Placer& operator<< (View& v);
+
+ /// Set the absolute increment amounts
+ Placer& abs(space_t vx, space_t vy);
+
+ /// Set view alignment location
+ Placer& align(space_t vx, space_t vy);
+
+ /// Set view alignment place
+ Placer& align(Place::t p);
+
+ /// Set anchor place of Views
+ Placer& anchor(Place::t p);
+
+ /// Reassign the placement flow direction
+ Placer& flow(Direction d);
+
+ /// Set the placement flow along with absolute and relative incrementing values
+ Placer& flow(Direction d, space_t abs, space_t rel=1);
+
+ /// Set the current position
+ Placer& pos(space_t vx, space_t vy);
+
+ /// Set the current x-position
+ Placer& posX(space_t v);
+
+ /// Set the current y-position
+ Placer& posY(space_t v);
+
+ /// Set the relative increment factors
+ Placer& rel(space_t vx, space_t vy);
+
+protected:
+ space_t x, y; // trajectory point
+ space_t rx, ry; // relative increment factors
+ space_t ax, ay; // absolute increment amounts
+ space_t fw, fh; // view alignment fraction [0, 1]
+ Place::t mAnchor;
+ View * parent;
+};
+
+
+
+
+// Base interface class for View auto-layout functors
+struct LayoutFunc{
+
+ /// @param[in] w Width of rect element
+ /// @param[in] h Height of rect element
+ /// @param[in] bounds Layout bounding rect
+ LayoutFunc(space_t w, space_t h, const Rect& bounds);
+ virtual ~LayoutFunc();
+
+ /// Returns next rect element of layout function
+ virtual Rect& operator()() = 0;
+
+ void layoutChildren(View& v);
+
+ Rect elem; ///< The current rect element
+ Rect bounds; ///< The layout bounding rect
+ View * parent;
+};
+
+
+
+// Grid auto-layout functor
+
+// Generates evenly distributed rects within a bounding region.
+//
+struct LayoutGrid : public LayoutFunc{
+
+ /// @param[in] w Width of rect element
+ /// @param[in] h Height of rect element
+ /// @param[in] bounds Layout bounding rect
+ /// @param[in] numV Number of vertical divisions
+ /// @param[in] numH Number of horizontal divisions
+ LayoutGrid(space_t w, space_t h, const Rect& bounds, int numV, int numH);
+ virtual ~LayoutGrid();
+
+
+ /// Constructor for auto-sized elements with uniform padding
+
+ /// @param[in] pad Padding between elements
+ /// @param[in] bounds Layout bounding rect
+ /// @param[in] numV Number of vertical divisions
+ /// @param[in] numH Number of horizontal divisions
+ LayoutGrid(space_t pad, const Rect& bounds, int numV, int numH);
+
+
+ LayoutGrid(View& parent, int numH, int numV, space_t pad);
+
+ /// Generate next layout rect going left-to-right, then top-to-bottom.
+ virtual Rect& operator()();
+
+
+ LayoutGrid& operator<< (View& v){
+ if(parent) (*parent) << v;
+ v.set((*this)());
+ return *this;
+ }
+
+protected:
+ int numV, numH, cntV, cntH;
+};
+
+
+
+} // glv::
+
+#endif

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_observer_pattern.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_observer_pattern.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,76 @@
+#ifndef INC_GLV_OBSERVER_H
+#define INC_GLV_OBSERVER_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include <vector>
+
+namespace glv {
+
+class Notifier;
+
+typedef void (*glvHandler)(Notifier * sender, void * userdata); ///< Handler type
+
+//! Handler functor
+class HandlerFunctor
+{
+public:
+
+ HandlerFunctor(glvHandler a, void * v = 0) { handler = a; udata = v; }
+
+ glvHandler handler;
+ void * udata;
+};
+
+//! Notifier
+class Notifier
+{
+public:
+
+ void notify();
+
+ void attachHandler(glvHandler a, void * userdata = 0);
+ void detachHandler(glvHandler a, void * userdata = 0);
+
+protected:
+
+ std::vector<HandlerFunctor> mHandlers;
+};
+
+
+
+// Implementation ______________________________________________________________
+
+inline
+void Notifier :: notify()
+{
+ if(mHandlers.empty()) return;
+
+ int i=mHandlers.size(); // call handlers in FIFO order
+ while (i--)
+ {
+ if (mHandlers[i].handler) mHandlers[i].handler(this, mHandlers[i].udata);
+ }
+}
+
+inline
+void Notifier :: attachHandler (glvHandler a, void * userdata)
+{
+ mHandlers.push_back(HandlerFunctor(a, userdata));
+}
+
+inline
+void Notifier :: detachHandler (glvHandler a, void * userdata)
+{
+ for(unsigned int i=0; i<mHandlers.size(); i++)
+ {
+ if (mHandlers[i].handler == a && mHandlers[i].udata == userdata) mHandlers.erase(mHandlers.begin() + i);
+ }
+}
+
+
+} // glv::
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_rect.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_rect.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,226 @@
+#ifndef INC_GLV_RECT_H
+#define INC_GLV_RECT_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include <stdio.h>
+
+namespace glv {
+
+/// Rectangle shape.
+
+/// Knows how to calculate useful things such as centre, intersection areas
+/// with other rects, etc.
+template <class T>
+class TRect {
+public:
+ T l; ///< Left edge position
+ T t; ///< Top edge position
+ T w; ///< Width
+ T h; ///< Height
+
+ TRect();
+
+ /// Construct from square extent with position set to (0,0).
+
+ /// @param[in] extent initial width and height
+ ///
+ TRect(T extent);
+
+ /// Construct from width and height with position set to (0,0).
+
+ /// @param[in] width initial width
+ /// @param[in] height initial height
+ TRect(T width, T height);
+
+ /// @param[in] left initial left edge position
+ /// @param[in] top initial top edge position
+ /// @param[in] width initial width
+ /// @param[in] height initial height
+ TRect(T left, T top, T width, T height);
+
+ virtual ~TRect(){}
+
+ const TRect& operator= (const TRect& r);
+
+ void extent(T v); ///< Set extent to fit in square.
+ void extent(T w, T h); ///< Set extent.
+ void copyUnder(const TRect<T>& from, T by=0);
+ void fixNegativeExtent(); ///< Fixes negative width or height to be positive.
+ void insetFrom(const TRect<T>& from, T inset); ///< Make TRect relative inset from 'from'
+ void pos(T left, T top); ///< Set left-top position.
+ void posAdd(T x, T y); ///< Translate by [x, y] units.
+ void posUnder(const TRect<T>& r, T by=0);
+ void posRightOf(const TRect<T>& r, T by=0);
+ void resizeLeftTo(T v); ///< Resize by moving left edge to value.
+ void resizeTopTo(T v); ///< Resize by moving top edge to value.
+ void resizeRightTo(T v); ///< Resize by moving right edge to value.
+ void resizeBottomTo(T v); ///< Resize by moving bottom edge to value.
+ void resizeEdgesBy(T v); ///< Resize by moving edges by value.
+ void set(T left, T top, T width, T height); ///< Set components.
+ void set(const TRect<T>& r); ///< Set components from other TRect.
+ void transpose(); ///< Swaps width and height.
+
+ void left(T v); ///< Set left position.
+ void top(T v); ///< Set top position.
+ void width(T v); ///< Set width.
+ void height(T v); ///< Set height.
+ void bottom(T v); ///< Set bottom edge preserving height.
+ void right(T v); ///< Set right edge preserving width.
+
+ // Accessors
+ T left() const { return l; } ///< Get left edge position
+ T top() const { return t; } ///< Get top edge position
+ T width() const { return w; } ///< Get width
+ T height() const { return h; } ///< Get height
+ T right() const; ///< Get right edge position
+ T bottom() const; ///< Get bottom edge position
+
+ T area() const; ///< Returns area (w x h).
+ void center(T & x, T & y) const;///< Gets center point
+ T centerX() const; ///< Returns center along x axis.
+ T centerY() const; ///< Returns center along y axis.
+
+ bool containsPoint(T x, T y) const; ///< Returns whether the point is inside the TRect.
+
+ TRect<T> extent() const;
+
+ /// Calculates the intersection of the two Rects.
+ void intersection(const TRect<T> & check, TRect<T> & intersection) const;
+
+ bool intersects(const TRect<T> & rect) const;///< Returns whether the two Rects intersect.
+ bool isVertical() const; ///< Returns true if h > w, false otherwise.
+ bool withinXBounds(T xmin, T xmax) const; ///< Returns whether the TRect is within the x range.
+ bool withinYBounds(T ymin, T ymax) const; ///< Returns whether the TRect is within the y range.
+
+ /// Called when the width or height change. Changes in extent are passed in.
+ virtual void onResize(T dx, T dy){}
+
+ void print(FILE * fp=stdout); ///< write about TRect to a file
+};
+
+
+
+
+// Implementation ______________________________________________________________
+
+#define TEM template <class T>
+
+TEM TRect<T>::TRect(){ set((T)0, (T)0, (T)40, (T)40); }
+TEM TRect<T>::TRect(T v){ set(0, 0, v, v); }
+TEM TRect<T>::TRect(T iw, T ih){ set(0, 0, iw, ih); }
+TEM TRect<T>::TRect(T il, T it, T iw, T ih){ set(il, it, iw, ih); }
+
+TEM const TRect<T>& TRect<T>::operator= (const TRect<T>& r){
+ set(r.l, r.t, r.w, r.h);
+ return *this;
+}
+
+TEM void TRect<T>::copyUnder(const TRect<T> & r, T by){
+ pos(r.l, r.bottom() + by);
+ extent(r.w, r.h);
+}
+
+TEM inline void TRect<T>::extent(T v){ w > h ? extent(v, v * h/w) : extent(v * w/h, v); }
+
+TEM inline void TRect<T>::extent(T wi, T he){
+ T dx = wi - w;
+ T dy = he - h;
+ w = wi; h = he;
+ onResize(dx, dy);
+}
+
+TEM inline void TRect<T>::fixNegativeExtent(){
+ if(w < (T)0){ w = -w; l -= w; }
+ if(h < (T)0){ h = -h; t -= h; }
+}
+
+TEM inline void TRect<T>::pos(T le, T to){ l = le; t = to; }
+TEM inline void TRect<T>::posAdd(T x, T y){ l += x; t += y; }
+TEM inline void TRect<T>::posRightOf(const TRect<T> & r, T by){ pos(r.right() + by, r.t); }
+TEM inline void TRect<T>::posUnder(const TRect<T> & r, T by){ pos(r.l, r.bottom() + by); }
+TEM inline void TRect<T>::resizeLeftTo(T v){ T dl = l-v; w += dl; l = v; onResize(dl, 0); }
+TEM inline void TRect<T>::resizeTopTo(T v){ T dt = t-v; h += dt; t = v; onResize(0, dt); }
+TEM inline void TRect<T>::resizeRightTo(T v){ width(v - l); }
+TEM inline void TRect<T>::resizeBottomTo(T v){ height(v - t); }
+TEM inline void TRect<T>::resizeEdgesBy(T v){ l -= v; t -= v; extent(w + 2 * v, h + 2 * v); }
+TEM inline void TRect<T>::set(const TRect<T>& r){ set(r.l, r.t, r.w, r.h); }
+TEM inline void TRect<T>::set(T le, T to, T wi, T he){ pos(le, to); extent(wi, he); }
+TEM inline void TRect<T>::transpose(){ extent(h, w); }
+
+TEM inline void TRect<T>::left (T v){ l = v; }
+TEM inline void TRect<T>::top (T v){ t = v; }
+TEM inline void TRect<T>::width (T v){ extent(v, h); }
+TEM inline void TRect<T>::height(T v){ extent(w, v); }
+TEM inline void TRect<T>::bottom(T v){ t = v - h; }
+TEM inline void TRect<T>::right (T v){ l = v - w; }
+
+TEM inline T TRect<T>::right() const { return l + w; }
+TEM inline T TRect<T>::bottom() const { return t + h; }
+TEM inline T TRect<T>::area() const { return w * h; }
+TEM inline void TRect<T>::center(T & x, T & y) const { x = centerX(); y = centerY(); }
+TEM inline T TRect<T>::centerX() const { return l + w * 0.5f; }
+TEM inline T TRect<T>::centerY() const { return t + h * 0.5f; }
+
+TEM inline bool TRect<T>::containsPoint(T x, T y) const {
+ return (x >= l) && (x <= (l + w)) && (y >= t) && (y <= (t + h));
+}
+
+TEM inline TRect<T> TRect<T>::extent() const { return TRect<T>(0,0,w,h); }
+
+TEM inline bool TRect<T>::intersects(const TRect<T> & r) const {
+ return ((l <= r.right()) && (r.l <= right()) &&
+ (t <= r.bottom()) && (r.t <= bottom()));
+}
+
+TEM inline bool TRect<T>::isVertical() const { return h > w; }
+
+TEM inline bool TRect<T>::withinXBounds(T xmin, T xmax) const {
+ return (l < xmax) && (right() > xmin);
+}
+
+TEM inline bool TRect<T>::withinYBounds(T ymin, T ymax) const {
+ return (t < ymax) && (bottom() > ymin);
+}
+
+TEM void TRect<T>::insetFrom(const TRect<T>& from, T by){
+ l = by;
+ t = by;
+ by *= 2.f;
+ extent(from.w - by, from.h - by);
+}
+
+TEM void TRect<T>::intersection(const TRect<T> & check, TRect<T> & inter) const{
+ T l1 = l;
+ T r1 = right();
+ T t1 = t;
+ T b1 = bottom();
+
+ T l2 = check.l;
+ T r2 = check.right();
+ T t2 = check.t;
+ T b2 = check.bottom();
+
+ inter.pos(
+ (l1 > l2) ? l1 : l2,
+ (t1 > t2) ? t1 : t2
+ );
+
+ inter.extent(
+ ((r1 < r2) ? r1 : r2) - inter.l,
+ ((b1 < b2) ? b1 : b2) - inter.t
+ );
+}
+
+
+TEM void TRect<T>::print(FILE * fp){
+ fprintf(fp, "[%.2f, %.2f, %.2f, %.2f]\n", l, t, w, h);
+}
+
+} // glv::
+
+#undef TEM
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_sliders.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_sliders.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,398 @@
+#ifndef INC_GLV_SLIDERS_H
+#define INC_GLV_SLIDERS_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_core.h"
+
+namespace glv {
+
+
+// LJP: The constructor for widgets takes a Rect as an argument rather than
+// individual l,t,w,h components since it's more flexible for layout and
+// only requires writing one constructor.
+
+/// Icon function type
+typedef void (* iconFunc)(float l, float t, float r, float b);
+
+template <int N>
+class ButtonBase : public View{
+public:
+
+ ButtonBase(const Rect& r=Rect(20), bool toggles=true, iconFunc on=draw::rect, iconFunc off=0, space_t iconInset=2)
+ : View(r), mIconOff(off), mIconOn(on), mIconInset(iconInset), mToggles(toggles)
+ {
+ valueMin();
+ }
+
+
+ ButtonBase& iconInset(space_t v){ mIconInset = v; return *this; }
+
+ /// Set button's inactive icon.
+ ButtonBase& iconOff(iconFunc fnc){ mIconOff = fnc; return *this; }
+
+ /// Set button's active icon.
+ ButtonBase& iconOn(iconFunc fnc){ mIconOn = fnc; return *this; }
+
+ ButtonBase& toggles(bool v){ mToggles = v; return *this; }
+
+ ButtonBase& value(bool v, int i){ mVals[i] = v; return *this; }
+
+ ButtonBase& valueMin(){ memset(mVals, 0, sizeof(bool) * size()); return *this; }
+
+
+ space_t iconInset() const { return mIconInset; }
+
+ bool toggles() const { return mToggles; }
+
+ /// Get value of button
+ bool value(int i=0) const { return mVals[i]; }
+
+ static int size(){ return N; }
+
+
+protected:
+ iconFunc mIconOff, mIconOn; // state icons
+ space_t mIconInset; // num pixels to inset icon
+ bool mVals[N]; // values
+ bool mToggles; // whether button stays on or off when clicked once
+};
+
+
+
+
+/// Button widget
+class Button : public ButtonBase<1>{
+public:
+
+ using ButtonBase<1>::iconInset;
+ using ButtonBase<1>::toggles;
+ using ButtonBase<1>::value;
+
+ /// Constructor
+ Button(const Rect& r=Rect(20), bool toggles=true, iconFunc on=draw::rect, iconFunc off=0);
+
+ virtual void onDraw();
+ virtual bool onEvent(Event::t e, GLV& glv);
+};
+
+
+
+template <int Nx, int Ny=1>
+class Buttons : public ButtonBase<Nx * Ny>{
+public:
+
+ using ButtonBase<Nx * Ny>::iconInset;
+ using ButtonBase<Nx * Ny>::toggles;
+ using ButtonBase<Nx * Ny>::value;
+ using ButtonBase<Nx * Ny>::valueMin;
+ using ButtonBase<Nx * Ny>::w;
+ using ButtonBase<Nx * Ny>::h;
+ using ButtonBase<Nx * Ny>::colors;
+
+ /// Constructor
+ Buttons(const Rect& r=Rect(20), bool mutExc=false, iconFunc on=draw::rect, iconFunc off=0);
+
+ int lastClicked() const;
+
+ virtual void onDraw();
+ virtual bool onEvent(Event::t e, GLV& glv);
+
+protected:
+
+ using ButtonBase<Nx * Ny>::mIconOn;
+ using ButtonBase<Nx * Ny>::mIconOff;
+
+ int cx, cy;
+
+ float rNx(){ return 1./Nx; }
+ float rNy(){ return 1./Ny; }
+ int index(int x, int y) const { return x + y*Nx; }
+ float cellW(){ return w * rNx(); }
+ float cellH(){ return h * rNy(); }
+ float iconW(){ return cellW() - 2*iconInset() + 0.5; }
+ float iconH(){ return cellH() - 2*iconInset() + 0.5; }
+};
+
+
+
+/// Abstract multidimensional slider
+
+/// The foreground color determines the color of the slider.
+///
+template <int Dim>
+class SliderBase : public View{
+public:
+
+ /// Constructor
+ SliderBase(const Rect& r);
+
+ float value(int dim=0) const; ///< Returns a slider value
+
+ void value(float val, int dim); ///< Sets a slider value
+ void valueAdd(float val, int dim); ///< Add to a slider value
+ void valueMax(); ///< Max all slider values
+ void valueMid(); ///< Center all slider values
+
+ static int dimensions(){ return Dim; } ///< Returns number of dimensions of slider
+
+protected:
+ float mAcc[Dim], mVal[Dim];
+ //float mSens;
+
+ void clip(float & v){ v<0.f ? v=0.f : v>1.f ? v=1.f : 0; }
+ void clipAccs(){ for(int i=0; i<Dim; ++i) clip(mAcc[i]); }
+ bool validDim(int dim) const { return (dim < Dim) && (dim >= 0); }
+ float sens(const GLV& g){ return (g.mouse.left() && g.mouse.right()) ? 0.25 : 1; }
+};
+
+
+
+/// A 1-D slider
+class Slider : public SliderBase<1>{
+public:
+
+ /// Constructor
+ Slider(const Rect& r=Rect(200,20), float val=0);
+
+ virtual void onDraw();
+ virtual bool onEvent(Event::t e, GLV & glv);
+};
+
+
+
+/// A 2-D slider
+class Slider2D : public SliderBase<2>{
+public:
+
+ /// Constructor
+ Slider2D(const Rect& r, float valX=0, float valY=0, space_t knobSize=12);
+
+ space_t knobSize; ///< Size of slider knob
+
+ virtual void onDraw();
+ virtual bool onEvent(Event::t e, GLV & glv);
+
+ static void drawKnob(const Slider2D& s);
+
+};
+
+
+
+/// A multi-parameter slider grid
+
+/// The cells of the grid represent all the pair permutations of parameters.
+/// The parameter values run from 0 to N, going left-to-right along the x-axis
+/// and bottom-to-top along th y-axis. Cells along the diagonal control the
+/// parameters individually.
+template <int Dim>
+class SliderGrid : public SliderBase<Dim>{
+public:
+ using SliderBase<Dim>::colors;
+ using SliderBase<Dim>::w;
+ using SliderBase<Dim>::h;
+ using SliderBase<Dim>::value;
+ using SliderBase<Dim>::clipAccs;
+ using SliderBase<Dim>::sens;
+
+ /// Constructor
+ SliderGrid(const Rect& r, space_t knobSize=4);
+
+ space_t knobSize; ///< Knob size
+
+ virtual void onDraw();
+ virtual bool onEvent(Event::t e, GLV& glv);
+
+protected:
+ int cx, cy;
+};
+
+
+
+// Implementation ______________________________________________________________
+
+template <int Nx, int Ny>
+Buttons<Nx, Ny>::Buttons(const Rect& r, bool mutExc, iconFunc on, iconFunc off)
+: ButtonBase<Nx*Ny>(r, !mutExc, on, off), cx(0), cy(0)
+{}
+
+
+template <int Nx, int Ny>
+int Buttons<Nx, Ny>::lastClicked() const{ return index(cx, cy); }
+
+
+template <int Nx, int Ny>
+void Buttons<Nx, Ny>::onDraw(){
+ using namespace glv::draw;
+
+ float wi = pix(w);
+ float hi = pix(h);
+ float wc = cellW();
+ float hc = cellH();
+
+ // draw the grid lines
+ color(colors().border);
+ lineWidth(1);
+ begin(Lines);
+ for(int x=1; x<Nx; ++x){
+ vertex(pix(x * wc), 0); vertex(pix(x * wc), hi);
+ }
+ for(int y=1; y<Ny; ++y){
+ vertex(0, pix(y * hc), 0); vertex(wi, pix(y * hc));
+ }
+ end();
+
+ for(int x=0; x<Nx; ++x){
+
+ float dx = x * wc + iconInset();
+
+ for(int y=0; y<Ny; ++y){
+
+ float dy = y * hc + iconInset();
+
+ if(value(index(x,y))){
+ color(colors().fore);
+ if(mIconOn) mIconOn(pix(dx), pix(dy), pix(dx+iconW()), pix(dy+iconH()+0.5));
+ }
+ else{
+ color(colors().fore);
+ if(mIconOff) mIconOff(pix(dx), pix(dy), pix(dx+iconW()), pix(dy+iconH()+0.5));
+ }
+ }
+ }
+}
+
+template <int Nx, int Ny>
+bool Buttons<Nx, Ny>::onEvent(Event::t e, GLV& g){
+ switch(e){
+ case Event::MouseDown:
+ if(g.mouse.left()){
+ cx = (int)((g.mouse.xRel() / w) * Nx);
+ cy = (int)((g.mouse.yRel() / h) * Ny);
+ cx < 0 ? cx=0 : cx>=Nx ? cx=Nx-1 : 0;
+ cy < 0 ? cy=0 : cy>=Ny ? cy=Ny-1 : 0;
+
+ if(!toggles()){ valueMin(); value(true, index(cx, cy)); }
+ else value(!value(index(cx, cy)), index(cx, cy));
+ return false;
+ }
+ default: break;
+ }
+ return true;
+}
+
+
+
+// SliderBase
+
+template <int Dim>
+SliderBase<Dim>::SliderBase(const Rect& r)
+: View(r)
+{
+ memset(mAcc, 0, sizeof(float) * Dim);
+ memset(mVal, 0, sizeof(float) * Dim);
+}
+
+template <int Dim>
+inline void SliderBase<Dim>::valueAdd(float add, int dim){
+ if(!validDim(dim)) return;
+ float acc = mAcc[dim] + add;
+ mAcc[dim] = mVal[dim] = acc;
+ clip(mVal[dim]); // clip in [0, 1]
+}
+
+template <int Dim>
+inline float SliderBase<Dim>::value(int dim) const{
+ return validDim(dim) ? mVal[dim] : 0;
+}
+
+template <int Dim>
+inline void SliderBase<Dim>::valueMid(){
+ for(int i=0; i<Dim; ++i) mVal[i] = mAcc[i] = 0.5;
+}
+
+template <int Dim>
+inline void SliderBase<Dim>::valueMax(){
+ for(int i=0; i<Dim; ++i) mVal[i] = mAcc[i] = 1;
+}
+
+template <int Dim>
+inline void SliderBase<Dim>::value(float value, int dim){
+ if(validDim(dim)) mVal[dim] = mAcc[dim] = value;
+}
+
+
+
+template <int Dim>
+SliderGrid<Dim>::SliderGrid(const Rect& r, space_t knobSize)
+: SliderBase<Dim>(r), knobSize(knobSize), cx(0), cy(0)
+{
+ //this->cropSelf = false;
+ this->disable(CropSelf);
+}
+
+template <int Dim>
+void SliderGrid<Dim>::onDraw(){
+ using namespace glv::draw;
+
+ float rDim = 1./Dim;
+ color(colors().fore);
+ lineWidth(1);
+ frame(cx * w * rDim, (Dim-cy-1) * h * rDim, (cx+1) * w * rDim, (Dim-cy) * h * rDim);
+ enable(LineStipple);
+ lineStipple(1, 0xAAAA);
+ grid(0,0,w,h,Dim,Dim, false);
+ shape(Lines,0,h,w,0);
+ disable(LineStipple);
+
+ pointSize(knobSize);
+ begin(Points);
+ for(int i=0; i<Dim; ++i){
+ float f = (i+value(i)) * rDim;
+ float x = f*w;
+ //float y = f*h;
+
+ for(int j=0; j<Dim; ++j){
+ vertex(x, (1.-(j+value(j)) * rDim) * h);
+ }
+ }
+ end();
+}
+
+template <int Dim>
+bool SliderGrid<Dim>::onEvent(Event::t e, GLV& g){
+
+ switch(e){
+ case Event::MouseDrag:
+ valueAdd( g.mouse.dx()/w * sens(g) * Dim, cx);
+ if(cx!=cy) valueAdd(-g.mouse.dy()/h * sens(g) * Dim, cy);
+ break;
+
+ case Event::MouseDown:
+ cx = (int)((g.mouse.xRel() / w) * Dim);
+ cy = (int)((g.mouse.yRel() / h) * Dim);
+ cy = (Dim-1) - cy;
+ cx < 0 ? cx=0 : cx>=Dim ? cx=Dim-1 : 0;
+ cy < 0 ? cy=0 : cy>=Dim ? cy=Dim-1 : 0;
+
+ if(g.mouse.left() && !g.mouse.right()){
+ float cw = w/Dim;
+ float ch = h/Dim;
+ value( (g.mouse.xRel()/cw - cx), cx);
+ if(cx!=cy) value(1.f - (g.mouse.yRel()/ch - ((Dim-1)-cy)), cy);
+ }
+ break;
+
+ case Event::MouseUp: clipAccs(); break;
+ default: break;
+ }
+ return false;
+}
+
+
+
+} // glv::
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_texture.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_texture.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,31 @@
+#ifndef INC_GLV_TEXTURE_H
+#define INC_GLV_TEXTURE_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include "glv_conf.h"
+
+namespace glv{
+
+class Texture2D{
+public:
+ Texture2D(GLsizei width, GLsizei height, bool doesLoad=false);
+ virtual ~Texture2D();
+
+ GLsizei width(){ return w; }
+ GLsizei height(){ return h; }
+
+ void bind(){ glBindTexture(GL_TEXTURE_2D, mID); } // Bind self to current context.
+ void load(GLsizei w, GLsizei h, const GLvoid * pixels = 0); // Resizes texture on graphics card.
+ void reload(){ load(w,h); }
+
+private:
+ GLuint mID;
+ GLsizei w, h;
+};
+
+
+} //glv::
+
+#endif

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_textview.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_textview.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,42 @@
+#ifndef INC_GLV_TEXTVIEW_H
+#define INC_GLV_TEXTVIEW_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+#include <string>
+#include <string.h>
+#include "glv_core.h"
+
+namespace glv{
+
+/// Basic label widget
+class Label : public View{
+public:
+
+ Label(const std::string str, bool vert);
+
+ /// @param[in] str Label string
+ /// @param[in] l Left position
+ /// @param[in] t Top position
+ /// @param[in] vert Whether to draw label vertically
+ Label(const std::string str, space_t l=0, space_t t=0, bool vert=false);
+
+ Label& label(const std::string& s);
+ Label& size(float pixels);
+ Label& vertical(bool v);
+
+ virtual void onDraw();
+
+protected:
+ std::string mLabel; // The label string
+ float mSize;
+ bool mVertical;
+
+ void fitExtent();
+ void rotateRect(); // swap between vertical and horizontal
+};
+
+} // glv::
+
+#endif

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_util.h
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glv/glv_util.h 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,48 @@
+#ifndef INC_GLV_UTIL_H
+#define INC_GLV_UTIL_H
+
+/* Graphics Library of Views (GLV) - GUI Building Toolkit
+ See COPYRIGHT file for authors and license information */
+
+namespace glv {
+
+/// Smart pointer functionality to avoid deleting references.
+
+/// When a class contains pointers to other objects, sometimes it is not clear
+/// if it is responsible for freeing the memory associated with those objects.
+class SmartPointer{
+public:
+
+ /// @param[in] del whether the object is deleted with smartDelete()
+ SmartPointer(bool del=true): mDeletable(del){}
+
+ /// Deletes object only if it is deletable, i.e. not a reference.
+ void smartDelete(){
+ //printf("%p %c\n", this, mDeletable ? 'y' : 'n');
+ if(true == mDeletable) delete this;
+ }
+
+ /// Set whether the object can be deleted.
+ void deletable(bool v){ mDeletable = v; }
+
+ /// Returns whether the object can be deleted.
+ bool deletable(){ return mDeletable; }
+
+// void operator delete (void * p){
+//
+// SmartPointer * pc = static_cast<SmartPointer *>(p);
+// if(pc && pc->mIsDeletable){
+// free(pc);
+// printf("freed\n");
+// }
+// else printf("denied\n");
+// }
+
+private:
+ bool mDeletable;
+};
+
+} // end namespace glv
+
+#endif
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_example.cpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,99 @@
+//[ cppgui_example
+
+// 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_binding_glut.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(int)
+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),0)
+ {
+ anchor(glv::Place::CL);
+ }
+ void operator()(float x)
+ {
+ std::cout <<"val: " << x << std::endl;
+ value(x, 0);
+ out(x);
+ }
+};
+
+// A regular Dataflow.Signals component, receives void(int)
+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),0)
+ {
+ anchor(glv::Place::CL);
+ }
+public:
+ bool onEvent(glv::Event::t e, glv::GLV& glv)
+ {
+ bool response = glv::Slider::onEvent(e, glv);
+ std::cout <<"preval: " << value(0) << std::endl;
+ out(value(0));
+ 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");
+ // A filter that doubles
+ add_component<signals::function<void (float), float(float)> >
+ ("x2", boost::function<float(float)>(boost::bind(std::multiplies<float>(), _1, 2)));
+ }
+};
+
+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();
+}
+
+//]
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/glv_gui/glvgui_logic.cpp 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -0,0 +1,86 @@
+//[ cppgui_example
+
+// 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_binding_glut.h>
+
+#include "blueprint_bank.hpp"
+#include "blueprint_window.hpp"
+
+#include <boost/dataflow/managed/fusion_component.hpp>
+#include <boost/dataflow/managed/network.hpp>
+#include <boost/dataflow/managed/runtime_support.hpp>
+#include <boost/assign/std/vector.hpp>
+#include <boost/dataflow/blueprint/component_bank.hpp>
+
+namespace df=boost::dataflow;
+namespace blueprint=boost::dataflow::blueprint;
+
+using df::managed::fusion_component;
+
+// source just provides an output port
+class source : public fusion_component<bool>
+{
+public:
+ source(df::managed::network &network)
+ : fusion_component<bool>(network)
+ {
+// m_producer_port.set(value);
+ }
+};
+
+// adder has two input ports and an output port.
+// invoking adds the two inputs into the output.
+class not_operation : public fusion_component<bool>
+{
+public:
+ not_operation(df::managed::network &network)
+ : fusion_component<bool>(network)
+ {}
+ void invoke()
+ {
+ m_producer_port.set(!m_consumer_port.get());
+ }
+};
+
+
+
+// A component_bank with some components
+class example_bank : public blueprint::tag_component_bank<df::managed::tag>
+{
+public:
+ example_bank()
+ {
+ add_component<source>("src", m_network);
+ add_component<not_operation>("not", m_network);
+ }
+private:
+ df::managed::network m_network;
+};
+
+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();
+}
+
+//]
+

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/blueprint/Jamfile.v2 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -9,9 +9,11 @@
     : requirements
       <include>../../../..
       <library>/boost/signals//boost_signals/<link>static
+ <library>../../build/managed//dataflow_managed/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
 
 run test_port.cpp ;
+run test_managed_port.cpp ;
 run test_component.cpp ;
 run test_dynamic_port.cpp ;

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/managed/Jamfile
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/managed/Jamfile (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/managed/Jamfile 2008-07-12 18:15:34 EDT (Sat, 12 Jul 2008)
@@ -9,8 +9,10 @@
     : requirements
       <include>../../../..
       <define>BOOST_ALL_NO_LIB=1
+# <library>/dataflow/managed//dataflow_managed/<link>static
+ <library>../../build/managed//dataflow_managed/<link>static
     ;
 
 run test_port.cpp ;
 run test_network.cpp ;
-
+run test_fusion_component.cpp ;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk