7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-03-30 06:46:34 +00:00

Common folder housekeeping part 1.

This commit is contained in:
Wayne Stambaugh 2025-01-12 11:27:18 -05:00
parent 4ba1c0130c
commit 5c8f4697ca
96 changed files with 707 additions and 581 deletions
common
advanced_config.cppbackground_jobs_monitor.cppbitmap.cppbitmap_base.cppbuild_version.cppcommit.cppcommon.cppconfig_params.cppdesign_block.hdesign_block_info.cppdesign_block_info.hdesign_block_io.cppdesign_block_io.hdesign_block_lib_table.cpp
dialog_about
dialog_shim.cpp
dialogs
draw_panel_gal.cpp
drawing_sheet
dsnlexer.cppeda_base_frame.cppeda_draw_frame.cppeda_pattern_match.cppeda_shape.cppeda_text.cppeda_tools.cppeda_units.cppembedded_files.cppenv_paths.cppenv_vars.cppexceptions.cppfilename_resolver.cpp
font
fp_lib_table.cpp
gal
gbr_metadata.cppgestfich.cpp
git
gr_basic.cppgr_text.cpp
eeschema
include
pcbnew/dialogs

View File

@ -169,7 +169,8 @@ wxString dumpParamCfg( const PARAM_CFG& aParam )
s << *static_cast<const PARAM_CFG_FILENAME&>( aParam ).m_Pt_param;
break;
case paramcfg_id::PARAM_BOOL:
s << ( *static_cast<const PARAM_CFG_BOOL&>( aParam ).m_Pt_param ? wxS( "true" ) : wxS( "false" ) );
s << ( *static_cast<const PARAM_CFG_BOOL&>( aParam ).m_Pt_param ? wxS( "true" )
: wxS( "false" ) );
break;
default: s << wxS( "Unsupported PARAM_CFG variant: " ) << aParam.m_Type;
}
@ -195,7 +196,7 @@ static void dumpCfg( const std::vector<PARAM_CFG*>& aArray )
/**
* Get the filename for the advanced config file
* Get the filename for the advanced config file.
*
* The user must check the file exists if they care.
*/
@ -349,7 +350,7 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
m_ExtraClearance, 0.0, 1.0 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableCreepageSlot,
&m_EnableCreepageSlot, m_EnableCreepageSlot ) );
&m_EnableCreepageSlot, m_EnableCreepageSlot ) );
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::DRCEpsilon,
@ -444,7 +445,8 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
&m_Skip3DModelFileCache, m_Skip3DModelFileCache ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::Skip3DModelMemoryCache,
&m_Skip3DModelMemoryCache, m_Skip3DModelMemoryCache ) );
&m_Skip3DModelMemoryCache,
m_Skip3DModelMemoryCache ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::HideVersionFromTitle,
&m_HideVersionFromTitle, m_HideVersionFromTitle ) );
@ -540,12 +542,13 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
0, 2147483647 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::MinorSchematicGraphSize,
&m_MinorSchematicGraphSize, m_MinorSchematicGraphSize,
0, 2147483647 ) );
&m_MinorSchematicGraphSize,
m_MinorSchematicGraphSize,
0, 2147483647 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::ResolveTextRecursionDepth,
&m_ResolveTextRecursionDepth,
m_ResolveTextRecursionDepth, 0, 10 ) );
&m_ResolveTextRecursionDepth,
m_ResolveTextRecursionDepth, 0, 10 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableExtensionSnaps,
&m_EnableExtensionSnaps,
@ -568,7 +571,8 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
0.0, 45.0 ) );
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::HoleWallPaintingMultiplier,
&m_HoleWallPaintingMultiplier, m_HoleWallPaintingMultiplier,
&m_HoleWallPaintingMultiplier,
m_HoleWallPaintingMultiplier,
0.1, 100.0 ) );
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::MsgPanelShowUuids,
@ -602,7 +606,8 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
for( PARAM_CFG* param : configParams )
delete param;
wxLogTrace( kicadTraceCoroutineStack, wxT( "Using coroutine stack size %d" ), m_CoroutineStackSize );
wxLogTrace( kicadTraceCoroutineStack, wxT( "Using coroutine stack size %d" ),
m_CoroutineStackSize );
}

View File

@ -55,16 +55,17 @@ public:
m_stName = new wxStaticText( this, wxID_ANY, aJob->m_name );
m_stName->Wrap( -1 );
m_stName->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT,
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false,
wxEmptyString ) );
mainSizer->Add( m_stName, 0, wxALL | wxEXPAND, 1 );
m_stStatus = new wxStaticText( this, wxID_ANY, aJob->m_status, wxDefaultPosition,
wxDefaultSize, 0 );
wxDefaultSize, 0 );
m_stStatus->Wrap( -1 );
mainSizer->Add( m_stStatus, 0, wxALL | wxEXPAND, 1 );
m_progress = new wxGauge( this, wxID_ANY, aJob->m_maxProgress, wxDefaultPosition, wxDefaultSize,
wxGA_HORIZONTAL );
m_progress = new wxGauge( this, wxID_ANY, aJob->m_maxProgress, wxDefaultPosition,
wxDefaultSize, wxGA_HORIZONTAL );
m_progress->SetValue( 0 );
mainSizer->Add( m_progress, 0, wxALL | wxEXPAND, 1 );
@ -134,7 +135,7 @@ public:
m_scrolledWindow->Layout();
m_contentSizer->Fit( m_scrolledWindow );
// call this at this window otherwise the child panels dont resize width properly
// call this at this window otherwise the child panels don't resize width properly
Layout();
m_jobPanels[aJob] = panel;
@ -261,9 +262,9 @@ void BACKGROUND_JOBS_MONITOR::Remove( std::shared_ptr<BACKGROUND_JOB> aJob )
std::lock_guard<std::shared_mutex> lock( m_mutex );
m_jobs.erase( std::remove_if( m_jobs.begin(), m_jobs.end(),
[&]( std::shared_ptr<BACKGROUND_JOB> job )
{
{
return job == aJob;
} ) );
} ) );
if( m_jobs.size() == 0 )
{
@ -370,4 +371,4 @@ void BACKGROUND_JOBS_MONITOR::UnregisterStatusBar( KISTATUSBAR* aStatusBar )
{
return statusBar == aStatusBar;
} ) );
}
}

View File

@ -123,13 +123,13 @@ int KiIconScale( wxWindow* aWindow )
{
// For historical reasons, "4" here means unity (no scaling)
#if defined( __WXMSW__)
// Basically don't try and scale within kicad and let wx do its thing
#if defined( __WXMSW__)
// Basically don't try and scale within KiCad and let wx do its thing
// with wx introducing bitmap bundles, it will auto scale automatically with dpi
// the issue is, none of the scaling factors have any tie to system scaling
// this means wx is actually going to scale again causing even more distorted icons
return 4;
#else
#else
const int vert_size = aWindow->ConvertDialogToPixels( wxSize( 0, 8 ) ).y;
// Autoscale won't exceed unity until the system has quite high resolution,
@ -140,7 +140,7 @@ int KiIconScale( wxWindow* aWindow )
else if( vert_size > 29 ) return 7;
else if( vert_size > 24 ) return 6;
else return 4;
#endif
#endif
}
@ -188,7 +188,7 @@ wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, wxWindow* aWindow )
{
wxImage image = aBitmap.ConvertToImage();
image.Rescale( scale * image.GetWidth() / 4, scale * image.GetHeight() / 4,
wxIMAGE_QUALITY_BILINEAR );
wxIMAGE_QUALITY_BILINEAR );
return wxBitmap( image );
}

View File

@ -195,8 +195,10 @@ bool BITMAP_BASE::SaveImageData( wxOutputStream& aOutStream ) const
{
if( m_imageData.IsEmpty() )
{
// If m_imageData is empty, use wxImage::Save() method to write m_image contents to the stream.
wxBitmapType type = m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG;
// If m_imageData is empty, use wxImage::Save() method to write m_image contents to
// the stream.
wxBitmapType type = m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG
: wxBITMAP_TYPE_PNG;
if( !m_image->SaveFile( aOutStream, type ) )
{
@ -222,7 +224,7 @@ bool BITMAP_BASE::LoadLegacyData( LINE_READER& aLine, wxString& aErrorMsg )
{
if( !aLine.ReadLine() )
{
aErrorMsg = wxT("Unexpected end of data");
aErrorMsg = wxT( "Unexpected end of data" );
return false;
}
@ -298,16 +300,16 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos,
// Now we have an issue on wxWidgets 3.1.6 to fix the clip area
// and the bitmap position when using TransformMatrix
// So for version == 3.1.6 do not use it
// Be carefull before changing the code.
// Be careful before changing the code.
bool useTransform = aDC->CanUseTransformMatrix();
wxAffineMatrix2D init_matrix = aDC->GetTransformMatrix();
// Note: clipping bitmap area was made to fix a minor issue in old versions of
// Kicad/wxWidgets (5.1 / wx 3.0)
// KiCad/wxWidgets (5.1 / wx 3.0)
// However SetClippingRegion creates a lot of issues (different ways to fix the
// position and size of the area, depending on wxWidget version)because it changes with
// each versions of wxWigets, so it is now disabled
// position and size of the area, depending on wxWidgets version)because it changes with
// each versions of wxWidgets, so it is now disabled
// However the code is still here, just in case
// #define USE_CLIP_AREA
@ -319,6 +321,7 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos,
matrix.Translate( pos.x, pos.y );
matrix.Scale( GetScalingFactor(), GetScalingFactor() );
aDC->SetTransformMatrix( matrix );
// Needed on wx <= 3.1.5, and this is strange...
// Nevertheless, this code has problem (the bitmap is not seen)
// with wx version > 3.1.5
@ -341,10 +344,10 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos,
clipAreaPos.y = pos.y;
}
#ifdef USE_CLIP_AREA
#ifdef USE_CLIP_AREA
aDC->DestroyClippingRegion();
aDC->SetClippingRegion( clipAreaPos, wxSize( size.x, size.y ) );
#endif
#endif
if( aBackgroundColor != COLOR4D::UNSPECIFIED && m_bitmap->HasAlpha() )
{
@ -383,9 +386,9 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos,
aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
}
#ifdef USE_CLIP_AREA
#ifdef USE_CLIP_AREA
aDC->DestroyClippingRegion();
#endif
#endif
}
@ -413,7 +416,7 @@ void BITMAP_BASE::Mirror( FLIP_DIRECTION aFlipDirection )
// wxImage::Mirror() clear some parameters of the original image.
// We need to restore them, especially resolution and unit, to be
// sure image parameters saved in file are the right parameters, not
// the defualt values
// the default values
int resX = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
int resY = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
int unit = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT );
@ -442,16 +445,16 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
// wxImage::Rotate90() clear some parameters of the original image.
// We need to restore them, especially resolution and unit, to be
// sure image parameters saved in file are the right parameters, not
// the defualt values
// the default values
int resX = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
int resY = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
int unit = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT );
*m_image = m_image->Rotate90( aRotateCCW );
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT , unit);
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX);
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONY, resY);
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT, unit );
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX );
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONY, resY );
m_rotation += ( aRotateCCW ? ANGLE_90 : -ANGLE_90 );
rebuildBitmap( false );
@ -492,7 +495,8 @@ void BITMAP_BASE::UpdateImageDataBuffer()
if( m_image )
{
wxMemoryOutputStream stream;
wxBitmapType type = m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG;
wxBitmapType type = m_imageType == wxBITMAP_TYPE_JPEG ? wxBITMAP_TYPE_JPEG
: wxBITMAP_TYPE_PNG;
if( !m_image->SaveFile( stream, type ) )
return;

View File

@ -125,6 +125,7 @@ wxString GetMajorMinorPatchVersion()
return msg;
}
const std::tuple<int,int,int>& GetMajorMinorPatchTuple()
{
static std::tuple<int, int, int> retval = KICAD_MAJOR_MINOR_PATCH_TUPLE;

View File

@ -135,7 +135,8 @@ int COMMIT::GetStatus( EDA_ITEM* aItem, BASE_SCREEN *aScreen )
}
COMMIT& COMMIT::createModified( EDA_ITEM* aItem, EDA_ITEM* aCopy, int aExtraFlags, BASE_SCREEN* aScreen )
COMMIT& COMMIT::createModified( EDA_ITEM* aItem, EDA_ITEM* aCopy, int aExtraFlags,
BASE_SCREEN* aScreen )
{
EDA_ITEM* parent = parentObject( aItem );
@ -163,8 +164,8 @@ void COMMIT::makeEntry( EDA_ITEM* aItem, CHANGE_TYPE aType, EDA_ITEM* aCopy, BAS
ent.m_copy = aCopy;
ent.m_screen = aScreen;
// N.B. Do not throw an assertion for multiple changed items. An item can be changed multiple times
// in a single commit such as when importing graphics and grouping them.
// N.B. Do not throw an assertion for multiple changed items. An item can be changed
// multiple times in a single commit such as when importing graphics and grouping them.
m_changedItems.insert( aItem );
m_changes.push_back( ent );

View File

@ -139,7 +139,8 @@ bool IsTextVar( const wxString& aSource )
//
// Stolen from wxExpandEnvVars and then heavily optimized
//
wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject, std::set<wxString>* aSet = nullptr )
wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject,
std::set<wxString>* aSet = nullptr )
{
// If the same string is inserted twice, we have a loop
if( aSet )
@ -254,7 +255,8 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject, std::s
// If the user has the older location defined, that will be matched
// first above. But if they do not, this will ensure that their board still
// displays correctly
else if( strVarName.Contains( "KISYS3DMOD") || strVarName.Matches( "KICAD*_3DMODEL_DIR" ) )
else if( strVarName.Contains( "KISYS3DMOD")
|| strVarName.Matches( "KICAD*_3DMODEL_DIR" ) )
{
if( getVersionedEnvVar( "KICAD*_3DMODEL_DIR", strResult ) )
expanded = true;
@ -320,13 +322,14 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject, std::s
case wxT( '\\' ):
// backslash can be used to suppress special meaning of % and $
if( n < strlen - 1 && (str[n + 1] == wxT( '%' ) || str[n + 1] == wxT( '$' )) )
if( n < strlen - 1 && (str[n + 1] == wxT( '%' ) || str[n + 1] == wxT( '$' ) ) )
{
str_n = str[++n];
strResult += str_n;
break;
}
KI_FALLTHROUGH;
default:
@ -475,7 +478,7 @@ bool matchWild( const char* pat, const char* text, bool dot_special )
return false;
}
for(;;)
for( ;; )
{
if( *m == '*' )
{
@ -565,13 +568,13 @@ bool matchWild( const char* pat, const char* text, bool dot_special )
* A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function
* private to src/common/filename.cpp.
*/
#if wxUSE_DATETIME && defined(__WIN32__) && !defined(__WXMICROWIN__)
#if wxUSE_DATETIME && defined( __WIN32__ ) && !defined( __WXMICROWIN__ )
// Convert between wxDateTime and FILETIME which is a 64-bit value representing
// the number of 100-nanosecond intervals since January 1, 1601 UTC.
//
// This is the offset between FILETIME epoch and the Unix/wxDateTime Epoch.
static wxInt64 EPOCH_OFFSET_IN_MSEC = wxLL(11644473600000);
static wxInt64 EPOCH_OFFSET_IN_MSEC = wxLL( 11644473600000 );
static void ConvertFileTimeToWx( wxDateTime* dt, const FILETIME& ft )

View File

@ -234,7 +234,7 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
// We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// and truncate issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param * m_BIU_to_cfgunit );
}
@ -291,7 +291,7 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
// We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// and truncate issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param );
}
@ -451,7 +451,7 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
// under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__
prm.Replace(wxT("/"), wxT("\\"));
prm.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
*m_Pt_param = prm;
}
@ -463,8 +463,9 @@ void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) const
return;
wxString prm = *m_Pt_param;
// filenames are stored using Unix notation
prm.Replace(wxT("\\"), wxT("/") );
prm.Replace( wxT( "\\" ), wxT( "/" ) );
aConfig->Write( m_Ident, prm );
}
@ -497,13 +498,14 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
if( libname.IsEmpty() )
break;
// file names are stored using Unix notation
// under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__
libname.Replace(wxT("/"), wxT("\\"));
libname.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
libname_list->Add( libname );
libname_list->Add( libname );
}
}
@ -523,11 +525,11 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) const
configkey = m_Ident;
// We use indexlib+1 because first lib name is LibName1
configkey << (indexlib + 1);
configkey << ( indexlib + 1 );
libname = libname_list->Item( indexlib );
// filenames are stored using Unix notation
libname.Replace(wxT("\\"), wxT("/") );
libname.Replace( wxT( "\\" ), wxT( "/" ) );
aConfig->Write( configkey, libname );
}
}

View File

@ -45,17 +45,19 @@ public:
{
m_fields = std::move( aFields );
}
const nlohmann::ordered_map<wxString, wxString>& GetFields() const { return m_fields; }
DESIGN_BLOCK() = default;
///< This is the only way to get m_fields to compile as a class member
/// This is the only way to get m_fields to compile as a class member.
DESIGN_BLOCK( DESIGN_BLOCK&& aOther ) = delete;
private:
LIB_ID m_lib_id;
wxString m_schematicFile; // File name and path for schematic symbol.
wxString m_libDescription; // File name and path for documentation file.
wxString m_keywords; // Search keywords to find footprint in library.
wxString m_schematicFile; ///< File name and path for schematic symbol.
wxString m_libDescription; ///< File name and path for documentation file.
wxString m_keywords; ///< Search keywords to find footprint in library.
nlohmann::ordered_map<wxString, wxString> m_fields;
};

View File

@ -22,8 +22,8 @@
*/
/*
* Functions to read design block libraries and fill m_design_blocks by available design blocks names
* and their documentation (comments and keywords)
* Functions to read design block libraries and fill m_design_blocks by available design blocks
* names and their documentation (comments and keywords).
*/
#include <design_block_info.h>

View File

@ -49,7 +49,7 @@ class KIWAY;
class wxTextFile;
/*
/**
* Helper class to handle the list of design blocks available in libraries. It stores
* design block names, doc and keywords.
*

View File

@ -73,7 +73,8 @@ DESIGN_BLOCK_IO* DESIGN_BLOCK_IO_MGR::FindPlugin( DESIGN_BLOCK_FILE_T aFileType
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T
DESIGN_BLOCK_IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl )
{
if( IO_RELEASER<DESIGN_BLOCK_IO>( FindPlugin( KICAD_SEXP ) )->CanReadLibrary( aLibPath ) && aCtl != KICTL_NONKICAD_ONLY )
if( IO_RELEASER<DESIGN_BLOCK_IO>( FindPlugin( KICAD_SEXP ) )->CanReadLibrary( aLibPath )
&& aCtl != KICTL_NONKICAD_ONLY )
return KICAD_SEXP;
return DESIGN_BLOCK_IO_MGR::FILE_TYPE_NONE;
@ -152,8 +153,8 @@ long long DESIGN_BLOCK_IO::GetLibraryTimestamp( const wxString& aLibraryPath ) c
{
wxFileName blockDir( aLibraryPath, filename );
// Check if the directory ends with ".kicad_block", if so hash all the files in it.
if( blockDir.GetFullName().EndsWith( FILEEXT::KiCadDesignBlockPathExtension ) )
// Check if the directory ends with ".kicad_block", if so hash all the files in it
ts += TimestampDir( blockDir.GetFullPath(), wxT( "*" ) );
hasMoreFiles = libDir.GetNext( &filename );
@ -282,10 +283,11 @@ DESIGN_BLOCK* DESIGN_BLOCK_IO::DesignBlockLoad( const wxString& aLibraryPath,
const wxString& aDesignBlockName, bool aKeepUUID,
const std::map<std::string, UTF8>* aProperties )
{
wxString dbPath = aLibraryPath + wxFileName::GetPathSeparator() +
aDesignBlockName + wxT( "." ) + FILEEXT::KiCadDesignBlockPathExtension + wxFileName::GetPathSeparator();
wxString dbSchPath = dbPath + aDesignBlockName + wxT( "." ) + FILEEXT::KiCadSchematicFileExtension;
wxString dbMetadataPath = dbPath + aDesignBlockName + wxT( "." ) + FILEEXT::JsonFileExtension;
wxString dbPath = aLibraryPath + wxFileName::GetPathSeparator() + aDesignBlockName + wxT( "." )
+ FILEEXT::KiCadDesignBlockPathExtension + wxFileName::GetPathSeparator();
wxString dbSchPath = dbPath + aDesignBlockName + wxT( "." )
+ FILEEXT::KiCadSchematicFileExtension;
wxString dbMetadataPath = dbPath + aDesignBlockName + wxT( "." ) + FILEEXT::JsonFileExtension;
if( !wxFileExists( dbSchPath ) )
return nullptr;

View File

@ -47,8 +47,9 @@ public:
static DESIGN_BLOCK_IO* FindPlugin( DESIGN_BLOCK_FILE_T aFileType );
static DESIGN_BLOCK_FILE_T EnumFromStr( const wxString& aFileType );
static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath, int aCtl = 0 );
/**
* Convert a design block library to the latest KiCad format
* Convert a design block library to the latest KiCad format.
*/
static bool ConvertLibrary( std::map<std::string, UTF8>* aOldFileProps,
const wxString& aOldFilePath, const wxString& aNewFilePath );

View File

@ -158,6 +158,7 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
case T_uri:
if( sawUri )
in->Duplicate( tok );
sawUri = true;
in->NeedSYMBOLorNUMBER();
row->SetFullURI( in->FromUTF8() );
@ -166,6 +167,7 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
case T_type:
if( sawType )
in->Duplicate( tok );
sawType = true;
in->NeedSYMBOLorNUMBER();
row->SetType( in->FromUTF8() );
@ -174,6 +176,7 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
case T_options:
if( sawOpts )
in->Duplicate( tok );
sawOpts = true;
in->NeedSYMBOLorNUMBER();
row->SetOptions( in->FromUTF8() );
@ -182,6 +185,7 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
case T_descr:
if( sawDesc )
in->Duplicate( tok );
sawDesc = true;
in->NeedSYMBOLorNUMBER();
row->SetDescr( in->FromUTF8() );
@ -190,13 +194,14 @@ void DESIGN_BLOCK_LIB_TABLE::Parse( LIB_TABLE_LEXER* in )
case T_disabled:
if( sawDisabled )
in->Duplicate( tok );
sawDisabled = true;
row->SetEnabled( false );
break;
case T_hidden:
// Hiding design block libraries is not yet supported. Unclear what path can set this
// attribute, but clear it on load.
// Hiding design block libraries is not yet supported. Unclear what path can
// set this attribute, but clear it on load.
row->SetVisible();
break;
@ -358,7 +363,8 @@ static void setLibNickname( DESIGN_BLOCK* aModule, const wxString& aNickname,
// having to copy the LIB_ID and its two strings, twice each.
LIB_ID& dbid = (LIB_ID&) aModule->GetLibId();
// Catch any misbehaving plugin, which should be setting internal design block name properly:
// Catch any misbehaving plugin, which should be setting internal design block name
// properly:
wxASSERT( aDesignBlockName == dbid.GetLibItemName().wx_str() );
// and clearing nickname
@ -534,8 +540,9 @@ public:
{
wxFileName dir = wxFileName::DirName( dirPath );
// consider a directory to be a lib if it's name ends with the design block lib dir extension
// it is under $KICADn_3RD_PARTY/design_blocks/<pkgid>/ i.e. has nested level of at least +3
// consider a directory to be a lib if it's name ends with the design block lib dir
// extension it is under $KICADn_3RD_PARTY/design_blocks/<pkgid>/ i.e. has nested
// level of at least +3.
if( dirPath.EndsWith( wxString::Format( wxS( ".%s" ),
FILEEXT::KiCadDesignBlockLibPathExtension ) )
&& dir.GetDirCount() >= m_prefix_dir_count + 3 )

View File

@ -111,7 +111,7 @@ public:
void SetAppIcon( const wxIcon& aIcon ) { m_appIcon = aIcon; }
wxIcon& GetAppIcon() { return m_appIcon; }
///< Wrapper to manage memory allocation for bitmaps
/// Wrapper to manage memory allocation for bitmaps.
wxBitmap* CreateKiBitmap( BITMAPS aBitmap )
{
m_bitmaps.emplace_back( KiBitmapNew( aBitmap ) );
@ -136,7 +136,7 @@ private:
wxIcon m_appIcon;
///< Bitmaps to be freed when the dialog is closed
/// Bitmaps to be freed when the dialog is closed.
std::vector<std::unique_ptr<wxBitmap>> m_bitmaps;
};

View File

@ -397,7 +397,8 @@ void DIALOG_SHIM::SelectAllInTextCtrls( wxWindowList& children )
else if( wxStyledTextCtrl* scintilla = dynamic_cast<wxStyledTextCtrl*>( child ) )
{
m_beforeEditValues[ scintilla ] = scintilla->GetText();
scintilla->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ),
scintilla->Connect( wxEVT_SET_FOCUS,
wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ),
nullptr, this );
if( !scintilla->GetSelectedText().IsEmpty() )

View File

@ -53,8 +53,10 @@ DIALOG_ASSIGN_NETCLASS::DIALOG_ASSIGN_NETCLASS( EDA_BASE_FRAME* aParent, const w
m_matchingNets->SetFont( KIUI::GetInfoFont( this ) );
m_info->SetFont( KIUI::GetInfoFont( this ).Italic() );
// @translate the string below.
if( aParent->GetFrameType() == FRAME_PCB_EDITOR )
m_info->SetLabel( wxT( "Note: complete netclass assignments can be edited in Board Setup > Project." ) );
m_info->SetLabel( wxT( "Note: complete netclass assignments can be edited in Board "
"Setup > Project." ) );
SetupStandardButtons();

View File

@ -110,7 +110,8 @@ DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER()
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
wxASSERT( cfg );
cfg->m_ColorPicker.default_tab = m_notebook->GetSelection();
if( cfg )
cfg->m_ColorPicker.default_tab = m_notebook->GetSelection();
delete m_bitmapRGB;
delete m_bitmapHSV;
@ -393,7 +394,7 @@ void DIALOG_COLOR_PICKER::createHSVBitmap()
color.FromHSV( hue, sat, 1.0 );
img.SetRGB( MAPX( xx ), MAPY( yy ), color.r*255, color.g*255, color.b*255 );
img.SetRGB( MAPX( xx ), MAPY( yy ), color.r * 255, color.g * 255, color.b * 255 );
}
}
@ -421,7 +422,8 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
// Use Y axis from bottom to top and origin to center
bitmapDC.SetAxisOrientation( true, true );
#if defined( __WXMSW__)
#if defined( __WXMSW__ )
// For some reason, SetDeviceOrigin has changed in wxWidgets 3.1.6 or 3.1.7
bitmapDC.SetDeviceOrigin( half_size, -half_size );
#else
@ -429,7 +431,7 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
#endif
// Reserve room to draw cursors inside the bitmap
half_size -= m_cursorsSize/2;
half_size -= m_cursorsSize / 2;
// Draw the 3 RGB cursors, using white color to make them always visible:
wxPen pen( wxColor( 255, 255, 255 ), 2 ); // use 2 pixels for pen size
@ -638,7 +640,7 @@ void DIALOG_COLOR_PICKER::onRGBMouseClick( wxMouseEvent& event )
dist = m_cursorBitmapGreen - mousePos;
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
if( std::abs( dist.x ) <= m_cursorsSize / 2 && std::abs( dist.y ) <= m_cursorsSize / 2 )
{
m_selectedCursor = &m_cursorBitmapGreen;
return;
@ -646,7 +648,7 @@ void DIALOG_COLOR_PICKER::onRGBMouseClick( wxMouseEvent& event )
dist = m_cursorBitmapBlue - mousePos;
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
if( std::abs( dist.x ) <= m_cursorsSize / 2 && std::abs( dist.y ) <= m_cursorsSize / 2 )
{
m_selectedCursor = &m_cursorBitmapBlue;
return;

View File

@ -86,7 +86,8 @@ bool DIALOG_GLOBAL_DESIGN_BLOCK_LIB_TABLE_CONFIG::TransferDataFromWindow()
return false;
}
// Make sure the design block library table to copy is a valid design block library table file.
// Make sure the design block library table to copy is a valid design block library
// table file.
DESIGN_BLOCK_LIB_TABLE tmpTable;
try

View File

@ -49,7 +49,8 @@ DIALOG_IMPORT_CHOOSE_PROJECT::DIALOG_IMPORT_CHOOSE_PROJECT( wxWindow* aParent,
{
m_listCtrl->InsertItem( row, convertName( desc.ComboName, desc.ComboId ) );
m_listCtrl->SetItem( row, pcbNameColId, convertName( desc.PCBName, desc.PCBId ) );
m_listCtrl->SetItem( row, schNameColId, convertName( desc.SchematicName, desc.SchematicId ) );
m_listCtrl->SetItem( row, schNameColId, convertName( desc.SchematicName,
desc.SchematicId ) );
++row;
}

View File

@ -25,7 +25,8 @@
#include <bitmaps.h>
DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, std::size_t aLockedItemCount,
DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent,
std::size_t aLockedItemCount,
PCBNEW_SETTINGS::LOCKING_OPTIONS& aLockingOptions ) :
DIALOG_LOCKED_ITEMS_QUERY_BASE( aParent ),
m_lockingOptions( aLockingOptions )

View File

@ -78,7 +78,8 @@ static const wxString pageFmts[] =
// to be recognized in code
};
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, EMBEDDED_FILES* aEmbeddedFiles, double aIuPerMils,
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent,
EMBEDDED_FILES* aEmbeddedFiles, double aIuPerMils,
const VECTOR2D& aMaxUserSizeMils ) :
DIALOG_PAGES_SETTINGS_BASE( aParent ),
m_parent( aParent ),
@ -602,8 +603,10 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
{
int lyWidth, lyHeight;
VECTOR2D clamped_layout_size( std::clamp( m_layout_size.x, (double)MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.x ),
std::clamp( m_layout_size.y, (double)MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.y ) );
VECTOR2D clamped_layout_size( std::clamp( m_layout_size.x, (double) MIN_PAGE_SIZE_MILS,
m_maxPageSizeMils.x ),
std::clamp( m_layout_size.y, (double) MIN_PAGE_SIZE_MILS,
m_maxPageSizeMils.y ) );
double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
(double) clamped_layout_size.y / clamped_layout_size.x :

View File

@ -34,7 +34,8 @@
#define INITIAL_HELP \
_( "Select an <b>Option Choice</b> in the listbox above, and then click the <b>Append Selected Option</b> button." )
_( "Select an <b>Option Choice</b> in the listbox above, and then click the " \
"<b>Append Selected Option</b> button." )
DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS( wxWindow* aParent,
@ -64,8 +65,8 @@ DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS( wxWindow* aParent,
{
unsigned int row = 0;
for( std::map<std::string, UTF8>::const_iterator it = m_choices.begin(); it != m_choices.end();
++it, ++row )
for( std::map<std::string, UTF8>::const_iterator it = m_choices.begin();
it != m_choices.end(); ++it, ++row )
{
wxString item = From_UTF8( it->first.c_str() );

View File

@ -35,14 +35,15 @@ static constexpr double MAX_SCALE = 100.0;
/**
* Custom print preview frame.
* This derived preview frame remembers its size and position during a session
*
* This derived preview frame remembers its size and position during a session.
*/
class KI_PREVIEW_FRAME : public wxPreviewFrame
{
public:
KI_PREVIEW_FRAME( wxPrintPreview* aPreview, wxWindow* aParent,
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize ) :
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize ) :
wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
{
}
@ -271,7 +272,7 @@ void DIALOG_PRINT_GENERIC::onPrintPreview( wxCommandEvent& event )
// Must be called after InitializeWithModality because otherwise in some wxWidget
// versions it is not always taken in account
frame->SetMinSize( wxSize( 650, 500 ) );
frame->SetSize( (m_parent->GetSize() * 3) / 4 );
frame->SetSize( ( m_parent->GetSize() * 3 ) / 4 );
frame->Raise(); // Needed on Ubuntu/Unity to display the frame
frame->Show( true );

View File

@ -303,7 +303,8 @@ void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLaye
KIUI::AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
if( !readOnly && current != saved )
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( BITMAPS::undo ) );
KIUI::AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ),
KiBitmap( BITMAPS::undo ) );
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
[&]( wxCommandEvent& aCmd )

Some files were not shown because too many files have changed in this diff Show More