Blame view

GUI/SW1/SRC/SW1_GUIMain.cpp 22 KB
886c558b   Steve Greedy   SACAMOS Public Re...
1
2
3
4
5
6
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
8bb536de   Steve Greedy   Resolved issue re...
7
// Copyright (C) 2015 - 2017 University of Nottingham
886c558b   Steve Greedy   SACAMOS Public Re...
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
//
// 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
//     SW1_GUIMain.cpp
//
// DESCRIPTION
//     Main application GUI for SACAMOS
//
// AUTHOR(S)
//     Steve Greedy
//
/////////////////////////////////////////////////////////////////////////////////


#include "SW1_GUIMain.h"


//(*InternalHeaders(SW1_GUIFrame)
886c558b   Steve Greedy   SACAMOS Public Re...
47
48
#include <wx/settings.h>
#include <wx/intl.h>
886c558b   Steve Greedy   SACAMOS Public Re...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <wx/string.h>
//*)

#define debug 0

//helper functions
enum wxbuildinfoformat
{
    short_f, long_f
};

wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);

    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif

#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }

    return wxbuild;
}

//(*IdInit(SW1_GUIFrame)
const long SW1_GUIFrame::ID_PANEL1 = wxNewId();
const long SW1_GUIFrame::ID_STATICBITMAP1 = wxNewId();
const long SW1_GUIFrame::ID_PANEL2 = wxNewId();
const long SW1_GUIFrame::ID_CREATEMOD = wxNewId();
const long SW1_GUIFrame::ID_SELECTMOD = wxNewId();
const long SW1_GUIFrame::ID_MENUITEM1 = wxNewId();
const long SW1_GUIFrame::ID_CYLINDRICAL = wxNewId();
const long SW1_GUIFrame::ID_COAX = wxNewId();
const long SW1_GUIFrame::ID_TWINAX = wxNewId();
const long SW1_GUIFrame::ID_UTP = wxNewId();
const long SW1_GUIFrame::ID_TP = wxNewId();
const long SW1_GUIFrame::ID_SPACEWIRE = wxNewId();
const long SW1_GUIFrame::ID_FLEX = wxNewId();
const long SW1_GUIFrame::ID_DSUB = wxNewId();
const long SW1_GUIFrame::ID_OVERSHIELD = wxNewId();
const long SW1_GUIFrame::ID_NEWBUNDLE = wxNewId();
const long SW1_GUIFrame::ID_EDITBUNDLE = wxNewId();
const long SW1_GUIFrame::ID_NEWSPICE = wxNewId();
const long SW1_GUIFrame::ID_MENUITEM2 = wxNewId();
const long SW1_GUIFrame::idMenuAbout = wxNewId();
const long SW1_GUIFrame::ID_STATUSBAR1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(SW1_GUIFrame,wxFrame)
    //(*EventTable(SW1_GUIFrame)
    //*)
END_EVENT_TABLE()

SW1_GUIFrame::SW1_GUIFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(SW1_GUIFrame)
    wxStaticBoxSizer* StaticBoxSizer2;
    wxMenuItem* MenuItem2;
    wxMenuItem* MenuItem1;
    wxMenu* Menu1;
    wxMenuBar* MenuBar1;
    wxStaticBoxSizer* StaticBoxSizer1;
    wxFlexGridSizer* FlexGridSizer1;
    wxMenu* Menu2;

    Create(parent, wxID_ANY, _("SACAMOS"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
886c558b   Steve Greedy   SACAMOS Public Re...
124
    FlexGridSizer1 = new wxFlexGridSizer(1, 2, 0, 5);
529d6552   Steve Greedy   SW1_GUI Bug fixes
125
    FlexGridSizer1->AddGrowableCol(0);
886c558b   Steve Greedy   SACAMOS Public Re...
126
127
128
129
130
131
132
    FlexGridSizer1->AddGrowableCol(1);
    FlexGridSizer1->AddGrowableRow(0);
    StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _("MOD Browser"));
    Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(300,300), wxSIMPLE_BORDER|wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    StaticBoxSizer1->Add(Panel1, 1, wxALL|wxEXPAND, 5);
    FlexGridSizer1->Add(StaticBoxSizer1, 0, wxALL|wxEXPAND, 5);
    StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, this, wxEmptyString);
2a0d305e   Steve Greedy   Modifications to ...
133
    Panel2 = new wxPanel(this, ID_PANEL2, wxDefaultPosition, wxSize(600,600), wxSIMPLE_BORDER|wxTAB_TRAVERSAL|wxFULL_REPAINT_ON_RESIZE, _T("ID_PANEL2"));
886c558b   Steve Greedy   SACAMOS Public Re...
134
135
    Panel2->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
    Panel2->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
2a0d305e   Steve Greedy   Modifications to ...
136
    StaticBitmap1 = new wxStaticBitmap(Panel2, ID_STATICBITMAP1, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE, _T("ID_STATICBITMAP1"));
886c558b   Steve Greedy   SACAMOS Public Re...
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
    StaticBoxSizer2->Add(Panel2, 1, wxALL|wxEXPAND, 5);
    FlexGridSizer1->Add(StaticBoxSizer2, 2, wxALL|wxEXPAND, 5);
    SetSizer(FlexGridSizer1);
    MenuBar1 = new wxMenuBar();
    Menu1 = new wxMenu();
    Menu6 = new wxMenuItem(Menu1, ID_CREATEMOD, _("Create MOD"), wxEmptyString, wxITEM_NORMAL);
    Menu1->Append(Menu6);
    MenuItem3 = new wxMenuItem(Menu1, ID_SELECTMOD, _("Select MOD"), _("Browse to MOD root folder"), wxITEM_NORMAL);
    Menu1->Append(MenuItem3);
    Menu1->AppendSeparator();
    MenuItem1 = new wxMenuItem(Menu1, ID_MENUITEM1, _("&Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
    Menu1->Append(MenuItem1);
    MenuBar1->Append(Menu1, _("&File"));
    Menu3 = new wxMenu();
    MenuItem5 = new wxMenuItem(Menu3, ID_CYLINDRICAL, _("Cylindrical Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem5);
    MenuItem4 = new wxMenuItem(Menu3, ID_COAX, _("Coaxial Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem4);
    MenuItem6 = new wxMenuItem(Menu3, ID_TWINAX, _("Twinax Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem6);
    MenuItem7 = new wxMenuItem(Menu3, ID_UTP, _("Twisted Pair Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem7);
    MenuItem8 = new wxMenuItem(Menu3, ID_TP, _("Shielded Twisted Pair Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem8);
    MenuItem9 = new wxMenuItem(Menu3, ID_SPACEWIRE, _("Spacewire"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem9);
    MenuItem11 = new wxMenuItem(Menu3, ID_FLEX, _("Flex Cable"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem11);
    MenuItem14 = new wxMenuItem(Menu3, ID_DSUB, _("D Sub Connector"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem14);
    MenuItem10 = new wxMenuItem(Menu3, ID_OVERSHIELD, _("Overshield"), wxEmptyString, wxITEM_NORMAL);
    Menu3->Append(MenuItem10);
    MenuBar1->Append(Menu3, _("Cable Model"));
    Menu4 = new wxMenu();
    MenuItem12 = new wxMenuItem(Menu4, ID_NEWBUNDLE, _("Create Bundle"), wxEmptyString, wxITEM_NORMAL);
    Menu4->Append(MenuItem12);
    MenuItem13 = new wxMenuItem(Menu4, ID_EDITBUNDLE, _("Edit Bundle"), wxEmptyString, wxITEM_NORMAL);
    Menu4->Append(MenuItem13);
    MenuItem13->Enable(false);
    MenuBar1->Append(Menu4, _("Bundle Model"));
    Menu5 = new wxMenu();
d475f4d6   Steve Greedy   SW1 Update to v1.0.1
178
    MenuItem16 = new wxMenuItem(Menu5, ID_NEWSPICE, _("Create Spice Bundle Model"), wxEmptyString, wxITEM_NORMAL);
886c558b   Steve Greedy   SACAMOS Public Re...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    Menu5->Append(MenuItem16);
    Menu5->AppendSeparator();
    Menu7 = new wxMenuItem(Menu5, ID_MENUITEM2, _("Export Spice Models"), wxEmptyString, wxITEM_NORMAL);
    Menu5->Append(Menu7);
    MenuBar1->Append(Menu5, _("Spice Model"));
    Menu2 = new wxMenu();
    MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
    Menu2->Append(MenuItem2);
    MenuBar1->Append(Menu2, _("Help"));
    SetMenuBar(MenuBar1);
    StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, wxST_SIZEGRIP, _T("ID_STATUSBAR1"));
    int __wxStatusBarWidths_1[1] = { -1 };
    int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
    StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
    StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
    SetStatusBar(StatusBar1);
    DirDialog1 = new wxDirDialog(this, _("Select the MOD Directory"), wxEmptyString, wxDD_DEFAULT_STYLE|wxSIMPLE_BORDER, wxDefaultPosition, wxDefaultSize, _T("wxDirDialog"));
    FlexGridSizer1->Fit(this);
    FlexGridSizer1->SetSizeHints(this);

    Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&SW1_GUIFrame::OnPanel1Paint,0,this);
    Panel2->Connect(wxEVT_PAINT,(wxObjectEventFunction)&SW1_GUIFrame::OnPanel2Paint,0,this);
2a0d305e   Steve Greedy   Modifications to ...
201
202
    Connect(ID_CREATEMOD,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnCreateMOD);
    Connect(ID_SELECTMOD,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnSelectMOD);
886c558b   Steve Greedy   SACAMOS Public Re...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnQuit);
    Connect(ID_CYLINDRICAL,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnCYLINDRICAL);
    Connect(ID_COAX,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnCOAXIAL);
    Connect(ID_TWINAX,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnTWINAX);
    Connect(ID_UTP,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnUTP);
    Connect(ID_TP,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnTP);
    Connect(ID_SPACEWIRE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnSPACEWIRE);
    Connect(ID_FLEX,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnFLEXCABLE);
    Connect(ID_DSUB,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnDSUB);
    Connect(ID_OVERSHIELD,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnOVERSHIELD);
    Connect(ID_NEWBUNDLE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnNEWBUNDLE);
    Connect(ID_NEWSPICE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnCREATESPICE);
    Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnEXPORTSPICE);
    Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SW1_GUIFrame::OnAbout);
    //*)

8bb536de   Steve Greedy   Resolved issue re...
219

2a0d305e   Steve Greedy   Modifications to ...
220
221
222
223
224
225
226
227
    // Set frame icon here
    wxIcon FrameIcon;
    FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("resources/spacewire_schematic_64x64.ico"))));
    SetIcon(FrameIcon);

    // Set main image
    StaticBitmap1->SetBitmap(wxBitmap(wxImage(_T("resources/Sacamos_Logo_v2.png"))));

886c558b   Steve Greedy   SACAMOS Public Re...
228
229
230
231
232
    // Disable Top Menu Items Until MOD location is chosen
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Cable Model")),false);
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Bundle Model")),false);
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Spice Model")),false);

2a0d305e   Steve Greedy   Modifications to ...
233
234
    // Set status bar message text
    StatusBar1 -> SetStatusText(wxT("Please Select MOD Directory"));
886c558b   Steve Greedy   SACAMOS Public Re...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
}

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

void SW1_GUIFrame::OnQuit(wxCommandEvent& event)
{
    //clean up temporary files
    clean_temp_files();
    Close();
}

void SW1_GUIFrame::OnAbout(wxCommandEvent& event)
{
    ABOUT *about = new ABOUT(this);
    about->ShowModal();
}

2a0d305e   Steve Greedy   Modifications to ...
256
void SW1_GUIFrame::OnSelectMOD(wxCommandEvent& event)
886c558b   Steve Greedy   SACAMOS Public Re...
257
258
259
260
261
262
263
264
265
266
{
    // Create a new wxDirDialog dialog
    wxDirDialog* dirDialog = new wxDirDialog(this);

    // Display the dialog and transfer the contents to
    // the wxTextCtrl on the main frame if the user
    // doesn't cancel
    if (dirDialog->ShowModal() == wxID_OK)
    {
        wxString selectedFile = dirDialog->GetPath();
2a0d305e   Steve Greedy   Modifications to ...
267
268

        SelectedFile = dirDialog->GetPath();
2f8cca9d   Steve Greedy   Fix MOD display i...
269
        PathToMOD    = dirDialog->GetPath();
886c558b   Steve Greedy   SACAMOS Public Re...
270
271

        // Show the selected folder in the status bar
2a0d305e   Steve Greedy   Modifications to ...
272
        SetStatusText(SelectedFile, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
273

2a0d305e   Steve Greedy   Modifications to ...
274
        PopulateTheDirectoryTree (SelectedFile);
886c558b   Steve Greedy   SACAMOS Public Re...
275
    }
886c558b   Steve Greedy   SACAMOS Public Re...
276
277
    dirDialog->Destroy();

1bcf33cb   Steve Greedy   Modifications to ...
278
279
280
    wxString separator(wxFileName::GetPathSeparator());

    wxStringTokenizer tkz(PathToMOD, separator);
886c558b   Steve Greedy   SACAMOS Public Re...
281
282
283
284
285

    while (tkz.HasMoreTokens())
    {
        MODname = tkz.GetNextToken();
    }
886c558b   Steve Greedy   SACAMOS Public Re...
286
287
}

2a0d305e   Steve Greedy   Modifications to ...
288
void SW1_GUIFrame::OnCreateMOD(wxCommandEvent& event)
886c558b   Steve Greedy   SACAMOS Public Re...
289
290
291
292
{
    // Create a new wxDirDialog dialog
    wxDirDialog* dirDialog = new wxDirDialog(this);

529d6552   Steve Greedy   SW1_GUI Bug fixes
293
294
    wxString separator(wxFileName::GetPathSeparator());

886c558b   Steve Greedy   SACAMOS Public Re...
295
296
297
298
299
300
    // Display the dialog and transfer the contents to
    // the wxTextCtrl on the main frame if the user
    // doesn't cancel
    if (dirDialog->ShowModal() == wxID_OK)
    {
        wxString selectedFile = dirDialog->GetPath();
529d6552   Steve Greedy   SW1_GUI Bug fixes
301
        PathToMOD = dirDialog->GetPath();
886c558b   Steve Greedy   SACAMOS Public Re...
302

529d6552   Steve Greedy   SW1_GUI Bug fixes
303
        wxStringTokenizer tkz(PathToMOD, separator);
886c558b   Steve Greedy   SACAMOS Public Re...
304
305
306
307
308

        while (tkz.HasMoreTokens())
        {
            MODname = tkz.GetNextToken();
        }
886c558b   Steve Greedy   SACAMOS Public Re...
309
310
        wxString folder, dirName;

529d6552   Steve Greedy   SW1_GUI Bug fixes
311
        folder = PathToMOD + separator + "CABLE";
886c558b   Steve Greedy   SACAMOS Public Re...
312
313
        dirName = folder;
        if (!wxDirExists(dirName))
2a0d305e   Steve Greedy   Modifications to ...
314
            wxMkdir(dirName, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
315

529d6552   Steve Greedy   SW1_GUI Bug fixes
316
        folder = PathToMOD + separator +"BUNDLE";
886c558b   Steve Greedy   SACAMOS Public Re...
317
318
        dirName = folder;
        if (!wxDirExists(dirName))
2a0d305e   Steve Greedy   Modifications to ...
319
            wxMkdir(dirName, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
320

529d6552   Steve Greedy   SW1_GUI Bug fixes
321
        folder = PathToMOD + separator +"SPICE";
886c558b   Steve Greedy   SACAMOS Public Re...
322
323
        dirName = folder;
        if (!wxDirExists(dirName))
2a0d305e   Steve Greedy   Modifications to ...
324
            wxMkdir(dirName, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
325

529d6552   Steve Greedy   SW1_GUI Bug fixes
326
        folder = PathToMOD + separator +"SPICE" + separator + "SYMBOL";
886c558b   Steve Greedy   SACAMOS Public Re...
327
328
        dirName = folder;
        if (!wxDirExists(dirName))
2a0d305e   Steve Greedy   Modifications to ...
329
            wxMkdir(dirName, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
330
331
332
333
334

        wxMenuBar* MenuBar1 = GetMenuBar();
        MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Cable Model")),true);
        MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Bundle Model")),true);
        MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Spice Model")),true);
886c558b   Steve Greedy   SACAMOS Public Re...
335
336
    }
    dirDialog->Destroy();
529d6552   Steve Greedy   SW1_GUI Bug fixes
337
338

    PopulateTheDirectoryTree (PathToMOD);
886c558b   Steve Greedy   SACAMOS Public Re...
339
340
341
342
343
}

void SW1_GUIFrame::PopulateTheDirectoryTree ( wxString RootFolder)
{
    int size_h, size_v;
886c558b   Steve Greedy   SACAMOS Public Re...
344
345

    if (tree != NULL)
8bb536de   Steve Greedy   Resolved issue re...
346
347
348
349
350
351
352
    {
        Disconnect(tree->GetTreeCtrl()->GetId(),wxEVT_COMMAND_TREE_SEL_CHANGED , (wxObjectEventFunction) (wxEventFunction)(wxCommandEventFunction) &SW1_GUIFrame::OnTreeSelection);
        Disconnect(tree->GetTreeCtrl()->GetId(),wxEVT_COMMAND_TREE_ITEM_ACTIVATED, (wxObjectEventFunction) (wxEventFunction)(wxCommandEventFunction) &SW1_GUIFrame::OnTreeSelectionChanged);
        tree -> Close();
        tree -> Destroy();
    }

886c558b   Steve Greedy   SACAMOS Public Re...
353
354
355

    tree = (wxSpecificDirCtrl *) NULL;

8bb536de   Steve Greedy   Resolved issue re...
356
357
    Panel1->GetSize(&size_h, &size_v );

886c558b   Steve Greedy   SACAMOS Public Re...
358
359
    tree = new wxSpecificDirCtrl (Panel1, -1, RootFolder,
                                 wxDefaultPosition,
8bb536de   Steve Greedy   Resolved issue re...
360
                                 wxSize(-1,-1),
2a0d305e   Steve Greedy   Modifications to ...
361
362
                                 wxSIMPLE_BORDER,
                                 "*.cable_spec;*.bundle_spec;*.spice_model_spec", 0,
886c558b   Steve Greedy   SACAMOS Public Re...
363
364
                                 _T("Directory Listing"));

2a0d305e   Steve Greedy   Modifications to ...
365
366
    //Connect tree item activated e.g. single click and tree item selected e.g. double click events
    Connect(tree->GetTreeCtrl()->GetId(),wxEVT_COMMAND_TREE_SEL_CHANGED , (wxObjectEventFunction) (wxEventFunction)(wxCommandEventFunction) &SW1_GUIFrame::OnTreeSelection);
886c558b   Steve Greedy   SACAMOS Public Re...
367
    Connect(tree->GetTreeCtrl()->GetId(),wxEVT_COMMAND_TREE_ITEM_ACTIVATED, (wxObjectEventFunction) (wxEventFunction)(wxCommandEventFunction) &SW1_GUIFrame::OnTreeSelectionChanged);
886c558b   Steve Greedy   SACAMOS Public Re...
368

2a0d305e   Steve Greedy   Modifications to ...
369
    //Activate Menu Items Once MOD Selected
886c558b   Steve Greedy   SACAMOS Public Re...
370
371
372
373
    wxMenuBar* MenuBar1 = GetMenuBar();
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Cable Model")),true);
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Bundle Model")),true);
    MenuBar1->EnableTop(MenuBar1->FindMenu(_("&Spice Model")),true);
886c558b   Steve Greedy   SACAMOS Public Re...
374
375
}

2a0d305e   Steve Greedy   Modifications to ...
376
void SW1_GUIFrame::OnTreeSelection(wxTreeEvent& evt)
886c558b   Steve Greedy   SACAMOS Public Re...
377
378
379
{
    wxFileName fname (tree->GetFilePath());
    wxString File_Path         = fname.GetPath();
2a0d305e   Steve Greedy   Modifications to ...
380
    wxString File_FullName     = fname.GetFullName();
886c558b   Steve Greedy   SACAMOS Public Re...
381
382
383
384
    wxString File_FullNamePath = fname.GetFullPath();

    StaticBitmap1->Hide();

2a0d305e   Steve Greedy   Modifications to ...
385
    SetStatusText(File_FullName, 0);
886c558b   Steve Greedy   SACAMOS Public Re...
386

2a0d305e   Steve Greedy   Modifications to ...
387
388
    if(File_FullName.substr(File_FullName.find_last_of(".") + 1) == "cable_spec")
    {
886c558b   Steve Greedy   SACAMOS Public Re...
389
390
391
392
         draw_cable(Panel2,File_FullNamePath, 0, 0);
    }

    else
886c558b   Steve Greedy   SACAMOS Public Re...
393

2a0d305e   Steve Greedy   Modifications to ...
394
395
    if(File_FullName.substr(File_FullName.find_last_of(".") + 1) == "bundle_spec")
    {
886c558b   Steve Greedy   SACAMOS Public Re...
396
397
398
399
         draw_bundle(Panel2, PathToMOD, File_FullNamePath);
    }
}

2a0d305e   Steve Greedy   Modifications to ...
400
401

void SW1_GUIFrame::OnTreeSelectionChanged(wxTreeEvent& evt)
886c558b   Steve Greedy   SACAMOS Public Re...
402
{
2a0d305e   Steve Greedy   Modifications to ...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
    wxFileName fname (tree->GetFilePath());
    wxString File_Path         = fname.GetPath();
    wxString File_FullName     = fname.GetFullName();
    wxString File_FullNamePath = fname.GetFullPath();

    SetStatusText(File_FullName, 0);

    StaticBitmap1->Hide();

    if(File_FullName.substr(File_FullName.find_last_of(".") + 1) == "cable_spec")
    {
        std::ifstream cableFile;
        cableFile.open (File_FullNamePath);

        std::string str;
886c558b   Steve Greedy   SACAMOS Public Re...
418

2a0d305e   Steve Greedy   Modifications to ...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
        std::getline(cableFile, str);
        std::getline(cableFile, str);
        std::getline(cableFile, str);

        if (str == "Cylindrical")
        {
            Edit = true;
            CreateCable ("Cylindrical", File_FullName, Edit);
        }

        if (str == "Coax")
        {
            Edit = true;
            CreateCable ("Coaxial", File_FullName, Edit);
        }

        if (str == "Twinax")
        {
            Edit = true;
            CreateCable ("Twinax", File_FullName, Edit);
        }

        if (str == "Twisted_pair")
        {
            Edit = true;
            CreateCable ("UTP", File_FullName, Edit);
        }

        if (str == "Shielded_twisted_pair")
        {
            Edit = true;
            CreateCable ("TP", File_FullName, Edit);
        }

        if (str == "Spacewire")
        {
            Edit = true;
            CreateCable ("Spacewire", File_FullName, Edit);
        }

        if (str == "Overshield")
        {
            Edit = true;
            CreateCable ("Overshield", File_FullName, Edit);
        }

        if (str == "Dconnector")
        {
            Edit = true;
            CreateCable ("Dsub", File_FullName, Edit);
        }

        if (str == "Flex_cable")
        {
            Edit = true;
            CreateCable ("Flexcable", File_FullName, Edit);
        }
    }
}

void SW1_GUIFrame::CreateCable(wxString CableType, wxString CableFile, bool Edit)
{
    int cable;

    if (CableType == "Cylindrical") cable = 1;
    if (CableType == "Coaxial")     cable = 2;
    if (CableType == "Twinax")      cable = 3;
    if (CableType == "UTP")         cable = 4;
    if (CableType == "TP")          cable = 5;
    if (CableType == "Spacewire")   cable = 6;
    if (CableType == "Overshield")  cable = 7;
    if (CableType == "Flexcable")   cable = 8;
    if (CableType == "Dsub")        cable = 9;

    switch (cable)
    {
        case 1:
            {
            CYLINDRICAL *cylindrical = new CYLINDRICAL(this);
            cylindrical->SetPathToMOD(PathToMOD, MODname);
            cylindrical->EDIT_EXISTING = Edit;
            cylindrical->ShowModal();
            break;
            }

        case 2:
            {
            COAXIAL *coaxial = new COAXIAL(this);
            coaxial->SetPathToMOD(PathToMOD, MODname);
            coaxial->EDIT_EXISTING = Edit;
            coaxial->ShowModal();
            break;
            }

        case 3:
            {
            TWINAX *twinax = new TWINAX(this);
            twinax->SetPathToMOD(PathToMOD, MODname);
            twinax->EDIT_EXISTING = Edit;
            twinax->ShowModal();
            break;
            }

        case 4:
            {
            UTP *utp = new UTP(this);
            utp->SetPathToMOD(PathToMOD, MODname);
            utp->EDIT_EXISTING = Edit;
            utp->ShowModal();
            break;
            }

        case 5:
            {
            TP *tp = new TP(this);
            tp->SetPathToMOD(PathToMOD, MODname);
            tp->EDIT_EXISTING = Edit;
            tp->ShowModal();
            break;
            }

        case 6:
            {
            SPACEWIRE *spacewire = new SPACEWIRE(this);
            spacewire->SetPathToMOD(PathToMOD, MODname);
            spacewire->EDIT_EXISTING = Edit;
            spacewire->ShowModal();
            break;
            }

        case 7:
            {
            OVERSHIELD *overshield = new OVERSHIELD(this);
            overshield->SetPathToMOD(PathToMOD, MODname);
            overshield->EDIT_EXISTING = Edit;
            overshield->ShowModal();
            break;
            }

        case 8:
            {
            FLEXCABLE *flexcable = new FLEXCABLE(this);
            flexcable->SetPathToMOD(PathToMOD, MODname);
            flexcable->EDIT_EXISTING = Edit;
            flexcable->ShowModal();
            break;
            }


        case 9:
            {
            DCONN *dsub = new DCONN(this);
            dsub->SetPathToMOD(PathToMOD, MODname);
            dsub->EDIT_EXISTING = Edit;
            dsub->ShowModal();
            break;
            }
    }
}

void SW1_GUIFrame::OnCYLINDRICAL(wxCommandEvent& event)
{
    Edit = false;
    CreateCable ("Cylindrical", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
583
584
585
586
}

void SW1_GUIFrame::OnCOAXIAL(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
587
588
    Edit = false;
    CreateCable ("Coaxial", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
589
590
591
592
}

void SW1_GUIFrame::OnTWINAX(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
593
594
    Edit = false;
    CreateCable ("Twinax", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
595
596
597
598
}

void SW1_GUIFrame::OnUTP(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
599
600
    Edit = false;
    CreateCable ("UTP", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
601
602
603
604
}

void SW1_GUIFrame::OnTP(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
605
606
    Edit = false;
    CreateCable ("TP", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
607
608
609
610
}

void SW1_GUIFrame::OnSPACEWIRE(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
611
612
    Edit = false;
    CreateCable ("Spacewire", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
613
614
615
616
}

void SW1_GUIFrame::OnOVERSHIELD(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
617
618
    Edit = false;
    CreateCable ("Overshield", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
619
620
621
622
}

void SW1_GUIFrame::OnFLEXCABLE(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
623
624
    Edit = false;
    CreateCable ("Flexcable", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
625
626
627
628
}

void SW1_GUIFrame::OnDSUB(wxCommandEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
629
630
    Edit = false;
    CreateCable ("Dsub", "", Edit);
886c558b   Steve Greedy   SACAMOS Public Re...
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
}

void SW1_GUIFrame::OnNEWBUNDLE(wxCommandEvent& event)
{
    BUNDLEBLDR *bundle = new BUNDLEBLDR(this);
    bundle->SetPathForDir(PathToMOD, MODname);
    bundle->ShowModal();
}

void SW1_GUIFrame::OnCREATESPICE(wxCommandEvent& event)
{
    SPICEMODEL *spice = new SPICEMODEL(this);
    spice->SetPathForDir(PathToMOD, MODname);
    spice->ShowModal();
}

void SW1_GUIFrame::OnEXPORTSPICE(wxCommandEvent& event)
{
    EXPORT_SPICE *exportspice = new EXPORT_SPICE(this);
    exportspice->SetPathToMOD(PathToMOD, MODname);
    exportspice->ShowModal();
}

void SW1_GUIFrame::OnPanel1Paint(wxPaintEvent& event)
{
2a0d305e   Steve Greedy   Modifications to ...
656
657
658
659
660
    if (tree != NULL){
        int size_h, size_v;
        Panel1->GetSize(&size_h, &size_v );
        tree->SetSize(size_h,size_v);
    }
886c558b   Steve Greedy   SACAMOS Public Re...
661
}
2a0d305e   Steve Greedy   Modifications to ...
662

886c558b   Steve Greedy   SACAMOS Public Re...
663
664
665
666
void SW1_GUIFrame::OnPanel2Paint(wxPaintEvent& event)
{

}