KiCad PCB EDA Suite
macros.h File Reference

This file contains miscellaneous commonly used macros and functions. More...

#include <wx/wx.h>
#include <vector>
#include <map>
#include <set>
#include <memory>

Go to the source code of this file.

Macros

#define TO_UTF8(wxstring)   ( (const char*) (wxstring).utf8_str() )
 Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes. More...
 
#define DIM(x)   unsigned( sizeof(x) / sizeof( (x)[0] ) )
 

of elements in an array

More...
 
#define DECL_VEC_FOR_SWIG(TypeName, MemberType)   typedef std::vector<MemberType> TypeName;
 Declare a std::vector but no swig template. More...
 
#define DECL_MAP_FOR_SWIG(TypeName, KeyType, ValueType)   typedef std::map<KeyType, ValueType> TypeName;
 
#define DECL_SPTR_FOR_SWIG(TypeName, MemberType)   typedef std::shared_ptr<MemberType> TypeName;
 
#define DECL_SET_FOR_SWIG(TypeName, MemberType)   typedef std::set<MemberType> TypeName;
 

Functions

static wxString FROM_UTF8 (const char *cstring)
 function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes. More...
 
void AccumulateDescription (wxString &aDesc, const wxString &aItem)
 Utility to build comma separated lists in messages. More...
 
static const wxChar * GetChars (const wxString &s)
 Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for passing strings to wxString::Printf() and wxString::Format(). More...
 
template<typename T >
Mirror (T aPoint, T aMirrorRef)
 Function MIRROR Mirror aPoint in aMirrorRef. More...
 
template<typename T >
void MIRROR (T &aPoint, const T &aMirrorRef)
 
template<typename T >
const T & Clamp (const T &lower, const T &value, const T &upper)
 Function Clamp limits value within the range lower <= value <= upper. More...
 

Detailed Description

This file contains miscellaneous commonly used macros and functions.

Definition in file macros.h.

Macro Definition Documentation

#define DECL_MAP_FOR_SWIG (   TypeName,
  KeyType,
  ValueType 
)    typedef std::map<KeyType, ValueType> TypeName;

Definition at line 147 of file macros.h.

#define DECL_SET_FOR_SWIG (   TypeName,
  MemberType 
)    typedef std::set<MemberType> TypeName;

Definition at line 149 of file macros.h.

#define DECL_SPTR_FOR_SWIG (   TypeName,
  MemberType 
)    typedef std::shared_ptr<MemberType> TypeName;

Definition at line 148 of file macros.h.

#define DECL_VEC_FOR_SWIG (   TypeName,
  MemberType 
)    typedef std::vector<MemberType> TypeName;

Declare a std::vector but no swig template.

Definition at line 146 of file macros.h.

#define DIM (   x)    unsigned( sizeof(x) / sizeof( (x)[0] ) )

of elements in an array

Definition at line 98 of file macros.h.

Referenced by PGM_BASE::AddMenuLanguageList(), AskLoadBoardFileName(), EAGLE_PLUGIN::clear_cu_map(), COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS(), CINFO3D_VISU::createLayers(), CreatePadsShapesSection(), CreateThermalReliefPadPolygon(), LSET::CuStack(), DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY(), DIALOG_PAGE_SHOW_PAGE_BORDERS::DIALOG_PAGE_SHOW_PAGE_BORDERS(), dlg_layers(), EDA_3D_VIEWER::EDA_3D_VIEWER(), EDA_DRAW_FRAME::EDA_DRAW_FRAME(), PROJECT::ElemsClear(), PCB_EDIT_FRAME::enableGALSpecificMenus(), EVT_COMMAND_RANGE(), FindKicadFile(), LSET::FmtHex(), PCB_EDIT_FRAME::forceColorsToLegacy(), PCB_IO::format(), GBR_SCREEN::GBR_SCREEN(), DIALOG_GENDRILL::GenDrillAndMapFiles(), GERBER_FILE_IMAGE::GERBER_FILE_IMAGE(), AUTOPLACER::get_colliding_sides(), AUTOPLACER::get_preferred_sides(), GetAssociatedDocument(), DIALOG_SVG_PRINT::getCheckBoxSelectedLayers(), PCB_EDIT_FRAME::GetConfigurationSettings(), GERBVIEW_FRAME::GetConfigurationSettings(), GERBER_FILE_IMAGE::GetDCODE(), GERBER_FILE_IMAGE::GetDcodesCount(), PROJECT::GetElem(), COLORS_DESIGN_SETTINGS::GetItemColor(), EDA_BASE_FRAME::GetKicadHelp(), COLORS_DESIGN_SETTINGS::GetLayerColor(), GetLayerColor(), MODEL_VRML::GetLayerZ(), DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog(), PROJECT::GetRString(), DIALOG_PAGES_SETTINGS::initDialog(), DIALOG_DISPLAY_OPTIONS::initOptDialog(), DIALOG_PAD_PROPERTIES::initValues(), LSET::InternalCuMask(), PCB_LAYER_WIDGET::isAllowedInFpMode(), EAGLE_PLUGIN::kicad_layer(), KicadDatasPath(), KIWAY::KiFACE(), EAGLE_PLUGIN::loadLayerDefs(), MODEL_VRML::MODEL_VRML(), KICAD_MANAGER_FRAME::OnArchiveFiles(), DIALOG_SVG_PRINT::OnCloseWindow(), DIALOG_PRINT_USING_PRINTER::OnCloseWindow(), KIWAY::OnKiwayEnd(), DIALOG_LAYERS_SETUP::OnPresetsChoice(), DIALOG_PAD_PROPERTIES::PadTypeSelected(), PCB_SCREEN::PCB_SCREEN(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), PL_EDITOR_SCREEN::PL_EDITOR_SCREEN(), PlotLayerOutlines(), PCB_LAYER_WIDGET::ReFill(), PCB_LAYER_WIDGET::ReFillRender(), GERBER_LAYER_WIDGET::ReFillRender(), GERBER_FILE_IMAGE::ResetDefaultValues(), SCH_SCREEN::SCH_SCREEN(), LSET::SeqStackupBottom2Top(), COLORS_DESIGN_SETTINGS::SetAllColorsAs(), PROJECT::SetElem(), COLORS_DESIGN_SETTINGS::SetItemColor(), PGM_BASE::SetLanguage(), PGM_BASE::SetLanguageIdentifier(), COLORS_DESIGN_SETTINGS::SetLayerColor(), SetLayerColor(), BOARD::SetLayerDescr(), DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection(), PROJECT::SetRString(), DIALOG_LAYERS_SETUP::showPresets(), PCB_EDIT_FRAME::Swap_Layers(), PCB_LAYER_WIDGET::SyncRenderStates(), LSET::Technicals(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::TransferDataToWindow(), LSET::UIOrder(), LSET::Users(), and GERBER_FILE_IMAGE::~GERBER_FILE_IMAGE().

#define TO_UTF8 (   wxstring)    ( (const char*) (wxstring).utf8_str() )

Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.

wxstring is a wxString, not a wxT() or _(). The scope of the return value is very limited and volatile, but can be used with printf() style functions well. NOTE: Trying to convert it to a function is tricky because of the type of the parameter!

Definition at line 47 of file macros.h.

Referenced by SCH_REFERENCE::Annotate(), DXF_PLOTTER::Arc(), DSN::SPECCTRA_DB::buildLayerMaps(), DXF_PLOTTER::Circle(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), copy_pro_file_template(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), CreateComponentsSection(), CreateDevicesSection(), CreateHeaderInfoData(), CreateRoutesSection(), CreateShapesSection(), CreateSignalsSection(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), PCB_EDIT_FRAME::DoGenFootprintsReport(), EDA_FILE_SELECTOR(), EDA_LIST_DIALOG::EDA_LIST_DIALOG(), PROJECT::ElemsClear(), PDF_PLOTTER::EndPlot(), EscapedUTF8(), EVT_TOOL(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), GBR_TO_PCB_EXPORTER::export_flashed_copper_item(), PCB_EDIT_FRAME::Export_IDF3(), export_vrml_module(), DSN::SPECCTRA_DB::exportNETCLASS(), DSN::SPECCTRA_DB::ExportPCB(), FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint(), PCB_EDIT_FRAME::ExportVRML_File(), TREE_PROJECT_FRAME::FileWatcherReset(), DIALOG_DESIGN_RULES::FillListBoxWithNetNames(), GITHUB_PLUGIN::FootprintDelete(), GPCB_PLUGIN::FootprintLoad(), LEGACY_PLUGIN::FootprintLoad(), EAGLE_PLUGIN::FootprintLoad(), PCB_IO::FootprintLoad(), FP_LIB_TABLE::FootprintLoad(), GITHUB_PLUGIN::FootprintSave(), FootprintWriteShape(), WORKSHEET_LAYOUT_IO::format(), SCH_LEGACY_PLUGIN::Format(), NETLIST_EXPORTER_PSPICE::Format(), PCB_IO::format(), PCB_IO::formatLayer(), FormatProbeItem(), DSN::SPECCTRA_DB::FromBOARD(), GENDRILL_WRITER_BASE::GenDrillReportFile(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), LAYER_WIDGET::GetLayerColor(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), FOOTPRINT_LIST::GetModuleInfo(), guessNickname(), idf_export_module(), PCB_PARSER::init(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), DIALOG_BOM::installPluginsList(), FP_CACHE::IsModified(), GPCB_FPL_CACHE::IsModified(), SCH_EDIT_FRAME::KiwayMailIn(), LIB_ID::LIB_ID(), CMP_READER::Load(), LIB_PIN::Load(), FP_CACHE::Load(), GPCB_FPL_CACHE::Load(), SCH_COMPONENT::Load(), SCH_EDIT_FRAME::Load_Component(), PART_LIBS::LoadAllLibraries(), LEGACY_NETLIST_READER::loadComponent(), EAGLE_PLUGIN::loadElements(), PCB_BASE_FRAME::LoadModuleFromLibrary(), SCH_EDIT_FRAME::LoadSettings(), SYMBOL_LIB_TABLE::LoadSymbol(), main(), DSN::SPECCTRA_DB::makeIMAGE(), DIALOG_FP_PLUGIN_OPTIONS::makeResult(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler(), DIALOG_FP_PLUGIN_OPTIONS::onListBoxItemSelected(), PCB_IO::Parse(), KICAD_NETLIST_PARSER::parseComponent(), PCB_PARSER::parseMODULE_unchecked(), DSN::PARSER::PARSER(), FP_GRID_TRICKS::paste_text(), DXF_PLOTTER::PenTo(), RESCUE_CASE_CANDIDATE::PerformAction(), RESCUE_CACHE_CANDIDATE::PerformAction(), DIALOG_RESCUE_EACH::PopulateInstanceList(), PythonPluginsReloadBase(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), RecreateCmpFile(), GITHUB_GETLIBLIST::remoteGetJSON(), GITHUB_PLUGIN::remoteGetZip(), FP_CACHE::Remove(), GPCB_FPL_CACHE::Remove(), PCB_EDIT_FRAME::Remove_One_Track(), LIB_TEXT::Save(), LIB_PIN::Save(), SCH_TEXT::Save(), SCH_COMPONENT::Save(), SCH_LABEL::Save(), SCH_GLOBALLABEL::Save(), SCH_HIERLABEL::Save(), SCH_SCREEN::Save(), LIB_PART::Save(), SCH_LEGACY_PLUGIN::saveComponent(), LIB_ALIAS::SaveDoc(), LIB_EDIT_FRAME::SaveOneSymbol(), SCH_LEGACY_PLUGIN::saveText(), SCH_COMPONENT::SCH_COMPONENT(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), CVPCB_MAINFRAME::SetNewPkg(), LIB_TABLE_ROW::SetOptions(), PROJECT::SetProjectFullName(), DIALOG_LABEL_EDITOR::SetTitle(), KIWAY_PLAYER::ShowModal(), PS_PLOTTER::StartPlot(), SVG_PLOTTER::StartPlot(), GERBER_PLOTTER::StartPlot(), DXF_PLOTTER::Text(), toUTFTildaText(), RESCUER::UndoRescues(), write_D356_records(), EXCELLON_WRITER::writeCoordinates(), GBR_TO_PCB_EXPORTER::writeCopperLineItem(), EXCELLON_WRITER::writeEXCELLONHeader(), EDA_BASE_FRAME::WriteHotkeyConfig(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), GBR_TO_PCB_EXPORTER::writePcbHeader(), GBR_TO_PCB_EXPORTER::writePcbLineItem(), and DIALOG_DRC_CONTROL::writeReport().

Function Documentation

void AccumulateDescription ( wxString &  aDesc,
const wxString &  aItem 
)
inline

Utility to build comma separated lists in messages.

Definition at line 65 of file macros.h.

Referenced by ZONE_CONTAINER::GetMsgPanelInfo(), and LayerMaskDescribe().

66 {
67  if( !aDesc.IsEmpty() )
68  aDesc << wxT(", ");
69 
70  aDesc << aItem;
71 }
template<typename T >
const T& Clamp ( const T &  lower,
const T &  value,
const T &  upper 
)
inline

Function Clamp limits value within the range lower <= value <= upper.

It will work on temporary expressions, since they are evaluated only once, and it should work on most if not all numeric types, string types, or any type for which "operator < ()" is present. The arguments are accepted in this order so you can remember the expression as a memory aid:

result is: lower <= value <= upper

Definition at line 127 of file macros.h.

Referenced by LSET::AllCuMask(), DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog(), EAGLE_PLUGIN::loadSignals(), DIALOG_LAYERS_SETUP::OnOkButtonClick(), EAGLE_PLUGIN::packagePad(), BRDITEMS_PLOTTER::plotOneDrillMark(), DIALOG_PAGES_SETTINGS::SavePageSettings(), BASE_SCREEN::SetScalingFactor(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

128 {
129  wxASSERT( lower <= upper );
130  if( value < lower )
131  return lower;
132  else if( upper < value )
133  return upper;
134  return value;
135 }
static wxString FROM_UTF8 ( const char *  cstring)
inlinestatic

function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.

Definition at line 53 of file macros.h.

Referenced by BOARD_NETLIST_UPDATER::addNewComponent(), SCH_REFERENCE::Annotate(), SCH_EDIT_FRAME::backAnnotateFootprints(), CVPCB_MAINFRAME::BuildCmpListBox(), CVPCB_MAINFRAME::buildEquivalenceList(), GITHUB_PLUGIN::cacheLib(), PYTHON_ACTION_PLUGIN::CallRetStrMethod(), PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(), DIALOG_EXCHANGE_MODULE::change_1_Module(), DIALOG_EXCHANGE_MODULE::changeSameFootprints(), ConvertOutlineToPolygon(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), SCH_EDIT_FRAME::CreateArchiveLibrary(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), detect_file_type(), Diagnose(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), PCB_EDIT_FRAME::DoGenFootprintsPositionFile(), PCB_EDIT_FRAME::DoGenFootprintsReport(), SCH_EDIT_FRAME::EditComponentFieldText(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::Export_IDF3(), FOOTPRINT_EDIT_FRAME::Export_Module(), FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint(), PCB_EDIT_FRAME::ExportVRML_File(), PART_LIBS::FindLibPart(), PART_LIBS::FindLibraryAlias(), RESCUE_CASE_CANDIDATE::FindRescues(), RESCUE_CACHE_CANDIDATE::FindRescues(), GPCB_PLUGIN::FootprintEnumerate(), LEGACY_PLUGIN::FootprintEnumerate(), EAGLE_PLUGIN::FootprintEnumerate(), PCB_IO::FootprintEnumerate(), GITHUB_PLUGIN::FootprintEnumerate(), FP_LIB_TABLE::FootprintLoad(), FP_LIB_TABLE::FootprintLoadWithOptionalNickname(), PCB_IO::FootprintSave(), FP_LIB_TABLE::FootprintSave(), DSN::SPECCTRA_DB::FromSESSION(), GENDRILL_WRITER_BASE::genDrillMapFile(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), SCH_COMPONENT::GetConnectionPoints(), GetIllegalFileNameWxChars(), FOOTPRINT_LIST::GetModuleInfo(), SCH_COMPONENT::GetMsgPanelInfo(), MODULE::GetMsgPanelInfo(), PYTHON_FOOTPRINT_WIZARD::GetParameterPageName(), SCH_COMPONENT::GetSelectMenuText(), NETLIST_READER::GuessNetlistFileType(), guessNickname(), DIALOG_EXCHANGE_MODULE::init(), EDA_3D_CANVAS::initializeOpenGL(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), SCH_NO_CONNECT::Load(), SCH_JUNCTION::Load(), LIB_TEXT::Load(), SCH_BUS_ENTRY_BASE::Load(), SCH_LINE::Load(), CMP_READER::Load(), SCH_BITMAP::Load(), LIB_PIN::Load(), SCH_TEXT::Load(), SCH_SHEET_PIN::Load(), SCH_COMPONENT::Load(), SCH_LABEL::Load(), SCH_GLOBALLABEL::Load(), SCH_SHEET::Load(), SCH_HIERLABEL::Load(), LIB_PART::Load(), LIB_PART::LoadAliases(), LEGACY_NETLIST_READER::loadComponent(), LEGACY_PLUGIN::loadDIMENSION(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), EAGLE_PLUGIN::loadElements(), PCB_BASE_FRAME::LoadFootprint(), LEGACY_NETLIST_READER::loadFootprintFilters(), PCB_EDIT_FRAME::LoadFootprints(), LIB_PART::LoadFootprints(), EAGLE_PLUGIN::loadLayerDefs(), EAGLE_PLUGIN::loadLibrary(), LEGACY_PLUGIN::loadMODULE(), LEGACY_PLUGIN::loadMODULE_EDGE(), PCB_BASE_FRAME::LoadModuleFromLibrary(), LEGACY_NETLIST_READER::loadNet(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), SCH_EDIT_FRAME::LoadOneEEFile(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), LEGACY_PLUGIN::loadSETUP(), LEGACY_PLUGIN::loadSHEET(), EAGLE_PLUGIN::loadSignals(), SYMBOL_LIB_TABLE::LoadSymbol(), SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname(), SCH_LEGACY_PLUGIN::loadText(), PCB_PARSER::lookUpLayer(), main(), NETLIST_EXPORTER_GENERIC::makeComponents(), EAGLE_PLUGIN::makeModule(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), DIALOG_BOM::OnHelp(), DIALOG_FREEROUTE::OnHelpButtonClick(), APP_SINGLE_TOP::OnInit(), APP_SINGLE_TOP::OnRun(), APP_KICAD::OnRun(), EAGLE_PLUGIN::orientModuleText(), EAGLE_PLUGIN::packagePad(), EAGLE_PLUGIN::packageSMD(), EAGLE_PLUGIN::packageText(), PCB_PLOT_PARAMS_PARSER::Parse(), TEMPLATE_FIELDNAME::Parse(), KICAD_NETLIST_PARSER::parseComponent(), PCB_PARSER::parseLayer(), KICAD_NETLIST_PARSER::parseLibPartList(), KICAD_NETLIST_PARSER::parseNet(), parseQuotedString(), parseUnquotedString(), pcbnewRunPythonMethodWithReturnedString(), LIB_PIN::PinStringNum(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), PyArrayStringToWx(), GERBER_FILE_IMAGE::ReadApertureMacro(), ReadDelimitedText(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), ReadSchemaDescr(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), GITHUB_GETLIBLIST::remoteGetJSON(), BOARD_NETLIST_UPDATER::replaceComponent(), BOARD::ReplaceNetlist(), REPORTER::Report(), PCB_BASE_FRAME::ResetModuleTextSizes(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_COMPONENT::Save(), SCH_LEGACY_PLUGIN::saveComponent(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), SCH_EDIT_FRAME::SaveSettings(), SYMBOL_LIB_TABLE::SaveSymbol(), SCH_COMPONENT::SCH_COMPONENT(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), CVPCB_MAINFRAME::SetNewPkg(), BOARD_NETLIST_UPDATER::testConnectivity(), BOARD_NETLIST_UPDATER::UpdateNetlist(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), DIALOG_BOM::~DIALOG_BOM(), and WORKSHEET_LAYOUT_STRINGIO::~WORKSHEET_LAYOUT_STRINGIO().

54 {
55  wxString line = wxString::FromUTF8( cstring );
56 
57  if( line.IsEmpty() ) // happens when cstring is not a valid UTF8 sequence
58  line = wxConvCurrent->cMB2WC( cstring ); // try to use locale conversion
59 
60  return line;
61 }
static const wxChar* GetChars ( const wxString &  s)
inlinestatic

Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for passing strings to wxString::Printf() and wxString::Format().

It can also be passed a UTF8 parameter which will be converted to wxString by the compiler.

Example: wxString::Format( wxT( "%s" ), GetChars( UTF( "some text" ) ) );

When wxWidgets is properly built for KiCad, a const wxChar* points to either:

  • 32 bit unicode characters on linux/OSX or
  • 16 bit UTF16 characters on windows.

Note that you cannot pass 8 bit strings to wxString::Format() or Printf() so this is a useful conversion function to wxChar*, which is needed by wxString::Format().

Returns
const wxChar* - a pointer to the UNICODE or UTF16 (on windows) text.

Definition at line 92 of file macros.h.

Referenced by DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter(), AddGerberX2Header(), AddMenusForComponent(), AddMenusForEditComponent(), BOARD_NETLIST_UPDATER::addNewComponent(), PL_EDITOR_FRAME::AddPageLayoutItem(), Append_Track_Width_List(), PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), CVPCB_MAINFRAME::AutomaticFootprintMatching(), CVPCB_MAINFRAME::BuildCmpListBox(), CVPCB_MAINFRAME::buildEquivalenceList(), GITHUB_PLUGIN::cacheLib(), DIALOG_EXCHANGE_MODULE::change_1_Module(), DIALOG_EXCHANGE_MODULE::changeSameFootprints(), SCH_REFERENCE_LIST::CheckAnnotation(), EDA_BASE_FRAME::CheckForAutoSaveFile(), DIALOG_BOM::choosePlugin(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), PGM_BASE::ConfigurePaths(), ConvertOutlineToPolygon(), copy_pro_file_template(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), DIALOG_DESIGN_RULES::CopyRulesListToBoard(), create_backup_file(), GERBER_WRITER::CreateDrillandMapFilesSet(), EXCELLON_WRITER::CreateDrillandMapFilesSet(), DIALOG_PLOT_SCHEMATIC::CreateDXFFile(), DIALOG_GEN_MODULE_POSITION::CreateFiles(), CreateHeaderInfoData(), DIALOG_PLOT_SCHEMATIC::createHPGLFile(), GENDRILL_WRITER_BASE::CreateMapFilesSet(), SCH_EDIT_FRAME::CreateNewImage(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), LIB_EDIT_FRAME::CreateNewLibraryPart(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), LIB_EDIT_FRAME::CreatePNGorJPEGFile(), DIALOG_PLOT_SCHEMATIC::createPSFile(), CreateSignalsSection(), DIALOG_PLOT_SCHEMATIC::createSVGFile(), TREEPROJECT_ITEM::Delete(), PCB_EDIT_FRAME::Delete_Drawings_All_Layer(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), LIB_EDIT_FRAME::DeleteOnePart(), PCB_BASE_FRAME::DeletePad(), BOARD_NETLIST_UPDATER::deleteSinglePadNets(), BOARD_NETLIST_UPDATER::deleteUnusedComponents(), Diagnose(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), CVPCB_MAINFRAME::DisplayStatus(), DRC::doNetClass(), EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL(), SCH_EDIT_FRAME::EditComponentFieldText(), LIB_EDIT_FRAME::EditField(), SCH_EDIT_FRAME::EditSheet(), EnsureFileDirectoryExists(), KICAD_MANAGER_FRAME::Execute(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), ExecuteFile(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), DSNLEXER::Expecting(), FOOTPRINT_EDIT_FRAME::Export_Module(), export_vrml_module(), GBR_TO_PCB_EXPORTER::ExportPcb(), DIALOG_SVG_PRINT::ExportSVGFile(), PCB_EDIT_FRAME::ExportToGenCAD(), PL_EDITOR_FRAME::Files_io(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::Fill_All_Zones(), SCH_EDIT_FRAME::FindComponentAndItem(), FindFileInSearchPaths(), SYMBOL_LIB_TABLE::FindRow(), FP_LIB_TABLE::FindRow(), GITHUB_PLUGIN::FootprintDelete(), GPCB_PLUGIN::FootprintEnumerate(), PCB_IO::FootprintEnumerate(), PCB_IO::FootprintSave(), DSN::SPECCTRA_DB::FromBOARD(), DSN::SPECCTRA_DB::FromSESSION(), DIALOG_GENDRILL::GenDrillAndMapFiles(), PCB_EDIT_FRAME::GenFootprintsReport(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), GetAssociatedDocument(), GERBER_FILE_IMAGE_LIST::GetDisplayName(), EDA_BASE_FRAME::GetFileFromHistory(), GITHUB_GETLIBLIST::GetFootprintLibraryList(), GetGerberFileFunctionAttribute(), EDA_BASE_FRAME::GetKicadHelp(), EAGLE_PLUGIN::getModificationTime(), MARKER_PCB::GetMsgPanelInfo(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), MODULE::GetMsgPanelInfo(), getOptimalModulePlacement(), PCB_TARGET::GetSelectMenuText(), LIB_CIRCLE::GetSelectMenuText(), LIB_RECTANGLE::GetSelectMenuText(), LIB_POLYLINE::GetSelectMenuText(), EDGE_MODULE::GetSelectMenuText(), SCH_LINE::GetSelectMenuText(), LIB_TEXT::GetSelectMenuText(), TEXTE_PCB::GetSelectMenuText(), LIB_ARC::GetSelectMenuText(), SCH_FIELD::GetSelectMenuText(), SCH_TEXT::GetSelectMenuText(), SCH_SHEET_PIN::GetSelectMenuText(), TEXTE_MODULE::GetSelectMenuText(), DIMENSION::GetSelectMenuText(), DRAWSEGMENT::GetSelectMenuText(), LIB_FIELD::GetSelectMenuText(), SCH_LABEL::GetSelectMenuText(), TRACK::GetSelectMenuText(), SCH_GLOBALLABEL::GetSelectMenuText(), SCH_HIERLABEL::GetSelectMenuText(), SEGZONE::GetSelectMenuText(), VIA::GetSelectMenuText(), LIB_PIN::GetSelectMenuText(), D_PAD::GetSelectMenuText(), MODULE::GetSelectMenuText(), SCH_SHEET::GetSelectMenuText(), SCH_COMPONENT::GetSelectMenuText(), ZONE_CONTAINER::GetSelectMenuText(), SCH_FIND_COLLECTOR::GetText(), FOOTPRINT_EDIT_FRAME::Import_Module(), DIALOG_EXCHANGE_MODULE::init(), DIALOG_LABEL_EDITOR::InitDialog(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg(), PGM_BASE::InitPgm(), FP_CACHE_ITEM::IsModified(), EDA_BASE_FRAME::IsWritable(), KIWAY::KiFACE(), PART_LIBS::LibNamesAndPaths(), GERBVIEW_FRAME::Liste_D_Codes(), CMP_READER::Load(), FP_CACHE::Load(), LIB_PART::Load(), SCH_EDIT_FRAME::Load_Component(), PART_LIBS::LoadAllLibraries(), PGM_BASE::loadCommonSettings(), LIB_PART::LoadDrawEntries(), EAGLE_PLUGIN::loadElements(), GERBVIEW_FRAME::LoadExcellonFiles(), PCB_BASE_FRAME::LoadFootprint(), LEGACY_NETLIST_READER::loadFootprintFilters(), PCB_EDIT_FRAME::LoadFootprints(), GERBVIEW_FRAME::LoadGerberFiles(), SYMBOL_LIB_TABLE::LoadGlobalTable(), FP_LIB_TABLE::LoadGlobalTable(), SCH_LEGACY_PLUGIN::loadHeader(), EAGLE_PLUGIN::loadLibrary(), PCB_BASE_FRAME::LoadModuleFromLibrary(), SCH_EDIT_FRAME::LoadOneEEFile(), LIB_EDIT_FRAME::LoadOneLibraryPart(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), LIB_EDIT_FRAME::LoadOneSymbol(), PCB_EDIT_FRAME::LoadProjectSettings(), PCB_PARSER::lookUpLayer(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), HTML_MESSAGE_BOX::MessageSet(), DIALOG_CONFIG_EQUFILES::OnAddFiles(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), KICAD_MANAGER_FRAME::OnArchiveFiles(), NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins(), DIALOG_FIND::onButtonFindItemClick(), LIB_EDIT_FRAME::OnCheckComponent(), PL_EDITOR_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnCloseWindow(), TREE_PROJECT_FRAME::OnCreateNewDirectory(), SCH_EDIT_FRAME::OnDragItem(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), SCH_EDIT_FRAME::OnEditItem(), LIB_EDIT_FRAME::OnExportPart(), PCB_EDIT_FRAME::OnExportVRML(), PL_EDITOR_FRAME::OnFileHistory(), SCH_EDIT_FRAME::OnFindDrcMarker(), DIALOG_GENDRILL::OnGenReportFile(), LIB_EDIT_FRAME::OnImportPart(), APP_SINGLE_TOP::OnInit(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), DIALOG_DRC_CONTROL::OnListUnconnectedClick(), KICAD_MANAGER_FRAME::OnLoadProject(), SCH_EDIT_FRAME::OnNewProject(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_NETLIST::OnReadNetlistFileClick(), TREE_PROJECT_FRAME::OnRenameFile(), GERBVIEW_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), APP_SINGLE_TOP::OnRun(), APP_KICAD::OnRun(), FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs(), DIALOG_NETLIST::OnSaveMessagesToFile(), SCH_EDIT_FRAME::OnSaveProject(), GERBVIEW_FRAME::OnShowGerberSourceFile(), DIALOG_DRC_CONTROL::OnStartdrcClick(), KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), PL_EDITOR_FRAME::OpenProjectFiles(), GERBVIEW_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), EDA_ITEM::operator<(), SYMBOL_LIB_TABLE::Parse(), FP_LIB_TABLE::Parse(), PCB_PARSER::Parse(), PCB_PARSER::parseBOARD_unchecked(), KICAD_NETLIST_PARSER::parseComponent(), PCB_PARSER::parseD_PAD(), PCB_PARSER::parseDouble(), PCB_PARSER::parseLayers(), GPCB_FPL_CACHE::parseMODULE(), PCB_PARSER::parseMODULE_unchecked(), KICAD_NETLIST_PARSER::parseNet(), PCB_PARSER::parsePAGE_INFO(), PCB_PARSER::parseTEXTE_MODULE(), PCB_PARSER::parseTRACK(), PCB_PARSER::parseVIA(), PCB_PARSER::parseZONE_CONTAINER(), SCH_EDIT_FRAME::PasteListOfItems(), DIALOG_PLOT::Plot(), PlotSilkScreen(), PlotStandardLayer(), DIALOG_BOM::pluginInit(), KICAD_MANAGER_FRAME::PrintPrjInfo(), PCB_EDIT_FRAME::Process_Config(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), GERBVIEW_FRAME::Read_EXCELLON_File(), GERBVIEW_FRAME::Read_GERBER_File(), GERBER_FILE_IMAGE::ReadApertureMacro(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::ReadPcbNetlist(), DIALOG_EXCHANGE_MODULE::RebuildCmpList(), PL_EDITOR_FRAME::RebuildDesignTree(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), GITHUB_PLUGIN::remoteGetZip(), FP_CACHE::Remove(), LIB_PART::RemoveAlias(), LIB_PART::RemoveDrawItem(), SCH_SHEET::RemovePin(), EDA_ITEM::Replace(), BOARD_NETLIST_UPDATER::replaceComponent(), BOARD::ReplaceNetlist(), SCH_EDIT_FRAME::ReSizeSheet(), WIDGET_HOTKEY_LIST::ResolveKeyConflicts(), ReturnUnitSymbol(), FP_CACHE::Save(), save_library(), LIB_EDIT_FRAME::SaveActiveLibrary(), PGM_BASE::SaveCommonSettings(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::SaveOnePart(), LIB_EDIT_FRAME::SaveOneSymbol(), DIALOG_PAGES_SETTINGS::SavePageSettings(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SearchHelpFileFullPath(), PCB_BASE_FRAME::SelectFootprint(), PCB_BASE_FRAME::SelectLibrary(), FOOTPRINTS_LISTBOX::SetFootprints(), PGM_BASE::SetLanguage(), PGM_BASE::SetLocalEnvVariable(), PGM_BASE::SetLocalEnvVariables(), CVPCB_MAINFRAME::SetNewPkg(), DRC_ITEM::ShowHtml(), DRC_ITEM::ShowReport(), SimilarLabelsDiagnose(), PCB_EDIT_FRAME::Solve(), SCH_BITMAP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_SHEET::SwapData(), BOARD_NETLIST_UPDATER::testConnectivity(), DIALOG_DESIGN_RULES::TestDataValidity(), DIALOG_ENV_VAR_CONFIG::TransferDataFromWindow(), DIALOG_MODULE_MODULE_EDITOR::TransferDataFromWindow(), DialogEditModuleText::TransferDataToWindow(), GERBVIEW_FRAME::unarchiveFiles(), DSNLEXER::Unexpected(), FOOTPRINT_WIZARD_FRAME::Update3D_Frame(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), BOARD_NETLIST_UPDATER::updateComponentParameters(), SCH_EDIT_FRAME::updateFindReplaceView(), BOARD_NETLIST_UPDATER::UpdateNetlist(), LIB_EDIT_FRAME::UpdatePartSelectList(), SCH_EDIT_FRAME::UpdateTitle(), GERBVIEW_FRAME::UpdateTitleAndInfo(), DIALOG_NETLIST::verifyFootprints(), DIALOG_FP_LIB_TABLE::verifyTables(), WriteDiagnosticERC(), EDA_BASE_FRAME::WriteHotkeyConfig(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), PCB_EDITOR_CONTROL::ZoneFillAll(), LIB_ALIAS::~LIB_ALIAS(), LIB_PART::~LIB_PART(), and SCH_LEGACY_PLUGIN_CACHE::~SCH_LEGACY_PLUGIN_CACHE().

93 {
94  return (const wxChar*) s.c_str();
95 }
template<typename T >
T Mirror ( aPoint,
aMirrorRef 
)

Function MIRROR Mirror aPoint in aMirrorRef.

Definition at line 106 of file macros.h.

Referenced by MIRROR(), MirrorMarkedItems(), SCH_TEXT::MirrorX(), SCH_LABEL::MirrorX(), SCH_GLOBALLABEL::MirrorX(), SCH_HIERLABEL::MirrorX(), SCH_TEXT::MirrorY(), SCH_GLOBALLABEL::MirrorY(), and SCH_HIERLABEL::MirrorY().

107 {
108  return -( aPoint - aMirrorRef ) + aMirrorRef;
109 }
template<typename T >
void MIRROR ( T &  aPoint,
const T &  aMirrorRef 
)