Move eseries helper class to common.
Also improves some terminology for english-speakers. Also substitues [] vector access (which creates empty elements) over at() (which throws if the item is not found).
This commit is contained in:
parent
4c63b4e061
commit
c0e0cbceb0
|
@ -183,7 +183,7 @@ set( COMMON_WIDGET_SRCS
|
|||
widgets/grid_text_button_helpers.cpp
|
||||
widgets/grid_text_helpers.cpp
|
||||
widgets/indicator_icon.cpp
|
||||
widgets/wx_infobar.cpp
|
||||
widgets/wx_infobar.cpp
|
||||
widgets/layer_box_selector.cpp
|
||||
widgets/lib_tree.cpp
|
||||
widgets/mathplot.cpp
|
||||
|
@ -321,10 +321,11 @@ set( COMMON_SRCS
|
|||
eda_units.cpp
|
||||
env_paths.cpp
|
||||
env_vars.cpp
|
||||
eseries.cpp
|
||||
exceptions.cpp
|
||||
executable_names.cpp
|
||||
filename_resolver.cpp
|
||||
file_history.cpp
|
||||
file_history.cpp
|
||||
filter_reader.cpp
|
||||
footprint_filter.cpp
|
||||
footprint_info.cpp
|
||||
|
|
|
@ -0,0 +1,386 @@
|
|||
/*
|
||||
* This program source code file
|
||||
* is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 <janvi@veith.net>
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include "eseries.h"
|
||||
|
||||
/*
|
||||
* If BENCHMARK is defined, any 4R E12 calculations will print its execution time to console
|
||||
* My Hasswell Enthusiast reports 225 mSec what are reproducible within plusminus 2 percent
|
||||
*/
|
||||
//#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
#include <profile.h>
|
||||
#endif
|
||||
|
||||
|
||||
// Return a string from aValue (aValue is expected in ohms)
|
||||
// If aValue < 1000 the returned string is aValue with unit = R
|
||||
// If aValue >= 1000 the returned string is aValue/1000 with unit = K
|
||||
// with notation similar to 2K2
|
||||
// If aValue >= 1e6 the returned string is aValue/1e6 with unit = M
|
||||
// with notation = 1M
|
||||
static std::string strValue( double aValue )
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if( aValue < 1000.0 )
|
||||
{
|
||||
result = std::to_string( static_cast<int>( aValue ) );
|
||||
result += 'R';
|
||||
}
|
||||
else
|
||||
{
|
||||
double div = 1e3;
|
||||
int unit = 'K';
|
||||
|
||||
if( aValue >= 1e6 )
|
||||
{
|
||||
div = 1e6;
|
||||
unit = 'M';
|
||||
}
|
||||
|
||||
aValue /= div;
|
||||
|
||||
int integer = static_cast<int>( aValue );
|
||||
result = std::to_string(integer);
|
||||
result += unit;
|
||||
|
||||
// Add mantissa: 1 digit, suitable for series up to E24
|
||||
double mantissa = aValue - integer;
|
||||
|
||||
if( mantissa > 0 )
|
||||
result += std::to_string( static_cast<int>( (mantissa*10)+0.5 ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
E_SERIES::E_SERIES()
|
||||
{
|
||||
// Build the list of available resistor values in each En serie
|
||||
double listValuesE1[] = { E1_VALUES };
|
||||
double listValuesE3[] = { E3_VALUES };
|
||||
double listValuesE6[] = { E6_VALUES };
|
||||
double listValuesE12[] = { E12_VALUES };
|
||||
double listValuesE24[] = { E24_VALUES };
|
||||
// buildSeriesData must be called in the order of En series, because
|
||||
// the list of series is expected indexed by En for the serie En
|
||||
buildSeriesData( listValuesE1 );
|
||||
buildSeriesData( listValuesE3 );
|
||||
buildSeriesData( listValuesE6 );
|
||||
buildSeriesData( listValuesE12 );
|
||||
int count = buildSeriesData( listValuesE24 );
|
||||
|
||||
// Reserve a buffer for intermediate calculations:
|
||||
// the buffer size is 2*count*count to store all combinaisons of 2 values
|
||||
// there are 2*count*count = 29282 combinations for E24
|
||||
int bufsize = 2*count*count;
|
||||
m_combined_table.reserve( bufsize );
|
||||
|
||||
// Store predefined R_DATA items.
|
||||
for( int ii = 0; ii < bufsize; ii++ )
|
||||
m_combined_table.emplace_back( "", 0.0 );
|
||||
}
|
||||
|
||||
|
||||
int E_SERIES::buildSeriesData( const double aList[] )
|
||||
{
|
||||
double curr_decade = FIRST_VALUE;
|
||||
int count = 0;
|
||||
|
||||
std::vector<R_DATA> curr_list;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
double curr_r;
|
||||
|
||||
for( int ii = 0; ; ii++ )
|
||||
{
|
||||
if( aList[ii] == 0.0 ) // End of list
|
||||
break;
|
||||
|
||||
curr_r = curr_decade * aList[ii];
|
||||
curr_list.emplace_back( strValue( curr_r ), curr_r );
|
||||
count++;
|
||||
|
||||
if( curr_r >= LAST_VALUE )
|
||||
break;
|
||||
}
|
||||
|
||||
if( curr_r >= LAST_VALUE )
|
||||
break;
|
||||
|
||||
curr_decade *= 10;
|
||||
}
|
||||
|
||||
m_tables.push_back( std::move( curr_list ) );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::Exclude( double aValue )
|
||||
{
|
||||
if( aValue != 0.0 ) // if there is a value to exclude other than a wire jumper
|
||||
{
|
||||
for( R_DATA& i : m_tables[m_series] ) // then search it in the selected E-Series table
|
||||
{
|
||||
if( i.e_value == aValue ) // if the value to exclude is found
|
||||
i.e_use = false; // disable its use
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::simple_solution( uint32_t aSize )
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
m_results.at( S2R ).e_value = std::numeric_limits<double>::max(); // assume no 2R solution or max deviation
|
||||
|
||||
for( i = 0; i < aSize; i++ )
|
||||
{
|
||||
if( abs( m_combined_table.at( i ).e_value - m_required_value ) < abs( m_results.at( S2R ).e_value ) )
|
||||
{
|
||||
m_results[S2R].e_value = m_combined_table[ i ].e_value - m_required_value; // save signed deviation in Ohms
|
||||
m_results[S2R].e_name = m_combined_table[ i ].e_name; // save combination text
|
||||
m_results[S2R].e_use = true; // this is a possible solution
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::combine4( uint32_t aSize )
|
||||
{
|
||||
uint32_t i,j;
|
||||
double tmp;
|
||||
|
||||
m_results[S4R].e_use = false; // disable 4R solution, until
|
||||
m_results[S4R].e_value = m_results[S3R].e_value; // 4R becomes better than 3R solution
|
||||
|
||||
#ifdef BENCHMARK
|
||||
PROF_TIMER timer; // start timer to count execution time
|
||||
#endif
|
||||
|
||||
for( i = 0; i < aSize; i++ ) // 4R search outer loop
|
||||
{ // scan valid intermediate 2R solutions
|
||||
for( j = 0; j < aSize; j++ ) // inner loop combines all with itself
|
||||
{
|
||||
tmp = m_combined_table[i].e_value + m_combined_table[j].e_value; // calculate 2R+2R serial
|
||||
tmp -= m_required_value; // calculate 4R deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results.at(S4R).e_value ) ) // if new 4R is better
|
||||
{
|
||||
m_results[S4R].e_value = tmp; // save amount of benefit
|
||||
std::string s = "( ";
|
||||
s.append( m_combined_table[i].e_name ); // mention 1st 2 component
|
||||
s.append( " ) + ( " ); // in series
|
||||
s.append( m_combined_table[j].e_name ); // with 2nd 2 components
|
||||
s.append( " )" );
|
||||
m_results[S4R].e_name = s; // save the result and
|
||||
m_results[S4R].e_use = true; // enable for later use
|
||||
}
|
||||
|
||||
tmp = ( m_combined_table[i].e_value * m_combined_table[j].e_value ) /
|
||||
( m_combined_table[i].e_value + m_combined_table[j].e_value ); // calculate 2R|2R parallel
|
||||
tmp -= m_required_value; // calculate 4R deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results[S4R].e_value ) ) // if new 4R is better
|
||||
{
|
||||
m_results[S4R].e_value = tmp; // save amount of benefit
|
||||
std::string s = "( ";
|
||||
s.append( m_combined_table[i].e_name ); // mention 1st 2 component
|
||||
s.append( " ) | ( " ); // in parallel
|
||||
s.append( m_combined_table[j].e_name ); // with 2nd 2 components
|
||||
s.append( " )" );
|
||||
m_results[S4R].e_name = s; // save the result
|
||||
m_results[S4R].e_use = true; // enable later use
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BENCHMARK
|
||||
printf( "Calculation time = %d mS", timer.msecs() );
|
||||
fflush( 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::NewCalc()
|
||||
{
|
||||
for( R_DATA& i : m_combined_table )
|
||||
i.e_use = false; // before any calculation is done, assume that
|
||||
|
||||
for( R_DATA& i : m_results )
|
||||
i.e_use = false; // no combinations and no results are available
|
||||
|
||||
for( R_DATA& i : m_tables[m_series])
|
||||
i.e_use = true; // all selected E-values available
|
||||
}
|
||||
|
||||
|
||||
uint32_t E_SERIES::combine2()
|
||||
{
|
||||
uint32_t combi2R = 0; // target index counts calculated 2R combinations
|
||||
std::string s;
|
||||
|
||||
for( const R_DATA& i : m_tables[m_series] ) // outer loop to sweep selected source lookup table
|
||||
{
|
||||
if( i.e_use )
|
||||
{
|
||||
for( const R_DATA& j : m_tables[m_series] ) // inner loop to combine values with itself
|
||||
{
|
||||
if( j.e_use )
|
||||
{
|
||||
m_combined_table[combi2R].e_use = true;
|
||||
m_combined_table[combi2R].e_value = i.e_value + j.e_value; // calculate 2R serial
|
||||
s = i.e_name;
|
||||
s.append( " + " );
|
||||
m_combined_table[combi2R].e_name = s.append( j.e_name);
|
||||
combi2R++; // next destination
|
||||
m_combined_table[combi2R].e_use = true; // calculate 2R parallel
|
||||
m_combined_table[combi2R].e_value = i.e_value * j.e_value / ( i.e_value + j.e_value );
|
||||
s = i.e_name;
|
||||
s.append( " | " );
|
||||
m_combined_table[combi2R].e_name = s.append( j.e_name );
|
||||
combi2R++; // next destination
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return combi2R;
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::combine3( uint32_t aSize )
|
||||
{
|
||||
uint32_t j = 0;
|
||||
double tmp = 0; // avoid warning for being uninitialized
|
||||
std::string s;
|
||||
|
||||
m_results[S3R].e_use = false; // disable 3R solution, until 3R
|
||||
m_results[S3R].e_value = m_results[S2R].e_value; // becomes better than 2R solution
|
||||
|
||||
for( const R_DATA& i : m_tables[m_series] ) // 3R Outer loop to selected primary E series table
|
||||
{
|
||||
if( i.e_use ) // skip all excluded values
|
||||
{
|
||||
for( j = 0; j < aSize; j++ ) // inner loop combines with all 2R intermediate
|
||||
{ // results R+2R serial combi
|
||||
tmp = m_combined_table[j].e_value + i.e_value;
|
||||
tmp -= m_required_value; // calculate deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results[S3R].e_value ) ) // compare if better
|
||||
{ // then take it
|
||||
s = i.e_name; // mention 3rd component
|
||||
s.append( " + ( " ); // in series
|
||||
s.append( m_combined_table[j].e_name ); // with 2R combination
|
||||
s.append( " )" );
|
||||
m_results[S3R].e_name = s; // save S3R result
|
||||
m_results[S3R].e_value = tmp; // save amount of benefit
|
||||
m_results[S3R].e_use = true; // enable later use
|
||||
}
|
||||
|
||||
tmp = i.e_value * m_combined_table[j].e_value /
|
||||
( i.e_value + m_combined_table[j].e_value ); // calculate R + 2R parallel
|
||||
tmp -= m_required_value; // calculate deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results[S3R].e_value ) ) // compare if better
|
||||
{ // then take it
|
||||
s = i.e_name; // mention 3rd component
|
||||
s.append( " | ( " ); // in parallel
|
||||
s.append( m_combined_table[j].e_name ); // with 2R combination
|
||||
s.append( " )" );
|
||||
m_results[S3R].e_name = s;
|
||||
m_results[S3R].e_value = tmp; // save amount of benefit
|
||||
m_results[S3R].e_use = true; // enable later use
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a 3R result with remaining deviation consider to search a possibly better
|
||||
// 4R solution
|
||||
// calculate 4R for small series always
|
||||
if( m_results[S3R].e_use && tmp )
|
||||
combine4( aSize );
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::Calculate()
|
||||
{
|
||||
uint32_t no_of_2Rcombi = 0;
|
||||
|
||||
no_of_2Rcombi = combine2(); // combine all 2R combinations for selected E serie
|
||||
simple_solution( no_of_2Rcombi ); // search for simple 2 component solution
|
||||
|
||||
if( m_results[S2R].e_value ) // if simple 2R result is not exact
|
||||
combine3( no_of_2Rcombi ); // continiue searching for a possibly better solution
|
||||
|
||||
strip3();
|
||||
strip4();
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::strip3()
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( m_results[S3R].e_use ) // if there is a 3 term result available
|
||||
{ // what is connected either by two "|" or by 3 plus
|
||||
s = m_results[S3R].e_name;
|
||||
|
||||
if( ( std::count( s.begin(), s.end(), '+' ) == 2 )
|
||||
|| ( std::count( s.begin(), s.end(), '|' ) == 2 ) )
|
||||
{ // then strip one pair of braces
|
||||
s.erase( s.find( '(' ), 1 ); // it is known sure, this is available
|
||||
s.erase( s.find( ')' ), 1 ); // in any unstripped 3R result term
|
||||
m_results[S3R].e_name = s; // use stripped result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIES::strip4()
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( m_results[S4R].e_use ) // if there is a 4 term result available
|
||||
{ // what are connected either by 3 "+" or by 3 "|"
|
||||
s = m_results[S4R].e_name;
|
||||
|
||||
if( ( std::count( s.begin(), s.end(), '+' ) == 3 )
|
||||
|| ( std::count( s.begin(), s.end(), '|' ) == 3 ) )
|
||||
{ // then strip two pair of braces
|
||||
s.erase( s.find( '(' ), 1 ); // it is known sure, they are available
|
||||
s.erase( s.find( ')' ), 1 ); // in any unstripped 4R result term
|
||||
s.erase( s.find( '(' ), 1 );
|
||||
s.erase( s.find( ')' ), 1 );
|
||||
m_results[S4R].e_name = s; // use stripped result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +97,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a
|
|||
}
|
||||
|
||||
#ifndef KICAD_SPICE
|
||||
m_excludeFromSim->Hide();
|
||||
m_spiceFieldsButton->Hide();
|
||||
#endif
|
||||
|
||||
|
@ -182,8 +183,10 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
|||
|
||||
m_OptionPower->SetValue( m_libEntry->IsPower() );
|
||||
|
||||
#ifdef KICAD_SPICE
|
||||
LIB_FIELD* simEnableField = m_libEntry->FindField( SIM_MODEL::ENABLE_FIELD );
|
||||
m_excludeFromSim->SetValue( simEnableField && simEnableField->GetText() == wxT( "0" ) );
|
||||
#endif
|
||||
|
||||
m_excludeFromBomCheckBox->SetValue( !m_libEntry->GetIncludeInBom() );
|
||||
m_excludeFromBoardCheckBox->SetValue( !m_libEntry->GetIncludeOnBoard() );
|
||||
|
@ -229,6 +232,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
|||
|
||||
void DIALOG_LIB_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& event )
|
||||
{
|
||||
#ifdef KICAD_SPICE
|
||||
int simEnableFieldRow = -1;
|
||||
|
||||
for( int ii = MANDATORY_FIELDS; ii < m_grid->GetNumberRows(); ++ii )
|
||||
|
@ -261,6 +265,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& even
|
|||
}
|
||||
|
||||
OnModify();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -316,6 +316,7 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
|
|||
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_fieldsGrid, m_symbol );
|
||||
|
||||
#ifndef KICAD_SPICE
|
||||
m_cbExcludeFromSim->Hide();
|
||||
m_spiceFieldsButton->Hide();
|
||||
#endif /* not KICAD_SPICE */
|
||||
|
||||
|
@ -513,7 +514,9 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
|||
case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
|
||||
}
|
||||
|
||||
#ifdef KICAD_SPICE
|
||||
m_cbExcludeFromSim->SetValue( m_symbol->GetFieldText( SIM_MODEL::ENABLE_FIELD ) == "0" );
|
||||
#endif
|
||||
m_cbExcludeFromBom->SetValue( !m_symbol->GetIncludeInBom() );
|
||||
m_cbExcludeFromBoard->SetValue( !m_symbol->GetIncludeOnBoard() );
|
||||
m_cbDNP->SetValue( m_symbol->GetDNP() );
|
||||
|
@ -537,6 +540,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
|||
|
||||
void DIALOG_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& event )
|
||||
{
|
||||
#ifdef KICAD_SPICE
|
||||
int simEnableFieldRow = -1;
|
||||
|
||||
for( int ii = MANDATORY_FIELDS; ii < m_fieldsGrid->GetNumberRows(); ++ii )
|
||||
|
@ -570,6 +574,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnExcludeFromSimulation( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
OnModify();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,16 +86,16 @@ struct R_DATA
|
|||
double e_value;
|
||||
};
|
||||
|
||||
class E_SERIE
|
||||
class E_SERIES
|
||||
{
|
||||
public:
|
||||
E_SERIE();
|
||||
E_SERIES();
|
||||
|
||||
/**
|
||||
* If any value of the selected E-serie not available, it can be entered as an exclude value.
|
||||
* If any value of the selected E-series not available, it can be entered as an exclude value.
|
||||
*
|
||||
* @param aValue is the value to exclude from calculation
|
||||
* Values to exclude are set to false in the selected E-serie source lookup table
|
||||
* Values to exclude are set to false in the selected E-series source lookup table
|
||||
*/
|
||||
void Exclude( double aValue );
|
||||
|
||||
|
@ -120,17 +120,15 @@ public:
|
|||
|
||||
private:
|
||||
/**
|
||||
* Build the list of R_DATA existing for a given serie
|
||||
* Series are E1, E6 ..
|
||||
* The values are extracted from the E96_VALUES list
|
||||
* @return the count of items added in list
|
||||
* Add values from aList to m_tables. Covers all decades between FIRST_VALUE and LAST_VALUE.
|
||||
* @return the count of items added to m_tables.
|
||||
*/
|
||||
int buildSerieData( int aEserie, double aList[] );
|
||||
int buildSeriesData( const double aList[] );
|
||||
|
||||
/**
|
||||
* Build all 2R combinations from the selected E-serie values
|
||||
* Build all 2R combinations from the selected E-series values
|
||||
*
|
||||
* Pre-calculated value combinations are saved in intermediate look up table m_cmb_lut
|
||||
* Pre-calculated value combinations are saved in intermediate look up table m_combined_table
|
||||
* @return is the number of found combinations what also depends from exclude values
|
||||
*/
|
||||
uint32_t combine2();
|
||||
|
@ -138,7 +136,7 @@ private:
|
|||
/**
|
||||
* Search for closest two component solution
|
||||
*
|
||||
* @param aSize is the number of valid 2R combinations in m_cmb_lut on where to search
|
||||
* @param aSize is the number of valid 2R combinations in m_combined_table on where to search
|
||||
* The 2R result with smallest deviation will be saved in results
|
||||
*/
|
||||
void simple_solution( uint32_t aSize );
|
||||
|
@ -146,19 +144,20 @@ private:
|
|||
/**
|
||||
* Check if there is a better 3 R solution than previous one using only two components.
|
||||
*
|
||||
* @param aSize gives the number of available combinations to be checked inside m_cmb_lut
|
||||
* Therefore m_cmb_lut is combinated with the primary E-serie look up table
|
||||
* The 3R result with smallest deviation will be saved in results if better than 2R
|
||||
* @param aSize gives the number of available combinations to be checked inside
|
||||
* m_combined_table. Therefore m_combined_table is combined with the primary
|
||||
* E-series look up table. The 3R result with smallest deviation will be saved
|
||||
* in results if better than 2R
|
||||
*/
|
||||
void combine3( uint32_t aSize );
|
||||
|
||||
/**
|
||||
* Check if there is a better four component solution.
|
||||
*
|
||||
* @param aSsize gives the number of 2R combinations to be checked inside m_cmb_lut
|
||||
* Occupied calculation time depends from number of available E-serie values
|
||||
* with the power of 4 why execution for E12 is conditional with 4R check box
|
||||
* for the case the previously found 3R solution is already exact
|
||||
* @param aSsize gives the number of 2R combinations to be checked inside m_combined_table
|
||||
* Occupied calculation time depends from number of available E-series values with the power
|
||||
* of 4 why execution for E12 is conditional with 4R check box for the case the previously
|
||||
* found 3R solution is already exact
|
||||
*/
|
||||
void combine4( uint32_t aSize );
|
||||
|
||||
|
@ -181,9 +180,9 @@ private:
|
|||
void strip4();
|
||||
|
||||
private:
|
||||
std::vector<std::vector<R_DATA>> m_luts;
|
||||
std::vector<std::vector<R_DATA>> m_tables;
|
||||
|
||||
/* Note: intermediate calculations use m_cmb_lut
|
||||
/* Note: intermediate calculations use m_combined_table
|
||||
* if the biggest list is En, reserved array size should be 2*En*En of std::vector primary list.
|
||||
* 2 component combinations including redundant swappable terms are for the moment
|
||||
* ( using values between 10 ohms and 1Mohm )
|
||||
|
@ -193,10 +192,9 @@ private:
|
|||
* 7442 combinations for E12
|
||||
* 29282 combinations for E24
|
||||
*/
|
||||
std::vector<R_DATA> m_cmb_lut; // intermediate 2R combinations
|
||||
std::vector<R_DATA> m_combined_table; // intermediate 2R combinations
|
||||
|
||||
std::array<R_DATA, S4R+1> m_results; // 2R, 3R and 4R results
|
||||
uint32_t m_series = E6; // Radio Button State
|
||||
uint32_t m_enable_4R = false; // Check Box 4R enable
|
||||
double m_required_value = 0.0; // required Resistor
|
||||
std::array<R_DATA, S4R+1> m_results; // 2R, 3R and 4R results
|
||||
uint32_t m_series = E6; // Radio Button State
|
||||
double m_required_value = 0.0; // required Resistor
|
||||
};
|
|
@ -8,7 +8,6 @@ include_directories(
|
|||
)
|
||||
|
||||
set( PCB_CALCULATOR_SRCS
|
||||
eserie.cpp
|
||||
common_data.cpp
|
||||
params_read_write.cpp
|
||||
pcb_calculator_frame.cpp
|
||||
|
@ -26,8 +25,8 @@ set( PCB_CALCULATOR_SRCS
|
|||
calculator_panels/panel_corrosion_base.cpp
|
||||
calculator_panels/panel_electrical_spacing.cpp
|
||||
calculator_panels/panel_electrical_spacing_base.cpp
|
||||
calculator_panels/panel_eserie.cpp
|
||||
calculator_panels/panel_eserie_base.cpp
|
||||
calculator_panels/panel_eseries.cpp
|
||||
calculator_panels/panel_eseries_base.cpp
|
||||
calculator_panels/panel_fusing_current.cpp
|
||||
calculator_panels/panel_fusing_current_base.cpp
|
||||
calculator_panels/panel_regulator.cpp
|
||||
|
@ -220,7 +219,7 @@ endfunction()
|
|||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula )
|
||||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/tee_formula )
|
||||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula )
|
||||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/eserie_help )
|
||||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/eseries_help )
|
||||
md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/fusing_current_help )
|
||||
|
||||
set( DOCS_LIST
|
||||
|
@ -229,7 +228,7 @@ set( DOCS_LIST
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/attenuators/bridget_tee_formula.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/attenuators/splitter_formula.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/eserie_help.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/eseries_help.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fusing_current_help.h
|
||||
)
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 jean-pierre.charras
|
||||
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.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 3
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* see
|
||||
* http://www.desmith.net/NMdS/Electronics/TraceWidth.html
|
||||
* http://www.ultracad.com/articles/pcbtemp.pdf
|
||||
* for more info
|
||||
*/
|
||||
|
||||
#include <calculator_panels/panel_eserie.h>
|
||||
#include <pcb_calculator_settings.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
#include <i18n_utility.h> // For _HKI definition
|
||||
wxString eseries_help =
|
||||
#include "eserie_help.h"
|
||||
|
||||
|
||||
PANEL_E_SERIE::PANEL_E_SERIE( wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
long style, const wxString& name ) :
|
||||
PANEL_E_SERIE_BASE( parent, id, pos, size, style, name )
|
||||
{
|
||||
m_reqResUnits->SetLabel( wxT( "kΩ" ) );
|
||||
m_exclude1Units->SetLabel( wxT( "kΩ" ) );
|
||||
m_exclude2Units->SetLabel( wxT( "kΩ" ) );
|
||||
|
||||
// show markdown formula explanation in lower help panel
|
||||
wxString msg;
|
||||
ConvertMarkdown2Html( wxGetTranslation( eseries_help ), msg );
|
||||
m_panelESeriesHelp->SetPage( msg );
|
||||
|
||||
// Needed on wxWidgets 3.0 to ensure sizers are correctly set
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
PANEL_E_SERIE::~PANEL_E_SERIE()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIE::ThemeChanged()
|
||||
{
|
||||
// Update the HTML window with the help text
|
||||
m_panelESeriesHelp->ThemeChanged();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
||||
{
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 jean-pierre.charras
|
||||
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.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 3
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* see
|
||||
* http://www.desmith.net/NMdS/Electronics/TraceWidth.html
|
||||
* http://www.ultracad.com/articles/pcbtemp.pdf
|
||||
* for more info
|
||||
*/
|
||||
|
||||
#include <calculator_panels/panel_eseries.h>
|
||||
#include <pcb_calculator_settings.h>
|
||||
#include <string_utils.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
#include <i18n_utility.h> // For _HKI definition in eseries_help.h
|
||||
wxString eseries_help =
|
||||
#include "eseries_help.h"
|
||||
|
||||
|
||||
extern double DoubleFromString( const wxString& TextValue );
|
||||
|
||||
PANEL_E_SERIES::PANEL_E_SERIES( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style, const wxString& name ) :
|
||||
PANEL_E_SERIES_BASE( parent, id, pos, size, style, name )
|
||||
{
|
||||
m_reqResUnits->SetLabel( wxT( "kΩ" ) );
|
||||
m_exclude1Units->SetLabel( wxT( "kΩ" ) );
|
||||
m_exclude2Units->SetLabel( wxT( "kΩ" ) );
|
||||
|
||||
// show markdown formula explanation in lower help panel
|
||||
wxString msg;
|
||||
ConvertMarkdown2Html( wxGetTranslation( eseries_help ), msg );
|
||||
m_panelESeriesHelp->SetPage( msg );
|
||||
|
||||
// Needed on wxWidgets 3.0 to ensure sizers are correctly set
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
PANEL_E_SERIES::~PANEL_E_SERIES()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIES::ThemeChanged()
|
||||
{
|
||||
// Update the HTML window with the help text
|
||||
m_panelESeriesHelp->ThemeChanged();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIES::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIES::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIES::OnCalculateESeries( wxCommandEvent& event )
|
||||
{
|
||||
double reqr; // required resistor stored in local copy
|
||||
double error, err3 = 0;
|
||||
wxString es, fs; // error and formula strings
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
reqr = ( 1000 * DoubleFromString( m_ResRequired->GetValue() ) );
|
||||
m_eSeries.SetRequiredValue( reqr ); // keep a local copy of required resistor value
|
||||
m_eSeries.NewCalc(); // assume all values available
|
||||
/*
|
||||
* Exclude itself. For the case, a value from the available series is found as required value,
|
||||
* the calculator assumes this value needs a replacement for the reason of being not available.
|
||||
* Two further exclude values can be entered to exclude and are skipped as not being available.
|
||||
* All values entered in KiloOhms are converted to Ohm for internal calculation
|
||||
*/
|
||||
m_eSeries.Exclude( 1000 * DoubleFromString( m_ResRequired->GetValue()));
|
||||
m_eSeries.Exclude( 1000 * DoubleFromString( m_ResExclude1->GetValue()));
|
||||
m_eSeries.Exclude( 1000 * DoubleFromString( m_ResExclude2->GetValue()));
|
||||
|
||||
try
|
||||
{
|
||||
m_eSeries.Calculate();
|
||||
}
|
||||
catch (std::out_of_range const& exc)
|
||||
{
|
||||
wxString msg;
|
||||
msg << "Internal error: " << exc.what();
|
||||
|
||||
wxMessageBox( msg );
|
||||
return;
|
||||
}
|
||||
|
||||
fs = m_eSeries.GetResults()[S2R].e_name; // show 2R solution formula string
|
||||
m_ESeries_Sol2R->SetValue( fs );
|
||||
error = reqr + m_eSeries.GetResults()[S2R].e_value; // absolute value of solution
|
||||
error = ( reqr / error - 1 ) * 100; // error in percent
|
||||
|
||||
if( error )
|
||||
{
|
||||
if( std::abs( error ) < 0.01 )
|
||||
es.Printf( "<%.2f", 0.01 );
|
||||
else
|
||||
es.Printf( "%+.2f",error);
|
||||
}
|
||||
else
|
||||
{
|
||||
es = _( "Exact" );
|
||||
}
|
||||
|
||||
m_ESeriesError2R->SetValue( es ); // anyway show 2R error string
|
||||
|
||||
if( m_eSeries.GetResults()[S3R].e_use ) // if 3R solution available
|
||||
{
|
||||
err3 = reqr + m_eSeries.GetResults()[S3R].e_value; // calculate the 3R
|
||||
err3 = ( reqr / err3 - 1 ) * 100; // error in percent
|
||||
|
||||
if( err3 )
|
||||
{
|
||||
if( std::abs( err3 ) < 0.01 )
|
||||
es.Printf( "<%.2f", 0.01 );
|
||||
else
|
||||
es.Printf( "%+.2f",err3);
|
||||
}
|
||||
else
|
||||
{
|
||||
es = _( "Exact" );
|
||||
}
|
||||
|
||||
m_ESeriesError3R->SetValue( es ); // show 3R error string
|
||||
fs = m_eSeries.GetResults()[S3R].e_name;
|
||||
m_ESeries_Sol3R->SetValue( fs ); // show 3R formula string
|
||||
}
|
||||
else // nothing better than 2R found
|
||||
{
|
||||
fs = _( "Not worth using" );
|
||||
m_ESeries_Sol3R->SetValue( fs );
|
||||
m_ESeriesError3R->SetValue( wxEmptyString );
|
||||
}
|
||||
|
||||
fs = wxEmptyString;
|
||||
|
||||
if( m_eSeries.GetResults()[S4R].e_use ) // show 4R solution if available
|
||||
{
|
||||
fs = m_eSeries.GetResults()[S4R].e_name;
|
||||
|
||||
error = reqr + m_eSeries.GetResults()[S4R].e_value; // absolute value of solution
|
||||
error = ( reqr / error - 1 ) * 100; // error in percent
|
||||
|
||||
if( error )
|
||||
es.Printf( "%+.2f",error );
|
||||
else
|
||||
es = _( "Exact" );
|
||||
|
||||
m_ESeriesError4R->SetValue( es );
|
||||
}
|
||||
else // no 4R solution
|
||||
{
|
||||
fs = _( "Not worth using" );
|
||||
es = wxEmptyString;
|
||||
m_ESeriesError4R->SetValue( es );
|
||||
}
|
||||
|
||||
m_ESeries_Sol4R->SetValue( fs );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIES::OnESeriesSelection( wxCommandEvent& event )
|
||||
{
|
||||
if( event.GetEventObject() == m_e1 )
|
||||
m_eSeries.SetSeries( E1 );
|
||||
else if( event.GetEventObject() == m_e3 )
|
||||
m_eSeries.SetSeries( E3 );
|
||||
else if( event.GetEventObject() == m_e12 )
|
||||
m_eSeries.SetSeries( E12 );
|
||||
else if( event.GetEventObject() == m_e24 )
|
||||
m_eSeries.SetSeries( E24 );
|
||||
else
|
||||
m_eSeries.SetSeries( E6 );
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.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
|
||||
|
@ -17,22 +17,22 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PANEL_E_SERIE_H
|
||||
#define PANEL_E_SERIE_H
|
||||
#ifndef PANEL_E_SERIES_H
|
||||
#define PANEL_E_SERIES_H
|
||||
|
||||
#include "panel_eserie_base.h"
|
||||
#include "panel_eseries_base.h"
|
||||
#include <eseries.h>
|
||||
|
||||
class PCB_CALCULATOR_SETTINGS;
|
||||
|
||||
|
||||
class PANEL_E_SERIE : public PANEL_E_SERIE_BASE
|
||||
class PANEL_E_SERIES : public PANEL_E_SERIES_BASE
|
||||
{
|
||||
public:
|
||||
PANEL_E_SERIE( wxWindow* parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
~PANEL_E_SERIE();
|
||||
PANEL_E_SERIES( wxWindow* parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
~PANEL_E_SERIES();
|
||||
|
||||
// Methods from CALCULATOR_PANEL that must be overridden
|
||||
void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override;
|
||||
|
@ -45,11 +45,14 @@ public:
|
|||
void OnCalculateESeries( wxCommandEvent& event ) override;
|
||||
|
||||
/**
|
||||
* Radio Buttons to select the E-serie for the resistor calculator.
|
||||
* Radio Buttons to select the E-series for the resistor calculator.
|
||||
*
|
||||
* @param event contains the radio button state.
|
||||
*/
|
||||
void OnESeriesSelection( wxCommandEvent& event ) override;
|
||||
|
||||
private:
|
||||
E_SERIES m_eSeries;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,18 +1,18 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "panel_eserie_base.h"
|
||||
#include "panel_eseries_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : CALCULATOR_PANEL( parent, id, pos, size, style, name )
|
||||
PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : CALCULATOR_PANEL( parent, id, pos, size, style, name )
|
||||
{
|
||||
wxBoxSizer* bSizerESerie;
|
||||
bSizerESerie = new wxBoxSizer( wxVERTICAL );
|
||||
wxBoxSizer* bSizerESeries;
|
||||
bSizerESeries = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bMiddleSizerESeries;
|
||||
bMiddleSizerESeries = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
@ -93,70 +93,70 @@ PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id, const w
|
|||
wxStaticBoxSizer* sbSizerESeriesSolutions;
|
||||
sbSizerESeriesSolutions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Solutions") ), wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizerESerieResults;
|
||||
fgSizerESerieResults = new wxFlexGridSizer( 6, 5, 3, 0 );
|
||||
fgSizerESerieResults->AddGrowableCol( 1 );
|
||||
fgSizerESerieResults->SetFlexibleDirection( wxBOTH );
|
||||
fgSizerESerieResults->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
wxFlexGridSizer* fgSizerESeriesResults;
|
||||
fgSizerESeriesResults = new wxFlexGridSizer( 6, 5, 3, 0 );
|
||||
fgSizerESeriesResults->AddGrowableCol( 1 );
|
||||
fgSizerESeriesResults->SetFlexibleDirection( wxBOTH );
|
||||
fgSizerESeriesResults->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_ESerieSimpleSolution = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("Simple solution:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESerieSimpleSolution->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESerieSimpleSolution, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
m_ESeriesSimpleSolution = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("Simple solution:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesSimpleSolution->Wrap( -1 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesSimpleSolution, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
m_ESeries_Sol2R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerESerieResults->Add( m_ESeries_Sol2R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeries_Sol2R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_ESeriesSimpleErr = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("Approximation:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesSimpleErr->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesSimpleErr, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesSimpleErr, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
|
||||
|
||||
m_ESeriesError2R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerESerieResults->Add( m_ESeriesError2R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesError2R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 3 );
|
||||
|
||||
m_ESeriesSimplePercent = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesSimplePercent->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesSimplePercent, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesSimplePercent, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_ESerie3RSolution1 = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("3R solution:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESerie3RSolution1->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESerie3RSolution1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
m_ESeries3RSolution1 = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("3R solution:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeries3RSolution1->Wrap( -1 );
|
||||
fgSizerESeriesResults->Add( m_ESeries3RSolution1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
m_ESeries_Sol3R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeries_Sol3R->SetMinSize( wxSize( 220,-1 ) );
|
||||
|
||||
fgSizerESerieResults->Add( m_ESeries_Sol3R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeries_Sol3R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||
|
||||
m_ESeriesAltErr = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("Approximation:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesAltErr->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesAltErr, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesAltErr, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
|
||||
|
||||
m_ESeriesError3R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerESerieResults->Add( m_ESeriesError3R, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesError3R, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 3 );
|
||||
|
||||
m_ESeriesAltPercent = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesAltPercent->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesAltPercent, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesAltPercent, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
m_ESeries4RSolution = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("4R solution:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeries4RSolution->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeries4RSolution, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeries4RSolution, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
m_ESeries_Sol4R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerESerieResults->Add( m_ESeries_Sol4R, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxEXPAND, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeries_Sol4R, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxEXPAND, 5 );
|
||||
|
||||
m_ESeriesAltErr1 = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("Approximation:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesAltErr1->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesAltErr1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesAltErr1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
|
||||
|
||||
m_ESeriesError4R = new wxTextCtrl( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizerESerieResults->Add( m_ESeriesError4R, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesError4R, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 3 );
|
||||
|
||||
m_ESeriesAltPercent1 = new wxStaticText( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_ESeriesAltPercent1->Wrap( -1 );
|
||||
fgSizerESerieResults->Add( m_ESeriesAltPercent1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
fgSizerESeriesResults->Add( m_ESeriesAltPercent1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
|
||||
sbSizerESeriesSolutions->Add( fgSizerESerieResults, 0, wxBOTTOM|wxEXPAND, 5 );
|
||||
sbSizerESeriesSolutions->Add( fgSizerESeriesResults, 0, wxBOTTOM|wxEXPAND, 5 );
|
||||
|
||||
m_staticline7 = new wxStaticLine( sbSizerESeriesSolutions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
sbSizerESeriesSolutions->Add( m_staticline7, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
|
@ -174,44 +174,47 @@ PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id, const w
|
|||
bMiddleSizerESeries->Add( bSizer47, 1, wxALIGN_BOTTOM, 5 );
|
||||
|
||||
|
||||
bSizerESerie->Add( bMiddleSizerESeries, 0, wxEXPAND|wxTOP, 5 );
|
||||
bSizerESeries->Add( bMiddleSizerESeries, 0, wxEXPAND|wxTOP, 5 );
|
||||
|
||||
wxBoxSizer* bLowerESerie;
|
||||
bLowerESerie = new wxBoxSizer( wxHORIZONTAL );
|
||||
wxBoxSizer* bLowerESeries;
|
||||
bLowerESeries = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sbLowerSizerEseriesHelp;
|
||||
sbLowerSizerEseriesHelp = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Help") ), wxVERTICAL );
|
||||
|
||||
m_panelESeriesHelp = new HTML_WINDOW( sbLowerSizerEseriesHelp->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
|
||||
m_panelESeriesHelp->SetMinSize( wxSize( -1,100 ) );
|
||||
|
||||
sbLowerSizerEseriesHelp->Add( m_panelESeriesHelp, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bLowerESerie->Add( sbLowerSizerEseriesHelp, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
bLowerESeries->Add( sbLowerSizerEseriesHelp, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bSizerESerie->Add( bLowerESerie, 1, wxEXPAND, 5 );
|
||||
bSizerESeries->Add( bLowerESeries, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bSizerESerie );
|
||||
this->SetSizer( bSizerESeries );
|
||||
this->Layout();
|
||||
bSizerESeries->Fit( this );
|
||||
|
||||
// Connect Events
|
||||
m_e1->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e3->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e6->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e12->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e24->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_buttonEScalculate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnCalculateESeries ), NULL, this );
|
||||
m_e1->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e3->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e6->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e12->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e24->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_buttonEScalculate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnCalculateESeries ), NULL, this );
|
||||
}
|
||||
|
||||
PANEL_E_SERIE_BASE::~PANEL_E_SERIE_BASE()
|
||||
PANEL_E_SERIES_BASE::~PANEL_E_SERIES_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_e1->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e3->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e6->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e12->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e24->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_buttonEScalculate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_E_SERIE_BASE::OnCalculateESeries ), NULL, this );
|
||||
m_e1->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e3->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e6->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e12->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_e24->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnESeriesSelection ), NULL, this );
|
||||
m_buttonEScalculate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_E_SERIES_BASE::OnCalculateESeries ), NULL, this );
|
||||
|
||||
}
|
|
@ -11,13 +11,13 @@
|
|||
<property name="embedded_files_path">res</property>
|
||||
<property name="encoding">UTF-8</property>
|
||||
<property name="event_generation">connect</property>
|
||||
<property name="file">panel_eserie_base</property>
|
||||
<property name="file">panel_eseries_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">panel_eserie_base</property>
|
||||
<property name="name">panel_eseries_base</property>
|
||||
<property name="namespace"></property>
|
||||
<property name="path">.</property>
|
||||
<property name="precompiled_header"></property>
|
||||
|
@ -29,7 +29,7 @@
|
|||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Panel" expanded="1">
|
||||
<object class="Panel" expanded="0">
|
||||
<property name="aui_managed">0</property>
|
||||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||
<property name="bg"></property>
|
||||
|
@ -43,34 +43,34 @@
|
|||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">PANEL_E_SERIE_BASE</property>
|
||||
<property name="name">PANEL_E_SERIES_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">887,453</property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="subclass">CALCULATOR_PANEL; calculator_panels/calculator_panel.h; </property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerESerie</property>
|
||||
<property name="name">bSizerESeries</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxTOP</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bMiddleSizerESeries</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<object class="wxStaticBoxSizer" expanded="0">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Inputs</property>
|
||||
<property name="minimum_size"></property>
|
||||
|
@ -712,7 +712,7 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
|
@ -1073,7 +1073,7 @@
|
|||
<property name="growablerows"></property>
|
||||
<property name="hgap">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">fgSizerESerieResults</property>
|
||||
<property name="name">fgSizerESeriesResults</property>
|
||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="rows">6</property>
|
||||
|
@ -1119,7 +1119,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_ESerieSimpleSolution</property>
|
||||
<property name="name">m_ESeriesSimpleSolution</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -1204,7 +1204,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="0">
|
||||
|
@ -1265,7 +1265,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
|
@ -1430,7 +1430,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_ESerie3RSolution1</property>
|
||||
<property name="name">m_ESeries3RSolution1</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -1515,7 +1515,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="0">
|
||||
|
@ -1576,7 +1576,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
|
@ -1826,7 +1826,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="0">
|
||||
|
@ -1887,8 +1887,8 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxTextCtrl" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -2160,20 +2160,20 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bLowerESerie</property>
|
||||
<property name="name">bLowerESeries</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<object class="wxStaticBoxSizer" expanded="0">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Help</property>
|
||||
<property name="minimum_size"></property>
|
||||
|
@ -2218,7 +2218,7 @@
|
|||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="minimum_size">-1,100</property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_panelESeriesHelp</property>
|
||||
<property name="pane_border">1</property>
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -34,9 +34,9 @@
|
|||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class PANEL_E_SERIE_BASE
|
||||
/// Class PANEL_E_SERIES_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class PANEL_E_SERIE_BASE : public CALCULATOR_PANEL
|
||||
class PANEL_E_SERIES_BASE : public CALCULATOR_PANEL
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -56,12 +56,12 @@ class PANEL_E_SERIE_BASE : public CALCULATOR_PANEL
|
|||
wxRadioButton* m_e6;
|
||||
wxRadioButton* m_e12;
|
||||
wxRadioButton* m_e24;
|
||||
wxStaticText* m_ESerieSimpleSolution;
|
||||
wxStaticText* m_ESeriesSimpleSolution;
|
||||
wxTextCtrl* m_ESeries_Sol2R;
|
||||
wxStaticText* m_ESeriesSimpleErr;
|
||||
wxTextCtrl* m_ESeriesError2R;
|
||||
wxStaticText* m_ESeriesSimplePercent;
|
||||
wxStaticText* m_ESerie3RSolution1;
|
||||
wxStaticText* m_ESeries3RSolution1;
|
||||
wxTextCtrl* m_ESeries_Sol3R;
|
||||
wxStaticText* m_ESeriesAltErr;
|
||||
wxTextCtrl* m_ESeriesError3R;
|
||||
|
@ -82,9 +82,9 @@ class PANEL_E_SERIE_BASE : public CALCULATOR_PANEL
|
|||
|
||||
public:
|
||||
|
||||
PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 887,453 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
PANEL_E_SERIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
|
||||
~PANEL_E_SERIE_BASE();
|
||||
~PANEL_E_SERIES_BASE();
|
||||
|
||||
};
|
||||
|
|
@ -1,512 +0,0 @@
|
|||
/*
|
||||
* This program source code file
|
||||
* is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 <janvi@veith.net>
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
#include <calculator_panels/panel_eserie.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
/* If BENCHMARK is defined, any 4R E12 calculations will print its execution time to console
|
||||
* My Hasswell Enthusiast reports 225 mSec what are reproducible within plusminus 2 percent
|
||||
*/
|
||||
//#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
#include <profile.h>
|
||||
#endif
|
||||
|
||||
#include "eserie.h"
|
||||
|
||||
extern double DoubleFromString( const wxString& TextValue );
|
||||
|
||||
E_SERIE r;
|
||||
|
||||
// Return a string from aValue (aValue is expected in ohms)
|
||||
// If aValue < 1000 the returned string is aValue with unit = R
|
||||
// If aValue >= 1000 the returned string is aValue/1000 with unit = K
|
||||
// with notation similar to 2K2
|
||||
// If aValue >= 1e6 the returned string is aValue/1e6 with unit = M
|
||||
// with notation = 1M
|
||||
static std::string strValue( double aValue )
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if( aValue < 1000.0 )
|
||||
{
|
||||
result = std::to_string( static_cast<int>( aValue ) );
|
||||
result += 'R';
|
||||
}
|
||||
else
|
||||
{
|
||||
double div = 1e3;
|
||||
int unit = 'K';
|
||||
|
||||
if( aValue >= 1e6 )
|
||||
{
|
||||
div = 1e6;
|
||||
unit = 'M';
|
||||
}
|
||||
|
||||
aValue /= div;
|
||||
|
||||
int integer = static_cast<int>( aValue );
|
||||
result = std::to_string(integer);
|
||||
result += unit;
|
||||
|
||||
// Add mantissa: 1 digit, suitable for series up to E24
|
||||
double mantissa = aValue - integer;
|
||||
|
||||
if( mantissa > 0 )
|
||||
result += std::to_string( static_cast<int>( (mantissa*10)+0.5 ) );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
E_SERIE::E_SERIE()
|
||||
{
|
||||
// Build the list of available resistor values in each En serie
|
||||
double listValuesE1[] = { E1_VALUES };
|
||||
double listValuesE3[] = { E3_VALUES };
|
||||
double listValuesE6[] = { E6_VALUES };
|
||||
double listValuesE12[] = { E12_VALUES };
|
||||
double listValuesE24[] = { E24_VALUES };
|
||||
// buildSerieData must be called in the order of En series, because
|
||||
// the list of series is expected indexed by En for the serie En
|
||||
buildSerieData( E1, listValuesE1 );
|
||||
buildSerieData( E3, listValuesE3 );
|
||||
buildSerieData( E6, listValuesE6 );
|
||||
buildSerieData( E12, listValuesE12 );
|
||||
int count = buildSerieData( E24, listValuesE24 );
|
||||
|
||||
// Reserve a buffer for intermediate calculations:
|
||||
// the buffer size is 2*count*count to store all combinaisons of 2 values
|
||||
// there are 2*count*count = 29282 combinations for E24
|
||||
int bufsize = 2*count*count;
|
||||
m_cmb_lut.reserve( bufsize );
|
||||
|
||||
// Store predefined R_DATA items.
|
||||
for( int ii = 0; ii < bufsize; ii++ )
|
||||
m_cmb_lut.emplace_back( "", 0.0 );
|
||||
}
|
||||
|
||||
|
||||
int E_SERIE::buildSerieData( int aEserie, double aList[] )
|
||||
{
|
||||
double curr_coeff = FIRST_VALUE;
|
||||
int count = 0;
|
||||
|
||||
std::vector<R_DATA> curr_list;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
double curr_r = curr_coeff;
|
||||
|
||||
for( int ii = 0; ; ii++ )
|
||||
{
|
||||
if( aList[ii] == 0.0 ) // End of list
|
||||
break;
|
||||
|
||||
double curr_r = curr_coeff * aList[ii];
|
||||
curr_list.emplace_back( strValue( curr_r ), curr_r );
|
||||
count++;
|
||||
|
||||
if( curr_r >= LAST_VALUE )
|
||||
break;
|
||||
}
|
||||
|
||||
if( curr_r >= LAST_VALUE )
|
||||
break;
|
||||
|
||||
curr_coeff *= 10;
|
||||
}
|
||||
|
||||
m_luts.push_back( std::move( curr_list ) );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::Exclude( double aValue )
|
||||
{
|
||||
if( aValue ) // if there is a value to exclude other than a wire jumper
|
||||
{
|
||||
for( R_DATA& i : m_luts[m_series] ) // then search it in the selected E-Serie lookup table
|
||||
{
|
||||
if( i.e_value == aValue ) // if the value to exclude is found
|
||||
i.e_use = false; // disable its use
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::simple_solution( uint32_t aSize )
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
m_results.at( S2R ).e_value = std::numeric_limits<double>::max(); // assume no 2R solution or max deviation
|
||||
|
||||
for( i = 0; i < aSize; i++ )
|
||||
{
|
||||
if( abs( m_cmb_lut.at( i ).e_value - m_required_value ) < abs( m_results.at( S2R ).e_value ) )
|
||||
{
|
||||
m_results.at( S2R ).e_value = m_cmb_lut.at( i ).e_value - m_required_value; // save signed deviation in Ohms
|
||||
m_results.at( S2R ).e_name = m_cmb_lut.at( i ).e_name; // save combination text
|
||||
m_results.at( S2R ).e_use = true; // this is a possible solution
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::combine4( uint32_t aSize )
|
||||
{
|
||||
uint32_t i,j;
|
||||
double tmp;
|
||||
|
||||
m_results.at( S4R ).e_use = false; // disable 4R solution, until
|
||||
m_results.at( S4R ).e_value = m_results.at( S3R ).e_value; // 4R becomes better than 3R solution
|
||||
|
||||
#ifdef BENCHMARK
|
||||
PROF_TIMER timer; // start timer to count execution time
|
||||
#endif
|
||||
|
||||
for( i = 0; i < aSize; i++ ) // 4R search outer loop
|
||||
{ // scan valid intermediate 2R solutions
|
||||
for( j = 0; j < aSize; j++ ) // inner loop combines all with itself
|
||||
{
|
||||
tmp = m_cmb_lut.at( i ).e_value + m_cmb_lut.at( j ).e_value; // calculate 2R+2R serial
|
||||
tmp -= m_required_value; // calculate 4R deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results.at(S4R).e_value ) ) // if new 4R is better
|
||||
{
|
||||
m_results.at( S4R ).e_value = tmp; // save amount of benefit
|
||||
std::string s = "( ";
|
||||
s.append( m_cmb_lut.at( i ).e_name ); // mention 1st 2 component
|
||||
s.append( " ) + ( " ); // in series
|
||||
s.append( m_cmb_lut.at( j ).e_name ); // with 2nd 2 components
|
||||
s.append( " )" );
|
||||
m_results.at( S4R ).e_name = s; // save the result and
|
||||
m_results.at( S4R ).e_use = true; // enable for later use
|
||||
}
|
||||
|
||||
tmp = ( m_cmb_lut[i].e_value * m_cmb_lut.at( j ).e_value ) /
|
||||
( m_cmb_lut[i].e_value + m_cmb_lut.at( j ).e_value ); // calculate 2R|2R parallel
|
||||
tmp -= m_required_value; // calculate 4R deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results.at( S4R ).e_value ) ) // if new 4R is better
|
||||
{
|
||||
m_results.at( S4R ).e_value = tmp; // save amount of benefit
|
||||
std::string s = "( ";
|
||||
s.append( m_cmb_lut.at( i ).e_name ); // mention 1st 2 component
|
||||
s.append( " ) | ( " ); // in parallel
|
||||
s.append( m_cmb_lut.at( j ).e_name ); // with 2nd 2 components
|
||||
s.append( " )" );
|
||||
m_results.at( S4R ).e_name = s; // save the result
|
||||
m_results.at( S4R ).e_use = true; // enable later use
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BENCHMARK
|
||||
printf( "Calculation time = %d mS", timer.msecs() );
|
||||
fflush( 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::NewCalc()
|
||||
{
|
||||
for( R_DATA& i : m_cmb_lut )
|
||||
i.e_use = false; // before any calculation is done, assume that
|
||||
|
||||
for( R_DATA& i : m_results )
|
||||
i.e_use = false; // no combinations and no results are available
|
||||
|
||||
for( R_DATA& i : m_luts[m_series])
|
||||
i.e_use = true; // all selected E-values available
|
||||
}
|
||||
|
||||
|
||||
uint32_t E_SERIE::combine2()
|
||||
{
|
||||
uint32_t combi2R = 0; // target index counts calculated 2R combinations
|
||||
std::string s;
|
||||
|
||||
for( const R_DATA& i : m_luts[m_series] ) // outer loop to sweep selected source lookup table
|
||||
{
|
||||
if( i.e_use )
|
||||
{
|
||||
for( const R_DATA& j : m_luts[m_series] ) // inner loop to combine values with itself
|
||||
{
|
||||
if( j.e_use )
|
||||
{
|
||||
m_cmb_lut.at( combi2R ).e_use = true;
|
||||
m_cmb_lut.at( combi2R ).e_value = i.e_value + j.e_value; // calculate 2R serial
|
||||
s = i.e_name;
|
||||
s.append( " + " );
|
||||
m_cmb_lut.at( combi2R ).e_name = s.append( j.e_name);
|
||||
combi2R++; // next destination
|
||||
m_cmb_lut.at( combi2R ).e_use = true; // calculate 2R parallel
|
||||
m_cmb_lut.at( combi2R ).e_value = i.e_value * j.e_value / ( i.e_value + j.e_value );
|
||||
s = i.e_name;
|
||||
s.append( " | " );
|
||||
m_cmb_lut.at( combi2R ).e_name = s.append( j.e_name );
|
||||
combi2R++; // next destination
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return combi2R;
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::combine3( uint32_t aSize )
|
||||
{
|
||||
uint32_t j = 0;
|
||||
double tmp = 0; // avoid warning for being uninitialized
|
||||
std::string s;
|
||||
|
||||
m_results.at( S3R ).e_use = false; // disable 3R solution, until
|
||||
m_results.at( S3R ).e_value = m_results.at( S2R ).e_value; // 3R becomes better than 2R solution
|
||||
|
||||
for( const R_DATA& i : m_luts[m_series] ) // 3R Outer loop to selected primary E serie LUT
|
||||
{
|
||||
if( i.e_use ) // skip all excluded values
|
||||
{
|
||||
for( j = 0; j < aSize; j++ ) // inner loop combines with all 2R intermediate results
|
||||
{ // R+2R serial combi
|
||||
tmp = m_cmb_lut.at( j ).e_value + i.e_value;
|
||||
tmp -= m_required_value; // calculate deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results.at( S3R ).e_value ) ) // compare if better
|
||||
{ // then take it
|
||||
s = i.e_name; // mention 3rd component
|
||||
s.append( " + ( " ); // in series
|
||||
s.append( m_cmb_lut.at( j ).e_name ); // with 2R combination
|
||||
s.append( " )" );
|
||||
m_results.at( S3R ).e_name = s; // save S3R result
|
||||
m_results.at( S3R ).e_value = tmp; // save amount of benefit
|
||||
m_results.at( S3R ).e_use = true; // enable later use
|
||||
}
|
||||
|
||||
tmp = i.e_value * m_cmb_lut.at( j ).e_value /
|
||||
( i.e_value + m_cmb_lut.at( j ).e_value ); // calculate R + 2R parallel
|
||||
tmp -= m_required_value; // calculate deviation
|
||||
|
||||
if( abs( tmp ) < abs( m_results.at( S3R ).e_value ) ) // compare if better
|
||||
{ // then take it
|
||||
s = i.e_name; // mention 3rd component
|
||||
s.append( " | ( " ); // in parallel
|
||||
s.append( m_cmb_lut.at( j ).e_name ); // with 2R combination
|
||||
s.append( " )" );
|
||||
m_results.at( S3R ).e_name = s;
|
||||
m_results.at( S3R ).e_value = tmp; // save amount of benefit
|
||||
m_results.at( S3R ).e_use = true; // enable later use
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a 3R result with remaining deviation consider to search a possibly better 4R solution
|
||||
// calculate 4R for small series always
|
||||
if(( m_results.at( S3R ).e_use == true ) && tmp )
|
||||
combine4( aSize );
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::Calculate()
|
||||
{
|
||||
uint32_t no_of_2Rcombi = 0;
|
||||
|
||||
no_of_2Rcombi = combine2(); // combine all 2R combinations for selected E serie
|
||||
simple_solution( no_of_2Rcombi ); // search for simple 2 component solution
|
||||
|
||||
if( m_results.at( S2R ).e_value ) // if simple 2R result is not exact
|
||||
combine3( no_of_2Rcombi ); // continiue searching for a possibly better solution
|
||||
|
||||
strip3();
|
||||
strip4();
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::strip3()
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( m_results.at( S3R ).e_use ) // if there is a 3 term result available
|
||||
{ // what is connected either by two "|" or by 3 plus
|
||||
s = m_results.at( S3R ).e_name;
|
||||
|
||||
if( ( std::count( s.begin(), s.end(), '+' ) == 2 )
|
||||
|| ( std::count( s.begin(), s.end(), '|' ) == 2 ) )
|
||||
{ // then strip one pair of braces
|
||||
s.erase( s.find( "(" ), 1 ); // it is known sure, this is available
|
||||
s.erase( s.find( ")" ), 1 ); // in any unstripped 3R result term
|
||||
m_results.at( S3R ).e_name = s; // use stripped result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void E_SERIE::strip4()
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( m_results.at( S4R ).e_use ) // if there is a 4 term result available
|
||||
{ // what are connected either by 3 "+" or by 3 "|"
|
||||
s = m_results.at( S4R ).e_name;
|
||||
|
||||
if( ( std::count( s.begin(), s.end(), '+' ) == 3 )
|
||||
|| ( std::count( s.begin(), s.end(), '|' ) == 3 ) )
|
||||
{ // then strip two pair of braces
|
||||
s.erase( s.find( "(" ), 1 ); // it is known sure, they are available
|
||||
s.erase( s.find( ")" ), 1 ); // in any unstripped 4R result term
|
||||
s.erase( s.find( "(" ), 1 );
|
||||
s.erase( s.find( ")" ), 1 );
|
||||
m_results.at( S4R ).e_name = s; // use stripped result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIE::OnCalculateESeries( wxCommandEvent& event )
|
||||
{
|
||||
double reqr; // required resistor stored in local copy
|
||||
double error, err3 = 0;
|
||||
wxString es, fs; // error and formula strings
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
reqr = ( 1000 * DoubleFromString( m_ResRequired->GetValue() ) );
|
||||
r.SetRequiredValue( reqr ); // keep a local copy of required resistor value
|
||||
r.NewCalc(); // assume all values available
|
||||
/*
|
||||
* Exclude itself. For the case, a value from the available series is found as required value,
|
||||
* the calculator assumes this value needs a replacement for the reason of being not available.
|
||||
* Two further exclude values can be entered to exclude and are skipped as not being available.
|
||||
* All values entered in KiloOhms are converted to Ohm for internal calculation
|
||||
*/
|
||||
r.Exclude( 1000 * DoubleFromString( m_ResRequired->GetValue()));
|
||||
r.Exclude( 1000 * DoubleFromString( m_ResExclude1->GetValue()));
|
||||
r.Exclude( 1000 * DoubleFromString( m_ResExclude2->GetValue()));
|
||||
|
||||
try
|
||||
{
|
||||
r.Calculate();
|
||||
}
|
||||
catch (std::out_of_range const& exc)
|
||||
{
|
||||
wxString msg;
|
||||
msg << "Internal error: " << exc.what();
|
||||
|
||||
wxMessageBox( msg );
|
||||
return;
|
||||
}
|
||||
|
||||
fs = r.GetResults()[S2R].e_name; // show 2R solution formula string
|
||||
m_ESeries_Sol2R->SetValue( fs );
|
||||
error = reqr + r.GetResults()[S2R].e_value; // absolute value of solution
|
||||
error = ( reqr / error - 1 ) * 100; // error in percent
|
||||
|
||||
if( error )
|
||||
{
|
||||
if( std::abs( error ) < 0.01 )
|
||||
es.Printf( "<%.2f", 0.01 );
|
||||
else
|
||||
es.Printf( "%+.2f",error);
|
||||
}
|
||||
else
|
||||
{
|
||||
es = _( "Exact" );
|
||||
}
|
||||
|
||||
m_ESeriesError2R->SetValue( es ); // anyway show 2R error string
|
||||
|
||||
if( r.GetResults()[S3R].e_use ) // if 3R solution available
|
||||
{
|
||||
err3 = reqr + r.GetResults()[S3R].e_value; // calculate the 3R
|
||||
err3 = ( reqr / err3 - 1 ) * 100; // error in percent
|
||||
|
||||
if( err3 )
|
||||
{
|
||||
if( std::abs( err3 ) < 0.01 )
|
||||
es.Printf( "<%.2f", 0.01 );
|
||||
else
|
||||
es.Printf( "%+.2f",err3);
|
||||
}
|
||||
else
|
||||
{
|
||||
es = _( "Exact" );
|
||||
}
|
||||
|
||||
m_ESeriesError3R->SetValue( es ); // show 3R error string
|
||||
fs = r.GetResults()[S3R].e_name;
|
||||
m_ESeries_Sol3R->SetValue( fs ); // show 3R formula string
|
||||
}
|
||||
else // nothing better than 2R found
|
||||
{
|
||||
fs = _( "Not worth using" );
|
||||
m_ESeries_Sol3R->SetValue( fs );
|
||||
m_ESeriesError3R->SetValue( wxEmptyString );
|
||||
}
|
||||
|
||||
fs = wxEmptyString;
|
||||
|
||||
if( r.GetResults()[S4R].e_use ) // show 4R solution if available
|
||||
{
|
||||
fs = r.GetResults()[S4R].e_name;
|
||||
|
||||
error = reqr + r.GetResults()[S4R].e_value; // absolute value of solution
|
||||
error = ( reqr / error - 1 ) * 100; // error in percent
|
||||
|
||||
if( error )
|
||||
es.Printf( "%+.2f",error );
|
||||
else
|
||||
es = _( "Exact" );
|
||||
|
||||
m_ESeriesError4R->SetValue( es );
|
||||
}
|
||||
else // no 4R solution
|
||||
{
|
||||
fs = _( "Not worth using" );
|
||||
es = wxEmptyString;
|
||||
m_ESeriesError4R->SetValue( es );
|
||||
}
|
||||
|
||||
m_ESeries_Sol4R->SetValue( fs );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_E_SERIE::OnESeriesSelection( wxCommandEvent& event )
|
||||
{
|
||||
if( event.GetEventObject() == m_e1 )
|
||||
r.SetSeries( E1 );
|
||||
else if( event.GetEventObject() == m_e3 )
|
||||
r.SetSeries( E3 );
|
||||
else if( event.GetEventObject() == m_e12 )
|
||||
r.SetSeries( E12 );
|
||||
else if( event.GetEventObject() == m_e24 )
|
||||
r.SetSeries( E24 );
|
||||
else
|
||||
r.SetSeries( E6 );
|
||||
}
|
|
@ -39,7 +39,7 @@
|
|||
#include <calculator_panels/panel_corrosion.h>
|
||||
#include <calculator_panels/panel_color_code.h>
|
||||
#include <calculator_panels/panel_electrical_spacing.h>
|
||||
#include <calculator_panels/panel_eserie.h>
|
||||
#include <calculator_panels/panel_eseries.h>
|
||||
#include <calculator_panels/panel_fusing_current.h>
|
||||
#include <calculator_panels/panel_regulator.h>
|
||||
#include <calculator_panels/panel_track_width.h>
|
||||
|
@ -109,7 +109,7 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
m_treebook->AddPage( nullptr, _( "Memo" ) );
|
||||
|
||||
AddCalculator( new PANEL_E_SERIE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
|
||||
AddCalculator( new PANEL_E_SERIES( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
|
||||
_( "E-Series" ) );
|
||||
AddCalculator( new PANEL_COLOR_CODE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
|
||||
_( "Color Code" ) );
|
||||
|
@ -156,14 +156,14 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
wxSysColourChangedEventHandler( PCB_CALCULATOR_FRAME::onThemeChanged ), this );
|
||||
|
||||
m_treebook->Connect( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxTreebookEventHandler(
|
||||
PCB_CALCULATOR_FRAME::OnPageChanged ), NULL, this );
|
||||
PCB_CALCULATOR_FRAME::OnPageChanged ), nullptr, this );
|
||||
}
|
||||
|
||||
|
||||
PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
|
||||
{
|
||||
m_treebook->Disconnect( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxTreebookEventHandler(
|
||||
PCB_CALCULATOR_FRAME::OnPageChanged ), NULL, this );
|
||||
PCB_CALCULATOR_FRAME::OnPageChanged ), nullptr, this );
|
||||
// This needed for OSX: avoids further OnDraw processing after this destructor and before
|
||||
// the native window is destroyed
|
||||
this->Freeze();
|
||||
|
|
Loading…
Reference in New Issue