diff options
Diffstat (limited to 'Project')
-rw-r--r-- | Project/ControlEditor.cpp | 8 | ||||
-rw-r--r-- | Project/ControlEditor.h | 18 | ||||
-rw-r--r-- | Project/Element.h | 2 | ||||
-rw-r--r-- | Project/ElementForm.cpp | 101 | ||||
-rw-r--r-- | Project/ElementForm.h | 32 | ||||
-rw-r--r-- | Project/ElementForm.wxcp | 871 | ||||
-rw-r--r-- | Project/IOControl.cpp | 224 | ||||
-rw-r--r-- | Project/IOControl.h | 49 | ||||
-rw-r--r-- | Project/IOControlForm.cpp | 89 | ||||
-rw-r--r-- | Project/IOControlForm.h | 27 | ||||
-rw-r--r-- | Project/Project.mk | 24 | ||||
-rw-r--r-- | Project/Project.project | 4 | ||||
-rw-r--r-- | Project/Project.txt | 2 |
13 files changed, 1436 insertions, 15 deletions
diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp index 36edb52..6dbf650 100644 --- a/Project/ControlEditor.cpp +++ b/Project/ControlEditor.cpp @@ -102,13 +102,15 @@ void ControlElementButton::OnLeftClickUp(wxMouseEvent& event) event.Skip(); } -ControlEditor::ControlEditor(wxWindow* parent) : ControlEditorBase(parent) +ControlEditor::ControlEditor(wxWindow* parent, int ioflags) : ControlEditorBase(parent) { BuildControlElementPanel(); m_glContext = new wxGLContext(m_glCanvas); m_camera = new Camera(); m_selectionRect = wxRect2DDouble(0, 0, 0, 0); //m_camera->SetScale(1.2); + m_ioFlags = ioflags; + } ControlEditor::~ControlEditor() { @@ -202,7 +204,9 @@ void ControlEditor::AddElement(ControlElementButtonID id) { switch(id) { case ID_IO: { - wxLogMessage("io"); + m_mode = MODE_INSERT; + IOControl* io = new IOControl(m_ioFlags); + m_elementList.push_back(io); } break; case ID_TF: { m_mode = MODE_INSERT; diff --git a/Project/ControlEditor.h b/Project/ControlEditor.h index 998fb2d..982aeca 100644 --- a/Project/ControlEditor.h +++ b/Project/ControlEditor.h @@ -9,6 +9,8 @@ #include <GL/gl.h> #include <GL/glu.h> +#include "IOControl.h" + class Camera; class Element; class ControlElement; @@ -26,11 +28,11 @@ enum ControlElementButtonID { ID_IO = 0, ID_TF, ID_SUM, ID_CONST, ID_LIMITER, ID class ControlElementButton : public wxWindow { -public: + public: ControlElementButton(wxWindow* parent, wxString label, wxImage image, wxWindowID id = wxID_ANY); ~ControlElementButton(); -protected: + protected: virtual void OnPaint(wxPaintEvent& event); virtual void OnMouseEnter(wxMouseEvent& event); virtual void OnMouseLeave(wxMouseEvent& event); @@ -54,7 +56,7 @@ protected: class ControlEditor : public ControlEditorBase { -public: + public: enum ControlEditorMode { MODE_EDIT = 0, MODE_MOVE_ELEMENT, @@ -67,7 +69,10 @@ public: MODE_PASTE, MODE_DRAG_PASTE }; - ControlEditor(wxWindow* parent); + + ControlEditor(wxWindow* parent, + int ioflags = IOControl::IN_TERMINAL_VOLTAGE | IOControl::IN_VELOCITY | IOControl::OUT_FIELD_VOLTAGE | + IOControl::OUT_MEC_POWER); virtual ~ControlEditor(); virtual void AddElement(ControlElementButtonID id); @@ -76,7 +81,7 @@ public: virtual void DeleteSelectedElements(); virtual void CheckConnections(); -protected: + protected: virtual void OnKeyDown(wxKeyEvent& event); virtual void OnIdle(wxIdleEvent& event); virtual void OnScroll(wxMouseEvent& event); @@ -106,5 +111,6 @@ protected: std::vector<ConnectionLine*> m_connectionList; bool m_firstDraw = true; + int m_ioFlags; }; -#endif // CONTROLEDITOR_H +#endif // CONTROLEDITOR_H diff --git a/Project/Element.h b/Project/Element.h index bd34f5c..4935f11 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -9,7 +9,7 @@ #include <complex> -#include <wx/log.h> +//#include <wx/log.h> /** * @enum PickboxID diff --git a/Project/ElementForm.cpp b/Project/ElementForm.cpp index cbdfbb5..986b28d 100644 --- a/Project/ElementForm.cpp +++ b/Project/ElementForm.cpp @@ -3460,3 +3460,104 @@ GainFormBase::~GainFormBase() m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GainFormBase::OnCancelButtonClick), NULL, this); } + +IOControlFormBase::IOControlFormBase(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_checkBoxInput = new wxCheckBox(m_panelGeneral, wxID_ANY, _("Input"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + m_checkBoxInput->SetValue(false); + + boxSizerLvl2_1->Add(m_checkBoxInput, 0, wxLEFT|wxRIGHT|wxTOP, WXC_FROM_DIP(5)); + + wxArrayString m_choiceInputArr; + m_choiceInput = new wxChoice(m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), m_choiceInputArr, 0); + + boxSizerLvl2_1->Add(m_choiceInput, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, WXC_FROM_DIP(5)); + + m_checkBoxOutput = new wxCheckBox(m_panelGeneral, wxID_ANY, _("Output"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0); + m_checkBoxOutput->SetValue(false); + + boxSizerLvl2_1->Add(m_checkBoxOutput, 0, wxLEFT|wxRIGHT|wxTOP, WXC_FROM_DIP(5)); + + wxArrayString m_choiceOutputArr; + m_choiceOutput = new wxChoice(m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), m_choiceOutputArr, 0); + + boxSizerLvl2_1->Add(m_choiceOutput, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, WXC_FROM_DIP(5)); + + 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("IOControlFormBase")); + 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_checkBoxInput->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(IOControlFormBase::OnInputChecked), NULL, this); + m_checkBoxOutput->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(IOControlFormBase::OnOutputChecked), NULL, this); + m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IOControlFormBase::OnOKButtonClick), NULL, this); + m_ButtonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IOControlFormBase::OnCancelButtonClick), NULL, this); + +} + +IOControlFormBase::~IOControlFormBase() +{ + m_checkBoxInput->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(IOControlFormBase::OnInputChecked), NULL, this); + m_checkBoxOutput->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(IOControlFormBase::OnOutputChecked), NULL, this); + m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IOControlFormBase::OnOKButtonClick), NULL, this); + m_ButtonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(IOControlFormBase::OnCancelButtonClick), NULL, this); + +} diff --git a/Project/ElementForm.h b/Project/ElementForm.h index a47dfb7..2d07908 100644 --- a/Project/ElementForm.h +++ b/Project/ElementForm.h @@ -971,4 +971,36 @@ public: virtual ~GainFormBase(); }; + +class IOControlFormBase : public wxDialog +{ +protected: + wxNotebook* m_notebook; + wxPanel* m_panelGeneral; + wxCheckBox* m_checkBoxInput; + wxChoice* m_choiceInput; + wxCheckBox* m_checkBoxOutput; + wxChoice* m_choiceOutput; + wxButton* m_buttonOK; + wxButton* m_ButtonCancel; + +protected: + virtual void OnInputChecked(wxCommandEvent& event) { event.Skip(); } + virtual void OnOutputChecked(wxCommandEvent& event) { event.Skip(); } + virtual void OnOKButtonClick(wxCommandEvent& event) { event.Skip(); } + virtual void OnCancelButtonClick(wxCommandEvent& event) { event.Skip(); } + +public: + wxCheckBox* GetCheckBoxInput() { return m_checkBoxInput; } + wxChoice* GetChoiceInput() { return m_choiceInput; } + wxCheckBox* GetCheckBoxOutput() { return m_checkBoxOutput; } + wxChoice* GetChoiceOutput() { return m_choiceOutput; } + wxPanel* GetPanelGeneral() { return m_panelGeneral; } + wxNotebook* GetNotebook() { return m_notebook; } + wxButton* GetButtonOK() { return m_buttonOK; } + wxButton* GetButtonCancel() { return m_ButtonCancel; } + IOControlFormBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Input / Output"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxDEFAULT_DIALOG_STYLE); + virtual ~IOControlFormBase(); +}; + #endif diff --git a/Project/ElementForm.wxcp b/Project/ElementForm.wxcp index 9ee35ab..1b02c55 100644 --- a/Project/ElementForm.wxcp +++ b/Project/ElementForm.wxcp @@ -1,7 +1,7 @@ { "metadata": { "m_generatedFilesDir": ".", - "m_objCounter": 1797, + "m_objCounter": 1833, "m_includeFiles": [], "m_bitmapFunction": "wxC9EE9InitBitmapResources", "m_bitmapsFile": "ElementFormBitmaps.cpp", @@ -35076,5 +35076,874 @@ }] }] }] + }, { + "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": "IOControlFormBase" + }, { + "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": "Input / Output" + }, { + "type": "virtualFolderPicker", + "m_label": "Virtual Folder:", + "m_path": "Project:wxcrafter:base" + }, { + "type": "choice", + "m_label": "Centre:", + "m_selection": 1, + "m_options": ["", "wxBOTH", "wxVERTICAL", "wxHORIZONTAL"] + }, { + "type": "string", + "m_label": "Inherited Class", + "m_value": "IOControlForm" + }, { + "type": "string", + "m_label": "File:", + "m_value": "IOControlForm" + }, { + "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": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP"], + "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_checkBoxInput" + }, { + "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": "Input" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnInputChecked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.", + "m_noBody": false + }], + "m_children": [] + }, { + "m_type": 4411, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "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_choiceInput" + }, { + "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": "Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "" + }], + "m_events": [], + "m_children": [] + }, { + "m_type": 4415, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP"], + "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_checkBoxOutput" + }, { + "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": "Output" + }, { + "type": "bool", + "m_label": "Value:", + "m_value": false + }], + "m_events": [{ + "m_eventName": "wxEVT_COMMAND_CHECKBOX_CLICKED", + "m_eventClass": "wxCommandEvent", + "m_eventHandler": "wxCommandEventHandler", + "m_functionNameAndSignature": "OnOutputChecked(wxCommandEvent& event)", + "m_description": "Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.", + "m_noBody": false + }], + "m_children": [] + }, { + "m_type": 4411, + "proportion": 0, + "border": 5, + "gbSpan": "1,1", + "gbPosition": "0,0", + "m_styles": [], + "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "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_choiceOutput" + }, { + "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": "Choices:", + "m_value": "" + }, { + "type": "string", + "m_label": "Selection:", + "m_value": "" + }], + "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": "OnOKButtonClick(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": "OnCancelButtonClick(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/IOControl.cpp b/Project/IOControl.cpp new file mode 100644 index 0000000..e3bbb1a --- /dev/null +++ b/Project/IOControl.cpp @@ -0,0 +1,224 @@ +#include "IOControl.h" +#include "IOControlForm.h" + +IOControl::IOControl(int ioFlags) : ControlElement() +{ + m_ioFlags = ioFlags; + + Node* node = new Node(m_position, Node::NODE_IN, m_borderSize); + m_nodeList.push_back(node); + + if(ioFlags & IN_TERMINAL_VOLTAGE) + SetValue(IN_TERMINAL_VOLTAGE); + else if(ioFlags & IN_VELOCITY) + SetValue(IN_VELOCITY); + node->StartMove(m_position); +} + +IOControl::~IOControl() {} +void IOControl::Draw(wxPoint2DDouble translation, double scale) const +{ + std::vector<wxPoint2DDouble> pts; + if(m_angle == 0.0) { + pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize)); + pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize - 10, m_borderSize)); + pts.push_back(m_position + wxPoint2DDouble(m_width / 2 - m_borderSize, 0)); + pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize - 10, -m_borderSize)); + pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize)); + } else if(m_angle == 90.0) { + pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize)); + pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize)); + pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize - 10)); + pts.push_back(m_position + wxPoint2DDouble(0, m_height / 2 - m_borderSize)); + pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize - 10)); + } else if(m_angle == 180.0) { + pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize + 10, m_borderSize)); + pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize)); + pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize)); + pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize + 10, -m_borderSize)); + pts.push_back(m_position + wxPoint2DDouble(-m_width / 2 + m_borderSize, 0)); + } else if(m_angle == 270.0) { + pts.push_back(m_position + wxPoint2DDouble(0, -m_height / 2 + m_borderSize)); + pts.push_back(m_rect.GetRightTop() + wxPoint2DDouble(-m_borderSize, m_borderSize + 10)); + pts.push_back(m_rect.GetRightBottom() + wxPoint2DDouble(-m_borderSize, -m_borderSize)); + pts.push_back(m_rect.GetLeftBottom() + wxPoint2DDouble(m_borderSize, -m_borderSize)); + pts.push_back(m_rect.GetLeftTop() + wxPoint2DDouble(m_borderSize, m_borderSize + 10)); + } + + if(m_selected) { + glColor4dv(m_selectionColour.GetRGBA()); + double borderSize = (m_borderSize * 2.0 + 1.0) / scale; + std::vector<wxPoint2DDouble> selPts = pts; + if(m_angle == 0.0) { + selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2); + selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2); + selPts[2] += wxPoint2DDouble(1.5 * borderSize / 2, 0); + selPts[3] += wxPoint2DDouble(borderSize / 2, borderSize / 2); + selPts[4] += wxPoint2DDouble(-borderSize / 2, borderSize / 2); + } else if(m_angle == 90.0) { + selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2); + selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2); + selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2); + selPts[3] += wxPoint2DDouble(0, 1.5 * borderSize / 2); + selPts[4] += wxPoint2DDouble(-borderSize / 2, borderSize / 2); + } else if(m_angle == 180.0) { + selPts[0] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2); + selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2); + selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2); + selPts[3] += wxPoint2DDouble(-borderSize / 2, borderSize / 2); + selPts[4] += wxPoint2DDouble(-1.5 * borderSize / 2, 0); + } else if(m_angle == 270.0) { + selPts[0] += wxPoint2DDouble(0, -1.5 * borderSize / 2); + selPts[1] += wxPoint2DDouble(borderSize / 2, -borderSize / 2); + selPts[2] += wxPoint2DDouble(borderSize / 2, borderSize / 2); + selPts[3] += wxPoint2DDouble(-borderSize / 2, borderSize / 2); + selPts[4] += wxPoint2DDouble(-borderSize / 2, -borderSize / 2); + } + DrawLine(selPts, GL_POLYGON); + } + glLineWidth(1.0); + glColor4d(1.0, 1.0, 1.0, 1.0); + DrawLine(pts, GL_POLYGON); + glColor4d(0.0, 0.0, 0.0, 1.0); + DrawLine(pts, GL_LINE_LOOP); + + // Plot number. + glEnable(GL_TEXTURE_2D); + glColor4d(0.0, 0.0, 0.0, 1.0); + m_glStringValue->bind(); + if(m_angle == 0.0) { + m_glStringValue->render(m_position.m_x - 5, m_position.m_y); + } else if(m_angle == 90.0) { + m_glStringValue->render(m_position.m_x, m_position.m_y - 5); + } else if(m_angle == 180.0) { + m_glStringValue->render(m_position.m_x + 5, m_position.m_y); + } else if(m_angle == 270.0) { + m_glStringValue->render(m_position.m_x, m_position.m_y + 5); + } + + glDisable(GL_TEXTURE_2D); + + glColor4d(0.0, 0.0, 0.0, 1.0); + DrawNodes(); +} + +bool IOControl::ShowForm(wxWindow* parent, Element* element) +{ + IOControlForm* form = new IOControlForm(parent, this); + if(form->ShowModal() == wxID_OK) { + form->Destroy(); + return true; + } + form->Destroy(); + return false; +} + +void IOControl::Rotate(bool clockwise) +{ + if(clockwise) + m_angle += 90.0; + else + m_angle -= 90.0; + if(m_angle >= 360.0) + m_angle = 0.0; + else if(m_angle < 0) + m_angle = 270.0; + + UpdatePoints(); + + for(auto it = m_nodeList.begin(), itEnd = m_nodeList.end(); it != itEnd; ++it) { + Node* node = *it; + node->Rotate(clockwise); + } +} + +wxString IOControl::GenerateText() +{ + wxString omega = wxString::FromUTF8("\xCF\x89"); + + switch(m_value) { + case IN_TERMINAL_VOLTAGE: { + m_ioNodeType = Node::NODE_OUT; + return _("Vt"); + } break; + case IN_VELOCITY: { + m_ioNodeType = Node::NODE_OUT; + return omega; + } break; + case IN_ACTIVE_POWER: { + m_ioNodeType = Node::NODE_OUT; + return _("Pe"); + } break; + case IN_REACTIVE_POWER: { + m_ioNodeType = Node::NODE_OUT; + return _("Qe"); + } break; + case OUT_FIELD_VOLTAGE: { + m_ioNodeType = Node::NODE_IN; + return _("Vf"); + } break; + case OUT_MEC_POWER: { + m_ioNodeType = Node::NODE_IN; + return _("Pm"); + } break; + } + return ""; +} + +void IOControl::SetValue(IOFlags value) +{ + m_value = value; + wxString text = GenerateText(); + + wxFont font(m_fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxScreenDC dc; + + if(m_glStringValue) { + delete m_glStringValue; + m_glStringValue = NULL; + } + m_glStringValue = new wxGLString(text); + m_glStringValue->setFont(font); + m_glStringValue->consolidate(&dc); + + m_width = m_glStringValue->getWidth() + 10 + 2 * m_borderSize; + m_height = m_glStringValue->getheight() + 10 + 2 * m_borderSize; + + SetPosition(m_position); // Update rectangle. + + UpdatePoints(); +} + +void IOControl::UpdatePoints() +{ + if(m_nodeList.size() != 0) { + Node* node = m_nodeList[0]; + if(node->GetNodeType() != m_ioNodeType) { + // Rotate 180 degrees + node->Rotate(); + node->Rotate(); + } + node->SetNodeType(m_ioNodeType); + if(m_angle == 0.0) { + if(m_ioNodeType == Node::NODE_IN) + node->SetPosition(m_position + wxPoint2DDouble(-m_width / 2, 0)); + else + node->SetPosition(m_position + wxPoint2DDouble(m_width / 2 - 2, 0)); + } else if(m_angle == 90.0) { + if(m_ioNodeType == Node::NODE_IN) + node->SetPosition(m_position + wxPoint2DDouble(0, -m_height / 2)); + else + node->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2 - 2)); + } else if(m_angle == 180.0) { + if(m_ioNodeType == Node::NODE_IN) + node->SetPosition(m_position + wxPoint2DDouble(m_width / 2, 0)); + else + node->SetPosition(m_position + wxPoint2DDouble(2 - m_width / 2, 0)); + } else if(m_angle == 270.0) { + if(m_ioNodeType == Node::NODE_IN) + node->SetPosition(m_position + wxPoint2DDouble(0, m_height / 2)); + else + node->SetPosition(m_position + wxPoint2DDouble(0, 2 - m_height / 2)); + } + } +} diff --git a/Project/IOControl.h b/Project/IOControl.h new file mode 100644 index 0000000..e736ac1 --- /dev/null +++ b/Project/IOControl.h @@ -0,0 +1,49 @@ +#ifndef IOCONTROL_H +#define IOCONTROL_H + +#include "ControlElement.h" + +#include <wx/dcscreen.h> +#include "wxGLString.h" + +class IOControlForm; + +class IOControl : public ControlElement +{ + public: + enum IOFlags { + IN_TERMINAL_VOLTAGE = 1 << 0, + IN_VELOCITY = 1 << 1, + IN_ACTIVE_POWER = 1 << 2, + IN_REACTIVE_POWER = 1 << 3, + OUT_FIELD_VOLTAGE = 1 << 4, + OUT_MEC_POWER = 1 << 5 + }; + + IOControl(int ioFlags); + ~IOControl(); + + virtual void Draw(wxPoint2DDouble translation, double scale) const; + virtual bool Contains(wxPoint2DDouble position) const { return m_rect.Contains(position); } + virtual bool Intersects(wxRect2DDouble rect) const { return m_rect.Intersects(rect); } + virtual bool ShowForm(wxWindow* parent, Element* element); + virtual void Rotate(bool clockwise = true); + + virtual wxString GenerateText(); + virtual void UpdatePoints(); + + virtual IOFlags GetValue() const { return m_value; } + virtual void SetValue(IOFlags value); + virtual int GetIOFlags() const { return m_ioFlags; } + + protected: + IOFlags m_value; + int m_ioFlags; + + Node::NodeType m_ioNodeType = Node::NODE_IN; + + wxGLString* m_glStringValue = NULL; + int m_fontSize = 10; +}; + +#endif // IOCONTROL_H diff --git a/Project/IOControlForm.cpp b/Project/IOControlForm.cpp new file mode 100644 index 0000000..374ce27 --- /dev/null +++ b/Project/IOControlForm.cpp @@ -0,0 +1,89 @@ +#include "IOControlForm.h" + +IOControlForm::IOControlForm(wxWindow* parent, IOControl* ioControl) + : IOControlFormBase(parent) +{ + m_parent = parent; + m_ioControl = ioControl; + + int ioFlags = m_ioControl->GetIOFlags(); + int inChoiceNumber = -1; + int outChoiceNumber = -1; + + if(ioFlags & IOControl::IN_TERMINAL_VOLTAGE) { + m_choiceInput->Append(_("Terminal voltage")); + m_inputFlags.push_back(IOControl::IN_TERMINAL_VOLTAGE); + if(m_ioControl->GetValue() == IOControl::IN_TERMINAL_VOLTAGE) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_VELOCITY) { + m_choiceInput->Append(_("Velocity")); + m_inputFlags.push_back(IOControl::IN_VELOCITY); + if(m_ioControl->GetValue() == IOControl::IN_VELOCITY) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_ACTIVE_POWER) { + m_choiceInput->Append(_("Active power")); + m_inputFlags.push_back(IOControl::IN_ACTIVE_POWER); + if(m_ioControl->GetValue() == IOControl::IN_ACTIVE_POWER) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::IN_REACTIVE_POWER) { + m_choiceInput->Append(_("Reactive power")); + m_inputFlags.push_back(IOControl::IN_REACTIVE_POWER); + if(m_ioControl->GetValue() == IOControl::IN_REACTIVE_POWER) + inChoiceNumber = (int)m_inputFlags.size() - 1; + } + if(ioFlags & IOControl::OUT_FIELD_VOLTAGE) { + m_choiceOutput->Append(_("Field voltage")); + m_outputFlags.push_back(IOControl::OUT_FIELD_VOLTAGE); + if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) + outChoiceNumber = (int)m_outputFlags.size() - 1; + } + if(ioFlags & IOControl::OUT_MEC_POWER) { + m_choiceOutput->Append(_("Mechanical power")); + m_outputFlags.push_back(IOControl::OUT_MEC_POWER); + if(m_ioControl->GetValue() == IOControl::OUT_MEC_POWER) + outChoiceNumber = (int)m_outputFlags.size() - 1; + } + + if(inChoiceNumber != -1) { + m_choiceInput->SetSelection(inChoiceNumber); + m_checkBoxInput->SetValue(true); + m_checkBoxOutput->SetValue(false); + m_choiceOutput->Enable(false); + } else { + m_choiceInput->SetSelection(outChoiceNumber); + m_checkBoxInput->SetValue(false); + m_checkBoxOutput->SetValue(true); + m_choiceInput->Enable(false); + } + +} + +IOControlForm::~IOControlForm() +{ +} +void IOControlForm::OnOKButtonClick(wxCommandEvent& event) +{ + if(ValidateData()) EndModal(wxID_OK); +} + +bool IOControlForm::ValidateData() +{ + return false; +} + +void IOControlForm::OnInputChecked(wxCommandEvent& event) +{ + m_checkBoxOutput->SetValue(false); + m_choiceOutput->Enable(false); + m_choiceInput->Enable(true); +} + +void IOControlForm::OnOutputChecked(wxCommandEvent& event) +{ + m_checkBoxInput->SetValue(false); + m_choiceOutput->Enable(true); + m_choiceInput->Enable(false); +} diff --git a/Project/IOControlForm.h b/Project/IOControlForm.h new file mode 100644 index 0000000..8b3f2d9 --- /dev/null +++ b/Project/IOControlForm.h @@ -0,0 +1,27 @@ +#ifndef IOCONTROLFORM_H +#define IOCONTROLFORM_H + +#include "ElementForm.h" +#include "IOControl.h" + +class IOControlForm : public IOControlFormBase +{ + public: + IOControlForm(wxWindow* parent, IOControl* ioControl); + virtual ~IOControlForm(); + + virtual bool ValidateData(); + + protected: + virtual void OnInputChecked(wxCommandEvent& event); + virtual void OnOutputChecked(wxCommandEvent& event); + virtual void OnCancelButtonClick(wxCommandEvent& event) { EndModal(wxID_CANCEL); }; + virtual void OnOKButtonClick(wxCommandEvent& event); + + wxWindow* m_parent; + IOControl* m_ioControl; + + std::vector<IOControl::IOFlags> m_inputFlags; + std::vector<IOControl::IOFlags> m_outputFlags; +}; +#endif // IOCONTROLFORM_H diff --git a/Project/Project.mk b/Project/Project.mk index 6ed7de9..26bc19e 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=NDSE-69 -Date :=04/04/2017 +Date :=06/04/2017 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC @@ -68,9 +68,9 @@ Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix) $(IntermediateDirector $(IntermediateDirectory)/Camera.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/BusFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementFormBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBitmaps.cpp$(ObjectSuffix) $(IntermediateDirectory)/MainFrameBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/WorkspaceBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/ElementForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ControlEditorBase.cpp$(ObjectSuffix) \ $(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)/ConnectionLine.cpp$(ObjectSuffix) $(IntermediateDirectory)/Sum.cpp$(ObjectSuffix) $(IntermediateDirectory)/Multiplier.cpp$(ObjectSuffix) $(IntermediateDirectory)/Limiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/Exponential.cpp$(ObjectSuffix) $(IntermediateDirectory)/Constant.cpp$(ObjectSuffix) $(IntermediateDirectory)/Gain.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) $(IntermediateDirectory)/SumForm.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/LimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ExponentialForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ConstantForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GainForm.cpp$(ObjectSuffix) + $(IntermediateDirectory)/ConnectionLine.cpp$(ObjectSuffix) $(IntermediateDirectory)/Sum.cpp$(ObjectSuffix) $(IntermediateDirectory)/Multiplier.cpp$(ObjectSuffix) $(IntermediateDirectory)/Limiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiter.cpp$(ObjectSuffix) $(IntermediateDirectory)/Exponential.cpp$(ObjectSuffix) $(IntermediateDirectory)/Constant.cpp$(ObjectSuffix) $(IntermediateDirectory)/Gain.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControl.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) \ + $(IntermediateDirectory)/SumForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/LimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/RateLimiterForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ExponentialForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/ConstantForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/GainForm.cpp$(ObjectSuffix) $(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix) @@ -479,6 +479,14 @@ $(IntermediateDirectory)/Gain.cpp$(DependSuffix): Gain.cpp $(IntermediateDirectory)/Gain.cpp$(PreprocessSuffix): Gain.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/Gain.cpp$(PreprocessSuffix) Gain.cpp +$(IntermediateDirectory)/IOControl.cpp$(ObjectSuffix): IOControl.cpp $(IntermediateDirectory)/IOControl.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/NDSE-69/Documents/GitHub/PSP/Project/IOControl.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IOControl.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/IOControl.cpp$(DependSuffix): IOControl.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IOControl.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IOControl.cpp$(DependSuffix) -MM IOControl.cpp + +$(IntermediateDirectory)/IOControl.cpp$(PreprocessSuffix): IOControl.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IOControl.cpp$(PreprocessSuffix) IOControl.cpp + $(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix): BusForm.cpp $(IntermediateDirectory)/BusForm.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/NDSE-69/Documents/GitHub/PSP/Project/BusForm.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/BusForm.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/BusForm.cpp$(DependSuffix): BusForm.cpp @@ -615,6 +623,14 @@ $(IntermediateDirectory)/GainForm.cpp$(DependSuffix): GainForm.cpp $(IntermediateDirectory)/GainForm.cpp$(PreprocessSuffix): GainForm.cpp $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/GainForm.cpp$(PreprocessSuffix) GainForm.cpp +$(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix): IOControlForm.cpp $(IntermediateDirectory)/IOControlForm.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "C:/Users/NDSE-69/Documents/GitHub/PSP/Project/IOControlForm.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/IOControlForm.cpp$(DependSuffix): IOControlForm.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/IOControlForm.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/IOControlForm.cpp$(DependSuffix) -MM IOControlForm.cpp + +$(IntermediateDirectory)/IOControlForm.cpp$(PreprocessSuffix): IOControlForm.cpp + $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/IOControlForm.cpp$(PreprocessSuffix) IOControlForm.cpp + -include $(IntermediateDirectory)/*$(DependSuffix) ## diff --git a/Project/Project.project b/Project/Project.project index 95c7380..f9a261d 100644 --- a/Project/Project.project +++ b/Project/Project.project @@ -47,6 +47,7 @@ <File Name="Exponential.cpp"/> <File Name="Constant.cpp"/> <File Name="Gain.cpp"/> + <File Name="IOControl.cpp"/> </VirtualDirectory> </VirtualDirectory> <VirtualDirectory Name="view"> @@ -81,6 +82,7 @@ <File Name="ExponentialForm.cpp"/> <File Name="ConstantForm.cpp"/> <File Name="GainForm.cpp"/> + <File Name="IOControlForm.cpp"/> </VirtualDirectory> </VirtualDirectory> <File Name="main.cpp"/> @@ -130,6 +132,7 @@ <File Name="Exponential.h"/> <File Name="Constant.h"/> <File Name="Gain.h"/> + <File Name="IOControl.h"/> </VirtualDirectory> </VirtualDirectory> <VirtualDirectory Name="view"> @@ -164,6 +167,7 @@ <File Name="ExponentialForm.h"/> <File Name="ConstantForm.h"/> <File Name="GainForm.h"/> + <File Name="IOControlForm.h"/> </VirtualDirectory> </VirtualDirectory> </VirtualDirectory> diff --git a/Project/Project.txt b/Project/Project.txt index 01bcf5f..1eda1e9 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/ConnectionLine.cpp.o ./Release/Sum.cpp.o ./Release/Multiplier.cpp.o ./Release/Limiter.cpp.o ./Release/RateLimiter.cpp.o ./Release/Exponential.cpp.o ./Release/Constant.cpp.o ./Release/Gain.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 ./Release/SumForm.cpp.o ./Release/LimiterForm.cpp.o ./Release/RateLimiterForm.cpp.o ./Release/ExponentialForm.cpp.o ./Release/ConstantForm.cpp.o ./Release/GainForm.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/ConnectionLine.cpp.o ./Release/Sum.cpp.o ./Release/Multiplier.cpp.o ./Release/Limiter.cpp.o ./Release/RateLimiter.cpp.o ./Release/Exponential.cpp.o ./Release/Constant.cpp.o ./Release/Gain.cpp.o ./Release/IOControl.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 ./Release/SumForm.cpp.o ./Release/LimiterForm.cpp.o ./Release/RateLimiterForm.cpp.o ./Release/ExponentialForm.cpp.o ./Release/ConstantForm.cpp.o ./Release/GainForm.cpp.o ./Release/IOControlForm.cpp.o |