1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.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
////////////////////////////////////////////////////////////////////////////////
23
#include "genericedge.h"
24
#include "genericnode.h"
25
#include "emptynode.h"
26
#include "miniellipse.h"
33
#include "roundedbox.h"
34
#include "ellipsedbox.h"
37
#include "horizontalbar.h"
38
#include "verticalbar.h"
39
#include "solidhorizontalbar.h"
40
#include "solidverticalbar.h"
48
#include "buildingblock.h"
50
#include "subfolder.h"
51
#include "gddiagram.h"
55
#include "gdboundaryshape.h"
56
#include "gdcontrollershape.h"
57
#include "gdentityshape.h"
59
const int GDDiagram::DOT_WIDTH = 8;
61
GDDiagram::GDDiagram(Config *c, GDWindow *d, GDViewer *v, GDGraph *g):
67
Thing *GDDiagram::CreateThing(int classNr) {
68
Grafport *g = GetDiagramViewer()->GetGrafport();
69
ShapeView *v = GetDiagramViewer()->GetCurView();
74
thing = new Box(v, g, 0, 0);
77
thing = new Square(v, g, 0, 0);
80
thing = new Circle(v, g, 0, 0);
83
thing = new Ellipse(v, g, 0, 0);
86
thing = new StickMan(v, g, 0, 0);
89
thing = new Triangle(v, g, 0, 0);
92
thing = new Hexagon(v, g, 0, 0);
94
case Code::HORIZONTAL_BAR:
95
thing = new HorizontalBar(v, g, 0, 0);
97
case Code::VERTICAL_BAR:
98
thing = new VerticalBar(v, g, 0, 0);
100
case Code::ROUNDED_BOX:
101
thing = new RoundedBox(v, g, 0, 0);
103
case Code::ELLIPSED_BOX:
104
thing = new EllipsedBox(v, g, 0, 0);
107
thing = new Diamond(v, g, 0, 0);
110
thing = new TextBox(v, g, 0, 0);
112
case Code::BLACK_DOT:
113
thing = new BlackDot(v, g, 0, 0);
115
case Code::BULLS_EYE:
116
thing = new BullsEye(v, g, 0, 0);
118
case Code::SOLID_HORIZONTAL_BAR:
119
thing = new SolidHorizontalBar(v, g, 0, 0);
121
case Code::SOLID_VERTICAL_BAR:
122
thing = new SolidVerticalBar(v, g, 0, 0);
125
thing = new NoteBox(v, g, 0, 0);
127
case Code::BUILDING_BLOCK:
128
thing = new BuildingBlock(v, g, 0, 0);
131
thing = new Cube(v, g, 0, 0);
134
thing = new Folder(v, g, 0, 0);
136
case Code::SUB_FOLDER:
137
thing = new SubFolder(v, g, 0, 0);
140
thing = new Disk(v, g, 0, 0);
142
case Code::GD_BOUNDARY_SHAPE:
143
thing = new GDBoundaryShape(v, g, 0, 0);
145
case Code::GD_CONTROLLER_SHAPE:
146
thing = new GDControllerShape(v, g, 0, 0);
148
case Code::GD_ENTITY_SHAPE:
149
thing = new GDEntityShape(v, g, 0, 0);
153
thing = new ShapeView(GetDiagramViewer());
157
thing = new Line(v, g, 0, 0, 0);
159
// old line (arrow) types...
162
Line *line = new Line(v, g, 0, 0, 0);
163
line->SetEnd2(LineEnd::FILLED_ARROW);
167
case Code::DOUBLE_ARROW:
169
Line *line = new Line(v, g, 0, 0, 0);
170
line->SetEnd1(LineEnd::FILLED_ARROW);
171
line->SetEnd2(LineEnd::FILLED_ARROW);
175
case Code::DOUBLE_HEADED_ARROW:
177
Line *line = new Line(v, g, 0, 0, 0);
178
line->SetEnd2(LineEnd::DOUBLE_FILLED_ARROW);
183
case Code::GENERIC_NODE:
184
thing = new GenericNode(GetGraph());
186
case Code::EMPTY_NODE:
187
thing = new EmptyNode(GetGraph());
190
thing = new Comment(GetGraph());
193
case Code::GENERIC_EDGE:
194
thing = new GenericEdge(GetGraph(), 0, 0);
197
error("%s, line %d: impl error: " "wrong class number %d\n",
198
__FILE__, __LINE__, classNr);
201
if (thing != 0 && HasIndexShape(thing->GetClassType()))
202
((NodeShape *)thing)->SetFixedIndexLabel(False);
207
Node *GDDiagram::CreateNode(){
209
switch ( GetNodeType() ) {
210
case Code::GENERIC_NODE:
211
node = new GenericNode(GetGraph());
213
case Code::EMPTY_NODE:
214
node = new EmptyNode(GetGraph());
217
node = new Comment(GetGraph());
220
error("%s, line %d: impl error: "
221
"unknown node type\n", __FILE__, __LINE__);
226
Edge *GDDiagram::CreateEdge(Subject *node1, Subject *node2){
227
// Check possible connections (node-node-edge matrix).
228
if (!CheckConnection(node1, node2))
231
if (GetEdgeType() == Code::GENERIC_EDGE)
232
edge = new GenericEdge(GetGraph(), node1, node2);
234
error( "%s, line %d: impl error: "
235
" unknown edge type\n", __FILE__, __LINE__);
239
NodeShape *GDDiagram::CreateNodeShape(Node *node, int x, int y) {
240
NodeShape *shape = 0;
241
Grafport *g = GetDiagramViewer()->GetGrafport();
242
ShapeView *v = GetDiagramViewer()->GetCurView();
243
int t = GetNodeShapeType();
246
shape = new Box(v, g, x, y);
249
shape = new Square(v, g, x, y);
252
shape = new Circle(v, g, x, y);
255
shape = new Ellipse(v, g, x, y);
258
shape = new StickMan(v, g, x, y);
261
shape = new Hexagon(v, g, x, y);
263
case Code::HORIZONTAL_BAR:
264
shape = new HorizontalBar(v, g, x, y);
266
case Code::VERTICAL_BAR:
267
shape = new VerticalBar(v, g, x, y);
270
shape = new Triangle(v, g, x, y);
272
case Code::ROUNDED_BOX:
273
shape = new RoundedBox(v, g, x, y);
275
case Code::ELLIPSED_BOX:
276
shape = new EllipsedBox(v, g, x, y);
279
shape = new Diamond(v, g, x, y);
282
shape = new NoteBox(v, g, x, y);
284
case Code::BLACK_DOT:
285
shape = new BlackDot(v, g, x, y);
287
case Code::BULLS_EYE:
288
shape = new BullsEye(v, g, x, y);
291
shape = new TextBox(v, g, x, y);
293
case Code::SOLID_HORIZONTAL_BAR:
294
shape = new SolidHorizontalBar(v, g, x, y);
296
case Code::SOLID_VERTICAL_BAR:
297
shape = new SolidVerticalBar(v, g, x, y);
299
case Code::BUILDING_BLOCK:
300
shape = new BuildingBlock(v, g, x, y);
303
shape = new Cube(v, g, x, y);
306
shape = new Folder(v, g, x, y);
308
case Code::SUB_FOLDER:
309
shape = new SubFolder(v, g, x, y);
312
shape = new Disk(v, g, x, y);
314
case Code::GD_BOUNDARY_SHAPE:
315
shape = new GDBoundaryShape(v, g, x, y);
317
case Code::GD_CONTROLLER_SHAPE:
318
shape = new GDControllerShape(v, g, x, y);
320
case Code::GD_ENTITY_SHAPE:
321
shape = new GDEntityShape(v, g, x, y);
324
error( "%s, line %d: impl error: "
325
"node shape type does not exist\n", __FILE__, __LINE__);
328
if (HasIndexShape(t))
329
shape->SetFixedIndexLabel(False);
330
shape->SetSubject(node);
331
shape->SetTextShape();
336
Line *GDDiagram::CreateLine(
337
Edge *edge, GShape *from, GShape *to, List<Point *> *l) {
338
Grafport *g = GetDiagramViewer()->GetGrafport();
339
ShapeView *v = GetDiagramViewer()->GetCurView();
341
int t = GetLineType();
343
line = new Line(v, g, from, to, l, IsCurve());
345
error( "%s, line %d: impl error: "
346
"line type does not exist\n", __FILE__, __LINE__);
348
line->SetSubject(edge);
349
line->SetTextShape();
350
line->SetEnd1(GetLineEnd1());
351
line->SetEnd2(GetLineEnd2());
356
void GDDiagram::UpdateNodeType(int num) {
357
((DiagramWindow *)GetMainWindow())->SetNodeName(num);
359
case 1: SetNodeType(Code::GENERIC_NODE);
360
SetNodeShapeType(Code::BOX);
362
case 2: SetNodeType(Code::GENERIC_NODE);
363
SetNodeShapeType(Code::CIRCLE);
365
case 3: SetNodeType(Code::GENERIC_NODE);
366
SetNodeShapeType(Code::ROUNDED_BOX);
368
case 4: SetNodeType(Code::GENERIC_NODE);
369
SetNodeShapeType(Code::TRIANGLE);
371
case 5: SetNodeType(Code::EMPTY_NODE);
372
SetNodeShapeType(Code::BULLS_EYE);
374
case 6: SetNodeType(Code::GENERIC_NODE);
375
SetNodeShapeType(Code::STICKMAN);
377
case 7: SetNodeType(Code::GENERIC_NODE);
378
SetNodeShapeType(Code::CUBE);
380
case 8: SetNodeType(Code::GENERIC_NODE);
381
SetNodeShapeType(Code::GD_BOUNDARY_SHAPE);
383
case 9: SetNodeType(Code::COMMENT);
384
SetNodeShapeType(Code::TEXT_BOX);
386
case 10: SetNodeType(Code::GENERIC_NODE);
387
SetNodeShapeType(Code::DIAMOND);
389
case 11: SetNodeType(Code::GENERIC_NODE);
390
SetNodeShapeType(Code::SQUARE);
392
case 12: SetNodeType(Code::GENERIC_NODE);
393
SetNodeShapeType(Code::VERTICAL_BAR);
395
case 13: SetNodeType(Code::GENERIC_NODE);
396
SetNodeShapeType(Code::HEXAGON);
398
case 14: SetNodeType(Code::EMPTY_NODE);
399
SetNodeShapeType(Code::SOLID_VERTICAL_BAR);
401
case 15: SetNodeType(Code::GENERIC_NODE);
402
SetNodeShapeType(Code::FOLDER);
404
case 16: SetNodeType(Code::GENERIC_NODE);
405
SetNodeShapeType(Code::BUILDING_BLOCK);
407
case 17: SetNodeType(Code::GENERIC_NODE);
408
SetNodeShapeType(Code::GD_CONTROLLER_SHAPE);
410
case 18: SetNodeType(Code::GENERIC_NODE);
411
SetNodeShapeType(Code::NOTE_BOX);
413
case 19: SetNodeType(Code::GENERIC_NODE);
414
SetNodeShapeType(Code::ELLIPSE);
416
case 20: SetNodeType(Code::EMPTY_NODE);
417
SetNodeShapeType(Code::BLACK_DOT);
419
case 21: SetNodeType(Code::GENERIC_NODE);
420
SetNodeShapeType(Code::HORIZONTAL_BAR);
422
case 22: SetNodeType(Code::GENERIC_NODE);
423
SetNodeShapeType(Code::ELLIPSED_BOX);
425
case 23: SetNodeType(Code::EMPTY_NODE);
426
SetNodeShapeType(Code::SOLID_HORIZONTAL_BAR);
428
case 24: SetNodeType(Code::GENERIC_NODE);
429
SetNodeShapeType(Code::SUB_FOLDER);
431
case 25: SetNodeType(Code::GENERIC_NODE);
432
SetNodeShapeType(Code::DISK);
434
case 26: SetNodeType(Code::GENERIC_NODE);
435
SetNodeShapeType(Code::GD_ENTITY_SHAPE);
438
error("%s, line %d: impl error: "
439
"unknown node type selected\n", __FILE__,__LINE__);
443
void GDDiagram::UpdateEdgeType(int num) {
444
((DiagramWindow *)GetMainWindow())->SetEdgeName(num);
445
SetEdgeType(Code::GENERIC_EDGE);
446
SetLineType(Code::LINE);
448
case 1: SetLineEnd1(LineEnd::EMPTY);
449
SetLineEnd2(LineEnd::EMPTY);
451
case 2: SetLineEnd1(LineEnd::FILLED_ARROW);
452
SetLineEnd2(LineEnd::FILLED_ARROW);
454
case 3: SetLineEnd1(LineEnd::EMPTY);
455
SetLineEnd2(LineEnd::FILLED_ARROW);
457
case 4: SetLineEnd1(LineEnd::EMPTY);
458
SetLineEnd2(LineEnd::WHITE_TRIANGLE);
460
case 5: SetLineEnd1(LineEnd::EMPTY);
461
SetLineEnd2(LineEnd::DOUBLE_FILLED_ARROW);
463
case 6: SetLineEnd1(LineEnd::EMPTY);
464
SetLineEnd2(LineEnd::OPEN_ARROW);
467
error("%s, line %d: impl error: "
468
"unknown edge type selected\n", __FILE__,__LINE__);
472
bool GDDiagram::HasIndexNode(int code) {
473
return (code == Code::GENERIC_NODE);
476
bool GDDiagram::HasIndexShape(int code) {
482
case Code::ROUNDED_BOX:
485
case Code::HORIZONTAL_BAR:
486
case Code::VERTICAL_BAR:
489
case Code::ELLIPSED_BOX:
491
case Code::SUB_FOLDER:
493
case Code::BUILDING_BLOCK:
496
case Code::GD_BOUNDARY_SHAPE:
497
case Code::GD_CONTROLLER_SHAPE:
498
case Code::GD_ENTITY_SHAPE: