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
////////////////////////////////////////////////////////////////////////////////
24
#include "shapeview.h"
25
#include "diagramviewer.h"
26
#include "draghandlecmd.h"
28
DragHandleCmd::DragHandleCmd(Line *l, unsigned n): DragShapeCmd(l) {
31
oldPt = *(*line->GetLine())[handleNr];
34
void DragHandleCmd::CalcPoints() {
35
oldPt = *(*line->GetLine())[handleNr];
37
pt = pt + *GetDelta();
39
pt.x = Shape::HANDLE_WIDTH/2;
41
pt.y = Shape::HANDLE_WIDTH/2;
46
void DragHandleCmd::Erase() {
51
void DragHandleCmd::Redraw() {
56
void DragHandleCmd::Execute() {
67
void DragHandleCmd::Executable() {
69
line->SetPoint(&newPt, handleNr);
70
line->CalcEndPoint(&newPt, handleNr);
72
if (Toolkit::EditorWithInterEdgeConnections(GetMainWindow()->GetTool()))
73
line->GetView()->GetViewer()->ShapePositionUpdate(line);
76
void DragHandleCmd::UnExecute() {
80
line->SetPoint(&oldPt, handleNr);
81
line->CalcEndPoint(&oldPt, handleNr);
83
if (Toolkit::EditorWithInterEdgeConnections(GetMainWindow()->GetTool()))
84
line->GetView()->GetViewer()->ShapePositionUpdate(line);
87
void DragHandleCmd::ReverseDelta() {
88
Point virtualPt = Point (oldPt + *GetDelta());
89
Point virtualDelta = newPt - virtualPt;
90
Point d = *GetDelta() + virtualDelta;
95
void DragHandleCmd::DrawLines(const Point *p1, const Point *p2,
98
GetGrafport()->SetLineStyle(LineStyle::DOTTED);
99
GetGrafport()->SetLineWidth(1);
100
GetGrafport()->SetForegroundColor("black");
101
GetGrafport()->DrawRectangle(p1->x - Shape::HANDLE_WIDTH/2,
102
p1->y - Shape::HANDLE_WIDTH/2,
103
Shape::HANDLE_WIDTH, Shape::HANDLE_WIDTH);
105
GetGrafport()->DrawLine(p1->x, p1->y, p2->x, p2->y);
106
GetGrafport()->DrawLine(p1->x, p1->y, p3->x, p3->y);
109
void DragHandleCmd::DrawOutLine(const Point *d) {
110
Point p1 = oldPt + ScaleCorrect(d);
111
GetView()->Snap(&p1);
113
// get left and right line segments
114
if (check(line->GetSegments(oldPt, &p2, &p3)))
115
DrawLines(&p1, &p2, &p3);