Commit 4de4a208 authored by jean-pierre charras's avatar jean-pierre charras

Add a new utility: pcb_calculator (need of course wore work)

Eeschema: optimize import of footprints names ( .stf files) that was time consumming with large designs.
parents 89ccc663 12752407
......@@ -239,6 +239,7 @@ add_subdirectory(polygon)
add_subdirectory(polygon/kbool/src)
add_subdirectory(potrace)
add_subdirectory(bitmap2component)
add_subdirectory(pcb_calculator)
#add_subdirectory(new)
#############
......
......@@ -15,18 +15,25 @@
#include "general.h"
#include "sch_sheet_path.h"
#include "sch_component.h"
#include "netlist.h"
const wxString BackAnnotateFileWildcard( wxT( "EESchema Back Annotation File (*.stf)|*.stf" ) );
bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeToVisible )
bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFile, bool aSetFieldAttributeToVisible )
{
int LineNum = 0;
char* cp, Ref[256], FootPrint[256], Line[1024];
SCH_SHEET_LIST SheetList;
wxString reference;
wxString footprint;
while( GetLine( aFilename, Line, &LineNum, sizeof(Line) ) )
// Build a flat list of components in schematic:
SCH_REFERENCE_LIST referencesList;
SheetList.GetComponents( referencesList, false );
while( GetLine( aFile, Line, &LineNum, sizeof(Line) ) )
{
if( sscanf( Line, "comp = \"%s module = \"%s", Ref, FootPrint ) == 2 )
{
......@@ -38,12 +45,39 @@ bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFilename, bool aSetFieldAttributeT
if( *cp == '"' )
*cp = 0;
wxString reference = FROM_UTF8( Ref );
wxString Footprint = FROM_UTF8( FootPrint );
SheetList.SetComponentFootprint( reference, Footprint, aSetFieldAttributeToVisible );
reference = FROM_UTF8( Ref );
footprint = FROM_UTF8( FootPrint );
// Search the component in the flat list
for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ )
{
if( reference.CmpNoCase( referencesList[ii].GetRef() ) == 0 )
{
// We have found a candidate.
// Note: it can be not unique (multiple parts per package)
// So we do not stop the search here
SCH_COMPONENT* component = referencesList[ii].GetComponent();
SCH_FIELD * fpfield = component->GetField( FOOTPRINT );
if( fpfield->m_Text.IsEmpty()
&& ( fpfield->m_Pos == wxPoint( 0, 0 ) ) )
{
fpfield->m_Orient = component->GetField( VALUE )->m_Orient;
fpfield->m_Pos = component->GetField( VALUE )->m_Pos;
fpfield->m_Pos.y -= 100;
}
fpfield->m_Text = footprint;
if( aSetFieldAttributeToVisible )
component->GetField( FOOTPRINT )->m_Attributs &= ~TEXT_NO_VISIBLE;
else
component->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE;
}
}
}
}
fclose( aFile );
return true;
}
......
......@@ -43,11 +43,13 @@ public:
* Function AppendToList
* @param aItem The SCH_MARKER* to add to the current list which will be
* displayed in the wxHtmlListBox
* @param aRefresh = true to refresh the display
*/
void AppendToList( SCH_MARKER* aItem )
void AppendToList( SCH_MARKER* aItem, bool aRefresh = true )
{
m_MarkerList.push_back( aItem);
SetItemCount( m_MarkerList.size() );
if( aRefresh )
Refresh();
}
......
......@@ -325,17 +325,11 @@ void DIALOG_ERC::DisplayERC_MarkersList()
SCH_MARKER* Marker = (SCH_MARKER*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue;
/* Display diag */
// wxString msg;
// msg.Printf( _( "<b>sheet %s</b><ul>\n" ),
// Sheet->PathHumanReadable().GetData() );
// msg += Marker->GetReporter().ShowHtml();
// m_MarkersList->Append( msg );
m_MarkersList->AppendToList( Marker );
// Add marker without refresh the displayed list:
m_MarkersList->AppendToList( Marker, false );
}
}
m_MarkersList->Refresh();
}
......
......@@ -54,6 +54,7 @@ enum pseudokeys {
#define EESCHEMA_EXE wxT( "eeschema.exe" )
#define GERBVIEW_EXE wxT( "gerbview.exe" )
#define BITMAPCONVERTER_EXE wxT( "bitmap2component.exe" )
#define PCB_CALCULATOR_EXE wxT( "pcb_calculator.exe" )
#else
#ifndef __WXMAC__
#define CVPCB_EXE wxT( "cvpcb" )
......@@ -61,12 +62,14 @@ enum pseudokeys {
#define EESCHEMA_EXE wxT( "eeschema" )
#define GERBVIEW_EXE wxT( "gerbview" )
#define BITMAPCONVERTER_EXE wxT( "bitmap2component" )
#define PCB_CALCULATOR_EXE wxT( "pcb_calculator" )
#else
#define CVPCB_EXE wxT( "cvpcb.app/Contents/MacOS/cvpcb" )
#define PCBNEW_EXE wxT( "pcbnew.app/Contents/MacOS/pcbnew" )
#define EESCHEMA_EXE wxT( "eeschema.app/Contents/MacOS/eeschema" )
#define GERBVIEW_EXE wxT( "gerbview.app/Contents/MacOS/gerbview" )
#define BITMAPCONVERTER_EXE wxT( "bitmap2component.app/Contents/MacOS/bitmap2component" )
#define PCB_CALCULATOR_EXE wxT( "pcb_calculator.app/Contents/MacOS/pcb_calculator" )
# endif
#endif
......
......@@ -10,6 +10,7 @@
#include "kicad.h"
#include "../bitmap2component/bitmap2component.xpm"
#include "../pcb_calculator/bitmaps/pcb_calculator.xpm"
RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) :
wxSashLayoutWindow( parent, wxID_ANY )
......@@ -86,6 +87,9 @@ void RIGHT_KM_FRAME::CreateCommandToolbar( void )
btn = AddBitmapButton( ID_TO_BITMAP_CONVERTER, wxBitmap( bitmap2component_xpm ) );
btn->SetToolTip( _( "Bitmap2Component (a tool to build a logo from a bitmap)\n\
Creates a component (for Eeschema) or a footprint (for Pcbnew) that shows a B&W picture" ) );
btn = AddBitmapButton( ID_TO_PCB_CALCULATOR, wxBitmap( pcb_calculator_xpm ) );
btn->SetToolTip( _( "Pcb calculator" ) );
}
......
......@@ -44,6 +44,7 @@ enum id_kicad_frm {
ID_TO_EESCHEMA,
ID_TO_GERBVIEW,
ID_TO_BITMAP_CONVERTER,
ID_TO_PCB_CALCULATOR,
ID_BROWSE_AN_SELECT_FILE,
ID_SELECT_PREFERED_EDITOR,
ID_SELECT_PREFERED_PDF_BROWSER_NAME,
......@@ -93,6 +94,7 @@ public:
void OnRunEeschema( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event );
void OnRunBitmapConverter( wxCommandEvent& event );
void OnRunPcbCalculator( wxCommandEvent& event );
void OnOpenTextEditor( wxCommandEvent& event );
void OnOpenFileInTextEditor( wxCommandEvent& event );
......
......@@ -176,6 +176,10 @@ void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString );
}
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
{
ExecuteFile( this, PCB_CALCULATOR_EXE, wxEmptyString );
}
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
{
......
......@@ -51,6 +51,7 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
EVT_BUTTON( ID_TO_EESCHEMA, KICAD_MANAGER_FRAME::OnRunEeschema )
EVT_BUTTON( ID_TO_GERBVIEW, KICAD_MANAGER_FRAME::OnRunGerbview )
EVT_BUTTON( ID_TO_BITMAP_CONVERTER, KICAD_MANAGER_FRAME::OnRunBitmapConverter )
EVT_BUTTON( ID_TO_PCB_CALCULATOR, KICAD_MANAGER_FRAME::OnRunPcbCalculator )
EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser )
EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser )
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/bitmaps
${CMAKE_CURRENT_SOURCE_DIR}/dialogs
${CMAKE_CURRENT_SOURCE_DIR}/transline
${CMAKE_CURRENT_SOURCE_DIR}/attenuators
)
set(PCB_CALCULATOR_SRCS
attenuators.cpp
board_classes_values.cpp
pcb_calculator.cpp
pcb_calculator_frame.cpp
colorcode.cpp
params_read_write.cpp
regulators_funct.cpp
transline_ident.cpp
UnitSelector.cpp
transline/transline.cpp
transline/c_microstrip.cpp
transline/microstrip.cpp
transline/coplanar.cpp
transline/coax.cpp
transline/rectwaveguide.cpp
transline/stripline.cpp
transline/twistedpair.cpp
transline_dlg_funct.cpp
dialogs/pcb_calculator_frame_base.cpp
attenuators/attenuator_classes.cpp
)
if(WIN32)
if(MINGW)
# PCB_CALCULATOR_RESOURCES variable is set by the macro.
mingw_resource_compiler(pcb_calculator)
else(MINGW)
set(PCB_CALCULATOR_RESOURCES pcb_calculator.rc)
endif(MINGW)
endif(WIN32)
if(APPLE)
set(PCB_CALCULATOR_RESOURCES pcb_calculator.icns)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator.icns"
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(MACOSX_BUNDLE_ICON_FILE pcb_calculator.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad-eda.pcb_calculator)
endif(APPLE)
add_executable(pcb_calculator WIN32 MACOSX_BUNDLE
${PCB_CALCULATOR_SRCS}
${PCB_CALCULATOR_RESOURCES})
if(APPLE)
set_target_properties(pcb_calculator PROPERTIES MACOSX_BUNDLE_INFO_PLIST
${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
endif(APPLE)
target_link_libraries( pcb_calculator
${wxWidgets_LIBRARIES}
)
install(TARGETS pcb_calculator
DESTINATION ${KICAD_BIN}
COMPONENT binary)
/**
* @file UnitSelector.cpp
* a wxChoiceBox to select units in Pcb_Calculator
*/
#include "UnitSelector.h"
#include "units_scales.h"
UNIT_SELECTOR_LEN::UNIT_SELECTOR_LEN(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _("mm") );
Append( _("um") );
Append( _("cm") );
Append( _("mil") );
Append( _("inch") );
};
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units (meter )
*/
double UNIT_SELECTOR_LEN::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_MM; break;
case 1: return UNIT_MICRON; break;
case 2: return UNIT_CM; break;
case 3: return UNIT_MIL; break;
case 4: return UNIT_INCH; break;
}
return 1.0;
}
UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _("GHz") );
Append( _("MHz") );
Append( _("KHz") );
Append( _("Hz") );
};
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units (herz )
*/
double UNIT_SELECTOR_FREQUENCY::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_GHZ; break;
case 1: return UNIT_MHZ; break;
case 2: return UNIT_KHZ; break;
case 3: return 1.0; break;
}
return 1.0;
}
UNIT_SELECTOR_ANGLE::UNIT_SELECTOR_ANGLE(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _("Radian") );
Append( _("Degree") );
};
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units ( radian )
*/
double UNIT_SELECTOR_ANGLE::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_RADIAN; break;
case 1: return UNIT_DEGREE; break;
}
return 1.0;
}
UNIT_SELECTOR_RESISTOR::UNIT_SELECTOR_RESISTOR(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _("Ohm") );
Append( _("KOhm") );
};
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units ( ohm )
*/
double UNIT_SELECTOR_RESISTOR::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_OHM; break;
case 1: return UNIT_KOHM; break;
}
return 1.0;
}
/**
* @file UnitSelector.h
* a wxChoiceBox to select units in Pcb_Calculator
*/
#ifndef _UnitSelector_h_
#define _UnitSelector_h_
#include <wx/string.h>
#include <wx/choice.h>
class UNIT_SELECTOR: public wxChoice
{
public:
UNIT_SELECTOR(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style = 0 ):
wxChoice( parent, id, pos, size, choices, style )
{
}
/**
* Function GetUnitScale
* @return the scaling factor to convert users units
* to normalized units (meter, herz, ohm, radian )
*/
virtual double GetUnitScale() = 0;
};
class UNIT_SELECTOR_LEN: public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_LEN(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style = 0 );
/**
* Function GetUnitScale
* @return the scaling factor to convert users units
* to normalized units (meter)
*/
virtual double GetUnitScale();
};
class UNIT_SELECTOR_FREQUENCY: public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_FREQUENCY(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style = 0 );
/**
* Function GetUnitScale
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale();
};
class UNIT_SELECTOR_ANGLE: public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_ANGLE(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style = 0 );
/**
* Function GetUnitScale
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale();
};
class UNIT_SELECTOR_RESISTOR: public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_RESISTOR(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style = 0 );
/**
* Function GetUnitScale
* @return the scaling factor to convert users units
* to normalized units (Hz)
*/
virtual double GetUnitScale();
};
#endif // _UnitSelector_h_
/**
* @file attenuators.cpp
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 12011 jean-pierre.charras
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wx/wx.h"
#include "pcb_calculator.h"
#include "attenuator_classes.h"
extern double ReturnDoubleFromString( const wxString& TextValue );
// Called on a attenuator selection
void PCB_CALCULATOR_FRAME::OnAttenuatorSelection( wxCommandEvent& event )
{
SetAttenuator( (unsigned) event.GetSelection() );
Refresh();
}
void PCB_CALCULATOR_FRAME::SetAttenuator( unsigned aIdx )
{
if( aIdx >=m_attenuator_list.size() )
aIdx = m_attenuator_list.size() - 1;
m_currAttenuator = m_attenuator_list[aIdx];
TransfAttenuatorDataToPanel();
m_Attenuator_Messages->Clear();
m_Att_R1_Value->SetValue( wxEmptyString );
m_Att_R2_Value->SetValue( wxEmptyString );
m_Att_R3_Value->SetValue( wxEmptyString );
}
void PCB_CALCULATOR_FRAME::OnCalculateAttenuator( wxCommandEvent& event )
{
TransfPanelDataToAttenuator();
m_currAttenuator->Calculate();
TransfAttenuatorResultsToPanel();
}
void PCB_CALCULATOR_FRAME::TransfPanelDataToAttenuator()
{
wxString msg;
msg = m_AttValueCtrl->GetValue();
m_currAttenuator->m_Attenuation = ReturnDoubleFromString(msg);
msg = m_ZinValueCtrl->GetValue();
m_currAttenuator->m_Zin = ReturnDoubleFromString(msg);
msg = m_ZoutValueCtrl->GetValue();
m_currAttenuator->m_Zout = ReturnDoubleFromString(msg);
}
void PCB_CALCULATOR_FRAME::TransfAttenuatorDataToPanel()
{
wxString msg;
msg.Printf( wxT( "%f" ), m_currAttenuator->m_Attenuation );
m_AttValueCtrl->SetValue( msg );
m_AttValueCtrl->Enable( m_currAttenuator->m_Attenuation_Enable );
m_ZinValueCtrl->Enable( m_currAttenuator->m_Zin_Enable );
if( m_currAttenuator->m_Zin_Enable )
msg.Printf( wxT( "%f" ), m_currAttenuator->m_Zin );
else
msg.Clear();;
m_ZinValueCtrl->SetValue( msg );
msg.Printf( wxT( "%f" ), m_currAttenuator->m_Zout );
m_ZoutValueCtrl->SetValue( msg );
}
void PCB_CALCULATOR_FRAME::TransfAttenuatorResultsToPanel()
{
wxString msg;
m_Attenuator_Messages->Clear();
if( m_currAttenuator->m_Error )
{
msg.Printf( _( "Error!\nSet attenuation more than %f dB" ),
m_currAttenuator->m_MinimumATT );
m_Attenuator_Messages->AppendText( msg );
msg = wxT( "--" );
m_Att_R1_Value->SetValue( msg );
m_Att_R2_Value->SetValue( msg );
if( m_currAttenuator->m_ResultCount >= 3 )
m_Att_R3_Value->SetValue( msg );
return;
}
msg.Printf( wxT( "%f" ), m_currAttenuator->m_R1 );
m_Att_R1_Value->SetValue( msg );
msg.Printf( wxT( "%f" ), m_currAttenuator->m_R2 );
m_Att_R2_Value->SetValue( msg );
if( m_currAttenuator->m_ResultCount < 3 )
m_Att_R3_Value->SetValue( wxEmptyString );
else
{
msg.Printf( wxT( "%f" ), m_currAttenuator->m_R3 );
m_Att_R3_Value->SetValue( msg );
}
}
void PCB_CALCULATOR_FRAME::OnPaintAttenuatorPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelDisplayAttenuator );
if( m_currAttenuator && m_currAttenuator->m_SchBitMap )
{
wxSize size = m_panelDisplayAttenuator->GetSize();
size.x -= m_currAttenuator->m_SchBitMap->GetWidth();
size.y -= m_currAttenuator->m_SchBitMap->GetHeight();
dc.DrawBitmap( *m_currAttenuator->m_SchBitMap, size.x / 2, size.y / 2 );
}
event.Skip();
}
void PCB_CALCULATOR_FRAME::OnPaintAttFormulaPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelAttFormula );
if( m_currAttenuator && m_currAttenuator->m_FormulaBitMap )
{
wxSize size = m_panelAttFormula->GetSize();
size.x -= m_currAttenuator->m_FormulaBitMap->GetWidth();
size.y -= m_currAttenuator->m_FormulaBitMap->GetHeight();
dc.DrawBitmap( *m_currAttenuator->m_FormulaBitMap, size.x / 2, size.y / 2 );
}
event.Skip();
}
/****************************************************************************
** From Qucs Attenuator Synthesis
** attenuator_classes.cpp
**
** since 2006/6/14
**
*****************************************************************************/
#include <math.h>
#include "attenuator_classes.h"
// Bitmaps:
#include "att_pi.xpm"
#include "att_tee.xpm"
#include "att_bridge.xpm"
#include "att_splitter.xpm"
#include "pi_formula.xpm"
#include "tee_formula.xpm"
#include "bridged_tee_formula.xpm"
#include "splitter_formula.xpm"
#ifndef NULL
#define NULL 0
#endif
ATTENUATOR::ATTENUATOR( ATTENUATORS_TYPE aTopology )
{
m_Name = wxT("att_base");
m_Error = false;
m_Topology = aTopology;
m_ResultCount = 3; // If 3 values must be calculated
m_Zin = 50; // Ohms
m_Zin_Enable = true;
m_Zout = 50; // Ohms
m_Attenuation = 6.0; // dB
m_Attenuation_Enable = true;
m_MinimumATT = 0.0; // dB
m_SchBitMap = NULL;
m_FormulaBitMap = NULL;
}
ATTENUATOR::~ATTENUATOR()
{
delete m_SchBitMap;
delete m_FormulaBitMap;
}
#define KEYWORD_ATTENUATOR_ATT wxT( "Attenuation" )
#define KEYWORD_ATTENUATOR_ZIN wxT( "Zin" )
#define KEYWORD_ATTENUATOR_ZOUT wxT( "Zout" )
#define KEYWORD_ATTENUATORS wxT( "Attenuators/" )
void ATTENUATOR::ReadConfig( wxConfig* aConfig )
{
aConfig->SetPath( KEYWORD_ATTENUATORS + m_Name );
if( m_Attenuation_Enable )
aConfig->Read( KEYWORD_ATTENUATOR_ATT, &m_Attenuation, 6.0 );
aConfig->Read( KEYWORD_ATTENUATOR_ZIN, &m_Zin, 50.0 );
aConfig->Read( KEYWORD_ATTENUATOR_ZOUT, &m_Zout, 50.0 );
aConfig->SetPath( wxT( "../.." ) );
}
void ATTENUATOR::WriteConfig( wxConfig* aConfig )
{
aConfig->SetPath( KEYWORD_ATTENUATORS + m_Name );
aConfig->Write( KEYWORD_ATTENUATOR_ATT, m_Attenuation );
aConfig->Write( KEYWORD_ATTENUATOR_ZIN, m_Zin );
aConfig->Write( KEYWORD_ATTENUATOR_ZOUT, m_Zout );
aConfig->SetPath( wxT( "../.." ) );
}
ATTENUATOR_PI::ATTENUATOR_PI() : ATTENUATOR( PI_TYPE )
{
m_Name = wxT("att_pi");
m_SchBitMap = new wxBitmap( att_pi_xpm );
m_FormulaBitMap = new wxBitmap( pi_formula_xpm );
}
bool ATTENUATOR_PI::Calculate()
{
if( !ATTENUATOR::Calculate() )
return false;
m_R2 = ( (L - 1) / 2 ) * sqrt( m_Zin * m_Zout / L );
m_R1 = 1 / ( ( (A / m_Zin) ) - (1 / m_R2) );
m_R3 = 1 / ( ( (A / m_Zout) ) - (1 / m_R2) );
return true;
}
ATTENUATOR_TEE::ATTENUATOR_TEE() : ATTENUATOR( TEE_TYPE )
{
m_Name = wxT("att_tee");
m_SchBitMap = new wxBitmap( att_tee_xpm );
m_FormulaBitMap = new wxBitmap( tee_formula_xpm );
}
bool ATTENUATOR_TEE::Calculate()
{
if( !ATTENUATOR::Calculate() )
return false;
m_R2 = ( 2 * sqrt( L * m_Zin * m_Zout ) ) / (L - 1);
m_R1 = m_Zin * A - m_R2;
m_R3 = m_Zout * A - m_R2;
return true;
}
ATTENUATOR_BRIDGE::ATTENUATOR_BRIDGE() : ATTENUATOR( BRIDGE_TYPE )
{
m_Name = wxT("att_bridge");
m_Zin_Enable = false;
m_ResultCount = 2;
m_SchBitMap = new wxBitmap( att_bridge_xpm );
m_FormulaBitMap = new wxBitmap( bridged_tee_formula_xpm );
}
bool ATTENUATOR_BRIDGE::Calculate()
{
m_Zin = m_Zout;
if( !ATTENUATOR::Calculate() )
return false;
L = pow( 10, m_Attenuation / 20 );
m_R1 = m_Zin * (L - 1);
m_R2 = m_Zin / (L - 1);
return true;
}
ATTENUATOR_SPLITTER::ATTENUATOR_SPLITTER() : ATTENUATOR( SPLITTER_TYPE )
{
m_Name = wxT("att_splitter");
m_Attenuation_Enable = false;
m_Attenuation = 6.0;
m_MinimumATT = 6.0;
m_Zin_Enable = false;
m_SchBitMap = new wxBitmap( att_splitter_xpm );
m_FormulaBitMap = new wxBitmap( splitter_formula_xpm );
}
bool ATTENUATOR_SPLITTER::Calculate()
{
m_Attenuation = 6.0;
m_Zin = m_Zout;
m_R1 = m_R2 = m_R3 = m_Zout / 3.0;
return true;
}
bool ATTENUATOR::Calculate()
{
L = pow( 10, m_Attenuation / 10 );
A = (L + 1) / (L - 1);
if( m_Zin > m_Zout )
{
Lmin = (2 * m_Zin / m_Zout) - 1 + 2 *
sqrt( m_Zin / m_Zout * (m_Zin / m_Zout - 1) );
}
else
{
Lmin = (2 * m_Zout / m_Zin) - 1 + 2 *
sqrt( m_Zout / m_Zin * (m_Zout / m_Zin - 1) );
}
m_MinimumATT = 10 * log10( Lmin );
if( m_MinimumATT > m_Attenuation )
{
m_Error = true;
return false;
}
m_Error = false;
return true;
}
/**
* @file attenuator_classes.h
*/
/*
* Attenuator Synthesis
*
* From Qucs
* Modified for Kicad
*/
#ifndef ATTENUATORFUNC_H
#define ATTENUATORFUNC_H
#include "wx/config.h"
#include <wx/bitmap.h>
enum ATTENUATORS_TYPE {
PI_TYPE,
TEE_TYPE,
BRIDGE_TYPE,
SPLITTER_TYPE
};
class ATTENUATOR
{
protected:
ATTENUATORS_TYPE m_Topology;
public:
wxString m_Name; // Identifier for config
int m_ResultCount; // Number of value to calculate, and therefore display
bool m_Error; // Set to true if values acnnot be calculated
double m_Zin; // Impedance of source
bool m_Zin_Enable; // Set to true when impedance of source has meaning
double m_Zout; // Impedance of load
double m_Attenuation; // Attenuation in dB
bool m_Attenuation_Enable; // Set to true when Attenuatiopn has meaning
double m_MinimumATT; // Minimun attenuation in dB from parameters
double m_R1; // value of R1
double m_R2; // value of R2
double m_R3; // value of R3 (if any)
wxBitmap* m_SchBitMap; // The schema of this attenuator
wxBitmap* m_FormulaBitMap; // The formula used to calcualte this attenuator
protected:
double Lmin, L, A; // internal variable for temporary use
protected:
// The constructor is protected, because this class is not intendent to be instancied
ATTENUATOR( ATTENUATORS_TYPE Topology );
public:
~ATTENUATOR();
/**
* Function Calculate
* calculates the values of components in attenuator
* @return true if ok, false if some values cannot be calculated
*/
virtual bool Calculate();
/**
* Function ReadConfig
* Read values stored in config for this attenuator
* @param aConfig = the config to use
*/
void ReadConfig( wxConfig* aConfig );
/**
* Function WriteConfig
* Read values stored in config for this attenuator
* @param aConfig = the config to use
*/
void WriteConfig( wxConfig* aConfig );
};
class ATTENUATOR_PI : public ATTENUATOR
{
public: ATTENUATOR_PI();
virtual bool Calculate();
};
class ATTENUATOR_TEE : public ATTENUATOR
{
public: ATTENUATOR_TEE();
virtual bool Calculate();
};
class ATTENUATOR_BRIDGE : public ATTENUATOR
{
public: ATTENUATOR_BRIDGE();
virtual bool Calculate();
};
class ATTENUATOR_SPLITTER : public ATTENUATOR
{
public: ATTENUATOR_SPLITTER();
virtual bool Calculate();
};
#endif // ATTENUATORFUNC_H
/* XPM */
const char *arrow_bottom_xpm[] = {
/* columns rows colors chars-per-pixel */
"22 22 16 1",
" c #FCFEFC",
". c #0C3A58",
"= c #23C1D8",
"+ c #DBEDF6",
"# c #040204",
": c #A8D2E0",
"- c #49DBE8",
"% c #14688D",
"* c #0C8EB3",
"o c #89C9DE",
"X c #244862",
"; c #139DC1",
"@ c #317D9C",
"$ c #70C0D8",
"& c #12ADCE",
"O c #C3E1ED",
/* pixels */
" ",
" ",
" ",
" ..XXX... ",
" .oO++O@# ",
" .+o$oo%# ",
" . O&*=%# ",
" . +$*-%# ",
" . O=*-%# ",
" . $&*=%# ",
" ......O$&;=;.X.... ",
" #@$oo:&**=;&;@%# ",
" #@+:$&*;&=-;%# ",
" #@ +$;;=-;%# ",
" #@ +$$-;%# ",
" #@ O-;%# ",
" #@+;%# ",
" #@%# ",
" ## ",
" ",
" ",
" "
};
/* XPM */
const char *arrow_top_xpm[] = {
/* columns rows colors chars-per-pixel */
"22 22 16 1",
"o c #7994B7",
"- c #27486C",
": c #74B9DC",
"& c #1286BD",
"X c #040B19",
"@ c #AFD3E7",
"O c #165686",
". c #0C3058",
" c #FBFEFC",
"+ c #2298C9",
"* c #74A6CC",
"$ c #8AC7E4",
"; c #147EB1",
"# c #1BABD6",
"% c #41C5E1",
"= c #206596",
/* pixels */
" ",
" ",
" ",
" .X ",
" .oOX ",
" .o +OX ",
" .o @#+OX ",
" .o @$#%+OX ",
" .o %+&#%+OX ",
" .o $*+&&+#%=OX ",
" .-=O=+&&&+&=OO.X ",
" ......++&&#;.....X ",
" X$@+&%=X ",
" - @:;%OX ",
" . $;%=X ",
" . @:;#OX ",
" .@*+;#OX ",
" .-=OOO.X ",
" XXXXXXXX ",
" ",
" ",
" "
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* XPM */
const char *pcb_calculator_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 16 1",
"o c #AC9D99",
"= c #6F5A87",
"- c #4242BA",
"& c #7E7EF7",
"# c #37357B",
"; c #9A5753",
"O c #997366",
". c #958280",
"@ c #342D4E",
"X c #B0816B",
" c None",
"$ c #3A1721",
"* c #6258B4",
": c #9C090B",
"+ c #5C433C",
"% c #6E5C55",
/* pixels */
" .XXX. ",
" oXo..OX o ",
" oX.+O.X.+@#$% ooo ",
" oX.+%X%&&&&*@+o o oo ",
" oOO%+.O&&&&&&*= o o ",
" .@@=X%+OX&&&&&&& o o ",
" oXX+@#&&&X%+%X&&&&&&& o o ",
" oOoX=&&&&OX%+OX&&&&&&& o o=$ ",
"O@O.OX..&O.%++OX&&&&&& oooooo-$o",
"+-O.+O.XX.%+++%..&&&& ooo oo--@O",
"@-*XO+++%%+++++%..&& oooo-----#+",
"$--=XO+++++%++++OX. oooo----##@@",
"$---OX..O..XO++++O ooo ---##@@@%",
"@----*OOXOOOXO+++oooo --##@@@@@.",
"%#----------OXO+oooo =#@@@@@@@@o",
".#----------*;Xooooo.X+@@@@@@%$ ",
" $=--------#$:$oooo++.X+@@@$%.+ ",
" +O+#-----$:;;:$. ++++.O+$++..+ ",
" o+O%$#--$::::::$.%++++.O. O..+ ",
" +$$::::::::;.%++++.X %..+ ",
" $:::::::::@O.%++++.X%.%+ ",
" +:::;:::::$..O.++++%.X$%o ",
" o$::+O:::::$O..+X.++++%.X ",
" ;:::Oo:::::+ O..+ X.++++%.X ",
" o$::;oo:::::$ O..+ X.++++%.o ",
" +::X o:::::$ .+$+ X.++oo.X ",
" $:o ;:::::$o %. X.% oOX ",
" +:::::::::o X.OO.X ",
" .::::::::% XXXXo ",
" +::::::$ oo ",
" +:::::o ",
" %$:$. "
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="256"
height="150"
id="svg2"
version="1.1"
inkscape:version="0.48.1 "
sodipodi:docname="regul.svg"
inkscape:export-filename="F:\kicad-launchpad\mytesting\pcb_calculator\bitmaps\sources\regul.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.0195312"
inkscape:cx="128"
inkscape:cy="122.0007"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1280"
inkscape:window-height="968"
inkscape:window-x="-4"
inkscape:window-y="-4"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3769"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-902.36218)">
<rect
style="fill:#f2f274;fill-opacity:1;stroke:#0000ff;stroke-width:2.70856905;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3757"
width="100"
height="90"
x="45"
y="917.36218"
rx="0.46518731"
ry="0.770051" />
<path
style="fill:none;stroke:#0000ff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:2;stroke-opacity:1;stroke-dasharray:none"
d="m 5.7075806,932.36216 39.0660404,0 0.601016,0"
id="path3767"
inkscape:connector-curvature="0" />
<path
style="fill:#800000;stroke:#800000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 145,932.36216 109.03021,0 1.67737,0"
id="path3767-5"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:25.21309471px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#800000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="160.62158"
y="927.8587"
id="text3789"
sodipodi:linespacing="125%"
transform="scale(1.0005354,0.99946488)"><tspan
sodipodi:role="line"
id="tspan3791"
x="160.62158"
y="927.8587"
style="fill:#800000;fill-opacity:1;stroke:none">VOUT</tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot3793"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
transform="translate(0,924.36218)"><flowRegion
id="flowRegion3795"><rect
id="rect3797"
width="69.019989"
height="28.36969"
x="320.98001"
y="-580.36969" /></flowRegion><flowPara
id="flowPara3799" /></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot3801"
style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
transform="translate(0,924.36218)"><flowRegion
id="flowRegion3803"><rect
id="rect3805"
width="133.74167"
height="52.57431"
x="315.44586"
y="-596.97211" /></flowRegion><flowPara
id="flowPara3807" /></flowRoot> <text
xml:space="preserve"
style="font-size:25.66092873px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#3729c3;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="1.4928155"
y="944.83636"
id="text3789-2"
sodipodi:linespacing="125%"
transform="scale(1.0183069,0.98202221)"><tspan
sodipodi:role="line"
id="tspan3791-3"
x="1.4928155"
y="944.83636"
style="fill:#3729c3;fill-opacity:1;stroke:none">Vin</tspan></text>
<path
style="fill:none;stroke:#0000ff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 90.000001,1007.3622 0,35 0,0"
id="path3830"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 80.000001,1042.3622 20.166509,0 0,0"
id="path3832"
inkscape:connector-curvature="0" />
<path
style="fill:#800000;stroke:#800000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:2;stroke-opacity:1;stroke-dasharray:none"
d="m 145.70758,987.36218 49.29242,0 0.75833,0"
id="path3767-5-1"
inkscape:connector-curvature="0" />
<rect
style="fill:#f3f36e;fill-opacity:1;stroke:#800000;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3898"
width="20"
height="40"
x="185"
y="942.36218"
rx="0.46518731"
ry="0.68448979" />
<rect
style="fill:#f2f26c;fill-opacity:1;stroke:#800000;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3898-6"
width="20"
height="40"
x="185"
y="992.36218"
rx="0.46518731"
ry="0.68448979" />
<text
xml:space="preserve"
style="font-size:22.56652641px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#800000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="240.08633"
y="866.28369"
id="text3789-8"
sodipodi:linespacing="125%"
transform="scale(0.89551121,1.1166806)"><tspan
sodipodi:role="line"
id="tspan3791-8"
x="240.08633"
y="866.28369"
style="fill:#800000;fill-opacity:1;stroke:none">R1</tspan></text>
<text
xml:space="preserve"
style="font-size:22.56652641px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#800000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="240.08633"
y="911.0592"
id="text3789-8-2"
sodipodi:linespacing="125%"
transform="scale(0.89551121,1.1166806)"><tspan
sodipodi:role="line"
id="tspan3791-8-7"
x="240.08633"
y="911.0592"
style="fill:#800000;fill-opacity:1;stroke:none">R2</tspan></text>
<path
style="fill:#800000;stroke:#800000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 195,932.36216 0,10 0,0"
id="path3960"
inkscape:connector-curvature="0" />
<path
style="fill:#800000;stroke:#800000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 195,982.36216 0,10.00002 0,0"
id="path3960-7"
inkscape:connector-curvature="0" />
<path
style="fill:#800000;stroke:#800000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 195,1032.3622 0,10 0,0"
id="path3960-1"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 184.83349,1042.3622 20.16651,0 0,0"
id="path3832-2"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:26.76031494px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#800000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="80.369926"
y="1059.1328"
id="text3789-6"
sodipodi:linespacing="125%"
transform="scale(1.061934,0.9416781)"><tspan
sodipodi:role="line"
id="tspan3791-0"
x="80.369926"
y="1059.1328"
style="fill:#800000;fill-opacity:1;stroke:none">Vref</tspan></text>
<path
style="fill:#800000;stroke:#800000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 245.70758,922.36218 10,10 -10,10 z"
id="path3794"
inkscape:connector-curvature="0" />
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/app.h>
#include <wx/config.h>
#include <wx/msgdlg.h>
#include "pcb_calculator_frame_base.h"
#include "pcb_calculator.h"
#include "UnitSelector.h"
#include "units_scales.h"
// A helper class to handle min values
// Values are in meters.
// Note : use -1.0 when a vaule is irrelevant in a class
class BOARD_MIN_SIZE_VALUES
{
public:
int m_Class; // Class Id
double m_Lines; // min copper lines width
double m_Clearance; // min dist between copper lines
double m_ViaDiamDiff; // Min value for diff between Via diameter
// and its hole diameter
double m_PadDiamDiffPlated; // Min value for diff between Pad diameter
// and its hole diameter (plated)
double m_PadDiamDiffNotPlated; // Min value for diff between Pad diameter
// and its hole diameter (not plated)
public:
BOARD_MIN_SIZE_VALUES( int aClass, double aLines,
double aClearance, double aViaDiffPlated,
double aPadDiffPlated , double aPadDiffNotPlated )
{
m_Class = aClass;
m_Lines = aLines;
m_Clearance = aClearance;
m_ViaDiamDiff = aViaDiffPlated;
m_PadDiamDiffPlated = aPadDiffPlated;
m_PadDiamDiffNotPlated = aPadDiffNotPlated;
}
};
#define BRDCLASS_COUNT 6
static BOARD_MIN_SIZE_VALUES clist[BRDCLASS_COUNT] =
{
// class 1
BOARD_MIN_SIZE_VALUES(1, 0.80*UNIT_MM, 0.68*UNIT_MM,
-1.0,
1.19*UNIT_MM, 1.57*UNIT_MM ),
// class 2
BOARD_MIN_SIZE_VALUES(1, 0.50*UNIT_MM, 0.50*UNIT_MM,
-1.0,
0.78*UNIT_MM, 1.13*UNIT_MM ),
// class 3
BOARD_MIN_SIZE_VALUES(1, 0.31*UNIT_MM, 0.31*UNIT_MM,
0.45*UNIT_MM,
0.6*UNIT_MM, 0.90*UNIT_MM ),
// class 4
BOARD_MIN_SIZE_VALUES(1, 0.21*UNIT_MM, 0.21*UNIT_MM,
0.34*UNIT_MM,
0.49*UNIT_MM, -1.0 ),
// class 5
BOARD_MIN_SIZE_VALUES(1, 0.15*UNIT_MM, 0.15*UNIT_MM,
0.24*UNIT_MM,
0.39*UNIT_MM, -1.0 ),
// class 6
BOARD_MIN_SIZE_VALUES(1, 0.12*UNIT_MM, 0.12*UNIT_MM,
0.20*UNIT_MM,
0.35*UNIT_MM, -1.0 )
};
void PCB_CALCULATOR_FRAME::OnBoardClassesUnitsSelection( wxCommandEvent& event )
{
BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() );
}
void PCB_CALCULATOR_FRAME::BoardClassesUpdateData( double aUnitScale )
{
wxString txt;
for( int ii = 0; ii < BRDCLASS_COUNT; ii ++ )
{
// Display min tracks width
if( clist[ii].m_Lines > -1.0 )
txt.Printf( wxT("%f"), clist[ii].m_Lines / aUnitScale);
else
txt = wxT("--");
m_gridClassesValuesDisplay->SetCellValue(0, ii, txt );
// Display min clearance
if( clist[ii].m_Clearance > -1.0 )
txt.Printf( wxT("%f"), clist[ii].m_Clearance / aUnitScale);
else
txt = wxT("--");
m_gridClassesValuesDisplay->SetCellValue(1, ii, txt );
// Display min Via diam diff
if( clist[ii].m_ViaDiamDiff > -1.0 )
txt.Printf( wxT("%f"), clist[ii].m_ViaDiamDiff / aUnitScale);
else
txt = wxT("--");
m_gridClassesValuesDisplay->SetCellValue(2, ii, txt );
// Display min Pad diam diff (plated)
if( clist[ii].m_PadDiamDiffPlated > -1.0 )
txt.Printf( wxT("%f"), clist[ii].m_PadDiamDiffPlated / aUnitScale);
else
txt = wxT("--");
m_gridClassesValuesDisplay->SetCellValue(3, ii, txt );
// Display min Pad diam diff (non plated)
if( clist[ii].m_PadDiamDiffNotPlated > -1.0 )
txt.Printf( wxT("%f"), clist[ii].m_PadDiamDiffNotPlated / aUnitScale);
else
txt = wxT("--");
m_gridClassesValuesDisplay->SetCellValue(4, ii, txt );
}
}
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/app.h>
#include <wx/config.h>
#include <wx/msgdlg.h>
#include "pcb_calculator_frame_base.h"
#include "pcb_calculator.h"
void PCB_CALCULATOR_FRAME::OnToleranceSelection( wxCommandEvent& event )
{
ToleranceSelection( event.GetSelection() );
}
void PCB_CALCULATOR_FRAME::ToleranceSelection( int aSelection )
{
/* For tolerance = 5 or 10 %, there are 3 ring for the value
* but for tolerance < 5 %, there are 4 ring
*/
bool enable = true;
switch( aSelection )
{
case 0:
case 1:
enable = false;
break;
default:
break;
}
bool oldstate = m_Band4Label->IsShown();
if( oldstate != enable )
{
m_Band4bitmap->Show(enable);
m_Band4Label->Show(enable);
// m_Band4Label visibility has changed:
// The new size must be taken in account
m_panelColorCode->GetSizer()->Layout();
m_panelColorCode->Refresh();
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wx/wx.h"
#include "wx/config.h"
#include "pcb_calculator_frame_base.h"
#include "pcb_calculator.h"
// PCB_CALCULATOR_APP
class PCB_CALCULATOR_APP : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP( PCB_CALCULATOR_APP )
///-----------------------------------------------------------------------------
// PCB_CALCULATOR_APP
// main program
//-----------------------------------------------------------------------------
bool PCB_CALCULATOR_APP::OnInit()
{
SetVendorName( wxT( "kicad" ) );
wxFrame* frame = new PCB_CALCULATOR_FRAME( NULL );
SetTopWindow( frame );
frame->Show( true );
return true;
}
This diff is collapsed.
pcb_calculator_icon ICON pcb_calculator.ico
#include "wx/msw/wx.rc"
This diff is collapsed.
/**
* @file regulators_funct.cpp
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2011 Kicad Developers, see change_log.txt for contributors.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wx/wx.h"
#include "wx/config.h"
#include "pcb_calculator.h"
extern double ReturnDoubleFromString( const wxString& TextValue );
void PCB_CALCULATOR_FRAME::OnRegulatorCalcButtonClick( wxCommandEvent& event )
{
RegulatorsSolve();
}
// Calculate a value from the 3 other values
// Vref is given by the regulator properties, so
// we can calculate only R1, R2 or Vout
void PCB_CALCULATOR_FRAME::RegulatorsSolve()
{
int id;
if( m_rbRegulR1->GetValue() )
id = 0; // for R1 calculation
else if( m_rbRegulR2->GetValue() )
id = 1; // for R2 calculation
else if( m_rbRegulVout->GetValue() )
id = 2; // for Vout calculation
else
{
wxMessageBox( wxT("Selection error" ) );
return;
}
double r1, r2, vref, vout;
wxString txt;
m_RegulMessage->SetLabel( wxEmptyString);
// Read values from panel:
txt = m_RegulR1Value->GetValue();
r1 = ReturnDoubleFromString(txt);
txt = m_RegulR2Value->GetValue();
r2 = ReturnDoubleFromString(txt);
txt = m_RegulVrefValue->GetValue();
vref = ReturnDoubleFromString(txt);
txt = m_RegulVoutValue->GetValue();
vout = ReturnDoubleFromString(txt);
// Some tests:
if( vout < vref && id != 2)
{
m_RegulMessage->SetLabel( _(" Vout must be greater than vref" ) );
return;
}
if( vref == 0.0 )
{
m_RegulMessage->SetLabel( _(" Vref set to 0 !" ) );
return;
}
if( (r1 < 0 && id != 0 ) || (r2 <= 0 && id != 1) )
{
m_RegulMessage->SetLabel( _("Incorrect value for R1 R2" ) );
return;
}
// Calculate
switch( id )
{
case 0:
r1 = ( vout / vref - 1 ) * r2;
break;
case 1:
r2 = r1 / ( vout / vref - 1);
break;
case 2:
vout = vref * (r1 + r2) / r2;
break;
}
// write values to panel:
txt.Printf(wxT("%f"), r1);
m_RegulR1Value->SetValue(txt);
txt.Printf(wxT("%f"), r2);
m_RegulR2Value->SetValue(txt);
txt.Printf(wxT("%f"), vref);
m_RegulVrefValue->SetValue(txt);
txt.Printf(wxT("%f"), vout);
m_RegulVoutValue->SetValue(txt);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment