summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-12 18:13:03 +0000
committerDavid Robillard <d@drobilla.net>2007-03-12 18:13:03 +0000
commitcd3dffb1d8838e813cfbf58d27e212db7f8eb0af (patch)
tree62ab746043feb0e70c3335c548c7fdc1d741a31c /src/progs
parent6d03649eb75291abf2900a062ed0b7dcdb5dca86 (diff)
downloadingen-cd3dffb1d8838e813cfbf58d27e212db7f8eb0af.tar.gz
ingen-cd3dffb1d8838e813cfbf58d27e212db7f8eb0af.tar.bz2
ingen-cd3dffb1d8838e813cfbf58d27e212db7f8eb0af.zip
Removed name-based interface for FlowCanvas (using the view as a model = evil), related performance improvements (especially for Machina).
Updates for FlowCanvas API changes. Machina SMF import performance improvements (temporarily disabled node labels). git-svn-id: http://svn.drobilla.net/lad/ingen@356 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/ingenuity/NodeModule.cpp4
-rw-r--r--src/progs/ingenuity/NodeModule.h3
-rw-r--r--src/progs/ingenuity/PatchCanvas.cpp103
-rw-r--r--src/progs/ingenuity/PatchCanvas.h16
-rw-r--r--src/progs/ingenuity/PatchPortModule.cpp4
-rw-r--r--src/progs/ingenuity/PatchPortModule.h7
6 files changed, 71 insertions, 66 deletions
diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp
index 971dfa6b..c927114d 100644
--- a/src/progs/ingenuity/NodeModule.cpp
+++ b/src/progs/ingenuity/NodeModule.cpp
@@ -90,7 +90,9 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n
void
NodeModule::add_port(SharedPtr<PortModel> port, bool resize_to_fit)
{
- Module::add_port(boost::shared_ptr<Port>(new Port(shared_from_this(), port)));
+ Module::add_port(boost::shared_ptr<Port>(new Port(
+ PtrCast<NodeModule>(shared_from_this()), port)));
+
if (resize_to_fit)
resize();
}
diff --git a/src/progs/ingenuity/NodeModule.h b/src/progs/ingenuity/NodeModule.h
index f3ca4cbc..77829e93 100644
--- a/src/progs/ingenuity/NodeModule.h
+++ b/src/progs/ingenuity/NodeModule.h
@@ -18,7 +18,6 @@
#define NODEMODULE_H
#include <string>
-#include <boost/enable_shared_from_this.hpp>
#include <libgnomecanvasmm.h>
#include <flowcanvas/Module.h>
#include "raul/SharedPtr.h"
@@ -48,7 +47,7 @@ class Port;
*
* \ingroup Ingenuity
*/
-class NodeModule : public boost::enable_shared_from_this<NodeModule>, public LibFlowCanvas::Module
+class NodeModule : public LibFlowCanvas::Module
{
public:
static boost::shared_ptr<NodeModule> create (boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node);
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp
index c15ba4b8..0835bb97 100644
--- a/src/progs/ingenuity/PatchCanvas.cpp
+++ b/src/progs/ingenuity/PatchCanvas.cpp
@@ -108,7 +108,7 @@ PatchCanvas::build()
// Create pseudo modules for ports (ports on this canvas, not on our module)
for (PortModelList::const_iterator i = _patch->ports().begin();
i != _patch->ports().end(); ++i) {
- add_item(PatchPortModule::create(shared_this, *i));
+ add_port(*i);
}
// Create connections
@@ -126,17 +126,26 @@ PatchCanvas::add_node(SharedPtr<NodeModel> nm)
boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this());
SharedPtr<PatchModel> pm = PtrCast<PatchModel>(nm);
+ SharedPtr<NodeModule> module;
if (pm)
- add_item(SubpatchModule::create(shared_this, pm));
+ module = SubpatchModule::create(shared_this, pm);
else
- add_item(NodeModule::create(shared_this, nm));
+ module = NodeModule::create(shared_this, nm);
+
+ add_item(module);
+ _views.insert(std::make_pair(nm, module));
}
void
PatchCanvas::remove_node(SharedPtr<NodeModel> nm)
{
- remove_item(nm->path().name()); // should cut all references
+ Views::iterator i = _views.find(nm);
+
+ if (i != _views.end()) {
+ remove_item(i->second);
+ _views.erase(i);
+ }
}
@@ -146,37 +155,50 @@ PatchCanvas::add_port(SharedPtr<PortModel> pm)
boost::shared_ptr<PatchCanvas> shared_this =
boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this());
- add_item(PatchPortModule::create(shared_this, pm));
+ SharedPtr<PatchPortModule> view = PatchPortModule::create(shared_this, pm);
+ _views.insert(std::make_pair(pm, view));
+ add_item(view);
}
void
PatchCanvas::remove_port(SharedPtr<PortModel> pm)
{
- remove_item(pm->path().name()); // should cut all references
+ Views::iterator i = _views.find(pm);
+
+ if (i != _views.end()) {
+ remove_item(i->second);
+ _views.erase(i);
+ }
}
-void
-PatchCanvas::connection(SharedPtr<ConnectionModel> cm)
+SharedPtr<LibFlowCanvas::Port>
+PatchCanvas::get_port_view(SharedPtr<PortModel> port)
{
- // Deal with port "anonymous nodes" for this patch's own ports...
- const Path& src_parent_path = cm->src_port_path().parent();
- const Path& dst_parent_path = cm->dst_port_path().parent();
-
- const string& src_parent_name = (src_parent_path == _patch->path())
- ? cm->src_port_path().name()
- : src_parent_path.name();
+ SharedPtr<LibFlowCanvas::Port> ret;
+ SharedPtr<LibFlowCanvas::Module> module = _views[port];
+
+ // Port on this patch
+ if (module) {
+ ret = (PtrCast<PatchPortModule>(module))
+ ? *(PtrCast<PatchPortModule>(module)->ports().begin())
+ : PtrCast<LibFlowCanvas::Port>(module);
+ } else {
+ module = PtrCast<NodeModule>(_views[port->parent()]);
+ if (module)
+ ret = module->get_port(port->path().name());
+ }
+
+ return ret;
+}
- const string& dst_parent_name = (dst_parent_path == _patch->path())
- ? cm->dst_port_path().name()
- : dst_parent_path.name();
- 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());
-
- cerr << "SPN: " << src_parent_name << endl;
- cerr << "DPN: " << dst_parent_name << endl;
+void
+PatchCanvas::connection(SharedPtr<ConnectionModel> cm)
+{
+ const SharedPtr<LibFlowCanvas::Port> src = get_port_view(cm->src_port());
+ const SharedPtr<LibFlowCanvas::Port> dst = get_port_view(cm->dst_port());
if (src && dst)
add_connection(boost::shared_ptr<Connection>(new Connection(shared_from_this(), cm, src, dst, src->color() + 0xFFFFFF00)));
@@ -187,41 +209,16 @@ PatchCanvas::connection(SharedPtr<ConnectionModel> cm)
void
-PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path)
+PatchCanvas::disconnection(SharedPtr<ConnectionModel> cm)
{
- // Deal with port "anonymous nodes" for this patch's own ports...
- const Path& src_parent_path = src_port_path.parent();
- const Path& dst_parent_path = dst_port_path.parent();
-
- const string& src_parent_name = (src_parent_path == _patch->path())
- ? src_port_path.name()
- : src_parent_path.name();
-
- const string& dst_parent_name = (dst_parent_path == _patch->path())
- ? dst_port_path.name()
- : dst_parent_path.name();
-
- cerr << "SPN: " << src_parent_name << endl;
- cerr << "DPN: " << dst_parent_name << endl;
-
- boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, src_port_path.name());
- boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, dst_port_path.name());
-
+ const SharedPtr<LibFlowCanvas::Port> src = get_port_view(cm->src_port());
+ const SharedPtr<LibFlowCanvas::Port> dst = get_port_view(cm->dst_port());
+
if (src && dst)
remove_connection(src, dst);
else
cerr << "[PatchCanvas] ERROR: Unable to find ports to disconnect "
- << src_port_path << " -> " << dst_port_path << endl;
-
- cerr << "FIXME: disconnection control window stuff\n";
- /*
- // Enable control slider in destination node control window
- PortController* p = (PortController)Store::instance().port(dst_port_path)->controller();
- assert(p);
-
- if (p->control_panel())
- p->control_panel()->enable_port(p->path());
- */
+ << cm->src_port_path() << " -> " << cm->dst_port_path() << endl;
}
diff --git a/src/progs/ingenuity/PatchCanvas.h b/src/progs/ingenuity/PatchCanvas.h
index 56b463eb..f76e0c94 100644
--- a/src/progs/ingenuity/PatchCanvas.h
+++ b/src/progs/ingenuity/PatchCanvas.h
@@ -19,11 +19,12 @@
#define PATCHCANVAS_H
#include <string>
+#include <map>
#include <boost/shared_ptr.hpp>
#include <flowcanvas/FlowCanvas.h>
#include <flowcanvas/Module.h>
-#include "raul/SharedPtr.h"
-#include "raul/Path.h"
+#include <raul/SharedPtr.h>
+#include <raul/Path.h>
#include "ConnectionModel.h"
#include "PatchModel.h"
#include "NodeModule.h"
@@ -54,10 +55,10 @@ public:
virtual ~PatchCanvas() {}
- boost::shared_ptr<NodeModule> find_module(const string& name) {
+ /*boost::shared_ptr<NodeModule> find_module(const string& name) {
return boost::dynamic_pointer_cast<NodeModule>(
FlowCanvas::get_item(name));
- }
+ }*/
void build();
@@ -66,7 +67,7 @@ public:
void add_port(SharedPtr<PortModel> pm);
void remove_port(SharedPtr<PortModel> pm);
void connection(SharedPtr<ConnectionModel> cm);
- void disconnection(const Path& src_port_path, const Path& dst_port_path);
+ void disconnection(SharedPtr<ConnectionModel> cm);
void get_new_module_location(double& x, double& y);
@@ -87,6 +88,8 @@ private:
bool canvas_event(GdkEvent* event);
+ SharedPtr<LibFlowCanvas::Port> get_port_view(SharedPtr<PortModel> port);
+
void connect(boost::shared_ptr<LibFlowCanvas::Connectable> src,
boost::shared_ptr<LibFlowCanvas::Connectable> dst);
@@ -95,6 +98,9 @@ private:
SharedPtr<PatchModel> _patch;
+ typedef std::map<SharedPtr<ObjectModel>, SharedPtr<LibFlowCanvas::Module> > Views;
+ Views _views;
+
int _last_click_x;
int _last_click_y;
diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp
index 17633939..048d0ee7 100644
--- a/src/progs/ingenuity/PatchPortModule.cpp
+++ b/src/progs/ingenuity/PatchPortModule.cpp
@@ -72,10 +72,10 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod
ret->_patch_port = boost::shared_ptr<Port>(new Port(ret, port, true, true));
ret->add_port(ret->_patch_port);
- ret->resize();
-
for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m)
ret->metadata_update(m->first, m->second);
+
+ ret->resize();
return ret;
}
diff --git a/src/progs/ingenuity/PatchPortModule.h b/src/progs/ingenuity/PatchPortModule.h
index 05ad4f34..21455089 100644
--- a/src/progs/ingenuity/PatchPortModule.h
+++ b/src/progs/ingenuity/PatchPortModule.h
@@ -45,11 +45,12 @@ class Port;
*
* \ingroup Ingenuity
*/
-class PatchPortModule : public boost::enable_shared_from_this<LibFlowCanvas::Module>, public LibFlowCanvas::Module
+class PatchPortModule : public boost::enable_shared_from_this<LibFlowCanvas::Module>,
+ public LibFlowCanvas::Module
{
public:
- static boost::shared_ptr<PatchPortModule> create (boost::shared_ptr<PatchCanvas> canvas,
- SharedPtr<PortModel> port);
+ static boost::shared_ptr<PatchPortModule> create(boost::shared_ptr<PatchCanvas> canvas,
+ SharedPtr<PortModel> port);
virtual ~PatchPortModule() {}