1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1998, 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 "addhandlecmd.h"
24
#include "diagramviewer.h"
25
#include "shapeview.h"
27
AddHandleCmd::AddHandleCmd(Line *s, int x, int y, unsigned n):
34
void AddHandleCmd::Executable() {
36
GetLine()->AddPoint(GetNewPt(), addPosition);
37
// reset Name Position
38
GetLine()->SetLineNumber(GetLine()->NrPoints()/2);
41
if (GetLine()->NrPoints() == 3) {
43
GetLine()->GetView()->CompleteShapes(&lines,
44
GetLine()->GetFromShape(), GetLine()->GetToShape());
45
for (lines.first(); !lines.done(); lines.next()) {
46
Line *line2 = (Line *)lines.cur();
47
if (line2->NrPoints() == 2) {
48
GetLine()->GetView()->MultipleLines(line2);
49
GetLine()->GetView()->MultipleLinesPosUpdate(line2);
54
if (Toolkit::EditorWithInterEdgeConnections(GetMainWindow()->GetTool()))
55
GetLine()->GetView()->GetViewer()->ShapePositionUpdate(GetLine());
58
void AddHandleCmd::UnExecute() {
62
GetLine()->RemovePoint(addPosition);
64
if (GetLine()->NrPoints() == 2) {
65
GetLine()->GetView()->MultipleLines(GetLine());
66
GetLine()->GetView()->MultipleLinesPosUpdate(GetLine());
68
if (Toolkit::EditorWithInterEdgeConnections(GetMainWindow()->GetTool()))
69
GetLine()->GetView()->GetViewer()->ShapePositionUpdate(GetLine());
72
void AddHandleCmd::DrawOutLine(const Point *d) {
73
Point p1 = *GetOldPt() + ScaleCorrect(d);
75
// get left and rigth points.
76
Point p2 = *(*GetLine()->GetLine())[addPosition-1];
77
Point p3 = *(*GetLine()->GetLine())[addPosition];
78
DrawLines(&p1, &p2, &p3);
81
void AddHandleCmd::CalcPoints() {
82
Point pt = *GetOldPt();
83
pt = pt + *GetDelta();
85
pt.x = Shape::HANDLE_WIDTH/2;
87
pt.y = Shape::HANDLE_WIDTH/2;