From 9e2742aada3a2e92bf2ad58ee66a475289394181 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 26 Jun 2017 11:16:36 +0200 Subject: Fix a small memory leak in SPCanvas::paint Signed-off-by: Uli Schlachter --- src/display/sp-canvas.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d04c81ecb..84bdfb762 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1853,6 +1853,7 @@ int SPCanvas::paint() cairo_region_get_rectangle(to_draw, i, &crect); if (!paintRect(crect.x, crect.y, crect.x + crect.width, crect.y + crect.height)) { // Aborted + cairo_region_destroy(to_draw); return FALSE; }; } @@ -1862,6 +1863,8 @@ int SPCanvas::paint() _forced_redraw_count = 0; } + cairo_region_destroy(to_draw); + return TRUE; } -- cgit v1.2.3 From ae3562c58dbfc2c4b002a67828639ffc91e83749 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 26 Jun 2017 11:10:28 +0200 Subject: SPCanvas: Use a similar image for _backing_store Cairo 1.12 adds the function cairo_surface_create_similar_image(). It works just like cairo_image_surface_create() in that it creates an image surface. However, when the passed-in surface is a cairo-xlib surface, the data of the image surface will be allocated in a shared memory segment. This makes it cheaper to have the X11 server access the surface since it does not need to be uploaded. To make use of this, a new _surface_for_similar member is added. This member is set to a (useless) surface in handle_draw(). On Linux this creates a cairo-xlib surface, so that _backing_store is latter allocated in a shared memory segment. Signed-off-by: Uli Schlachter --- src/display/sp-canvas.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++---- src/display/sp-canvas.h | 4 ++++ 2 files changed, 51 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 84bdfb762..196a14069 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -966,6 +966,9 @@ static void sp_canvas_init(SPCanvas *canvas) canvas->_drawing_disabled = false; canvas->_backing_store = NULL; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + canvas->_surface_for_similar = NULL; +#endif canvas->_clean_region = cairo_region_create(); canvas->_background = cairo_pattern_create_rgb(1, 1, 1); canvas->_background_is_checkerboard = false; @@ -1003,6 +1006,12 @@ void SPCanvas::dispose(GObject *object) cairo_surface_destroy(canvas->_backing_store); canvas->_backing_store = NULL; } +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + if (canvas->_surface_for_similar) { + cairo_surface_destroy(canvas->_surface_for_similar); + canvas->_surface_for_similar = NULL; + } +#endif if (canvas->_clean_region) { cairo_region_destroy(canvas->_clean_region); canvas->_clean_region = NULL; @@ -1125,8 +1134,14 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation allocation->width, allocation->height); // resize backing store - cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - allocation->width, allocation->height); + cairo_surface_t *new_backing_store = NULL; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + if (canvas->_surface_for_similar != NULL) + new_backing_store = cairo_surface_create_similar_image(canvas->_surface_for_similar, + CAIRO_FORMAT_ARGB32, allocation->width, allocation->height); +#endif + if (new_backing_store == NULL) + new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation->width, allocation->height); if (canvas->_backing_store) { cairo_t *cr = cairo_create(new_backing_store); cairo_translate(cr, -canvas->_x0, -canvas->_y0); @@ -1764,6 +1779,28 @@ void SPCanvas::endForcedFullRedraws() gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { SPCanvas *canvas = SP_CANVAS(widget); +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + if (canvas->_surface_for_similar == NULL && canvas->_backing_store != NULL) { + canvas->_surface_for_similar = cairo_surface_create_similar( + cairo_get_target(cr), CAIRO_CONTENT_COLOR_ALPHA, 1, 1); + + // Reallocate backing store so that cairo can use shared memory + cairo_surface_t *new_backing_store = cairo_surface_create_similar_image( + canvas->_surface_for_similar, CAIRO_FORMAT_ARGB32, + cairo_image_surface_get_width(canvas->_backing_store), + cairo_image_surface_get_height(canvas->_backing_store)); + + // Copy the old backing store contents + cairo_t *cr = cairo_create(new_backing_store); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(cr, canvas->_backing_store, 0, 0); + cairo_paint(cr); + cairo_destroy(cr); + cairo_surface_destroy(canvas->_backing_store); + canvas->_backing_store = new_backing_store; + } +#endif + // Blit from the backing store, without regard for the clean region. // This is necessary because GTK clears the widget for us, which causes // severe flicker while drawing if we don't blit the old contents. @@ -1949,8 +1986,14 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol // adjust backing store contents assert(_backing_store); - cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - allocation.width, allocation.height); + cairo_surface_t *new_backing_store = NULL; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + if (_surface_for_similar != NULL) + new_backing_store = cairo_surface_create_similar_image( + _surface_for_similar, CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); +#endif + if (new_backing_store == NULL) + new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); cairo_t *cr = cairo_create(new_backing_store); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); // Paint the background diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index a2cbe0b27..92a50da11 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -179,6 +179,10 @@ public: /// Image surface storing the contents of the widget cairo_surface_t *_backing_store; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) + /// This should be e.g. a cairo-xlib surface that is used to allocate _backing_store; might be NULL. + cairo_surface_t *_surface_for_similar; +#endif /// Area of the widget that has up-to-date content cairo_region_t *_clean_region; /// Widget background, defaults to white -- cgit v1.2.3 From 6ef4b7cae493468892242aec8cdd3a5fb4e26d0e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 26 Jun 2017 10:31:45 +0200 Subject: SPCanvas::paintSingleBuffer: Draw directly to _backing_store Before this commit, this function creates a new cairo image surface, draws the tile that it was told to redraw to this buffer and then uses cairo to copy the drawn data at the right position inside of _backing_store. Thus, the drawn data was copied around at least once. This commit changes the code so that it draws directly to _backing_store: We get the information from _backing_store and then create a new image surface from this that covers just the part that we should redraw. Thus, one copy of the data is avoided. Signed-off-by: Uli Schlachter --- src/display/sp-canvas.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 196a14069..8857b8c68 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1525,8 +1525,23 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect buf.canvas_rect = canvas_rect; buf.is_empty = true; - // create temporary surface - cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height()); + // Make sure the following code does not go outside of _backing_store's data + assert(cairo_image_surface_get_format(_backing_store) == CAIRO_FORMAT_ARGB32); + assert(paint_rect.left() - _x0 >= 0); + assert(paint_rect.top() - _y0 >= 0); + assert(paint_rect.right() - _x0 <= cairo_image_surface_get_width(_backing_store)); + assert(paint_rect.bottom() - _y0 <= cairo_image_surface_get_height(_backing_store)); + + // Create a temporary surface that draws directly to _backing_store + cairo_surface_flush(_backing_store); + unsigned char *data = cairo_image_surface_get_data(_backing_store); + int stride = cairo_image_surface_get_stride(_backing_store); + // Move to the right row + data += stride * (paint_rect.top() - _y0); + // Move to the right pixel inside of that row + data += 4 * (paint_rect.left() - _x0); + cairo_surface_t *imgs = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, + paint_rect.width(), paint_rect.height(), stride); buf.ct = cairo_create(imgs); cairo_save(buf.ct); @@ -1567,16 +1582,7 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - //cairo_t *xct = gdk_cairo_create(gtk_widget_get_window (widget)); - cairo_t *xct = cairo_create(_backing_store); - cairo_translate(xct, paint_rect.left() - _x0, paint_rect.top() - _y0); - cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height()); - cairo_clip(xct); - cairo_set_source_surface(xct, imgs, 0, 0); - cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE); - cairo_paint(xct); - cairo_destroy(xct); - cairo_surface_destroy(imgs); + cairo_surface_mark_dirty(_backing_store); // Mark the painted rectangle clean markRect(paint_rect, 0); -- cgit v1.2.3 From 953aae6dd1af3511b2fd18540efcb0a933fffe62 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 1 Jul 2017 11:41:45 +0200 Subject: Fix a compiling error on debian testing --- src/ui/dialog/filter-editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp index 730f8175c..1b532578d 100644 --- a/src/ui/dialog/filter-editor.cpp +++ b/src/ui/dialog/filter-editor.cpp @@ -85,7 +85,7 @@ FilterEditorDialog::FilterEditorDialog() : UI::Widget::Panel("", "/dialogs/filte for(std::string w:req_widgets) { builder->get_widget(w,test); if(!test){ - g_warning("Required widget %s does not exist", w); + g_warning("Required widget %s does not exist", w.c_str()); return; } } -- cgit v1.2.3 From fd733201b82f39655488a286c89142f321ef9dc9 Mon Sep 17 00:00:00 2001 From: Sylvain Chiron Date: Sat, 1 Jul 2017 13:36:41 +0200 Subject: Updated libs from the Adaptagrams project: libavoid, libcola and libvspc; changed the code to match the new API Signed-off-by: Sylvain Chiron --- src/conn-avoid-ref.cpp | 15 +- src/graphlayout.cpp | 193 +- src/libavoid/CMakeLists.txt | 21 + src/libavoid/Doxyfile | 1867 ++ src/libavoid/LICENSE.LGPL | 460 + src/libavoid/Makefile.am | 91 + src/libavoid/README | 31 +- src/libavoid/actioninfo.cpp | 187 + src/libavoid/actioninfo.h | 88 + src/libavoid/assertions.h | 15 +- src/libavoid/connectionpin.cpp | 476 + src/libavoid/connectionpin.h | 303 + src/libavoid/connector.cpp | 1902 +- src/libavoid/connector.h | 462 +- src/libavoid/connend.cpp | 434 + src/libavoid/connend.h | 267 + src/libavoid/debug.h | 70 +- src/libavoid/debughandler.h | 138 + src/libavoid/dllexport.h | 39 + src/libavoid/doc/description.doc | 73 + src/libavoid/doc/example.doc | 122 + src/libavoid/doc/header.html | 19 + src/libavoid/geometry.cpp | 89 +- src/libavoid/geometry.h | 12 +- src/libavoid/geomtypes.cpp | 306 +- src/libavoid/geomtypes.h | 123 +- src/libavoid/graph.cpp | 387 +- src/libavoid/graph.h | 59 +- src/libavoid/hyperedge.cpp | 388 + src/libavoid/hyperedge.h | 223 + src/libavoid/hyperedgeimprover.cpp | 1231 + src/libavoid/hyperedgeimprover.h | 159 + src/libavoid/hyperedgetree.cpp | 821 + src/libavoid/hyperedgetree.h | 143 + src/libavoid/junction.cpp | 232 + src/libavoid/junction.h | 197 + src/libavoid/libavoid.h | 18 +- src/libavoid/libavoid.pc.in | 12 + src/libavoid/libavoid.sln | 196 + src/libavoid/libavoid.vcxproj | 195 + src/libavoid/makefile.in | 17 - src/libavoid/makepath.cpp | 1431 +- src/libavoid/makepath.h | 20 +- src/libavoid/mtst.cpp | 1095 + src/libavoid/mtst.h | 134 + src/libavoid/obstacle.cpp | 355 + src/libavoid/obstacle.h | 150 + src/libavoid/orthogonal.cpp | 2980 ++- src/libavoid/orthogonal.h | 6 +- src/libavoid/router.cpp | 2235 +- src/libavoid/router.h | 697 +- src/libavoid/scanline.cpp | 561 + src/libavoid/scanline.h | 136 + src/libavoid/shape.cpp | 401 +- src/libavoid/shape.h | 129 +- src/libavoid/tests/2junctions.cpp | 108 + src/libavoid/tests/Makefile.am | 217 + src/libavoid/tests/buildOrthogonalChannelInfo1.cpp | 65 + src/libavoid/tests/checkpointNudging1.cpp | 2592 ++ src/libavoid/tests/checkpointNudging2.cpp | 2606 ++ src/libavoid/tests/checkpointNudging3.cpp | 5242 ++++ src/libavoid/tests/checkpoints01.cpp | 62 + src/libavoid/tests/checkpoints02.cpp | 105 + src/libavoid/tests/checkpoints03.cpp | 96 + src/libavoid/tests/complex.cpp | 107 + src/libavoid/tests/connectionpin01.cpp | 68 + src/libavoid/tests/connectionpin02.cpp | 113 + src/libavoid/tests/connectionpin03.cpp | 328 + src/libavoid/tests/connendmove.cpp | 85 + src/libavoid/tests/corneroverlap01.cpp | 154 + src/libavoid/tests/endlessLoop01.cpp | 142 + src/libavoid/tests/example.cpp | 81 + src/libavoid/tests/finalSegmentNudging1.cpp | 5227 ++++ src/libavoid/tests/finalSegmentNudging2.cpp | 397 + src/libavoid/tests/finalSegmentNudging3.cpp | 2658 ++ src/libavoid/tests/forwardFlowingConnectors01.cpp | 380 + src/libavoid/tests/freeFloatingDirection01.cpp | 3321 +++ src/libavoid/tests/hola01.cpp | 1006 + src/libavoid/tests/hyperedge01.cpp | 285 + src/libavoid/tests/hyperedge02.cpp | 99 + src/libavoid/tests/hyperedgeLoop1.cpp | 87 + src/libavoid/tests/hyperedgeRerouting01.cpp | 150 + src/libavoid/tests/improveHyperedge01.cpp | 109 + src/libavoid/tests/improveHyperedge02.cpp | 90 + src/libavoid/tests/improveHyperedge03.cpp | 90 + src/libavoid/tests/improveHyperedge04.cpp | 113 + src/libavoid/tests/improveHyperedge05.cpp | 154 + src/libavoid/tests/improveHyperedge06.cpp | 92 + src/libavoid/tests/infinity.cpp | 26 + src/libavoid/tests/inline.cpp | 73 + src/libavoid/tests/inlineOverlap09.cpp | 401 + src/libavoid/tests/inlineOverlap10.cpp | 93 + src/libavoid/tests/inlineOverlap11.cpp | 187 + src/libavoid/tests/inlineShapes.cpp | 97 + src/libavoid/tests/inlineoverlap01.cpp | 25 + src/libavoid/tests/inlineoverlap02.cpp | 62 + src/libavoid/tests/inlineoverlap03.cpp | 55 + src/libavoid/tests/inlineoverlap04.cpp | 62 + src/libavoid/tests/inlineoverlap05.cpp | 69 + src/libavoid/tests/inlineoverlap06.cpp | 62 + src/libavoid/tests/inlineoverlap07.cpp | 75 + src/libavoid/tests/inlineoverlap08.cpp | 120 + src/libavoid/tests/junction01.cpp | 55 + src/libavoid/tests/junction02.cpp | 55 + src/libavoid/tests/junction03.cpp | 55 + src/libavoid/tests/junction04.cpp | 100 + src/libavoid/tests/latesetup.cpp | 94 + src/libavoid/tests/lineSegWrapperCrash1.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash2.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash3.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash4.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash5.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash6.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash7.cpp | 1884 ++ src/libavoid/tests/lineSegWrapperCrash8.cpp | 1884 ++ src/libavoid/tests/msctests/2junctions.vcxproj | 152 + .../msctests/buildOrthogonalChannelInfo1.vcxproj | 152 + .../tests/msctests/checkpointNudging1.vcxproj | 152 + .../tests/msctests/checkpointNudging2.vcxproj | 152 + src/libavoid/tests/msctests/checkpoints01.vcxproj | 152 + .../tests/msctests/connectionpin01.vcxproj | 152 + .../tests/msctests/connectionpin02.vcxproj | 152 + .../tests/msctests/connectionpin03.vcxproj | 152 + src/libavoid/tests/msctests/connendmove.vcxproj | 152 + .../tests/msctests/corneroverlap01.vcxproj | 152 + src/libavoid/tests/msctests/example.vcxproj | 152 + .../tests/msctests/finalSegmentNudging1.vcxproj | 152 + .../tests/msctests/finalSegmentNudging2.vcxproj | 152 + .../tests/msctests/finalSegmentNudging3.vcxproj | 152 + .../tests/msctests/freeFloatingDirection01.vcxproj | 152 + src/libavoid/tests/msctests/junction01.vcxproj | 152 + src/libavoid/tests/multiconnact.cpp | 75 + src/libavoid/tests/node1.cpp | 68 + src/libavoid/tests/nudgeCrossing01.cpp | 2665 ++ src/libavoid/tests/nudgeintobug.cpp | 40 + src/libavoid/tests/nudgeold.cpp | 80 + src/libavoid/tests/nudgingSkipsCheckpoint01.cpp | 1507 ++ src/libavoid/tests/nudgingSkipsCheckpoint02.cpp | 3054 +++ src/libavoid/tests/orderassertion.cpp | 1720 ++ src/libavoid/tests/orthordering01.cpp | 92 + src/libavoid/tests/orthordering02.cpp | 92 + src/libavoid/tests/output/README.txt | 1 + src/libavoid/tests/overlappingRects.cpp | 2327 ++ src/libavoid/tests/penaltyRerouting01.cpp | 369 + src/libavoid/tests/performance01.cpp | 7665 ++++++ src/libavoid/tests/reallyslowrouting.cpp | 7099 +++++ src/libavoid/tests/removeJunctions01.cpp | 103 + src/libavoid/tests/restrictedNudging.cpp | 68 + src/libavoid/tests/slowrouting.cpp | 1459 ++ src/libavoid/tests/tjunct.cpp | 48 + src/libavoid/tests/treeRootCrash01.cpp | 140 + src/libavoid/tests/treeRootCrash02.cpp | 243 + src/libavoid/tests/unsatisfiableRangeAssertion.cpp | 25789 ++++++++++++++++++ src/libavoid/tests/validPaths01.cpp | 457 + src/libavoid/tests/validPaths02.cpp | 53 + src/libavoid/tests/vertlineassertion.cpp | 2214 ++ src/libavoid/timer.cpp | 178 +- src/libavoid/timer.h | 74 +- src/libavoid/vertices.cpp | 237 +- src/libavoid/vertices.h | 94 +- src/libavoid/viscluster.cpp | 60 +- src/libavoid/viscluster.h | 91 +- src/libavoid/visibility.cpp | 234 +- src/libavoid/visibility.h | 11 +- src/libavoid/vpsc.cpp | 477 +- src/libavoid/vpsc.h | 130 +- src/libcola/CMakeLists.txt | 14 +- src/libcola/Makefile.am | 60 + src/libcola/box.cpp | 111 + src/libcola/box.h | 82 + src/libcola/cc_clustercontainmentconstraints.cpp | 194 + src/libcola/cc_clustercontainmentconstraints.h | 52 + src/libcola/cc_nonoverlapconstraints.cpp | 647 + src/libcola/cc_nonoverlapconstraints.h | 98 + src/libcola/cluster.cpp | 719 + src/libcola/cluster.h | 371 + src/libcola/cola.cpp | 829 +- src/libcola/cola.h | 1031 +- src/libcola/cola_log.h | 203 + src/libcola/colafd.cpp | 1490 ++ src/libcola/commondefs.h | 103 + src/libcola/compound_constraints.cpp | 1671 ++ src/libcola/compound_constraints.h | 827 + src/libcola/conjugate_gradient.cpp | 124 +- src/libcola/conjugate_gradient.h | 35 +- src/libcola/connected_components.cpp | 88 +- src/libcola/connected_components.h | 54 + src/libcola/convex_hull.cpp | 129 + src/libcola/convex_hull.h | 31 + src/libcola/cycle_detector.cpp | 249 - src/libcola/cycle_detector.h | 55 - src/libcola/defs.h | 132 - src/libcola/doc/description.doc | 50 + src/libcola/exceptions.h | 54 + src/libcola/gradient_projection.cpp | 614 +- src/libcola/gradient_projection.h | 388 +- src/libcola/libcola.pc.in | 11 + src/libcola/output_svg.cpp | 389 + src/libcola/output_svg.h | 80 + src/libcola/pseudorandom.cpp | 48 + src/libcola/pseudorandom.h | 44 + src/libcola/shapepair.cpp | 47 + src/libcola/shapepair.h | 47 + src/libcola/shortest_paths.cpp | 102 - src/libcola/shortest_paths.h | 248 +- src/libcola/sparse_matrix.h | 140 + src/libcola/straightener.cpp | 759 +- src/libcola/straightener.h | 484 +- src/libcola/tests/FixedRelativeConstraint01.cpp | 51 + src/libcola/tests/Makefile.am | 68 + src/libcola/tests/StillOverlap01.cpp | 221 + src/libcola/tests/StillOverlap02.cpp | 1863 ++ src/libcola/tests/boundary.cpp | 121 + src/libcola/tests/connected_components.cpp | 69 + src/libcola/tests/constrained.cpp | 99 + src/libcola/tests/containment.cpp | 89 + src/libcola/tests/containment2.cpp | 157 + src/libcola/tests/convex_hull.cpp | 180 + src/libcola/tests/cycle_detector.cpp | 386 + src/libcola/tests/data/1138_bus.txt | 1458 ++ src/libcola/tests/data/uetzNetworkGSC-all.gml | 26139 +++++++++++++++++++ src/libcola/tests/gml_graph.cpp | 257 + src/libcola/tests/graphlayouttest.h | 275 + src/libcola/tests/initialOverlap.cpp | 168 + src/libcola/tests/invalid.cpp | 80 + src/libcola/tests/large_graph.cpp | 144 + src/libcola/tests/makefeasible.cpp | 366 + src/libcola/tests/makefeasible02.cpp | 932 + src/libcola/tests/makemovie.sh | 10 + src/libcola/tests/max_acyclic_subgraph.cpp | 346 + src/libcola/tests/overlappingClusters01.cpp | 333 + src/libcola/tests/overlappingClusters02.cpp | 100 + src/libcola/tests/overlappingClusters04.cpp | 61 + src/libcola/tests/page_bounds.cpp | 102 + src/libcola/tests/planar.cpp | 287 + src/libcola/tests/random_graph.cpp | 113 + src/libcola/tests/rectangularClusters01.cpp | 1135 + src/libcola/tests/rectclustershapecontainment.cpp | 2173 ++ src/libcola/tests/resize.cpp | 132 + src/libcola/tests/runtest.sh | 8 + src/libcola/tests/scale_free.cpp | 135 + src/libcola/tests/shortest_paths.cpp | 140 + src/libcola/tests/small_graph.cpp | 111 + src/libcola/tests/sparse_matrix.cpp | 88 + src/libcola/tests/test_cg.cpp | 164 + src/libcola/tests/topology.cpp | 177 + src/libcola/tests/trees.cpp | 103 + src/libcola/tests/unconstrained.cpp | 71 + src/libcola/tests/unsatisfiable.cpp | 85 + src/libcola/tests/view_cd_output.sh | 43 + src/libcola/tests/view_mas_output.sh | 43 + src/libcola/unused.h | 26 + src/libvpsc/CMakeLists.txt | 17 +- src/libvpsc/Makefile.am | 42 + src/libvpsc/assertions.h | 102 + src/libvpsc/block.cpp | 845 +- src/libvpsc/block.h | 163 +- src/libvpsc/blocks.cpp | 333 +- src/libvpsc/blocks.h | 140 +- src/libvpsc/cbuffer.cpp | 95 + src/libvpsc/cbuffer.h | 49 + src/libvpsc/constraint.cpp | 224 +- src/libvpsc/constraint.h | 161 +- src/libvpsc/doc/description.doc | 36 + src/libvpsc/exceptions.h | 36 + src/libvpsc/generate-constraints.cpp | 309 - src/libvpsc/generate-constraints.h | 84 - src/libvpsc/isnan.h | 74 + src/libvpsc/libvpsc.pc.in | 12 + src/libvpsc/linesegment.h | 138 + src/libvpsc/pairing_heap.h | 394 + src/libvpsc/pairingheap/PairingHeap.cpp | 335 - src/libvpsc/pairingheap/PairingHeap.h | 125 - src/libvpsc/pairingheap/dsexceptions.h | 9 - src/libvpsc/placement_SolveVPSC.h | 53 - src/libvpsc/rectangle.cpp | 745 + src/libvpsc/rectangle.h | 302 + src/libvpsc/remove_rectangle_overlap.cpp | 106 - src/libvpsc/remove_rectangle_overlap.h | 34 - src/libvpsc/solve_VPSC.cpp | 812 +- src/libvpsc/solve_VPSC.h | 176 +- src/libvpsc/tests/Makefile.am | 15 + src/libvpsc/tests/block.cpp | 105 + src/libvpsc/tests/cycle.cpp | 106 + src/libvpsc/tests/rectangleoverlap.cpp | 660 + src/libvpsc/tests/satisfy_inc.cpp | 666 + src/libvpsc/variable.cpp | 31 +- src/libvpsc/variable.h | 79 +- src/removeoverlap.cpp | 116 +- src/sp-conn-end-pair.cpp | 120 +- src/ui/tools/connector-tool.cpp | 3 +- 291 files changed, 178958 insertions(+), 8031 deletions(-) create mode 100644 src/libavoid/Doxyfile create mode 100644 src/libavoid/LICENSE.LGPL create mode 100644 src/libavoid/Makefile.am create mode 100644 src/libavoid/actioninfo.cpp create mode 100644 src/libavoid/actioninfo.h create mode 100644 src/libavoid/connectionpin.cpp create mode 100644 src/libavoid/connectionpin.h create mode 100644 src/libavoid/connend.cpp create mode 100644 src/libavoid/connend.h create mode 100644 src/libavoid/debughandler.h create mode 100644 src/libavoid/dllexport.h create mode 100644 src/libavoid/doc/description.doc create mode 100644 src/libavoid/doc/example.doc create mode 100644 src/libavoid/doc/header.html create mode 100644 src/libavoid/hyperedge.cpp create mode 100644 src/libavoid/hyperedge.h create mode 100644 src/libavoid/hyperedgeimprover.cpp create mode 100644 src/libavoid/hyperedgeimprover.h create mode 100644 src/libavoid/hyperedgetree.cpp create mode 100644 src/libavoid/hyperedgetree.h create mode 100644 src/libavoid/junction.cpp create mode 100644 src/libavoid/junction.h create mode 100644 src/libavoid/libavoid.pc.in create mode 100755 src/libavoid/libavoid.sln create mode 100755 src/libavoid/libavoid.vcxproj delete mode 100644 src/libavoid/makefile.in create mode 100644 src/libavoid/mtst.cpp create mode 100644 src/libavoid/mtst.h create mode 100644 src/libavoid/obstacle.cpp create mode 100644 src/libavoid/obstacle.h create mode 100644 src/libavoid/scanline.cpp create mode 100644 src/libavoid/scanline.h create mode 100644 src/libavoid/tests/2junctions.cpp create mode 100644 src/libavoid/tests/Makefile.am create mode 100644 src/libavoid/tests/buildOrthogonalChannelInfo1.cpp create mode 100644 src/libavoid/tests/checkpointNudging1.cpp create mode 100644 src/libavoid/tests/checkpointNudging2.cpp create mode 100644 src/libavoid/tests/checkpointNudging3.cpp create mode 100644 src/libavoid/tests/checkpoints01.cpp create mode 100644 src/libavoid/tests/checkpoints02.cpp create mode 100644 src/libavoid/tests/checkpoints03.cpp create mode 100644 src/libavoid/tests/complex.cpp create mode 100644 src/libavoid/tests/connectionpin01.cpp create mode 100644 src/libavoid/tests/connectionpin02.cpp create mode 100644 src/libavoid/tests/connectionpin03.cpp create mode 100644 src/libavoid/tests/connendmove.cpp create mode 100644 src/libavoid/tests/corneroverlap01.cpp create mode 100644 src/libavoid/tests/endlessLoop01.cpp create mode 100644 src/libavoid/tests/example.cpp create mode 100644 src/libavoid/tests/finalSegmentNudging1.cpp create mode 100644 src/libavoid/tests/finalSegmentNudging2.cpp create mode 100644 src/libavoid/tests/finalSegmentNudging3.cpp create mode 100644 src/libavoid/tests/forwardFlowingConnectors01.cpp create mode 100644 src/libavoid/tests/freeFloatingDirection01.cpp create mode 100644 src/libavoid/tests/hola01.cpp create mode 100644 src/libavoid/tests/hyperedge01.cpp create mode 100644 src/libavoid/tests/hyperedge02.cpp create mode 100644 src/libavoid/tests/hyperedgeLoop1.cpp create mode 100644 src/libavoid/tests/hyperedgeRerouting01.cpp create mode 100644 src/libavoid/tests/improveHyperedge01.cpp create mode 100644 src/libavoid/tests/improveHyperedge02.cpp create mode 100644 src/libavoid/tests/improveHyperedge03.cpp create mode 100644 src/libavoid/tests/improveHyperedge04.cpp create mode 100644 src/libavoid/tests/improveHyperedge05.cpp create mode 100644 src/libavoid/tests/improveHyperedge06.cpp create mode 100644 src/libavoid/tests/infinity.cpp create mode 100644 src/libavoid/tests/inline.cpp create mode 100644 src/libavoid/tests/inlineOverlap09.cpp create mode 100644 src/libavoid/tests/inlineOverlap10.cpp create mode 100644 src/libavoid/tests/inlineOverlap11.cpp create mode 100644 src/libavoid/tests/inlineShapes.cpp create mode 100644 src/libavoid/tests/inlineoverlap01.cpp create mode 100644 src/libavoid/tests/inlineoverlap02.cpp create mode 100644 src/libavoid/tests/inlineoverlap03.cpp create mode 100644 src/libavoid/tests/inlineoverlap04.cpp create mode 100644 src/libavoid/tests/inlineoverlap05.cpp create mode 100644 src/libavoid/tests/inlineoverlap06.cpp create mode 100644 src/libavoid/tests/inlineoverlap07.cpp create mode 100644 src/libavoid/tests/inlineoverlap08.cpp create mode 100644 src/libavoid/tests/junction01.cpp create mode 100644 src/libavoid/tests/junction02.cpp create mode 100644 src/libavoid/tests/junction03.cpp create mode 100644 src/libavoid/tests/junction04.cpp create mode 100644 src/libavoid/tests/latesetup.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash1.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash2.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash3.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash4.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash5.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash6.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash7.cpp create mode 100644 src/libavoid/tests/lineSegWrapperCrash8.cpp create mode 100755 src/libavoid/tests/msctests/2junctions.vcxproj create mode 100755 src/libavoid/tests/msctests/buildOrthogonalChannelInfo1.vcxproj create mode 100755 src/libavoid/tests/msctests/checkpointNudging1.vcxproj create mode 100755 src/libavoid/tests/msctests/checkpointNudging2.vcxproj create mode 100755 src/libavoid/tests/msctests/checkpoints01.vcxproj create mode 100755 src/libavoid/tests/msctests/connectionpin01.vcxproj create mode 100755 src/libavoid/tests/msctests/connectionpin02.vcxproj create mode 100755 src/libavoid/tests/msctests/connectionpin03.vcxproj create mode 100755 src/libavoid/tests/msctests/connendmove.vcxproj create mode 100755 src/libavoid/tests/msctests/corneroverlap01.vcxproj create mode 100755 src/libavoid/tests/msctests/example.vcxproj create mode 100755 src/libavoid/tests/msctests/finalSegmentNudging1.vcxproj create mode 100755 src/libavoid/tests/msctests/finalSegmentNudging2.vcxproj create mode 100755 src/libavoid/tests/msctests/finalSegmentNudging3.vcxproj create mode 100755 src/libavoid/tests/msctests/freeFloatingDirection01.vcxproj create mode 100755 src/libavoid/tests/msctests/junction01.vcxproj create mode 100644 src/libavoid/tests/multiconnact.cpp create mode 100644 src/libavoid/tests/node1.cpp create mode 100644 src/libavoid/tests/nudgeCrossing01.cpp create mode 100644 src/libavoid/tests/nudgeintobug.cpp create mode 100644 src/libavoid/tests/nudgeold.cpp create mode 100644 src/libavoid/tests/nudgingSkipsCheckpoint01.cpp create mode 100644 src/libavoid/tests/nudgingSkipsCheckpoint02.cpp create mode 100644 src/libavoid/tests/orderassertion.cpp create mode 100644 src/libavoid/tests/orthordering01.cpp create mode 100644 src/libavoid/tests/orthordering02.cpp create mode 100644 src/libavoid/tests/output/README.txt create mode 100644 src/libavoid/tests/overlappingRects.cpp create mode 100644 src/libavoid/tests/penaltyRerouting01.cpp create mode 100644 src/libavoid/tests/performance01.cpp create mode 100644 src/libavoid/tests/reallyslowrouting.cpp create mode 100644 src/libavoid/tests/removeJunctions01.cpp create mode 100644 src/libavoid/tests/restrictedNudging.cpp create mode 100644 src/libavoid/tests/slowrouting.cpp create mode 100644 src/libavoid/tests/tjunct.cpp create mode 100644 src/libavoid/tests/treeRootCrash01.cpp create mode 100644 src/libavoid/tests/treeRootCrash02.cpp create mode 100644 src/libavoid/tests/unsatisfiableRangeAssertion.cpp create mode 100644 src/libavoid/tests/validPaths01.cpp create mode 100644 src/libavoid/tests/validPaths02.cpp create mode 100644 src/libavoid/tests/vertlineassertion.cpp create mode 100644 src/libcola/Makefile.am create mode 100644 src/libcola/box.cpp create mode 100644 src/libcola/box.h create mode 100644 src/libcola/cc_clustercontainmentconstraints.cpp create mode 100644 src/libcola/cc_clustercontainmentconstraints.h create mode 100644 src/libcola/cc_nonoverlapconstraints.cpp create mode 100644 src/libcola/cc_nonoverlapconstraints.h create mode 100644 src/libcola/cluster.cpp create mode 100644 src/libcola/cluster.h create mode 100644 src/libcola/cola_log.h create mode 100644 src/libcola/colafd.cpp create mode 100644 src/libcola/commondefs.h create mode 100644 src/libcola/compound_constraints.cpp create mode 100644 src/libcola/compound_constraints.h create mode 100644 src/libcola/connected_components.h create mode 100644 src/libcola/convex_hull.cpp create mode 100644 src/libcola/convex_hull.h delete mode 100644 src/libcola/cycle_detector.cpp delete mode 100644 src/libcola/cycle_detector.h delete mode 100644 src/libcola/defs.h create mode 100644 src/libcola/doc/description.doc create mode 100644 src/libcola/exceptions.h create mode 100644 src/libcola/libcola.pc.in create mode 100644 src/libcola/output_svg.cpp create mode 100644 src/libcola/output_svg.h create mode 100644 src/libcola/pseudorandom.cpp create mode 100644 src/libcola/pseudorandom.h create mode 100644 src/libcola/shapepair.cpp create mode 100644 src/libcola/shapepair.h delete mode 100644 src/libcola/shortest_paths.cpp create mode 100644 src/libcola/sparse_matrix.h create mode 100755 src/libcola/tests/FixedRelativeConstraint01.cpp create mode 100644 src/libcola/tests/Makefile.am create mode 100755 src/libcola/tests/StillOverlap01.cpp create mode 100755 src/libcola/tests/StillOverlap02.cpp create mode 100644 src/libcola/tests/boundary.cpp create mode 100644 src/libcola/tests/connected_components.cpp create mode 100644 src/libcola/tests/constrained.cpp create mode 100644 src/libcola/tests/containment.cpp create mode 100644 src/libcola/tests/containment2.cpp create mode 100644 src/libcola/tests/convex_hull.cpp create mode 100644 src/libcola/tests/cycle_detector.cpp create mode 100644 src/libcola/tests/data/1138_bus.txt create mode 100644 src/libcola/tests/data/uetzNetworkGSC-all.gml create mode 100644 src/libcola/tests/gml_graph.cpp create mode 100644 src/libcola/tests/graphlayouttest.h create mode 100644 src/libcola/tests/initialOverlap.cpp create mode 100644 src/libcola/tests/invalid.cpp create mode 100644 src/libcola/tests/large_graph.cpp create mode 100644 src/libcola/tests/makefeasible.cpp create mode 100755 src/libcola/tests/makefeasible02.cpp create mode 100644 src/libcola/tests/makemovie.sh create mode 100644 src/libcola/tests/max_acyclic_subgraph.cpp create mode 100644 src/libcola/tests/overlappingClusters01.cpp create mode 100644 src/libcola/tests/overlappingClusters02.cpp create mode 100644 src/libcola/tests/overlappingClusters04.cpp create mode 100644 src/libcola/tests/page_bounds.cpp create mode 100644 src/libcola/tests/planar.cpp create mode 100644 src/libcola/tests/random_graph.cpp create mode 100644 src/libcola/tests/rectangularClusters01.cpp create mode 100644 src/libcola/tests/rectclustershapecontainment.cpp create mode 100644 src/libcola/tests/resize.cpp create mode 100755 src/libcola/tests/runtest.sh create mode 100644 src/libcola/tests/scale_free.cpp create mode 100644 src/libcola/tests/shortest_paths.cpp create mode 100644 src/libcola/tests/small_graph.cpp create mode 100644 src/libcola/tests/sparse_matrix.cpp create mode 100644 src/libcola/tests/test_cg.cpp create mode 100644 src/libcola/tests/topology.cpp create mode 100644 src/libcola/tests/trees.cpp create mode 100644 src/libcola/tests/unconstrained.cpp create mode 100644 src/libcola/tests/unsatisfiable.cpp create mode 100755 src/libcola/tests/view_cd_output.sh create mode 100755 src/libcola/tests/view_mas_output.sh create mode 100644 src/libcola/unused.h create mode 100644 src/libvpsc/Makefile.am create mode 100644 src/libvpsc/assertions.h create mode 100644 src/libvpsc/cbuffer.cpp create mode 100644 src/libvpsc/cbuffer.h create mode 100644 src/libvpsc/doc/description.doc create mode 100644 src/libvpsc/exceptions.h delete mode 100644 src/libvpsc/generate-constraints.cpp delete mode 100644 src/libvpsc/generate-constraints.h create mode 100644 src/libvpsc/isnan.h create mode 100644 src/libvpsc/libvpsc.pc.in create mode 100644 src/libvpsc/linesegment.h create mode 100644 src/libvpsc/pairing_heap.h delete mode 100644 src/libvpsc/pairingheap/PairingHeap.cpp delete mode 100644 src/libvpsc/pairingheap/PairingHeap.h delete mode 100644 src/libvpsc/pairingheap/dsexceptions.h delete mode 100644 src/libvpsc/placement_SolveVPSC.h create mode 100644 src/libvpsc/rectangle.cpp create mode 100644 src/libvpsc/rectangle.h delete mode 100644 src/libvpsc/remove_rectangle_overlap.cpp delete mode 100644 src/libvpsc/remove_rectangle_overlap.h create mode 100644 src/libvpsc/tests/Makefile.am create mode 100644 src/libvpsc/tests/block.cpp create mode 100644 src/libvpsc/tests/cycle.cpp create mode 100644 src/libvpsc/tests/rectangleoverlap.cpp create mode 100644 src/libvpsc/tests/satisfy_inc.cpp (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 71743fda5..5e7942f19 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -24,6 +24,7 @@ #include "sp-conn-end.h" #include "sp-path.h" #include "libavoid/router.h" +#include "libavoid/shape.h" #include "xml/node.h" #include "document.h" #include "desktop.h" @@ -57,12 +58,10 @@ SPAvoidRef::~SPAvoidRef() // If the document is being destroyed then the router instance // and the ShapeRefs will have been destroyed with it. - const bool routerInstanceExists = (item->document->router != NULL); + Router *router = item->document->router; - if (shapeRef && routerInstanceExists) { - // Deleting the shapeRef will remove it completely from - // an existing Router instance. - delete shapeRef; + if (shapeRef && router) { + router->deleteShape(shapeRef); } shapeRef = NULL; } @@ -117,17 +116,13 @@ void SPAvoidRef::handleSettingChange(void) GQuark itemID = g_quark_from_string(id); shapeRef = new Avoid::ShapeRef(router, poly, itemID); - - router->addShape(shapeRef); } } else { g_assert(shapeRef); - // Deleting the shapeRef will remove it completely from - // an existing Router instance. - delete shapeRef; + router->deleteShape(shapeRef); shapeRef = NULL; } } diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 52bb6b6a2..ba8cd10d5 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -28,26 +28,32 @@ #include "conn-avoid-ref.h" #include "libavoid/router.h" #include "libcola/cola.h" +#include "libcola/connected_components.h" using namespace std; using namespace cola; using namespace vpsc; + /** * Returns true if item is a connector */ -bool isConnector(SPItem const *const i) { - SPPath *path = NULL; - if(SP_IS_PATH(i)) { - path = SP_PATH(i); +bool isConnector(SPItem const * const item) { + SPPath * path = NULL; + if (SP_IS_PATH(item)) { + path = SP_PATH(item); } return path && path->connEndPair.isAutoRoutingConn(); } -struct CheckProgress : TestConvergence { - CheckProgress(double d,unsigned i,list& - selected,vector& rs,map& nodelookup) : - TestConvergence(d,i), selected(selected), rs(rs), nodelookup(nodelookup) {} - bool operator()(double new_stress, double* X, double* Y) { +struct CheckProgress: TestConvergence { + CheckProgress(double d, unsigned i, list & selected, Rectangles & rs, + map & nodelookup) + : TestConvergence(d, i) + , selected(selected) + , rs(rs) + , nodelookup(nodelookup) + {} + bool operator()(const double new_stress, valarray & X, valarray & Y) { /* This is where, if we wanted to animate the layout, we would need to update * the positions of all objects and redraw the canvas and maybe sleep a bit cout << "stress="<& selected; - vector& rs; - map& nodelookup; + list & selected; + Rectangles & rs; + map & nodelookup; }; /** * Scans the items list and places those items that are * not connectors in filtered */ -void filterConnectors(std::vector const &items, list &filtered) { - for(std::vector::const_iterator i = items.begin();i !=items.end(); ++i){ - SPItem *item = *i; - if(!isConnector(item)) { +void filterConnectors(std::vector const & items, list & filtered) { + for (SPItem * item: items) { + if (!isConnector(item)) { filtered.push_back(item); } } } + /** -* Takes a list of inkscape items, extracts the graph defined by -* connectors between them, and uses graph layout techniques to find -* a nice layout -*/ -void graphlayout(std::vector const &items) { - if(items.empty()) { - return; - } + * Takes a list of inkscape items, extracts the graph defined by + * connectors between them, and uses graph layout techniques to find + * a nice layout + */ +void graphlayout(std::vector const & items) { + if (items.empty()) return; - list selected; - filterConnectors(items,selected); - if (selected.empty()) return; + list selected; + filterConnectors(items, selected); - const unsigned n=selected.size(); - //Check 2 or more selected objects - if (n < 2) return; + if (selected.size() < 2) return; // add the connector spacing to the size of node bounding boxes // so that connectors can always be routed between shapes - SPDesktop* desktop = SP_ACTIVE_DESKTOP; + SPDesktop * desktop = SP_ACTIVE_DESKTOP; double spacing = 0; - if(desktop) spacing = desktop->namedview->connector_spacing+0.1; + if (desktop) spacing = desktop->namedview->connector_spacing + 0.1; - map nodelookup; - vector rs; + map nodelookup; + Rectangles rs; vector es; - for (list::iterator i(selected.begin()); - i != selected.end(); - ++i) - { - SPItem *u=*i; - Geom::OptRect const item_box = u->desktopVisualBounds(); - if(item_box) { + for (SPItem * item: selected) { + Geom::OptRect const item_box = item->desktopVisualBounds(); + if (item_box) { Geom::Point ll(item_box->min()); Geom::Point ur(item_box->max()); - nodelookup[u->getId()]=rs.size(); - rs.push_back(new Rectangle(ll[0]-spacing,ur[0]+spacing, - ll[1]-spacing,ur[1]+spacing)); + nodelookup[item->getId()] = rs.size(); + rs.push_back(new Rectangle(ll[0] - spacing, ur[0] + spacing, + ll[1] - spacing, ur[1] + spacing)); } else { // I'm not actually sure if it's possible for something with a // NULL item-box to be attached to a connector in which case we // should never get to here... but if such a null box can occur it's // probably pretty safe to simply ignore - //fprintf(stderr,"NULL item_box found in graphlayout, ignoring!\n"); + //fprintf(stderr, "NULL item_box found in graphlayout, ignoring!\n"); } } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - SimpleConstraints scx,scy; + Inkscape::Preferences * prefs = Inkscape::Preferences::get(); + CompoundConstraints constraints; double ideal_connector_length = prefs->getDouble("/tools/connector/length", 100.0); double directed_edge_height_modifier = 1.0; - bool directed = prefs->getBool("/tools/connector/directedlayout"); + bool directed = prefs->getBool("/tools/connector/directedlayout"); bool avoid_overlaps = prefs->getBool("/tools/connector/avoidoverlaplayout"); - for (list::iterator i(selected.begin()); - i != selected.end(); - ++i) - { - SPItem *iu=*i; - map::iterator i_iter=nodelookup.find(iu->getId()); - map::iterator i_iter_end=nodelookup.end(); - if(i_iter==i_iter_end) { - continue; - } - unsigned u=i_iter->second; - std::vector nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); - list connectors; + for (SPItem * item: selected) { + map::iterator i_iter=nodelookup.find(item->getId()); + if (i_iter == nodelookup.end()) continue; + unsigned u = i_iter->second; + vector nlist = item->avoidRef->getAttachedConnectors(Avoid::runningFrom); + list connectors; connectors.insert(connectors.end(), nlist.begin(), nlist.end()); - for (list::iterator j(connectors.begin()); - j != connectors.end(); - ++j) { - SPItem *conn=*j; - SPItem *iv; - SPItem *items[2]; + for (SPItem * conn: connectors) { + SPItem * iv; + SPItem * items[2]; assert(isConnector(conn)); SP_PATH(conn)->connEndPair.getAttachedItems(items); - if(items[0]==iu) { - iv=items[1]; + if (items[0] == item) { + iv = items[1]; } else { - iv=items[0]; + iv = items[0]; } if (iv == NULL) { @@ -179,62 +166,52 @@ void graphlayout(std::vector const &items) { // If iv not in nodelookup we again treat the connector // as disconnected and continue - map::iterator v_pair=nodelookup.find(iv->getId()); - if(v_pair!=nodelookup.end()) { - unsigned v=v_pair->second; + map::iterator v_pair = nodelookup.find(iv->getId()); + if (v_pair != nodelookup.end()) { + unsigned v = v_pair->second; //cout << "Edge: (" << u <<","<style->marker_end.set) { - if(directed && strcmp(conn->style->marker_end.value,"none")) { - scy.push_back(new SimpleConstraint(v, u, - (ideal_connector_length * directed_edge_height_modifier))); + es.push_back(make_pair(u, v)); + if (conn->style->marker_end.set) { + if (directed && strcmp(conn->style->marker_end.value, "none")) { + constraints.push_back(new SeparationConstraint(YDIM, v, u, + ideal_connector_length * directed_edge_height_modifier)); } } } } } - const unsigned E = es.size(); - double eweights[E]; - fill(eweights,eweights+E,1); + EdgeLengths elengths(es.size(), 1); vector cs; - connectedComponents(rs,es,scx,scy,cs); - for(unsigned i=0;iedges.size()<2) continue; - CheckProgress test(0.0001,100,selected,rs,nodelookup); - ConstrainedMajorizationLayout alg(c->rects,c->edges,eweights,ideal_connector_length,test); - alg.setupConstraints(NULL,NULL,avoid_overlaps, - NULL,NULL,&c->scx,&c->scy,NULL,NULL); + connectedComponents(rs, es, cs); + for (Component * c: cs) { + if (c->edges.size() < 2) continue; + CheckProgress test(0.0001, 100, selected, rs, nodelookup); + ConstrainedMajorizationLayout alg(c->rects, c->edges, NULL, ideal_connector_length, elengths, &test); + if (avoid_overlaps) alg.setAvoidOverlaps(); + alg.setConstraints(&constraints); alg.run(); } separateComponents(cs); - for (list::iterator it(selected.begin()); - it != selected.end(); - ++it) - { - SPItem *u=*it; - if(!isConnector(u)) { - map::iterator i=nodelookup.find(u->getId()); - if(i!=nodelookup.end()) { - Rectangle* r=rs[i->second]; - Geom::OptRect item_box = u->desktopVisualBounds(); + for (SPItem * item: selected) { + if (!isConnector(item)) { + map::iterator i = nodelookup.find(item->getId()); + if (i != nodelookup.end()) { + Rectangle * r = rs[i->second]; + Geom::OptRect item_box = item->desktopVisualBounds(); if (item_box) { Geom::Point const curr(item_box->midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); - sp_item_move_rel(u, Geom::Translate(dest - curr)); + sp_item_move_rel(item, Geom::Translate(dest - curr)); } } } } - for(unsigned i=0;i