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

#include <OutputOperandDialog.hh>

Inheritance diagram for OutputOperandDialog:
Inheritance graph
Collaboration diagram for OutputOperandDialog:
Collaboration graph

Public Member Functions

 OutputOperandDialog (wxWindow *window, Operand *operand, int index)
 
virtual ~OutputOperandDialog ()
 

Private Types

enum  {
  ID_MEM_DATA , ID_OPERATION_OUTPUT_TYPES , ID_ELEMENT_WIDTH , ID_ELEMENT_COUNT ,
  ID_TEXT_WIDTH , ID_TEXT_COUNT
}
 

Private Member Functions

 OutputOperandDialog (const OutputOperandDialog &)
 Copying not allowed.
 
OutputOperandDialogoperator= (const OutputOperandDialog &)
 Assignment not allowed.
 
wxSizer * createContents (wxWindow *window, bool call_fit, bool set_sizer)
 
void onOk (wxCommandEvent &event)
 
void onType (wxCommandEvent &event)
 
void onElementWidth (wxSpinEvent &event)
 
void onElementCount (wxCommandEvent &event)
 
void updateTypes ()
 
void updateElementWidths ()
 
void updateElementCounts ()
 
void setTexts ()
 

Private Attributes

Operandoperand_
 Operand to be modified.
 
bool memData_
 Flag indicating whether operand is memory data or not.
 
int index_
 Index of the operand.
 
wxChoice * outputTypesComboBox_
 Choice box for operation input types.
 
wxSpinCtrl * elementWidthSpinCtrl_
 Spin ctrl for operand element width.
 
wxChoice * elementCountChoice_
 Choice box for operand element count.
 
int type_
 Current operand type in choice box.
 
int elemWidth_
 Current element width in choice box.
 
int elemCount_
 Current element count in choice box.
 
std::vector< std::string > outputTypes_
 Output types.
 
operandList operandTypes_
 

Detailed Description

Class for adding or modifying output operands.

Definition at line 49 of file OutputOperandDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Component ids.

Enumerator
ID_MEM_DATA 

Memory data choice.

ID_OPERATION_OUTPUT_TYPES 

Output Type ComboBox.

ID_ELEMENT_WIDTH 
ID_ELEMENT_COUNT 
ID_TEXT_WIDTH 
ID_TEXT_COUNT 

Definition at line 74 of file OutputOperandDialog.hh.

74 {
75 ID_MEM_DATA, ///< Memory data choice.
76 ID_OPERATION_OUTPUT_TYPES, ///< Output Type ComboBox
81 };
@ ID_MEM_DATA
Memory data choice.
@ ID_OPERATION_OUTPUT_TYPES
Output Type ComboBox.

Constructor & Destructor Documentation

◆ OutputOperandDialog() [1/2]

OutputOperandDialog::OutputOperandDialog ( wxWindow *  parent,
Operand operand,
int  index 
)

Constructor.

Parameters
parentParent window.
operandOperand to be added or modified.
indexIndex of the operand.

Definition at line 66 of file OutputOperandDialog.cc.

69 :
70 wxDialog(parent, -1, _T(""),
72 operand_(operand), memData_(false), index_(index) {
73
75 createContents(this, true, true);
76
78 dynamic_cast<wxChoice*>(FindWindow(ID_OPERATION_OUTPUT_TYPES));
79
81 dynamic_cast<wxSpinCtrl*>(FindWindow(ID_ELEMENT_WIDTH));
82
84 dynamic_cast<wxChoice*>(FindWindow(ID_ELEMENT_COUNT));
85
86 FindWindow(ID_MEM_DATA)->SetValidator(wxGenericValidator(&memData_));
87
97
107
108 FindWindow(wxID_OK)->SetFocus();
109
110 type_ = operand_->type();
113 updateTypes();
116
117 setTexts();
118}
std::pair< int, Operand::OperandType > operandPair
static wxPoint getPosition(Dialogs dialog)
@ DIALOG_OUTPUT_OPERAND
Output operand dialog.
virtual bool isMemoryData() const
Definition Operand.cc:351
virtual int elementCount() const
Definition Operand.cc:298
static const std::string FLOAT_WORD_STRING
Definition Operand.hh:75
static const std::string SLONG_WORD_STRING
Definition Operand.hh:70
static const std::string HALF_FLOAT_WORD_STRING
Definition Operand.hh:74
static const std::string BOOL_STRING
Definition Operand.hh:77
virtual OperandType type() const
Definition Operand.cc:165
static const std::string DOUBLE_WORD_STRING
Definition Operand.hh:76
@ SLONG_WORD
Definition Operand.hh:66
@ FLOAT_WORD
Definition Operand.hh:61
@ ULONG_WORD
Definition Operand.hh:67
@ RAW_DATA
Definition Operand.hh:65
@ SINT_WORD
Definition Operand.hh:59
@ DOUBLE_WORD
Definition Operand.hh:62
@ UINT_WORD
Definition Operand.hh:60
@ HALF_FLOAT_WORD
Definition Operand.hh:63
static const std::string ULONG_WORD_STRING
Definition Operand.hh:71
static const std::string UINT_WORD_STRING
Definition Operand.hh:73
static const std::string RAW_DATA_STRING
Definition Operand.hh:78
static const std::string SINT_WORD_STRING
Definition Operand.hh:72
virtual int elementWidth() const
Definition Operand.cc:278
std::vector< std::string > outputTypes_
Output types.
int elemWidth_
Current element width in choice box.
int type_
Current operand type in choice box.
bool memData_
Flag indicating whether operand is memory data or not.
wxChoice * elementCountChoice_
Choice box for operand element count.
wxChoice * outputTypesComboBox_
Choice box for operation input types.
wxSpinCtrl * elementWidthSpinCtrl_
Spin ctrl for operand element width.
wxSizer * createContents(wxWindow *window, bool call_fit, bool set_sizer)
int index_
Index of the operand.
Operand * operand_
Operand to be modified.
int elemCount_
Current element count in choice box.

References Operand::BOOL, Operand::BOOL_STRING, Operand::DOUBLE_WORD, Operand::DOUBLE_WORD_STRING, Operand::FLOAT_WORD, Operand::FLOAT_WORD_STRING, Operand::HALF_FLOAT_WORD, Operand::HALF_FLOAT_WORD_STRING, Operand::RAW_DATA, Operand::RAW_DATA_STRING, Operand::SINT_WORD, Operand::SINT_WORD_STRING, Operand::SLONG_WORD, Operand::SLONG_WORD_STRING, Operand::UINT_WORD, Operand::UINT_WORD_STRING, Operand::ULONG_WORD, and Operand::ULONG_WORD_STRING.

◆ ~OutputOperandDialog()

OutputOperandDialog::~OutputOperandDialog ( )
virtual

Destructor.

Definition at line 123 of file OutputOperandDialog.cc.

123 {
124 int x, y;
125 GetPosition(&x, &y);
126 wxPoint point(x, y);
128}
static void setPosition(Dialogs dialog, wxPoint point)

References DialogPosition::DIALOG_OUTPUT_OPERAND, and DialogPosition::setPosition().

Here is the call graph for this function:

◆ OutputOperandDialog() [2/2]

OutputOperandDialog::OutputOperandDialog ( const OutputOperandDialog )
private

Copying not allowed.

Member Function Documentation

◆ createContents()

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

Creates the contents of the dialog.

NOTE! This function was generated by wxDesigner. This is why it may be ugly.

Parameters
parentParent window.
call_fitIf true fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.
Returns
The created sizer.

Definition at line 347 of file OutputOperandDialog.cc.

350 {
351
352 wxBoxSizer *item0 = new wxBoxSizer(wxVERTICAL);
353
354 wxBoxSizer *item1 = new wxBoxSizer(wxHORIZONTAL);
355
356 wxString strs9[] =
357 {
358 wxT("id: 1")
359 };
360
361 // Choice for input operand types
362 wxChoice *itemOutputTypes = new wxChoice(parent, ID_OPERATION_OUTPUT_TYPES, wxDefaultPosition, wxSize(100,-1), 1, strs9);
363 item1->Add(itemOutputTypes, 0, wxALIGN_CENTER|wxALL, 5);
364
365 wxStaticText *itemTextWidth = new wxStaticText(parent, ID_TEXT_WIDTH, wxT("Element width:"), wxDefaultPosition, wxDefaultSize, 0);
366 item1->Add(itemTextWidth, 0, wxALIGN_CENTER|wxALL, 5);
367 wxSpinCtrl *itemElemWidth = new wxSpinCtrl(parent, ID_ELEMENT_WIDTH, wxT(""), wxDefaultPosition, wxSize(-1,-1), 1);
368 item1->Add(itemElemWidth, 0, wxALIGN_CENTER|wxALL, 5);
369 wxStaticText *itemTextCount = new wxStaticText(parent, ID_TEXT_COUNT, wxT("Element count:"), wxDefaultPosition, wxDefaultSize, 0);
370 item1->Add(itemTextCount, 0, wxALIGN_CENTER|wxALL, 5);
371 wxChoice *itemElemCount = new wxChoice(parent, ID_ELEMENT_COUNT, wxDefaultPosition, wxSize(70,-1), 1, strs9);
372 item1->Add(itemElemCount, 0, wxALIGN_CENTER|wxALL, 5);
373
374 wxBoxSizer *item1b = new wxBoxSizer(wxHORIZONTAL);
375 wxCheckBox *item3 = new wxCheckBox(parent, ID_MEM_DATA, wxT("Memory data"), wxDefaultPosition, wxDefaultSize, 0);
376 item1b->Add(item3, 0, wxALIGN_CENTER|wxALL, 5);
377
378 item0->Add(item1, 0, wxALIGN_CENTER|wxALL, 5);
379 item0->Add(item1b, 0, wxALIGN_CENTER|wxALL, 5);
380
381 wxBoxSizer *item4 = new wxBoxSizer(wxHORIZONTAL);
382
383 wxButton *item5 = new wxButton(parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0);
384 item4->Add(item5, 0, wxALIGN_CENTER|wxALL, 5);
385
386 wxButton *item6 = new wxButton(parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
387 item4->Add(item6, 0, wxALIGN_CENTER|wxALL, 5);
388
389 item0->Add(item4, 0, wxALIGN_CENTER|wxALL, 5);
390
391 if (set_sizer)
392 {
393 parent->SetSizer(item0);
394 if (call_fit)
395 item0->SetSizeHints(parent);
396 }
397
398 return item0;
399}

References ID_ELEMENT_COUNT, ID_ELEMENT_WIDTH, ID_MEM_DATA, ID_OPERATION_OUTPUT_TYPES, ID_TEXT_COUNT, and ID_TEXT_WIDTH.

◆ onElementCount()

void OutputOperandDialog::onElementCount ( wxCommandEvent &  event)
private

Event handler for element count choice box.

Definition at line 159 of file OutputOperandDialog.cc.

159 {
160 // get the current choice box value and convert it to integer
161 int index = elementCountChoice_->GetSelection();
162 wxString number = elementCountChoice_->GetString(index);
163 long value;
164 if(!number.ToLong(&value)) {
165 elemCount_ = 1;
166 return;
167 }
168
169 // save current choice
170 elemCount_ = static_cast<int>(value);
171 // update spin ctrl range
173}

References elemCount_, elementCountChoice_, and updateElementWidths().

Here is the call graph for this function:

◆ onElementWidth()

void OutputOperandDialog::onElementWidth ( wxSpinEvent &  event)
private

Event handler for element width spin ctrl.

Definition at line 149 of file OutputOperandDialog.cc.

149 {
150 elemWidth_ = elementWidthSpinCtrl_->GetValue();
151 // update choice box list cells
153}

References elementWidthSpinCtrl_, elemWidth_, and updateElementCounts().

Here is the call graph for this function:

◆ onOk()

void OutputOperandDialog::onOk ( wxCommandEvent &  event)
private

Handles the event when OK button is pushed.

Definition at line 279 of file OutputOperandDialog.cc.

279 {
280 TransferDataFromWindow();
281 ObjectState* root = new ObjectState("");
283
284 int selected = outputTypesComboBox_->GetSelection();
285 Operand::OperandType type = operandTypes_[selected];
286
287 switch(type)
288 {
291 break;
294 break;
297 break;
300 break;
302 root->setAttribute(
304 break;
305 case Operand::BOOL:
307 break;
310 break;
312 root->setAttribute(
314 break;
316 root->setAttribute(
318 break;
319 default:
321 break;
322 }
323
326
329
330 operand_->loadState(root);
331 delete root;
332 EndModal(wxID_OK);
333}
void setAttribute(const std::string &name, const std::string &value)
static const std::string OPRND_ELEM_WIDTH
Object state name for element width.
Definition Operand.hh:98
virtual int index() const
Definition Operand.cc:135
static const std::string OPRND_TYPE
Object state name for operand type.
Definition Operand.hh:84
static const std::string OPRND_MEM_ADDRESS
Object state name for memory address.
Definition Operand.hh:86
static const std::string OPRND_ELEM_COUNT
Object state name for element count.
Definition Operand.hh:100
OperandType
Definition Operand.hh:58
static const std::string OPRND_MEM_DATA
Object state name for memory data.
Definition Operand.hh:90
static const std::string OPRND_ID
Object state name for operand id.
Definition Operand.hh:82
virtual void loadState(const ObjectState *state)
Definition Operand.cc:383

References Operand::BOOL, Operand::BOOL_STRING, Operand::DOUBLE_WORD, Operand::DOUBLE_WORD_STRING, elemCount_, elemWidth_, Operand::FLOAT_WORD, Operand::FLOAT_WORD_STRING, Operand::HALF_FLOAT_WORD, Operand::HALF_FLOAT_WORD_STRING, Operand::index(), Operand::loadState(), memData_, operand_, operandTypes_, Operand::OPRND_ELEM_COUNT, Operand::OPRND_ELEM_WIDTH, Operand::OPRND_ID, Operand::OPRND_MEM_ADDRESS, Operand::OPRND_MEM_DATA, Operand::OPRND_TYPE, outputTypesComboBox_, Operand::RAW_DATA, Operand::RAW_DATA_STRING, ObjectState::setAttribute(), Operand::SINT_WORD, Operand::SINT_WORD_STRING, Operand::SLONG_WORD, Operand::SLONG_WORD_STRING, Operand::UINT_WORD, Operand::UINT_WORD_STRING, Operand::ULONG_WORD, and Operand::ULONG_WORD_STRING.

Here is the call graph for this function:

◆ onType()

void OutputOperandDialog::onType ( wxCommandEvent &  event)
private

Event handler for operand type choice box.

Definition at line 134 of file OutputOperandDialog.cc.

134 {
135
136 type_ = outputTypesComboBox_->GetSelection();
137
138 Operand::OperandType operType = static_cast<Operand::OperandType>(type_);
140 elemCount_ = 1;
143}
static int defaultElementWidth(OperandType type)
Definition Operand.cc:557

References Operand::defaultElementWidth(), elemCount_, elemWidth_, outputTypesComboBox_, type_, updateElementCounts(), and updateElementWidths().

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ setTexts()

void OutputOperandDialog::setTexts ( )
private

Set texts to widgets.

Definition at line 252 of file OutputOperandDialog.cc.

252 {
253
256
257 // title
258 format fmt =
260 fmt % index_;
261 SetTitle(WxConversion::toWxString(fmt.str()));
262
263 // buttons
264 WidgetTools::setLabel(&guiText, FindWindow(wxID_OK),
266
267 WidgetTools::setLabel(&guiText, FindWindow(wxID_CANCEL),
269
270 // check boxes
273}
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
static OSEdTextGenerator & instance()
@ TXT_OUTPUT_OPERAND_DIALOG_TITLE
Output operand dialog title.
@ TXT_CHECKBOX_MEM_DATA
Memory data label.
virtual boost::format text(int textId)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
static wxString toWxString(const std::string &source)

References ID_MEM_DATA, index_, GUITextGenerator::instance(), OSEdTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_OK, OSEdTextGenerator::TXT_CHECKBOX_MEM_DATA, and OSEdTextGenerator::TXT_OUTPUT_OPERAND_DIALOG_TITLE.

Here is the call graph for this function:

◆ updateElementCounts()

void OutputOperandDialog::updateElementCounts ( )
private

Updates the element count choice box list.

Definition at line 230 of file OutputOperandDialog.cc.

230 {
231
232 elementCountChoice_->Clear();
233
234 // update the list so that only shorter or equal than SIMD_WORD_WIDTH
235 // width*count combinations are listed
236 int elemCount = 1;
237 int elemCountIndex = 0;
238 while (elemCount*elemWidth_ <= SIMD_WORD_WIDTH) {
239 if (elemCount < elemCount_) {
240 ++elemCountIndex;
241 }
243 elemCount *= 2;
244 }
245 elementCountChoice_->SetSelection(elemCountIndex);
246}
#define SIMD_WORD_WIDTH
Definition SimValue.hh:42

References elemCount_, elementCountChoice_, elemWidth_, SIMD_WORD_WIDTH, and WxConversion::toWxString().

Referenced by onElementWidth(), and onType().

Here is the call graph for this function:

◆ updateElementWidths()

void OutputOperandDialog::updateElementWidths ( )
private

Updates the element width choice box list.

Definition at line 196 of file OutputOperandDialog.cc.

196 {
197
198 Operand::OperandType operType = static_cast<Operand::OperandType>(type_);
199
200 if (operType == Operand::RAW_DATA) {
201 // element width for raw data can be arbitrary up to the max width
202 int elemWidth = 1;
203 int lastValidWidth = 1;
204 while (elemCount_*elemWidth <= SIMD_WORD_WIDTH) {
205 lastValidWidth = elemWidth;
206 elemWidth *= 2;
207 }
208
209 // degrade current element width if it is too big
210 if (elemWidth_ > lastValidWidth) {
211 elemWidth_ = lastValidWidth;
212 }
213 elementWidthSpinCtrl_->SetRange(1, lastValidWidth);
215 } else if (operType == Operand::SINT_WORD || operType == Operand::UINT_WORD) {
216 // element width for integers is 8 to 32
217 elementWidthSpinCtrl_->SetRange(8, 32);
219 } else {
220 // element width for other types is their default type width
223 }
224}

References elemCount_, elementWidthSpinCtrl_, elemWidth_, Operand::RAW_DATA, SIMD_WORD_WIDTH, Operand::SINT_WORD, type_, and Operand::UINT_WORD.

Referenced by onElementCount(), and onType().

◆ updateTypes()

void OutputOperandDialog::updateTypes ( )
private

Updates the type lists.

Definition at line 179 of file OutputOperandDialog.cc.

179 {
180
181 outputTypesComboBox_->Clear();
182
183 for (unsigned int i = 0; i < outputTypes_.size(); i++) {
184 wxString oper = WxConversion::toWxString(outputTypes_.at(i));
185 outputTypesComboBox_->Append(oper);
186 }
187
188 outputTypesComboBox_->SetSelection(type_);
189
190}

References outputTypes_, outputTypesComboBox_, WxConversion::toWxString(), and type_.

Here is the call graph for this function:

Member Data Documentation

◆ elemCount_

int OutputOperandDialog::elemCount_
private

Current element count in choice box.

Definition at line 100 of file OutputOperandDialog.hh.

Referenced by onElementCount(), onOk(), onType(), updateElementCounts(), and updateElementWidths().

◆ elementCountChoice_

wxChoice* OutputOperandDialog::elementCountChoice_
private

Choice box for operand element count.

Definition at line 94 of file OutputOperandDialog.hh.

Referenced by onElementCount(), and updateElementCounts().

◆ elementWidthSpinCtrl_

wxSpinCtrl* OutputOperandDialog::elementWidthSpinCtrl_
private

Spin ctrl for operand element width.

Definition at line 92 of file OutputOperandDialog.hh.

Referenced by onElementWidth(), and updateElementWidths().

◆ elemWidth_

int OutputOperandDialog::elemWidth_
private

Current element width in choice box.

Definition at line 98 of file OutputOperandDialog.hh.

Referenced by onElementWidth(), onOk(), onType(), updateElementCounts(), and updateElementWidths().

◆ index_

int OutputOperandDialog::index_
private

Index of the operand.

Definition at line 88 of file OutputOperandDialog.hh.

Referenced by setTexts().

◆ memData_

bool OutputOperandDialog::memData_
private

Flag indicating whether operand is memory data or not.

Definition at line 86 of file OutputOperandDialog.hh.

Referenced by onOk().

◆ operand_

Operand* OutputOperandDialog::operand_
private

Operand to be modified.

Definition at line 84 of file OutputOperandDialog.hh.

Referenced by onOk().

◆ operandTypes_

operandList OutputOperandDialog::operandTypes_
private

Definition at line 104 of file OutputOperandDialog.hh.

Referenced by onOk().

◆ outputTypes_

std::vector<std::string> OutputOperandDialog::outputTypes_
private

Output types.

Definition at line 103 of file OutputOperandDialog.hh.

Referenced by updateTypes().

◆ outputTypesComboBox_

wxChoice* OutputOperandDialog::outputTypesComboBox_
private

Choice box for operation input types.

Definition at line 90 of file OutputOperandDialog.hh.

Referenced by onOk(), onType(), and updateTypes().

◆ type_

int OutputOperandDialog::type_
private

Current operand type in choice box.

Definition at line 96 of file OutputOperandDialog.hh.

Referenced by onType(), updateElementWidths(), and updateTypes().


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