KiCad PCB EDA Suite
eserie.cpp File Reference
#include <array>
#include <algorithm>
#include <calculator_panels/panel_eserie.h>
#include <wx/msgdlg.h>
#include "eserie.h"

Go to the source code of this file.

Functions

double DoubleFromString (const wxString &TextValue)
 
static std::string strValue (double aValue)
 

Variables

E_SERIE r
 

Function Documentation

◆ DoubleFromString()

double DoubleFromString ( const wxString &  TextValue)

Definition at line 37 of file params_read_write.cpp.

38{
39 double value = 0;
40
41 /* Acquire the 'right' decimal point separator */
42 const struct lconv* lc = localeconv();
43 wxChar decimal_point = lc->decimal_point[0];
44 wxString buf( TextValue.Strip( wxString::both ) );
45
46 /* Convert the period in decimal point */
47 buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
48 // An ugly fix needed by WxWidgets 2.9.1 that sometimes
49 // back to a point as separator, although the separator is the comma
50 buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
51
52 /* Find the end of the numeric part
53 *(when units are append to the number, remove them)
54 */
55 unsigned brk_point = 0;
56 while( brk_point < buf.Len() )
57 {
58 wxChar ch = buf[brk_point];
59 if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
60 || ( ch == '+' ) || ( ch == 'e' ) || ( ch == 'E' ) ) )
61 {
62 break;
63 }
64 ++brk_point;
65 }
66
67 // Check for strings that cannot qualify as a number
68 if( brk_point == 0 )
69 return std::nan( "" );
70
71 /* Extract the numeric part */
72 if( !buf.Left( brk_point ).ToDouble( &value ) )
73 return std::nan( "" );
74
75 return value;
76}

Referenced by PANEL_E_SERIE::OnCalculateESeries().

◆ strValue()

static std::string strValue ( double  aValue)
static

Definition at line 49 of file eserie.cpp.

50{
51 std::string result;
52
53 if( aValue < 1000.0 )
54 {
55 result = std::to_string( static_cast<int>( aValue ) );
56 result += 'R';
57 }
58 else
59 {
60 double div = 1e3;
61 int unit = 'K';
62
63 if( aValue >= 1e6 )
64 {
65 div = 1e6;
66 unit = 'M';
67 }
68
69 aValue /= div;
70
71 int integer = static_cast<int>( aValue );
72 result = std::to_string(integer);
73 result += unit;
74
75 // Add mantissa: 1 digit, suitable for series up to E24
76 double mantissa = aValue - integer;
77
78 if( mantissa > 0 )
79 result += std::to_string( static_cast<int>( (mantissa*10)+0.5 ) );
80 }
81
82 return result;
83}

Referenced by E_SERIE::buildSerieData(), and IbisParser::readTypMinMaxValue().

Variable Documentation

◆ r

Definition at line 41 of file eserie.cpp.

Referenced by ZONE_FILLER::addHatchFillTypeOnZone(), PNS::DEBUG_DECORATOR::AddShape(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PNS::ApproximateSegmentAsRect(), PolygonTriangulation::area(), POLYGON_TEST::area(), SELECTION::AreAllItemsIdentical(), BlendColor(), PAD::BuildEffectiveShapes(), PNS::buildHullForPrimitiveShape(), DIALOG_NET_INSPECTOR::buildNetsList(), CalcArcCenter(), DXF_PLOTTER::Circle(), KIGFX::VIEW::Clear(), KIGFX::VIEW::clearGroupCache(), Collide(), PCB_GRID_HELPER::computeAnchors(), SHAPE_ARC::ConvertToPolyline(), PNS_PCBNEW_RULE_RESOLVER::DpNetPair(), KIGFX::PCB_PAINTER::draw(), KIGFX::CAIRO_GAL_BASE::DrawArc(), KIGFX::CAIRO_GAL_BASE::DrawArcSegment(), KIGFX::CAIRO_GAL_BASE::DrawCircle(), ROUTER_PREVIEW_ITEM::drawShape(), DRILL_PRECISION::DRILL_PRECISION(), TRANSLINE::ellipk(), PS_PLOTTER::emitSetRGBColor(), PDF_PLOTTER::emitSetRGBColor(), SVG_PLOTTER::emitSetRGBColor(), fontconfig::FONTCONFIG::FindFont(), EDA_DRAW_FRAME::FocusOnLocation(), EDA_TEXT::Format(), STROKE_PARAMS::Format(), from_json(), SCH_PIN::GetBoundingBox(), DATA::GetColor(), DIALOG_MOVE_EXACT::GetTranslationInIU(), DIALOG_POSITION_RELATIVE::GetTranslationInIU(), FIELDS_EDITOR_GRID_DATA_MODEL::GetValue(), LIB_TABLE_GRID::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), BOARD_INSPECTION_TOOL::InspectDRCError(), intersect(), BOX2< Vec >::IntersectsCircle(), BOX2< Vec >::IntersectsCircleEdge(), KI_TEST::IsColorNearHex(), KI_TEST::IsImagePixelOfColor(), isqrt(), SEG::LineDistance(), EAGLE_PLUGIN::loadLibrary(), EAGLE_PLUGIN::loadPlain(), PLOTTER::markerSquare(), SPICE_GENERATOR_R_POT::ModelLine(), SPICE_GENERATOR_TLINE::ModelLine(), SEG::mutualDistance(), DIALOG_NET_INSPECTOR::OnBoardHighlightNetChanged(), DIALOG_NET_INSPECTOR::OnBoardItemAdded(), DIALOG_NET_INSPECTOR::OnBoardItemRemoved(), PANEL_E_SERIE::OnCalculateESeries(), DIALOG_POSITION_RELATIVE::OnClear(), PANEL_E_SERIE::OnESeriesSelection(), APPEARANCE_CONTROLS::OnLayerChanged(), SELECTION::OnlyContains(), FP_LIB_TABLE::operator!=(), LIB_TABLE::operator!=(), LIB_TABLE_ROW::operator!=(), LIB_TABLE::operator==(), LIB_TABLE_ROW::operator==(), PNS::OPTIMIZER::Optimize(), EAGLE_PLUGIN::packageRectangle(), PCAD2KICAD::PCB_ARC::Parse(), mpBitmapLayer::Plot(), PDF_PLOTTER::PlotImage(), pushoutForce(), S3D::ReadColor(), KIGFX::VIEW::RecacheAllItems(), SCH_SYMBOL::ReplaceInstanceSheetPath(), PNS::SHOVE::replaceLine(), BOARD_INSPECTION_TOOL::reportCompileError(), BOARD_INSPECTION_TOOL::reportHeader(), rescale(), DIRECTION_45::Right(), round_to_half_pixel(), PNS::SHOVE::runOptimizer(), screenSpaceCircle(), STEP_PCB_MODEL::SetBoardColor(), SCH_LINE::SetLineColor(), DIALOG_NET_INSPECTOR::Settings(), LIB_TABLE_GRID::SetValue(), SpreadFootprints(), spreadRectangles(), STROKE_PARAMS::Stroke(), tb_project_to_sphere(), to_json(), DIALOG_MOVE_EXACT::ToPolarDeg(), DIALOG_POSITION_RELATIVE::ToPolarDeg(), DIALOG_JUNCTION_PROPS::TransferDataToWindow(), DIALOG_LINE_PROPERTIES::TransferDataToWindow(), EDA_SHAPE::TransformShapeToPolygon(), KIGFX::VIEW::UpdateLayerColor(), SCH_SHEET_LIST::UpdateSheetInstances(), SCH_SHEET_LIST::UpdateSymbolInstances(), DIALOG_NET_INSPECTOR::DATA_MODEL::valueAt(), PANEL_SYM_LIB_TABLE::verifyTables(), PANEL_FP_LIB_TABLE::verifyTables(), SELECTION::ViewBBox(), S3D::WriteColor(), and SGCOLORS::WriteVRML().