~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/dg/polypoint.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 2001, Universiteit Twente, Enschede.
 
5
// Author: David N. Jansen (dnjansen@cs.utwente.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
 
 
23
#ifndef _POLYPOINT_H
 
24
#define _POLYPOINT_H
 
25
 
 
26
#include "dpoint.h"
 
27
#include "textshape.h"
 
28
class Grafport;
 
29
 
 
30
class PolyPoint {
 
31
public:
 
32
        static const PolyPoint TopLeft, Top, TopRight, Right,
 
33
                BottomRight, Bottom, BottomLeft, Left,
 
34
                TopLeft1, Top1, TopRight1, Right1,
 
35
                BottomRight1, Bottom1, BottomLeft1, Left1,
 
36
                FolderTR1, FolderTR2, FolderTR3, FolderLeft,
 
37
                TopLeftInv, TopRightInv, BottomLeftInv, BottomRightInv,
 
38
                TopArc, RightArc, BottomArc, LeftArc,
 
39
                TopAbsArc, RightAbsArc, BottomAbsArc, LeftAbsArc,
 
40
                TopArc1, RightArc1, BottomArc1, LeftArc1,
 
41
                TopLeftSq, TopSq, TopRightSq, RightSq,
 
42
                BottomRightSq, BottomSq, BottomLeftSq, LeftSq,
 
43
                TopSqArc, RightSqArc, BottomSqArc, LeftSqArc,
 
44
                TopLeftTxt, BottomLeftTxt, BottomRightTxt, TopRightTxt,
 
45
                TopLeftTxt2, BottomLeftTxt2, BottomRightTxt2, TopRightTxt2,
 
46
                RoundedBoxTTL, RoundedBoxTLL, RoundedBoxBLL, RoundedBoxBBL,
 
47
                RoundedBoxBBR, RoundedBoxBRR, RoundedBoxTRR, RoundedBoxTTR,
 
48
                RoundedBoxTTL1, RoundedBoxTLL1, RoundedBoxBLL1, RoundedBoxBBL1,
 
49
                RoundedBoxBBR1, RoundedBoxBRR1, RoundedBoxTRR1, RoundedBoxTTR1,
 
50
                Index, Dupli, Multi,
 
51
                IndexSq, DupliSq, MultiSq,
 
52
                SubtitleTLSq, SubtitleTRSq, SubtitleBLSq, SubtitleBRSq,
 
53
                BottomLeftSqInv, BottomSqInv, BottomRightSqInv;
 
54
        ///
 
55
        PolyPoint(double xu, double xhs, double xvs, double xns, double yu,
 
56
                double yhs, double yvs, double yns, bool ev = false,
 
57
                bool ea = false);
 
58
 
 
59
        ///
 
60
        ~PolyPoint() { }
 
61
 
 
62
        ///
 
63
        bool HasFixedWidth() const { return 0.0 == XHorizScaled && 0.0 == XVertScaled; }
 
64
 
 
65
        ///
 
66
        bool HasFixedHeight() const { return 0.0 == YVertScaled && 0.0 == YHorizScaled; }
 
67
 
 
68
        ///
 
69
        void Write(Grafport *g, double x, double y, double hs, double vs,
 
70
                TextShape *text) const;
 
71
 
 
72
        ///
 
73
        void CalcPoint(DPoint *p, double x, double y, double hs, double vs,
 
74
                double tw, double th) const
 
75
        {
 
76
                p->Set(x + XUnscaled + hs * XHorizScaled + vs * XVertScaled + tw * XNameScaled,
 
77
                      y + YUnscaled + hs * YHorizScaled + vs * YVertScaled + th * YNameScaled);
 
78
        }
 
79
        /// looks for hs and vs s.t. corner comes as near to p as possible:
 
80
        void CalcScale(const DPoint *p, double x, double y,
 
81
                double *hs, double *vs, double tw, double th,
 
82
                bool constrainX, bool constrainY);
 
83
 
 
84
        ///
 
85
        bool operator <(const PolyPoint &p) const {
 
86
                /* returns true if this is to the left of p */
 
87
                if ( XHorizScaled != p.XHorizScaled )
 
88
                        return XHorizScaled < p.XHorizScaled;
 
89
                if ( XNameScaled != p.XNameScaled )
 
90
                        return XNameScaled < p.XNameScaled;
 
91
                if ( XVertScaled != p.XVertScaled )
 
92
                        return XVertScaled < p.XVertScaled;
 
93
                return XUnscaled < p.XUnscaled;
 
94
        }
 
95
 
 
96
        ///
 
97
        bool operator ^(const PolyPoint &p) const {
 
98
                /* returns true if this is to the top of p */
 
99
                if ( YVertScaled != p.YVertScaled )
 
100
                        return YVertScaled < p.YVertScaled;
 
101
                if ( YNameScaled != p.YNameScaled )
 
102
                        return YNameScaled < p.YNameScaled;
 
103
                if ( YHorizScaled != p.YHorizScaled )
 
104
                        return YHorizScaled < p.YHorizScaled;
 
105
                return YUnscaled < p.YUnscaled;
 
106
        }
 
107
 
 
108
        double GetXUnscaled() const { return XUnscaled; }
 
109
        double GetXHorizScaled() const { return XHorizScaled; }
 
110
        double GetXVertScaled() const { return XVertScaled; }
 
111
        double GetXNameScaled() const { return XNameScaled; }
 
112
 
 
113
        double GetYUnscaled() const { return YUnscaled; }
 
114
        double GetYHorizScaled() const { return YHorizScaled; }
 
115
        double GetYVertScaled() const { return YVertScaled; }
 
116
        double GetYNameScaled() const { return YNameScaled; }
 
117
 
 
118
        void SetXUnscaled(double xu) { XUnscaled = xu; }
 
119
        void SetXHorizScaled(double xh) { XHorizScaled = xh; }
 
120
        void SetXVertScaled(double xv) { XVertScaled = xv; }
 
121
        void SetXNameScaled(double xn) { XNameScaled = xn; }
 
122
 
 
123
        void SetYUnscaled(double yu) { YUnscaled = yu; }
 
124
        void SetYHorizScaled(double yh) { YHorizScaled = yh; }
 
125
        void SetYVertScaled(double yv) { YVertScaled = yv; }
 
126
        void SetYNameScaled(double yn) { YNameScaled = yn; }
 
127
 
 
128
        bool EdgeIsArc() const { return edgeIsArc; }
 
129
        bool EdgeIsVisible() const { return edgeVisible; }
 
130
protected:
 
131
private:
 
132
        ///
 
133
        double XUnscaled;
 
134
 
 
135
        ///
 
136
        double XHorizScaled;
 
137
 
 
138
        ///
 
139
        double XVertScaled;
 
140
 
 
141
        ///
 
142
        double XNameScaled;
 
143
 
 
144
        ///
 
145
        double YUnscaled;
 
146
 
 
147
        ///
 
148
        double YHorizScaled;
 
149
 
 
150
        ///
 
151
        double YVertScaled;
 
152
 
 
153
        ///
 
154
        double YNameScaled;
 
155
 
 
156
        /// Is the edge to the next point in the polygon visible?
 
157
        const bool edgeVisible;
 
158
 
 
159
        /// Is the edge to the next point in the polygon an arc?
 
160
        const bool edgeIsArc;
 
161
};
 
162
 
 
163
#endif