graphlayout.cpp revision 36bb2154f1627a17c3591eb4d7f89335e8b5dadd
/** @file
* @brief Interface between Inkscape code (SPItem) and graphlayout functions.
*/
/*
* Authors:
* Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
* Abhishek Sharma
*
* Copyright (C) 2005 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#include <iostream>
#include <config.h>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <float.h>
#include "desktop.h"
#include "inkscape.h"
#include "sp-namedview.h"
#include "util/glib-list-iterators.h"
#include "graphlayout.h"
#include "sp-path.h"
#include "sp-item.h"
#include "sp-item-transform.h"
#include "sp-conn-end-pair.h"
#include "style.h"
#include "conn-avoid-ref.h"
#include "libavoid/connector.h"
#include "libavoid/geomtypes.h"
#include "libvpsc/generate-constraints.h"
#include "preferences.h"
using namespace std;
using namespace cola;
using namespace vpsc;
/**
* Returns true if item is a connector
*/
bool isConnector(SPItem const *const i) {
if(SP_IS_PATH(i)) {
}
}
struct CheckProgress : TestConvergence {
bool operator()(double new_stress, double* X, double* 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="<<new_stress<<endl;
cout << "x[0]="<<rs[0]->getMinX()<<endl;
for (list<SPItem *>::iterator it(selected.begin());
it != selected.end();
++it)
{
SPItem *u=*it;
if(!isConnector(u)) {
Rectangle* r=rs[nodelookup[u->id]];
Geom::Rect const item_box(sp_item_bbox_desktop(u));
Geom::Point const curr(item_box.midpoint());
Geom::Point const dest(r->getCentreX(),r->getCentreY());
sp_item_move_rel(u, Geom::Translate(dest - curr));
}
}
*/
return TestConvergence::operator()(new_stress,X,Y);
}
};
/**
* Scans the items list and places those items that are
* not connectors in filtered
*/
if(!isConnector(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
*/
if(!items) {
return;
}
//Check 2 or more selected objects
if (n < 2) return;
// add the connector spacing to the size of node bounding boxes
// so that connectors can always be routed between shapes
double spacing = 0;
++i)
{
SPItem *u=*i;
if(item_box) {
} 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");
}
}
double directed_edge_height_modifier = 1.0;
++i)
{
if(i_iter==i_iter_end) {
continue;
}
j != connectors.end();
++j) {
} else {
}
// The connector is not attached to anything at the
// other end so we should just ignore it.
continue;
}
// If iv not in nodelookup we again treat the connector
// as disconnected and continue
//cout << "Edge: (" << u <<","<<v<<")"<<endl;
}
}
}
}
if(nlist) {
}
}
double eweights[E];
}
++it)
{
if(!isConnector(u)) {
if(i!=nodelookup.end()) {
if (item_box) {
}
}
}
}
delete scx[i];
}
delete scy[i];
}
delete rs[i];
}
}
// vim: set cindent
// vim: ts=4 sw=4 et tw=0 wm=0
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :