~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/libvpsc/constraint.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

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
#include "constraint.h"
 
14
#include <cassert>
 
15
namespace vpsc {
 
16
Constraint::Constraint(Variable *left, Variable *right, double gap, bool equality)
 
17
: left(left),
 
18
  right(right),
 
19
  gap(gap),
 
20
  timeStamp(0),
 
21
  active(false),
 
22
  visited(false),
 
23
  equality(equality)
 
24
{
 
25
        left->out.push_back(this);
 
26
        right->in.push_back(this);
 
27
}
 
28
Constraint::~Constraint() {
 
29
        Constraints::iterator i;
 
30
        for(i=left->out.begin(); i!=left->out.end(); i++) {
 
31
                if(*i==this) break;
 
32
        }
 
33
        left->out.erase(i);
 
34
        for(i=right->in.begin(); i!=right->in.end(); i++) {
 
35
                if(*i==this) break;
 
36
        }
 
37
        right->in.erase(i);
 
38
}
 
39
std::ostream& operator <<(std::ostream &os, const Constraint &c)
 
40
{
 
41
        if(&c==NULL) {
 
42
                os<<"NULL";
 
43
        } else {
 
44
                const char *type=c.equality?"=":"<=";
 
45
                os<<*c.left<<"+"<<c.gap<<type<<*c.right<<"("<<c.slack()<<")"<<(c.active?"-active":"");
 
46
        }
 
47
        return os;
 
48
}
 
49
}