From 47cbb42e83023f45bf92cdcf5dbeaf03bc2aff57 Mon Sep 17 00:00:00 2001 From: Steve Greedy Date: Sat, 6 Oct 2018 13:16:08 +0100 Subject: [PATCH] Update SW1 --- GUI/SW1/SRC/BUNDLEBLDR.cpp | 1704 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ GUI/SW1/SRC/SW1_GUIApp.h | 2 +- GUI/SW1/SRC/resources/Build | 2 +- version_information.inc | 2 +- 4 files changed, 861 insertions(+), 849 deletions(-) diff --git a/GUI/SW1/SRC/BUNDLEBLDR.cpp b/GUI/SW1/SRC/BUNDLEBLDR.cpp index acb8446..1dc6cd0 100644 --- a/GUI/SW1/SRC/BUNDLEBLDR.cpp +++ b/GUI/SW1/SRC/BUNDLEBLDR.cpp @@ -325,6 +325,27 @@ BUNDLEBLDR::BUNDLEBLDR(wxWindow* parent,wxWindowID id,const wxPoint& pos,const w //PopulateTheDirectoryTree(PathToMOD); } + +BUNDLEBLDR::~BUNDLEBLDR() +{ + //(*Destroy(BUNDLEBLDR) + //*) +} + +void BUNDLEBLDR::SetPathForDir(wxString Path, wxString Name) +{ + PathToMOD << Path; + MODname << Name; + + PopulateTheDirectoryTree(PathToMOD); +} + + +//========================================================================================================= +// Build bundle from components selected from MOD + + +//Select cable component for removal void BUNDLEBLDR::OnListboxRDown(wxMouseEvent& event) { int item = ListBox1->HitTest(event.GetPosition()); @@ -334,9 +355,10 @@ void BUNDLEBLDR::OnListboxRDown(wxMouseEvent& event) wxString strMessage; wxString strItem = ListBox1->GetString(item); - strMessage = "Are you sure you w DrawBundleCsection();ish to delete: "; + strMessage = "Are you sure you wish to delete: "; strMessage = strMessage << strItem; - // Confirm cable component deletion? + + // Confirm cable component deletion wxMessageDialog bb_ConfirmDelete (this, strMessage, _("Please confirm delete") ,wxYES_NO|wxCENTRE,wxDefaultPosition ); bb_ConfirmDelete.ShowModal(); @@ -351,11 +373,13 @@ void BUNDLEBLDR::OnListboxRDown(wxMouseEvent& event) event.Skip(); } + +//Add cable component to component list void BUNDLEBLDR::PopulateListControl(void) { ListBox1->Clear(); - Button1->Enable(); DrawBundleCsection(); + Button1->Enable(); Bundle *Current = bundle_root; @@ -364,10 +388,10 @@ void BUNDLEBLDR::PopulateListControl(void) ListBox1->Append(Current->CableType); Current = Current->next; } - DrawPanel(); - DrawBundleCsection(); } + +//Delete cable component from component list void BUNDLEBLDR::removeElement(int ItemIndex) { @@ -399,13 +423,7 @@ void BUNDLEBLDR::removeElement(int ItemIndex) } - -BUNDLEBLDR::~BUNDLEBLDR() -{ - //(*Destroy(BUNDLEBLDR) - //*) -} - +// Display MOD void BUNDLEBLDR::PopulateTheDirectoryTree (wxString Path) { int size_h, size_v; @@ -426,8 +444,10 @@ void BUNDLEBLDR::PopulateTheDirectoryTree (wxString Path) //SetButtonState_FolderSelected(); } +//========================================================================================================= +//Capture component selection from MOD, position and display void BUNDLEBLDR::OnTreeSelectionChanged(wxTreeEvent& evt) { // A few file functions @@ -464,32 +484,10 @@ void BUNDLEBLDR::OnTreeSelectionChanged(wxTreeEvent& evt) } - -void BUNDLEBLDR::OnPanel2Paint(wxPaintEvent& event) -{ - -} - - -void BUNDLEBLDR::SetPathForDir(wxString Path, wxString Name) -{ - PathToMOD << Path; - MODname << Name; - - PopulateTheDirectoryTree(PathToMOD); -} - -void BUNDLEBLDR::OnCheckListBox1Toggled(wxCommandEvent& event) -{ -} - +// Initialise Draw Panel void BUNDLEBLDR::OnPanel1Paint(wxPaintEvent& event) { - DrawPanel(); - //DrawBundleCsection(); - - } void BUNDLEBLDR::DrawPanel() @@ -503,27 +501,7 @@ void BUNDLEBLDR::DrawPanel() FormatPanel(maxDimension); } -void BUNDLEBLDR::DrawBundleCsection() -{ - bundle_list = bundle_root; - - wxString x, y, rot, cable; - - while ( bundle_list->next != NULL ) - { - cable = bundle_list->CableType; - x = bundle_list->x_offset; - y = bundle_list->y_offset; - rot = bundle_list->rot_theta; - - DrawBundleCable(cable, x, y, rot); - - bundle_list = bundle_list->next; - } -} - - -// BUNDLE GRAPHICAL SCHEMATIC - SET UP PANEL +// Set Default Panel void BUNDLEBLDR::FormatPanel(double maxDimension) { @@ -566,711 +544,733 @@ void BUNDLEBLDR::FormatPanel(double maxDimension) } -void BUNDLEBLDR::DrawBundleCable(wxString cable, wxString x, wxString y, wxString rot) +// Draw Bundle for Selected Components +void BUNDLEBLDR::DrawBundleCsection() { - wxString separator(wxFileName::GetPathSeparator()); - - double xCoord, yCoord, rotation, maxDimension; + bundle_list = bundle_root; - x.ToDouble(&xCoord); - y.ToDouble(&yCoord); - rot.ToDouble(&rotation); + wxString x, y, rot, cable; - yCoord = -1.0 * yCoord; + double maxDimension; - int size_h, size_v; - Panel1->GetSize(&size_h, &size_v ); + wxString maxXY = TextCtrl8->GetValue(); - wxClientDC dc(Panel1); + maxXY.ToDouble(&maxDimension); - std::stringstream stream; - stream << PathToMOD << separator << "CABLE"<< separator << cable; + FormatPanel(maxDimension); - cable = (stream.str().c_str()); - std::ifstream cableFile; - cableFile.open (cable); + while ( bundle_list->next != NULL ) + { + cable = bundle_list->CableType; + x = bundle_list->x_offset; + y = bundle_list->y_offset; + rot = bundle_list->rot_theta; - std::string str; + DrawBundleCable(cable, x, y, rot); - std::getline(cableFile, str); - std::getline(cableFile, str); - std::getline(cableFile, str); + bundle_list = bundle_list->next; + } +} - float scaleFactor = (size_h/2 * 1.0); - wxString maxXY = TextCtrl8->GetValue(); - maxXY.ToDouble(&maxDimension); +// Save bundle +void BUNDLEBLDR::OnButton1Click(wxCommandEvent& event) +{ + int IsError = 0; - if (str.compare("Cylindrical") == 0 ){ + wxString fileName = TextCtrl1->GetValue(); - std::getline(cableFile, str); - std::getline(cableFile, str); + TextCtrl1->SetBackgroundColour(wxColor(255,255,255)); - float conductor_radius, dielectric_radius; + if (fileName == "") + { + wxMessageBox("Please Specify a Cable Name" , _("Missing Cable Name")); + return; + } - cableFile >> conductor_radius; - std::getline(cableFile, str); //Read to end of line - cableFile >> dielectric_radius; + WriteBundleFile(fileName); - float dielectric_Scaledradius,conductor_Scaledradius, scaledxCoord, scaledyCoord; + Button1->Disable(); +} - dielectric_Scaledradius = (dielectric_radius/maxDimension)*scaleFactor; - conductor_Scaledradius = (conductor_radius/maxDimension)*scaleFactor; - scaledxCoord = (xCoord/maxDimension)*scaleFactor; - scaledyCoord = (yCoord/maxDimension)*scaleFactor; +void BUNDLEBLDR::WriteBundleFile(wxString fileName) +{ + ofstream cableFile; + wxString separator(wxFileName::GetPathSeparator()); - 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 ); + wxString fullFileName = PathToMOD + separator + "BUNDLE" + separator + fileName + ".bundle_spec"; - } + cableFile.open (fullFileName); - if (str.compare("Coax") == 0 ){ + if (cableFile.is_open()) + { + cableFile << "#MOD_cable_lib_dir" << "\n"; - std::getline(cableFile, str); - std::getline(cableFile, str); + cableFile <<".." << separator << MODname << separator << "CABLE" << separator <<"\n"; - float inner_conductor_radius, shield_radius, outer_insulation, shield_thickness; + cableFile << "#MOD_cable_lib_dir" << "\n"; - 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; + cableFile <<".." << separator << MODname << separator << "BUNDLE" << separator <<"\n"; - float inner_conductor_Scaledradius, shield_Scaledradius, outer_Scaledinsulation, shield_Scaledthickness, scaledxCoord, scaledyCoord; + cableFile << ListBox1->GetCount() << " #Number of cables in bundle, cable list follows\n"; - 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; + bundle_list = bundle_root; - 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 ); + wxString x, y, rot, cable; - 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 ); + while ( bundle_list->next != NULL ) + { - 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 ); + cable = bundle_list->CableType; - 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 ); + //Remove 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; - if (str.compare("Twinax") == 0 ){ + cableFile << cable_name <<"\n"; + cableFile << x << "\t" << y << "\t" << rot << "\n"; - std::getline(cableFile, str); - std::getline(cableFile, str); + bundle_list = bundle_list->next; + } - float inner_conductor_radius, inner_dielectric_radius, conductor_separation, shield_radius, shield_thickness, outer_dielectric_radius; + if (CheckBox1->GetValue()) + { + cableFile << "ground_plane\n"; + } + else + { + cableFile <<"no_ground_plane\n"; + } - 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; + if (CheckBox4->GetValue()) + { + cableFile << TextCtrl2->GetValue() <<"\t # order for filter fitting\n"; + if (RadioButton1) + { + cableFile << "lin # frequency range type for filter fitting type (lin or dB)"; + } + else + { + cableFile << "log # frequency range type for filter fitting type (lin or dB)"; + } + cableFile << TextCtrl3->GetValue() <<" "<< TextCtrl6->GetValue() <<" "<< TextCtrl7->GetValue() <<"\t # fmin fmax number_of_frequencies for filter fitting"; - 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; + if (CheckBox2->GetValue()) + { + cableFile << "use_laplace\n"; + } + else + { + cableFile << "no_laplace\n"; + } - 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 ); + if (CheckBox3->GetValue()) + { + cableFile << "Laplace_boundary_constant\n"; + cableFile << TextCtrl4->GetValue() <<"\n"; + cableFile << "Laplace_surface_mesh_constant\n"; + cableFile << TextCtrl5->GetValue() <<"\n"; + cableFile << "max_mesh_edge_length\n"; + cableFile << TextCtrl9->GetValue() <<"\n"; - 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 ); + if (CheckBox1->GetValue()) + { + cableFile << "gp_edge_length\n"; + cableFile << TextCtrl10->GetValue() <<"\n"; + } + //CheckBox3 ->SetValue(false); + } + } + cableFile.close(); - 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 ); +// Build Bundle Model +void BUNDLEBLDR::OnButton2Click(wxCommandEvent& event) +{ + //clean up directory + clean_temp_files(); - 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 ); + wxString fileName = TextCtrl1->GetValue(); - 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 ); + wxString command_line; - 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 ); - } + wxString separator(wxFileName::GetPathSeparator()); - if (str.compare("Twisted_pair") == 0 ){ + WriteBundleFile (TextCtrl1->GetValue()); - std::getline(cableFile, str); - std::getline(cableFile, str); + std::stringstream stream; + stream <<"." + separator + << "cable_bundle_model_builder" + << " " + << ".." + separator + MODname + separator + "BUNDLE" + separator + << fileName ; - float conductor_radius, conductor_separation, dielectric_radius; + command_line << stream.str().c_str(); - 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; + wxExecute (command_line,wxEXEC_SYNC); - float conductor_Scaledradius, conductor_Scaledseparation, dielectric_Scaledradius, scaledxCoord, scaledyCoord; + // Display Run Status + RUN_STATUS *run_status_bundle = new RUN_STATUS(this); + run_status_bundle->ShowModal(); - 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; + DrawBundleCsection(); - size_h = size_h + scaledxCoord; - size_v = size_v + scaledyCoord; + Button1->Enable(); - float wire_pos = (conductor_Scaledseparation/2)*0.707; + if (CheckBox2->GetValue()) + { + wxString pattern(("*.msh.vtk")); + wxString file; - 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 ); + ComboBox1->Clear(); + file = wxFindFirstFile(pattern); - 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 ); + while ( !file.empty()) + { + wxString meshfile = file; - 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 ); + size_t extindex = meshfile.find_last_of ("."); - 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 ); + 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(); } + - 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; +void BUNDLEBLDR::OnButton3Click(wxCommandEvent& event) +{ + //clean up directory + clean_temp_files(); + Close(); +} - 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; +void BUNDLEBLDR::OnCheckBox1Click(wxCommandEvent& event) +{ + int size_h, size_v; + Panel1->GetSize(&size_h, &size_v ); - float inner_conductor_Scaledradius, - inner_conductor_Scaledseparation, - inner_dielectric_Scaledradius, - shield_Scaledradius, - shield_Scaledthickness, - outer_dielectric_Scaledradius, - scaledxCoord, - scaledyCoord; + DrawBundleCsection(); - 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; + TextCtrl10->Enable(); +} - float wire_pos = (inner_conductor_Scaledseparation/2)*0.707; +void BUNDLEBLDR::OnCheckBox3Click(wxCommandEvent& event) +{ + if (CheckBox3->GetValue()) + { + TextCtrl4->Enable(); + TextCtrl5->Enable(); + TextCtrl9->Enable(); + } - 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 ); + //WriteBundleFile (TextCtrl1->GetValue()); +} - 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 ); +void BUNDLEBLDR::OnComboBox1Selected(wxCommandEvent& event) +{ + wxString meshToView; + meshToView<GetValue(); + draw_mesh(Panel1,meshToView, scale); - dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); - dc.SetBrush(wxBrush(*wxWHITE, wxSOLID)); - dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledradius ); + MeshSelected = 1; - 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 ); + TextCtrl8->Disable(); +} - 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 ); +void BUNDLEBLDR::OnTextCtrl4Text(wxCommandEvent& event) +{ + TextCtrl4->SetForegroundColour(*wxBLACK); + int IsError = 0; + check_is_numeric(TextCtrl4, &IsError); +} - 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 ); +void BUNDLEBLDR::OnInit(wxInitDialogEvent& event) +{ + TextCtrl4->SetForegroundColour(*wxLIGHT_GREY); + TextCtrl5->SetForegroundColour(*wxLIGHT_GREY); +} - 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 ); +void BUNDLEBLDR::OnTextCtrl5Text(wxCommandEvent& event) +{ + TextCtrl5->SetForegroundColour(*wxBLACK); + int IsError = 0; + check_is_numeric(TextCtrl5, &IsError); +} + +void BUNDLEBLDR::OnSpinButton1Change(wxSpinEvent& event) +{ + +} + +void BUNDLEBLDR::OnTextCtrl8TextEnter(wxCommandEvent& event) +{ + double maxDimension; + + wxString maxXY = TextCtrl8->GetValue(); + + maxXY.ToDouble(&maxDimension); + + + if (MeshSelected == 1) + { + scale = scale + 0.1; + + wxString meshToView; + meshToView<GetValue(); + draw_mesh(Panel1,meshToView, scale); } - if (str.compare("Spacewire") == 0 ){ + else + { + DrawBundleCsection(); + } - 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; +void BUNDLEBLDR::OnSpinButton1ChangeUp(wxSpinEvent& event) +{ + double maxDimension; - 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; + wxString maxXY = TextCtrl8->GetValue(); - 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; + maxXY.ToDouble(&maxDimension); - 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; + maxDimension = maxDimension + 0.001; - size_h = size_h + scaledxCoord; - size_v = size_v + scaledyCoord; + maxXY = ""; - 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 ); + maxXY << maxDimension; - 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 ); + TextCtrl8 ->SetValue(maxXY); - 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 ); + if (MeshSelected == 1) + { + scale = scale + 0.05; - 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 ); + wxString meshToView; + meshToView<GetValue(); + draw_mesh(Panel1,meshToView, scale); + } - 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 ); + else + { + DrawBundleCsection(); + } - 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 ); +void BUNDLEBLDR::OnSpinButton1ChangeDown(wxSpinEvent& event) +{ + double maxDimension; - 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 ); + wxString maxXY = TextCtrl8->GetValue(); - 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 ); + maxXY.ToDouble(&maxDimension); + maxDimension = maxDimension - 0.001; - //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 ); + if (maxDimension <=0) maxDimension = 0; + + maxXY = ""; + + maxXY << maxDimension; + + TextCtrl8 ->SetValue(maxXY); + + + if (MeshSelected == 1) + { + scale = scale - 0.05; + + if (scale <= 0.05) scale = 0.05; + + wxString meshToView; + meshToView<GetValue(); + draw_mesh(Panel1,meshToView, scale); + } + + else + { + DrawBundleCsection(); + } +} - 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 ); +//===================================================================================== +// Draw routines - //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 ); +void BUNDLEBLDR::DrawBundleCable(wxString cable, wxString x, wxString y, wxString rot) +{ + wxString separator(wxFileName::GetPathSeparator()); - 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 ); + double xCoord, yCoord, rotation, maxDimension; - 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 ); + x.ToDouble(&xCoord); + y.ToDouble(&yCoord); + rot.ToDouble(&rotation); - 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 ); + yCoord = -1.0 * yCoord; - 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 ); + int size_h, size_v; + Panel1->GetSize(&size_h, &size_v ); - 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 ); + wxClientDC dc(Panel1); - 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 ); + std::stringstream stream; + stream << PathToMOD << separator << "CABLE"<< separator << cable; - //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 ); + cable = (stream.str().c_str()); - 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 ); + std::ifstream cableFile; + cableFile.open (cable); - 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 ); + std::string str; - 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 ); + std::getline(cableFile, str); + std::getline(cableFile, str); + std::getline(cableFile, str); - 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 ); + float scaleFactor = (size_h/2 * 1.0); - 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 ); + wxString maxXY = TextCtrl8->GetValue(); - 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 ); - } + maxXY.ToDouble(&maxDimension); - if (str.compare("Overshield") == 0 ){ + if (str.compare("Cylindrical") == 0 ){ std::getline(cableFile, str); std::getline(cableFile, str); - float overshield_radius, overshield_thickness; + float conductor_radius, dielectric_radius; - cableFile >> overshield_radius; + cableFile >> conductor_radius; std::getline(cableFile, str); //Read to end of line - cableFile >> overshield_thickness; - + cableFile >> dielectric_radius; - float overshield_Scaledradius, overshield_Scaledthickness, scaledxCoord, scaledyCoord; + float dielectric_Scaledradius,conductor_Scaledradius, scaledxCoord, scaledyCoord; - overshield_Scaledradius = (overshield_radius/maxDimension)*scaleFactor; - overshield_Scaledthickness = (overshield_thickness/maxDimension)*scaleFactor; + dielectric_Scaledradius = (dielectric_radius/maxDimension)*scaleFactor; + conductor_Scaledradius = (conductor_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+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,size_v/2), overshield_Scaledthickness+overshield_Scaledradius ); + dc.DrawCircle( wxPoint(size_h/2+scaledxCoord,size_v/2+scaledyCoord), conductor_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 ){ + if (str.compare("Coax") == 0 ){ - float dielectric_width, dielectric_height, conductor_rows; + 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 >> dielectric_width; - std::getline(cableFile, str); //Read to end of line - cableFile >> dielectric_height; + cableFile >> outer_insulation; std::getline(cableFile, str); //Read to end of line - cableFile >> conductor_rows; std::getline(cableFile, str); //Read to end of line + cableFile >> shield_thickness; - float scaled_dielectric_width, scaled_dielectric_height, scaledxCoord, scaledyCoord; + float inner_conductor_Scaledradius, shield_Scaledradius, outer_Scaledinsulation, shield_Scaledthickness, scaledxCoord, scaledyCoord; - float dx1,dy1,dx2,dy2,dx3,dy3,dx4,dy4, tempx, tempy, rotation_rad; + 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; - scaled_dielectric_width = (dielectric_width/maxDimension) * scaleFactor; - scaled_dielectric_height = (dielectric_height/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 ); - scaledxCoord = xCoord/maxDimension * scaleFactor; - scaledyCoord = yCoord/maxDimension * scaleFactor; + 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 ); - rotation_rad = rotation * (PI/180.0); + 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 ); - float s = sin(rotation_rad); - float c = cos(rotation_rad); + 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 ); - dx1 = -scaled_dielectric_width/2; - dy1 = scaled_dielectric_height/2; + } - tempx = dx1*c - dy1*s; - tempy = dx1*s + dy1*c; + if (str.compare("Twinax") == 0 ){ - dx1 = size_h/2 + tempx + scaledxCoord; - dy1 = size_v/2 + tempy + scaledyCoord ; + std::getline(cableFile, str); + std::getline(cableFile, str); - //point 3 - dx2 = -scaled_dielectric_width/2; - dy2 = -scaled_dielectric_height/2; + float inner_conductor_radius, inner_dielectric_radius, conductor_separation, shield_radius, shield_thickness, outer_dielectric_radius; - tempx = dx2*c - dy2*s; - tempy = dx2*s + dy2*c; + 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; - dx2 = size_h/2 + tempx + scaledxCoord; - dy2 = size_v/2 + tempy + scaledyCoord; + float outer_dielectric_Scaledradius, + shield_Scaledthickness, + shield_Scaledradius, + inner_dielectric_Scaledradius, + inner_conductor_Scaledradius, + conductor_Scaledseparation, + scaledxCoord, + scaledyCoord; - //point 3 - dx3 = scaled_dielectric_width/2; - dy3 = -scaled_dielectric_height/2; + 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; - tempx = dx3*c - dy3*s; - tempy = dx3*s + dy3*c; + size_h = size_h + scaledxCoord; + size_v = size_v + scaledyCoord; - dx3 = size_h/2 + tempx + scaledxCoord; - dy3 = size_v/2 + tempy + 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 ); - //point 4 - dx4 = scaled_dielectric_width/2; - dy4 = scaled_dielectric_height/2; + 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 ); - tempx = dx4*c - dy4*s; - tempy = dx4*s + dy4*c; + 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 ); - dx4 = size_h/2 + tempx + scaledxCoord; - dy4 = size_v/2 + tempy + scaledyCoord; + 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, wxBDIAGONAL_HATCH)); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); + dc.DrawCircle( wxPoint((size_h/2)+(conductor_Scaledseparation/2),size_v/2), inner_conductor_Scaledradius ); - dc.DrawLine(dx1, dy1, dx2, dy2); - dc.DrawLine(dx2, dy2, dx3, dy3); - dc.DrawLine(dx3, dy3, dx4, dy4); - dc.DrawLine(dx4, dy4, dx1, dy1); + 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 ); + } - float offset_x, offset_y, width, height,separation, conductors; + if (str.compare("Twisted_pair") == 0 ){ - for (int i = 0; i < conductor_rows;i++){ - cableFile >> offset_x; - std::getline(cableFile, str); //Read to end of line + std::getline(cableFile, str); + std::getline(cableFile, str); - cableFile >> offset_y; - std::getline(cableFile, str); //Read to end of line + 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; - cableFile >> width; - std::getline(cableFile, str); //Read to end of line + float conductor_Scaledradius, conductor_Scaledseparation, dielectric_Scaledradius, scaledxCoord, scaledyCoord; - cableFile >> height; - std::getline(cableFile, str); //Read to end of line + 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; - cableFile >> separation; - std::getline(cableFile, str); //Read to end of line + size_h = size_h + scaledxCoord; + size_v = size_v + scaledyCoord; - cableFile >> conductors; - std::getline(cableFile, str); //Read to end of line + 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 ); - float scaled_conductor_width = width/maxDimension * scaleFactor; - float scaled_conductor_height = height/maxDimension * scaleFactor; - float scaled_conductor_separation = separation/maxDimension * scaleFactor; - float scaled_offset_x = offset_x/maxDimension * scaleFactor; - float scaled_offset_y = offset_y/maxDimension * scaleFactor; - //calculate conductor origin, top left corner: start at no.1 - float x_origin = 0 - (scaled_conductor_width * conductors/2) - scaled_conductor_separation*(conductors - 1)/2 + scaled_offset_x; - float y_origin = scaled_conductor_height/2 + scaled_offset_y; + 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 ); - float cx1,cy1,cx2,cy2,cx3,cy3,cx4,cy4; + 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(*wxWHITE, wxSOLID)); + 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 ); + } - for (int j = 0; j> 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; - //point 3 - cx2 = x_origin + j * (scaled_conductor_width + scaled_conductor_separation); - cy2 = y_origin - scaled_conductor_height; + float inner_conductor_Scaledradius, + inner_conductor_Scaledseparation, + inner_dielectric_Scaledradius, + shield_Scaledradius, + shield_Scaledthickness, + outer_dielectric_Scaledradius, + scaledxCoord, + scaledyCoord; - tempx = cx2*c - cy2*s; - tempy = cx2*s + cy2*c; + 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; - cx2 = tempx + scaledxCoord + size_h/2; - cy2 = tempy + scaledyCoord + size_v/2; + size_h = size_h + scaledxCoord; + size_v = size_v + scaledyCoord; - //point 3 - cx3 = x_origin + scaled_conductor_width + j * (scaled_conductor_width + scaled_conductor_separation); - cy3 = y_origin - scaled_conductor_height; + float wire_pos = (inner_conductor_Scaledseparation/2)*0.707; - tempx = cx3*c - cy3*s; - tempy = cx3*s + cy3*c; + 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 ); - cx3 = tempx + scaledxCoord + size_h/2; - cy3 = tempy + scaledyCoord + size_v/2; + 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 ); - //point 4 - cx4 = x_origin + scaled_conductor_width + j * (scaled_conductor_width + scaled_conductor_separation); - cy4 = y_origin; + dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); + dc.SetBrush(wxBrush(*wxWHITE, wxSOLID)); + dc.DrawCircle( wxPoint(size_h/2,size_v/2), shield_Scaledradius ); - tempx = cx4*c - cy4*s; - tempy = cx4*s + cy4*c; + 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 ); - cx4 = tempx + scaledxCoord + size_h/2; - cy4 = tempy + scaledyCoord + size_v/2; + 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.DrawLine(cx1, cy1, cx2, cy2); - dc.DrawLine(cx2, cy2, cx3, cy3); - dc.DrawLine(cx3, cy3, cx4, cy4); - dc.DrawLine(cx4, cy4, cx1, cy1); - } - } + 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("Dconnector") == 0 ){ + if (str.compare("Spacewire") == 0 ){ - float conductors, conductor_radius, conductor_pitch, conductor_separation, shell_offset; + std::getline(cableFile, str); + std::getline(cableFile, str); - cableFile >> conductors; + 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 >> conductor_radius; + cableFile >> inner_shield_radius; std::getline(cableFile, str); //Read to end of line - cableFile >> conductor_pitch; + cableFile >> inner_shield_thickness; std::getline(cableFile, str); //Read to end of line - cableFile >> conductor_separation; + cableFile >> inner_shield_jacket_radius; std::getline(cableFile, str); //Read to end of line - cableFile >> shell_offset; - -// float totalWidth = (conductors/2 * conductor_separation) + (2 * shell_offset) + (2 * conductor_radius); + 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 conductor_Scaledradius, - conductor_Scaledpitch, - conductor_Scaledseparation, + 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; - - 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; - + 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; @@ -1278,404 +1278,416 @@ void BUNDLEBLDR::DrawBundleCable(wxString cable, wxString x, wxString y, wxStrin 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.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)); - - for(int i=0;iGetValue()) - { - // Ground Plane - int size_hl, size_vl; - Panel1->GetSize(&size_hl, &size_vl ); - dc.SetPen( wxPen( (*wxBLACK) ,5 , wxSOLID) ); - dc.DrawLine( 0, size_vl/2, size_hl,size_vl/2 ); - } + 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 ); -void BUNDLEBLDR::OnButton1Click(wxCommandEvent& event) -{ - int IsError = 0; + //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 ); - wxString fileName = TextCtrl1->GetValue(); + 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 ); - TextCtrl1->SetBackgroundColour(wxColor(255,255,255)); + 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 ); - if (fileName == "") - { - wxMessageBox("Please Specify a Cable Name" , _("Missing Cable Name")); - return; - } + 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 ); - WriteBundleFile(fileName); + 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 ); - Button1->Disable(); -} + 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 ); -void BUNDLEBLDR::WriteBundleFile(wxString fileName) -{ - ofstream cableFile; - wxString separator(wxFileName::GetPathSeparator()); + 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 ); - wxString fullFileName = PathToMOD + separator + "BUNDLE" + separator + fileName + ".bundle_spec"; - cableFile.open (fullFileName); + //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 ); - if (cableFile.is_open()) - { - cableFile << "#MOD_cable_lib_dir" << "\n"; + 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 ); - cableFile <<".." << separator << MODname << separator << "CABLE" << separator <<"\n"; + 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 ); - cableFile << "#MOD_cable_lib_dir" << "\n"; + 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 ); - cableFile <<".." << separator << MODname << separator << "BUNDLE" << separator <<"\n"; + 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 ); - cableFile << ListBox1->GetCount() << " #Number of cables in bundle, cable list follows\n"; + 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 ); - bundle_list = bundle_root; + 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 ); - wxString x, y, rot, cable; + //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 ); - while ( bundle_list->next != NULL ) - { + 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 ); - cable = bundle_list->CableType; + 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 ); - //Remove 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 + 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 ); - x = bundle_list->x_offset; - y = bundle_list->y_offset; - rot = bundle_list->rot_theta; + 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 ); - cableFile << cable_name <<"\n"; - cableFile << x << "\t" << y << "\t" << rot << "\n"; + 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 ); - bundle_list = bundle_list->next; - } + 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 ); - if (CheckBox1->GetValue()) - { - cableFile << "ground_plane\n"; - } - else - { - cableFile <<"no_ground_plane\n"; - } + //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 ); - if (CheckBox4->GetValue()) - { - cableFile << TextCtrl2->GetValue() <<"\t # order for filter fitting\n"; - if (RadioButton1) - { - cableFile << "lin # frequency range type for filter fitting type (lin or dB)"; - } - else - { - cableFile << "log # frequency range type for filter fitting type (lin or dB)"; - } - cableFile << TextCtrl3->GetValue() <<" "<< TextCtrl6->GetValue() <<" "<< TextCtrl7->GetValue() <<"\t # fmin fmax number_of_frequencies for filter fitting"; + 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 ); - if (CheckBox2->GetValue()) - { - cableFile << "use_laplace\n"; - } - else - { - cableFile << "no_laplace\n"; - } + 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 ); - if (CheckBox3->GetValue()) - { - cableFile << "Laplace_boundary_constant\n"; - cableFile << TextCtrl4->GetValue() <<"\n"; - cableFile << "Laplace_surface_mesh_constant\n"; - cableFile << TextCtrl5->GetValue() <<"\n"; - cableFile << "max_mesh_edge_length\n"; - cableFile << TextCtrl9->GetValue() <<"\n"; + 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 (CheckBox1->GetValue()) - { - cableFile << "gp_edge_length\n"; - cableFile << TextCtrl10->GetValue() <<"\n"; - } - //CheckBox3 ->SetValue(false); - } + 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 ); } - cableFile.close(); -} + if (str.compare("Overshield") == 0 ){ + std::getline(cableFile, str); + std::getline(cableFile, str); -void BUNDLEBLDR::OnButton2Click(wxCommandEvent& event) -{ - //clean up directory - clean_temp_files(); + float overshield_radius, overshield_thickness; - wxString fileName = TextCtrl1->GetValue(); + cableFile >> overshield_radius; + std::getline(cableFile, str); //Read to end of line + cableFile >> overshield_thickness; - wxString command_line; - wxString separator(wxFileName::GetPathSeparator()); + float overshield_Scaledradius, overshield_Scaledthickness, scaledxCoord, scaledyCoord; - WriteBundleFile (TextCtrl1->GetValue()); + overshield_Scaledradius = (overshield_radius/maxDimension)*scaleFactor; + overshield_Scaledthickness = (overshield_thickness/maxDimension)*scaleFactor; + scaledxCoord = (xCoord/maxDimension)*scaleFactor; + scaledyCoord = (yCoord/maxDimension)*scaleFactor; - std::stringstream stream; - stream <<"." + separator - << "cable_bundle_model_builder" - << " " - << ".." + separator + MODname + separator + "BUNDLE" + separator - << fileName ; + size_h = size_h + scaledxCoord; + size_v = size_v + scaledyCoord; - command_line << stream.str().c_str(); + 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 ); - wxExecute (command_line,wxEXEC_SYNC); + dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); + dc.SetBrush(wxBrush(*wxWHITE, wxSOLID)); + dc.DrawCircle( wxPoint(size_h/2,size_v/2), overshield_Scaledradius ); + } - // Display Run Status - RUN_STATUS *run_status_bundle = new RUN_STATUS(this); - run_status_bundle->ShowModal(); + if (str.compare("flex_cable") == 0 ){ - Button1->Enable(); + float dielectric_width, dielectric_height, conductor_rows; - if (CheckBox2->GetValue()) - { - wxString pattern(("*.msh.vtk")); - wxString file; + std::getline(cableFile, str); //Read to end of line + std::getline(cableFile, str); //Read to end of line + cableFile >> dielectric_width; + std::getline(cableFile, str); //Read to end of line + cableFile >> dielectric_height; + std::getline(cableFile, str); //Read to end of line + cableFile >> conductor_rows; + std::getline(cableFile, str); //Read to end of line - ComboBox1->Clear(); + float scaled_dielectric_width, scaled_dielectric_height, scaledxCoord, scaledyCoord; - file = wxFindFirstFile(pattern); + float dx1,dy1,dx2,dy2,dx3,dy3,dx4,dy4, tempx, tempy, rotation_rad; - while ( !file.empty()) - { - wxString meshfile = file; + scaled_dielectric_width = (dielectric_width/maxDimension) * scaleFactor; + scaled_dielectric_height = (dielectric_height/maxDimension) * scaleFactor; - size_t extindex = meshfile.find_last_of ("."); + scaledxCoord = xCoord/maxDimension * scaleFactor; + scaledyCoord = yCoord/maxDimension * scaleFactor; - meshfile = meshfile.substr(0, extindex); + rotation_rad = rotation * (PI/180.0); - extindex = meshfile.find_last_of ("."); - int size_h, size_v; - Panel1->GetSize(&size_h, &size_v ); - meshfile = meshfile.substr(0, extindex); + float s = sin(rotation_rad); + float c = cos(rotation_rad); - meshfile = meshfile.substr(2,meshfile.length()); + dx1 = -scaled_dielectric_width/2; + dy1 = scaled_dielectric_height/2; - ComboBox1->Append(meshfile); + tempx = dx1*c - dy1*s; + tempy = dx1*s + dy1*c; - file = wxFindNextFile(); - } - CheckBox3->Enable(); - } -} + dx1 = size_h/2 + tempx + scaledxCoord; + dy1 = size_v/2 + tempy + scaledyCoord ; -void BUNDLEBLDR::OnButton3Click(wxCommandEvent& event) -{ - //PopulateTheDirectoryTree(PathToMOD); - //clean up directory - clean_temp_files(); - Close(); -} + //point 3 + dx2 = -scaled_dielectric_width/2; + dy2 = -scaled_dielectric_height/2; -void BUNDLEBLDR::OnCheckBox1Click(wxCommandEvent& event) -{ - int size_h, size_v; - Panel1->GetSize(&size_h, &size_v ); + tempx = dx2*c - dy2*s; + tempy = dx2*s + dy2*c; - wxClientDC dc(Panel1); + dx2 = size_h/2 + tempx + scaledxCoord; + dy2 = size_v/2 + tempy + scaledyCoord; - // Ground Plane - dc.SetPen( wxPen( (*wxBLACK) ,5 , wxSOLID) ); - dc.DrawLine( 0, size_v/2, size_h,size_v/2 ); + //point 3 + dx3 = scaled_dielectric_width/2; + dy3 = -scaled_dielectric_height/2; - TextCtrl10->Enable(); + tempx = dx3*c - dy3*s; + tempy = dx3*s + dy3*c; -} + dx3 = size_h/2 + tempx + scaledxCoord; + dy3 = size_v/2 + tempy + scaledyCoord; -void BUNDLEBLDR::OnCheckBox3Click(wxCommandEvent& event) -{ - if (CheckBox3->GetValue()) - { - TextCtrl4->Enable(); - TextCtrl5->Enable(); - TextCtrl9->Enable(); - } + //point 4 + dx4 = scaled_dielectric_width/2; + dy4 = scaled_dielectric_height/2; - //WriteBundleFile (TextCtrl1->GetValue()); -} + tempx = dx4*c - dy4*s; + tempy = dx4*s + dy4*c; -void BUNDLEBLDR::OnComboBox1Selected(wxCommandEvent& event) -{ - wxString meshToView; - meshToView<GetValue(); - draw_mesh(Panel1,meshToView, scale); + dx4 = size_h/2 + tempx + scaledxCoord; + dy4 = size_v/2 + tempy + scaledyCoord; - MeshSelected = 1; - TextCtrl8->Disable(); -} + dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); + dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH)); -void BUNDLEBLDR::OnTextCtrl4Text(wxCommandEvent& event) -{ - TextCtrl4->SetForegroundColour(*wxBLACK); - int IsError = 0; - check_is_numeric(TextCtrl4, &IsError); -} + dc.DrawLine(dx1, dy1, dx2, dy2); + dc.DrawLine(dx2, dy2, dx3, dy3); + dc.DrawLine(dx3, dy3, dx4, dy4); + dc.DrawLine(dx4, dy4, dx1, dy1); -void BUNDLEBLDR::OnInit(wxInitDialogEvent& event) -{ - TextCtrl4->SetForegroundColour(*wxLIGHT_GREY); - TextCtrl5->SetForegroundColour(*wxLIGHT_GREY); -} + float offset_x, offset_y, width, height,separation, conductors; -void BUNDLEBLDR::OnTextCtrl5Text(wxCommandEvent& event) -{ - TextCtrl5->SetForegroundColour(*wxBLACK); - int IsError = 0; - check_is_numeric(TextCtrl5, &IsError); -} + for (int i = 0; i < conductor_rows;i++){ + cableFile >> offset_x; + std::getline(cableFile, str); //Read to end of line -void BUNDLEBLDR::OnSpinButton1Change(wxSpinEvent& event) -{ + cableFile >> offset_y; + std::getline(cableFile, str); //Read to end of line - double maxDimension; + cableFile >> width; + std::getline(cableFile, str); //Read to end of line - wxString maxXY = TextCtrl8->GetValue(); + cableFile >> height; + std::getline(cableFile, str); //Read to end of line - maxXY.ToDouble(&maxDimension); + cableFile >> separation; + std::getline(cableFile, str); //Read to end of line - if (MeshSelected == 0) - { - FormatPanel(maxDimension); - DrawBundleCsection(); - } + cableFile >> conductors; + std::getline(cableFile, str); //Read to end of line -} -void BUNDLEBLDR::OnTextCtrl8TextEnter(wxCommandEvent& event) -{ - double maxDimension; + float scaled_conductor_width = width/maxDimension * scaleFactor; + float scaled_conductor_height = height/maxDimension * scaleFactor; + float scaled_conductor_separation = separation/maxDimension * scaleFactor; + float scaled_offset_x = offset_x/maxDimension * scaleFactor; + float scaled_offset_y = offset_y/maxDimension * scaleFactor; - wxString maxXY = TextCtrl8->GetValue(); + //calculate conductor origin, top left corner: start at no.1 + float x_origin = 0 - (scaled_conductor_width * conductors/2) - scaled_conductor_separation*(conductors - 1)/2 + scaled_offset_x; + float y_origin = scaled_conductor_height/2 + scaled_offset_y; - maxXY.ToDouble(&maxDimension); + float cx1,cy1,cx2,cy2,cx3,cy3,cx4,cy4; - FormatPanel(maxDimension); + dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); + dc.SetBrush(wxBrush(*wxWHITE, wxSOLID)); + for (int j = 0; jGetValue(); - draw_mesh(Panel1,meshToView, scale); - } + tempx = cx1*c - cy1*s; + tempy = cx1*s + cy1*c; - else - { - DrawBundleCsection(); - } + cx1 = tempx + scaledxCoord + size_h/2; + cy1 = tempy + scaledyCoord + size_v/2; -} + //point 3 + cx2 = x_origin + j * (scaled_conductor_width + scaled_conductor_separation); + cy2 = y_origin - scaled_conductor_height; -void BUNDLEBLDR::OnSpinButton1ChangeUp(wxSpinEvent& event) -{ - double maxDimension; + tempx = cx2*c - cy2*s; + tempy = cx2*s + cy2*c; - wxString maxXY = TextCtrl8->GetValue(); + cx2 = tempx + scaledxCoord + size_h/2; + cy2 = tempy + scaledyCoord + size_v/2; - maxXY.ToDouble(&maxDimension); + //point 3 + cx3 = x_origin + scaled_conductor_width + j * (scaled_conductor_width + scaled_conductor_separation); + cy3 = y_origin - scaled_conductor_height; - maxDimension = maxDimension + 0.001; + tempx = cx3*c - cy3*s; + tempy = cx3*s + cy3*c; - maxXY = ""; + cx3 = tempx + scaledxCoord + size_h/2; + cy3 = tempy + scaledyCoord + size_v/2; - maxXY << maxDimension; + //point 4 + cx4 = x_origin + scaled_conductor_width + j * (scaled_conductor_width + scaled_conductor_separation); + cy4 = y_origin; - TextCtrl8 ->SetValue(maxXY); + tempx = cx4*c - cy4*s; + tempy = cx4*s + cy4*c; - FormatPanel(maxDimension); + cx4 = tempx + scaledxCoord + size_h/2; + cy4 = tempy + scaledyCoord + size_v/2; - if (MeshSelected == 1) - { - scale = scale + 0.05; + dc.DrawLine(cx1, cy1, cx2, cy2); + dc.DrawLine(cx2, cy2, cx3, cy3); + dc.DrawLine(cx3, cy3, cx4, cy4); + dc.DrawLine(cx4, cy4, cx1, cy1); + } + } - wxString meshToView; - meshToView<GetValue(); - draw_mesh(Panel1,meshToView, scale); } - else - { - DrawBundleCsection(); - } + if (str.compare("Dconnector") == 0 ){ -} + float conductors, conductor_radius, conductor_pitch, conductor_separation, shell_offset; -void BUNDLEBLDR::OnSpinButton1ChangeDown(wxSpinEvent& event) -{ - double maxDimension; + cableFile >> 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; - wxString maxXY = TextCtrl8->GetValue(); +// float totalWidth = (conductors/2 * conductor_separation) + (2 * shell_offset) + (2 * conductor_radius); - maxXY.ToDouble(&maxDimension); + float conductor_Scaledradius, + conductor_Scaledpitch, + conductor_Scaledseparation, + scaledxCoord, + scaledyCoord; - maxDimension = maxDimension - 0.001; - if (maxDimension <=0) maxDimension = 0; + float x_origin, y_origin; - maxXY = ""; + scaleFactor = (size_h * 0.25); - maxXY << maxDimension; + conductor_Scaledradius = (conductor_radius/maxDimension)*scaleFactor; + conductor_Scaledpitch = (conductor_pitch/maxDimension)*scaleFactor; + conductor_Scaledseparation = (conductor_separation/maxDimension)*scaleFactor; - TextCtrl8 ->SetValue(maxXY); + scaledxCoord = (xCoord/maxDimension)*scaleFactor; + scaledyCoord = (yCoord/maxDimension)*scaleFactor; - FormatPanel(maxDimension); + 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); - if (MeshSelected == 1) - { - scale = scale - 0.05; + dc.SetPen( wxPen( wxColor(0,0,0),1 ) ); + dc.SetBrush(wxBrush(*wxBLACK)); - if (scale <= 0.05) scale = 0.05; + for(int i=0;iGetValue(); - draw_mesh(Panel1,meshToView, scale); + dc.DrawCircle( wxPoint(x_origin,y_origin), conductor_Scaledradius ); + x_origin = x_origin + (conductor_Scaledpitch); + } + // Lower conductors + int lower_conductors = (conductors / 2) - 1; + x_origin = (size_h/2) - (lower_conductors/2 * conductor_Scaledseparation) + conductor_Scaledseparation/2; + y_origin = (size_v/2) + (conductor_Scaledpitch); // This isn't correct!! + + for(int i=0;iGetValue()) { - DrawBundleCsection(); + int size_hl, size_vl; + Panel1->GetSize(&size_hl, &size_vl ); + dc.SetPen( wxPen( (*wxBLACK) ,5 , wxSOLID) ); + dc.DrawLine( 0, size_vl/2, size_hl,size_vl/2 ); } + +} + + +void BUNDLEBLDR::OnPanel2Paint(wxPaintEvent& event) +{ + +} + +void BUNDLEBLDR::OnCheckListBox1Toggled(wxCommandEvent& event) +{ } + diff --git a/GUI/SW1/SRC/SW1_GUIApp.h b/GUI/SW1/SRC/SW1_GUIApp.h index 7b531e9..1c2bbb3 100644 --- a/GUI/SW1/SRC/SW1_GUIApp.h +++ b/GUI/SW1/SRC/SW1_GUIApp.h @@ -68,7 +68,7 @@ class SW1_GUIApp : public wxApp wxBitmap splashimage; std::string SACAMOS_V_NUMBER = "SPICE_CABLE_MODEL_BUILDER_version=\"v4.0.0\""; - std::string SACAMOS_V_DATE = "SPICE_CABLE_MODEL_BUILDER_date=\"5th October 2018\""; + std::string SACAMOS_V_DATE = "SPICE_CABLE_MODEL_BUILDER_date=\"6th October 2018\""; diff --git a/GUI/SW1/SRC/resources/Build b/GUI/SW1/SRC/resources/Build index 12d9a62..426c5a3 100644 --- a/GUI/SW1/SRC/resources/Build +++ b/GUI/SW1/SRC/resources/Build @@ -1,6 +1,6 @@ GUI: Version: v4.0.0 -Date: 5th October 2018 +Date: 6th October 2018 SPICE_CABLE_MODEL_BUILDER Version: v4.0.0 diff --git a/version_information.inc b/version_information.inc index 7fc07df..6d6c2a3 100644 --- a/version_information.inc +++ b/version_information.inc @@ -1,2 +1,2 @@ SPICE_CABLE_MODEL_BUILDER_version="v4.0.0" -SPICE_CABLE_MODEL_BUILDER_date="5th October 2018" +SPICE_CABLE_MODEL_BUILDER_date="6th October 2018" -- libgit2 0.21.2