diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2017-01-28 14:50:12 -0200 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2017-01-28 14:50:12 -0200 |
commit | 5e7c19ae397164dd718b2593663cee5d1be687cd (patch) | |
tree | ea14141c3f4bb83ea8448cf017dfeb5b211611a0 | |
parent | 10bb7105946bc0a892a9daf42ec5181ad9994fcf (diff) | |
download | PSP.git-5e7c19ae397164dd718b2593663cee5d1be687cd.tar.gz PSP.git-5e7c19ae397164dd718b2593663cee5d1be687cd.tar.xz PSP.git-5e7c19ae397164dd718b2593663cee5d1be687cd.zip |
Node bug fixes, tf form implemented
-rw-r--r-- | Project/ControlEditor.cpp | 20 | ||||
-rw-r--r-- | Project/ControlElement.cpp | 20 | ||||
-rw-r--r-- | Project/ControlElement.h | 3 | ||||
-rw-r--r-- | Project/ElementForm.cpp | 101 | ||||
-rw-r--r-- | Project/ElementForm.h | 30 | ||||
-rw-r--r-- | Project/ElementForm.wxcp | 881 | ||||
-rw-r--r-- | Project/Project.mk | 12 | ||||
-rw-r--r-- | Project/Project.project | 6 | ||||
-rw-r--r-- | Project/Project.txt | 2 | ||||
-rw-r--r-- | Project/TransferFunction.cpp | 18 | ||||
-rw-r--r-- | Project/TransferFunction.h | 13 | ||||
-rw-r--r-- | Project/TransferFunctionForm.cpp | 78 | ||||
-rw-r--r-- | Project/TransferFunctionForm.h | 23 | ||||
-rw-r--r-- | Project/Transformer.h | 16 |
14 files changed, 1197 insertions, 26 deletions
diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp index 80c0813..cf79283 100644 --- a/Project/ControlEditor.cpp +++ b/Project/ControlEditor.cpp @@ -262,7 +262,23 @@ void ControlEditor::OnPaint(wxPaintEvent& event) event.Skip(); } -void ControlEditor::OnDoubleClick(wxMouseEvent& event) {} +void ControlEditor::OnDoubleClick(wxMouseEvent& event) +{ + wxPoint2DDouble clickPoint = event.GetPosition(); + bool redraw = false; + + if(m_mode == MODE_EDIT) { + for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) { + Element* element = *it; + if(element->Contains(m_camera->ScreenToWorld(clickPoint))) { + element->ShowForm(this, element); + redraw = true; + } + } + } + + if(redraw) Redraw(); +} void ControlEditor::OnLeftClickDown(wxMouseEvent& event) { @@ -284,7 +300,7 @@ void ControlEditor::OnLeftClickDown(wxMouseEvent& event) foundElement = true; } } - + if(!foundNode) { // Set movement initial position (not necessarily will be moved). element->StartMove(m_camera->ScreenToWorld(clickPoint)); diff --git a/Project/ControlElement.cpp b/Project/ControlElement.cpp index 09c7b79..c7ce3c2 100644 --- a/Project/ControlElement.cpp +++ b/Project/ControlElement.cpp @@ -2,7 +2,8 @@ Node::Node(wxPoint2DDouble position, NodeType nodeType, double borderSize) { - m_rect = wxRect2DDouble(position.m_x, position.m_y, 2 * m_radius + 2 * borderSize, 2 * m_radius + 2 * borderSize); + double totalRadius = m_radius + borderSize; + m_rect = wxRect2DDouble(position.m_x - totalRadius, position.m_y - totalRadius, totalRadius * 2, totalRadius * 2); m_nodeType = nodeType; m_triPts.push_back(GetPosition() + wxPoint2DDouble(-m_radius - m_rect.GetSize().GetWidth() / 2, m_radius)); @@ -14,22 +15,27 @@ Node::~Node() {} void Node::SetPosition(wxPoint2DDouble position) { - m_rect = wxRect2DDouble(position.m_x, position.m_y, m_rect.m_width, m_rect.m_height); + m_rect = wxRect2DDouble( + position.m_x - m_rect.m_width / 2, position.m_y - m_rect.m_height / 2, m_rect.m_width, m_rect.m_height); + m_triPts[0] = GetPosition() + wxPoint2DDouble(-m_radius - m_rect.GetSize().GetWidth() / 2, m_radius); + m_triPts[1] = GetPosition() + wxPoint2DDouble(-m_radius - m_rect.GetSize().GetWidth() / 2, -m_radius); + m_triPts[2] = GetPosition() + wxPoint2DDouble(-m_radius + 1, 0); } void Node::StartMove(wxPoint2DDouble position) { m_moveStartPt = position; - m_movePos = m_rect.GetPosition(); - m_triPtsMovePos = m_triPts; + m_movePos = m_rect.GetPosition() - wxPoint2DDouble(-m_rect.m_width / 2, -m_rect.m_height / 2); } void Node::Move(wxPoint2DDouble position) { SetPosition(m_movePos + position - m_moveStartPt); - m_triPts[0] = m_triPtsMovePos[0] + position - m_moveStartPt; - m_triPts[1] = m_triPtsMovePos[1] + position - m_moveStartPt; - m_triPts[2] = m_triPtsMovePos[2] + position - m_moveStartPt; +} + +wxPoint2DDouble Node::GetPosition() const +{ + return m_rect.GetPosition() + wxPoint2DDouble(m_rect.GetSize().GetWidth() / 2, m_rect.GetSize().GetHeight() / 2); } ControlElement::ControlElement() diff --git a/Project/ControlElement.h b/Project/ControlElement.h index 9414d38..063b2a5 100644 --- a/Project/ControlElement.h +++ b/Project/ControlElement.h @@ -14,7 +14,7 @@ public: wxRect2DDouble GetRect() const { return m_rect; } void SetRect(wxRect2DDouble rect) { m_rect = rect; } - wxPoint2DDouble GetPosition() const { return m_rect.GetPosition(); } + wxPoint2DDouble GetPosition() const; void SetPosition(wxPoint2DDouble position); NodeType GetNodeType() const { return m_nodeType; } @@ -36,7 +36,6 @@ protected: double m_radius = 3.0; std::vector<wxPoint2DDouble> m_triPts; - std::vector<wxPoint2DDouble> m_triPtsMovePos; }; class ControlElement : public Element diff --git a/Project/ElementForm.cpp b/Project/ElementForm.cpp index b77c191..27a120c 100644 --- a/Project/ElementForm.cpp +++ b/Project/ElementForm.cpp @@ -2785,3 +2785,104 @@ TextFormBase::~TextFormBase() m_ButtonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TextFormBase::OnCancelButtonClick), NULL, this); } + +TransferFunctionFormBase::TransferFunctionFormBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) + : wxDialog(parent, id, title, pos, size, style) +{ + if ( !bBitmapLoaded ) { + // We need to initialise the default bitmap handler + wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler); + wxC9EE9InitBitmapResources(); + bBitmapLoaded = true; + } + + wxBoxSizer* boxSizerLvl1_1 = new wxBoxSizer(wxVERTICAL); + this->SetSizer(boxSizerLvl1_1); + + m_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxBK_DEFAULT); + m_notebook->SetName(wxT("m_notebook")); + + boxSizerLvl1_1->Add(m_notebook, 1, wxEXPAND, WXC_FROM_DIP(5)); + + m_panelGeneral = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_notebook, wxSize(-1,-1)), wxTAB_TRAVERSAL); + m_notebook->AddPage(m_panelGeneral, _("General"), false); + + wxBoxSizer* boxSizerLvl2_1 = new wxBoxSizer(wxVERTICAL); + m_panelGeneral->SetSizer(boxSizerLvl2_1); + + m_staticTextNumerator = new wxStaticText(m_panelGeneral, wxID_ANY, _("Numerator parameters"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + + boxSizerLvl2_1->Add(m_staticTextNumerator, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); + + m_textCtrlNumerator = new wxTextCtrl(m_panelGeneral, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + #if wxVERSION_NUMBER >= 3000 + m_textCtrlNumerator->SetHint(wxT("")); + #endif + + boxSizerLvl2_1->Add(m_textCtrlNumerator, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); + m_textCtrlNumerator->SetMinSize(wxSize(300,-1)); + + m_staticTextDenominator = new wxStaticText(m_panelGeneral, wxID_ANY, _("Denominator parameters"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + + boxSizerLvl2_1->Add(m_staticTextDenominator, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); + + m_textCtrlDenominator = new wxTextCtrl(m_panelGeneral, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + #if wxVERSION_NUMBER >= 3000 + m_textCtrlDenominator->SetHint(wxT("")); + #endif + + boxSizerLvl2_1->Add(m_textCtrlDenominator, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5)); + m_textCtrlDenominator->SetMinSize(wxSize(300,-1)); + + wxBoxSizer* boxSizerBottomButtons = new wxBoxSizer(wxHORIZONTAL); + + boxSizerLvl1_1->Add(boxSizerBottomButtons, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5)); + + boxSizerBottomButtons->Add(0, 0, 1, wxALL, WXC_FROM_DIP(5)); + + m_buttonOK = new wxButton(this, wxID_ANY, _("OK"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0); + + boxSizerBottomButtons->Add(m_buttonOK, 0, wxALL|wxALIGN_RIGHT, WXC_FROM_DIP(5)); + + m_ButtonCancel = new wxButton(this, wxID_ANY, _("Cancel"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0); + + boxSizerBottomButtons->Add(m_ButtonCancel, 0, wxALL|wxALIGN_RIGHT, WXC_FROM_DIP(5)); + + + #if wxVERSION_NUMBER >= 2900 + if(!wxPersistenceManager::Get().Find(m_notebook)){ + wxPersistenceManager::Get().RegisterAndRestore(m_notebook); + } else { + wxPersistenceManager::Get().Restore(m_notebook); + } + #endif + + SetName(wxT("TransferFunctionFormBase")); + SetSize(-1,-1); + if (GetSizer()) { + GetSizer()->Fit(this); + } + if(GetParent()) { + CentreOnParent(wxBOTH); + } else { + CentreOnScreen(wxBOTH); + } +#if wxVERSION_NUMBER >= 2900 + if(!wxPersistenceManager::Get().Find(this)) { + wxPersistenceManager::Get().RegisterAndRestore(this); + } else { + wxPersistenceManager::Get().Restore(this); + } +#endif + // Connect events + m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TransferFunctionFormBase::OnOKClick), NULL, this); + m_ButtonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TransferFunctionFormBase::OnCancelClick), NULL, this); + +} + +TransferFunctionFormBase::~TransferFunctionFormBase() +{ + m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TransferFunctionFormBase::OnOKClick), NULL, this); + m_ButtonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(TransferFunctionFormBase::OnCancelClick), NULL, this); + +} diff --git a/Project/ElementForm.h b/Project/ElementForm.h index 9756bc8..f7c9ebb 100644 --- a/Project/ElementForm.h +++ b/Project/ElementForm.h @@ -771,4 +771,34 @@ public: virtual ~TextFormBase(); }; + +class TransferFunctionFormBase : public wxDialog +{ +protected: + wxNotebook* m_notebook; + wxPanel* m_panelGeneral; + wxStaticText* m_staticTextNumerator; + wxTextCtrl* m_textCtrlNumerator; + wxStaticText* m_staticTextDenominator; + wxTextCtrl* m_textCtrlDenominator; + wxButton* m_buttonOK; + wxButton* m_ButtonCancel; + +protected: + virtual void OnOKClick(wxCommandEvent& event) { event.Skip(); } + virtual void OnCancelClick(wxCommandEvent& event) { event.Skip(); } + +public: + wxStaticText* GetStaticTextNumerator() { return m_staticTextNumerator; } + wxTextCtrl* GetTextCtrlNumerator() { return m_textCtrlNumerator; } + wxStaticText* GetStaticTextDenominator() { return m_staticTextDenominator; } + wxTextCtrl* GetTextCtrlDenominator() { return m_textCtrlDenominator; } + wxPanel* GetPanelGeneral() { return m_panelGeneral; } + wxNotebook* GetNotebook() { return m_notebook; } + wxButton* GetButtonOK() { return m_buttonOK; } + wxButton* GetButtonCancel() { return m_ButtonCancel; } + TransferFunctionFormBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Transfer function"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxDEFAULT_DIALOG_STYLE); + virtual ~TransferFunctionFormBase(); +}; + #endif diff --git a/Project/ElementForm.wxcp b/Project/ElementForm.wxcp index 877a38d..8a4f50d 100644 --- a/Project/ElementForm.wxcp +++ b/Project/ElementForm.wxcp @@ -1,7 +1,7 @@ { "metadata": { "m_generatedFilesDir": ".", - "m_objCounter": 1580, + "m_objCounter": 1628, "m_includeFiles": [], "m_bitmapFunction": "wxC9EE9InitBitmapResources", "m_bitmapsFile": "ElementFormBitmaps.cpp", @@ -29334,5 +29334,884 @@ }] }] }] + }, { + "m_type": 4421, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxDEFAULT_DIALOG_STYLE"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "TransferFunctionFormBase" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Enable Window Persistency:", + "m_value": true + }, { + "type": "string", + "m_label": "Title:", + "m_value": "Transfer function" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "Project:wxcrafter" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }, { + "type": "string", + "m_label": "Inherited Class", + "m_value": "TransferFunctionForm" + }, { + "type": "string", + "m_label": "File:", + "m_value": "TransferFunctionForm" + }, { + "type": "string", + "m_label": "Class Decorator", + "m_value": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (16x16) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (32x32) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (64x64) :", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (128x128):", + "m_path": "" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File (256x256):", + "m_path": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "boxSizerLvl1_1" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4442, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxBK_DEFAULT"], + "m_sizerFlags": ["wxEXPAND"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_notebook" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }], + "m_events": [], + "m_children": [{ + "m_type": 4441, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": ["wxTAB_TRAVERSAL"], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_panelGeneral" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "General" + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "bool", + "m_label": "Selected", + "m_value": false + }, { + "type": "bool", + "m_label": "Null Page", + "m_value": false + }], + "m_events": [], + "m_children": [{ + "m_type": 4401, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "boxSizerLvl2_1" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 0, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4405, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticTextNumerator" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Numerator parameters" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "300,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrlNumerator" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Text Hint", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }, { + "type": "bool", + "m_label": "Auto Complete Directories:", + "m_value": false + }, { + "type": "bool", + "m_label": "Auto Complete Files:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4405, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_staticTextDenominator" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "multi-string", + "m_label": "Label:", + "m_value": "Denominator parameters" + }, { + "type": "string", + "m_label": "Wrap:", + "m_value": "-1" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4406, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "wxEXPAND", "wxALIGN_CENTER_VERTICAL"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "300,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_textCtrlDenominator" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Value:", + "m_value": "" + }, { + "type": "string", + "m_label": "Text Hint", + "m_value": "" + }, { + "type": "string", + "m_label": "Max Length:", + "m_value": "0" + }, { + "type": "bool", + "m_label": "Auto Complete Directories:", + "m_value": false + }, { + "type": "bool", + "m_label": "Auto Complete Files:", + "m_value": false + }], + "m_events": [], + "m_children": [] + }] + }] + }] + }, { + "m_type": 4401, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"], + "m_properties": [{ + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "boxSizerBottomButtons" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "choice", + "m_label": "Orientation:", + "m_selection": 1, + "m_options": ["wxVERTICAL", "wxHORIZONTAL"] + }], + "m_events": [], + "m_children": [{ + "m_type": 4454, + "proportion": 1, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"], + "m_properties": [{ + "type": "string", + "m_label": "Name:", + "m_value": "Spacer_1" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "0,0" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_buttonOK" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "OK" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Direction", + "m_selection": 0, + "m_options": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"] + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_BUTTON_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnOKClick(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.", + "m_noBody": false + }], + "m_children": [] + }, { + "m_type": 4400, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxALIGN_RIGHT"], + "m_properties": [{ + "type": "winid", + "m_label": "ID:", + "m_winid": "wxID_ANY" + }, { + "type": "string", + "m_label": "Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Minimum Size:", + "m_value": "-1,-1" + }, { + "type": "string", + "m_label": "Name:", + "m_value": "m_ButtonCancel" + }, { + "type": "multi-string", + "m_label": "Tooltip:", + "m_value": "" + }, { + "type": "colour", + "m_label": "Bg Colour:", + "colour": "<Default>" + }, { + "type": "colour", + "m_label": "Fg Colour:", + "colour": "<Default>" + }, { + "type": "font", + "m_label": "Font:", + "m_value": "" + }, { + "type": "bool", + "m_label": "Hidden", + "m_value": false + }, { + "type": "bool", + "m_label": "Disabled", + "m_value": false + }, { + "type": "bool", + "m_label": "Focused", + "m_value": false + }, { + "type": "string", + "m_label": "Class Name:", + "m_value": "" + }, { + "type": "string", + "m_label": "Include File:", + "m_value": "" + }, { + "type": "string", + "m_label": "Style:", + "m_value": "" + }, { + "type": "string", + "m_label": "Label:", + "m_value": "Cancel" + }, { + "type": "bool", + "m_label": "Default Button", + "m_value": false + }, { + "type": "bitmapPicker", + "m_label": "Bitmap File:", + "m_path": "" + }, { + "type": "choice", + "m_label": "Direction", + "m_selection": 0, + "m_options": ["wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"] + }, { + "type": "string", + "m_label": "Margins:", + "m_value": "2,2" + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_BUTTON_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnCancelClick(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.", + "m_noBody": false + }], + "m_children": [] + }] + }] + }] }] }
\ No newline at end of file diff --git a/Project/Project.mk b/Project/Project.mk index ecdac4b..0b7e705 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=27/01/2017 +Date :=28/01/2017 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC @@ -69,7 +69,7 @@ Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirector $(IntermediateDirectory)/Bus.cpp$(ObjectSuffix) $(IntermediateDirectory)/Line.cpp$(ObjectSuffix) $(IntermediateDirectory)/Transformer.cpp$(ObjectSuffix) $(IntermediateDirectory)/Machines.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncGenerator.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Branch.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMotor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Shunt.cpp$(ObjectSuffix) $(IntermediateDirectory)/Load.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/Inductor.cpp$(ObjectSuffix) $(IntermediateDirectory)/Capacitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElectricCalculation.cpp$(ObjectSuffix) $(IntermediateDirectory)/PowerFlow.cpp$(ObjectSuffix) $(IntermediateDirectory)/Fault.cpp$(ObjectSuffix) $(IntermediateDirectory)/Text.cpp$(ObjectSuffix) $(IntermediateDirectory)/GraphicalElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlElement.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransferFunction.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GeneratorStabForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SwitchingForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TransformerForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LoadForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ReactiveShuntElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IndMotorForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/SyncMachineForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/TextForm.cpp$(ObjectSuffix) \ - + $(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix) @@ -494,6 +494,14 @@ $(IntermediateDirectory)/TextForm.cpp$(DependSuffix): TextForm.cpp $(IntermediateDirectory)/TextForm.cpp$(PreprocessSuffix): TextForm.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/TextForm.cpp$(PreprocessSuffix) TextForm.cpp +$(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix): TransferFunctionForm.cpp $(IntermediateDirectory)/TransferFunctionForm.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/Thales/Documents/GitHub/PSP/Project/TransferFunctionForm.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/TransferFunctionForm.cpp$(DependSuffix): TransferFunctionForm.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/TransferFunctionForm.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/TransferFunctionForm.cpp$(DependSuffix) -MM TransferFunctionForm.cpp + +$(IntermediateDirectory)/TransferFunctionForm.cpp$(PreprocessSuffix): TransferFunctionForm.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/TransferFunctionForm.cpp$(PreprocessSuffix) TransferFunctionForm.cpp + -include $(IntermediateDirectory)/*$(DependSuffix) ## diff --git a/Project/Project.project b/Project/Project.project index b6d6ae0..46d70e1 100644 --- a/Project/Project.project +++ b/Project/Project.project @@ -65,6 +65,9 @@ </VirtualDirectory> <File Name="ControlEditor.cpp"/> <File Name="Camera.cpp"/> + <VirtualDirectory Name="control element form"> + <File Name="TransferFunctionForm.cpp"/> + </VirtualDirectory> </VirtualDirectory> <File Name="main.cpp"/> </VirtualDirectory> @@ -131,6 +134,9 @@ </VirtualDirectory> <File Name="ControlEditor.h"/> <File Name="Camera.h"/> + <VirtualDirectory Name="control element form"> + <File Name="TransferFunctionForm.h"/> + </VirtualDirectory> </VirtualDirectory> </VirtualDirectory> <VirtualDirectory Name="resources"> diff --git a/Project/Project.txt b/Project/Project.txt index 5cc3566..67cb7a2 100644 --- a/Project/Project.txt +++ b/Project/Project.txt @@ -1 +1 @@ -./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/TransferFunction.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o +./Release/main.cpp.o ./Release/win_resources.rc.o ./Release/ElementDataObject.cpp.o ./Release/Element.cpp.o ./Release/ArtMetro.cpp.o ./Release/wxGLString.cpp.o ./Release/MainFrame.cpp.o ./Release/Workspace.cpp.o ./Release/FileHanding.cpp.o ./Release/ControlEditor.cpp.o ./Release/Camera.cpp.o ./Release/MainFrameBitmaps.cpp.o ./Release/WorkspaceBitmaps.cpp.o ./Release/BusFormBitmaps.cpp.o ./Release/ElementFormBitmaps.cpp.o ./Release/ControlEditorBitmaps.cpp.o ./Release/MainFrameBase.cpp.o ./Release/WorkspaceBase.cpp.o ./Release/ElementForm.cpp.o ./Release/ControlEditorBase.cpp.o ./Release/Bus.cpp.o ./Release/Line.cpp.o ./Release/Transformer.cpp.o ./Release/Machines.cpp.o ./Release/SyncGenerator.cpp.o ./Release/IndMotor.cpp.o ./Release/Branch.cpp.o ./Release/SyncMotor.cpp.o ./Release/Shunt.cpp.o ./Release/Load.cpp.o ./Release/Inductor.cpp.o ./Release/Capacitor.cpp.o ./Release/PowerElement.cpp.o ./Release/ElectricCalculation.cpp.o ./Release/PowerFlow.cpp.o ./Release/Fault.cpp.o ./Release/Text.cpp.o ./Release/GraphicalElement.cpp.o ./Release/ControlElement.cpp.o ./Release/TransferFunction.cpp.o ./Release/BusForm.cpp.o ./Release/GeneratorStabForm.cpp.o ./Release/LineForm.cpp.o ./Release/SwitchingForm.cpp.o ./Release/TransformerForm.cpp.o ./Release/LoadForm.cpp.o ./Release/ReactiveShuntElementForm.cpp.o ./Release/IndMotorForm.cpp.o ./Release/SyncMachineForm.cpp.o ./Release/TextForm.cpp.o ./Release/TransferFunctionForm.cpp.o diff --git a/Project/TransferFunction.cpp b/Project/TransferFunction.cpp index b295864..74314a2 100644 --- a/Project/TransferFunction.cpp +++ b/Project/TransferFunction.cpp @@ -1,4 +1,5 @@ #include "TransferFunction.h" +#include "TransferFunctionForm.h" TransferFunction::TransferFunction() { @@ -48,7 +49,7 @@ void TransferFunction::Draw(wxPoint2DDouble translation, double scale) const linePts.push_back(wxPoint2DDouble(m_position.m_x - m_width / 2 + 5 + m_borderSize, m_position.m_y)); linePts.push_back(wxPoint2DDouble(m_position.m_x + m_width / 2 - 5 - m_borderSize, m_position.m_y)); DrawLine(linePts); - + DrawNodes(); glEnable(GL_TEXTURE_2D); @@ -188,4 +189,19 @@ void TransferFunction::UpdateTFText() wxString num, den; GetTFString(num, den); SetText(num, den); + if(m_nodeList.size() == 2) { + m_nodeList[0].SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 0)); + m_nodeList[1].SetPosition(m_position + wxPoint2DDouble(m_width / 2, 0)); + } +} + +bool TransferFunction::ShowForm(wxWindow* parent, Element* element) +{ + TransferFunctionForm* tfForm = new TransferFunctionForm(parent, this); + if(tfForm->ShowModal() == wxID_OK) { + tfForm->Destroy(); + return true; + } + tfForm->Destroy(); + return false; } diff --git a/Project/TransferFunction.h b/Project/TransferFunction.h index 282ccb0..c8ca59f 100644 --- a/Project/TransferFunction.h +++ b/Project/TransferFunction.h @@ -6,6 +6,8 @@ #include <wx/dcscreen.h> #include "wxGLString.h" +class TransferFunctionForm; + class TransferFunction : public ControlElement { public: @@ -16,12 +18,19 @@ public: virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); } virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); } virtual bool AddParent(Element* parent, wxPoint2DDouble position) { return false; } + virtual bool ShowForm(wxWindow* parent, Element* element); + + virtual std::vector<double> GetNumerator() const { return m_numerator; } + virtual std::vector<double> GetDenominator() const { return m_denominator; } + virtual void SetNumerator(std::vector<double> numerator) { m_numerator = numerator; } + virtual void SetDenominator(std::vector<double> denominator) { m_denominator = denominator; } + virtual void UpdateTFText(); + +protected: virtual void SetText(wxString numerator, wxString denominator); virtual wxString GetSuperscriptNumber(int number); virtual void GetTFString(wxString& numerator, wxString& denominator); - virtual void UpdateTFText(); -protected: wchar_t m_supNumber[10]; wxGLString* m_glStringNum = NULL; diff --git a/Project/TransferFunctionForm.cpp b/Project/TransferFunctionForm.cpp new file mode 100644 index 0000000..5814339 --- /dev/null +++ b/Project/TransferFunctionForm.cpp @@ -0,0 +1,78 @@ +#include "TransferFunctionForm.h" +#include "TransferFunction.h" + +TransferFunctionForm::TransferFunctionForm(wxWindow* parent, TransferFunction* transferFunction) + : TransferFunctionFormBase(parent) +{ + m_parent = parent; + m_tf = transferFunction; + LoadTFData(); +} + +TransferFunctionForm::~TransferFunctionForm() {} + +void TransferFunctionForm::OnCancelClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); } + +void TransferFunctionForm::OnOKClick(wxCommandEvent& event) +{ + if(ValidateData()) EndModal(wxID_OK); +} + +void TransferFunctionForm::LoadTFData() +{ + auto num = m_tf->GetNumerator(); + auto den = m_tf->GetDenominator(); + + wxString numStr = ""; + for(auto it = num.begin(), itEnd = num.end(); it != itEnd; ++it) { + double value = *it; + if(it == num.begin()) + numStr = m_tf->StringFromDouble(value, 0); + else + numStr += " " + m_tf->StringFromDouble(value, 0); + } + m_textCtrlNumerator->SetValue(numStr); + + wxString denStr = ""; + for(auto it = den.begin(), itEnd = den.end(); it != itEnd; ++it) { + double value = *it; + if(it == den.begin()) + denStr = m_tf->StringFromDouble(value, 0); + else + denStr += " " + m_tf->StringFromDouble(value, 0); + } + m_textCtrlDenominator->SetValue(denStr); +} + +bool TransferFunctionForm::ValidateData() +{ + wxString num = m_textCtrlNumerator->GetValue(); + std::vector<double> numerator; + while(num != "") { + wxString rest; + wxString strValue = num.BeforeFirst(' ', &rest); + num = rest; + double value = 0; + if(!m_tf->DoubleFromString( + this, strValue, value, _("Value entered incorrectly in the field \"Numerator parameters\"."))) + return false; + numerator.push_back(value); + } + + wxString den = m_textCtrlDenominator->GetValue(); + std::vector<double> denominator; + while(den != "") { + wxString rest; + wxString strValue = den.BeforeFirst(' ', &rest); + den = rest; + double value = 0; + if(!m_tf->DoubleFromString( + this, strValue, value, _("Value entered incorrectly in the field \"Denominator parameters\"."))) + return false; + denominator.push_back(value); + } + m_tf->SetNumerator(numerator); + m_tf->SetDenominator(denominator); + m_tf->UpdateTFText(); + return true; +} diff --git a/Project/TransferFunctionForm.h b/Project/TransferFunctionForm.h new file mode 100644 index 0000000..269eda6 --- /dev/null +++ b/Project/TransferFunctionForm.h @@ -0,0 +1,23 @@ +#ifndef TRANSFERFUNCTIONFORM_H +#define TRANSFERFUNCTIONFORM_H + +#include "ElementForm.h" + +class TransferFunction; + +class TransferFunctionForm : public TransferFunctionFormBase +{ +public: + TransferFunctionForm(wxWindow* parent, TransferFunction* transferFunction); + virtual ~TransferFunctionForm(); + bool ValidateData(); + +protected: + virtual void OnCancelClick(wxCommandEvent& event); + virtual void OnOKClick(wxCommandEvent& event); + void LoadTFData(); + + wxWindow* m_parent = NULL; + TransferFunction* m_tf = NULL; +}; +#endif // TRANSFERFUNCTIONFORM_H diff --git a/Project/Transformer.h b/Project/Transformer.h index d557cda..723a5df 100644 --- a/Project/Transformer.h +++ b/Project/Transformer.h @@ -35,10 +35,10 @@ struct TransformerElectricalData { double turnsRatio = 1.0; double phaseShift = 0.0; bool useTransformerPower = false; - + // Power flow (p.u.) - std::complex<double> current[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)}; - std::complex<double> powerFlow[2] = {std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0)}; + std::complex<double> current[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) }; + std::complex<double> powerFlow[2] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0) }; // Fault double zeroResistance = 0.0; @@ -53,12 +53,12 @@ struct TransformerElectricalData { class Transformer : public Branch { - public: +public: Transformer(); Transformer(wxString name); virtual ~Transformer(); - - virtual Element* GetCopy(); + + virtual Element* GetCopy(); virtual bool AddParent(Element* parent, wxPoint2DDouble position); virtual bool Contains(wxPoint2DDouble position) const; virtual void Draw(wxPoint2DDouble translation, double scale) const; @@ -77,9 +77,9 @@ class Transformer : public Branch virtual void SetElectricaData(TransformerElectricalData electricalData) { m_electricalData = electricalData; } virtual void SetNominalVoltage(std::vector<double> nominalVoltage, std::vector<ElectricalUnit> nominalVoltageUnit); - protected: +protected: void UpdatePowerFlowArrowsPosition(); TransformerElectricalData m_electricalData; }; -#endif // TRANSFORMER_H +#endif // TRANSFORMER_H |