25#include <wx/chartype.h>
27#include "idf_helpers.h"
38 for(
size_t ii = 0; ii < aStr.Len(); ++ii )
41 wxUniChar ch = aStr[ii];
43 if( ch > 126 || !std::isgraph(
static_cast<unsigned char>( ch ) ) )
58 std::string str = aStr.ToStdString();
60 out.reserve( str.size() );
64 if( ( c >= 33 && c <= 126 ) && c !=
';' )
83 std::string str = aStr.ToStdString();
85 out.reserve( str.size() );
91 else if( isdigit( c ) || c ==
'-' || c ==
'_' || c ==
'+' || c ==
'.' )
99 if( out.length() > 64 )
104 while( !out.IsEmpty() && ( out[0] ==
'.' || out[0] ==
'-' || out[0] ==
'+' ) )
109 while( !out.IsEmpty() && out.Last() ==
'.' )
127 while( str.EndsWith( wxT(
"00" ) ) )
140 wxString str = wxString::FromCDouble( aVal, aDigits );
142 return str.ToStdString();
161 std::pair<wxString, wxString> xy =
176 case SHAPE_T::RECTANGLE:
181 case SHAPE_T::CIRCLE:
184 case SHAPE_T::BEZIER:
185 case SHAPE_T::SEGMENT:
187 case SHAPE_T::UNDEFINED:
198 const wxString& aSubDir )
200 wxFileName
path = wxFileName::DirName( aPareDir );
202 wxArrayString subDirs = wxFileName::DirName( aSubDir.Lower() ).GetDirs();
204 for(
size_t i = 0; i < subDirs.GetCount(); i++ )
205 path.AppendDir( subDirs[i] );
207 if( !
path.DirExists() )
209 if( !
path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
211 throw( std::runtime_error(
"Could not create directory" +
path.GetPath() ) );
220 m_treeWriter( aTreeWriter )
233 fn.SetFullName( aFileName );
235 wxString dirPath = fn.GetPath();
237 if( !wxDir::Exists( dirPath ) )
239 if( !wxDir::Make( dirPath ) )
240 throw( std::runtime_error(
"Could not create directory" + dirPath ) );
243 if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
250 std::ios_base::out | std::ios_base::trunc | std::ios_base::binary );
252 m_ostream.imbue( std::locale::classic() );
255 throw std::runtime_error(
"Failed to open file: " + fn.GetFullPath() );
267 throw std::runtime_error(
"close file failed" );
279 m_ostream << var <<
"=" << value << std::endl;
286 m_ostream << var <<
"=" << value << std::endl;
300 throw std::runtime_error(
"already in array" );
309 throw std::runtime_error(
"not in array" );
311 m_ostream <<
"}" << std::endl << std::endl;
329 const wxString& aUserParams ) :
330 m_units( aUnits ), m_thickness( aThickness ), m_userParams( aUserParams )
343 for(
const auto& tool :
m_tools )
int GetRectangleWidth() const
int GetRectangleHeight() const
void CreateFile(const wxString &aFileName)
ODB_TREE_WRITER & m_treeWriter
ODB_FILE_WRITER(ODB_TREE_WRITER &aTreeWriter, const wxString &aFileName)
ARRAY_PROXY(ODB_TEXT_WRITER &aWriter, const std::string &aStr)
ODB_TEXT_WRITER & m_writer
void WriteEquationLine(const std::string &var, int value)
ARRAY_PROXY MakeArrayProxy(const std::string &aStr)
void BeginArray(const std::string &a)
void CreateEntityDirectory(const wxString &aPareDir, const wxString &aSubDir=wxEmptyString)
const wxString GetCurrentPath() const
static double m_symbolScale
VECTOR2I GetPosition() const override
wxString Data2String(double aVal)
wxString GenODBString(const wxString &aStr)
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
wxString GenLegalEntityName(const wxString &aStr)
wxString GenLegalNetName(const wxString &aStr)
wxString Double2String(double aVal)
wxString SymDouble2String(double aVal)
VECTOR2I GetShapePosition(const PCB_SHAPE &aShape)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
VECTOR2< int32_t > VECTOR2I