1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 2002, Universiteit Twente.
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
////////////////////////////////////////////////////////////////////////////////
22
#include "scdandline.h"
23
#include "nodeshape.h"
26
SCDAndLine::SCDAndLine(ShapeView *v, Grafport *g, GShape *node1,
27
List<Point *> *aline, bool Curved)
29
Line(v, g, node1, node1, aline, Curved)
33
SetEnd2(LineEnd::FILLED_ARROW);
37
SCDAndLine::SCDAndLine(ShapeView *v, Grafport *g, GShape *node1, bool Curved)
39
Line(v, g, node1, node1, Curved)
43
SetEnd2(LineEnd::FILLED_ARROW);
47
SCDAndLine::~SCDAndLine() {
52
/* virtual */ void SCDAndLine::CalcEndPoints() {
53
Line::CalcEndPoints();
54
// // ... but end points have to be on the child area's border instead of
55
// // the (outer) boundary.
56
// NodeShape *shape = dynamic_cast<NodeShape *>(GetFromShape());
59
// List<Point *> *lin = GetLine();
60
// int len = lin->count();
62
// // The code below is copied and adapted from NodeShape::GiveOrthoSnp()
63
// // and ShapeType::GiveOrthoSnp().
64
// const Point *to = (*lin)[1], *pos = shape->GetPosition();
65
// DPoint p1(shape->GetShapeType()->GetChildArea()->GiveOrthoSnp(
67
// to->x - pos->x, to->y - pos->y,
68
// shape->GetWidth(), shape->GetHeight(),
69
// shape->GetName()->GetStringWidth(),
70
// shape->GetName()->GetStringHeight()));
74
// const Point *from = (*lin)[len-2];
75
// DPoint p2(shape->GetShapeType()->GetChildArea()->GiveOrthoSnp(
77
// from->x - pos->x, from->y - pos->y,
78
// shape->GetWidth(), shape->GetHeight(),
79
// shape->GetName()->GetStringWidth(),
80
// shape->GetName()->GetStringHeight()));
84
// (*lin)[0]->Set(int(0.5 + p1.x), int(0.5 + p1.y));
85
// (*lin)[len-1]->Set(int(0.5 + p2.x), int(0.5 + p2.y));
87
// /// maybe one also wants to set the points (*line)[1] and (*line)[len-2]
92
/* virtual */ void SCDAndLine::CalcPosition() {
93
// line points have to lie in the child area of the corresponding shape.
95
NodeShape *shape = dynamic_cast<NodeShape *>(GetFromShape());
98
List <Point *> *lin = GetLine();
99
const Polygon *ca = shape->GetShapeType()->GetChildArea();
100
const Point *pos = shape->GetPosition();
102
for ( int i = lin->count() ; --i >= 0 ; ) {
103
Point to = *(*lin)[i];
105
if ( ! ca->IsInside(to.x, to.y,
106
shape->GetWidth(), shape->GetHeight(),
107
shape->GetName()->GetStringWidth(),
108
shape->GetName()->GetStringHeight()) ) {
109
DPoint p(ca->GiveOrthoSnp(to.x, to.y,
110
shape->GetWidth(), shape->GetHeight(),
111
shape->GetName()->GetStringWidth(),
112
shape->GetName()->GetStringHeight()));
115
(*lin)[i]->Set(int(0.5 + p.x), int(0.5 + p.y));