From d18b8150ba16f4a930b213dae1f4fb369cb3d0bf Mon Sep 17 00:00:00 2001 From: Tim Dwyer Date: Fri, 14 Jul 2006 04:09:40 +0000 Subject: - Connectors with end-markers now constrained to point downwards in graph layout - vpsc namespace added to libvpsc (bzr r1408) --- src/libcola/cola.cpp | 2 +- src/libcola/cola.h | 6 ++--- src/libcola/gradient_projection.cpp | 31 ++++++++++++------------ src/libcola/gradient_projection.h | 48 ++++++++++++++++++------------------- src/libcola/straightener.h | 2 +- 5 files changed, 45 insertions(+), 44 deletions(-) (limited to 'src/libcola') diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 74663f501..3499d729a 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -253,7 +253,7 @@ void ConstrainedMajorizationLayout::straighten(vector& sedg } } GradientProjection gp(dim,n,Q,coords,tol,100, - (AlignmentConstraints*)NULL,false,(Rectangle**)NULL,(PageBoundaryConstraints*)NULL,&cs); + (AlignmentConstraints*)NULL,false,(vpsc::Rectangle**)NULL,(PageBoundaryConstraints*)NULL,&cs); constrainedLayout = true; majlayout(Dij,&gp,coords,b); for(unsigned i=0;i& rs, + vector& rs, vector& es, double* eweights, double idealLength, @@ -141,7 +141,7 @@ namespace cola { straightenEdges(NULL) { assert(rs.size()==n); - boundingBoxes = new Rectangle*[rs.size()]; + boundingBoxes = new vpsc::Rectangle*[rs.size()]; copy(rs.begin(),rs.end(),boundingBoxes); double** D=new double*[n]; @@ -229,7 +229,7 @@ namespace cola { double** Dij; double tol; TestConvergence& done; - Rectangle** boundingBoxes; + vpsc::Rectangle** boundingBoxes; double *X, *Y; Clusters* clusters; double edge_length; diff --git a/src/libcola/gradient_projection.cpp b/src/libcola/gradient_projection.cpp index 061ba0f1a..cec59c57a 100644 --- a/src/libcola/gradient_projection.cpp +++ b/src/libcola/gradient_projection.cpp @@ -19,12 +19,13 @@ #include using namespace std; +using namespace vpsc; //#define CONMAJ_LOGGING 1 -static void dumpVPSCException(char const *str, IncVPSC* vpsc) { +static void dumpVPSCException(char const *str, IncSolver* solver) { cerr<getConstraints(m); + Constraint** cs = solver->getConstraints(m); for(unsigned i=0;ifirst], o->second)); - cs.push_back(new Constraint(vs[o->first], vr, o->second)); + cs.push_back(new vpsc::Constraint(vl, vs[o->first], o->second)); + cs.push_back(new vpsc::Constraint(vs[o->first], vr, o->second)); } } OffsetList offsets; @@ -99,19 +99,19 @@ friend class GradientProjection; */ void setupVPSC(Variables &vars, Constraints &cs) { double weight=1; - left = new Variable(vars.size(),place_l,weight); + left = new vpsc::Variable(vars.size(),place_l,weight); vars.push_back(left); - right = new Variable(vars.size(),place_r,weight); + right = new vpsc::Variable(vars.size(),place_r,weight); vars.push_back(right); for(CList::iterator cit=leftof.begin(); cit!=leftof.end(); ++cit) { - Variable* v = vars[(*cit).first]; - cs.push_back(new Constraint(left,v,(*cit).second)); + vpsc::Variable* v = vars[(*cit).first]; + cs.push_back(new vpsc::Constraint(left,v,(*cit).second)); } for(CList::iterator cit=rightof.begin(); cit!=rightof.end(); ++cit) { - Variable* v = vars[(*cit).first]; - cs.push_back(new Constraint(v,right,(*cit).second)); + vpsc::Variable* v = vars[(*cit).first]; + cs.push_back(new vpsc::Constraint(v,right,(*cit).second)); } } /** @@ -163,8 +163,8 @@ friend class GradientProjection; } double dist; // ideal distance between vars double b; // linear coefficient in quad form for left (b_right = -b) - Variable* left; // Variables used in constraints - Variable* right; + vpsc::Variable* left; // Variables used in constraints + vpsc::Variable* right; double lap2; // laplacian entry double g; // descent vec for quad form for left (g_right = -g) double old_place_l; // old_place is where the descent vec g was computed @@ -185,7 +185,7 @@ public: unsigned max_iterations, AlignmentConstraints* acs=NULL, bool nonOverlapConstraints=false, - Rectangle** rs=NULL, + vpsc::Rectangle** rs=NULL, PageBoundaryConstraints *pbc = NULL, SimpleConstraints *sc = NULL) : k(k), n(n), A(A), place(x), rs(rs), @@ -195,18 +195,18 @@ public: constrained(false) { for(unsigned i=0;ibegin(); iac!=acs->end();++iac) { AlignmentConstraint* ac=*iac; - Variable *v=ac->variable=new Variable(vars.size(),ac->position,0.0001); + vpsc::Variable *v=ac->variable=new vpsc::Variable(vars.size(),ac->position,0.0001); vars.push_back(v); for(OffsetList::iterator o=ac->offsets.begin(); o!=ac->offsets.end(); o++) { - gcs.push_back(new Constraint(v,vars[o->first],o->second,true)); + gcs.push_back(new vpsc::Constraint(v,vars[o->first],o->second,true)); } } } @@ -215,7 +215,7 @@ public: } if (sc) { for(SimpleConstraints::iterator c=sc->begin(); c!=sc->end();++c) { - gcs.push_back(new Constraint( + gcs.push_back(new vpsc::Constraint( vars[(*c)->left],vars[(*c)->right],(*c)->gap)); } } @@ -239,8 +239,8 @@ public: unsigned solve(double* b); DummyVars dummy_vars; // special vars that must be considered in Lapl. private: - IncVPSC* setupVPSC(); - void destroyVPSC(IncVPSC *vpsc); + vpsc::IncSolver* setupVPSC(); + void destroyVPSC(vpsc::IncSolver *vpsc); Dim k; unsigned n; // number of actual vars double** A; // Graph laplacian matrix @@ -250,7 +250,7 @@ private: Constraints gcs; /* global constraints - persist throughout all iterations */ Constraints lcs; /* local constraints - only for current iteration */ - Rectangle** rs; + vpsc::Rectangle** rs; bool nonOverlapConstraints; double tolerance; AlignmentConstraints* acs; diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h index 33af0c697..e2c50a3a6 100644 --- a/src/libcola/straightener.h +++ b/src/libcola/straightener.h @@ -97,7 +97,7 @@ namespace straightener { bool dummy; double weight; bool open; - Node(unsigned id, Rectangle* r) : + Node(unsigned id, vpsc::Rectangle* r) : id(id),x(r->getCentreX()),y(r->getCentreY()), width(r->width()), height(r->height()), xmin(x-width/2),xmax(x+width/2), ymin(y-height/2),ymax(y+height/2), -- cgit v1.2.3