1
////////////////////////////////////////////////////////////////////////////////
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).
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.
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.
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
21
////////////////////////////////////////////////////////////////////////////////
27
#include "textshape.h"
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,
51
IndexSq, DupliSq, MultiSq,
52
SubtitleTLSq, SubtitleTRSq, SubtitleBLSq, SubtitleBRSq,
53
BottomLeftSqInv, BottomSqInv, BottomRightSqInv;
55
PolyPoint(double xu, double xhs, double xvs, double xns, double yu,
56
double yhs, double yvs, double yns, bool ev = false,
63
bool HasFixedWidth() const { return 0.0 == XHorizScaled && 0.0 == XVertScaled; }
66
bool HasFixedHeight() const { return 0.0 == YVertScaled && 0.0 == YHorizScaled; }
69
void Write(Grafport *g, double x, double y, double hs, double vs,
70
TextShape *text) const;
73
void CalcPoint(DPoint *p, double x, double y, double hs, double vs,
74
double tw, double th) const
76
p->Set(x + XUnscaled + hs * XHorizScaled + vs * XVertScaled + tw * XNameScaled,
77
y + YUnscaled + hs * YHorizScaled + vs * YVertScaled + th * YNameScaled);
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);
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;
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;
108
double GetXUnscaled() const { return XUnscaled; }
109
double GetXHorizScaled() const { return XHorizScaled; }
110
double GetXVertScaled() const { return XVertScaled; }
111
double GetXNameScaled() const { return XNameScaled; }
113
double GetYUnscaled() const { return YUnscaled; }
114
double GetYHorizScaled() const { return YHorizScaled; }
115
double GetYVertScaled() const { return YVertScaled; }
116
double GetYNameScaled() const { return YNameScaled; }
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; }
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; }
128
bool EdgeIsArc() const { return edgeIsArc; }
129
bool EdgeIsVisible() const { return edgeVisible; }
156
/// Is the edge to the next point in the polygon visible?
157
const bool edgeVisible;
159
/// Is the edge to the next point in the polygon an arc?
160
const bool edgeIsArc;