1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 2000, 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
////////////////////////////////////////////////////////////////////////////////
22
//#include "grafport.h"
24
//#include "shapeview.h"
25
//#include "diagram.h"
26
//#include "diagramviewer.h"
27
//#include "drawwindow.h"
28
#include "sizeshapebordercmd.h"
29
#include "nodeshape.h"
31
SizeShapeBorderCmd::SizeShapeBorderCmd(GShape *s, int dir)
35
if ( 1 == dir || 4 == dir || 7 == dir ) {
36
shape->GetShapeType()->GetRight(¢re);
37
shape->GetShapeType()->GetLeft(&corner);
38
fixpoint.x = shape->GetRightMost();
40
shape->GetShapeType()->GetLeft(¢re);
41
shape->GetShapeType()->GetRight(&corner);
42
fixpoint.x = shape->GetLeftMost();
44
// centre.x = -centre.x;
45
centre.SetXUnscaled (-centre.GetXUnscaled() );
46
centre.SetXHorizScaled(-centre.GetXHorizScaled());
47
centre.SetXVertScaled (-centre.GetXVertScaled() );
48
centre.SetXNameScaled (-centre.GetXNameScaled() );
49
// corner.x += centre.x;
50
corner.SetXUnscaled (corner.GetXUnscaled() +
51
centre.GetXUnscaled() );
52
corner.SetXHorizScaled(corner.GetXHorizScaled() +
53
centre.GetXHorizScaled());
54
corner.SetXVertScaled (corner.GetXVertScaled() +
55
centre.GetXVertScaled() );
56
corner.SetXNameScaled (corner.GetXNameScaled() +
57
centre.GetXNameScaled() );
60
if ( 3 == dir || 4 == dir || 5 == dir ) {
61
shape->GetShapeType()->GetTop(¢re);
62
shape->GetShapeType()->GetBottom(&corner);
63
fixpoint.y = shape->GetTopMost();
65
shape->GetShapeType()->GetBottom(¢re);
66
shape->GetShapeType()->GetTop(&corner);
67
fixpoint.y = shape->GetBottomMost();
69
// centre.y = -centre.y;
70
centre.SetYUnscaled (-centre.GetYUnscaled() );
71
centre.SetYHorizScaled(-centre.GetYHorizScaled());
72
centre.SetYVertScaled (-centre.GetYVertScaled() );
73
centre.SetYNameScaled (-centre.GetYNameScaled() );
74
// corner.y += centre.y;
75
corner.SetYUnscaled (corner.GetYUnscaled() +
76
centre.GetYUnscaled() );
77
corner.SetYHorizScaled(corner.GetYHorizScaled() +
78
centre.GetYHorizScaled());
79
corner.SetYVertScaled (corner.GetYVertScaled() +
80
centre.GetYVertScaled() );
81
corner.SetYNameScaled (corner.GetYNameScaled() +
82
centre.GetYNameScaled() );
87
//void SizeShapeBorderCmd::DrawOutline(const Point *pt) {
88
// Point p = ScaleCorrect(pt);
90
// if (direction==1||direction==4||direction==7) {
91
// // left side moved.
92
// p.x = min(p.x, newTopLeft.x+newWidth-Shape::MIN_WIDTH);
93
// newWidth += newTopLeft.x-p.x;
94
// newTopLeft.x = p.x;
97
// // right side moved.
98
// p.x = max(p.x, newTopLeft.x+Shape::MIN_WIDTH);
99
// newWidth = p.x - newTopLeft.x;
102
// if (!constrainY) {
103
// if (direction==1||direction==2||direction==6) {
104
// // top side moved.
105
// p.y = min(p.y,newTopLeft.y+newHeight-Shape::MIN_HEIGHT);
106
// newHeight += newTopLeft.y-p.y;
107
// newTopLeft.y = p.y;
110
// // bottom side moved.
111
// p.y = max(p.y, newTopLeft.y+Shape::MIN_HEIGHT);
112
// newHeight = p.y - newTopLeft.y;
115
// newWidth = max(1, newWidth);
116
// newHeight = max(1, newHeight);
117
// GetGrafport()->SetLineStyle(LineStyle::DOTTED);
118
// GetGrafport()->SetLineWidth(1);
119
// GetGrafport()->SetForegroundColor("black");
120
// GetGrafport()->DrawRectangle(newTopLeft.x, newTopLeft.y,
121
// newWidth, newHeight);
124
//void SizeShapeBorderCmd::Execute() {
125
// Command::Execute();
127
// pt.x = newTopLeft.x + newWidth/2;
128
// pt.y = newTopLeft.y + newHeight/2;
129
// shape->UpdatePosition(&pt);
130
// shape->UpdateSize(newWidth, newHeight);
131
// shape->GetView()->GetViewer()->ShapePositionUpdate(shape);
132
// GetMainWindow()->FitDocument();
135
//void SizeShapeBorderCmd::UnExecute() {
136
// Command::UnExecute();
138
// shape->UpdateSize(oldWidth, oldHeight);
139
// pt.x = oldTopLeft.x + oldWidth/2;
140
// pt.y = oldTopLeft.y + oldHeight/2;
141
// shape->UpdatePosition(&pt);
142
// shape->GetView()->GetViewer()->ShapePositionUpdate(shape);