diff options
author | David Robillard <d@drobilla.net> | 2015-10-26 17:36:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-26 17:36:03 +0000 |
commit | 1b005502bb4f3a271c514e46ce66d3b24b2a5f38 (patch) | |
tree | f76a0ef36c35138cde3a7170fa5b094d6cbd1f05 /src | |
parent | 128bdd836148ad902470d45f4eb36cb0a2045f4f (diff) | |
download | ganv-1b005502bb4f3a271c514e46ce66d3b24b2a5f38.tar.gz ganv-1b005502bb4f3a271c514e46ce66d3b24b2a5f38.tar.bz2 ganv-1b005502bb4f3a271c514e46ce66d3b24b2a5f38.zip |
Add support for edges that do not constrain the layout
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5792 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 11 | ||||
-rw-r--r-- | src/edge.c | 25 | ||||
-rw-r--r-- | src/ganv-private.h | 1 |
3 files changed, 35 insertions, 2 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 3c59351..7d79ffe 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -745,6 +745,9 @@ GanvCanvasImpl::layout_dot(const std::string& filename) ss << edge->impl->head << (flow_right ? ":w" : ":n"); agsafeset(e, (char*)"headport", (char*)ss.str().c_str(), (char*)""); } + if (!ganv_edge_get_constraining(edge)) { + agsafeset(e, (char*)"constraint", "false", (char*)""); + } } else { std::cerr << "Unable to find graphviz node" << std::endl; } @@ -861,8 +864,12 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) // Calculate attractive spring forces for edges FOREACH_EDGE(_edges, i) { const GanvEdge* const edge = *i; - GanvNode* tail = ganv_edge_get_tail(edge); - GanvNode* head = ganv_edge_get_head(edge); + if (!ganv_edge_get_constraining(edge)) { + continue; + } + + GanvNode* tail = ganv_edge_get_tail(edge); + GanvNode* head = ganv_edge_get_head(edge); if (GANV_IS_PORT(tail)) { tail = GANV_NODE(ganv_port_get_module(GANV_PORT(tail))); } @@ -47,6 +47,7 @@ enum { PROP_DASH_LENGTH, PROP_DASH_OFFSET, PROP_COLOR, + PROP_CONSTRAINING, PROP_CURVED, PROP_ARROWHEAD, PROP_SELECTED, @@ -72,6 +73,7 @@ ganv_edge_init(GanvEdge* edge) memset(&impl->coords, '\0', sizeof(GanvEdgeCoords)); impl->coords.width = 2.0; impl->coords.handle_radius = 4.0; + impl->coords.constraining = TRUE; impl->coords.curved = FALSE; impl->coords.arrowhead = FALSE; @@ -120,6 +122,7 @@ ganv_edge_set_property(GObject* object, SET_CASE(DASH_LENGTH, double, impl->dash_length); SET_CASE(DASH_OFFSET, double, impl->dash_offset); SET_CASE(COLOR, uint, impl->color); + SET_CASE(CONSTRAINING, boolean, impl->coords.constraining); SET_CASE(CURVED, boolean, impl->coords.curved); SET_CASE(ARROWHEAD, boolean, impl->coords.arrowhead); SET_CASE(SELECTED, boolean, impl->selected); @@ -151,6 +154,7 @@ ganv_edge_get_property(GObject* object, GET_CASE(DASH_LENGTH, double, impl->dash_length); GET_CASE(DASH_OFFSET, double, impl->dash_offset); GET_CASE(COLOR, uint, impl->color); + GET_CASE(CONSTRAINING, boolean, impl->coords.constraining); GET_CASE(CURVED, boolean, impl->coords.curved); GET_CASE(ARROWHEAD, boolean, impl->coords.arrowhead); GET_CASE(SELECTED, boolean, impl->selected); @@ -564,6 +568,14 @@ ganv_edge_class_init(GanvEdgeClass* klass) G_PARAM_READWRITE)); g_object_class_install_property( + gobject_class, PROP_CONSTRAINING, g_param_spec_boolean( + "constraining", + _("Constraining"), + _("Whether edge should constrain the layout."), + 1, + G_PARAM_READWRITE)); + + g_object_class_install_property( gobject_class, PROP_CURVED, g_param_spec_boolean( "curved", _("Curved"), @@ -653,6 +665,19 @@ ganv_edge_update_location(GanvEdge* edge) } gboolean +ganv_edge_get_constraining(const GanvEdge* edge) +{ + return edge->impl->coords.constraining; +} + +void +ganv_edge_set_constraining(GanvEdge* edge, gboolean constraining) +{ + edge->impl->coords.constraining = constraining; + ganv_edge_request_redraw(GANV_ITEM(edge), &edge->impl->coords); +} + +gboolean ganv_edge_get_curved(const GanvEdge* edge) { return edge->impl->coords.curved; diff --git a/src/ganv-private.h b/src/ganv-private.h index 93f286c..2cbe963 100644 --- a/src/ganv-private.h +++ b/src/ganv-private.h @@ -68,6 +68,7 @@ typedef struct { double cx1, cy1, cx2, cy2; double handle_x, handle_y, handle_radius; double width; + gboolean constraining; gboolean curved; gboolean arrowhead; } GanvEdgeCoords; |