diff options
Diffstat (limited to 'src/progs/ingenuity/PatchCanvas.cpp')
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index 6d8403eb..3f9c97fa 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -26,11 +26,14 @@ #include "LoadSubpatchWindow.h" #include "NewSubpatchWindow.h" #include "Port.h" +#include "Connection.h" #include "NodeModel.h" #include "NodeModule.h" #include "SubpatchModule.h" #include "GladeFactory.h" #include "WindowFactory.h" +#include "Serializer.h" +using Ingen::Client::Serializer; namespace Ingenuity { @@ -170,10 +173,14 @@ PatchCanvas::connection(CountedPtr<ConnectionModel> cm) boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, cm->src_port_path().name()); boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, cm->dst_port_path().name()); - if (src && dst) - add_connection(src, dst); - else + if (src && dst) { + boost::shared_ptr<Connection> c(new Connection(shared_from_this(), cm, src, dst)); + src->add_connection(c); + dst->add_connection(c); + add_connection(c); + } else { cerr << "[Canvas] ERROR: Unable to find ports to create connection." << endl; + } } @@ -293,7 +300,7 @@ PatchCanvas::canvas_event(GdkEvent* event) void -PatchCanvas::destroy_selected() +PatchCanvas::destroy_selection() { for (list<boost::shared_ptr<Module> >::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) { boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m); @@ -303,6 +310,32 @@ PatchCanvas::destroy_selected() } +void +PatchCanvas::copy_selection() +{ + Serializer serializer(App::instance().engine()); + serializer.start_to_string(); + + for (list<boost::shared_ptr<Module> >::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m) { + boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m); + if (module) + serializer.serialize(module->node()); + } + + for (list<boost::shared_ptr<LibFlowCanvas::Connection> >::iterator c = m_selected_connections.begin(); + c != m_selected_connections.end(); ++c) { + boost::shared_ptr<Connection> connection = boost::dynamic_pointer_cast<Connection>(*c); + if (connection) + serializer.serialize_connection(connection->model()); + } + + string result = serializer.finish(); + + Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); + clipboard->set_text(result); +} + + string PatchCanvas::generate_port_name(const string& base) { string name = base; |