~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to source/blender/img/intern/IMG_Rect.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: IMG_Rect.cpp,v 1.4 2005/09/09 22:31:23 bjornmose Exp $
3
 
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License
7
 
 * as published by the Free Software Foundation; either version 2
8
 
 * of the License, or (at your option) any later version. The Blender
9
 
 * Foundation also sells licenses for use in proprietary software under
10
 
 * the Blender License.  See http://www.blender.org/BL/ for information
11
 
 * about this.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program; if not, write to the Free Software Foundation,
20
 
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 
 *
22
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23
 
 * All rights reserved.
24
 
 *
25
 
 * The Original Code is: all of this file.
26
 
 *
27
 
 * Contributor(s): none yet.
28
 
 *
29
 
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
30
 
 */
31
 
 
32
 
#include "IMG_Rect.h"
33
 
 
34
 
#ifdef HAVE_CONFIG_H
35
 
#include <config.h>
36
 
#endif
37
 
 
38
 
TVisibility IMG_Rect::getVisibility(IMG_Rect& r) const
39
 
{
40
 
        bool lt = isInside(r.m_l, r.m_t);
41
 
        bool rt = isInside(r.m_r, r.m_t);
42
 
        bool lb = isInside(r.m_l, r.m_b);
43
 
        bool rb = isInside(r.m_r, r.m_b);
44
 
        TVisibility v;
45
 
        if (lt && rt && lb && rb) {
46
 
                // All points inside, rectangle is inside this
47
 
                v = kFullyVisible;              
48
 
        }
49
 
        else if (!(lt || rt || lb || rb)) {
50
 
                // None of the points inside
51
 
                // Check to see whether the rectangle is larger than this one
52
 
                if ((r.m_l < m_l) && (r.m_t < m_t) && (r.m_r > m_r) && (r.m_b > m_b)) {
53
 
                        v = kPartiallyVisible;
54
 
                }
55
 
                else {
56
 
                        v = kNotVisible;
57
 
                }
58
 
        }
59
 
        else {
60
 
                // Some of the points inside, rectangle is partially inside
61
 
                v = kPartiallyVisible;
62
 
        }
63
 
        return v;
64
 
}
65
 
 
66
 
TVisibility IMG_Rect::getVisibility(IMG_Line& l) const
67
 
{
68
 
        bool s = isInside(l.m_xs, l.m_ys);
69
 
        bool e = isInside(l.m_xe, l.m_ye);
70
 
        TVisibility v;
71
 
        if (s && e) {
72
 
                v = kFullyVisible;
73
 
        }
74
 
        else if (s || e) {
75
 
                v = kPartiallyVisible;
76
 
        }
77
 
        else {
78
 
                v = kNotVisible;
79
 
        }
80
 
        return v;
81
 
}
82
 
 
83
 
        
84
 
void IMG_Rect::setCenter(TInt32 cx, TInt32 cy)
85
 
{
86
 
        TInt32 offset = cx - (m_l + (m_r - m_l)/2);
87
 
        m_l += offset;
88
 
        m_r += offset;
89
 
        offset = cy - (m_t + (m_b - m_t)/2);
90
 
        m_t += offset;
91
 
        m_b += offset;
92
 
}
93
 
 
94
 
void IMG_Rect::setCenter(TInt32 cx, TInt32 cy, TInt32 w, TInt32 h)
95
 
{
96
 
        long w_2, h_2;
97
 
        
98
 
        w_2 = w >> 1;
99
 
        h_2 = h >> 1;
100
 
        m_l = cx - w_2;
101
 
        m_t = cy - h_2;
102
 
        m_r = m_l + w;
103
 
        m_b = m_t + h;
104
 
}
105
 
 
106
 
bool IMG_Rect::clip(IMG_Rect& r) const
107
 
{
108
 
        bool clipped = false;
109
 
        if (r.m_l < m_l) {
110
 
                r.m_l = m_l;
111
 
                clipped = true;
112
 
        }
113
 
        if (r.m_t < m_t) {
114
 
                r.m_t = m_t;
115
 
                clipped = true;
116
 
        }
117
 
        if (r.m_r > m_r) {
118
 
                r.m_r = m_r;
119
 
                clipped = true;
120
 
        }
121
 
        if (r.m_b > m_b) {
122
 
                r.m_b = m_b;
123
 
                clipped = true;
124
 
        }
125
 
        return clipped;
126
 
}
127
 
 
128
 
bool IMG_Rect::clip(IMG_Line& l) const
129
 
{
130
 
        bool clipped = false;
131
 
        return clipped;
132
 
}