diff options
| author | Tim Dwyer <tgdwyer@gmail.com> | 2006-07-12 06:37:29 +0000 |
|---|---|---|
| committer | tgdwyer <tgdwyer@users.sourceforge.net> | 2006-07-12 06:37:29 +0000 |
| commit | 61b45f9df2853aa6b09df65773aa281d37b66a85 (patch) | |
| tree | 83c00e907fa90ea1f61b95c85660ce87d3c442a7 | |
| parent | Added layout button and ideal connector length spinbox to connector toolbar (diff) | |
| download | inkscape-61b45f9df2853aa6b09df65773aa281d37b66a85.tar.gz inkscape-61b45f9df2853aa6b09df65773aa281d37b66a85.zip | |
- added toggle buttons for directed layout (doesn't do anything yet) and overlap avoiding layout to connector toolbar
- added icon for directed layout toggle button
- removed old ref to remove_rectangle_overlaps-test from src/Makefile.am
(bzr r1396)
| -rw-r--r-- | share/icons/icons.svg | 91 | ||||
| -rw-r--r-- | src/Makefile.am | 2 | ||||
| -rw-r--r-- | src/graphlayout/graphlayout.cpp | 37 | ||||
| -rw-r--r-- | src/graphlayout/graphlayout.h | 2 | ||||
| -rw-r--r-- | src/libcola/conjugate_gradient.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/align-and-distribute.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 59 |
7 files changed, 174 insertions, 23 deletions
diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 2b7c4ff34..922b6ba00 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -14,9 +14,35 @@ width="1000.0000pt" sodipodi:version="0.32" id="svg1" - sodipodi:docbase="/usr/local/src/inkscape/share/icons"> + sodipodi:docbase="/home/dwyer/devel/inkscape/share/icons"> <defs id="defs3"> + <marker + inkscape:stockid="Arrow2Lend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow2Lend" + style="overflow:visible;"> + <path + id="path4828" + style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;" + d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " + transform="scale(1.1) rotate(180) translate(1,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Send" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Send" + style="overflow:visible;"> + <path + id="path4834" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.2) rotate(180) translate(6,0)" /> + </marker> <linearGradient inkscape:collect="always" xlink:href="#linearGradient10585" @@ -12045,7 +12071,7 @@ http://www.inkscape.org/</dc:description> <g style="display:inline" id="remove_overlaps" - transform="translate(-46.01598,41.0433)"> + transform="translate(-48,41)"> <rect y="611" x="828" @@ -12760,4 +12786,65 @@ http://www.inkscape.org/</dc:description> id="path11171" /> </g> </g> + <g + id="g3735" + transform="matrix(0.76838,0,0,0.776759,4.51551,573.2782)" /> + <g + id="directed_graph"> + <path + id="path3750" + d="M 815.45042,655.58782 L 819.72521,661.58781" + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:0.78564852;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Send)" + sodipodi:nodetypes="cc" /> + <path + id="path3752" + d="M 828.27479,655.72521 L 824.27479,661.45042" + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:0.78564852;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Send)" + sodipodi:nodetypes="cc" /> + <path + sodipodi:type="arc" + style="color:black;fill:#99b7d5;fill-opacity:0.70196078;fill-rule:evenodd;stroke:blue;stroke-width:0.81931818;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" + id="path3762" + sodipodi:cx="328" + sodipodi:cy="215" + sodipodi:rx="5" + sodipodi:ry="5" + d="M 333 215 A 5 5 0 1 1 323,215 A 5 5 0 1 1 333 215 z" + transform="matrix(0.375607,0,0,0.376774,698.833,582.9556)" /> + <path + sodipodi:type="arc" + style="color:black;fill:#99b7d5;fill-opacity:0.70196078;fill-rule:evenodd;stroke:blue;stroke-width:0.81931818;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" + id="path3764" + sodipodi:cx="328" + sodipodi:cy="215" + sodipodi:rx="5" + sodipodi:ry="5" + d="M 333 215 A 5 5 0 1 1 323,215 A 5 5 0 1 1 333 215 z" + transform="matrix(0.375607,0,0,0.376774,690.833,572.9556)" /> + <path + sodipodi:type="arc" + style="color:black;fill:#99b7d5;fill-opacity:0.70196078;fill-rule:evenodd;stroke:blue;stroke-width:0.81931818;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" + id="path3766" + sodipodi:cx="328" + sodipodi:cy="215" + sodipodi:rx="5" + sodipodi:ry="5" + d="M 333 215 A 5 5 0 1 1 323,215 A 5 5 0 1 1 333 215 z" + transform="matrix(0.375607,0,0,0.376774,706.833,572.9556)" /> + <path + sodipodi:type="arc" + style="color:black;fill:#99b7d5;fill-opacity:0.70196078;fill-rule:evenodd;stroke:blue;stroke-width:0.81931818;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:0;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;display:inline" + id="path3787" + sodipodi:cx="328" + sodipodi:cy="215" + sodipodi:rx="5" + sodipodi:ry="5" + d="M 333 215 A 5 5 0 1 1 323,215 A 5 5 0 1 1 333 215 z" + transform="matrix(0.375607,0,0,0.376774,698.833,592.9556)" /> + <path + id="path3789" + d="M 822,666 L 822,670.62605" + style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:black;stroke-width:0.78564852;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Send)" + sodipodi:nodetypes="cc" /> + </g> </svg> diff --git a/src/Makefile.am b/src/Makefile.am index 6358d35dd..f69bb9bf1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -182,7 +182,6 @@ TESTS = \ libnr/nr-translate-test$(EXEEXT) \ libnr/nr-types-test$(EXEEXT) \ libnr/test-nr$(EXEEXT) \ - removeoverlap/remove_rectangle_overlap-test$(EXEEXT) \ svg/test-svg$(EXEEXT) \ util/list-container-test$(EXEEXT) \ xml/test-xml$(EXEEXT) \ @@ -210,7 +209,6 @@ check_PROGRAMS = \ libnr/nr-translate-test \ libnr/nr-types-test \ libnr/test-nr \ - removeoverlap/remove_rectangle_overlap-test \ svg/test-svg \ util/list-container-test \ xml/test-xml \ diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp index 69d26120d..ac2d5429f 100644 --- a/src/graphlayout/graphlayout.cpp +++ b/src/graphlayout/graphlayout.cpp @@ -9,11 +9,15 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#include "util/glib-list-iterators.h" -#include "graphlayout/graphlayout.h" #include <iostream> #include <config.h> +#include <map> +#include <vector> +#include <algorithm> +#include <float.h> +#include "util/glib-list-iterators.h" +#include "graphlayout/graphlayout.h" #include "sp-path.h" #include "sp-item.h" #include "sp-item-transform.h" @@ -23,10 +27,7 @@ #include "libavoid/geomtypes.h" #include "libcola/cola.h" #include "libvpsc/generate-constraints.h" -#include <map> -#include <vector> -#include <algorithm> -#include <float.h> +#include "prefs-utils.h" using namespace std; using namespace cola; @@ -59,7 +60,7 @@ void filterConnectors(GSList const *const items, list<SPItem *> &filtered) { * connectors between them, and uses graph layout techniques to find * a nice layout */ -void graphlayout(GSList const *const items, double edgeLength) { +void graphlayout(GSList const *const items) { if(!items) { return; } @@ -70,7 +71,6 @@ void graphlayout(GSList const *const items, double edgeLength) { if (selected.empty()) return; const unsigned n=selected.size(); - cout<<"|V|="<<n<<endl; //Check 2 or more selected objects if (n < 2) return; @@ -89,7 +89,6 @@ void graphlayout(GSList const *const items, double edgeLength) { NR::Point ur(item_box.max()); minX=min(ll[0],minX); minY=min(ll[1],minY); maxX=max(ur[0],maxX); maxY=max(ur[1],maxY); - cout<<"Creating node for id: "<<u->id<<endl; nodelookup[u->id]=rs.size(); rs.push_back(new Rectangle(ll[0],ur[0],ll[1],ur[1])); } @@ -100,7 +99,6 @@ void graphlayout(GSList const *const items, double edgeLength) { ++i) { SPItem *iu=*i; - cout<<"Getting neighbours for id: "<<iu->id<<endl; unsigned u=nodelookup[iu->id]; GSList *nlist=iu->avoidRef->getAttachedShapes(Avoid::runningFrom); list<SPItem *> neighbours; @@ -124,7 +122,24 @@ void graphlayout(GSList const *const items, double edgeLength) { double eweights[E]; fill(eweights,eweights+E,1); - ConstrainedMajorizationLayout alg(rs,es,eweights,edgeLength); + ConstrainedMajorizationLayout alg(rs,es,eweights, + prefs_get_double_attribute("tools.connector","length",100)); + gchar const *directed = NULL, *overlaps = NULL; + directed = prefs_get_string_attribute("tools.connector", + "directedlayout"); + overlaps = prefs_get_string_attribute("tools.connector", + "avoidoverlaplayout"); + bool avoid_overlaps = false; + if (directed && !strcmp(directed, "true")) { + cout << "Directed layout requested, but not yet implemented\n"; + cout << " because we haven't coded cyclic removal alg...\n"; + } + if (overlaps && !strcmp(overlaps, "true")) { + cout << "Avoid overlaps requested.\n"; + avoid_overlaps = true; + } + alg.setupConstraints(NULL,NULL,avoid_overlaps, + NULL,NULL,NULL,NULL,NULL,NULL); alg.run(); for (list<SPItem *>::iterator it(selected.begin()); diff --git a/src/graphlayout/graphlayout.h b/src/graphlayout/graphlayout.h index 2e8de2ddd..40090ef6b 100644 --- a/src/graphlayout/graphlayout.h +++ b/src/graphlayout/graphlayout.h @@ -13,7 +13,7 @@ #define SEEN_GRAPHLAYOUT_H struct _GSList; -void graphlayout(_GSList const *const items, double edgeLength); +void graphlayout(_GSList const *const items); class SPItem; bool isConnector(SPItem const *const item); #include <list> diff --git a/src/libcola/conjugate_gradient.cpp b/src/libcola/conjugate_gradient.cpp index 5dfb4363d..ed8ffbfed 100644 --- a/src/libcola/conjugate_gradient.cpp +++ b/src/libcola/conjugate_gradient.cpp @@ -97,8 +97,8 @@ conjugate_gradient(valarray<double> const &A, r -= alpha_k*Ap; r_r = r_r_new; } - printf("njh: %d iters, Linfty = %g L2 = %g\n", k, - std::max(-r.min(), r.max()), sqrt(r_r)); + //printf("njh: %d iters, Linfty = %g L2 = %g\n", k, + //std::max(-r.min(), r.max()), sqrt(r_r)); // x is solution } /* diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index dda9cad5f..a7b2aa991 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -511,7 +511,7 @@ private : int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED); prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(),100); + graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()); // restore compensation setting prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 4fa2d6044..b0ab387f0 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -3890,19 +3890,41 @@ static void sp_connector_graph_layout(void) { if (!SP_ACTIVE_DESKTOP) return; - // see comment in ActionAlign above + // hack for clones, see comment in align-and-distribute.cpp int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED); prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(), - prefs_get_double_attribute("tools.connector","length",100)); + graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList()); - // restore compensation setting prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation); sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, /* TODO: annotate */ "toolbox.cpp:129"); } +static void +sp_directed_graph_layout_toggled(GtkWidget *widget, GtkObject *tbl) +{ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { + prefs_set_string_attribute("tools.connector", "directedlayout", + "true"); + } else { + prefs_set_string_attribute("tools.connector", "directedlayout", + "false"); + } +} +static void +sp_nooverlaps_graph_layout_toggled(GtkWidget *widget, GtkObject *tbl) +{ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { + prefs_set_string_attribute("tools.connector", "avoidoverlaplayout", + "true"); + } else { + prefs_set_string_attribute("tools.connector", "avoidoverlaplayout", + "false"); + } +} + + static void connector_length_changed(GtkAdjustment *adj, GtkWidget *tbl) { prefs_set_double_attribute("tools.connector", "length", adj->value); @@ -3990,6 +4012,35 @@ sp_connector_toolbox_new(SPDesktop *desktop) gtk_box_pack_start(GTK_BOX(tbl), connector_length, FALSE, FALSE, AUX_SPACING); } + gchar const *tbuttonstate; + // Directed edges toggle button + { + GtkWidget *tbutton = gtk_toggle_button_new (); + gtk_button_set_relief (GTK_BUTTON (tbutton), GTK_RELIEF_NONE); + gtk_container_add (GTK_CONTAINER (tbutton), sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, "directed_graph")); + gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (tbutton), FALSE); + gtk_tooltips_set_tip(tt, tbutton, _("Make connectors point downwards"), NULL); + + gtk_box_pack_start (GTK_BOX (tbl), tbutton, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(tbutton), "toggled", GTK_SIGNAL_FUNC(sp_directed_graph_layout_toggled), tbl); + tbuttonstate = prefs_get_string_attribute("tools.connector", "directedlayout"); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(tbutton), + (tbuttonstate && !strcmp(tbuttonstate, "true"))?TRUE:FALSE ); + } + // Avoid overlaps toggle button + { + GtkWidget *tbutton = gtk_toggle_button_new (); + gtk_button_set_relief (GTK_BUTTON (tbutton), GTK_RELIEF_NONE); + gtk_container_add (GTK_CONTAINER (tbutton), sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, "remove_overlaps")); + gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (tbutton), FALSE); + gtk_tooltips_set_tip(tt, tbutton, _("Do not allow overlapping shapes"), NULL); + + gtk_box_pack_start (GTK_BOX (tbl), tbutton, FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(tbutton), "toggled", GTK_SIGNAL_FUNC(sp_nooverlaps_graph_layout_toggled), tbl); + tbuttonstate = prefs_get_string_attribute("tools.connector", "avoidoverlaplayout"); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(tbutton), + (tbuttonstate && !strcmp(tbuttonstate, "true"))?TRUE:FALSE ); + } gtk_widget_show_all(tbl); sp_set_font_size_smaller (tbl); |
