OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
OSEdTreeView Class Reference

#include <OSEdTreeView.hh>

Inheritance diagram for OSEdTreeView:
Inheritance graph
Collaboration diagram for OSEdTreeView:
Collaboration graph

Public Member Functions

 OSEdTreeView (wxWindow *parent, OSEdInfoView *infoView)
 
virtual ~OSEdTreeView ()
 
OperationselectedOperation ()
 
wxTreeItemId selectedOperationId ()
 
std::string moduleOfOperation (wxTreeItemId id)
 
wxTreeItemId moduleIdOfOperation (wxTreeItemId id)
 
std::string pathOfModule (wxTreeItemId id)
 
wxTreeItemId pathIdOfModule (wxTreeItemId id)
 
std::string selectedPath ()
 
wxTreeItemId selectedPathId ()
 
wxTreeItemId selectedModuleId ()
 
std::string selectedModule ()
 
OSEdInfoViewinfoView () const
 
std::vector< std::string > constructTree ()
 
void addItem (wxTreeItemId parent, std::string item)
 
void changeText (wxTreeItemId id, const std::string &text)
 
void removeItem (wxTreeItemId id)
 
void update ()
 
bool isPathSelected () const
 
bool isModuleSelected () const
 
bool isOperationSelected () const
 

Private Types

typedef std::map< std::string, wxTreeItemId >::value_type ValType
 Value type for the map.
 
typedef std::map< std::string, wxTreeItemId >::iterator Iter
 Iterators for the maps.
 
typedef std::multimap< std::string, wxTreeItemId >::iterator IterM
 

Private Member Functions

 OSEdTreeView (const OSEdTreeView &)
 Copying not allowed.
 
OSEdTreeViewoperator= (const OSEdTreeView &)
 Assignment not allowed.
 
bool isPath (wxTreeItemId id) const
 
bool isModule (wxTreeItemId id) const
 
bool isOperation (wxTreeItemId id) const
 
void onItemClicked (wxTreeEvent &event)
 
void onDropDownMenu (wxMouseEvent &event)
 
void onItemSelected (wxTreeEvent &event)
 

Private Attributes

OSEdInfoViewinfoView_
 An info window controlled by tree view.
 
std::map< std::string, wxTreeItemId > paths_
 Paths of the operation data base.
 
std::multimap< std::string, wxTreeItemId > modules_
 Modules of the operation data base.
 
std::multimap< std::string, wxTreeItemId > operations_
 Operations of operation data base.
 

Detailed Description

Models a tree view of the operation data base.

Shows a tree-like structure of search paths, operation modules, and operations.

Definition at line 54 of file OSEdTreeView.hh.

Member Typedef Documentation

◆ Iter

typedef std::map<std::string,wxTreeItemId>::iterator OSEdTreeView::Iter
private

Iterators for the maps.

Definition at line 85 of file OSEdTreeView.hh.

◆ IterM

typedef std::multimap<std::string,wxTreeItemId>::iterator OSEdTreeView::IterM
private

Definition at line 86 of file OSEdTreeView.hh.

◆ ValType

typedef std::map<std::string,wxTreeItemId>::value_type OSEdTreeView::ValType
private

Value type for the map.

Definition at line 83 of file OSEdTreeView.hh.

Constructor & Destructor Documentation

◆ OSEdTreeView() [1/2]

OSEdTreeView::OSEdTreeView ( wxWindow *  parent,
OSEdInfoView infoView 
)

Constructor.

Parameters
parent.Parent window.
infoViewInfo view controlled by tree view.

Definition at line 71 of file OSEdTreeView.cc.

71 :
72 wxTreeCtrl(parent, OSEdConstants::CMD_TREE_ITEM), infoView_(infoView) {
73}
@ CMD_TREE_ITEM
Id for tree events.
OSEdInfoView * infoView() const
OSEdInfoView * infoView_
An info window controlled by tree view.

◆ ~OSEdTreeView()

OSEdTreeView::~OSEdTreeView ( )
virtual

Destructor.

Definition at line 78 of file OSEdTreeView.cc.

78 {
79}

◆ OSEdTreeView() [2/2]

OSEdTreeView::OSEdTreeView ( const OSEdTreeView )
private

Copying not allowed.

Member Function Documentation

◆ addItem()

void OSEdTreeView::addItem ( wxTreeItemId  parent,
std::string  item 
)

Adds an item to the tree.

Parameters
parentParent id.
itemThe item to be added.

Definition at line 573 of file OSEdTreeView.cc.

573 {
574 wxTreeItemId id = AppendItem(parent, WxConversion::toWxString(item));
575 if (isPath(parent)) {
576 modules_.insert(std::pair<std::string, wxTreeItemId>(item, id));
577 } else if (isModule(parent)) {
578 operations_.insert(std::pair<std::string, wxTreeItemId>(item, id));
579 //operations_[item] = id;
580 } else {
581 assert(false);
582 }
583}
#define assert(condition)
std::multimap< std::string, wxTreeItemId > operations_
Operations of operation data base.
bool isPath(wxTreeItemId id) const
bool isModule(wxTreeItemId id) const
std::multimap< std::string, wxTreeItemId > modules_
Modules of the operation data base.
static wxString toWxString(const std::string &source)

References assert, isModule(), isPath(), modules_, operations_, and WxConversion::toWxString().

Referenced by OSEdAddModuleCmd::Do(), and OSEdAddOperationCmd::Do().

Here is the call graph for this function:

◆ changeText()

void OSEdTreeView::changeText ( wxTreeItemId  id,
const std::string &  text 
)

Changes the text of the item.

Parameters
idId of the item to be changed.
textNew label.

Definition at line 592 of file OSEdTreeView.cc.

592 {
593
594 if (isOperation(id)) {
596 Iter it = operations_.find(key);
597 operations_.erase(it);
598 operations_.insert(std::pair<std::string, wxTreeItemId>(text, id));
599 //operations_[text] = id;
600 } else if (isModule(id)) {
601 string key = MapTools::keyForValue<string>(modules_, id);
602 IterM it = modules_.find(key);
603 modules_.erase(it);
604 modules_.insert(std::pair<std::string, wxTreeItemId>(text, id));
605 } else if (isPath(id)) {
606 string key = MapTools::keyForValue<string>(paths_, id);
607 Iter it = paths_.find(key);
608 paths_.erase(it);
609 paths_[text] = id;
610 }
611 SetItemText(id, WxConversion::toWxString(text));
612}
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
std::map< std::string, wxTreeItemId > paths_
Paths of the operation data base.
std::map< std::string, wxTreeItemId >::iterator Iter
Iterators for the maps.
bool isOperation(wxTreeItemId id) const
std::multimap< std::string, wxTreeItemId >::iterator IterM

References isModule(), isOperation(), isPath(), MapTools::keyForValue(), modules_, operations_, paths_, and WxConversion::toWxString().

Referenced by OSEdPropertiesCmd::Do().

Here is the call graph for this function:

◆ constructTree()

vector< string > OSEdTreeView::constructTree ( )

Constructs the tree structure.

If errors occurs while constructing the tree structure, the error messages are collected and returned.

Returns
Results of erronous modules.

Definition at line 90 of file OSEdTreeView.cc.

90 {
91
92 vector<string> results;
94 OperationSerializer& serializer =
96
97 wxTreeItemId root = AddRoot(_T("root"));
98 vector<string> paths = Environment::osalPaths();
99
100 for (size_t i = 0; i < paths.size(); i++) {
101 // add path
102 string pathName = paths[i];
103 wxTreeItemId path =
104 AppendItem(root, WxConversion::toWxString(pathName));
105
106 if (FileSystem::fileExists(pathName)) {
107 SetItemBold(path);
108 }
109
110 paths_[pathName] = path;
111 int modules = 0;
112 try {
113 modules = opIndex.moduleCount(pathName);
114 } catch (const PathNotFound& p) {
115 // no modules in this path
116 continue;
117 }
118 for (int j = 0; j < modules; j++) {
119 // add module
120 OperationModule& mod = opIndex.module(j, pathName);
121 wxTreeItemId module =
122 AppendItem(path, WxConversion::toWxString(mod.name()));
123
124 modules_.insert(std::pair<std::string, wxTreeItemId>(mod.name(), module));
125
126 int operations = 0;
127
128 // test that operation properties can be loaded
129 try {
130 operations = opIndex.operationCount(mod);
131 serializer.setSourceFile(mod.propertiesModule());
132 ObjectState* tree = serializer.readState();
133 if (tree->childCount() > 0) {
135 temp.loadState(tree->child(0));
136 }
137 delete tree;
138 } catch (const Exception& e) {
139 results.push_back(mod.propertiesModule() + ":\n");
140 results.push_back(e.errorMessage() + "\n");
141 results.push_back("\n");
142 }
143
144 for (int k = 0; k < operations; k++) {
145 // add operation
146 string opName = opIndex.operationName(k, mod);
147 wxTreeItemId oper =
148 AppendItem(module, WxConversion::toWxString(opName));
149
150 //operations_[opIndex.operationName(k, mod)] = oper;
151 operations_.insert(std::pair<std::string, wxTreeItemId>(opIndex.operationName(k, mod), oper));
152 }
153 SortChildren(module);
154 }
155 SortChildren(path);
156 }
158 return results;
159}
static std::vector< std::string > osalPaths()
std::string errorMessage() const
Definition Exception.cc:123
static bool fileExists(const std::string fileName)
static NullOperationBehavior & instance()
ObjectState * child(int index) const
int childCount() const
static OperationSerializer & operationSerializer()
static OperationIndex & operationIndex()
std::string operationName(int i, const OperationModule &om)
OperationModule & module(int i)
int operationCount(const OperationModule &om)
int moduleCount() const
virtual std::string name() const
virtual std::string propertiesModule() const
void setSourceFile(const std::string &filename)
virtual ObjectState * readState()

References ObjectState::child(), ObjectState::childCount(), Exception::errorMessage(), FileSystem::fileExists(), infoView_, NullOperationBehavior::instance(), Operation::loadState(), OperationIndex::module(), OperationIndex::moduleCount(), modules_, OperationModule::name(), OperationIndex::operationCount(), OperationContainer::operationIndex(), OperationIndex::operationName(), operations_, OperationContainer::operationSerializer(), Environment::osalPaths(), paths_, OSEdInfoView::pathView(), OperationModule::propertiesModule(), OperationSerializer::readState(), OperationSerializer::setSourceFile(), and WxConversion::toWxString().

Referenced by OSEd::OnInit().

Here is the call graph for this function:

◆ infoView()

OSEdInfoView * OSEdTreeView::infoView ( ) const

Returns pointer to info view.

Returns
Pointer to info view.

Definition at line 662 of file OSEdTreeView.cc.

662 {
663 return infoView_;
664}

References infoView_.

Referenced by OSEdRemoveModuleCmd::Do(), and OSEdRemoveOperationCmd::Do().

◆ isModule()

bool OSEdTreeView::isModule ( wxTreeItemId  id) const
private

Returns true if tree node with given id is a module.

Parameters
idId of the tree node.
Returns
True if id is a module.

Definition at line 305 of file OSEdTreeView.cc.

305 {
307}
static bool containsValue(const MapType &aMap, const ValueType &aValue)

References MapTools::containsValue(), and modules_.

Referenced by addItem(), changeText(), onDropDownMenu(), onItemSelected(), and removeItem().

Here is the call graph for this function:

◆ isModuleSelected()

bool OSEdTreeView::isModuleSelected ( ) const

Returns true if a module is selected.

Returns
True, if a module is selected.

Definition at line 731 of file OSEdTreeView.cc.

731 {
732 if (MapTools::containsValue(modules_, GetSelection()) ||
733 infoView_->selectedModule() != "") {
734 return true;
735 }
736 return false;
737}
std::string selectedModule()

References MapTools::containsValue(), infoView_, modules_, and OSEdInfoView::selectedModule().

Referenced by OSEdRemoveModuleCmd::isEnabled().

Here is the call graph for this function:

◆ isOperation()

bool OSEdTreeView::isOperation ( wxTreeItemId  id) const
private

Return true if tree node with given id is an operation.

Parameters
idId of the tree node.
Returns
True if id is an operation.

Definition at line 316 of file OSEdTreeView.cc.

316 {
318}

References MapTools::containsValue(), and operations_.

Referenced by changeText(), onDropDownMenu(), onItemClicked(), onItemSelected(), and removeItem().

Here is the call graph for this function:

◆ isOperationSelected()

bool OSEdTreeView::isOperationSelected ( ) const

Returns true if an operation is selected.

Returns
True, if an operation is selected.

Definition at line 745 of file OSEdTreeView.cc.

745 {
746 if (MapTools::containsValue(operations_, GetSelection()) ||
747 infoView_->selectedOperation() != "") {
748
749 return true;
750 }
751 return false;
752}
std::string selectedOperation()

References MapTools::containsValue(), infoView_, operations_, and OSEdInfoView::selectedOperation().

Referenced by OSEdModifyBehaviorCmd::isEnabled(), OSEdRemoveOperationCmd::isEnabled(), and OSEdSimulateCmd::isEnabled().

Here is the call graph for this function:

◆ isPath()

bool OSEdTreeView::isPath ( wxTreeItemId  id) const
private

Returns true if tree node with given id is a path.

Parameters
idId of the tree node.
Returns
True if id is a path.

Definition at line 294 of file OSEdTreeView.cc.

294 {
296}

References MapTools::containsValue(), and paths_.

Referenced by addItem(), changeText(), onDropDownMenu(), onItemSelected(), and removeItem().

Here is the call graph for this function:

◆ isPathSelected()

bool OSEdTreeView::isPathSelected ( ) const

Returns true if a path is selected.

Returns
True, if a path is selected.

Definition at line 716 of file OSEdTreeView.cc.

716 {
717 if (MapTools::containsValue(paths_, GetSelection()) ||
718 infoView_->selectedPath() != "") {
719
720 return true;
721 }
722 return false;
723}
std::string selectedPath()

References MapTools::containsValue(), infoView_, paths_, and OSEdInfoView::selectedPath().

Here is the call graph for this function:

◆ moduleIdOfOperation()

wxTreeItemId OSEdTreeView::moduleIdOfOperation ( wxTreeItemId  id)

Returns the id of the module of the operation with a given id.

Parameters
idThe id of the operation.
Returns
The id of the module.

Definition at line 420 of file OSEdTreeView.cc.

420 {
421 return GetItemParent(id);
422}

Referenced by OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdSimulateCmd::Do(), OSEdModifyBehaviorCmd::isEnabled(), and OSEdRemoveOperationCmd::isEnabled().

◆ moduleOfOperation()

string OSEdTreeView::moduleOfOperation ( wxTreeItemId  id)

Returns the module of an operation with a given id.

Parameters
idThe id of operation.
Returns
The name of the module.

Definition at line 407 of file OSEdTreeView.cc.

407 {
408 wxTreeItemId modId = GetItemParent(id);
409 string moduleName = MapTools::keyForValue<string>(modules_, modId);
410 return moduleName;
411}

References MapTools::keyForValue(), and modules_.

Referenced by OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdSimulateCmd::Do(), OSEdModifyBehaviorCmd::isEnabled(), and onItemSelected().

Here is the call graph for this function:

◆ onDropDownMenu()

void OSEdTreeView::onDropDownMenu ( wxMouseEvent &  event)
private

Handles the event when right mouse button is clicked.

A different drop down menu is showed, depending on where mouse button is clicked.

Parameters
eventEvent to be handled.

Definition at line 243 of file OSEdTreeView.cc.

243 {
244
245 // coordinates of mouse click
247 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
248 wxPoint pos = event.GetPosition();
249 int flags = wxTREE_HITTEST_ONITEMLABEL;
250 wxTreeItemId id = HitTest(pos, flags);
251
252 // mouse is not clicked on a tree item
253 if (!id.IsOk()) {
254 return;
255 }
256
257 SelectItem(id);
258 DropDownMenu* menu = NULL;
259 if (isPath(id)) {
260
262 mainFrame->statusBar()->
263 SetStatusText(WxConversion::toWxString(fmt.str()));
265 PopupMenu(menu, pos);
266 } else if (isModule(id)) {
267
269 mainFrame->statusBar()->
270 SetStatusText(WxConversion::toWxString(fmt.str()));
272 PopupMenu(menu, pos);
273 } else if (isOperation(id)) {
274
275 format fmt =
277 mainFrame->statusBar()->
278 SetStatusText(WxConversion::toWxString(fmt.str()));
280 PopupMenu(menu, pos);
281 } else {
282 mainFrame->statusBar()->SetStatusText(_T("Cannot open"));
283 }
284 delete menu;
285}
@ MENU_MODULE
Module menu.
@ MENU_OPERATION
Operation menu.
@ MENU_PATH
Path menu.
wxStatusBar * statusBar() const
static OSEdTextGenerator & instance()
@ TXT_STATUS_MODULE_SELECTED
Status bar text when module is selected.
@ TXT_STATUS_OPERATION_SELECTED
Status bar text when operation is selected.
@ TXT_STATUS_PATH_SELECTED
Status bar text when path is selected.
virtual boost::format text(int textId)

References OSEdTextGenerator::instance(), isModule(), isOperation(), isPath(), DropDownMenu::MENU_MODULE, DropDownMenu::MENU_OPERATION, DropDownMenu::MENU_PATH, OSEdMainFrame::statusBar(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_STATUS_MODULE_SELECTED, OSEdTextGenerator::TXT_STATUS_OPERATION_SELECTED, and OSEdTextGenerator::TXT_STATUS_PATH_SELECTED.

Here is the call graph for this function:

◆ onItemClicked()

void OSEdTreeView::onItemClicked ( wxTreeEvent &  event)
private

Handles the event when item is selected on tree by double-clicking with mouse.

Double clicking an operation opens an operation property dialog, where operation properties can be modified.

Parameters
eventEvent to be handled.

Definition at line 220 of file OSEdTreeView.cc.

220 {
221 wxTreeItemId id = event.GetItem();
222 if (isOperation(id)) {
223 // operation is clicked, lets open the property dialog
224 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
225 CommandRegistry* registry = mainFrame->registry();
226 GUICommand* command =
228 command->setParentWindow(mainFrame);
229 command->Do();
230 delete command;
231 }
232}
GUICommand * createCommand(const int id)
virtual bool Do()=0
void setParentWindow(wxWindow *view)
Definition GUICommand.cc:64
@ CMD_PROPERTIES
Operation properties command id.
CommandRegistry * registry() const

References OSEdConstants::CMD_PROPERTIES, CommandRegistry::createCommand(), GUICommand::Do(), isOperation(), OSEdMainFrame::registry(), and GUICommand::setParentWindow().

Here is the call graph for this function:

◆ onItemSelected()

void OSEdTreeView::onItemSelected ( wxTreeEvent &  event)
private

Handles the event when item is selected on tree.

If selected item is a path, path view is shown. If selected item is a module, module view is shown. If selected item is an operation, operation view is shown.

Parameters
eventThe event to be handled.

Definition at line 171 of file OSEdTreeView.cc.

171 {
172
173 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
175 wxTreeItemId id = event.GetItem();
176
177 if (isPath(id)) {
178 string path = MapTools::keyForValue<string>(paths_, id);
180 mainFrame->statusBar()->
181 SetStatusText(WxConversion::toWxString(fmt.str()));
182 infoView_->moduleView(path);
183 } else if (isModule(id)) {
184 string moduleName = MapTools::keyForValue<string>(modules_, id);
186 mainFrame->statusBar()->
187 SetStatusText(WxConversion::toWxString(fmt.str()));
188 string pathName = pathOfModule(id);
189 infoView_->operationView(pathName, moduleName);
190 } else if (isOperation(id)) {
191
192 string opName = MapTools::keyForValue<string>(operations_, id);
193 format fmt =
195
196 mainFrame->statusBar()->
197 SetStatusText(WxConversion::toWxString(fmt.str()));
198
199 string modName = moduleOfOperation(id);
200 string pathName = pathOfModule(GetItemParent(id));
201 infoView_->operationPropertyView(opName, modName, pathName);
202 } else {
203 mainFrame->statusBar()->SetStatusText(_T(""));
204 // root is selected
206 }
207 wxGetApp().mainFrame()->updateMenuBar();
208}
void operationView(const std::string &path, const std::string &mod)
void moduleView(const std::string &name)
void operationPropertyView(const std::string &opName, const std::string &modName, const std::string &pathName)
std::string pathOfModule(wxTreeItemId id)
std::string moduleOfOperation(wxTreeItemId id)

References infoView_, OSEdTextGenerator::instance(), isModule(), isOperation(), isPath(), MapTools::keyForValue(), moduleOfOperation(), modules_, OSEdInfoView::moduleView(), OSEdInfoView::operationPropertyView(), operations_, OSEdInfoView::operationView(), pathOfModule(), paths_, OSEdInfoView::pathView(), OSEdMainFrame::statusBar(), Texts::TextGenerator::text(), WxConversion::toWxString(), OSEdTextGenerator::TXT_STATUS_MODULE_SELECTED, OSEdTextGenerator::TXT_STATUS_OPERATION_SELECTED, and OSEdTextGenerator::TXT_STATUS_PATH_SELECTED.

Here is the call graph for this function:

◆ operator=()

OSEdTreeView & OSEdTreeView::operator= ( const OSEdTreeView )
private

Assignment not allowed.

◆ pathIdOfModule()

wxTreeItemId OSEdTreeView::pathIdOfModule ( wxTreeItemId  id)

Returns the id of the path in which module with given id belongs to.

Parameters
idId of the module.
Returns
The id of the path.

Definition at line 444 of file OSEdTreeView.cc.

444 {
445 return GetItemParent(id);
446}

◆ pathOfModule()

string OSEdTreeView::pathOfModule ( wxTreeItemId  id)

Returns the path of the module with given id.

Parameters
idThe id of the module.
Returns
The name of the path.

Definition at line 431 of file OSEdTreeView.cc.

431 {
432 wxTreeItemId pathId = GetItemParent(id);
433 std::string path = MapTools::keyForValue<string>(paths_, pathId);
434 return path;
435}

References MapTools::keyForValue(), and paths_.

Referenced by OSEdAddOperationCmd::Do(), OSEdBuildCmd::Do(), OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdSimulateCmd::Do(), OSEdAddOperationCmd::isEnabled(), OSEdBuildCmd::isEnabled(), OSEdModifyBehaviorCmd::isEnabled(), OSEdRemoveModuleCmd::isEnabled(), OSEdRemoveOperationCmd::isEnabled(), onItemSelected(), and selectedOperation().

Here is the call graph for this function:

◆ removeItem()

void OSEdTreeView::removeItem ( wxTreeItemId  id)

Removes an item from the tree view.

Collapses the parent and set the parent selected.

Parameters
idThe id of the item to be removed.

Definition at line 622 of file OSEdTreeView.cc.

622 {
623
624 wxTreeItemId parent = GetItemParent(id);
625 Collapse(parent);
626 SelectItem(parent);
627 DeleteChildren(id);
628 Delete(id);
629
630 // remove the item from the inner data structure also
631 if (isOperation(id)) {
633 Iter it = operations_.find(key);
634 operations_.erase(it);
635 } else if (isModule(id)) {
636 string key = MapTools::keyForValue<string>(modules_, id);
637 IterM it = modules_.find(key);
638 modules_.erase(it);
639 Iter ot = operations_.begin();
640 while (ot != operations_.end()) {
641 if (GetItemParent((*ot).second) == id) {
642 Iter next = ot;
643 next++;
644 operations_.erase(ot);
645 ot = next;
646 } else {
647 ot++;
648 }
649 }
650 } else if (isPath(id)) {
651 // paths can not be erased
652 assert(false);
653 }
654}

References assert, isModule(), isOperation(), isPath(), MapTools::keyForValue(), modules_, and operations_.

Referenced by OSEdRemoveModuleCmd::Do(), and OSEdRemoveOperationCmd::Do().

Here is the call graph for this function:

◆ selectedModule()

string OSEdTreeView::selectedModule ( )

Returns the selected module.

If no module is selected, an empty string is returned.

Returns
The selected module or an empty string.

Definition at line 513 of file OSEdTreeView.cc.

513 {
514
515 IterM it = modules_.begin();
516
517 // first look from the tree view
518 while (it != modules_.end()) {
519 if (IsSelected((*it).second)) {
520 return (*it).first;
521 }
522 it++;
523 }
524
525 // then look from the info view
526 string module = infoView_->selectedModule();
527 return module;
528}

References modules_.

Referenced by OSEdAddOperationCmd::Do(), OSEdBuildCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdAddOperationCmd::isEnabled(), OSEdBuildCmd::isEnabled(), and selectedOperation().

◆ selectedModuleId()

wxTreeItemId OSEdTreeView::selectedModuleId ( )

Returns the id of selected module.

Exceptions
NotAvailableIf no module is selected.
Returns
The id of selected module.

Definition at line 537 of file OSEdTreeView.cc.

537 {
538 if (MapTools::containsValue(modules_, GetSelection())) {
539 return GetSelection();
540 }
541
542 IterM it = modules_.begin();
543 // first search the selected module from tree view
544 while (it != modules_.end()) {
545 if (IsSelected((*it).second)) {
546 return (*it).second;
547 }
548 it++;
549 }
550
551 // no module in tree view selected, look from the info view
552 string module = infoView_->selectedModule();
553 if (module != "") {
554 try {
555 it = modules_.find(module);
556 wxTreeItemId id = it->second;
557 return id;
558 } catch (const KeyNotFound& k) {
559 assert(false);
560 }
561 }
562
563 throw NotAvailable(__FILE__, __LINE__, __func__);
564}
#define __func__

References __func__, assert, MapTools::containsValue(), and modules_.

Referenced by OSEdAddOperationCmd::Do(), OSEdBuildCmd::Do(), OSEdRemoveModuleCmd::Do(), OSEdAddOperationCmd::isEnabled(), OSEdBuildCmd::isEnabled(), OSEdRemoveModuleCmd::isEnabled(), and selectedOperation().

Here is the call graph for this function:

◆ selectedOperation()

Operation * OSEdTreeView::selectedOperation ( )

Returns the selected operation.

If no operation is selected, NULL is returned.

Returns
The selected operation.

Definition at line 328 of file OSEdTreeView.cc.

328 {
329
330 Iter it = operations_.begin();
331 string opName = "";
332 string modName = "";
333 string pathName = "";
334
335 // get the name of the selected operation, its module and its path.
336 while(it != operations_.end()) {
337 if (IsSelected((*it).second)) {
338 opName = (*it).first;
339 wxTreeItemId opId = (*it).second;
340
341 wxTreeItemId moduleId = GetItemParent(opId);
342 wxTreeItemId pathId = GetItemParent(moduleId);
343
344 modName = WxConversion::toString(GetItemText(moduleId));
345 pathName = WxConversion::toString(GetItemText(pathId));
346
347 break;
348 }
349 it++;
350 }
351
352 // if no operation was selected in a tree view, let's look from
353 // the info view
354 if (opName == "") {
355 opName = infoView_->selectedOperation();
356 if (opName == "") {
357 return NULL;
358 } else {
359
360 modName = selectedModule();
361 assert(modName != "");
362
363 pathName = pathOfModule(selectedModuleId());
364 assert(pathName != "");
365 }
366 }
367
368 Operation* op = OperationContainer::operation(pathName, modName, opName);
369 return op;
370}
wxTreeItemId selectedModuleId()
std::string selectedModule()
static Operation * operation(const std::string &path, const std::string &module, const std::string &oper)
static std::string toString(const wxString &source)

References assert, infoView_, OperationContainer::operation(), operations_, pathOfModule(), selectedModule(), selectedModuleId(), OSEdInfoView::selectedOperation(), and WxConversion::toString().

Referenced by OSEdPropertiesCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdSimulateCmd::Do(), OSEdPropertiesCmd::isEnabled(), and OSEdSimulateCmd::isEnabled().

Here is the call graph for this function:

◆ selectedOperationId()

wxTreeItemId OSEdTreeView::selectedOperationId ( )

Returns the id of selected operation.

Exceptions
NotAvailableIf no operation is selected.
Returns
The id of selected operation.

Definition at line 379 of file OSEdTreeView.cc.

379 {
380 Iter it = operations_.begin();
381 // first look from the tree view
382 while (it != operations_.end()) {
383 if (IsSelected((*it).second)) {
384 return (*it).second;
385 }
386 it++;
387 }
388
389 string name = infoView_->selectedOperation();
390 it = operations_.begin();
391 while (it != operations_.end()) {
392 if ((*it).first == name) {
393 return (*it).second;
394 }
395 it++;
396 }
397 throw NotAvailable(__FILE__, __LINE__, __func__);
398}

References __func__, infoView_, operations_, and OSEdInfoView::selectedOperation().

Referenced by OSEdModifyBehaviorCmd::Do(), OSEdPropertiesCmd::Do(), OSEdRemoveOperationCmd::Do(), OSEdSimulateCmd::Do(), OSEdModifyBehaviorCmd::isEnabled(), and OSEdRemoveOperationCmd::isEnabled().

Here is the call graph for this function:

◆ selectedPath()

string OSEdTreeView::selectedPath ( )

Returns the selected path.

If not path is selected, an empty string is returned.

Returns
The selected path, or an empty string.

Definition at line 456 of file OSEdTreeView.cc.

456 {
457
458 Iter it = paths_.begin();
459
460 // first look from the tree view
461 while (it != paths_.end()) {
462 if (IsSelected((*it).second)) {
463 return (*it).first;
464 }
465 it++;
466 }
467
468 // then info view
469 string path = infoView_->selectedPath();
470 return path;
471}

References infoView_, paths_, and OSEdInfoView::selectedPath().

Referenced by OSEdAddModuleCmd::Do(), and OSEdAddModuleCmd::isEnabled().

Here is the call graph for this function:

◆ selectedPathId()

wxTreeItemId OSEdTreeView::selectedPathId ( )

Returns the id of selected path.

Exceptions
NotAvailableIf path is not selected.
Returns
Id of selected path.

Definition at line 480 of file OSEdTreeView.cc.

480 {
481 Iter it = paths_.begin();
482
483 // first look from the tree view
484 while (it != paths_.end()) {
485 if (IsSelected((*it).second)) {
486 return (*it).second;
487 }
488 it++;
489 }
490
491 // then look from the info view
492 string path = infoView_->selectedPath();
493 if (path != "") {
494 try {
495 wxTreeItemId id = paths_[path];
496 return id;
497 } catch (const KeyNotFound& k) {
498 assert(false);
499 }
500 }
501
502 throw NotAvailable(__FILE__, __LINE__, __func__);
503}

References __func__, assert, infoView_, paths_, and OSEdInfoView::selectedPath().

Referenced by OSEdAddModuleCmd::Do().

Here is the call graph for this function:

◆ update()

void OSEdTreeView::update ( )

Updates the treeview.

Definition at line 670 of file OSEdTreeView.cc.

670 {
671
672 Iter it = paths_.begin();
673 while (it != paths_.end()) {
674 if (IsSelected((*it).second)) {
675 infoView_->moduleView((*it).first);
676 return;
677 }
678 it++;
679 }
680
681 IterM itm = modules_.begin();
682 while (itm != modules_.end()) {
683 if (IsSelected((*itm).second)) {
684 wxTreeItemId pathId = GetItemParent((*itm).second);
685 string pathName = WxConversion::toString(GetItemText(pathId));
686 infoView_->operationView(pathName, (*itm).first);
687 return;
688 }
689 itm++;
690 }
691
692 it = operations_.begin();
693 while (it != operations_.end()) {
694 if (IsSelected((*it).second)) {
695 wxTreeItemId modId = GetItemParent((*it).second);
696 wxTreeItemId pathId = GetItemParent(modId);
697
698 string modName = WxConversion::toString(GetItemText(modId));
699 string pathName = WxConversion::toString(GetItemText(pathId));
700
701 infoView_->operationPropertyView((*it).first, modName, pathName);
702 return;
703 }
704 it++;
705 }
706
708}

References infoView_, modules_, OSEdInfoView::moduleView(), OSEdInfoView::operationPropertyView(), operations_, OSEdInfoView::operationView(), paths_, OSEdInfoView::pathView(), and WxConversion::toString().

Referenced by OSEdAddModuleCmd::Do(), OSEdAddOperationCmd::Do(), and OSEdPropertiesCmd::Do().

Here is the call graph for this function:

Member Data Documentation

◆ infoView_

OSEdInfoView* OSEdTreeView::infoView_
private

◆ modules_

std::multimap<std::string, wxTreeItemId> OSEdTreeView::modules_
private

◆ operations_

std::multimap<std::string, wxTreeItemId> OSEdTreeView::operations_
private

◆ paths_

std::map<std::string, wxTreeItemId> OSEdTreeView::paths_
private

Paths of the operation data base.

Definition at line 104 of file OSEdTreeView.hh.

Referenced by changeText(), constructTree(), isPath(), isPathSelected(), onItemSelected(), pathOfModule(), selectedPath(), selectedPathId(), and update().


The documentation for this class was generated from the following files: