OpenASIP  2.0
SelectCmd.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file SelectCmd.cc
26  *
27  * Definition of SelectCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "SelectCmd.hh"
34 #include "SelectTool.hh"
35 #include "MDFView.hh"
36 #include "ProDe.hh"
37 #include "ProDeConstants.hh"
38 #include "MachineCanvas.hh"
39 
40 using std::string;
41 
42 /**
43  * The Constructor.
44  */
46  EditorCommand(ProDeConstants::CMD_NAME_SELECT) {
47 
48 }
49 
50 
51 /**
52  * The Destructor.
53  */
55 }
56 
57 
58 /**
59  * Executes the command.
60  *
61  * @return True, if the command was succesfully executed, false otherwise.
62  */
63 bool
65  MDFView* mdfView = dynamic_cast<MDFView*>(view());
66  ChildFrame* frame = dynamic_cast<ChildFrame*>(mdfView->GetFrame());
67  assert(frame != NULL);
68  mdfView->clearSelection();
69  SelectTool* tool = new SelectTool(frame, mdfView);
70  mdfView->canvas()->setTool(tool);
71  return true;
72 }
73 
74 
75 /**
76  * Returns id of this command.
77  *
78  * @return ID for this command to be used in menus and toolbars.
79  */
80 int
81 SelectCmd::id() const {
83 }
84 
85 
86 /**
87  * Creates and returns a new instance of this command.
88  *
89  * @return Newly created instance of this command.
90  */
91 SelectCmd*
93  return new SelectCmd();
94 }
95 
96 
97 /**
98  * Returns path to the command's icon file.
99  *
100  * @return Full path to the command's icon file.
101  */
102 string
105 }
106 
107 
108 /**
109  * Returns true when the command is executable, false when not.
110  *
111  * This command is executable when a document is open.
112  *
113  * @return True, if a document is open.
114  */
115 bool
117  wxDocManager* manager = wxGetApp().docManager();
118  if (manager->GetCurrentView() != NULL) {
119  return true;
120  }
121  return false;
122 }
SelectCmd.hh
ProDe.hh
SelectTool
Definition: SelectTool.hh:47
MDFView::canvas
MachineCanvas * canvas() const
Definition: MDFView.cc:229
SelectCmd
Definition: SelectCmd.hh:41
SelectCmd::SelectCmd
SelectCmd()
Definition: SelectCmd.cc:45
ChildFrame
Definition: ChildFrame.hh:42
MachineCanvas::setTool
void setTool(MachineCanvasTool *tool)
Definition: MachineCanvas.cc:305
assert
#define assert(condition)
Definition: Application.hh:86
SelectCmd::create
virtual SelectCmd * create() const
Definition: SelectCmd.cc:92
ProDeConstants::COMMAND_SELECT
@ COMMAND_SELECT
Definition: ProDeConstants.hh:460
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
MDFView::clearSelection
void clearSelection()
Definition: MDFView.cc:182
MachineCanvas.hh
SelectCmd::~SelectCmd
virtual ~SelectCmd()
Definition: SelectCmd.cc:54
SelectCmd::icon
virtual std::string icon() const
Definition: SelectCmd.cc:103
ProDeConstants.hh
SelectCmd::Do
virtual bool Do()
Definition: SelectCmd.cc:64
SelectTool.hh
SelectCmd::id
virtual int id() const
Definition: SelectCmd.cc:81
ProDeConstants::CMD_ICON_SELECT
static const std::string CMD_ICON_SELECT
Icon location for the "Select" command.
Definition: ProDeConstants.hh:304
MDFView.hh
SelectCmd::isEnabled
bool isEnabled()
Definition: SelectCmd.cc:116
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
MDFView
Definition: MDFView.hh:59