OpenASIP  2.0
ToggleUnitDetailsCmd.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 ToggleUnitDetailsCmd.cc
26  *
27  * Definition of ToggleUnitDetails class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/docview.h>
34 
35 #include "ToggleUnitDetailsCmd.hh"
36 #include "MDFView.hh"
37 #include "MachineCanvas.hh"
38 #include "ProDeConstants.hh"
39 #include "ProDe.hh"
40 #include "MachineCanvasOptions.hh"
41 #include "OptionValue.hh"
42 
43 using std::string;
44 
45 /**
46  * The Constructor.
47  */
49  EditorCommand(ProDeConstants::CMD_NAME_TOGGLE_UNIT_DETAILS) {
50 
51 }
52 
53 
54 /**
55  * The Destructor.
56  */
58 }
59 
60 /**
61  * Executes the command.
62  *
63  * @return true, if the command was succesfully executed, false otherwise.
64  */
65 bool
67  MDFView* mView = dynamic_cast<MDFView*>(view());
68  MachineCanvas* canvas = mView->canvas();
69  OptionValue& option = canvas->options().optionValue(
71  option.setBoolValue(!option.isFlagOn());
72  canvas->updateMachine();
73  return true;
74 }
75 
76 
77 /**
78  * Returns state of the check-item related to this command.
79  *
80  * @return true, if the command check item is checked.
81  */
82 bool
84  MDFView* mView = dynamic_cast<MDFView*>(view());
85  if (mView == NULL) {
86  return false;
87  }
88  MachineCanvas* canvas = mView->canvas();
89  if (canvas == NULL) {
90  return false;
91  }
92  OptionValue& option = canvas->options().optionValue(
94  return option.isFlagOn();
95 }
96 
97 
98 
99 /**
100  * Returns id of this command.
101  *
102  * @return ID for this command to be used in menus and toolbars.
103  */
104 int
107 }
108 
109 
110 /**
111  * Creates and returns a new instance of this command.
112  *
113  * @return Newly created instance of this command.
114  */
117  return new ToggleUnitDetailsCmd();
118 }
119 
120 
121 /**
122  * Returns short version of the command name.
123  *
124  * @return Short name of the command to be used in the toolbar.
125  */
126 string
129 }
130 
131 
132 /**
133  * Returns true when the command is executable, false when not.
134  *
135  * This command is executable when a document is open.
136  *
137  * @return True, if a document is open.
138  */
139 bool
141  wxDocManager* manager = wxGetApp().docManager();
142  if (manager->GetCurrentView() != NULL) {
143  return true;
144  }
145  return false;
146 }
MachineCanvas
Definition: MachineCanvas.hh:64
ProDe.hh
ProDeConstants::CMD_SNAME_TOGGLE_UNIT_DETAILS
static const std::string CMD_SNAME_TOGGLE_UNIT_DETAILS
Command name for the "Toggle Unit Details" command.
Definition: ProDeConstants.hh:280
MDFView::canvas
MachineCanvas * canvas() const
Definition: MDFView.cc:229
Options::optionValue
OptionValue & optionValue(const string &name, int index=0)
Definition: Options.cc:115
ToggleUnitDetailsCmd::isChecked
virtual bool isChecked() const
Definition: ToggleUnitDetailsCmd.cc:83
MachineCanvasOptions.hh
ToggleUnitDetailsCmd.hh
ToggleUnitDetailsCmd::create
virtual ToggleUnitDetailsCmd * create() const
Definition: ToggleUnitDetailsCmd.cc:116
MachineCanvasOptions::SHOW_UNIT_INFO_STRING
static const std::string SHOW_UNIT_INFO_STRING
Option name for the unit info string visibility flag.
Definition: MachineCanvasOptions.hh:48
ToggleUnitDetailsCmd::ToggleUnitDetailsCmd
ToggleUnitDetailsCmd()
Definition: ToggleUnitDetailsCmd.cc:48
ToggleUnitDetailsCmd::Do
virtual bool Do()
Definition: ToggleUnitDetailsCmd.cc:66
OptionValue::isFlagOn
virtual bool isFlagOn() const
Definition: OptionValue.cc:166
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
MachineCanvas.hh
ToggleUnitDetailsCmd::~ToggleUnitDetailsCmd
virtual ~ToggleUnitDetailsCmd()
Definition: ToggleUnitDetailsCmd.cc:57
MachineCanvas::updateMachine
void updateMachine()
Definition: MachineCanvas.cc:345
ProDeConstants::COMMAND_TOGGLE_UNIT_DETAILS
@ COMMAND_TOGGLE_UNIT_DETAILS
Definition: ProDeConstants.hh:452
ProDeConstants.hh
MachineCanvas::options
MachineCanvasOptions & options()
Definition: MachineCanvas.cc:681
ToggleUnitDetailsCmd::id
virtual int id() const
Definition: ToggleUnitDetailsCmd.cc:105
ToggleUnitDetailsCmd::isEnabled
virtual bool isEnabled()
Definition: ToggleUnitDetailsCmd.cc:140
MDFView.hh
ToggleUnitDetailsCmd::shortName
virtual std::string shortName() const
Definition: ToggleUnitDetailsCmd.cc:127
OptionValue
Definition: OptionValue.hh:51
EditorCommand
Definition: EditorCommand.hh:46
OptionValue::setBoolValue
virtual void setBoolValue(bool)
Definition: OptionValue.cc:106
ProDeConstants
Definition: ProDeConstants.hh:43
OptionValue.hh
MDFView
Definition: MDFView.hh:59
ToggleUnitDetailsCmd
Definition: ToggleUnitDetailsCmd.hh:41