/////////////////////////////////////////////////////////////////////////////////
//
// 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 .
//
// 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:
//
//
// The University of Nottingham can be contacted at: ggiemr@nottingham.ac.uk
//
// File Contents:
//
// NAME
// BUNDLEBLDR.cpp
//
// DESCRIPTION
// Cable bundle builder application
//
// AUTHOR(S)
// Steve Greedy
//
/////////////////////////////////////////////////////////////////////////////////
#include "BUNDLEBLDR.h"
#include "PLACE_CABLE.h"
#include "MESH_LAPLACE.h"
//#define debug 1
#include
#include
#include
#include
#include
#include
#include
using namespace std;
//(*InternalHeaders(BUNDLEBLDR)
#include
#include
#include
//*)
//(*IdInit(BUNDLEBLDR)
const long BUNDLEBLDR::ID_STATICTEXT1 = wxNewId();
const long BUNDLEBLDR::ID_TEXTCTRL1 = wxNewId();
const long BUNDLEBLDR::ID_PANEL2 = wxNewId();
const long BUNDLEBLDR::ID_LISTBOX1 = wxNewId();
const long BUNDLEBLDR::ID_PANEL3 = wxNewId();
const long BUNDLEBLDR::ID_CHECKBOX1 = wxNewId();
const long BUNDLEBLDR::ID_STATICTEXT2 = wxNewId();
const long BUNDLEBLDR::ID_PANEL4 = wxNewId();
const long BUNDLEBLDR::ID_CHECKBOX2 = wxNewId();
const long BUNDLEBLDR::ID_COMBOBOX1 = wxNewId();
const long BUNDLEBLDR::ID_CHECKBOX3 = wxNewId();
const long BUNDLEBLDR::ID_STATICTEXT6 = wxNewId();
const long BUNDLEBLDR::ID_STATICTEXT7 = wxNewId();
const long BUNDLEBLDR::ID_TEXTCTRL4 = wxNewId();
const long BUNDLEBLDR::ID_STATICTEXT8 = wxNewId();
const long BUNDLEBLDR::ID_TEXTCTRL5 = wxNewId();
const long BUNDLEBLDR::ID_PANEL5 = wxNewId();
const long BUNDLEBLDR::ID_NOTEBOOK1 = wxNewId();
const long BUNDLEBLDR::ID_BUTTON1 = wxNewId();
const long BUNDLEBLDR::ID_BUTTON2 = wxNewId();
const long BUNDLEBLDR::ID_BUTTON3 = wxNewId();
const long BUNDLEBLDR::ID_PANEL1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(BUNDLEBLDR,wxDialog)
//(*EventTable(BUNDLEBLDR)
//*)
END_EVENT_TABLE()
BUNDLEBLDR::BUNDLEBLDR(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(BUNDLEBLDR)
wxStaticBoxSizer* StaticBoxSizer2;
wxBoxSizer* BoxSizer6;
wxFlexGridSizer* FlexGridSizer4;
wxBoxSizer* BoxSizer5;
wxStaticBoxSizer* StaticBoxSizer4;
wxFlexGridSizer* FlexGridSizer3;
wxFlexGridSizer* FlexGridSizer5;
wxBoxSizer* BoxSizer2;
wxStaticBoxSizer* StaticBoxSizer3;
wxBoxSizer* BoxSizer1;
wxStaticBoxSizer* StaticBoxSizer1;
wxFlexGridSizer* FlexGridSizer1;
wxBoxSizer* BoxSizer3;
Create(parent, wxID_ANY, _("SACAMOS: CABLE BUNDLE BUILDER"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, _T("wxID_ANY"));
FlexGridSizer1 = new wxFlexGridSizer(1, 2, 0, 0);
FlexGridSizer1->AddGrowableCol(1);
FlexGridSizer1->AddGrowableRow(0);
StaticBoxSizer4 = new wxStaticBoxSizer(wxVERTICAL, this, _("Bundle Specification"));
FlexGridSizer3 = new wxFlexGridSizer(0, 1, 0, 0);
BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Bundle Name"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
BoxSizer2->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"));
BoxSizer2->Add(TextCtrl1, 2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer3->Add(BoxSizer2, 1, wxALL|wxEXPAND, 5);
BoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
Notebook1 = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxSize(-1,380), 0, _T("ID_NOTEBOOK1"));
Panel3 = new wxPanel(Notebook1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
BoxSizer6 = new wxBoxSizer(wxVERTICAL);
StaticBoxSizer2 = new wxStaticBoxSizer(wxVERTICAL, Panel3, _("Cable Component Browser"));
Panel2 = new wxPanel(Panel3, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER|wxTAB_TRAVERSAL, _T("ID_PANEL2"));
Panel2->SetMinSize(wxSize(300,0));
StaticBoxSizer2->Add(Panel2, 1, wxALL|wxEXPAND, 5);
BoxSizer6->Add(StaticBoxSizer2, 2, wxALL|wxEXPAND, 5);
StaticBoxSizer3 = new wxStaticBoxSizer(wxVERTICAL, Panel3, _("Bundle Component Cables"));
BoxSizer3 = new wxBoxSizer(wxVERTICAL);
ListBox1 = new wxListBox(Panel3, ID_LISTBOX1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
BoxSizer3->Add(ListBox1, 1, wxALL|wxEXPAND, 5);
StaticBoxSizer3->Add(BoxSizer3, 1, wxALL|wxEXPAND, 5);
BoxSizer6->Add(StaticBoxSizer3, 2, wxALL|wxEXPAND, 5);
Panel3->SetSizer(BoxSizer6);
BoxSizer6->Fit(Panel3);
BoxSizer6->SetSizeHints(Panel3);
Panel4 = new wxPanel(Notebook1, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
FlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer4->AddGrowableCol(1);
CheckBox1 = new wxCheckBox(Panel4, ID_CHECKBOX1, _("Use Ground Plane"), wxDefaultPosition, wxSize(154,13), 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
CheckBox1->SetValue(false);
FlexGridSizer4->Add(CheckBox1, 1, wxALL|wxALIGN_LEFT, 5);
StaticText2 = new wxStaticText(Panel4, ID_STATICTEXT2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer4->Add(StaticText2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel4->SetSizer(FlexGridSizer4);
FlexGridSizer4->Fit(Panel4);
FlexGridSizer4->SetSizeHints(Panel4);
Panel5 = new wxPanel(Notebook1, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL5"));
FlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
CheckBox2 = new wxCheckBox(Panel5, ID_CHECKBOX2, _("Use Laplace"), wxDefaultPosition, wxSize(95,24), 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
CheckBox2->SetValue(false);
FlexGridSizer5->Add(CheckBox2, 1, wxALL, 5);
ComboBox1 = new wxComboBox(Panel5, ID_COMBOBOX1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX1"));
FlexGridSizer5->Add(ComboBox1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
CheckBox3 = new wxCheckBox(Panel5, ID_CHECKBOX3, _("Refine Laplace Mesh"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX3"));
CheckBox3->SetValue(false);
CheckBox3->Disable();
FlexGridSizer5->Add(CheckBox3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
StaticText6 = new wxStaticText(Panel5, ID_STATICTEXT6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
FlexGridSizer5->Add(StaticText6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText7 = new wxStaticText(Panel5, ID_STATICTEXT7, _("Surface Mesh Constant"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
FlexGridSizer5->Add(StaticText7, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl4 = new wxTextCtrl(Panel5, ID_TEXTCTRL4, _("3"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL4"));
FlexGridSizer5->Add(TextCtrl4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticText8 = new wxStaticText(Panel5, ID_STATICTEXT8, _("Boundary Constant"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
FlexGridSizer5->Add(StaticText8, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl5 = new wxTextCtrl(Panel5, ID_TEXTCTRL5, _("3"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL5"));
FlexGridSizer5->Add(TextCtrl5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Panel5->SetSizer(FlexGridSizer5);
FlexGridSizer5->Fit(Panel5);
FlexGridSizer5->SetSizeHints(Panel5);
Notebook1->AddPage(Panel3, _("Bundle"), false);
Notebook1->AddPage(Panel4, _("Ground Plane"), false);
Notebook1->AddPage(Panel5, _("Laplace Solver"), false);
BoxSizer5->Add(Notebook1, 1, wxALL|wxEXPAND, 5);
FlexGridSizer3->Add(BoxSizer5, 1, wxALL|wxEXPAND, 5);
StaticBoxSizer4->Add(FlexGridSizer3, 8, wxALL|wxEXPAND, 5);
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
Button1 = new wxButton(this, ID_BUTTON1, _("SAVE"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
BoxSizer1->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"));
BoxSizer1->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"));
BoxSizer1->Add(Button3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticBoxSizer4->Add(BoxSizer1, 1, wxALL, 5);
FlexGridSizer1->Add(StaticBoxSizer4, 3, wxALL|wxEXPAND, 5);
StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("2D Cross Section"));
Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxSize(500,500), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
Panel1->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
StaticBoxSizer1->Add(Panel1, 1, wxALL|wxEXPAND, 5);
FlexGridSizer1->Add(StaticBoxSizer1, 1, wxALL, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);
Panel2->Connect(wxEVT_PAINT,(wxObjectEventFunction)&BUNDLEBLDR::OnPanel2Paint,0,this);
Connect(ID_CHECKBOX1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&BUNDLEBLDR::OnCheckBox1Click);
Connect(ID_COMBOBOX1,wxEVT_COMMAND_COMBOBOX_SELECTED,(wxObjectEventFunction)&BUNDLEBLDR::OnComboBox1Selected);
Connect(ID_CHECKBOX3,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&BUNDLEBLDR::OnCheckBox3Click);
Connect(ID_TEXTCTRL4,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&BUNDLEBLDR::OnTextCtrl4Text);
Connect(ID_TEXTCTRL5,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&BUNDLEBLDR::OnTextCtrl5Text);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BUNDLEBLDR::OnButton1Click);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BUNDLEBLDR::OnButton2Click);
Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&BUNDLEBLDR::OnButton3Click);
Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&BUNDLEBLDR::OnPanel1Paint,0,this);
Connect(wxID_ANY,wxEVT_INIT_DIALOG,(wxObjectEventFunction)&BUNDLEBLDR::OnInit);
//*)
ListBox1->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(BUNDLEBLDR::OnListboxRDown), NULL, this);
// Initialise the head node
bundle_root = new Bundle;
bundle_root->next = NULL;
// Ths is the list
bundle_list = bundle_root;
// Load and populate file tree
//PopulateTheDirectoryTree(PathToMOD);
}
void BUNDLEBLDR::OnListboxRDown(wxMouseEvent& event)
{
int item = ListBox1->HitTest(event.GetPosition());
if ( item != wxNOT_FOUND )
{
wxString strMessage;
wxString strItem = ListBox1->GetString(item);
strMessage = "Are you sure you wish to delete: ";
strMessage = strMessage << strItem;
// We have an item in the list to delete - shall we confirm?
wxMessageDialog bb_ConfirmDelete (this, strMessage, _("Please confirm delete") ,wxYES_NO|wxCENTRE,wxDefaultPosition );
bb_ConfirmDelete.ShowModal();
//int RetVal = bb_ConfirmDelete.GetReturnCode();
//if ( RetVal == wxID_YES )
//{
// Delete the item 'item' from the linked list
removeElement(item);
PopulateListControl();
// And repopulate the listbox (clear it first!)
//}
}
else
wxMessageBox(_T("Listbox right clicked but no item clicked upon"),_("No item selected"));
event.Skip();
}
void BUNDLEBLDR::PopulateListControl(void)
{
ListBox1->Clear();
Bundle *Current = bundle_root;
while ( Current->next != NULL )
{
ListBox1->Append(Current->CableType);
Current = Current->next;
}
}
void BUNDLEBLDR::removeElement(int ItemIndex)
{
Bundle *Current = bundle_root;
Bundle *Previous = Current;
//Bundle *Next = bundle_root->next;
// Otherwise we look through the list for the item
int i = 0;
while( (Current!= NULL) && (i < ItemIndex) )
{
Previous = Current;
Current = Current->next;
i++;
}
if ( Current == bundle_root) // Deleting the 1st item in the list
{
bundle_root = bundle_root->next;
}
else
{
Previous->next= Current->next;
}
delete Current;
}
BUNDLEBLDR::~BUNDLEBLDR()
{
//(*Destroy(BUNDLEBLDR)
//*)
}
void BUNDLEBLDR::PopulateTheDirectoryTree (wxString Path)
{
#ifdef debug
wxMessageBox(Path, _("PathToMod"));
#endif
int size_h, size_v;
Panel2->GetSize(&size_h, &size_v );
//wxGenericDirCtrl *tree;
tree = (wxSpecificDirCtrl *) NULL;
tree = new wxSpecificDirCtrl (Panel2, -1, Path,
wxDefaultPosition,
wxSize(size_h, size_v),
wxSIMPLE_BORDER,//wxDIRCTRL_3D_INTERNAL|wxSUNKEN_BORDER,
"*.cable_spec", 0,
_T("Directory Listing"));
// JIB
Connect(tree->GetTreeCtrl()->GetId(),wxEVT_COMMAND_TREE_ITEM_ACTIVATED, (wxObjectEventFunction) (wxEventFunction)(wxCommandEventFunction) &BUNDLEBLDR::OnTreeSelectionChanged);
//SetButtonState_FolderSelected();
}
void BUNDLEBLDR::OnTreeSelectionChanged(wxTreeEvent& evt)
{
// A few file functions
wxFileName fname (tree->GetFilePath());
wxString File_Path = fname.GetPath();
wxString File_FullName = fname.GetFullName();
PLACE_CABLE *winPLACE_CABLE = new PLACE_CABLE(this);
if ( winPLACE_CABLE->ShowModal() == wxID_OK )
{
bundle_list->x_offset = winPLACE_CABLE->TextCtrl1->GetValue();
bundle_list->y_offset = winPLACE_CABLE->TextCtrl2->GetValue();
bundle_list->rot_theta = winPLACE_CABLE->TextCtrl3->GetValue();
bundle_list->CableType = File_FullName;
// Create a new node additional cables
bundle_list->next = new Bundle;
// Set the current to the new one
bundle_list = bundle_list->next;
// Mark the NULL end of bundle component list
bundle_list->next = NULL;
};
winPLACE_CABLE->Destroy();
ListBox1->Append(File_FullName);
DrawBundleCsection();
}
void BUNDLEBLDR::OnPanel2Paint(wxPaintEvent& event)
{
}
void BUNDLEBLDR::SetPathForDir(wxString Path, wxString Name)
{
PathToMOD << Path;
MODname << Name;
PopulateTheDirectoryTree(PathToMOD);
}
void BUNDLEBLDR::OnCheckListBox1Toggled(wxCommandEvent& event)
{
}
void BUNDLEBLDR::OnPanel1Paint(wxPaintEvent& event)
{
FormatPanel("temp");
}
void BUNDLEBLDR::DrawBundleCsection()
{
bundle_list = bundle_root;
wxString x, y, cable;
while ( bundle_list->next != NULL )
{
cable = bundle_list->CableType;
x = bundle_list->x_offset;
y = bundle_list->y_offset;
DrawBundleCable(cable, x, y);
bundle_list = bundle_list->next;
}
}
// BUNDLE GRAPHICAL SCHEMATIC - SET UP PANEL
void BUNDLEBLDR::FormatPanel(wxString TheFileNameToDraw)
{
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(*wxBLACK);
dc.DrawText("y=0", 5, (size_v/2)-15);
dc.DrawText("x=0", (size_h/2)+5, size_v-20);
// Draw ordinates
dc.SetPen( wxPen( wxColor(255,0,0),1 ) );
dc.DrawCircle( wxPoint(5,size_v-10), 5 );
dc.DrawLine( 5, size_v-10, 30, size_v-10 );
dc.DrawLine( 5, size_v-10, 5, size_v-35);
dc.DrawText("y", 10, size_v-45);
dc.DrawText("x", 30, size_v-25);
}
void BUNDLEBLDR::DrawBundleCable(wxString cable, wxString x, wxString y)
{
double xCoord, yCoord;
x.ToDouble(&xCoord);
y.ToDouble(&yCoord);
yCoord = -1.0 * yCoord;
int size_h, size_v;
Panel1->GetSize(&size_h, &size_v );
wxClientDC dc(Panel1);
std::stringstream stream;
stream <> conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> dielectric_radius;
float dielectric_Scaledradius,conductor_Scaledradius, scaledxCoord, scaledyCoord;
dielectric_Scaledradius = (dielectric_radius/maxDimension)*scaleFactor;
conductor_Scaledradius = (conductor_radius/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), conductor_Scaledradius );
}
if (str.compare("Coax") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float inner_conductor_radius, shield_radius, outer_insulation, shield_thickness;
cableFile >> inner_conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_insulation;
std::getline(cableFile, str); //Read to end of line
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_thickness;
float inner_conductor_Scaledradius, shield_Scaledradius, outer_Scaledinsulation, shield_Scaledthickness, scaledxCoord, scaledyCoord;
//scaleFactor = (size_h * 0.5);
outer_Scaledinsulation = (outer_insulation/maxDimension)*scaleFactor;
shield_Scaledthickness = (shield_thickness/maxDimension)*scaleFactor;
shield_Scaledradius = (shield_radius/maxDimension)*scaleFactor;
inner_conductor_Scaledradius = (inner_conductor_radius/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), outer_Scaledinsulation );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), shield_Scaledthickness+shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxLIGHT_GREY, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), inner_conductor_Scaledradius );
}
if (str.compare("Twinax") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float inner_conductor_radius, inner_dielectric_radius, conductor_separation, shield_radius, shield_thickness, outer_dielectric_radius;
cableFile >> inner_conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_thickness;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_dielectric_radius;
float outer_dielectric_Scaledradius,
shield_Scaledthickness,
shield_Scaledradius,
inner_dielectric_Scaledradius,
inner_conductor_Scaledradius,
conductor_Scaledseparation,
scaledxCoord,
scaledyCoord;
outer_dielectric_Scaledradius = (outer_dielectric_radius/maxDimension)*scaleFactor;
shield_Scaledthickness = (shield_thickness/maxDimension)*scaleFactor;
shield_Scaledradius = (shield_radius/maxDimension)*scaleFactor;
inner_dielectric_Scaledradius = (inner_dielectric_radius/maxDimension)*scaleFactor;
inner_conductor_Scaledradius = (inner_conductor_radius/maxDimension)*scaleFactor;
conductor_Scaledseparation = (conductor_separation/maxDimension)*scaleFactor;
scaledxCoord = 2*(xCoord/maxDimension)*scaleFactor;
scaledyCoord = 2*(yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledthickness+shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxLIGHT_GREY, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2)+(conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2)-(conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2)+(conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2)-(conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
}
if (str.compare("Twisted_pair") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float conductor_radius, conductor_separation, dielectric_radius;
cableFile >> conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> dielectric_radius;
float conductor_Scaledradius, conductor_Scaledseparation, dielectric_Scaledradius, scaledxCoord, scaledyCoord;
conductor_Scaledradius = (conductor_radius/maxDimension)*scaleFactor;
conductor_Scaledseparation = (conductor_separation/maxDimension)*scaleFactor;
dielectric_Scaledradius = (dielectric_radius/maxDimension)*scaleFactor;
scaledxCoord = 2*(xCoord/maxDimension)*scaleFactor;
scaledyCoord = 2*(yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
float wire_pos = (conductor_Scaledseparation/2)*0.707;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2-wire_pos,size_v/2-wire_pos), conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2-wire_pos,size_v/2-wire_pos), dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+wire_pos,size_v/2+wire_pos), conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2+wire_pos,size_v/2+wire_pos), dielectric_Scaledradius );
}
if (str.compare("Shielded_twisted_pair") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float inner_conductor_radius, inner_conductor_separation, inner_dielectric_radius, shield_radius, shield_thickness, outer_dielectric_radius;
cableFile >> inner_conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> shield_thickness;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_dielectric_radius;
float inner_conductor_Scaledradius,
inner_conductor_Scaledseparation,
inner_dielectric_Scaledradius,
shield_Scaledradius,
shield_Scaledthickness,
outer_dielectric_Scaledradius,
scaledxCoord,
scaledyCoord;
inner_conductor_Scaledradius = (inner_conductor_radius/maxDimension)*scaleFactor;
inner_conductor_Scaledseparation = (inner_conductor_separation/maxDimension)*scaleFactor;
inner_dielectric_Scaledradius = (inner_dielectric_radius/maxDimension)*scaleFactor;
shield_Scaledradius = (shield_radius/maxDimension)*scaleFactor;
shield_Scaledthickness = (shield_thickness/maxDimension)*scaleFactor;
outer_dielectric_Scaledradius = (outer_dielectric_radius/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
float wire_pos = (inner_conductor_Scaledseparation/2)*0.707;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledthickness+shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2-wire_pos,size_v/2-wire_pos), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2-wire_pos,size_v/2-wire_pos), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2+wire_pos,size_v/2+wire_pos), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2+wire_pos,size_v/2+wire_pos), inner_conductor_Scaledradius );
}
if (str.compare("Spacewire") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float inner_conductor_radius, inner_conductor_separation, inner_dielectric_radius, inner_shield_radius, inner_shield_thickness,
inner_shield_jacket_radius, shielded_twisted_pair_radius, outer_shield_radius, outer_shield_thickness, outer_dielectric_radius;
cableFile >> inner_conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_shield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_shield_thickness;
std::getline(cableFile, str); //Read to end of line
cableFile >> inner_shield_jacket_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> shielded_twisted_pair_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_shield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_shield_thickness;
std::getline(cableFile, str); //Read to end of line
cableFile >> outer_dielectric_radius;
float inner_conductor_Scaledradius,
inner_dielectric_Scaledradius,
inner_conductor_Scaledseparation,
inner_shield_Scaledradius,
inner_shield_Scaledthickness,
inner_shield_jacket_Scaledradius,
shielded_twisted_pair_Scaledradius,
outer_shield_Scaledradius,
outer_shield_Scaledthickness,
outer_dielectric_Scaledradius,
scaledxCoord,
scaledyCoord;
inner_conductor_Scaledradius = (inner_conductor_radius/maxDimension)*scaleFactor;
inner_dielectric_Scaledradius = (inner_dielectric_radius/maxDimension)*scaleFactor;
inner_conductor_Scaledseparation = (inner_conductor_separation/maxDimension)*scaleFactor;
inner_shield_Scaledradius = (inner_shield_radius/maxDimension)*scaleFactor;
inner_shield_Scaledthickness = (inner_shield_thickness/maxDimension)*scaleFactor;
inner_shield_jacket_Scaledradius = (inner_shield_jacket_radius/maxDimension)*scaleFactor;
shielded_twisted_pair_Scaledradius = (shielded_twisted_pair_radius/maxDimension)*scaleFactor;
outer_shield_Scaledradius = (outer_shield_radius/maxDimension)*scaleFactor;
outer_shield_Scaledthickness = (outer_shield_thickness/maxDimension)*scaleFactor;
outer_dielectric_Scaledradius = (outer_dielectric_radius/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), outer_shield_Scaledthickness+outer_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), outer_shield_Scaledradius );
//TP Top
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius)), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius)), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius)), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2)), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2)), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2)), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2-shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2)), inner_conductor_Scaledradius );
//TP Left
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2-shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
//TP Bottom
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius)), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius)), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius)), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2)), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2)), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2)), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,(size_v/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2)), inner_conductor_Scaledradius );
//TP Right
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius),size_v/2), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_h/2+shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius );
}
if (str.compare("Overshield") == 0 ){
std::getline(cableFile, str);
std::getline(cableFile, str);
float overshield_radius, overshield_thickness;
cableFile >> overshield_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> overshield_thickness;
float overshield_Scaledradius, overshield_Scaledthickness, scaledxCoord, scaledyCoord;
overshield_Scaledradius = (overshield_radius/maxDimension)*scaleFactor;
overshield_Scaledthickness = (overshield_thickness/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), overshield_Scaledthickness+overshield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_h/2,size_v/2), overshield_Scaledradius );
}
if (str.compare("Flex_cable") == 0 ){
float conductors, conductor_width, conductor_height, conductor_separation, dielectric_offset_x, dielectric_offset_y;
cableFile >> conductors;
std::getline(cableFile, str); //Read to end of line
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_width;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_height;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> dielectric_offset_x;
std::getline(cableFile, str); //Read to end of line
cableFile >> dielectric_offset_y;
float conductor_Scaledwidth,
conductor_Scaledheight,
conductor_Scaledseparation,
dielectric_Scaledoffset_x,
//dielectric_Scaledoffset_y,
totalScaledWidth,
totalScaledHeight,
scaledxCoord,
scaledyCoord;
float totalWidth = (conductors*conductor_width)+((conductors-1) * conductor_separation)+(dielectric_offset_x * 2);
float totalHeight = (2 * dielectric_offset_y) + conductor_height;
conductor_Scaledwidth = (conductor_width/maxDimension)*scaleFactor;
conductor_Scaledheight = (conductor_height/maxDimension)*scaleFactor;
conductor_Scaledseparation = (conductor_separation/maxDimension)*scaleFactor;
dielectric_Scaledoffset_x = (dielectric_offset_x/maxDimension)*scaleFactor;
//dielectric_Scaledoffset_y = (dielectric_offset_y/maxDimension)*scaleFactor;
totalScaledHeight = (totalHeight/maxDimension)*scaleFactor;
totalScaledWidth = (totalWidth/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawRectangle(wxPoint(size_h/2-totalScaledWidth/2, size_v/2-totalScaledHeight/2), wxSize(totalScaledWidth,totalScaledHeight));
float x_origin, y_origin;
x_origin = (size_h/2 - totalScaledWidth/2)+dielectric_Scaledoffset_x;
y_origin = size_v/2 - conductor_Scaledheight/2;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
for(int i=0;i> conductors;
std::getline(cableFile, str); //Read to end of line
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_radius;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_pitch;
std::getline(cableFile, str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, str); //Read to end of line
cableFile >> shell_offset;
// float totalWidth = (conductors/2 * conductor_separation) + (2 * shell_offset) + (2 * conductor_radius);
float conductor_Scaledradius,
conductor_Scaledpitch,
conductor_Scaledseparation,
scaledxCoord,
scaledyCoord;
float x_origin, y_origin;
scaleFactor = (size_h * 0.25);
conductor_Scaledradius = (conductor_radius/maxDimension)*scaleFactor;
conductor_Scaledpitch = (conductor_pitch/maxDimension)*scaleFactor;
conductor_Scaledseparation = (conductor_separation/maxDimension)*scaleFactor;
//shell_Scaledoffset = (shell_offset/maxDimension)*scaleFactor;
//total_Scaledwidth = (totalWidth/maxDimension)*scaleFactor;
scaledxCoord = (xCoord/maxDimension)*scaleFactor;
scaledyCoord = (yCoord/maxDimension)*scaleFactor;
size_h = size_h + scaledxCoord;
size_v = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
// Upper conductors & Shell
int upper_conductors = conductors / 2;
x_origin = (size_h/2) - (upper_conductors/2 * conductor_Scaledseparation);
y_origin = (size_v/2) - (conductor_Scaledpitch);
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK));
for(int i=0;iGetValue();
TextCtrl1->SetBackgroundColour(wxColor(255,255,255));
if (fileName == "")
{
wxMessageBox("Please Specify a Cable Name" , _("Missing Cable Name"));
return;
}
wxString fullFileName = PathToMOD + "\\BUNDLE\\" + fileName + ".bundle_spec";
cableFile.open (fullFileName);
if (cableFile.is_open())
{
cableFile << "#MOD_cable_lib_dir" << "\n";
cableFile <<"../"<< MODname <<"/CABLE/"<<"\n";
cableFile << "#MOD_cable_lib_dir" << "\n";
cableFile <<"../"<< MODname <<"/BUNDLE/"<<"\n";
cableFile << ListBox1->GetCount() << " #Number of cables in bundle, cable list follows\n";
bundle_list = bundle_root;
wxString x, y, rot, cable;
while ( bundle_list->next != NULL )
{
cable = bundle_list->CableType;
//Remove pesky file extension
size_t lastindex = cable.find_last_of(".");
wxString cable_name = cable.substr(0, lastindex); //at the moment here requires full path to file
x = bundle_list->x_offset;
y = bundle_list->y_offset;
rot = bundle_list->rot_theta;
cableFile << cable_name <<"\n";
cableFile << x << "\t" << y << "\t" << rot << "\n";
bundle_list = bundle_list->next;
}
if (CheckBox1->GetValue())
{
cableFile << "ground_plane\n";
}
else
{
cableFile <<"no_ground_plane\n";
}
if (CheckBox2->GetValue())
{
cableFile << "use_laplace\n";
}
else
{
cableFile << "no_laplace\n";
}
if (CheckBox3->GetValue())
{
cableFile << "Laplace_boundary_constant\n";
cableFile << TextCtrl4->GetValue() <<"\n";
cableFile << "Laplace_surface_mesh_constant\n";
cableFile << TextCtrl5->GetValue() <<"\n";
CheckBox3 ->SetValue(false);
}
}
cableFile.close();
Button1->Disable();
}
void BUNDLEBLDR::OnButton2Click(wxCommandEvent& event)
{
//clean up directory
clean_temp_files();
wxString fileName = TextCtrl1->GetValue();
std::stringstream stream;
stream << "\"..\\BIN\\cable_bundle_model_builder.exe\""
<< " "
<< "..\\" + MODname + "\\BUNDLE\\"
<< fileName ;
system(stream.str().c_str());
// Display Run Status
RUN_STATUS *run_status = new RUN_STATUS(this);
run_status->ShowModal();
Button1->Enable();
if (CheckBox2->GetValue())
{
// Identify all mesh files for viewing
//struct _finddata_t fileinfo;
long hFile;
wxString meshFileName = "*.msh.vtk";
//wxString pattern((meshFileName));
wxString pattern((".msh.vtk"));
wxString file;
ComboBox1->Clear();
file = wxFindFirstFile(pattern);
while ( !file.empty())
{
wxString meshfile = file;
size_t extindex = meshfile.find_first_of (".");
meshfile = meshfile.substr(0, extindex);
ComboBox1->Append(meshfile);
}
// if (( hFile = _findfirst( pattern, &fileinfo )) != -1 )
// {
// do
// {
// wxString meshfile = fileinfo.name;
// size_t extindex = meshfile.find_first_of (".");
//
// meshfile = meshfile.substr(0, extindex);
//
// ComboBox1->Append(meshfile);
//
// } while ( _findnext( hFile, &fileinfo) == 0);
// }
// _findclose( hFile);
CheckBox3->Enable();
}
}
void BUNDLEBLDR::OnButton3Click(wxCommandEvent& event)
{
PopulateTheDirectoryTree(PathToMOD);
//clean up directory
clean_temp_files();
Close();
}
void BUNDLEBLDR::OnCheckBox1Click(wxCommandEvent& event)
{
int size_h, size_v;
Panel1->GetSize(&size_h, &size_v );
wxClientDC dc(Panel1);
// Ground Plane
dc.SetPen( wxPen( (*wxBLACK) ,5 , wxSOLID) );
dc.DrawLine( 0, size_v/2, size_h,size_v/2 );
}
void BUNDLEBLDR::OnCheckBox3Click(wxCommandEvent& event)
{
if (CheckBox3->GetValue())
{
TextCtrl4->Enable();
TextCtrl5->Enable();
}
}
void BUNDLEBLDR::OnComboBox1Selected(wxCommandEvent& event)
{
wxString meshToView;
meshToView<GetValue();
draw_mesh(Panel1,meshToView);
}
void BUNDLEBLDR::OnTextCtrl4Text(wxCommandEvent& event)
{
TextCtrl4->SetForegroundColour(*wxBLACK);
int IsError = 0;
check_is_numeric(TextCtrl4, &IsError);
}
void BUNDLEBLDR::OnInit(wxInitDialogEvent& event)
{
TextCtrl4->SetForegroundColour(*wxLIGHT_GREY);
TextCtrl5->SetForegroundColour(*wxLIGHT_GREY);
}
void BUNDLEBLDR::OnTextCtrl5Text(wxCommandEvent& event)
{
TextCtrl5->SetForegroundColour(*wxBLACK);
int IsError = 0;
check_is_numeric(TextCtrl5, &IsError);
}