Merge remote-tracking branch 'origin/master' into last_net_inspector_settings

This commit is contained in:
Yang Hongbo 2023-11-22 07:21:03 +08:00
commit f324b1b88d
18 changed files with 143 additions and 90 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2023 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
@ -91,7 +91,7 @@ RENDER_3D_RAYTRACE::~RENDER_3D_RAYTRACE()
int RENDER_3D_RAYTRACE::GetWaitForEditingTimeOut()
{
return 1000; // ms
return 200; // ms
}

View File

@ -292,6 +292,14 @@ bool DIALOG_SHIM::Show( bool show )
std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ),
0 );
}
#ifdef __WXMAC__
if( m_parent != nullptr )
{
if( wxDisplay::GetFromPoint( m_parent->GetPosition() )
!= wxDisplay::GetFromPoint( savedDialogRect.GetPosition() ) )
Centre();
}
#endif
}
else if( m_initialSize != wxDefaultSize )
{

View File

@ -23,6 +23,7 @@
#include <eda_base_frame.h>
#include <eda_pattern_match.h>
#include <kiface_base.h>
#include <kiplatform/ui.h>
#include <lib_tree_model_adapter.h>
#include <project/project_file.h>
#include <settings/app_settings.h>
@ -85,13 +86,15 @@ public:
points[3] = aRect.GetBottomRight() + wxPoint( -4, 1 );
points[4] = aRect.GetBottomLeft() + wxPoint( 0, 1 );
points[5] = aRect.GetTopLeft();
dc->SetPen( KIPLATFORM::UI::IsDarkTheme() ? *wxWHITE_PEN : *wxBLACK_PEN );
dc->DrawLines( 6, points );
}
// We should be able to pass wxDATAVIEW_CELL_SELECTED into RenderText() and have it do
// the right thing -- but it picks wxSYS_COLOUR_HIGHLIGHTTEXT on MacOS and GTK (instead
// of wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT).
if ( aState & wxDATAVIEW_CELL_SELECTED )
if( aState & wxDATAVIEW_CELL_SELECTED )
dc->SetTextForeground( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
aRect.Deflate( 1 );

View File

@ -137,8 +137,10 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
wxT( "*.stp" ), wxT( "*.step" ), // 3d files
wxT( "*.wrl" ),
wxT( "*.g?" ), wxT( "*.g??" ), // Gerber files
wxT( "*.gm??"), // Some gerbers like .gm12 (from protel export)
wxT( "*.gbrjob" ), // Gerber job files
wxT( "*.pos" ), wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab files
wxT( "*.pos" ), // our position files
wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab drill files
wxT( "*.d356" ),
wxT( "*.rpt" ),
wxT( "*.net" ),
@ -197,8 +199,18 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
unsigned long uncompressedBytes = 0;
// Our filename collector can store duplicate filenames. for instance *.gm2
// matches both *.g?? and *.gm??.
// So skip duplicate filenames (they are sorted, so it is easy.
wxString lastStoredFile;
for( unsigned ii = 0; ii < files.GetCount(); ii++ )
{
if( lastStoredFile == files[ii] ) // duplicate name: already stored
continue;
lastStoredFile = files[ii];
wxFileSystem fsfile;
wxFileName curr_fn( files[ii] );

View File

@ -338,21 +338,23 @@ void BITMAP_BUTTON::OnPaint( wxPaintEvent& aEvent )
{
dc.SetFont( m_badgeFont );
wxSize box_size = dc.GetTextExtent( m_badgeText );
wxSize text_padding( 3, 1 );
if( m_padding )
text_padding *= 2;
wxSize box_size = dc.GetTextExtent( m_badgeText ) + text_padding;
wxSize box_offset = box_size;
wxSize text_offset = box_offset;
if( m_padding != 0 )
{
box_offset += wxSize( m_padding - 2, m_padding );
text_offset -= wxSize( 3, 1 );
}
box_offset += wxSize( m_padding / 3, m_padding / 3 );
dc.SetPen( wxPen( m_badgeColor ) );
dc.SetBrush( wxBrush( m_badgeColor ) );
dc.DrawRoundedRectangle( rect.GetRightBottom() - box_offset, box_size, -0.25 );
dc.SetTextForeground( m_badgeTextColor );
dc.DrawText( m_badgeText, rect.GetRightBottom() - text_offset );
dc.DrawText( m_badgeText, rect.GetRightBottom() - box_offset + ( text_padding / 2 ) );
}
}

View File

@ -56,6 +56,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
SetFieldsCount( aNumberFields + ExtraFields );
int* widths = new int[aNumberFields + ExtraFields];
for( int i = 0; i < aNumberFields; i++ )
widths[i] = -1;
@ -65,7 +66,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
widths[aNumberFields + FIELD_OFFSET_NOTIFICATION_BUTTON] = 20; // notifications button
#ifdef __WXOSX__
// offset from the right edge
widths[aNumberFields + ExtraFields] = 15;
widths[aNumberFields + ExtraFields - 1] = 10;
#endif
SetStatusWidths( aNumberFields + ExtraFields, widths );
@ -79,15 +80,13 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
SetStatusStyles( aNumberFields + ExtraFields, styles );
delete[] styles;
m_backgroundTxt =
new wxStaticText( this, wxID_ANY, wxT( "" ), wxDefaultPosition, wxDefaultSize );
m_backgroundTxt = new wxStaticText( this, wxID_ANY, wxT( "" ) );
m_backgroundProgressBar = new wxGauge( this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize,
wxGA_HORIZONTAL | wxGA_SMOOTH );
m_backgroundStopButton =
new wxButton( this, wxID_ANY, "X", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
m_backgroundStopButton = new wxButton( this, wxID_ANY, "X", wxDefaultPosition, wxDefaultSize,
wxBU_EXACTFIT );
m_notificationsButton = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition,
wxDefaultSize, wxBU_EXACTFIT );

View File

@ -268,6 +268,7 @@ void DIALOG_PLOT_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event )
}
m_openFileAfterPlot->Enable( fmt == PLOT_FORMAT::PDF );
m_plotPDFPropertyPopups->Enable( fmt == PLOT_FORMAT::PDF );
m_paperSizeOption->Set( paperSizes );
m_paperSizeOption->SetSelection( selection );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -170,7 +170,6 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind
m_otherOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Other options") ), wxVERTICAL );
m_openFileAfterPlot = new wxCheckBox( m_otherOptions->GetStaticBox(), wxID_ANY, _("Open file after plot"), wxDefaultPosition, wxDefaultSize, 0 );
m_openFileAfterPlot->Enable( false );
m_openFileAfterPlot->SetToolTip( _("Open output file with associated application after successful plot") );
m_otherOptions->Add( m_openFileAfterPlot, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );

View File

@ -1585,7 +1585,7 @@
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!

View File

@ -329,22 +329,11 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un
// mark the current library if it's collapsed
if( curSymbol && curSymbol->GetLibId().GetLibNickname() == node->m_LibId.GetLibNickname() )
{
#if 1
if( !m_widget->IsExpanded( ToItem( node ) ) )
{
// LIB_TREE_RENDERER uses strikethrough as a proxy for is-canvas-item
aAttr.SetStrikethrough( true );
aAttr.SetStrikethrough( true ); // LIB_TREE_RENDERER uses strikethrough as a
// proxy for "is canvas item"
}
#else
#ifdef __WXGTK__
// The native wxGTK+ impl ignores background colour, so set the text colour instead.
// This works reasonably well in dark themes, and quite poorly in light ones....
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
#else
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
#endif
#endif
}
break;
@ -358,19 +347,8 @@ bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, un
// mark the current (on-canvas) part
if( curSymbol && curSymbol->GetLibId() == node->m_LibId )
{
#if 1
// LIB_TREE_RENDERER uses strikethrough as a proxy for is-canvas-item
aAttr.SetStrikethrough( true );
#else
#ifdef __WXGTK__
// The native wxGTK+ impl ignores background colour, so set the text colour instead.
// This works reasonably well in dark themes, and quite poorly in light ones....
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
#else
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
#endif
#endif
aAttr.SetStrikethrough( true ); // LIB_TREE_RENDERER uses strikethrough as a
// proxy for "is canvas item"
}
break;

View File

@ -213,21 +213,51 @@ int SYMBOL_EDITOR_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
saveCopyInUndoList( m_frame->GetCurSymbol(), UNDO_REDO::LIBEDIT );
if( selection.GetSize() == 1 )
mirrorPoint = item->GetPosition();
else
mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
mirrorPoint = item->GetPosition();
switch( item->Type() )
{
case LIB_FIELD_T:
{
LIB_FIELD* field = static_cast<LIB_FIELD*>( item );
if( xAxis )
field->SetVertJustify( TO_VJUSTIFY( -field->GetVertJustify() ) );
else
field->SetHorizJustify( TO_HJUSTIFY( -field->GetHorizJustify() ) );
break;
}
default:
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
break;
}
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
m_frame->UpdateItem( item, false, true );
}
else
{
mirrorPoint = m_frame->GetNearestHalfGridPosition( mapCoords( selection.GetCenter() ) );
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
item = static_cast<LIB_ITEM*>( selection.GetItem( ii ) );
if( xAxis )
item->MirrorVertical( mirrorPoint );
else
item->MirrorHorizontal( mirrorPoint );
m_frame->UpdateItem( item, false, true );
}
}
if( item->IsMoving() )
{

View File

@ -67,15 +67,18 @@ void SCH_SEARCH_HANDLER::FindAll( const std::function<bool( SCH_ITEM*, SCH_SHEET
void SCH_SEARCH_HANDLER::Sort( int aCol, bool aAscending )
{
int col = std::max( 0, aCol ); // Provide a stable order by sorting on first column if no
// sort column provided.
std::sort( m_hitlist.begin(), m_hitlist.end(),
[&]( const SCH_SEARCH_HIT& a, const SCH_SEARCH_HIT& b ) -> bool
{
// N.B. To meet the iterator sort conditions, we cannot simply invert the truth
// to get the opposite sort. i.e. ~(a<b) != (a>b)
if( aAscending )
return StrNumCmp( getResultCell( a, aCol ), getResultCell( b, aCol ), true ) < 0;
return StrNumCmp( getResultCell( a, col ), getResultCell( b, col ), true ) < 0;
else
return StrNumCmp( getResultCell( b, aCol ), getResultCell( a, aCol ), true ) < 0;
return StrNumCmp( getResultCell( b, col ), getResultCell( a, col ), true ) < 0;
} );
}

View File

@ -39,8 +39,6 @@ CLI::PCB_EXPORT_GERBERS_COMMAND::PCB_EXPORT_GERBERS_COMMAND() :
PCB_EXPORT_GERBER_COMMAND( "gerbers" )
{
m_requireLayers = false;
addDrawingSheetArg();
addDefineArg();
m_argParser.add_description( UTF8STDSTR( _( "Plot multiple Gerbers for a PCB, including the "
"ability to use stored board plot settings" ) ) );

View File

@ -72,10 +72,13 @@ CLI::SCH_EXPORT_PLOT_COMMAND::SCH_EXPORT_PLOT_COMMAND( const std::string& aName,
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( ARG_EXCLUDE_PDF_PROPERTY_POPUPS )
.help( UTF8STDSTR( _( "Do not generate property popups in PDF" ) ) )
.implicit_value( true )
.default_value( false );
if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
{
m_argParser.add_argument( ARG_EXCLUDE_PDF_PROPERTY_POPUPS )
.help( UTF8STDSTR( _( "Do not generate property popups in PDF" ) ) )
.implicit_value( true )
.default_value( false );
}
m_argParser.add_argument( "-n", ARG_NO_BACKGROUND_COLOR )
.help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) )

View File

@ -203,7 +203,6 @@ STEP_PCB_MODEL::STEP_PCB_MODEL( const wxString& aPcbName )
m_mergeOCCMaxDist = OCC_MAX_DISTANCE_TO_MERGE_POINTS;
m_minx = 1.0e10; // absurdly large number; any valid PCB X value will be smaller
m_pcbName = aPcbName;
BRepBuilderAPI::Precision( m_mergeOCCMaxDist );
m_maxError = pcbIUScale.mmToIU( ARC_TO_SEGMENT_MAX_ERROR_MM );
}
@ -473,7 +472,6 @@ void STEP_PCB_MODEL::OCCSetMergeMaxDistance( double aDistance )
{
// Ensure a minimal value (in mm)
m_mergeOCCMaxDist = aDistance;
BRepBuilderAPI::Precision( m_mergeOCCMaxDist );
}
@ -907,13 +905,21 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
}
}
Bnd_Box brdBndBox;
for( const TopoDS_Shape& brdShape : m_board_outlines )
BRepBndLib::Add( brdShape, brdBndBox );
// subtract cutouts (if any)
if( m_cutouts.size() )
{
ReportMessage( wxString::Format( wxT( "Build board cutouts and holes (%d hole(s)).\n" ),
(int) m_cutouts.size() ) );
Bnd_BoundSortBox bsb;
// We need to encompass every location we'll need to test in the global bbox,
// otherwise Bnd_BoundSortBox doesn't work near the boundaries.
Bnd_Box brdWithHolesBndBox = brdBndBox;
Bnd_BoundSortBox bsbHoles;
Handle( Bnd_HArray1OfBox ) holeBoxSet = new Bnd_HArray1OfBox( 0, m_cutouts.size() - 1 );
@ -921,10 +927,11 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
{
Bnd_Box bbox;
BRepBndLib::Add( m_cutouts[i], bbox );
brdWithHolesBndBox.Add( bbox );
( *holeBoxSet )[i] = bbox;
}
bsb.Initialize( holeBoxSet );
bsbHoles.Initialize( brdWithHolesBndBox, holeBoxSet );
auto subtractShapes = [&]( const wxString& aWhat, std::vector<TopoDS_Shape>& aShapesList )
{
@ -935,7 +942,7 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
Bnd_Box shapeBbox;
BRepBndLib::Add( shape, shapeBbox );
const TColStd_ListOfInteger& indices = bsb.Compare( shapeBbox );
const TColStd_ListOfInteger& indices = bsbHoles.Compare( shapeBbox );
TopTools_ListOfShape holelist;
@ -1493,7 +1500,7 @@ bool STEP_PCB_MODEL::readSTEP( Handle( TDocStd_Document )& doc, const char* fnam
// set other translation options
reader.SetColorMode( true ); // use model colors
reader.SetNameMode( false ); // don't use label names
reader.SetNameMode( true ); // use label names
reader.SetLayerMode( false ); // ignore LAYER data
if( !reader.Transfer( doc ) )
@ -1545,10 +1552,17 @@ TDF_Label STEP_PCB_MODEL::transferModel( Handle( TDocStd_Document )& source,
while( id <= nshapes )
{
TopoDS_Shape shape = s_assy->GetShape( frshapes.Value( id ) );
const TDF_Label& s_shapeLabel = frshapes.Value( id );
TopoDS_Shape shape = s_assy->GetShape( s_shapeLabel );
if( !shape.IsNull() )
{
Handle( TDataStd_Name ) s_nameAttr;
s_shapeLabel.FindAttribute( TDataStd_Name::GetID(), s_nameAttr );
TCollection_ExtendedString s_labelName =
s_nameAttr ? s_nameAttr->Get() : TCollection_ExtendedString();
TopoDS_Shape scaled_shape( shape );
if( aScale.x != 1.0 || aScale.y != 1.0 || aScale.z != 1.0 )
@ -1567,7 +1581,13 @@ TDF_Label STEP_PCB_MODEL::transferModel( Handle( TDocStd_Document )& source,
}
}
TDF_Label niulab = d_assy->AddComponent( component, scaled_shape, Standard_False );
TDF_Label d_shapeLabel = d_assy->AddShape( scaled_shape, Standard_False );
if( s_labelName.Length() > 0 )
TDataStd_Name::Set( d_shapeLabel, s_labelName );
TDF_Label niulab =
d_assy->AddComponent( component, d_shapeLabel, scaled_shape.Location() );
// check for per-surface colors
stop.Init( shape, TopAbs_FACE );

View File

@ -280,14 +280,12 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
case LIB_TREE_NODE::LIBRARY:
if( node->m_Name == m_frame->GetLoadedFPID().GetLibNickname() )
{
#ifdef __WXGTK__
// The native wxGTK+ impl ignores background colour, so set the text colour
// instead. Works reasonably well in dark themes, less well in light ones....
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
#else
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
#endif
// mark the current library if it's collapsed
if( !m_widget->IsExpanded( ToItem( node ) ) )
{
aAttr.SetStrikethrough( true ); // LIB_TREE_RENDERER uses strikethrough as a
// proxy for "is canvas item"
}
// mark modified libs with bold font
if( m_frame->GetScreen()->IsContentModified() && !m_frame->IsCurrentFPFromBoard() )
@ -298,14 +296,9 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
case LIB_TREE_NODE::ITEM:
if( node->m_LibId == m_frame->GetLoadedFPID() )
{
#ifdef __WXGTK__
// The native wxGTK+ impl ignores background colour, so set the text colour
// instead. Works reasonably well in dark themes, less well in light ones....
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
#else
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT ) );
#endif
// mark the current (on-canvas) part
aAttr.SetStrikethrough( true ); // LIB_TREE_RENDERER uses strikethrough as a
// proxy for "is canvas item"
// mark modified part with bold font
if( m_frame->GetScreen()->IsContentModified() && !m_frame->IsCurrentFPFromBoard() )

View File

@ -1223,8 +1223,12 @@ int PCB_SELECTION_TOOL::expandConnection( const TOOL_EVENT& aEvent )
for( const EDA_ITEM* item : m_selection.GetItems() )
{
if( item->Type() == PCB_FOOTPRINT_T || BOARD_CONNECTED_ITEM::ClassOf( item ) )
if( item->Type() == PCB_FOOTPRINT_T ||
( BOARD_CONNECTED_ITEM::ClassOf( item )
&& static_cast<const BOARD_CONNECTED_ITEM*>( item )->IsConnected() ) )
{
initialCount++;
}
}
if( initialCount == 0 )