OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
FUDialog Class Reference

#include <FUDialog.hh>

Inheritance diagram for FUDialog:
Inheritance graph
Collaboration diagram for FUDialog:
Collaboration graph

Public Member Functions

 FUDialog (wxWindow *parent, TTAMachine::FunctionUnit *functionUnit)
 
virtual ~FUDialog ()
 

Protected Member Functions

virtual bool TransferDataToWindow ()
 

Private Types

enum  {
  ID_NAME =10000, ID_ADDRESS_SPACE, ID_OPERATION_LIST, ID_ADD_OPERATION,
  ID_EDIT_OPERATION, ID_ADD_OPERATION_FROM_OPSET, ID_DELETE_OPERATION, ID_PORT_LIST,
  ID_ADD_PORT, ID_EDIT_PORT, ID_DELETE_PORT, ID_HELP,
  ID_LABEL_NAME, ID_LABEL_AS
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
TTAMachine::FUPortselectedPort ()
 
TTAMachine::HWOperationselectedOperation ()
 
void onOK (wxCommandEvent &event)
 
void onHelp (wxCommandEvent &event)
 
void onName (wxCommandEvent &event)
 
void onPortSelection (wxListEvent &event)
 
void onPortRightClick (wxListEvent &event)
 
void onAddPort (wxCommandEvent &event)
 
void onDeletePort (wxCommandEvent &event)
 
void onEditPort (wxCommandEvent &event)
 
void onActivatePort (wxListEvent &event)
 
void onOperationSelection (wxListEvent &event)
 
void onAddOperation (wxCommandEvent &event)
 
void onAddOperationFromOpset (wxCommandEvent &event)
 
void onDeleteOperation (wxCommandEvent &event)
 
void onEditOperation (wxCommandEvent &event)
 
void onSetAddressSpace (wxCommandEvent &event)
 
void onActivateOperation (wxListEvent &event)
 
void onOperationRightClick (wxListEvent &event)
 
void updateAddressSpaceChoice ()
 
void updatePortList ()
 
void updateOperationList ()
 
void setTexts ()
 

Private Attributes

TTAMachine::FunctionUnitfunctionUnit_
 FunctionUnit to modify. More...
 
wxString name_
 Name of the function unit. More...
 
wxListCtrl * portListCtrl_
 Port list control. More...
 
wxListCtrl * operationListCtrl_
 Operation list control. More...
 
wxChoice * addressSpaceChoice_
 Address Space choice control. More...
 
wxStaticBoxSizer * portsSizer_
 Sizer for the port list controls. More...
 
wxStaticBoxSizer * operationsSizer_
 Sizer for the operation list controls. More...
 

Detailed Description

Dialog for querying FunctionUnit parameters from the user.

Definition at line 48 of file FUDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NAME 
ID_ADDRESS_SPACE 
ID_OPERATION_LIST 
ID_ADD_OPERATION 
ID_EDIT_OPERATION 
ID_ADD_OPERATION_FROM_OPSET 
ID_DELETE_OPERATION 
ID_PORT_LIST 
ID_ADD_PORT 
ID_EDIT_PORT 
ID_DELETE_PORT 
ID_HELP 
ID_LABEL_NAME 
ID_LABEL_AS 

Definition at line 99 of file FUDialog.hh.

99  {
100  ID_NAME=10000,
107  ID_PORT_LIST,
108  ID_ADD_PORT,
109  ID_EDIT_PORT,
111  ID_HELP,
114  };

Constructor & Destructor Documentation

◆ FUDialog()

FUDialog::FUDialog ( wxWindow *  parent,
TTAMachine::FunctionUnit functionUnit 
)

The Constructor.

Parameters
parentParent window of the dialog.
functionUnitA function unit to be shown in the dialog.

Definition at line 109 of file FUDialog.cc.

111  :
112  wxDialog(parent, -1, _T(""), wxDefaultPosition),
113  functionUnit_(functionUnit),
114  name_(_T("")),
115  portListCtrl_(NULL),
116  operationListCtrl_(NULL),
117  addressSpaceChoice_(NULL) {
118 
119  createContents(this, true, true);
120 
121  portListCtrl_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_PORT_LIST));
123  dynamic_cast<wxListCtrl*>(FindWindow(ID_OPERATION_LIST));
125  dynamic_cast<wxChoice*>(FindWindow(ID_ADDRESS_SPACE));
126 
127  FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
128 
129  FindWindow(wxID_OK)->Disable();
130 
131  // set widget texts
132  setTexts();
133 
135 }

◆ ~FUDialog()

FUDialog::~FUDialog ( )
virtual

The Destructor.

Definition at line 141 of file FUDialog.cc.

141  {
142 }

Member Function Documentation

◆ createContents()

wxSizer * FUDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog window contents.

This method was initially generated with wxDesigner, code will be cleaned up later.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 747 of file FUDialog.cc.

747  {
748 
749  wxFlexGridSizer *item0 = new wxFlexGridSizer( 2, 0, 10 );
750 
751  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
752 
753  wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
754  item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
755 
756  wxTextCtrl *item3 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(150,-1), 0 );
757  item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
758 
759  item0->Add( item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
760 
761  wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
762 
763  wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_AS, wxT("Address Space:"), wxDefaultPosition, wxDefaultSize, 0 );
764  item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
765 
766  wxString *strs6 = (wxString*) NULL;
767  wxChoice *item6 = new wxChoice( parent, ID_ADDRESS_SPACE, wxDefaultPosition, wxSize(150,-1), 0, strs6, 0 );
768  item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
769 
770  item0->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
771 
772  wxStaticBox *item8 = new wxStaticBox( parent, -1, wxT("Operations:") );
773  wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
774  operationsSizer_ = item7;
775 
776  wxListCtrl *item9 = new wxListCtrl( parent, ID_OPERATION_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxSUNKEN_BORDER );
777  item7->Add( item9, 0, wxGROW|wxALL, 5 );
778 
779  wxBoxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
780 
781  wxButton *item11 = new wxButton( parent, ID_ADD_OPERATION, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
782  item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
783 
784  wxButton *item12 = new wxButton( parent, ID_EDIT_OPERATION, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
785  item10->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
786 
787  wxButton *item13 = new wxButton( parent, ID_DELETE_OPERATION, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
788  item10->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
789 
790  item7->Add( item10, 0, wxALIGN_CENTER, 5 );
791 
792  wxButton *item14 = new wxButton( parent, ID_ADD_OPERATION_FROM_OPSET, wxT(" Add from Opset... "), wxDefaultPosition, wxDefaultSize, 0 );
793  item7->Add( item14, 0, wxALL, 5 );
794 
795  item0->Add( item7, 0, wxGROW|wxALL, 5 );
796 
797  wxStaticBox *item16 = new wxStaticBox( parent, -1, wxT("Ports:") );
798  wxStaticBoxSizer *item15 = new wxStaticBoxSizer( item16, wxVERTICAL );
799  portsSizer_ = item15;
800 
801  wxListCtrl *item17 = new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxSUNKEN_BORDER );
802  item15->Add( item17, 0, wxGROW|wxALL, 5 );
803 
804  wxBoxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
805 
806  wxButton *item19 = new wxButton( parent, ID_ADD_PORT, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
807  item18->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
808 
809  wxButton *item20 = new wxButton( parent, ID_EDIT_PORT, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
810  item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
811 
812  wxButton *item21 = new wxButton( parent, ID_DELETE_PORT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
813  item18->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
814 
815  item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
816 
817  item0->Add( item15, 0, wxGROW|wxALL, 5 );
818 
819  wxBoxSizer *item25 = new wxBoxSizer( wxHORIZONTAL );
820 
821  wxButton *item26 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
822  item25->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
823 
824  item0->Add( item25, 0, wxALL, 5 );
825 
826  wxBoxSizer *item27 = new wxBoxSizer( wxHORIZONTAL );
827 
828  wxButton *item28 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
829  item27->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
830 
831  wxButton *item29 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
832  item27->Add( item29, 0, wxALIGN_CENTER|wxALL, 5 );
833 
834  item0->Add( item27, 0, wxALL, 5 );
835 
836  if (set_sizer)
837  {
838  parent->SetSizer( item0 );
839  if (call_fit)
840  item0->SetSizeHints( parent );
841  }
842 
843  return item0;
844 }

◆ onActivateOperation()

void FUDialog::onActivateOperation ( wxListEvent &  event)
private

Handles left mouse button double clicks on the operation list.

Definition at line 729 of file FUDialog.cc.

729  {
730  wxCommandEvent dummy;
732 }

References dummy.

◆ onActivatePort()

void FUDialog::onActivatePort ( wxListEvent &  event)
private

Handles left mouse button double clicks on the port list.

Definition at line 380 of file FUDialog.cc.

380  {
381  wxCommandEvent dummy;
382  onEditPort(dummy);
383 }

References dummy.

◆ onAddOperation()

void FUDialog::onAddOperation ( wxCommandEvent &  event)
private

Creates and shows an empty Function Unit Operation Dialog for adding operations.

Not Implemented.

Definition at line 430 of file FUDialog.cc.

430  {
432 
433  // Generate name for the new operation.
434  int i = 1;
437  while (functionUnit_->hasOperation(newName)) {
440  i++;
441  }
442  HWOperation* operation = NULL;
443  operation = new HWOperation(newName, *functionUnit_);
444 
445  OperationDialog dialog(this, operation);
446  if (dialog.ShowModal() == wxID_OK) {
447  delete fu;
448  } else {
450  }
452 }

References ProDeConstants::COMP_NEW_NAME_PREFIX_OPERATION, and Conversion::toString().

Here is the call graph for this function:

◆ onAddOperationFromOpset()

void FUDialog::onAddOperationFromOpset ( wxCommandEvent &  event)
private

Event handler for the add operation from opset button.

Definition at line 458 of file FUDialog.cc.

458  {
459 
460  try {
461  OpsetDialog opsetDialog(this);
462  if (opsetDialog.ShowModal() != wxID_OK) {
463  return;
464  }
465 
466  HWOperation* operation = opsetDialog.createOperation(*functionUnit_);
467 
468  if (operation == NULL) {
469  return;
470  }
471 
472  OperationDialog operationDialog(this, operation);
473  if (operationDialog.ShowModal() != wxID_OK) {
474  delete operation;
475  }
476 
478  } catch (Exception & e) {
479  wxString message = WxConversion::toWxString(e.errorMessage());
480  ErrorDialog dialog(this, message);
481  dialog.ShowModal();
482  return;
483  }
484 }

References OpsetDialog::createOperation(), Exception::errorMessage(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onAddPort()

void FUDialog::onAddPort ( wxCommandEvent &  event)
private

Creates and shows an empty Function Unit Port Dialog for adding ports.

Definition at line 321 of file FUDialog.cc.

321  {
322 
323  // Generate name for the new port.
324  int i = 1;
327  while (functionUnit_->hasPort(newName)) {
330  i++;
331  }
332 
333  FUPort* port = new FUPort(
334  newName, ModelConstants::DEFAULT_WIDTH, *functionUnit_, false, false);
335  FUPortDialog portDialog(this, port);
336  if (portDialog.ShowModal() == wxID_CANCEL) {
337  // adding port was cancelled
338  delete port;
339  }
340  updatePortList();
341 }

References ProDeConstants::COMP_NEW_NAME_PREFIX_PORT, ModelConstants::DEFAULT_WIDTH, and Conversion::toString().

Here is the call graph for this function:

◆ onDeleteOperation()

void FUDialog::onDeleteOperation ( wxCommandEvent &  event)
private

Deletes selected operation from the operation list.

Definition at line 490 of file FUDialog.cc.

490  {
492  if (name == "") {
493  return;
494  }
495  delete functionUnit_->operation(name);
497 }

References WidgetTools::lcStringSelection().

Here is the call graph for this function:

◆ onDeletePort()

void FUDialog::onDeletePort ( wxCommandEvent &  event)
private

Deletes selected port from the port list.

Definition at line 349 of file FUDialog.cc.

349  {
350  FUPort* selected = selectedPort();
351  if (selected == NULL) {
352  return;
353  }
354  assert(selected != NULL);
355  delete selected;
356  updatePortList();
357 }

References assert.

◆ onEditOperation()

void FUDialog::onEditOperation ( wxCommandEvent &  event)
private

Handles the 'Edit Operation' button event.

Opens a FUOperationDialog with the selected operation's attributes set.

Definition at line 507 of file FUDialog.cc.

507  {
508 
509  HWOperation* selected = selectedOperation();
510  if (selected == NULL) {
511  // No operation selected.
512  return;
513  }
514 
516  OperationDialog dialog(this, selected);
517  if (dialog.ShowModal() == wxID_OK) {
518  delete fu;
519  } else {
521  }
523 }

◆ onEditPort()

void FUDialog::onEditPort ( wxCommandEvent &  event)
private

Handles the 'Edit Port' button event.

Opens a FUPortDialog with the selected port set.

Definition at line 392 of file FUDialog.cc.

392  {
393  FUPort* port = selectedPort();
394  if (port == NULL) {
395  return;
396  }
397  FUPortDialog portDialog(this, port);
398  portDialog.ShowModal();
399  updatePortList();
400 }

◆ onHelp()

void FUDialog::onHelp ( wxCommandEvent &  event)
private

◆ onName()

void FUDialog::onName ( wxCommandEvent &  event)
private

Checks whether name field is empty and disables OK button of the dialog if it is.

Definition at line 531 of file FUDialog.cc.

531  {
532  if (!TransferDataFromWindow()) {
533  assert(false);
534  }
535  wxString trimmedName = name_.Trim(false).Trim(true);
536  if (trimmedName == _T("")) {
537  FindWindow(wxID_OK)->Disable();
538  } else {
539  FindWindow(wxID_OK)->Enable();
540  }
541 }

References assert.

◆ onOK()

void FUDialog::onOK ( wxCommandEvent &  event)
private

Validates input in the controls, and updates the FunctionUnit.

Definition at line 243 of file FUDialog.cc.

243  {
244 
245  if (!Validate()) {
246  return;
247  }
248 
249  if (!TransferDataFromWindow()) {
250  return;
251  }
252 
253  string trimmedName =
254  WxConversion::toString(name_.Trim(false).Trim(true));
255 
256  // Check the name validity.
257  if (!MachineTester::isValidComponentName(trimmedName)) {
259  format message =
261  InformationDialog warning(
262  this, WxConversion::toWxString(message.str()));
263  warning.ShowModal();
264  return;
265  }
266 
267  if (trimmedName != functionUnit_->name()) {
270  for (int i = 0; i < navigator.count(); i++) {
271  FunctionUnit* fu = navigator.item(i);
272  if (trimmedName == fu->name()) {
273  ProDeTextGenerator* prodeTexts =
275  format message =
277  format a_fu =
279  format machine =
281  format fu =
283  message % trimmedName % a_fu.str() % machine.str() % fu.str();
284  WarningDialog warning(
285  this, WxConversion::toWxString(message.str()));
286  warning.ShowModal();
287  return;
288  }
289  }
290  }
291  functionUnit_->setName(trimmedName);
292  EndModal(wxID_OK);
293 }

References ProDeTextGenerator::COMP_A_FUNCTION_UNIT, ProDeTextGenerator::COMP_FUNCTION_UNIT, ProDeTextGenerator::COMP_MACHINE, TTAMachine::Machine::Navigator< ComponentType >::count(), ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, TTAMachine::Component::name(), Texts::TextGenerator::text(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onOperationRightClick()

void FUDialog::onOperationRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button was pressed on the operation list.

Parameters
eventInformation about right mouse click event.

Definition at line 705 of file FUDialog.cc.

705  {
706 
707  operationListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
708  wxLIST_STATE_SELECTED);
709 
710  wxMenu* contextMenu = new wxMenu();
711 
713  format button = prodeTexts->text(
715  contextMenu->Append(
717  button = prodeTexts->text(
719  contextMenu->Append(
721  operationListCtrl_->PopupMenu(contextMenu, event.GetPoint());
722 }

References ProDeTextGenerator::instance(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE, and ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT.

Here is the call graph for this function:

◆ onOperationSelection()

void FUDialog::onOperationSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the operation list.

If a operation is selected, buttons are enabled. If no operation is selected the buttons will be disabled.

Parameters
eventListEvent, which may have changed the selection.

Definition at line 568 of file FUDialog.cc.

568  {
569  if (operationListCtrl_->GetSelectedItemCount() != 1) {
570  FindWindow(ID_DELETE_OPERATION)->Disable();
571  FindWindow(ID_EDIT_OPERATION)->Disable();
572  return;
573  }
574  FindWindow(ID_DELETE_OPERATION)->Enable();
575  FindWindow(ID_EDIT_OPERATION)->Enable();
576 }

◆ onPortRightClick()

void FUDialog::onPortRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button was pressed.

Parameters
eventInformation about right mouse click event.

Definition at line 678 of file FUDialog.cc.

678  {
679 
680  portListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
681  wxLIST_STATE_SELECTED);
682 
683  wxMenu* contextMenu = new wxMenu();
684 
686  format button = prodeTexts->text(
688  contextMenu->Append(
689  ID_EDIT_PORT, WxConversion::toWxString(button.str()));
690  button = prodeTexts->text(
692  contextMenu->Append(
694  portListCtrl_->PopupMenu(contextMenu, event.GetPoint());
695 }

References ProDeTextGenerator::instance(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE, and ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT.

Here is the call graph for this function:

◆ onPortSelection()

void FUDialog::onPortSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the port list.

If a port is selected, buttons are enabled. If no port is selected the buttons will be disabled.

Parameters
eventListEvent, which may have changed the selection.

Definition at line 412 of file FUDialog.cc.

412  {
413  if (portListCtrl_->GetSelectedItemCount() != 1) {
414  FindWindow(ID_DELETE_PORT)->Disable();
415  FindWindow(ID_EDIT_PORT)->Disable();
416  return;
417  }
418  FindWindow(ID_DELETE_PORT)->Enable();
419  FindWindow(ID_EDIT_PORT)->Enable();
420 }

◆ onSetAddressSpace()

void FUDialog::onSetAddressSpace ( wxCommandEvent &  event)
private

Sets the function unit address space when user changes it.

Definition at line 299 of file FUDialog.cc.

299  {
300 
301  string asName =
302  WxConversion::toString(addressSpaceChoice_->GetStringSelection());
303 
306  } else {
307 
310 
311  AddressSpace* as = navigator.item(asName);
313  }
314 }

References TTAMachine::Machine::Navigator< ComponentType >::item(), ProDeConstants::NONE, and WxConversion::toString().

Here is the call graph for this function:

◆ selectedOperation()

HWOperation * FUDialog::selectedOperation ( )
private

Returns pointer to the operation, which is selected on the operation list.

Returns
Pointer to the selected operation.

Definition at line 550 of file FUDialog.cc.

550  {
552  if (name == "") {
553  return NULL;
554  }
555  return functionUnit_->operation(name);
556 }

References WidgetTools::lcStringSelection().

Here is the call graph for this function:

◆ selectedPort()

FUPort * FUDialog::selectedPort ( )
private

Returns a pointer to the function unit port which is selected.

Returns
Pointer to the port selected in the port list.

Definition at line 366 of file FUDialog.cc.

366  {
368  if (name == "") {
369  return NULL;
370  }
371  FUPort* port = functionUnit_->operationPort(name);
372  return port;
373 }

References WidgetTools::lcStringSelection().

Here is the call graph for this function:

◆ setTexts()

void FUDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 149 of file FUDialog.cc.

149  {
152 
153  // Dialog title
154  format fmt = prodeTexts->text(ProDeTextGenerator::TXT_FU_DIALOG_TITLE);
155  SetTitle(WxConversion::toWxString(fmt.str()));
156 
157  // buttons
158  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
160 
161  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
163 
166 
169 
172 
175 
178 
181 
184 
185  // widget labels
188 
191 
192  // box sizer labels
193  fmt = prodeTexts->text(ProDeTextGenerator::TXT_FU_PORTS_BOX);
195 
198 
199  // Create port list columns.
200  wxListCtrl* portList =
201  dynamic_cast<wxListCtrl*>(FindWindow(ID_PORT_LIST));
203  portList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
204  wxLIST_FORMAT_CENTER, 30);
205  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
206  portList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
207  wxLIST_FORMAT_LEFT, 110);
208  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_WIDTH);
209  portList->InsertColumn(2, WxConversion::toWxString(fmt.str()),
210  wxLIST_FORMAT_LEFT, 110);
211 
212  // Create operation list column.
213  wxListCtrl* operationList =
214  dynamic_cast<wxListCtrl*>(FindWindow(ID_OPERATION_LIST));
215  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
216  operationList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
217  wxLIST_FORMAT_LEFT, 250);
218 
219  Layout();
220 }

References GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_ADD_DIALOG, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_EDIT_DIALOG, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_NAME, ProDeTextGenerator::TXT_COLUMN_TRIGGERS, ProDeTextGenerator::TXT_COLUMN_WIDTH, ProDeTextGenerator::TXT_FU_DIALOG_TITLE, ProDeTextGenerator::TXT_FU_OPERATIONS_BOX, ProDeTextGenerator::TXT_FU_PORTS_BOX, ProDeTextGenerator::TXT_LABEL_ADDRESS_SPACE, and ProDeTextGenerator::TXT_LABEL_NAME.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool FUDialog::TransferDataToWindow ( )
protectedvirtual

Transfers data from the MOM to the dialog widgets.

Returns
False, if an error occured in the transfer, true otherwise.

Definition at line 228 of file FUDialog.cc.

228  {
229 
231  updatePortList();
234 
235  return wxWindow::TransferDataToWindow();
236 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ updateAddressSpaceChoice()

void FUDialog::updateAddressSpaceChoice ( )
private

Updates 'Address Space' choice control.

Clears all items from the choicer and adds all address spaces plus an item 'NONE' indicating empty selection.

Definition at line 586 of file FUDialog.cc.

586  {
587 
588  addressSpaceChoice_->Clear();
590 
593 
594  // put each address space of the Machine to the control.
595  for (int i = 0; i < navigator.count(); i++) {
596  AddressSpace* as = navigator.item(i);
597  wxString name = WxConversion::toWxString(as->name());
598  addressSpaceChoice_->Append(name);
599  }
600 
601  // set address space selection
603  if (as != NULL) {
604  wxString name = WxConversion::toWxString(as->name());
605  addressSpaceChoice_->SetStringSelection(name);
606  } else {
607  addressSpaceChoice_->SetStringSelection(ProDeConstants::NONE);
608  }
609 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), ProDeConstants::NONE, and WxConversion::toWxString().

Here is the call graph for this function:

◆ updateOperationList()

void FUDialog::updateOperationList ( )
private

Updates operation list.

Definition at line 650 of file FUDialog.cc.

650  {
651 
652  operationListCtrl_->DeleteAllItems();
653 
654  // Operation names are put in a set, which will sort the operation
655  // names automatically.
656  std::set<std::string> operations;
657  for (int i=0; i < functionUnit_->operationCount(); i++) {
658  operations.insert(functionUnit_->operation(i)->name());
659  }
660 
661  std::set<std::string>::reverse_iterator iter = operations.rbegin();
662  for (; iter != operations.rend(); iter++) {
663  wxString name = WxConversion::toWxString(*iter);
664  operationListCtrl_->InsertItem(0, name);
665  }
666 
667  wxListEvent dummy;
669 }

References dummy, and WxConversion::toWxString().

Here is the call graph for this function:

◆ updatePortList()

void FUDialog::updatePortList ( )
private

Updates 'Ports' list control.

Clears all items from the choicer and adds all ports.

Definition at line 618 of file FUDialog.cc.

618  {
619 
620  portListCtrl_->DeleteAllItems();
621 
622  for (int i = 0; i < functionUnit_->portCount(); i++) {
623 
624  FUPort* port = functionUnit_->operationPort(i);
625 
626  bool triggers = port->isTriggering();
627  string width = Conversion::toString(port->width());
628  string name = port->name();
629 
630  // set asterisk symbol in the "T" column if port triggers
631  if (!triggers) {
632  portListCtrl_->InsertItem(i, _T(""), 0);
633  } else {
634  portListCtrl_->InsertItem(i, _T("*"), 0);
635  }
636 
637  portListCtrl_->SetItem(i, 1, WxConversion::toWxString(name));
638  portListCtrl_->SetItem(i, 2, WxConversion::toWxString(width));
639 
640  }
641  wxListEvent dummy;
643 }

References dummy, TTAMachine::FUPort::isTriggering(), TTAMachine::Port::name(), Conversion::toString(), WxConversion::toWxString(), and TTAMachine::BaseFUPort::width().

Here is the call graph for this function:

Member Data Documentation

◆ addressSpaceChoice_

wxChoice* FUDialog::addressSpaceChoice_
private

Address Space choice control.

Definition at line 92 of file FUDialog.hh.

◆ functionUnit_

TTAMachine::FunctionUnit* FUDialog::functionUnit_
private

FunctionUnit to modify.

Definition at line 83 of file FUDialog.hh.

◆ name_

wxString FUDialog::name_
private

Name of the function unit.

Definition at line 85 of file FUDialog.hh.

◆ operationListCtrl_

wxListCtrl* FUDialog::operationListCtrl_
private

Operation list control.

Definition at line 90 of file FUDialog.hh.

◆ operationsSizer_

wxStaticBoxSizer* FUDialog::operationsSizer_
private

Sizer for the operation list controls.

Definition at line 97 of file FUDialog.hh.

◆ portListCtrl_

wxListCtrl* FUDialog::portListCtrl_
private

Port list control.

Definition at line 88 of file FUDialog.hh.

◆ portsSizer_

wxStaticBoxSizer* FUDialog::portsSizer_
private

Sizer for the port list controls.

Definition at line 95 of file FUDialog.hh.


The documentation for this class was generated from the following files:
FUDialog::ID_HELP
@ ID_HELP
Definition: FUDialog.hh:111
FUDialog::onPortSelection
void onPortSelection(wxListEvent &event)
Definition: FUDialog.cc:412
FUDialog::addressSpaceChoice_
wxChoice * addressSpaceChoice_
Address Space choice control.
Definition: FUDialog.hh:92
WarningDialog
Definition: WarningDialog.hh:42
WxConversion::toWxString
static wxString toWxString(const std::string &source)
FUDialog::ID_NAME
@ ID_NAME
Definition: FUDialog.hh:100
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.
Definition: ProDeTextGenerator.hh:95
FUDialog::onEditPort
void onEditPort(wxCommandEvent &event)
Definition: FUDialog.cc:392
ProDeTextGenerator::TXT_FU_DIALOG_TITLE
@ TXT_FU_DIALOG_TITLE
Function unit dialog title.
Definition: ProDeTextGenerator.hh:188
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
FUDialog::ID_ADDRESS_SPACE
@ ID_ADDRESS_SPACE
Definition: FUDialog.hh:101
FUDialog::portListCtrl_
wxListCtrl * portListCtrl_
Port list control.
Definition: FUDialog.hh:88
FUDialog::selectedOperation
TTAMachine::HWOperation * selectedOperation()
Definition: FUDialog.cc:550
FUDialog::updatePortList
void updatePortList()
Definition: FUDialog.cc:618
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
GUITextGenerator
Definition: GUITextGenerator.hh:46
ObjectState
Definition: ObjectState.hh:59
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
FUDialog::setTexts
void setTexts()
Definition: FUDialog.cc:149
FindWindow
Definition: FindWindow.hh:49
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
ProDeTextGenerator::COMP_A_FUNCTION_UNIT
@ COMP_A_FUNCTION_UNIT
Name for FU (w/ article).
Definition: ProDeTextGenerator.hh:264
ProDeTextGenerator::TXT_COLUMN_WIDTH
@ TXT_COLUMN_WIDTH
Label for width column in a list.
Definition: ProDeTextGenerator.hh:109
ProDeConstants::COMP_NEW_NAME_PREFIX_PORT
static const std::string COMP_NEW_NAME_PREFIX_PORT
Prefix for new port names.
Definition: ProDeConstants.hh:373
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
TTAMachine::FUPort::isTriggering
virtual bool isTriggering() const
Definition: FUPort.cc:182
FUDialog::ID_DELETE_PORT
@ ID_DELETE_PORT
Definition: FUDialog.hh:110
FUDialog::updateAddressSpaceChoice
void updateAddressSpaceChoice()
Definition: FUDialog.cc:586
FUDialog::ID_ADD_OPERATION
@ ID_ADD_OPERATION
Definition: FUDialog.hh:103
Conversion::toString
static std::string toString(const T &source)
ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
Definition: ProDeTextGenerator.hh:96
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
Definition: ProDeTextGenerator.hh:223
FUDialog::operationsSizer_
wxStaticBoxSizer * operationsSizer_
Sizer for the operation list controls.
Definition: FUDialog.hh:97
ProDeTextGenerator::MSG_ERROR_SAME_NAME
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
Definition: ProDeTextGenerator.hh:229
ProDeTextGenerator::COMP_FUNCTION_UNIT
@ COMP_FUNCTION_UNIT
Name for FU (w/o article).
Definition: ProDeTextGenerator.hh:263
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProDeConstants::COMP_NEW_NAME_PREFIX_OPERATION
static const std::string COMP_NEW_NAME_PREFIX_OPERATION
Prefix for new operation names.
Definition: ProDeConstants.hh:377
TTAMachine::FUPort
Definition: FUPort.hh:46
FUDialog::onEditOperation
void onEditOperation(wxCommandEvent &event)
Definition: FUDialog.cc:507
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ModelConstants::DEFAULT_WIDTH
static const int DEFAULT_WIDTH
Default bit width.
Definition: ModelConstants.hh:46
ErrorDialog
Definition: ErrorDialog.hh:42
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
ProDeTextGenerator::TXT_COLUMN_TRIGGERS
@ TXT_COLUMN_TRIGGERS
Label for T column in a list.
Definition: ProDeTextGenerator.hh:119
WidgetTools::lcStringSelection
static std::string lcStringSelection(wxListCtrl *list, int column)
Definition: WidgetTools.cc:108
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
ProDeTextGenerator::TXT_LABEL_NAME
@ TXT_LABEL_NAME
Label for component name widget.
Definition: ProDeTextGenerator.hh:56
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
TTAMachine::Unit::hasPort
virtual bool hasPort(const std::string &name) const
Definition: Unit.cc:96
FUDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: FUDialog.cc:228
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
Exception
Definition: Exception.hh:54
TTAMachine::FunctionUnit::setAddressSpace
virtual void setAddressSpace(AddressSpace *as)
Definition: FunctionUnit.cc:594
ProDeTextGenerator::TXT_FU_PORTS_BOX
@ TXT_FU_PORTS_BOX
Ports box title.
Definition: ProDeTextGenerator.hh:189
TTAMachine::Machine::addressSpaceNavigator
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition: Machine.cc:392
MachineTester::isValidComponentName
static bool isValidComponentName(const std::string &name)
Definition: MachineTester.cc:312
ProDeTextGenerator::TXT_FU_OPERATIONS_BOX
@ TXT_FU_OPERATIONS_BOX
Operations box title.
Definition: ProDeTextGenerator.hh:190
FUDialog::ID_LABEL_AS
@ ID_LABEL_AS
Definition: FUDialog.hh:113
TTAMachine::FunctionUnit::saveState
virtual ObjectState * saveState() const
Definition: FunctionUnit.cc:677
FUDialog::ID_LABEL_NAME
@ ID_LABEL_NAME
Definition: FUDialog.hh:112
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GUITextGenerator::TXT_BUTTON_DELETE
@ TXT_BUTTON_DELETE
Label for delete button.
Definition: GUITextGenerator.hh:56
FUDialog::functionUnit_
TTAMachine::FunctionUnit * functionUnit_
FunctionUnit to modify.
Definition: FUDialog.hh:83
FUDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: FUDialog.cc:747
FUDialog::onOperationSelection
void onOperationSelection(wxListEvent &event)
Definition: FUDialog.cc:568
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
FUDialog::ID_EDIT_OPERATION
@ ID_EDIT_OPERATION
Definition: FUDialog.hh:104
FUDialog::ID_EDIT_PORT
@ ID_EDIT_PORT
Definition: FUDialog.hh:109
FUDialog::ID_PORT_LIST
@ ID_PORT_LIST
Definition: FUDialog.hh:107
GUITextGenerator::TXT_BUTTON_ADD_DIALOG
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
Definition: GUITextGenerator.hh:54
FUDialog::ID_OPERATION_LIST
@ ID_OPERATION_LIST
Definition: FUDialog.hh:102
GUITextGenerator::TXT_BUTTON_EDIT_DIALOG
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
Definition: GUITextGenerator.hh:58
FUDialog::ID_ADD_OPERATION_FROM_OPSET
@ ID_ADD_OPERATION_FROM_OPSET
Definition: FUDialog.hh:105
TTAMachine::Component::machine
virtual Machine * machine() const
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
TTAMachine::FunctionUnit::loadState
virtual void loadState(const ObjectState *state)
Definition: FunctionUnit.cc:706
ProDeTextGenerator::COMP_MACHINE
@ COMP_MACHINE
Text for machine description.
Definition: ProDeTextGenerator.hh:252
FUDialog::portsSizer_
wxStaticBoxSizer * portsSizer_
Sizer for the port list controls.
Definition: FUDialog.hh:95
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
FUDialog::ID_ADD_PORT
@ ID_ADD_PORT
Definition: FUDialog.hh:108
WidgetTools::setWidgetLabel
static void setWidgetLabel(wxWindow *widget, std::string text)
Definition: WidgetTools.cc:52
InformationDialog
Definition: InformationDialog.hh:42
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
FUDialog::operationListCtrl_
wxListCtrl * operationListCtrl_
Operation list control.
Definition: FUDialog.hh:90
FUDialog::ID_DELETE_OPERATION
@ ID_DELETE_OPERATION
Definition: FUDialog.hh:106
FUDialog::name_
wxString name_
Name of the function unit.
Definition: FUDialog.hh:85
ProDeConstants::NONE
static const wxString NONE
Constant for "None".
Definition: ProDeConstants.hh:56
WxConversion::toString
static std::string toString(const wxString &source)
TTAMachine::FunctionUnit::setName
virtual void setName(const std::string &name)
Definition: FunctionUnit.cc:118
ProDeTextGenerator::TXT_COLUMN_NAME
@ TXT_COLUMN_NAME
Label for name column in a list.
Definition: ProDeTextGenerator.hh:105
FUPortDialog
Definition: FUPortDialog.hh:44
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
OpsetDialog
Definition: OpsetDialog.hh:50
FUDialog::selectedPort
TTAMachine::FUPort * selectedPort()
Definition: FUDialog.cc:366
OperationDialog
Definition: OperationDialog.hh:49
ProDeTextGenerator::TXT_LABEL_ADDRESS_SPACE
@ TXT_LABEL_ADDRESS_SPACE
Label for address spave selector.
Definition: ProDeTextGenerator.hh:59
TTAMachine::BaseFUPort::width
virtual int width() const
Definition: BaseFUPort.cc:109
FUDialog::updateOperationList
void updateOperationList()
Definition: FUDialog.cc:650
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59