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

« back to all changes in this revision

Viewing changes to src/sd/dv/cbviewer.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 2000, Vrije Universiteit Amsterdam and University of Twente.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
// Author: Henk van de Zandschulp (henkz@cs.utwente.nl).
 
7
//
 
8
// TCM is free software; you can redistribute it and/or modify
 
9
// it under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation; either version 2 of the License, or
 
11
// (at your option) any later version.
 
12
//
 
13
// TCM is distributed in the hope that it will be useful,
 
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
// GNU General Public License for more details.
 
17
//
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with TCM; if not, write to the Free Software Foundation, Inc.,
 
20
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#include "cbviewer.h"
 
23
#include "cbwindow.h"
 
24
#include "cbupdateactortypecmd.h"
 
25
#include "subject.h"
 
26
#include "ssddoubleclassbox.h"          // compatibility
 
27
#include "ssdtripleclassbox.h"          // compatibility
 
28
#include "ssdupdateclassboxpropertycmd.h"
 
29
#include "updatemessagedirectioncmd.h"
 
30
#include "cbdmessage.h"
 
31
 
 
32
CBViewer::CBViewer(Config *c, CBWindow *w): ERViewer(c, w) { }
 
33
 
 
34
Command *CBViewer::Drag(int x, int y) {
 
35
        TextShape *textShape;
 
36
        double x1 = GetScaler()->ScaleCorrect(x);
 
37
        double y1 = GetScaler()->ScaleCorrect(y);
 
38
        // do note allow moving messages 
 
39
        if ((textShape = GetCurView()->HitTextShape(static_cast<int>(0.5 + x1),
 
40
                                                                                static_cast<int>(0.5 + y1), False))) {
 
41
                Subject *subj = textShape->GetParent()->GetSubject();
 
42
 
 
43
                if ((*textShape->GetDescription() == "Message") &&
 
44
                    ((subj->GetClassType() == Code::CBD_CLASS_LINK_EDGE) ||
 
45
                         (subj->GetClassType() == Code::CBD_OBJECT_LINK_EDGE))) {
 
46
                        SetStatus("aborted: message can not be dragged");
 
47
                        return 0;
 
48
                } 
 
49
        }
 
50
        return ERViewer::Drag(x,y);
 
51
}
 
52
 
 
53
void CBViewer::UpdateNodeShapeType(int actorType) {
 
54
        SetStatus("action: Update actor type");
 
55
        List<int *> t;
 
56
        t.add(new int(Code::UCD_SINGLE_CLASS_BOX));
 
57
        t.add(new int(Code::STICKMAN));
 
58
        if (GetCurView()->NrSelected() > 0) {
 
59
                NewCommand(new CBUpdateActorTypeCmd(
 
60
                                GetCurView(), &t, actorType));
 
61
                ExecuteCommand();
 
62
        }
 
63
        else
 
64
                EmptySelectionMessage();
 
65
        t.clear();
 
66
}
 
67
 
 
68
 
 
69
void CBViewer::UpdateShowStereotypes(bool b) {
 
70
        if (b)
 
71
                SetStatus("action: show stereotypes");
 
72
        else
 
73
                SetStatus("action: hide stereotypes");
 
74
        if (GetCurView()->NrSelected() > 0) {
 
75
                NewCommand(new SSDUpdateClassBoxPropertyCmd(
 
76
                                GetCurView(), 
 
77
                                SSDUpdateClassBoxPropertyCmd::STEREOTYPE, b));
 
78
                ExecuteCommand();
 
79
        }
 
80
        else
 
81
                EmptySelectionMessage();
 
82
}
 
83
 
 
84
 
 
85
void CBViewer::UpdateShowProperties(bool b) {
 
86
        if (b)
 
87
                SetStatus("action: show properties");
 
88
        else
 
89
                SetStatus("action: hide properties");
 
90
        if (GetCurView()->NrSelected() > 0) {
 
91
                NewCommand(new SSDUpdateClassBoxPropertyCmd(
 
92
                                GetCurView(), 
 
93
                                SSDUpdateClassBoxPropertyCmd::PROPERTIES, b));
 
94
                ExecuteCommand();
 
95
        }
 
96
        else
 
97
                EmptySelectionMessage();
 
98
}
 
99
 
 
100
 
 
101
void CBViewer::UpdateMessageDirection(TextShape *t, CBDMessage *msg, int k,
 
102
                                                                                ReadDirection::Type dir) {
 
103
        SetStatus("action: Update message direction");
 
104
        if (GetCurView()->NrSelected() > 0) {
 
105
                NewCommand(new UpdateMessageDirectionCmd(GetCurView(), t, msg, k, dir));
 
106
                ExecuteCommand();
 
107
        }
 
108
        else
 
109
                EmptySelectionMessage();
 
110
}