summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a7f9305)
raw | patch | inline | side by side (parent: a7f9305)
author | tgdwyer <tgdwyer@users.sourceforge.net> | |
Wed, 12 Jul 2006 06:37:29 +0000 (06:37 +0000) | ||
committer | tgdwyer <tgdwyer@users.sourceforge.net> | |
Wed, 12 Jul 2006 06:37:29 +0000 (06:37 +0000) |
- added icon for directed layout toggle button
- removed old ref to remove_rectangle_overlaps-test from src/Makefile.am
- removed old ref to remove_rectangle_overlaps-test from src/Makefile.am
diff --git a/share/icons/icons.svg b/share/icons/icons.svg
index 2b7c4ff34e8b029434a8ea4e81a7b6d7e6b17dba..922b6ba00ce57204a96bb3fdb8ad1e55b683c9e2 100644 (file)
--- a/share/icons/icons.svg
+++ b/share/icons/icons.svg
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"
<g
style="display:inline"
id="remove_overlaps"
- transform="translate(-46.01598,41.0433)">
+ transform="translate(-48,41)">
<rect
y="611"
x="828"
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 6358d35dda637de52d850a3e77131beccfacb562..f69bb9bf142b3ac9aee7b28999c96d82cca0a581 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
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) \
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 \
index 69d26120d29ff703ed07238181461513753eb435..ac2d5429f4ae1518e50d73706d01567b37f12a88 100644 (file)
*
* 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"
#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;
* 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;
}
if (selected.empty()) return;
const unsigned n=selected.size();
- cout<<"|V|="<<n<<endl;
//Check 2 or more selected objects
if (n < 2) return;
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]));
}
++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;
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());
index 2e8de2ddd18a54671ceb7e329221a5f95f6e6ee1..40090ef6b54ad8b3ced046f827cdebec765e51cb 100644 (file)
#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>
index 5dfb4363d62b42740e83ebf92df8f076c26a6749..ed8ffbfed3d1aacbe75b00bb42115492d0df9452 100644 (file)
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
}
/*
index dda9cad5f0a29978b17e3c21354c213d47093d73..a7b2aa991ecdc59b9656700fea347e16757c00dd 100644 (file)
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);
index 4fa2d6044f87c95e1488b754e7de03fa7df01c59..b0ab387f097ab9b4afdf74b05fb43db12b4cfe22 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
{
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);
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);