~ubuntu-branches/ubuntu/lucid/graphviz/lucid-updates

« back to all changes in this revision

Viewing changes to lib/neatogen/adjust.c

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2008-06-19 20:23:23 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619202323-ls23h96ntj9ny94m
Tags: 2.18-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build depend on liblualib50-dev instead of liblua5.1-0-dev.
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev or python2.5-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: adjust.c,v 1.12 2006/05/21 06:33:20 ellson Exp $ $Revision: 1.12 $ */
 
1
/* $Id: adjust.c,v 1.14 2008/02/05 04:37:16 erg Exp $ $Revision: 1.14 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
28
28
#include "site.h"
29
29
#include "heap.h"
30
30
#include "hedges.h"
 
31
#include "digcola.h"
 
32
#ifdef IPSEPCOLA
 
33
#include <csolve_VPSC.h>
 
34
#include "quad_prog_vpsc.h"
 
35
#endif
31
36
 
32
37
static double margin = 0.05;    /* Create initial bounding box by adding
33
38
                                 * margin * dimension around box enclosing
637
642
    }
638
643
}
639
644
 
 
645
#ifdef IPSEPCOLA
 
646
static int
 
647
vpscAdjust(graph_t* G)
 
648
{
 
649
    int dim = 2;
 
650
    int nnodes = agnnodes(G);
 
651
    ipsep_options opt;
 
652
    pointf* nsize = N_GNEW(nnodes, pointf);
 
653
    float** coords = N_GNEW(dim, float*);
 
654
    float* f_storage = N_GNEW(dim * nnodes, float);
 
655
    int i, j;
 
656
    Agnode_t* v;
 
657
    char* str;
 
658
 
 
659
    for (i = 0; i < dim; i++) {
 
660
        coords[i] = f_storage + i * nnodes;
 
661
    }
 
662
 
 
663
    j = 0;
 
664
    for (v = agfstnode(G); v; v = agnxtnode(G, v)) {
 
665
        for (i = 0; i < dim; i++) {
 
666
            coords[i][j] =  (float) (ND_pos(v)[i]);
 
667
        }
 
668
        nsize[j].x = ND_width(v);
 
669
        nsize[j].y = ND_height(v);
 
670
        j++;
 
671
    }
 
672
 
 
673
    opt.diredges = 0;
 
674
    opt.edge_gap = 0;
 
675
    opt.noverlap = 2;
 
676
    opt.clusters = NEW(cluster_data);
 
677
    if ((str = agget(G, "sep")) && 
 
678
        (i = sscanf(str, "%lf,%lf", &opt.gap.x, &opt.gap.y))) {
 
679
            if (i == 1) opt.gap.y = opt.gap.x;
 
680
            if(Verbose)
 
681
                fprintf(stderr,"gap=%f,%f\n",opt.gap.x,opt.gap.y);
 
682
    }
 
683
    else opt.gap.x = opt.gap.y = PS2INCH(10);
 
684
    opt.nsize = nsize;
 
685
 
 
686
    removeoverlaps(nnodes, coords, &opt);
 
687
 
 
688
    j = 0;
 
689
    for (v = agfstnode(G); v; v = agnxtnode(G, v)) {
 
690
        for (i = 0; i < dim; i++) {
 
691
            ND_pos(v)[i] = coords[i][j];
 
692
        }
 
693
        j++;
 
694
    }
 
695
 
 
696
    free (opt.clusters);
 
697
    free (f_storage);
 
698
    free (coords);
 
699
    free (nsize);
 
700
    return 0;
 
701
}
 
702
#endif
 
703
 
640
704
/* normalize:
641
705
 * If normalize is set, move first node to origin, then
642
706
 * rotate graph so that first edge is horizontal.
722
786
 
723
787
adjust_data *graphAdjustMode(graph_t *G)
724
788
{
725
 
    return (getAdjustMode (agget(G, "overlap")));
 
789
    char* am = agget(G, "overlap");
 
790
    return (getAdjustMode (am ? am : ""));
726
791
}
727
792
 
728
793
/* removeOverlapAs:
778
843
        case AM_COMPRESS:
779
844
            ret = scAdjust(G, -1);
780
845
            break;
 
846
#ifdef IPSEPCOLA
 
847
        case AM_VPSC:
 
848
            ret = vpscAdjust(G);
 
849
            break;
 
850
#endif
781
851
        default:                /* to silence warnings */
782
852
            break;
783
853
        }