Blame view

GUI/SW1/SRC/FLEXCABLE.cpp 41.9 KB
886c558b   Steve Greedy   SACAMOS Public Re...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/////////////////////////////////////////////////////////////////////////////////
//
// This file is part of SACAMOS, cable models for EMI simulations in SPICE.
// It was developed by the University of Nottingham and the Netherlands Aerospace
// Centre (NLR) for ESA under contract number 4000112765/14/NL/HK.
//
// Copyright (C) 2015 - 2017 University of Nottingham
//
// SACAMOS is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// SACAMOS is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// A copy of the GNU General Public License version 3 can be found in the
// file GNU_GPL_v3 in the root or at <http://www.gnu.org/licenses/>.
//
// wxWidgets is currently licenced under the "wxWindows Library Licence".
// A copy of the wxWindows Library Licence, Version 3.1 can be found in the file
// wxWindows_Library_Licence_v3-1 in the root or at:
// <https://www.wxwidgets.org/about/licence/>
//
// The University of Nottingham can be contacted at: ggiemr@nottingham.ac.uk
//
// File Contents:
//
// NAME
//     FLEXCABLE.cpp
//
// DESCRIPTION
//     GUI for the construction of cable_spec file for cable type: Flexcable
//
// AUTHOR(S)
//     Steve Greedy
//
/////////////////////////////////////////////////////////////////////////////////
#include "FLEXCABLE.h"

//(*InternalHeaders(FLEXCABLE)
#include <wx/settings.h>
#include <wx/intl.h>
#include <wx/string.h>
//*)

//(*IdInit(FLEXCABLE)
const long FLEXCABLE::ID_STATICTEXT1 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL1 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT16 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL13 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT2 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL2 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT3 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL3 = wxNewId();
dd86ff43   Steve Greedy   Updates to SW1
58
59
60
const long FLEXCABLE::ID_STATICTEXT17 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL14 = wxNewId();
const long FLEXCABLE::ID_GRID1 = wxNewId();
886c558b   Steve Greedy   SACAMOS Public Re...
61
const long FLEXCABLE::ID_STATICTEXT4 = wxNewId();
dd86ff43   Steve Greedy   Updates to SW1
62
const long FLEXCABLE::ID_CHECKBOX2 = wxNewId();
886c558b   Steve Greedy   SACAMOS Public Re...
63
const long FLEXCABLE::ID_STATICTEXT5 = wxNewId();
dd86ff43   Steve Greedy   Updates to SW1
64
const long FLEXCABLE::ID_COMBOBOX1 = wxNewId();
886c558b   Steve Greedy   SACAMOS Public Re...
65
const long FLEXCABLE::ID_STATICTEXT6 = wxNewId();
dd86ff43   Steve Greedy   Updates to SW1
66
const long FLEXCABLE::ID_CHECKBOX3 = wxNewId();
886c558b   Steve Greedy   SACAMOS Public Re...
67
68
69
70
71
72
73
const long FLEXCABLE::ID_PANEL2 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT12 = wxNewId();
const long FLEXCABLE::ID_TEXTCTRL12 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT13 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT14 = wxNewId();
const long FLEXCABLE::ID_STATICTEXT15 = wxNewId();
const long FLEXCABLE::ID_CHECKBOX1 = wxNewId();
886c558b   Steve Greedy   SACAMOS Public Re...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const long FLEXCABLE::ID_PANEL3 = wxNewId();
const long FLEXCABLE::ID_NOTEBOOK1 = wxNewId();
const long FLEXCABLE::ID_BUTTON1 = wxNewId();
const long FLEXCABLE::ID_BUTTON2 = wxNewId();
const long FLEXCABLE::ID_BUTTON3 = wxNewId();
const long FLEXCABLE::ID_PANEL1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(FLEXCABLE,wxDialog)
	//(*EventTable(FLEXCABLE)
	//*)
END_EVENT_TABLE()

FLEXCABLE::FLEXCABLE(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
	//(*Initialize(FLEXCABLE)
	wxBoxSizer* BoxSizer4;
	wxStaticBoxSizer* StaticBoxSizer2;
dd86ff43   Steve Greedy   Updates to SW1
92
93
94
95
	wxBoxSizer* BoxSizer6;
	wxFlexGridSizer* FlexGridSizer4;
	wxBoxSizer* BoxSizer5;
	wxBoxSizer* BoxSizer7;
886c558b   Steve Greedy   SACAMOS Public Re...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	wxFlexGridSizer* FlexGridSizer3;
	wxFlexGridSizer* FlexGridSizer5;
	wxFlexGridSizer* FlexGridSizer2;
	wxBoxSizer* BoxSizer2;
	wxBoxSizer* BoxSizer1;
	wxStaticBoxSizer* StaticBoxSizer1;
	wxFlexGridSizer* FlexGridSizer1;
	wxBoxSizer* BoxSizer3;

	Create(parent, wxID_ANY, _("SACAMOS: FLAXCABLE MODEL"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
	FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
	StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("Flex Cable Parameters"));
	FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
	BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
	StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Cabe Name"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
	BoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
	BoxSizer1->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	FlexGridSizer2->Add(BoxSizer1, 1, wxALL|wxEXPAND, 5);
	BoxSizer3 = new wxBoxSizer(wxVERTICAL);
	Notebook1 = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_NOTEBOOK1"));
	Panel2 = new wxPanel(Notebook1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
dd86ff43   Steve Greedy   Updates to SW1
118
119
	BoxSizer5 = new wxBoxSizer(wxVERTICAL);
	BoxSizer6 = new wxBoxSizer(wxVERTICAL);
886c558b   Steve Greedy   SACAMOS Public Re...
120
	FlexGridSizer3 = new wxFlexGridSizer(0, 2, 0, 0);
dd86ff43   Steve Greedy   Updates to SW1
121
	StaticText16 = new wxStaticText(Panel2, ID_STATICTEXT16, _("Number of Conductor Rows"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT16"));
886c558b   Steve Greedy   SACAMOS Public Re...
122
	FlexGridSizer3->Add(StaticText16, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
dd86ff43   Steve Greedy   Updates to SW1
123
	TextCtrl13 = new wxTextCtrl(Panel2, ID_TEXTCTRL13, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER, wxDefaultValidator, _T("ID_TEXTCTRL13"));
886c558b   Steve Greedy   SACAMOS Public Re...
124
	FlexGridSizer3->Add(TextCtrl13, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
dd86ff43   Steve Greedy   Updates to SW1
125
	StaticText2 = new wxStaticText(Panel2, ID_STATICTEXT2, _("Dielectric Width x, (m)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
886c558b   Steve Greedy   SACAMOS Public Re...
126
127
128
	FlexGridSizer3->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	TextCtrl2 = new wxTextCtrl(Panel2, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
	FlexGridSizer3->Add(TextCtrl2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
dd86ff43   Steve Greedy   Updates to SW1
129
	StaticText3 = new wxStaticText(Panel2, ID_STATICTEXT3, _("Dielectric Height, y (m)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
886c558b   Steve Greedy   SACAMOS Public Re...
130
131
132
	FlexGridSizer3->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	TextCtrl3 = new wxTextCtrl(Panel2, ID_TEXTCTRL3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
	FlexGridSizer3->Add(TextCtrl3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
886c558b   Steve Greedy   SACAMOS Public Re...
133
134
135
136
	StaticText17 = new wxStaticText(Panel2, ID_STATICTEXT17, _("Conductor Conductivity (S/m)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT17"));
	FlexGridSizer3->Add(StaticText17, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	TextCtrl14 = new wxTextCtrl(Panel2, ID_TEXTCTRL14, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL14"));
	FlexGridSizer3->Add(TextCtrl14, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
dd86ff43   Steve Greedy   Updates to SW1
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	BoxSizer6->Add(FlexGridSizer3, 0, wxALIGN_LEFT, 0);
	BoxSizer5->Add(BoxSizer6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
	Grid1 = new wxGrid(Panel2, ID_GRID1, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER|wxVSCROLL|wxHSCROLL|wxFULL_REPAINT_ON_RESIZE, _T("ID_GRID1"));
	BoxSizer7->Add(Grid1, 3, wxALL|wxEXPAND, 5);
	BoxSizer5->Add(BoxSizer7, 1, wxALL|wxEXPAND, 5);
	FlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
	StaticText4 = new wxStaticText(Panel2, ID_STATICTEXT4, _("Use Laplace"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
	FlexGridSizer4->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	CheckBox2 = new wxCheckBox(Panel2, ID_CHECKBOX2, _("Yes"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
	CheckBox2->SetValue(true);
	CheckBox2->Disable();
	FlexGridSizer4->Add(CheckBox2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	StaticText5 = new wxStaticText(Panel2, ID_STATICTEXT5, _("View Mesh"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
	FlexGridSizer4->Add(StaticText5, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	ComboBox1 = new wxComboBox(Panel2, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
	FlexGridSizer4->Add(ComboBox1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText6 = new wxStaticText(Panel2, ID_STATICTEXT6, _("Refine Mesh"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
	FlexGridSizer4->Add(StaticText6, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	CheckBox3 = new wxCheckBox(Panel2, ID_CHECKBOX3, _("Yes"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX3"));
	CheckBox3->SetValue(false);
	CheckBox3->Disable();
	FlexGridSizer4->Add(CheckBox3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer5->Add(FlexGridSizer4, 1, wxALL|wxEXPAND, 5);
	Panel2->SetSizer(BoxSizer5);
	BoxSizer5->Fit(Panel2);
	BoxSizer5->SetSizeHints(Panel2);
886c558b   Steve Greedy   SACAMOS Public Re...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
	Panel3 = new wxPanel(Notebook1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
	BoxSizer4 = new wxBoxSizer(wxVERTICAL);
	FlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
	StaticText12 = new wxStaticText(Panel3, ID_STATICTEXT12, _("Dielectric Permittivity"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12"));
	FlexGridSizer5->Add(StaticText12, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	TextCtrl12 = new wxTextCtrl(Panel3, ID_TEXTCTRL12, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL12"));
	FlexGridSizer5->Add(TextCtrl12, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
	StaticText13 = new wxStaticText(Panel3, ID_STATICTEXT13, _("Or"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT13"));
	FlexGridSizer5->Add(StaticText13, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText14 = new wxStaticText(Panel3, ID_STATICTEXT14, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT14"));
	FlexGridSizer5->Add(StaticText14, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText15 = new wxStaticText(Panel3, ID_STATICTEXT15, _("Frequency Dependent Model"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT15"));
	FlexGridSizer5->Add(StaticText15, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	CheckBox1 = new wxCheckBox(Panel3, ID_CHECKBOX1, _("Yes"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
	CheckBox1->SetValue(false);
	FlexGridSizer5->Add(CheckBox1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer4->Add(FlexGridSizer5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
886c558b   Steve Greedy   SACAMOS Public Re...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
	Panel3->SetSizer(BoxSizer4);
	BoxSizer4->Fit(Panel3);
	BoxSizer4->SetSizeHints(Panel3);
	Notebook1->AddPage(Panel2, _("General"), false);
	Notebook1->AddPage(Panel3, _("Material"), false);
	BoxSizer3->Add(Notebook1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	FlexGridSizer2->Add(BoxSizer3, 0, wxALL|wxEXPAND, 5);
	StaticBoxSizer1->Add(FlexGridSizer2, 10, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
	Button1 = new wxButton(this, ID_BUTTON1, _("SAVE"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
	BoxSizer2->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button2 = new wxButton(this, ID_BUTTON2, _("BUILD"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
	BoxSizer2->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button3 = new wxButton(this, ID_BUTTON3, _("CLOSE"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
	BoxSizer2->Add(Button3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticBoxSizer1->Add(BoxSizer2, 1, wxALL|wxEXPAND, 5);
	FlexGridSizer1->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND, 5);
	StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Cross Section"));
	Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(500,500), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
	Panel1->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
	Panel1->SetToolTip(_("Double Click to Reset Schematic"));
	StaticBoxSizer2->Add(Panel1, 1, wxALL|wxALIGN_TOP, 5);
	FlexGridSizer1->Add(StaticBoxSizer2, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
	SetSizer(FlexGridSizer1);
	FlexGridSizer1->Fit(this);
	FlexGridSizer1->SetSizeHints(this);

	Connect(ID_TEXTCTRL13,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&FLEXCABLE::OnTextCtrl13Text);
dd86ff43   Steve Greedy   Updates to SW1
209
	Connect(ID_TEXTCTRL13,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&FLEXCABLE::OnTextCtrl13TextEnter);
886c558b   Steve Greedy   SACAMOS Public Re...
210
211
	Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&FLEXCABLE::OnTextCtrl2Text);
	Connect(ID_TEXTCTRL3,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&FLEXCABLE::OnTextCtrl3Text);
dd86ff43   Steve Greedy   Updates to SW1
212
	Connect(ID_CHECKBOX3,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&FLEXCABLE::OnCheckBox3Click);
886c558b   Steve Greedy   SACAMOS Public Re...
213
214
	Connect(ID_TEXTCTRL12,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&FLEXCABLE::OnTextCtrl12Text);
	Connect(ID_CHECKBOX1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&FLEXCABLE::OnCheckBox1Click);
886c558b   Steve Greedy   SACAMOS Public Re...
215
216
217
218
219
220
	Connect(ID_NOTEBOOK1,wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,(wxObjectEventFunction)&FLEXCABLE::OnNotebook1PageChanging);
	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&FLEXCABLE::OnButton1Click);
	Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&FLEXCABLE::OnButton2Click);
	Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&FLEXCABLE::OnButton3Click);
	Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&FLEXCABLE::OnPanel1Paint,0,this);
	Panel1->Connect(wxEVT_LEFT_DCLICK,(wxObjectEventFunction)&FLEXCABLE::OnPanel1LeftDClick,0,this);
dd86ff43   Steve Greedy   Updates to SW1
221
	Connect(wxEVT_PAINT,(wxObjectEventFunction)&FLEXCABLE::OnPaint);
886c558b   Steve Greedy   SACAMOS Public Re...
222
223
224
225
	//*)

    TextCtrl2->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
    TextCtrl3->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
886c558b   Steve Greedy   SACAMOS Public Re...
226
227
228
    TextCtrl12->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
    TextCtrl14->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
    CheckBox1->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
dd86ff43   Steve Greedy   Updates to SW1
229
    Grid1->Bind(wxEVT_SET_FOCUS,(wxObjectEventFunction)&FLEXCABLE::OnHighlightSchematic, this);
886c558b   Steve Greedy   SACAMOS Public Re...
230
231
232
233
234
235
236
237
238
}


FLEXCABLE::~FLEXCABLE()
{
	//(*Destroy(FLEXCABLE)
	//*)
}

dd86ff43   Steve Greedy   Updates to SW1
239
void FLEXCABLE::OnPaint(wxPaintEvent& event)
886c558b   Steve Greedy   SACAMOS Public Re...
240
{
dd86ff43   Steve Greedy   Updates to SW1
241
242
    if (EDIT_EXISTING==true) EditExistingCable();
}
886c558b   Steve Greedy   SACAMOS Public Re...
243

dd86ff43   Steve Greedy   Updates to SW1
244
245
void FLEXCABLE::SetPathToMOD(wxString Path, wxString Name)
{
886c558b   Steve Greedy   SACAMOS Public Re...
246
247
    pathToMOD << Path;
    MODname << Name;
886c558b   Steve Greedy   SACAMOS Public Re...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
}

void FLEXCABLE::OnButton1Click(wxCommandEvent& event)
{
    int IsError = 0;

    wxString fileName = TextCtrl1->GetValue();

    TextCtrl1->SetBackgroundColour(wxColor(255,255,255));

    if (fileName == "")
    {
        wxMessageBox("Please Specify a Cable Name" , _("Missing Cable Name"));
        return;
    }

    check_is_empty(TextCtrl2, &IsError);
    check_is_empty(TextCtrl3, &IsError);
886c558b   Steve Greedy   SACAMOS Public Re...
266
267
268
269
270
    check_is_empty(TextCtrl13, &IsError);
    check_is_empty(TextCtrl14, &IsError);

    if (CheckBox1->GetValue())
    {
d475f4d6   Steve Greedy   SW1 Update to v1.0.1
271
272
273
274
275
//        check_is_empty(TextCtrl7, &IsError);
//        check_is_empty(TextCtrl8, &IsError);
//        check_is_empty(TextCtrl9, &IsError);
//        check_is_empty(TextCtrl10, &IsError);
//        check_is_empty(TextCtrl11, &IsError);
886c558b   Steve Greedy   SACAMOS Public Re...
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
    }

    else
    {
        check_is_empty(TextCtrl12, &IsError);
    }

    if ( IsError == 1)
    {
        wxMessageBox("Please fix highlighted errors" , _("Non numeric entry"));
        return;
    }

    WriteCableFile (fileName);

    Button1->Disable();
}

void FLEXCABLE::OnCheckBox1Click(wxCommandEvent& event)
{
d475f4d6   Steve Greedy   SW1 Update to v1.0.1
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318

    TextCtrl12->Disable();

    FD_ESR *winFD_ESR = new FD_ESR(this);

    winFD_ESR->formtype = 1;

    if ( winFD_ESR->ShowModal() == wxID_OK )
    {
        FD_ESR6 = winFD_ESR->TextCtrl6->GetValue();
        FD_ESR7 = winFD_ESR->TextCtrl7->GetValue();
        FD_ESR8 = winFD_ESR->TextCtrl8->GetValue();
        FD_ESR9 = winFD_ESR->TextCtrl9->GetValue();
        FD_ESR10= winFD_ESR->TextCtrl10->GetValue();
    }
    winFD_ESR->Destroy();


//    TextCtrl7->Enable();
//    TextCtrl8->Enable();
//    TextCtrl9->Enable();
//    TextCtrl10->Enable();
//    TextCtrl11->Enable();
886c558b   Steve Greedy   SACAMOS Public Re...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340

}

void FLEXCABLE::OnButton2Click(wxCommandEvent& event)
{
    //CABLE BUIDER
    wxString fileName = TextCtrl1->GetValue();
    wxString fineName = fileName;

    std::stringstream stream;
    stream  << "\"..\\BIN\\cable_model_builder.exe\""
            << " "
            << "..\\" + MODname + "\\CABLE\\"
            << fileName ;

    system(stream.str().c_str());

    // Display Run Status
    RUN_STATUS *run_status = new RUN_STATUS(this);
    run_status->ShowModal();

    Button1->Enable();
dd86ff43   Steve Greedy   Updates to SW1
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372

    if (CheckBox2->GetValue())
    {

        wxString pattern (("*.msh.vtk")) ;

        wxString file;

        ComboBox1->Clear();

        file = wxFindFirstFile(pattern);

        while ( !file.empty())
        {
                wxString meshfile = file;
                size_t extindex = meshfile.find_last_of (".");

                meshfile  = meshfile.substr(0, extindex);

                extindex = meshfile.find_last_of (".");

                meshfile  = meshfile.substr(0, extindex);

                meshfile = meshfile.substr(2,meshfile.length());

                ComboBox1->Append(meshfile);

                file = wxFindNextFile();
        }

        CheckBox3->Enable();
    }
886c558b   Steve Greedy   SACAMOS Public Re...
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
}

void FLEXCABLE::OnButton3Click(wxCommandEvent& event)
{
    //clean up directory
    clean_temp_files();
    Close();
}

void FLEXCABLE::OnTextCtrl2Text(wxCommandEvent& event)
{
    int IsError = 0;
    check_is_numeric(TextCtrl2, &IsError);
    check_is_positive(TextCtrl2, &IsError);
}

void FLEXCABLE::OnTextCtrl3Text(wxCommandEvent& event)
{
    int IsError = 0;
    check_is_numeric(TextCtrl3, &IsError);
    check_is_positive(TextCtrl3, &IsError);
}

886c558b   Steve Greedy   SACAMOS Public Re...
396
397
398
399
400
401
402
void FLEXCABLE::OnTextCtrl12Text(wxCommandEvent& event)
{
    int IsError = 0;
    check_is_numeric(TextCtrl12, &IsError);
    check_is_positive(TextCtrl2, &IsError);
}

d475f4d6   Steve Greedy   SW1 Update to v1.0.1
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
//void FLEXCABLE::OnTextCtrl7Text(wxCommandEvent& event)
//{
//    int IsError = 0;
//    check_is_numeric(TextCtrl7, &IsError);
//    check_is_positive(TextCtrl7, &IsError);
//}
//
//void FLEXCABLE::OnTextCtrl8Text(wxCommandEvent& event)
//{
//    int IsError = 0;
//    check_is_numeric(TextCtrl8, &IsError);
//    check_is_positive(TextCtrl8, &IsError);
//}
//
//void FLEXCABLE::OnTextCtrl9Text(wxCommandEvent& event)
//{
//    int IsError = 0;
//    check_is_numeric_list(TextCtrl9, &IsError);
//}
//
//void FLEXCABLE::OnTextCtrl10Text(wxCommandEvent& event)
//{
//    int IsError = 0;
//    check_is_numeric(TextCtrl10, &IsError);
//    check_is_positive(TextCtrl10, &IsError);
//}

//void FLEXCABLE::OnTextCtrl11Text(wxCommandEvent& event)
//{
//    int IsError = 0;
//    check_is_numeric_list(TextCtrl11, &IsError);
//}
886c558b   Steve Greedy   SACAMOS Public Re...
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464

void FLEXCABLE::OnTextCtrl13Text(wxCommandEvent& event)
{
    int IsError = 0;
    check_is_numeric(TextCtrl13, &IsError);
    check_is_positive(TextCtrl3, &IsError);

    double value_tb13;
    wxString contents_tb13;

    contents_tb13 = TextCtrl13->GetValue();

    contents_tb13.ToDouble(&value_tb13);

    if (floor(value_tb13) != ceil(value_tb13) || value_tb13 < 1)
    {
        TextCtrl13->SetBackgroundColour(wxColor(255,153,153));
        TextCtrl13->SetFocus();
        IsError = 1;
    }
}

void FLEXCABLE::WriteCableFile (wxString fileName)
{
    ofstream cableFile;

    wxString fullFileName = pathToMOD + "//CABLE//" + fileName + ".cable_spec";

    cableFile.open (fullFileName);

dd86ff43   Steve Greedy   Updates to SW1
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
    int n_rows, n_conductors, row;

    n_conductors = 0;

    n_rows = wxAtoi(TextCtrl13->GetValue());

    for (int i = 0; i < n_rows; i++){

        wxString conductors = Grid1->GetCellValue(i,5);

        n_conductors  = n_conductors + wxAtoi(conductors);

    }

    int n_parameters = (n_rows * 6) + 4;

886c558b   Steve Greedy   SACAMOS Public Re...
481
482
    if (cableFile.is_open())
    {
886c558b   Steve Greedy   SACAMOS Public Re...
483
484
        cableFile <<"# MOD_cable_lib_dir \n";
        cableFile <<"../"<< MODname <<"/CABLE/"<<"\n";
dd86ff43   Steve Greedy   Updates to SW1
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
        cableFile <<"flex_cable\n";
        cableFile << n_conductors <<" #number of conductors \n";
        cableFile << n_parameters <<" #number of parameters \n";

        cableFile << TextCtrl2->GetValue() <<" # parameter 1: dielectric width (x dimension)\n";
        cableFile << TextCtrl3->GetValue() <<" # parameter 2: dielectric height (y dimension)\n";
        cableFile << TextCtrl13->GetValue() <<" # parameter 3: number of rows of conductors\n";

        for (row = 0; row < n_rows;row++){

            cableFile << Grid1->GetCellValue(row,0) <<" # parameter "<< (row * 6) + 4 <<": row "<<row+1<<" centre offset x\n";
            cableFile << Grid1->GetCellValue(row,1) <<" # parameter "<< (row * 6) + 5 <<": row "<<row+1<<" centre offset y\n";
            cableFile << Grid1->GetCellValue(row,2) <<" # parameter "<< (row * 6) + 6 <<": row "<<row+1<<" conductor width (x dimension)\n";
            cableFile << Grid1->GetCellValue(row,3) <<" # parameter "<< (row * 6) + 7 <<": row "<<row+1<<" conductor width (y dimension)\n";
            cableFile << Grid1->GetCellValue(row,4) <<" # parameter "<< (row * 6) + 8 <<": row "<<row+1<<" conductor separation\n";
            cableFile << Grid1->GetCellValue(row,5) <<" # parameter "<< (row * 6) + 9 <<": row "<<row+1<<" number of conductors\n";
        }

        cableFile << TextCtrl14->GetValue() <<" # parameter "<< ((row-1) * 6) + 10<<": conductivity\n";

886c558b   Steve Greedy   SACAMOS Public Re...
505
506
507
508
        cableFile <<"1 # number of frequency dependent parameters\n";

        if (CheckBox1->GetValue()){
            cableFile << "# Dielectric relative permittivity model follows\n";
d475f4d6   Steve Greedy   SW1 Update to v1.0.1
509
510
511
512
513
            cableFile << FD_ESR6 <<" # w normalisation constant\n";
            cableFile << FD_ESR7 <<" # a order, a coefficients follow below\n";
            cableFile << FD_ESR8 <<" \n";
            cableFile << FD_ESR9 <<" # b order, b coefficients follow below\n";
            cableFile << FD_ESR10 <<" \n";
886c558b   Steve Greedy   SACAMOS Public Re...
514
515
516
517
518
519
520
521
522
523
524
        }

        else{
            cableFile << "# Dielectric relative permittivity model follows\n";
            cableFile << "1.0 # w normalisation constant\n";
            cableFile << "0 # a order, a coefficients follow below\n";
            cableFile << TextCtrl12->GetValue()<<"\n";
            cableFile << "0 # b order, b coefficients follow below\n";
            cableFile << "1.0\n";
        }

dd86ff43   Steve Greedy   Updates to SW1
525
526
527
528
529
530
531
532
533
534
535
536
537
538
        cableFile <<"use_laplace \n";

        if (CheckBox2->GetValue())
        {
            //cableFile << "Laplace_boundary_constant\n";
            //cableFile << MESH_PARAM1 <<"\n";
            cableFile << "Laplace_surface_mesh_constant\n";
            cableFile << MESH_PARAM2 <<"\n";
            //cableFile << "max_mesh_edge_length\n";
            //cableFile << MESH_PARAM3 <<"\n";

            CheckBox2 ->SetValue(false);
        }

886c558b   Steve Greedy   SACAMOS Public Re...
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
        cableFile.close();
    }
}

void FLEXCABLE::OnPanel1Paint(wxPaintEvent& event)
{
    flexcableSchematic();
}

void FLEXCABLE::flexcableSchematic()
{
    int size_h, size_v;
    Panel1->GetSize(&size_h, &size_v );

    wxClientDC dc(Panel1);
    dc.Clear();

    // Draw centre lines
    dc.SetPen( wxPen( wxColor(224,224,224),1 , wxDOT_DASH) );
    dc.DrawLine( 0, size_v/2, size_h,size_v/2 );
    dc.DrawLine( size_h/2, 0, size_h/2, size_v);

    dc.SetTextForeground(*wxBLUE);
dd86ff43   Steve Greedy   Updates to SW1
562
563
564
565
566
567
    dc.DrawText("General Multi-layer Flexcable", 10, 15);

    float conductor_width_r1, conductor_height_r1, conductor_width_r2, conductor_height_r2,conductor_width_r3, conductor_height_r3,conductor_separation_r1, conductor_separation_r2,totalHeight, totalWidth;

    conductor_width_r1 = 0.175 * size_h;
    conductor_height_r1 = 0.06 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
568

dd86ff43   Steve Greedy   Updates to SW1
569
570
    conductor_width_r2 = 0.175 * size_h;
    conductor_height_r2 = 0.04 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
571

dd86ff43   Steve Greedy   Updates to SW1
572
573
574
575
576
577
578
    conductor_width_r3 = 0.9 * size_h;
    conductor_height_r3 = 0.02 * size_v;

    conductor_separation_r1 = 0.05 * size_h;
    conductor_separation_r2 = 0.1 * size_h;

    totalHeight = 0.5 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
579
580
581
582
583
584
585
    totalWidth = 0.98 * size_h;

    dc.SetPen( wxPen( wxColor(192,192,192),1 ) );
    dc.SetBrush(wxBrush(wxColor(224,224,224), wxBDIAGONAL_HATCH));
    dc.DrawRectangle(wxPoint(size_h/2-totalWidth/2, size_v/2-totalHeight/2), wxSize(totalWidth,totalHeight));

    dc.SetBrush(wxBrush(wxColor(224,224,224), wxSOLID));
886c558b   Steve Greedy   SACAMOS Public Re...
586

dd86ff43   Steve Greedy   Updates to SW1
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
    //row 1
    dc.DrawRectangle(wxPoint(size_h/2- 2 * conductor_width_r1 - 2 * conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
    dc.DrawRectangle(wxPoint(size_h/2- conductor_width_r1 - conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
    dc.DrawRectangle(wxPoint(size_h/2 + conductor_width_r1 + conductor_separation_r1 , size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));

    //row 2
    dc.DrawRectangle(wxPoint(size_h/2 - 1.5 * conductor_width_r2 - conductor_separation_r2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));
    dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r2/2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));

    // row n
    dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r3/2, size_v/2 + totalHeight/4 ), wxSize(conductor_width_r3,conductor_height_r3));

    dc.SetPen( wxPen( wxColor(0,0,0),2, wxDOT ) );
    dc.DrawLine( size_h/2 - conductor_separation_r1 , size_v/3, size_h/2 + conductor_width_r1 + conductor_separation_r1, size_v/3);
    dc.DrawLine( size_h/2 - conductor_width_r2/2 , size_v/2 - conductor_height_r2/2 , size_h/2 - conductor_width_r2/2 - conductor_separation_r2, size_v/2 - conductor_height_r2/2);

    dc.SetPen( wxPen( wxColor(51,51,255),1 , wxDOT_DASH) );
    dc.DrawLine( size_h*0.2, size_v/2-conductor_height_r2/2, size_h*0.7,size_v/2-conductor_height_r2/2 );
    dc.DrawLine( size_h/2-conductor_width_r2/2-conductor_separation_r2/2, size_v/2-conductor_height_r2, size_h/2-conductor_width_r2/2-conductor_separation_r2/2,size_v/2+conductor_height_r2 );

    wxPoint arrowHead[3];

    dc.SetPen(wxPen(wxColor(51,51,255), 3));
    dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
    dc.DrawLine( size_h/2-conductor_width_r2/2-conductor_separation_r2/2,size_v/2-conductor_height_r2*2, size_h/2,size_v/2-conductor_height_r2*2 );

    arrowHead[0] = wxPoint(size_h/2-conductor_width_r2/2-conductor_separation_r2/2,size_v/2-conductor_height_r2*2);
    arrowHead[1] = wxPoint(size_h/2-conductor_width_r2/2-conductor_separation_r2/2+5,size_v/2-conductor_height_r2*2-3);
    arrowHead[2] = wxPoint(size_h/2-conductor_width_r2/2-conductor_separation_r2/2+5,size_v/2-conductor_height_r2*2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h/2,size_v/2-conductor_height_r2*2);
    arrowHead[1] = wxPoint(size_h/2 -5,size_v/2-conductor_height_r2*2-3);
    arrowHead[2] = wxPoint(size_h/2 -5,size_v/2-conductor_height_r2*2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h*0.65,size_v/2);
    arrowHead[1] = wxPoint(size_h*0.65 - 3,size_v/2 + 5);
    arrowHead[2] = wxPoint(size_h*0.65 + 3,size_v/2 + 5);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h*0.65,size_v/2 - conductor_height_r2/2);
    arrowHead[1] = wxPoint(size_h*0.65 - 3,size_v/2 - conductor_height_r2/2 - 5);
    arrowHead[2] = wxPoint(size_h*0.65 + 3,size_v/2 - conductor_height_r2/2 - 5);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    dc.SetTextForeground(*wxBLUE);
    dc.DrawText("offset x", size_h/2 + 3,size_v/2-conductor_height_r2*2 - 10);
    dc.DrawText("offset y", size_h*0.65,size_v/2 - conductor_height_r2/2 + 15);
    dc.DrawText("h", 45,size_v/2 - conductor_height_r2/2-10);
    dc.DrawText("w", 100,size_v/2 + 20);
    dc.DrawText("s", 180,size_v/2 + 20);




    dc.DrawLine( size_h/2-conductor_width_r2 * 1.5 - conductor_separation_r2,size_v/2 + conductor_height_r2, size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2,size_v/2 + conductor_height_r2 );
    dc.DrawLine( size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2,size_v/2 + conductor_height_r2, size_h/2-conductor_width_r2 * 0.5,size_v/2 + conductor_height_r2 );

    arrowHead[0] = wxPoint(size_h/2-conductor_width_r2 * 1.5 - conductor_separation_r2,size_v/2 + conductor_height_r2);
    arrowHead[1] = wxPoint(size_h/2-conductor_width_r2 * 1.5 - conductor_separation_r2+5,size_v/2 + conductor_height_r2-3);
    arrowHead[2] = wxPoint(size_h/2-conductor_width_r2 * 1.5 - conductor_separation_r2+5,size_v/2 + conductor_height_r2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2,size_v/2 + conductor_height_r2);
    arrowHead[1] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2 -5,size_v/2 + conductor_height_r2-3);
    arrowHead[2] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2 -5,size_v/2 + conductor_height_r2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2,size_v/2 + conductor_height_r2);
    arrowHead[1] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2 +5,size_v/2 + conductor_height_r2-3);
    arrowHead[2] = wxPoint(size_h/2-conductor_width_r2 * 0.5 - conductor_separation_r2 +5,size_v/2 + conductor_height_r2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h/2-conductor_width_r2 * 0.5 ,size_v/2 + conductor_height_r2);
    arrowHead[1] = wxPoint(size_h/2-conductor_width_r2 * 0.5 -5,size_v/2 + conductor_height_r2-3);
    arrowHead[2] = wxPoint(size_h/2-conductor_width_r2 * 0.5 -5,size_v/2 + conductor_height_r2+3);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);



    arrowHead[0] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2,size_v/2);
    arrowHead[1] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2 - 3,size_v/2 - 5);
    arrowHead[2] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2 + 3,size_v/2 - 5);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

    arrowHead[0] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2,size_v/2 - conductor_height_r2);
    arrowHead[1] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2 - 3,size_v/2 - conductor_height_r2 + 5);
    arrowHead[2] = wxPoint(size_h/2-5-conductor_width_r2 * 1.5 - conductor_separation_r2 + 3,size_v/2 - conductor_height_r2 + 5);
    dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);

886c558b   Steve Greedy   SACAMOS Public Re...
678
679
680
681
682
683
684
685
686
687
688
689
}

void FLEXCABLE::OnHighlightSchematic(wxCommandEvent& event)
{
    flexcableSchematic();

    int ID = event.GetId();
    event.Skip(true);

    int size_h, size_v;
    Panel1->GetSize(&size_h, &size_v );

dd86ff43   Steve Greedy   Updates to SW1
690
    float conductor_width_r1, conductor_height_r1, conductor_width_r2, conductor_height_r2,conductor_width_r3, conductor_height_r3,conductor_separation_r1, conductor_separation_r2,totalHeight, totalWidth;
886c558b   Steve Greedy   SACAMOS Public Re...
691

dd86ff43   Steve Greedy   Updates to SW1
692
693
    conductor_width_r1 = 0.175 * size_h;
    conductor_height_r1 = 0.06 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
694

dd86ff43   Steve Greedy   Updates to SW1
695
696
    conductor_width_r2 = 0.175 * size_h;
    conductor_height_r2 = 0.04 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
697

dd86ff43   Steve Greedy   Updates to SW1
698
699
    conductor_width_r3 = 0.9 * size_h;
    conductor_height_r3 = 0.02 * size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
700

dd86ff43   Steve Greedy   Updates to SW1
701
702
    conductor_separation_r1 = 0.05 * size_h;
    conductor_separation_r2 = 0.1 * size_h;
886c558b   Steve Greedy   SACAMOS Public Re...
703

dd86ff43   Steve Greedy   Updates to SW1
704
705
    totalHeight = 0.5 * size_v;
    totalWidth = 0.98 * size_h;
886c558b   Steve Greedy   SACAMOS Public Re...
706

dd86ff43   Steve Greedy   Updates to SW1
707
    wxClientDC dc(Panel1);
886c558b   Steve Greedy   SACAMOS Public Re...
708

dd86ff43   Steve Greedy   Updates to SW1
709
    wxPoint arrowHead[3];
886c558b   Steve Greedy   SACAMOS Public Re...
710

dd86ff43   Steve Greedy   Updates to SW1
711
    if ( ID == ID_TEXTCTRL14)
886c558b   Steve Greedy   SACAMOS Public Re...
712
    {
886c558b   Steve Greedy   SACAMOS Public Re...
713

886c558b   Steve Greedy   SACAMOS Public Re...
714
715
        dc.SetPen(wxPen(wxColor(51,51,255), 3));
        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
886c558b   Steve Greedy   SACAMOS Public Re...
716

dd86ff43   Steve Greedy   Updates to SW1
717
718
719
720
        //row 1
        dc.DrawRectangle(wxPoint(size_h/2- 2 * conductor_width_r1 - 2 * conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
        dc.DrawRectangle(wxPoint(size_h/2- conductor_width_r1 - conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
        dc.DrawRectangle(wxPoint(size_h/2 + conductor_width_r1 + conductor_separation_r1 , size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
886c558b   Steve Greedy   SACAMOS Public Re...
721

dd86ff43   Steve Greedy   Updates to SW1
722
723
724
        //row 2
        dc.DrawRectangle(wxPoint(size_h/2 - 1.5 * conductor_width_r2 - conductor_separation_r2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));
        dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r2/2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));
886c558b   Steve Greedy   SACAMOS Public Re...
725

dd86ff43   Steve Greedy   Updates to SW1
726
727
        // row n
        dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r3/2, size_v/2 + totalHeight/4 ), wxSize(conductor_width_r3,conductor_height_r3));
886c558b   Steve Greedy   SACAMOS Public Re...
728
729
    }

886c558b   Steve Greedy   SACAMOS Public Re...
730

dd86ff43   Steve Greedy   Updates to SW1
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
//    if ( ID == ID_TEXTCTRL2)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawLine( size_h/2 - conductor_width - conductor_separation,size_v/2, size_h/2 - conductor_separation,size_v/2 );
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_width - conductor_separation,size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_width - conductor_separation+5,size_v/2-3);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_width - conductor_separation+5,size_v/2+3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_separation,size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_separation-5,size_v/2-3);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_separation-5,size_v/2+3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//    }
//
//    if ( ID == ID_TEXTCTRL3)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawLine( size_h/2 - conductor_separation,size_v/2-conductor_height/2, size_h/2 - conductor_separation,size_v/2 + conductor_height/2);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_separation,size_v/2-conductor_height/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_separation - 3,size_v/2-conductor_height/2 + 5);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_separation + 3,size_v/2-conductor_height/2 + 5);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_separation,size_v/2 + conductor_height/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_separation - 3,size_v/2 + conductor_height/2 - 5);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_separation + 3,size_v/2 + conductor_height/2 - 5);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//    }
//
//    if ( ID == ID_TEXTCTRL4)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawLine( size_h/2 - conductor_width - 2 * conductor_separation,size_v/2, size_h/2 - conductor_width - conductor_separation,size_v/2);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_width - 2 * conductor_separation,size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_width - 2 * conductor_separation + 5,size_v/2 - 3);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_width - 2 * conductor_separation + 5,size_v/2 + 3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_width - conductor_separation,size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_width - conductor_separation - 5,size_v/2 - 3);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_width - conductor_separation - 5,size_v/2 + 3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//    }
//
//    if ( ID == ID_TEXTCTRL5)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawLine( size_h/2 - totalWidth/2, size_v/2, size_h/2 - 2 * conductor_width - 2 * conductor_separation,size_v/2);
//
//        arrowHead[0] = wxPoint(size_h/2 - totalWidth/2, size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - totalWidth/2 + 5, size_v/2 - 3);
//        arrowHead[2] = wxPoint(size_h/2 - totalWidth/2 + 5, size_v/2 + 3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//        arrowHead[0] = wxPoint(size_h/2 - 2 * conductor_width - 2 * conductor_separation,size_v/2);
//        arrowHead[1] = wxPoint(size_h/2 - 2 * conductor_width - 2 * conductor_separation - 5,size_v/2 - 3);
//        arrowHead[2] = wxPoint(size_h/2 - 2 * conductor_width - 2 * conductor_separation - 5,size_v/2 + 3);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//    }
//
//    if ( ID == ID_TEXTCTRL6)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawLine( size_h/2 - conductor_separation,size_v/2 - conductor_height/2, size_h/2 - conductor_separation,size_v/2 - totalHeight/2);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_separation,size_v/2 - conductor_height/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_separation - 3,size_v/2 - conductor_height/2 - 5);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_separation + 3,size_v/2 - conductor_height/2 - 5);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//
//        arrowHead[0] = wxPoint(size_h/2 - conductor_separation,size_v/2 - totalHeight/2);
//        arrowHead[1] = wxPoint(size_h/2 - conductor_separation - 3,size_v/2 - totalHeight/2 +5);
//        arrowHead[2] = wxPoint(size_h/2 - conductor_separation + 3,size_v/2 - totalHeight/2 + 5);
//        dc.DrawPolygon(WXSIZEOF(arrowHead), arrowHead);
//    }
//    if ( ID == ID_TEXTCTRL14)
//    {
//        dc.SetPen(wxPen(wxColor(51,51,255), 3));
//        dc.SetBrush(wxBrush(wxColor(51,51,255), wxSOLID));
//        dc.DrawRectangle(wxPoint(size_h/2-conductor_width-conductor_separation, size_v/2-conductor_height/2), wxSize(conductor_width,conductor_height));
//        dc.DrawRectangle(wxPoint(size_h/2-(2* conductor_width)-(2*conductor_separation), size_v/2-conductor_height/2), wxSize(conductor_width,conductor_height));
//        dc.DrawRectangle(wxPoint(size_h/2 + conductor_separation, size_v/2-conductor_height/2), wxSize(conductor_width,conductor_height));
//        dc.DrawRectangle(wxPoint(size_h/2 + conductor_width +(2*conductor_separation), size_v/2-conductor_height/2), wxSize(conductor_width,conductor_height));
//
//    }
886c558b   Steve Greedy   SACAMOS Public Re...
826

dd86ff43   Steve Greedy   Updates to SW1
827
    if ( ID == ID_TEXTCTRL12 || ID == ID_CHECKBOX1 || ID == ID_TEXTCTRL2 || ID == ID_TEXTCTRL3)
886c558b   Steve Greedy   SACAMOS Public Re...
828
829
830
831
832
833
834
    {
    dc.SetPen( wxPen( wxColor(51,51,255),1 ) );
    dc.SetBrush(wxBrush(wxColor(51,51,255), wxBDIAGONAL_HATCH));
    dc.DrawRectangle(wxPoint(size_h/2-totalWidth/2, size_v/2-totalHeight/2), wxSize(totalWidth,totalHeight));

    dc.SetPen( wxPen( wxColor(192,192,192),1 ) );
    dc.SetBrush(wxBrush(wxColor(224,224,224), wxSOLID));
dd86ff43   Steve Greedy   Updates to SW1
835
836
837
838
839
840
841
842
843
844
845
846

    //row 1
    dc.DrawRectangle(wxPoint(size_h/2- 2 * conductor_width_r1 - 2 * conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
    dc.DrawRectangle(wxPoint(size_h/2- conductor_width_r1 - conductor_separation_r1, size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));
    dc.DrawRectangle(wxPoint(size_h/2 + conductor_width_r1 + conductor_separation_r1 , size_v/3-conductor_height_r1/2), wxSize(conductor_width_r1,conductor_height_r1));

    //row 2
    dc.DrawRectangle(wxPoint(size_h/2 - 1.5 * conductor_width_r2 - conductor_separation_r2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));
    dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r2/2, size_v/2-conductor_height_r2), wxSize(conductor_width_r2,conductor_height_r2));

    // row n
    dc.DrawRectangle(wxPoint(size_h/2 - conductor_width_r3/2, size_v/2 + totalHeight/4 ), wxSize(conductor_width_r3,conductor_height_r3));
886c558b   Steve Greedy   SACAMOS Public Re...
847
848

    dc.SetPen( wxPen( wxColor(0,0,0),4, wxDOT ) );
dd86ff43   Steve Greedy   Updates to SW1
849
850
851
852
853
    dc.DrawLine( size_h/2 - conductor_separation_r1 , size_v/3, size_h/2 + conductor_width_r1 + conductor_separation_r1, size_v/3);
    dc.DrawLine( size_h/2 - conductor_width_r2/2 , size_v/2 - conductor_height_r2/2 , size_h/2 - conductor_width_r2/2 - conductor_separation_r2, size_v/2 - conductor_height_r2/2);

    //dc.SetPen( wxPen( wxColor(0,0,0),4, wxDOT ) );
    //dc.DrawLine( size_h/2 - conductor_separation, size_v/2, size_h/2 + conductor_separation, size_v/2);
886c558b   Steve Greedy   SACAMOS Public Re...
854
855

    }
dd86ff43   Steve Greedy   Updates to SW1
856
857
858
859
860
861
862
863
864
865

//    if ( ID == ID_GRID1)
//    {
//
//        dc.SetPen( wxPen( wxColor(51,51,255),1 , wxDOT_DASH) );
//        dc.DrawLine( size_h*0.25, size_v/2-conductor_height_r2/2, size_h*0.75,size_v/2-conductor_height_r2/2 );
//        //dc.DrawLine( size_h/2, 0, size_h/2, size_v);
//
//
//    }
886c558b   Steve Greedy   SACAMOS Public Re...
866
867
868
869
870
871
872
873
874
875
876
877
}

void FLEXCABLE::OnNotebook1PageChanging(wxNotebookEvent& event)
{
    flexcableSchematic();
}

void FLEXCABLE::OnPanel1LeftDClick(wxMouseEvent& event)
{
    flexcableSchematic();
}

dd86ff43   Steve Greedy   Updates to SW1
878
879
880
881
void FLEXCABLE::EditExistingCable()
{
    Close();
}
886c558b   Steve Greedy   SACAMOS Public Re...
882

dd86ff43   Steve Greedy   Updates to SW1
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
void FLEXCABLE::OnTextCtrl13TextEnter(wxCommandEvent& event)
{

    int IsError = 0;
    check_is_numeric(TextCtrl13, &IsError);
    check_is_positive(TextCtrl3, &IsError);

    double value_tb13;
    wxString contents_tb13;

    contents_tb13 = TextCtrl13->GetValue();

    contents_tb13.ToDouble(&value_tb13);

    Grid1 -> CreateGrid (value_tb13, 6);

    Grid1->EnableEditing(true);
    Grid1->EnableGridLines(true);

    Grid1 -> SetColLabelValue(0,_("offset x"));
    Grid1 -> SetColLabelValue(1,_("offset y"));
    Grid1 -> SetColLabelValue(2,_("width"));
    Grid1 -> SetColLabelValue(3,_("height"));
    Grid1 -> SetColLabelValue(4,_("separation"));
    Grid1 -> SetColLabelValue(5,_("conductor n"));

    for (int row_num = 0; row_num < value_tb13; row_num++){

        wxString row;
        row << row_num+1;

        Grid1 -> SetRowLabelValue(row_num,_(row));
    }

}

void FLEXCABLE::OnCheckBox3Click(wxCommandEvent& event)
{
    if (CheckBox3->GetValue())
    {
        MESH_PARAM *winMESH_PARAM = new MESH_PARAM(this);

        winMESH_PARAM->TextCtrl1->Disable();
        winMESH_PARAM->TextCtrl3->Disable();
        //winMESH_PARAM->TextCtrl4->Disable();

        if ( winMESH_PARAM->ShowModal() == wxID_OK )
        {
            MESH_PARAM1 = winMESH_PARAM->TextCtrl1->GetValue();
            MESH_PARAM2 = winMESH_PARAM->TextCtrl2->GetValue();
            MESH_PARAM3 = winMESH_PARAM->TextCtrl3->GetValue();
        }
        winMESH_PARAM->Destroy();
    }
    WriteCableFile (TextCtrl1->GetValue());
}