summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ec681f)
raw | patch | inline | side by side (parent: 1ec681f)
author | tgdwyer <tgdwyer@users.sourceforge.net> | |
Wed, 12 Jul 2006 02:26:13 +0000 (02:26 +0000) | ||
committer | tgdwyer <tgdwyer@users.sourceforge.net> | |
Wed, 12 Jul 2006 02:26:13 +0000 (02:26 +0000) |
index 42b867a335d233dff9bb2f8e38e7890f4369b89e..69d26120d29ff703ed07238181461513753eb435 100644 (file)
* connectors between them, and uses graph layout techniques to find
* a nice layout
*/
-void graphlayout(GSList const *const items) {
+void graphlayout(GSList const *const items, double edgeLength) {
if(!items) {
return;
}
double eweights[E];
fill(eweights,eweights+E,1);
- ConstrainedMajorizationLayout alg(rs,es,eweights,width/n);
+ ConstrainedMajorizationLayout alg(rs,es,eweights,edgeLength);
alg.run();
for (list<SPItem *>::iterator it(selected.begin());
index 40090ef6b54ad8b3ced046f827cdebec765e51cb..2e8de2ddd18a54671ceb7e329221a5f95f6e6ee1 100644 (file)
#define SEEN_GRAPHLAYOUT_H
struct _GSList;
-void graphlayout(_GSList const *const items);
+void graphlayout(_GSList const *const items, double edgeLength);
class SPItem;
bool isConnector(SPItem const *const item);
#include <list>
index a7b2aa991ecdc59b9656700fea347e16757c00dd..dda9cad5f0a29978b17e3c21354c213d47093d73 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());
+ graphlayout(sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(),100);
// restore compensation setting
prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
index 6862794b33034a292283e46ff6514188c1050a55..4fa2d6044f87c95e1488b754e7de03fa7df01c59 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "../prefs-utils.h"
#include "../inkscape-stock.h"
#include "icon.h"
+#include "graphlayout/graphlayout.h"
#include "mod360.h"
}
+
static void connector_spacing_changed(GtkAdjustment *adj, GtkWidget *tbl)
{
// quit if run by the _changed callbacks
spinbutton_defocus(GTK_OBJECT(tbl));
}
+static void sp_connector_graph_layout(void)
+{
+ if (!SP_ACTIVE_DESKTOP) return;
+
+ // see comment in ActionAlign above
+ 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));
+
+ // 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 connector_length_changed(GtkAdjustment *adj, GtkWidget *tbl)
+{
+ prefs_set_double_attribute("tools.connector", "length", adj->value);
+ spinbutton_defocus(GTK_OBJECT(tbl));
+}
static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
gchar const *name, gchar const *old_value, gchar const *new_value,
gtk_box_pack_start(GTK_BOX(tbl), object_spacing, FALSE, FALSE,
AUX_SPACING);
}
+ // Graph (connector network) layout
+ sp_toolbox_button_new(tbl, Inkscape::ICON_SIZE_SMALL_TOOLBAR,
+ "graph_layout", GTK_SIGNAL_FUNC(sp_connector_graph_layout),
+ tt, _("Nicely arrange selected connector network"));
+ // Default connector length spinbox
+ {
+ GtkWidget *connector_length = sp_tb_spinbutton(_("Length:"),
+ _("Ideal length for connectors when layout is applied"),
+ "tools.connector", "length", 100, NULL, tbl, TRUE,
+ "inkscape:connector-length", 10, 1000, 10.0, 100.0,
+ connector_length_changed, 1, 0);
+
+ gtk_box_pack_start(GTK_BOX(tbl), connector_length, FALSE, FALSE,
+ AUX_SPACING);
+ }
gtk_widget_show_all(tbl);
sp_set_font_size_smaller (tbl);