/////////////////////////////////////////////////////////////////////////////////
//
// 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
// BUNDLE_SCHEMATIC.cpp
//
// DESCRIPTION
// Functions to render cables - arguements: full path to .bundle_spec file
//
// AUTHOR(S)
// Steve Greedy
//
/////////////////////////////////////////////////////////////////////////////////
#include "BUNDLE_SCHEMATIC.h"
void draw_bundle(wxPanel *Panel, wxString Path, wxString bundle_to_draw)
{
int size_h, size_v;
Panel->GetSize(&size_h, &size_v );
wxClientDC dc(Panel);
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)-20);
dc.DrawText("x=0", (size_h/2)+5, size_v-20);
float maxDimension;
maxDimension = findMaxDim(bundle_to_draw);
if (maxDimension == 0.0)
{
maxDimension = 0.02;
}
else
{
maxDimension = maxDimension * 2.0;
}
std::ifstream bundleFile;
bundleFile.open (bundle_to_draw);
if (bundleFile.fail()){
wxMessageBox(bundle_to_draw , _("Failed to Open Bundle Specification"));
}
std::string bundle_str, cable_str;
std::getline(bundleFile, bundle_str);
std::getline(bundleFile, bundle_str);
std::getline(bundleFile, bundle_str);
std::getline(bundleFile, bundle_str);
int cableCount;
bundleFile >> cableCount;
std::getline(bundleFile, bundle_str); //Read to end of line
float scaleFactor = (size_h/2 * 1.0);
float xCoord, yCoord;// rot;
wxString scale;
scale << maxDimension/2.0;
dc.SetTextForeground(*wxBLUE);
dc.SetPen( wxPen( wxColor(255,0,0),1 ) );
dc.DrawLine( size_h/2, size_v-50, size_h-size_h/4, size_v-50 );
dc.DrawLine( size_h/2, size_v-50, size_h/2, size_v-40 );
dc.DrawLine( size_h-size_h/4, size_v-50, size_h-size_h/4, size_v-40 );
dc.DrawText("scale (m)", (size_h/2+50), size_v-70);
dc.DrawText(scale, (size_h/2+55), size_v-40);
wxString component_cable, cableFileName;
for (int cable_no = 0; cable_no < cableCount; cable_no++)
{
std::getline(bundleFile, bundle_str);
wxString cable_spec(bundle_str);
wxString separator(wxFileName::GetPathSeparator());
wxString cableFileName;
cableFileName << Path << separator << "CABLE" << separator <> xCoord;
bundleFile >> yCoord;
std::getline(bundleFile, bundle_str); //Read to end of line
std::ifstream cableFile;
cableFile.open (cableFileName);
if (cableFile.fail()){
wxMessageBox(cable_spec , _("Failed to Open Cable Specification"));
}
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
if (cable_str.compare("Cylindrical") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
float conductor_radius, dielectric_radius;
cableFile >> conductor_radius;
std::getline(cableFile, cable_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 = -1.0*(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);
cableFile.close();
}
if (cable_str.compare("Coax") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
float inner_conductor_radius, shield_radius, outer_insulation, shield_thickness;
cableFile >> inner_conductor_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> outer_insulation;
std::getline(cableFile, cable_str); //Read to end of line
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_thickness;
float inner_conductor_Scaledradius, shield_Scaledradius, outer_Scaledinsulation, shield_Scaledthickness, scaledxCoord, scaledyCoord;
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 = -1.0*(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 );
cableFile.close();
}
if (cable_str.compare("Twinax") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
float inner_conductor_radius, inner_dielectric_radius, conductor_separation, shield_radius, shield_thickness, outer_dielectric_radius;
cableFile >> inner_conductor_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_thickness;
std::getline(cableFile, cable_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.0*(xCoord/maxDimension)*scaleFactor;
scaledyCoord = -2.0*(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), shield_Scaledthickness+shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxLIGHT_GREY, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2)+(conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2)-(conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2)+(conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2)-(conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
cableFile.close();
}
if (cable_str.compare("Twisted_pair") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
float conductor_radius, conductor_separation, dielectric_radius;
cableFile >> conductor_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, cable_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.0*(xCoord/maxDimension)*scaleFactor;
scaledyCoord = -2.0*(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = 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_ho/2-wire_pos,size_vo/2-wire_pos), conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2-wire_pos,size_vo/2-wire_pos), dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2+wire_pos,size_vo/2+wire_pos), conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2+wire_pos,size_vo/2+wire_pos), dielectric_Scaledradius );
cableFile.close();
}
if (cable_str.compare("Shielded_twisted_pair") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_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, cable_str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_conductor_separation;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shield_thickness;
std::getline(cableFile, cable_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 = -1.0 *(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = 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_ho/2,size_vo/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), shield_Scaledthickness+shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2-wire_pos,size_vo/2-wire_pos), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2-wire_pos,size_vo/2-wire_pos), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2+wire_pos,size_vo/2+wire_pos), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2+wire_pos,size_vo/2+wire_pos), inner_conductor_Scaledradius );
cableFile.close();
}
if (cable_str.compare("Spacewire") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_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, cable_str); //Read to end of line
cableFile >> inner_dielectric_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_conductor_separation;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_shield_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_shield_thickness;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> inner_shield_jacket_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> shielded_twisted_pair_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> outer_shield_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> outer_shield_thickness;
std::getline(cableFile, cable_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 = -1.0*(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), outer_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), outer_shield_Scaledthickness+outer_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), outer_shield_Scaledradius );
//TP Top
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2-shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2-shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
//TP Bottom
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint(size_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2,(size_vo/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_ho/2+shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_jacket_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_Scaledthickness + inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius),size_vo/2), inner_shield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_vo/2), inner_dielectric_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius+inner_conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint((size_ho/2+shielded_twisted_pair_Scaledradius-inner_conductor_Scaledseparation/2),size_vo/2), inner_conductor_Scaledradius );
cableFile.close();
}
if (cable_str.compare("Overshield") == 0 )
{
std::getline(cableFile, cable_str);
std::getline(cableFile, cable_str);
float overshield_radius, overshield_thickness;
cableFile >> overshield_radius;
std::getline(cableFile, cable_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 = -1.0*(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = size_v + scaledyCoord;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), overshield_Scaledthickness+overshield_Scaledradius );
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
dc.DrawCircle( wxPoint(size_ho/2,size_vo/2), overshield_Scaledradius );
cableFile.close();
}
if (cable_str.compare("flex_cable") == 0 )
{
float dielectric_width, dielectric_height, conductor_rows;
std::getline(cableFile, cable_str); //Read to end of line
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> dielectric_width;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> dielectric_height;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_rows;
std::getline(cableFile, cable_str); //Read to end of line
wxString mystring2;
mystring2 << dielectric_width;
dc.DrawText ("Dielectric Width (m)", 10, 40);
dc.DrawText(mystring2, 10, 55);
wxString mystring3;
mystring3 << dielectric_height;
dc.DrawText ("Dielectric Height (m):", 10, 75);
dc.DrawText(mystring3, 10, 90);
wxString mystring4;
mystring4 << conductor_rows;
dc.DrawText ("Number of Conductor Rows:", 10, 110);
dc.DrawText(mystring4, 10, 125);
float scaleFactor = (size_h/dielectric_width) * 0.8;
float scaled_dielectric_width, scaled_dielectric_height, scaled_offset_x, scaled_offset_y;
scaled_dielectric_width = dielectric_width * scaleFactor;
scaled_dielectric_height = dielectric_height * scaleFactor;
//Draw dielectric
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
dc.DrawRectangle(wxPoint(size_h/2-scaled_dielectric_width/2, size_v/2-scaled_dielectric_height/2), wxSize(scaled_dielectric_width, scaled_dielectric_height));
float offset_x, offset_y, width, height,separation, conductors;
for (int i = 0; i < conductor_rows;i++){
cableFile >> offset_x;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> offset_y;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> width;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> height;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> separation;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductors;
std::getline(cableFile, cable_str); //Read to end of line
float scaled_offset_x = offset_x * scaleFactor;
float scaled_offset_y = offset_y * scaleFactor;
float scaled_conductor_width = width * scaleFactor;
float scaled_conductor_height = height * scaleFactor;
float scaled_conductor_separation = separation * scaleFactor;
float x_origin = size_h/2 - (scaled_conductor_width * conductors/2) - scaled_conductor_separation*(conductors - 1)/2 - scaled_offset_x;
float y_origin = size_v/2 - (scaled_conductor_height/2) - scaled_offset_y;
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxWHITE, wxSOLID));
for (int j = 0; j> conductors;
// std::getline(cableFile, cable_str); //Read to end of line
// std::getline(cableFile, cable_str); //Read to end of line
// cableFile >> conductor_width;
// std::getline(cableFile, cable_str); //Read to end of line
// cableFile >> conductor_height;
// std::getline(cableFile, cable_str); //Read to end of line
// cableFile >> conductor_separation;
// std::getline(cableFile, cable_str); //Read to end of line
// cableFile >> dielectric_offset_x;
// std::getline(cableFile, cable_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 = -1.0*(yCoord/maxDimension)*scaleFactor;
//
// float size_ho = size_h + scaledxCoord;
// float size_vo = size_v + scaledyCoord;
//
// dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
// dc.SetBrush(wxBrush(*wxBLACK, wxBDIAGONAL_HATCH));
// dc.DrawRectangle(wxPoint(size_ho/2-totalScaledWidth/2, size_vo/2-totalScaledHeight/2), wxSize(totalScaledWidth,totalScaledHeight));
//
// float x_origin, y_origin;
// x_origin = (size_ho/2 - totalScaledWidth/2) + dielectric_Scaledoffset_x;
// y_origin = (size_vo/2 - conductor_Scaledheight/2) + dielectric_Scaledoffset_y;
//
// dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
// dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
//
// for(int i=0;i> conductors;
std::getline(cableFile, cable_str); //Read to end of line
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_radius;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_pitch;
std::getline(cableFile, cable_str); //Read to end of line
cableFile >> conductor_separation;
std::getline(cableFile, cable_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,
//shell_Scaledoffset,
//total_Scaledwidth,
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 = -1.0*(yCoord/maxDimension)*scaleFactor;
float size_ho = size_h + scaledxCoord;
float size_vo = 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_ho/2) - (upper_conductors/2 * conductor_Scaledseparation);
y_origin = (size_vo/2) - (conductor_Scaledpitch);
dc.SetPen( wxPen( wxColor(0,0,0),1 ) );
dc.SetBrush(wxBrush(*wxBLACK));
for(int i=0;i> cableCount;
std::getline(bundleFile, bundle_str); //Read to end of line
for (int cable_no = 0; cable_no < cableCount; cable_no++)
{
std::getline(bundleFile, bundle_str); //Read to end of line
bundleFile >> xCoord;
bundleFile >> yCoord;
std::getline(bundleFile, bundle_str); //Read to end of line
if (abs(yCoord) > maxyCoord )
maxyCoord = abs(yCoord);
if (abs(xCoord) > maxxCoord )
maxxCoord = abs(xCoord);
}
float maxDim;
if (maxxCoord > maxyCoord)
{
maxDim = maxxCoord;
}
else
{
maxDim = maxyCoord;
}
bundleFile.close();
return maxDim;
}