~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/libvpsc/constraint.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \brief A constraint determines a minimum or exact spacing required between
 
3
 * two variables.
 
4
 *
 
5
 * Authors:
 
6
 *   Tim Dwyer <tgdwyer@gmail.com>
 
7
 *
 
8
 * Copyright (C) 2005 Authors
 
9
 *
 
10
 * Released under GNU LGPL.  Read the file 'COPYING' for more information.
 
11
 */
 
12
 
 
13
#ifndef SEEN_REMOVEOVERLAP_CONSTRAINT_H
 
14
#define SEEN_REMOVEOVERLAP_CONSTRAINT_H
 
15
 
 
16
#include <iostream>
 
17
#include "variable.h"
 
18
namespace vpsc {
 
19
 
 
20
class Constraint
 
21
{
 
22
        friend std::ostream& operator <<(std::ostream &os,const Constraint &c);
 
23
public:
 
24
        Variable *left;
 
25
        Variable *right;
 
26
        double gap;
 
27
        double lm;
 
28
        Constraint(Variable *left, Variable *right, double gap, bool equality=false);
 
29
    virtual ~Constraint();
 
30
        inline double slack() const { return right->position() - gap - left->position(); }
 
31
        long timeStamp;
 
32
        bool active;
 
33
        bool visited;
 
34
        bool equality;
 
35
};
 
36
#include <float.h>
 
37
#include "block.h"
 
38
static inline bool compareConstraints(Constraint *const &l, Constraint *const &r) {
 
39
        double const sl = 
 
40
                l->left->block->timeStamp > l->timeStamp
 
41
                ||l->left->block==l->right->block
 
42
                ?-DBL_MAX:l->slack();
 
43
        double const sr = 
 
44
                r->left->block->timeStamp > r->timeStamp
 
45
                ||r->left->block==r->right->block
 
46
                ?-DBL_MAX:r->slack();
 
47
        if(sl==sr) {
 
48
                // arbitrary choice based on id
 
49
                if(l->left->id==r->left->id) {
 
50
                        if(l->right->id<r->right->id) return true;
 
51
                        return false;
 
52
                }
 
53
                if(l->left->id<r->left->id) return true;
 
54
                return false;
 
55
        }
 
56
        return sl < sr;
 
57
}
 
58
}
 
59
 
 
60
#endif // SEEN_REMOVEOVERLAP_CONSTRAINT_H