1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1996-2000, Vrije Universiteit Amsterdam and University of Twente
5
// Author: Frank Dehne (frank@cs.vu.nl).
6
// Author: Henk van de Zandschulp (henkz@cs.utwente.nl).
8
// TCM is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 2 of the License, or
11
// (at your option) any later version.
13
// TCM 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.
18
// You should have received a copy of the GNU General Public License
19
// along with TCM; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22
////////////////////////////////////////////////////////////////////////////////
23
#include "inputfile.h"
24
#include "outputfile.h"
27
#include "binaryrelationship.h"
30
#include "updatereaddirectioncmd.h"
32
C2R2Line::C2R2Line(ShapeView *v, Grafport *g, GShape *node1, GShape *node2,
33
List<Point *> *aline, bool Curved):
34
T4Line(v, g, node1, node2, aline, Curved) {
38
C2R2Line::C2R2Line(ShapeView *v, Grafport *g, GShape *node1, GShape *node2,
39
bool Curved): T4Line(v, g, node1, node2, Curved) {
43
void C2R2Line::InitTextShapes() {
44
GetTextShape1()->SetDescription("Cardinality Constraint");
45
GetTextShape2()->SetDescription("Cardinality Constraint");
46
GetTextShape3()->SetDescription("Role Name");
47
GetTextShape4()->SetDescription("Role Name");
48
GetTextShape1()->SetOneLine(True);
49
GetTextShape2()->SetOneLine(True);
50
SetNameDirection(ReadDirection::NONE);
53
bool C2R2Line::SetAssocSubject(AssocList *al) {
54
if (!T4Line::SetAssocSubject(al))
56
int classType = GetSubject()->GetClassType();
57
if (check(GetSubject() &&
58
(classType==Code::BINARY_RELATIONSHIP ||
59
classType==Code::SSD_BINARY_ASSOCIATION_EDGE ||
60
classType==Code::UCD_BINARY_ASSOCIATION_EDGE ||
61
classType==Code::SSD_AGGREGATION_EDGE ||
62
classType==Code::SSD_COMPOSITION_EDGE)))
68
void C2R2Line::SetTextShape() {
69
T4Line::SetTextShape();
70
int classType = GetSubject()->GetClassType();
71
if (check(GetSubject() &&
72
(classType==Code::BINARY_RELATIONSHIP ||
73
classType==Code::SSD_BINARY_ASSOCIATION_EDGE ||
74
classType==Code::UCD_BINARY_ASSOCIATION_EDGE ||
75
classType==Code::SSD_AGGREGATION_EDGE ||
76
classType==Code::SSD_COMPOSITION_EDGE))) {
77
GetTextShape1()->SetString(
78
((BinaryRelationship *)GetSubject())->GetConstraint1());
79
GetTextShape2()->SetString(
80
((BinaryRelationship *)GetSubject())->GetConstraint2());
81
GetTextShape3()->SetString(((BinaryRelationship *)GetSubject())->
83
GetTextShape4()->SetString(((BinaryRelationship *)GetSubject())->
88
TextShape *C2R2Line::ChooseTextShape(int x, int y) {
89
Rectangle rect2(GetName()->GetRightMost(),
90
GetName()->GetTopMost(),
92
GetName()->GetHeight());
93
if (rect2.Inside(x, y)) {
94
if (GetName()->GetStringWidth() > 0) { // toggle OK
95
int newDir = ((int) GetNameDirection() + 1) % 3;
96
ERViewer *erviewer = dynamic_cast<ERViewer *>(GetViewer());
98
erviewer->UpdateReadDirection((ReadDirection::Type) newDir);
102
return T4Line::ChooseTextShape(x, y);
105
TextShape *C2R2Line::HitTextShape(int x, int y) {
106
Rectangle rect2(GetName()->GetRightMost(),
107
GetName()->GetTopMost(),
109
GetName()->GetHeight());
110
if (GetNameDirection() != ReadDirection::NONE && rect2.Inside(x, y)) {
113
return T4Line::HitTextShape(x, y);
116
void C2R2Line::DrawShape() {
121
void C2R2Line::WriteMembers(OutputFile *ofile) {
122
T4Line::WriteMembers(ofile);
124
ReadDirection::Type2String(GetNameDirection(), &s);
125
(*ofile) << "\t{ NameDirection " << s << " }\n";
128
bool C2R2Line::ReadMembers(InputFile *ifile, double format) {
129
if (!T4Line::ReadMembers(ifile, format))
131
if (format >= 1.31) {
133
if (!ifile->ReadAttribute("NameDirection", &val))
135
UpdateNameDirection(ReadDirection::String2Type(&val));
138
SetNameDirection(ReadDirection::NONE);