OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
wxString name_
 Name of the function unit.
 
wxListCtrl * portListCtrl_
 Port list control.
 
wxListCtrl * operationListCtrl_
 Operation list control.
 
wxChoice * addressSpaceChoice_
 Address Space choice control.
 
wxStaticBoxSizer * portsSizer_
 Sizer for the port list controls.
 
wxStaticBoxSizer * operationsSizer_
 Sizer for the operation list controls.
 

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.

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}
virtual bool TransferDataToWindow()
Definition FUDialog.cc:228
wxListCtrl * operationListCtrl_
Operation list control.
Definition FUDialog.hh:90
void setTexts()
Definition FUDialog.cc:149
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition FUDialog.cc:747
wxChoice * addressSpaceChoice_
Address Space choice control.
Definition FUDialog.hh:92
wxListCtrl * portListCtrl_
Port list control.
Definition FUDialog.hh:88
wxString name_
Name of the function unit.
Definition FUDialog.hh:85
TTAMachine::FunctionUnit * functionUnit_
FunctionUnit to modify.
Definition FUDialog.hh:83

◆ ~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}
wxStaticBoxSizer * portsSizer_
Sizer for the port list controls.
Definition FUDialog.hh:95
wxStaticBoxSizer * operationsSizer_
Sizer for the operation list controls.
Definition FUDialog.hh:97

References ID_ADD_OPERATION, ID_ADD_OPERATION_FROM_OPSET, ID_ADD_PORT, ID_ADDRESS_SPACE, ID_DELETE_OPERATION, ID_DELETE_PORT, ID_EDIT_OPERATION, ID_EDIT_PORT, ID_HELP, ID_LABEL_AS, ID_LABEL_NAME, ID_NAME, ID_OPERATION_LIST, ID_PORT_LIST, operationsSizer_, and portsSizer_.

◆ 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}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onEditOperation(wxCommandEvent &event)
Definition FUDialog.cc:507

References dummy, and onEditOperation().

Here is the call graph for this function:

◆ 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;
383}
void onEditPort(wxCommandEvent &event)
Definition FUDialog.cc:392

References dummy, and onEditPort().

Here is the call graph for this function:

◆ 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}
static std::string toString(const T &source)
void updateOperationList()
Definition FUDialog.cc:650
static const std::string COMP_NEW_NAME_PREFIX_OPERATION
Prefix for new operation names.
virtual void loadState(const ObjectState *state)
virtual ObjectState * saveState() const
virtual bool hasOperation(const std::string &name) const

References ProDeConstants::COMP_NEW_NAME_PREFIX_OPERATION, functionUnit_, TTAMachine::FunctionUnit::hasOperation(), TTAMachine::FunctionUnit::loadState(), TTAMachine::FunctionUnit::saveState(), Conversion::toString(), and updateOperationList().

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}
std::string errorMessage() const
Definition Exception.cc:123
static wxString toWxString(const std::string &source)

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

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 }
341}
void updatePortList()
Definition FUDialog.cc:618
static const int DEFAULT_WIDTH
Default bit width.
static const std::string COMP_NEW_NAME_PREFIX_PORT
Prefix for new port names.
virtual bool hasPort(const std::string &name) const
Definition Unit.cc:96

References ProDeConstants::COMP_NEW_NAME_PREFIX_PORT, ModelConstants::DEFAULT_WIDTH, functionUnit_, TTAMachine::Unit::hasPort(), Conversion::toString(), and updatePortList().

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}
virtual HWOperation * operation(const std::string &name) const
static std::string lcStringSelection(wxListCtrl *list, int column)

References functionUnit_, WidgetTools::lcStringSelection(), TTAMachine::FunctionUnit::operation(), operationListCtrl_, and updateOperationList().

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;
357}
#define assert(condition)
TTAMachine::FUPort * selectedPort()
Definition FUDialog.cc:366

References assert, selectedPort(), and updatePortList().

Here is the call graph for this function:

◆ 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}
TTAMachine::HWOperation * selectedOperation()
Definition FUDialog.cc:550

References functionUnit_, TTAMachine::FunctionUnit::loadState(), TTAMachine::FunctionUnit::saveState(), selectedOperation(), and updateOperationList().

Referenced by onActivateOperation().

Here is the call graph for this function:

◆ 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();
400}

References selectedPort(), and updatePortList().

Referenced by onActivatePort().

Here is the call graph for this function:

◆ 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, and name_.

◆ 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}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static bool isValidComponentName(const std::string &name)
static ProDeTextGenerator * instance()
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
@ COMP_FUNCTION_UNIT
Name for FU (w/o article).
@ COMP_A_FUNCTION_UNIT
Name for FU (w/ article).
@ COMP_MACHINE
Text for machine description.
virtual Machine * machine() const
virtual TCEString name() const
virtual void setName(const std::string &name)
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual boost::format text(int textId)
static std::string toString(const wxString &source)

References ProDeTextGenerator::COMP_A_FUNCTION_UNIT, ProDeTextGenerator::COMP_FUNCTION_UNIT, ProDeTextGenerator::COMP_MACHINE, TTAMachine::Machine::Navigator< ComponentType >::count(), functionUnit_, TTAMachine::Machine::functionUnitNavigator(), ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), machine, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, TTAMachine::Component::name(), name_, TTAMachine::FunctionUnit::setName(), 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}
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.

References ID_DELETE_OPERATION, ID_EDIT_OPERATION, ProDeTextGenerator::instance(), operationListCtrl_, 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) {
571 FindWindow(ID_EDIT_OPERATION)->Disable();
572 return;
573 }
575 FindWindow(ID_EDIT_OPERATION)->Enable();
576}

References ID_DELETE_OPERATION, ID_EDIT_OPERATION, and operationListCtrl_.

Referenced by updateOperationList().

◆ 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(
690 button = prodeTexts->text(
692 contextMenu->Append(
694 portListCtrl_->PopupMenu(contextMenu, event.GetPoint());
695}

References ID_DELETE_PORT, ID_EDIT_PORT, ProDeTextGenerator::instance(), portListCtrl_, 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}

References ID_DELETE_PORT, ID_EDIT_PORT, and portListCtrl_.

Referenced by updatePortList().

◆ 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}
static const wxString NONE
Constant for "None".
virtual void setAddressSpace(AddressSpace *as)
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

References addressSpaceChoice_, TTAMachine::Machine::addressSpaceNavigator(), functionUnit_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), ProDeConstants::NONE, TTAMachine::FunctionUnit::setAddressSpace(), 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 functionUnit_, WidgetTools::lcStringSelection(), TTAMachine::FunctionUnit::operation(), and operationListCtrl_.

Referenced by onEditOperation().

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}
virtual FUPort * operationPort(const std::string &name) const

References functionUnit_, WidgetTools::lcStringSelection(), TTAMachine::FunctionUnit::operationPort(), and portListCtrl_.

Referenced by onDeletePort(), and onEditPort().

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
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);
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}
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_LABEL_ADDRESS_SPACE
Label for address spave selector.
@ TXT_COLUMN_WIDTH
Label for width column in a list.
@ TXT_FU_OPERATIONS_BOX
Operations box title.
@ TXT_FU_PORTS_BOX
Ports box title.
@ TXT_COLUMN_TRIGGERS
Label for T column in a list.
@ TXT_FU_DIALOG_TITLE
Function unit dialog title.
@ TXT_COLUMN_NAME
Label for name column in a list.
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD_OPERATION, ID_ADD_PORT, ID_DELETE_OPERATION, ID_DELETE_PORT, ID_EDIT_OPERATION, ID_EDIT_PORT, ID_HELP, ID_LABEL_AS, ID_LABEL_NAME, ID_OPERATION_LIST, ID_PORT_LIST, GUITextGenerator::instance(), ProDeTextGenerator::instance(), operationsSizer_, portsSizer_, 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
234
235 return wxWindow::TransferDataToWindow();
236}
void updateAddressSpaceChoice()
Definition FUDialog.cc:586

References functionUnit_, TTAMachine::Component::name(), name_, WxConversion::toWxString(), updateAddressSpaceChoice(), updateOperationList(), and updatePortList().

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}
virtual AddressSpace * addressSpace() const

References TTAMachine::FunctionUnit::addressSpace(), addressSpaceChoice_, TTAMachine::Machine::addressSpaceNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), functionUnit_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), ProDeConstants::NONE, and WxConversion::toWxString().

Referenced by TransferDataToWindow().

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}
void onOperationSelection(wxListEvent &event)
Definition FUDialog.cc:568
virtual int operationCount() const
const std::string & name() const

References dummy, functionUnit_, TTAMachine::HWOperation::name(), onOperationSelection(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), operationListCtrl_, and WxConversion::toWxString().

Referenced by onAddOperation(), onAddOperationFromOpset(), onDeleteOperation(), onEditOperation(), and TransferDataToWindow().

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
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}
void onPortSelection(wxListEvent &event)
Definition FUDialog.cc:412
virtual int width() const
virtual bool isTriggering() const
Definition FUPort.cc:182
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135

References dummy, functionUnit_, TTAMachine::FUPort::isTriggering(), TTAMachine::Port::name(), onPortSelection(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::Unit::portCount(), portListCtrl_, Conversion::toString(), WxConversion::toWxString(), and TTAMachine::BaseFUPort::width().

Referenced by onAddPort(), onDeletePort(), onEditPort(), and TransferDataToWindow().

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.

Referenced by onSetAddressSpace(), and updateAddressSpaceChoice().

◆ functionUnit_

TTAMachine::FunctionUnit* FUDialog::functionUnit_
private

◆ name_

wxString FUDialog::name_
private

Name of the function unit.

Definition at line 85 of file FUDialog.hh.

Referenced by onName(), onOK(), and TransferDataToWindow().

◆ operationListCtrl_

wxListCtrl* FUDialog::operationListCtrl_
private

◆ operationsSizer_

wxStaticBoxSizer* FUDialog::operationsSizer_
private

Sizer for the operation list controls.

Definition at line 97 of file FUDialog.hh.

Referenced by createContents(), and setTexts().

◆ portListCtrl_

wxListCtrl* FUDialog::portListCtrl_
private

Port list control.

Definition at line 88 of file FUDialog.hh.

Referenced by onPortRightClick(), onPortSelection(), selectedPort(), and updatePortList().

◆ portsSizer_

wxStaticBoxSizer* FUDialog::portsSizer_
private

Sizer for the port list controls.

Definition at line 95 of file FUDialog.hh.

Referenced by createContents(), and setTexts().


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