ADDED show pin names on footprint pads when assigning to symbol.

Fixes https://gitlab.com/kicad/code/kicad/issues/4576
This commit is contained in:
Jeff Young 2022-07-24 23:40:47 +01:00
parent 582c133835
commit e10158ff10
23 changed files with 314 additions and 108 deletions

View File

@ -429,6 +429,7 @@ set( COMMON_SRCS
settings/app_settings.cpp
settings/color_settings.cpp
settings/cvpcb_settings.cpp
settings/common_settings.cpp
settings/json_settings.cpp
settings/nested_settings.cpp

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cvpcb_settings.h>
#include <settings/cvpcb_settings.h>
#include <settings/parameters.h>
#include <wx/config.h>

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 CERN
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 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
@ -30,6 +30,7 @@
#include <bitmaps.h>
#include <kiway.h>
#include <kiway_player.h>
#include <kiway_express.h>
#include <string_utils.h>
#include <dialog_shim.h>
#include <common.h>
@ -239,11 +240,12 @@ class TEXT_BUTTON_FP_CHOOSER : public wxComboCtrl
{
public:
TEXT_BUTTON_FP_CHOOSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg,
const wxString& aPreselect ) :
const wxString& aSymbolNetlist, const wxString& aPreselect ) :
wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER ),
m_dlg( aParentDlg ),
m_preselect( aPreselect )
m_preselect( aPreselect ),
m_symbolNetlist( aSymbolNetlist.ToStdString() )
{
SetButtonBitmaps( KiBitmap( BITMAPS::small_library ) );
@ -267,6 +269,12 @@ protected:
KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_VIEWER_MODAL, true, m_dlg );
if( !m_symbolNetlist.empty() )
{
KIWAY_EXPRESS event( FRAME_FOOTPRINT_VIEWER, MAIL_SYMBOL_NETLIST, m_symbolNetlist );
frame->KiwayMailIn( event );
}
if( frame->ShowModal( &fpid, m_dlg ) )
SetValue( fpid );
@ -275,13 +283,24 @@ protected:
DIALOG_SHIM* m_dlg;
wxString m_preselect;
/*
* Symbol netlist format:
* library:footprint
* reference
* value
* pinName,netName,pinFunction,pinType
* pinName,netName,pinFunction,pinType
* ...
*/
std::string m_symbolNetlist;
};
void GRID_CELL_FOOTPRINT_ID_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
void GRID_CELL_FPID_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler )
{
m_control = new TEXT_BUTTON_FP_CHOOSER( aParent, m_dlg, m_preselect );
m_control = new TEXT_BUTTON_FP_CHOOSER( aParent, m_dlg, m_symbolNetlist, m_preselect );
#if wxUSE_VALIDATORS
// validate text in textctrl, if validator is set

View File

@ -35,7 +35,6 @@ set( CVPCB_SRCS
footprints_listbox.cpp
library_listbox.cpp
cvpcb_mainframe.cpp
cvpcb_settings.cpp
listbox_base.cpp
menubar.cpp
readwrite_dlgs.cpp

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007 Jean-Pierre Charras, jp..charras at wanadoo.fr
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -31,7 +31,7 @@
#include <settings/settings_manager.h>
#include <cvpcb_mainframe.h>
#include <cvpcb_settings.h>
#include <settings/cvpcb_settings.h>
#include <display_footprints_frame.h>
#include <kiface_ids.h>

View File

@ -49,7 +49,7 @@
#include <cvpcb_association.h>
#include <cvpcb_id.h>
#include <cvpcb_mainframe.h>
#include <cvpcb_settings.h>
#include <settings/cvpcb_settings.h>
#include <display_footprints_frame.h>
#include <kiplatform/ui.h>
#include <listboxes.h>

View File

@ -26,9 +26,10 @@
#include <bitmaps.h>
#include <board.h>
#include <footprint.h>
#include <pad.h>
#include <common.h>
#include <confirm.h>
#include <cvpcb_settings.h>
#include <settings/cvpcb_settings.h>
#include <footprint_editor_settings.h>
#include <fp_lib_table.h>
#include <id.h>
@ -376,16 +377,20 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxCHECK( cfg, nullptr );
CVPCB_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
return &cfg->m_FootprintViewer;
}
PCB_VIEWERS_SETTINGS_BASE* DISPLAY_FOOTPRINTS_FRAME::GetViewerSettingsBase() const
{
return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
}
MAGNETIC_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetMagneticItemsSettings()
{
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( Kiface().KifaceSettings() );
wxCHECK( cfg, nullptr );
CVPCB_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
return &cfg->m_FootprintViewerMagneticSettings;
}
@ -462,21 +467,18 @@ FOOTPRINT* DISPLAY_FOOTPRINTS_FRAME::GetFootprint( const wxString& aFootprintNam
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent();
COMPONENT* comp = parentframe->GetSelectedComponent();
FOOTPRINT* footprint = nullptr;
const FOOTPRINT_INFO* fpInfo = nullptr;
GetBoard()->DeleteAllFootprints();
GetBoard()->GetNetInfo().RemoveUnusedNets();
GetCanvas()->GetView()->Clear();
wxString footprintName = parentframe->GetSelectedFootprint();
if( footprintName.IsEmpty() )
{
COMPONENT* comp = parentframe->GetSelectedComponent();
if( comp )
if( footprintName.IsEmpty() && comp )
footprintName = comp->GetFPID().GetUniStringLibId();
}
INFOBAR_REPORTER infoReporter( m_infoBar );
m_infoBar->Dismiss();
@ -491,7 +493,25 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
}
if( footprint )
{
if( comp )
{
for( PAD* pad : footprint->Pads() )
{
const COMPONENT_NET& net = comp->GetNet( pad->GetNumber() );
if( !net.GetPinFunction().IsEmpty() )
{
NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
netinfo->SetNetname( net.GetPinFunction() );
GetBoard()->Add( netinfo );
pad->SetNet( netinfo );
}
}
}
GetBoard()->Add( footprint );
}
if( fpInfo )
SetStatusText( wxString::Format( _( "Lib: %s" ), fpInfo->GetLibNickname() ), 0 );

View File

@ -73,6 +73,8 @@ public:
WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
PCB_VIEWERS_SETTINGS_BASE* GetViewerSettingsBase() const override;
MAGNETIC_SETTINGS* GetMagneticItemsSettings() override;
///< @copydoc EDA_DRAW_FRAME::UpdateMsgPanel()

View File

@ -829,7 +829,7 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent )
// set footprint column browse button
attr = new wxGridCellAttr;
attr->SetEditor( new GRID_CELL_FOOTPRINT_ID_EDITOR( this ) );
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, wxEmptyString ) );
m_grid->SetColAttr( FOOTPRINT_FIELD, attr );
// set datasheet column viewer button

View File

@ -310,7 +310,7 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
// so we need to handle m_part == nullptr
// wxASSERT( m_part );
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_fieldsGrid, m_part );
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_fieldsGrid, m_symbol );
m_editorShown = false;
m_lastRequestedSize = wxSize( 0, 0 );

View File

@ -58,6 +58,36 @@ enum
#define DEFAULT_FONT_NAME _( "Default Font" )
static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath )
{
/*
* Symbol netlist format:
* library:footprint
* reference
* value
* pinName,netName,pinFunction,pinType
* pinName,netName,pinFunction,pinType
* ...
*/
wxString netlist;
netlist << EscapeString( aSymbol->GetFootprint( &aSheetPath, true ), CTX_LINE ) << wxS( "\r" );
netlist << EscapeString( aSymbol->GetRef( &aSheetPath ), CTX_LINE ) << wxS( "\r" );
netlist << EscapeString( aSymbol->GetValue( &aSheetPath, true ), CTX_LINE );
for( SCH_PIN* pin : aSymbol->GetPins( &aSheetPath ) )
{
netlist << wxS( "\r" );
netlist << EscapeString( pin->GetNumber(), CTX_CSV ) << wxS( "," );
netlist << EscapeString( pin->GetDefaultNetName( aSheetPath ), CTX_CSV ) << wxS( "," );
netlist << EscapeString( pin->GetName(), CTX_CSV ) << wxS( "," );
netlist << EscapeString( pin->GetCanonicalElectricalTypeName(), CTX_CSV );
}
return netlist;
}
template <class T>
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame,
WX_GRID* aGrid, LIB_SYMBOL* aSymbol ) :
@ -80,7 +110,29 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
template <class T>
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame,
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame,
WX_GRID* aGrid, SCH_SYMBOL* aSymbol ) :
m_frame( aFrame ),
m_dialog( aDialog ),
m_grid( aGrid ),
m_parentType( SCH_SYMBOL_T ),
m_mandatoryFieldCount( MANDATORY_FIELDS ),
m_part( aSymbol->GetLibSymbolRef().get() ),
m_symbolNetlist( netList( aSymbol, aFrame->GetCurrentSheet() ) ),
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
m_libIdValidator(),
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
{
initGrid( aGrid );
}
template <class T>
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame,
WX_GRID* aGrid, SCH_SHEET* aSheet ) :
m_frame( aFrame ),
m_dialog( aDialog ),
@ -101,7 +153,7 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
template <class T>
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame,
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame,
WX_GRID* aGrid, SCH_LABEL_BASE* aLabel ) :
m_frame( aFrame ),
m_dialog( aDialog ),
@ -147,7 +199,7 @@ void FIELDS_GRID_TABLE<T>::initGrid( WX_GRID* aGrid )
m_valueAttr->SetEditor( valueEditor );
m_footprintAttr = new wxGridCellAttr;
GRID_CELL_FOOTPRINT_ID_EDITOR* fpIdEditor = new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dialog );
GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, m_symbolNetlist );
fpIdEditor->SetValidator( m_libIdValidator );
m_footprintAttr->SetEditor( fpIdEditor );

View File

@ -77,9 +77,11 @@ class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
public:
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
LIB_SYMBOL* aSymbol );
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
SCH_SYMBOL* aSymbol );
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
SCH_SHEET* aSheet );
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
SCH_LABEL_BASE* aLabel );
~FIELDS_GRID_TABLE();
@ -118,6 +120,7 @@ private:
KICAD_T m_parentType;
int m_mandatoryFieldCount;
LIB_SYMBOL* m_part;
wxString m_symbolNetlist;
wxString m_curdir;
SCH_FIELD_VALIDATOR m_fieldNameValidator;

View File

@ -42,6 +42,7 @@ enum MAIL_T
MAIL_ASSIGN_FOOTPRINTS, // CVPCB->SCH footprint stuffing
MAIL_SCH_SAVE, // CVPCB->SCH save the schematic
MAIL_EESCHEMA_NETLIST, // SCH->CVPCB netlist immediately after launching CVPCB
MAIL_SYMBOL_NETLIST, // SCH->FP_VIEWER symbol pin information
MAIL_PCB_UPDATE, // SCH->PCB forward update
MAIL_SCH_UPDATE, // PCB->SCH forward update
MAIL_IMPORT_FILE, // Import a different format file

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 CERN
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 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
@ -89,18 +89,19 @@ protected:
};
class GRID_CELL_FOOTPRINT_ID_EDITOR : public GRID_CELL_TEXT_BUTTON
class GRID_CELL_FPID_EDITOR : public GRID_CELL_TEXT_BUTTON
{
public:
GRID_CELL_FOOTPRINT_ID_EDITOR( DIALOG_SHIM* aParent,
GRID_CELL_FPID_EDITOR( DIALOG_SHIM* aParent, const wxString& aSymbolNetlist,
const wxString& aPreselect = wxEmptyString ) :
m_dlg( aParent ),
m_preselect( aPreselect )
m_preselect( aPreselect ),
m_symbolNetlist( aSymbolNetlist )
{ }
wxGridCellEditor* Clone() const override
{
return new GRID_CELL_FOOTPRINT_ID_EDITOR( m_dlg );
return new GRID_CELL_FPID_EDITOR( m_dlg, m_symbolNetlist );
}
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
@ -108,6 +109,7 @@ public:
protected:
DIALOG_SHIM* m_dlg;
wxString m_preselect;
wxString m_symbolNetlist;
};

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2022 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
@ -34,6 +34,8 @@
#include <footprint_viewer_frame.h>
#include <fp_lib_table.h>
#include <kiway.h>
#include <kiway_express.h>
#include <netlist_reader/pcb_netlist.h>
#include <widgets/msgpanel.h>
#include <widgets/wx_listbox.h>
#include <pcb_draw_panel_gal.h>
@ -114,7 +116,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
: NONMODAL_STYLE,
aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL ? FOOTPRINT_VIEWER_FRAME_NAME_MODAL
: FOOTPRINT_VIEWER_FRAME_NAME )
: FOOTPRINT_VIEWER_FRAME_NAME ),
m_comp( LIB_ID(), wxEmptyString, wxEmptyString, KIID_PATH(), {} )
{
wxASSERT( aFrameType == FRAME_FOOTPRINT_VIEWER_MODAL || aFrameType == FRAME_FOOTPRINT_VIEWER );
@ -738,14 +741,17 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
GetBoard()->DeleteAllFootprints();
GetBoard()->GetNetInfo().RemoveUnusedNets();
LIB_ID id;
id.SetLibNickname( getCurNickname() );
id.SetLibItemName( getCurFootprintName() );
FOOTPRINT* footprint = nullptr;
try
{
GetBoard()->Add( loadFootprint( id ) );
footprint = loadFootprint( id );
}
catch( const IO_ERROR& ioe )
{
@ -757,6 +763,9 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
DisplayError( this, msg );
}
if( footprint )
displayFootprint( footprint );
UpdateTitle();
updateView();
@ -767,6 +776,25 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
}
void FOOTPRINT_VIEWER_FRAME::displayFootprint( FOOTPRINT* aFootprint )
{
for( PAD* pad : aFootprint->Pads() )
{
const COMPONENT_NET& net = m_comp.GetNet( pad->GetNumber() );
if( !net.GetPinFunction().IsEmpty() )
{
NETINFO_ITEM* netinfo = new NETINFO_ITEM( GetBoard() );
netinfo->SetNetname( net.GetPinFunction() );
GetBoard()->Add( netinfo );
pad->SetNet( netinfo );
}
}
GetBoard()->Add( aFootprint );
}
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxMouseEvent& aEvent )
{
wxCommandEvent evt;
@ -1004,6 +1032,52 @@ void FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton( wxUpdateUIEvent& aEvent )
}
void FOOTPRINT_VIEWER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();
switch( mail.Command() )
{
case MAIL_SYMBOL_NETLIST:
{
/*
* Symbol netlist format:
* library:footprint
* reference
* value
* pinName,netName,pinFunction,pinType
* pinName,netName,pinFunction,pinType
* ...
*/
std::vector<std::string> strings = split( payload, "\r" );
LIB_ID libid;
if( strings.size() >= 3 )
{
libid.Parse( strings[0] );
m_comp.SetFPID( libid );
m_comp.SetReference( strings[1] );
m_comp.SetValue( strings[2] );
m_comp.ClearNets();
for( size_t ii = 3; ii < strings.size(); ++ii )
{
std::vector<std::string> pinData = split( strings[ii], "," );
m_comp.AddNet( pinData[0], pinData[1], pinData[2], pinData[3] );
}
}
break;
}
default:
;
}
}
bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
{
if( aFootprint && !aFootprint->IsEmpty() )
@ -1144,15 +1218,15 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
// Delete the current footprint
GetBoard()->DeleteAllFootprints();
GetBoard()->GetNetInfo().RemoveUnusedNets();
FOOTPRINT* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(),
getCurFootprintName() );
if( footprint )
GetBoard()->Add( footprint, ADD_MODE::APPEND );
displayFootprint( footprint );
Update3DView( true, true );
updateView();
}

View File

@ -29,6 +29,7 @@
#include <wx/gdicmn.h>
#include <pcb_base_frame.h>
#include <pcbnew_settings.h>
#include <netlist_reader/pcb_netlist.h>
class wxSashLayoutWindow;
class WX_LISTBOX;
@ -81,6 +82,8 @@ public:
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
protected:
FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType );
@ -105,6 +108,8 @@ private:
*/
void UpdateTitle();
void displayFootprint( FOOTPRINT* aFootprint );
void doCloseWindow() override;
void CloseFootprintViewer( wxCommandEvent& event );
void OnExitKiCad( wxCommandEvent& event );
@ -165,6 +170,7 @@ private:
friend struct PCB::IFACE; // constructor called from here only
private:
wxSearchCtrl* m_libFilter;
WX_LISTBOX* m_libList; // The list of library names.
int m_libListWidth; // Last width of the window.
@ -173,6 +179,8 @@ private:
WX_LISTBOX* m_fpList; // The list of footprint names.
int m_fpListWidth; // Last width of the window.
COMPONENT m_comp;
bool m_autoZoom;
double m_lastZoom;
};

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2012 Jean-Pierre Charras.
* Copyright (C) 2013-2016 Wayne Stambaugh <stambaughw@gmail.com>.
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012-2022 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
@ -112,6 +112,8 @@ public:
const COMPONENT_NET& GetNet( const wxString& aPinName ) const;
void ClearNets() { m_nets.clear(); }
void SortPins() { sort( m_nets.begin(), m_nets.end() ); }
void SetName( const wxString& aName ) { m_name = aName;}
@ -120,7 +122,10 @@ public:
void SetLibrary( const wxString& aLibrary ) { m_library = aLibrary; }
const wxString& GetLibrary() const { return m_library; }
void SetReference( const wxString& aReference ) { m_reference = aReference; }
const wxString& GetReference() const { return m_reference; }
void SetValue( const wxString& aValue ) { m_value = aValue; }
const wxString& GetValue() const { return m_value; }
void SetProperties( std::map<wxString, wxString>& aProps )
@ -160,11 +165,12 @@ public:
void Format( OUTPUTFORMATTER* aOut, int aNestLevel, int aCtl );
private:
COMPONENT_NETS m_nets; ///< list of nets shared by the component pins
wxArrayString m_footprintFilters; ///< Footprint filters found in netlist.
int m_pinCount; ///< Number of pins found in netlist.
wxString m_reference; ///< The component reference designator found in netlist.
wxString m_value; ///< The component value found in netlist.
std::vector<COMPONENT_NET> m_nets; ///< list of nets shared by the component pins
wxArrayString m_footprintFilters;
int m_pinCount;
wxString m_reference;
wxString m_value;
/// A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID, .. ]
KIID_PATH m_path;
@ -172,7 +178,7 @@ private:
/// A vector of possible KIIDs corresponding to all units in a symbol
std::vector<KIID> m_kiids;
/// The name of the component in #m_library used when it was placed on the schematic..
/// The name of the component in #m_library used when it was placed on the schematic.
wxString m_name;
/// The name of the component library where #m_name was found.
@ -187,7 +193,7 @@ private:
LIB_ID m_altFpid;
/// The #FOOTPRINT loaded for #m_FPID.
std::unique_ptr< FOOTPRINT > m_footprint;
std::unique_ptr<FOOTPRINT> m_footprint;
/// Component-specific properties found in the netlist.
std::map<wxString, wxString> m_properties;

View File

@ -52,7 +52,7 @@
#include <pcb_painter.h>
#include <settings/settings_manager.h>
#include <pcbnew_settings.h>
#include <settings/cvpcb_settings.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/pcb_actions.h>
@ -926,7 +926,22 @@ FOOTPRINT_EDITOR_SETTINGS* PCB_BASE_FRAME::GetFootprintEditorSettings() const
PCB_VIEWERS_SETTINGS_BASE* PCB_BASE_FRAME::GetViewerSettingsBase() const
{
switch( GetFrameType() )
{
case FRAME_PCB_EDITOR:
case FRAME_FOOTPRINT_EDITOR:
case FRAME_FOOTPRINT_WIZARD:
case FRAME_PCB_DISPLAY3D:
default:
return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
case FRAME_FOOTPRINT_VIEWER:
case FRAME_FOOTPRINT_VIEWER_MODAL:
case FRAME_FOOTPRINT_PREVIEW:
case FRAME_CVPCB:
case FRAME_CVPCB_DISPLAY:
return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2017 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -210,7 +210,12 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_view = new KIGFX::PCB_VIEW( true );
m_view->SetGAL( m_gal );
m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal );
FRAME_T frameType = FRAME_FOOTPRINT_PREVIEW;
if( EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( aParentWindow ) )
frameType = frame->GetFrameType();
m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal, frameType );
m_view->SetPainter( m_painter.get() );
// This fixes the zoom in and zoom out limits:

View File

@ -49,6 +49,7 @@
#include <settings/color_settings.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <settings/cvpcb_settings.h>
#include <pcbnew_settings.h>
#include <convert_basic_shapes_to_polygon.h>
@ -76,34 +77,24 @@ PCBNEW_SETTINGS* pcbconfig()
// Helpers for display options existing in Cvpcb and Pcbnew
// Note, when running Cvpcb, pcbconfig() returns nullptr and viewer_settings()
// returns the viewer options existing to Cvpcb and Pcbnew
static PCB_VIEWERS_SETTINGS_BASE* viewer_settings()
PCB_VIEWERS_SETTINGS_BASE* PCB_PAINTER::viewer_settings()
{
if( pcbconfig() )
switch( m_frameType )
{
case FRAME_PCB_EDITOR:
case FRAME_FOOTPRINT_EDITOR:
case FRAME_FOOTPRINT_WIZARD:
case FRAME_PCB_DISPLAY3D:
default:
return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
else
return dynamic_cast<PCB_VIEWERS_SETTINGS_BASE*>( Kiface().KifaceSettings() );
}
static bool displayPadFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
}
static bool displayGraphicsFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
}
static bool displayTextFill()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
}
static bool displayPadNumbers()
{
return viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers;
case FRAME_FOOTPRINT_VIEWER:
case FRAME_FOOTPRINT_VIEWER_MODAL:
case FRAME_FOOTPRINT_PREVIEW:
case FRAME_CVPCB:
case FRAME_CVPCB_DISPLAY:
return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
}
}
@ -406,8 +397,9 @@ bool PCB_RENDER_SETTINGS::GetShowPageLimits() const
}
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PCB_PAINTER::PCB_PAINTER( GAL* aGal, FRAME_T aFrameType ) :
PAINTER( aGal ),
m_frameType( aFrameType ),
m_maxError( ARC_HIGH_DEF ),
m_holePlatingThickness( 0 )
{
@ -996,11 +988,11 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
wxString netname;
wxString padNumber;
if( displayPadNumbers() )
if( viewer_settings()->m_ViewersDisplay.m_DisplayPadNumbers )
{
padNumber = UnescapeString( aPad->GetNumber() );
if( !displayOpts )
if( dynamic_cast<CVPCB_SETTINGS*>( viewer_settings() ) )
netname = UnescapeString( aPad->GetShortNetname() );
}
@ -1078,7 +1070,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
// position to display 2 lines
if( !netname.IsEmpty() && !padNumber.IsEmpty() )
{
size = size / 2.5;
size = size / 2.2;
textpos.y = size / 1.7;
}
@ -1089,11 +1081,12 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size...
tsize *= 0.75;
tsize *= 0.85;
VECTOR2D namesize( tsize, tsize );
m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->SetLineWidth( namesize.x / 6.0 );
m_gal->SetFontBold( true );
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
}
@ -1106,12 +1099,13 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size...
tsize *= 0.75;
tsize *= 0.85;
tsize = std::min( tsize, size );
VECTOR2D numsize( tsize, tsize );
m_gal->SetGlyphSize( numsize );
m_gal->SetLineWidth( numsize.x / 12.0 );
m_gal->SetLineWidth( numsize.x / 6.0 );
m_gal->SetFontBold( true );
m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL );
}
@ -1137,7 +1131,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
return;
}
bool outline_mode = !displayPadFill();
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayPadFill;
if( m_pcbSettings.m_ForcePadSketchModeOff )
outline_mode = false;
@ -1452,7 +1446,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
void PCB_PAINTER::draw( const PCB_SHAPE* aShape, int aLayer )
{
COLOR4D color = m_pcbSettings.GetColor( aShape, aShape->GetLayer() );
bool outline_mode = !displayGraphicsFill();
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
int thickness = getLineThickness( aShape->GetWidth() );
PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
@ -1773,7 +1767,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() );
bool outline_mode = !displayTextFill();
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color );
@ -1926,7 +1920,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
return;
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
bool outline_mode = !displayTextFill();
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayTextFill;
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
m_gal->SetStrokeColor( color );
@ -2266,7 +2260,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
bool outline_mode = !displayGraphicsFill();
bool outline_mode = !viewer_settings()->m_ViewersDisplay.m_DisplayGraphicsFill;
if( outline_mode )
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );

View File

@ -28,6 +28,7 @@
#ifndef PCB_PAINTER_H
#define PCB_PAINTER_H
#include <frame_type.h>
#include <painter.h>
#include <pcb_display_options.h>
#include <math/vector2d.h>
@ -36,6 +37,7 @@
class EDA_ITEM;
class PCB_DISPLAY_OPTIONS;
class PCB_VIEWERS_SETTINGS_BASE;
class BOARD_ITEM;
class PCB_ARC;
class BOARD;
@ -153,7 +155,7 @@ protected:
class PCB_PAINTER : public PAINTER
{
public:
PCB_PAINTER( GAL* aGal );
PCB_PAINTER( GAL* aGal, FRAME_T aFrameType );
/// @copydoc PAINTER::GetSettings()
virtual PCB_RENDER_SETTINGS* GetSettings() override
@ -165,6 +167,8 @@ public:
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
protected:
PCB_VIEWERS_SETTINGS_BASE* viewer_settings();
// Drawing functions for various types of PCB-specific items
void draw( const PCB_TRACK* aTrack, int aLayer );
void draw( const PCB_ARC* aArc, int aLayer );
@ -211,6 +215,7 @@ protected:
protected:
PCB_RENDER_SETTINGS m_pcbSettings;
FRAME_T m_frameType;
int m_maxError;
int m_holePlatingThickness;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018 CERN
* Author: Maciej Suminski <maciej.suminski@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
@ -283,7 +283,7 @@ std::unique_ptr<KIGFX::PAINTER> PCBNEW_PRINTOUT::getPainter( KIGFX::GAL* aGal )
KIGFX::PCB_PRINT_PAINTER::PCB_PRINT_PAINTER( GAL* aGal ) :
PCB_PAINTER( aGal ),
PCB_PAINTER( aGal, FRAME_PCB_EDITOR ),
m_drillMarkReal( false ),
m_drillMarkSize( 0 )
{ }