~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/sd/bv/stviewer.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
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).
 
6
//
 
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.
 
11
//
 
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.
 
16
//
 
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
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
#include "stwindow.h"
 
23
#include "diagram.h"
 
24
#include "stviewer.h"
 
25
#include "selectareacmd.h"
 
26
#include "sizeshapecmd.h"
 
27
#include "draghandlecmd.h"
 
28
#include "dragshapescmd.h"
 
29
#include "dragstlabelcmd.h"
 
30
#include "draghlinecmd.h"
 
31
#include "transitionarrow.h"
 
32
#include "nodeshape.h"
 
33
 
 
34
STViewer::STViewer(Config *c, STWindow *d): DiagramViewer(c, d) { }
 
35
 
 
36
TransitionArrow *STViewer::HitHLine(int x, int y) {
 
37
        List<GShape *> *shapes = GetCurView()->GetShapes();
 
38
        for (shapes->first(); !shapes->done(); shapes->next()) {
 
39
                GShape *shape = shapes->cur();
 
40
                if (shape->GetClassType()==Code::TRANSITION_ARROW && 
 
41
                    shape->IsVisible()) {
 
42
                        TransitionArrow *h = (TransitionArrow *)shape;
 
43
                        if (h->HitHLine(x, y))
 
44
                                return h;
 
45
                }
 
46
        }
 
47
        return 0;
 
48
}
 
49
 
 
50
Command *STViewer::Drag(int x, int y) {
 
51
        double x1 = GetScaler()->ScaleCorrect(x);
 
52
        double y1 = GetScaler()->ScaleCorrect(y);
 
53
        Line *line;
 
54
        int w;
 
55
        if ((line = GetCurView()->HitLineHandle(static_cast<int>(0.5 + x1), 
 
56
                                                                                        static_cast<int>(0.5 + y1), w)))
 
57
                return new DragHandleCmd(line, w);
 
58
        TextShape *textShape;
 
59
        if ((textShape = GetCurView()->HitTextShape(static_cast<int>(0.5 + x1),
 
60
                                                                                                static_cast<int>(0.5 + y1))))
 
61
                return new DragSTLabelCmd(textShape);
 
62
        // look for horizontal transition line to drag.
 
63
        GShape *shape;
 
64
        if ((shape = HitHLine(static_cast<int>(0.5 + x1), 
 
65
                                                  static_cast<int>(0.5 + y1))))
 
66
                return new DragHLineCmd((TransitionArrow *)shape);
 
67
        return DiagramViewer::Drag(x, y);
 
68
        //
 
69
        // look for nodes shapes.
 
70
        // else if ((shape = curView->HitNodeShape(x, y))) {
 
71
        //        if (shape->IsSelected() && (w = shape->HitHandles(x, y)) >= 0)
 
72
        //               return new SizeShapeCenterCmd(shape, w);
 
73
        //      else if (shape->IsSelected() && curView->NrSelected() > 1)
 
74
        //             return new DragShapesCmd(curView);
 
75
        //    else
 
76
        //           return new DragShapeCmd(shape);
 
77
        //}
 
78
        // else
 
79
        //      return new SelectAreaCmd(GetCurView());
 
80
}