2020-01-29 16:33:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Alexander Shuklin <Jasuramme@gmail.com>
|
2023-06-09 16:24:49 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-29 16:33:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <backannotate.h>
|
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <dsnlexer.h>
|
|
|
|
#include <ptree.h>
|
|
|
|
#include <reporter.h>
|
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <sch_sheet_path.h>
|
2022-01-24 13:40:39 +00:00
|
|
|
#include <sch_label.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2023-06-09 21:41:33 +00:00
|
|
|
#include <sch_commit.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-07-10 16:59:06 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-11-25 22:16:06 +00:00
|
|
|
#include <connection_graph.h>
|
2021-06-03 12:11:15 +00:00
|
|
|
#include <wx/log.h>
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2021-03-24 13:25:32 +00:00
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
|
2020-06-08 18:36:25 +00:00
|
|
|
bool aProcessFootprints, bool aProcessValues,
|
2023-05-01 12:53:36 +00:00
|
|
|
bool aProcessReferences, bool aProcessNetNames,
|
2023-07-31 14:38:02 +00:00
|
|
|
bool aProcessAttributes, bool aProcessOtherFields,
|
|
|
|
bool aDryRun ) :
|
2020-06-08 18:36:25 +00:00
|
|
|
m_reporter( aReporter ),
|
2020-07-16 17:31:36 +00:00
|
|
|
m_matchByReference( aRelinkFootprints ),
|
2020-06-08 18:36:25 +00:00
|
|
|
m_processFootprints( aProcessFootprints ),
|
|
|
|
m_processValues( aProcessValues ),
|
|
|
|
m_processReferences( aProcessReferences ),
|
|
|
|
m_processNetNames( aProcessNetNames ),
|
2023-05-01 12:53:36 +00:00
|
|
|
m_processAttributes( aProcessAttributes ),
|
2023-07-31 14:38:02 +00:00
|
|
|
m_processOtherFields( aProcessOtherFields ),
|
2020-06-08 18:36:25 +00:00
|
|
|
m_dryRun( aDryRun ),
|
2020-03-25 13:13:03 +00:00
|
|
|
m_frame( aFrame ),
|
2023-06-09 16:24:49 +00:00
|
|
|
m_changesCount( 0 )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BACK_ANNOTATE::~BACK_ANNOTATE()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool BACK_ANNOTATE::BackAnnotateSymbols( const std::string& aNetlist )
|
|
|
|
{
|
|
|
|
m_changesCount = 0;
|
|
|
|
|
2021-01-19 23:15:47 +00:00
|
|
|
if( !m_matchByReference && !m_processValues && !m_processFootprints && !m_processReferences
|
2023-05-01 12:53:36 +00:00
|
|
|
&& !m_processNetNames && !m_processAttributes )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-06-08 18:36:25 +00:00
|
|
|
m_reporter.ReportTail( _( "Select at least one property to back annotate." ),
|
|
|
|
RPT_SEVERITY_ERROR );
|
2020-01-29 16:33:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
getPcbModulesFromString( aNetlist );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
|
2020-11-15 16:08:31 +00:00
|
|
|
sheets.GetSymbols( m_refs, false );
|
|
|
|
sheets.GetMultiUnitSymbols( m_multiUnitsRefs );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
getChangeList();
|
|
|
|
checkForUnusedSymbols();
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
applyChangelist();
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
return true;
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
bool BACK_ANNOTATE::FetchNetlistFromPCB( std::string& aNetlist )
|
|
|
|
{
|
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
{
|
2023-02-14 21:44:49 +00:00
|
|
|
DisplayErrorMessage( m_frame, _( "Cannot fetch PCB netlist because Schematic Editor is opened "
|
2020-06-08 18:36:25 +00:00
|
|
|
"in stand-alone mode.\n"
|
|
|
|
"You must launch the KiCad project manager and create "
|
|
|
|
"a project." ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:59:06 +00:00
|
|
|
KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
{
|
|
|
|
wxFileName fn( m_frame->Prj().GetProjectFullName() );
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::PcbFileExtension );
|
2020-07-10 16:59:06 +00:00
|
|
|
|
|
|
|
frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, true );
|
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
m_frame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_GET_NETLIST, aNetlist );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
void BACK_ANNOTATE::PushNewLinksToPCB()
|
|
|
|
{
|
|
|
|
std::string nullPayload;
|
|
|
|
|
|
|
|
m_frame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE_LINKS, nullPayload );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-06-08 18:36:25 +00:00
|
|
|
auto getStr = []( const PTREE& pt ) -> wxString
|
|
|
|
{
|
|
|
|
return UTF8( pt.front().first );
|
|
|
|
};
|
|
|
|
|
2023-09-09 04:10:57 +00:00
|
|
|
DSNLEXER lexer( aPayload, From_UTF8( __func__ ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
PTREE doc;
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
// NOTE: KiCad's PTREE scanner constructs a property *name* tree, not a property tree.
|
|
|
|
// Every token in the s-expr is stored as a property name; the property's value is then
|
|
|
|
// either the nested s-exprs or an empty PTREE; there are *no* literal property values.
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
Scan( &doc, &lexer );
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
PTREE& tree = doc.get_child( "pcb_netlist" );
|
|
|
|
wxString msg;
|
2020-11-13 11:17:15 +00:00
|
|
|
m_pcbFootprints.clear();
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
for( const std::pair<const std::string, PTREE>& item : tree )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
wxString path, value, footprint;
|
2023-05-01 12:53:36 +00:00
|
|
|
bool dnp = false, exBOM = false;
|
2023-07-31 14:38:02 +00:00
|
|
|
std::map<wxString, wxString> pinNetMap, fieldsMap;
|
2020-01-29 16:33:57 +00:00
|
|
|
wxASSERT( item.first == "ref" );
|
2020-06-08 18:36:25 +00:00
|
|
|
wxString ref = getStr( item.second );
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
try
|
|
|
|
{
|
2020-07-16 17:31:36 +00:00
|
|
|
if( m_matchByReference )
|
|
|
|
path = ref;
|
|
|
|
else
|
|
|
|
path = getStr( item.second.get_child( "timestamp" ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
if( path == "" )
|
|
|
|
{
|
2021-03-24 13:25:32 +00:00
|
|
|
msg.Printf( _( "Footprint '%s' has no assigned symbol." ), ref );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_WARNING );
|
2020-01-29 16:33:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
footprint = getStr( item.second.get_child( "fpid" ) );
|
|
|
|
value = getStr( item.second.get_child( "value" ) );
|
|
|
|
|
2023-07-31 14:38:02 +00:00
|
|
|
// Get child PTREE of fields
|
|
|
|
boost::optional<const PTREE&> fields = item.second.get_child_optional( "fields" );
|
|
|
|
|
|
|
|
// Parse each field out of the fields string
|
|
|
|
if( fields )
|
|
|
|
{
|
|
|
|
for( const std::pair<const std::string, PTREE>& field : fields.get() )
|
|
|
|
{
|
|
|
|
if( field.first != "field" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Fields are of the format "(field (name "name") "12345")
|
2023-12-18 18:45:02 +00:00
|
|
|
const auto& fieldName = field.second.get_child_optional( "name" );
|
|
|
|
const auto& fieldValue = field.second.back().first;
|
2023-07-31 14:38:02 +00:00
|
|
|
|
|
|
|
if( !fieldName )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fieldsMap[getStr( fieldName.get() )] = fieldValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-01 12:53:36 +00:00
|
|
|
// Get DNP and Exclude from BOM out of the properties if they exist
|
|
|
|
for( const auto& child : item.second )
|
|
|
|
{
|
|
|
|
if( child.first != "property" )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto property = child.second;
|
|
|
|
auto name = property.get_child_optional( "name" );
|
|
|
|
|
|
|
|
if( !name )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( name.get().front().first == "dnp" )
|
|
|
|
{
|
|
|
|
dnp = true;
|
|
|
|
}
|
|
|
|
else if( name.get().front().first == "exclude_from_bom" )
|
|
|
|
{
|
|
|
|
exBOM = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
boost::optional<const PTREE&> nets = item.second.get_child_optional( "nets" );
|
|
|
|
|
|
|
|
if( nets )
|
|
|
|
{
|
|
|
|
for( const std::pair<const std::string, PTREE>& pin_net : nets.get() )
|
|
|
|
{
|
|
|
|
wxASSERT( pin_net.first == "pin_net" );
|
|
|
|
wxString pinNumber = UTF8( pin_net.second.front().first );
|
|
|
|
wxString netName = UTF8( pin_net.second.back().first );
|
|
|
|
pinNetMap[ pinNumber ] = netName;
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
2020-11-09 12:06:03 +00:00
|
|
|
wxLogWarning( "Cannot parse PCB netlist for back-annotation." );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Use lower_bound for not to iterate over map twice
|
2020-11-13 11:17:15 +00:00
|
|
|
auto nearestItem = m_pcbFootprints.lower_bound( path );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
if( nearestItem != m_pcbFootprints.end() && nearestItem->first == path )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
// Module with this path already exists - generate error
|
2020-11-19 15:29:17 +00:00
|
|
|
msg.Printf( _( "Footprints '%s' and '%s' linked to same symbol." ),
|
2020-11-09 12:06:03 +00:00
|
|
|
nearestItem->second->m_ref,
|
|
|
|
ref );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ERROR );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-13 11:17:15 +00:00
|
|
|
// Add footprint to the map
|
2023-06-09 16:24:49 +00:00
|
|
|
auto data = std::make_shared<PCB_FP_DATA>( ref, footprint, value, dnp, exBOM,
|
2023-07-31 14:38:02 +00:00
|
|
|
pinNetMap, fieldsMap );
|
2020-11-13 11:17:15 +00:00
|
|
|
m_pcbFootprints.insert( nearestItem, std::make_pair( path, data ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
void BACK_ANNOTATE::getChangeList()
|
|
|
|
{
|
2020-11-13 11:17:15 +00:00
|
|
|
for( std::pair<const wxString, std::shared_ptr<PCB_FP_DATA>>& fpData : m_pcbFootprints )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-11-13 11:17:15 +00:00
|
|
|
const wxString& pcbPath = fpData.first;
|
|
|
|
auto& pcbData = fpData.second;
|
2020-07-16 17:31:36 +00:00
|
|
|
int refIndex;
|
2020-06-08 18:36:25 +00:00
|
|
|
bool foundInMultiunit = false;
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
for( std::pair<const wxString, SCH_REFERENCE_LIST>& item : m_multiUnitsRefs )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-06-08 18:36:25 +00:00
|
|
|
SCH_REFERENCE_LIST& refList = item.second;
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
if( m_matchByReference )
|
|
|
|
refIndex = refList.FindRef( pcbPath );
|
|
|
|
else
|
2022-11-03 10:15:23 +00:00
|
|
|
refIndex = refList.FindRefByFullPath( pcbPath );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
if( refIndex >= 0 )
|
|
|
|
{
|
2020-11-13 11:17:15 +00:00
|
|
|
// If footprint linked to multi unit symbol, we add all symbol's units to
|
2020-01-29 16:33:57 +00:00
|
|
|
// the change list
|
|
|
|
foundInMultiunit = true;
|
2020-07-10 16:59:06 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
for( size_t i = 0; i < refList.GetCount(); ++i )
|
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
refList[ i ].GetSymbol()->ClearFlags(SKIP_STRUCT );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_changelist.emplace_back( CHANGELIST_ITEM( refList[i], pcbData ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( foundInMultiunit )
|
|
|
|
continue;
|
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
if( m_matchByReference )
|
|
|
|
refIndex = m_refs.FindRef( pcbPath );
|
|
|
|
else
|
2022-11-03 10:15:23 +00:00
|
|
|
refIndex = m_refs.FindRefByFullPath( pcbPath );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
if( refIndex >= 0 )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2021-03-24 13:25:32 +00:00
|
|
|
m_refs[ refIndex ].GetSymbol()->ClearFlags( SKIP_STRUCT );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_changelist.emplace_back( CHANGELIST_ITEM( m_refs[refIndex], pcbData ) );
|
|
|
|
}
|
2020-01-29 16:33:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Haven't found linked symbol in multiunits or common refs. Generate error
|
2020-11-09 12:06:03 +00:00
|
|
|
wxString msg = wxString::Format( _( "Cannot find symbol for footprint '%s'." ),
|
|
|
|
pcbData->m_ref );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_reporter.ReportTail( msg, RPT_SEVERITY_ERROR );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
void BACK_ANNOTATE::checkForUnusedSymbols()
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-03-07 07:43:30 +00:00
|
|
|
m_refs.SortByTimeStamp();
|
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
std::sort( m_changelist.begin(), m_changelist.end(),
|
|
|
|
[]( const CHANGELIST_ITEM& a, const CHANGELIST_ITEM& b )
|
|
|
|
{
|
|
|
|
return SCH_REFERENCE_LIST::sortByTimeStamp( a.first, b.first );
|
|
|
|
} );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
size_t i = 0;
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
for( const std::pair<SCH_REFERENCE, std::shared_ptr<PCB_FP_DATA>>& item : m_changelist )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
// Refs and changelist are both sorted by paths, so we just go over m_refs and
|
|
|
|
// generate errors before we will find m_refs member to which item linked
|
|
|
|
while( i < m_refs.GetCount() && m_refs[i].GetPath() != item.first.GetPath() )
|
|
|
|
{
|
2021-01-19 16:39:18 +00:00
|
|
|
const SCH_REFERENCE& ref = m_refs[i];
|
2020-11-19 15:29:17 +00:00
|
|
|
|
2023-06-25 02:03:06 +00:00
|
|
|
if( ref.GetSymbol()->GetExcludedFromBoard() )
|
2020-11-19 15:29:17 +00:00
|
|
|
{
|
2020-11-26 19:29:50 +00:00
|
|
|
wxString msg = wxString::Format( _( "Footprint '%s' is not present on PCB. "
|
|
|
|
"Corresponding symbols in schematic must be "
|
|
|
|
"manually deleted (if desired)." ),
|
2022-05-03 07:20:46 +00:00
|
|
|
m_refs[i].GetRef() );
|
2020-11-26 19:29:50 +00:00
|
|
|
m_reporter.ReportTail( msg, RPT_SEVERITY_WARNING );
|
2020-11-19 15:29:17 +00:00
|
|
|
}
|
2021-01-19 16:39:18 +00:00
|
|
|
|
|
|
|
++i;
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
2020-07-16 17:31:36 +00:00
|
|
|
|
2021-01-30 16:30:35 +00:00
|
|
|
if( m_matchByReference && !m_frame->ReadyToNetlist( _( "Re-linking footprints requires a fully "
|
|
|
|
"annotated schematic." ) ) )
|
2020-07-16 17:31:36 +00:00
|
|
|
{
|
2021-01-30 16:30:35 +00:00
|
|
|
m_reporter.ReportTail( _( "Footprint re-linking cancelled by user." ), RPT_SEVERITY_ERROR );
|
2020-07-16 17:31:36 +00:00
|
|
|
}
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BACK_ANNOTATE::applyChangelist()
|
|
|
|
{
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_COMMIT commit( m_frame );
|
|
|
|
wxString msg;
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
// Apply changes from change list
|
2020-06-08 18:36:25 +00:00
|
|
|
for( CHANGELIST_ITEM& item : m_changelist )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
SCH_REFERENCE& ref = item.first;
|
|
|
|
PCB_FP_DATA& fpData = *item.second;
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = ref.GetSymbol();
|
2020-11-15 16:08:31 +00:00
|
|
|
SCH_SCREEN* screen = ref.GetSheetPath().LastScreen();
|
|
|
|
wxString oldFootprint = ref.GetFootprint();
|
|
|
|
wxString oldValue = ref.GetValue();
|
2023-05-01 12:53:36 +00:00
|
|
|
bool oldDNP = ref.GetSymbol()->GetDNP();
|
2023-06-25 02:03:06 +00:00
|
|
|
bool oldExBOM = ref.GetSymbol()->GetExcludedFromBOM();
|
2020-11-15 16:08:31 +00:00
|
|
|
bool skip = ( ref.GetSymbol()->GetFlags() & SKIP_STRUCT ) > 0;
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2023-05-01 12:53:36 +00:00
|
|
|
auto boolString = []( bool b ) -> wxString
|
|
|
|
{
|
|
|
|
return b ? _( "true" ) : _( "false" );
|
|
|
|
};
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_processReferences && ref.GetRef() != fpData.m_ref && !skip )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
++m_changesCount;
|
2020-11-19 15:29:17 +00:00
|
|
|
msg.Printf( _( "Change '%s' reference designator to '%s'." ),
|
2022-05-03 07:20:46 +00:00
|
|
|
ref.GetRef(),
|
2020-11-13 02:57:11 +00:00
|
|
|
fpData.m_ref );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
if( !m_dryRun )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( symbol, screen );
|
2020-11-15 16:08:31 +00:00
|
|
|
symbol->SetRef( &ref.GetSheetPath(), fpData.m_ref );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_processFootprints && oldFootprint != fpData.m_footprint && !skip )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
++m_changesCount;
|
2020-11-19 15:29:17 +00:00
|
|
|
msg.Printf( _( "Change %s footprint assignment from '%s' to '%s'." ),
|
2022-05-03 07:20:46 +00:00
|
|
|
ref.GetRef(),
|
2020-08-29 13:41:47 +00:00
|
|
|
oldFootprint,
|
2020-11-13 02:57:11 +00:00
|
|
|
fpData.m_footprint );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
if( !m_dryRun )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( symbol, screen );
|
2022-11-25 14:25:39 +00:00
|
|
|
symbol->SetFootprintFieldText( fpData.m_footprint );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 02:57:11 +00:00
|
|
|
if( m_processValues && oldValue != fpData.m_value && !skip )
|
2020-01-29 16:33:57 +00:00
|
|
|
{
|
|
|
|
++m_changesCount;
|
2020-11-19 15:29:17 +00:00
|
|
|
msg.Printf( _( "Change %s value from '%s' to '%s'." ),
|
2022-05-03 07:20:46 +00:00
|
|
|
ref.GetRef(),
|
2020-08-29 13:41:47 +00:00
|
|
|
oldValue,
|
2020-11-13 02:57:11 +00:00
|
|
|
fpData.m_value );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
if( !m_dryRun )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( symbol, screen );
|
2022-11-25 14:25:39 +00:00
|
|
|
symbol->SetValueFieldText( fpData.m_value );
|
2020-07-13 11:21:40 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
|
2023-05-01 12:53:36 +00:00
|
|
|
if( m_processAttributes && oldDNP != fpData.m_DNP && !skip )
|
|
|
|
{
|
|
|
|
++m_changesCount;
|
|
|
|
msg.Printf( _( "Change %s 'Do not populate' from '%s' to '%s'." ), ref.GetRef(),
|
|
|
|
boolString( oldDNP ), boolString( fpData.m_DNP ) );
|
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( symbol, screen );
|
2023-05-01 12:53:36 +00:00
|
|
|
symbol->SetDNP( fpData.m_DNP );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_processAttributes && oldExBOM != fpData.m_excludeFromBOM && !skip )
|
|
|
|
{
|
|
|
|
++m_changesCount;
|
|
|
|
msg.Printf( _( "Change %s 'Exclude from bill of materials' from '%s' to '%s'." ),
|
|
|
|
ref.GetRef(), boolString( oldExBOM ),
|
|
|
|
boolString( fpData.m_excludeFromBOM ) );
|
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
commit.Modify( symbol, screen );
|
2023-06-25 02:03:06 +00:00
|
|
|
symbol->SetExcludedFromBOM( fpData.m_excludeFromBOM );
|
2023-05-01 12:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
|
2020-06-08 18:36:25 +00:00
|
|
|
if( m_processNetNames )
|
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
for( const std::pair<const wxString, wxString>& entry : fpData.m_pinMap )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
|
|
|
const wxString& pinNumber = entry.first;
|
|
|
|
const wxString& shortNetName = entry.second;
|
2020-11-15 16:08:31 +00:00
|
|
|
SCH_PIN* pin = symbol->GetPin( pinNumber );
|
2020-11-03 18:25:05 +00:00
|
|
|
|
|
|
|
if( !pin )
|
|
|
|
{
|
2020-11-19 15:29:17 +00:00
|
|
|
msg.Printf( _( "Cannot find %s pin '%s'." ),
|
2022-05-03 07:20:46 +00:00
|
|
|
ref.GetRef(),
|
2020-11-03 18:25:05 +00:00
|
|
|
pinNumber );
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ERROR );
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
SCH_CONNECTION* connection = pin->Connection( &ref.GetSheetPath() );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
if( connection && connection->Name( true ) != shortNetName )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
processNetNameChange( &commit, ref.GetRef(), pin, connection,
|
2020-11-25 22:16:06 +00:00
|
|
|
connection->Name( true ), shortNetName );
|
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
}
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
2021-10-12 20:05:37 +00:00
|
|
|
|
2023-07-31 14:38:02 +00:00
|
|
|
if( m_processOtherFields )
|
|
|
|
{
|
|
|
|
// Need to handle three cases: existing field, new field, deleted field
|
|
|
|
for( const std::pair<const wxString, wxString>& field : fpData.m_fieldsMap )
|
|
|
|
{
|
|
|
|
const wxString& fpFieldName = field.first;
|
|
|
|
const wxString& fpFieldValue = field.second;
|
|
|
|
SCH_FIELD* symField = symbol->FindField( fpFieldName );
|
|
|
|
|
2023-08-03 13:09:13 +00:00
|
|
|
// Skip fields that are individually controlled
|
2023-10-03 16:14:03 +00:00
|
|
|
if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
|
|
|
|
|| fpFieldName == GetCanonicalFieldName( VALUE_FIELD )
|
|
|
|
|| fpFieldName == GetCanonicalFieldName( FOOTPRINT_FIELD ) )
|
2023-08-03 13:09:13 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-07-31 14:38:02 +00:00
|
|
|
// 1. Existing fields has changed value
|
|
|
|
// PCB Field value is checked against the shown text because this is the value
|
|
|
|
// with all the variables resolved. The footprints field value gets the symbol's
|
|
|
|
// resolved value when the PCB is updated from the schematic.
|
|
|
|
if( symField
|
|
|
|
&& symField->GetShownText( &ref.GetSheetPath(), false ) != fpFieldValue )
|
|
|
|
{
|
|
|
|
m_changesCount++;
|
|
|
|
msg.Printf( _( "Change field '%s' value to '%s'." ),
|
|
|
|
symField->GetCanonicalName(), fpFieldValue );
|
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
|
|
|
commit.Modify( symbol, screen );
|
|
|
|
symField->SetText( fpFieldValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2. New field has been added to footprint and needs to be added to symbol
|
|
|
|
if( symField == nullptr )
|
|
|
|
{
|
|
|
|
m_changesCount++;
|
|
|
|
msg.Printf( _( "Add field '%s' with value '%s'." ), fpFieldName, fpFieldValue );
|
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
|
|
|
commit.Modify( symbol, screen );
|
|
|
|
|
|
|
|
SCH_FIELD newField( VECTOR2I( 0, 0 ), symbol->GetFieldCount(), symbol,
|
|
|
|
fpFieldName );
|
|
|
|
newField.SetText( fpFieldValue );
|
|
|
|
symbol->AddField( newField );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3. Existing field has been deleted from footprint and needs to be deleted from symbol
|
|
|
|
// Check all symbol fields for existence in the footprint field map
|
|
|
|
for( SCH_FIELD& field : symbol->GetFields() )
|
|
|
|
{
|
|
|
|
// Never delete mandatory fields
|
2024-04-12 21:00:41 +00:00
|
|
|
if( field.IsMandatory() )
|
2023-07-31 14:38:02 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( fpData.m_fieldsMap.find( field.GetCanonicalName() )
|
|
|
|
== fpData.m_fieldsMap.end() )
|
|
|
|
{
|
|
|
|
// Field not found in footprint field map, delete it
|
|
|
|
m_changesCount++;
|
|
|
|
msg.Printf( _( "Delete field '%s.'" ), field.GetCanonicalName() );
|
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
|
|
|
commit.Modify( symbol, screen );
|
|
|
|
symbol->RemoveField( &field );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-09 16:24:49 +00:00
|
|
|
// TODO: back-annotate netclass changes?
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
2020-07-13 11:21:40 +00:00
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
m_frame->RecalculateConnections( &commit, NO_CLEANUP );
|
2020-08-13 21:30:30 +00:00
|
|
|
m_frame->UpdateNetHighlightStatus();
|
2023-06-09 16:24:49 +00:00
|
|
|
|
|
|
|
commit.Push( _( "Update Schematic from PCB" ) );
|
2020-08-13 21:30:30 +00:00
|
|
|
}
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
|
2023-09-07 16:09:53 +00:00
|
|
|
static SPIN_STYLE orientLabel( SCH_PIN* aPin )
|
2020-07-19 00:52:34 +00:00
|
|
|
{
|
2023-09-07 16:09:53 +00:00
|
|
|
SPIN_STYLE spin = SPIN_STYLE::RIGHT;
|
2020-07-19 00:52:34 +00:00
|
|
|
|
|
|
|
// Initial orientation from the pin
|
|
|
|
switch( aPin->GetLibPin()->GetOrientation() )
|
|
|
|
{
|
2024-04-20 09:44:34 +00:00
|
|
|
default:
|
|
|
|
case PIN_ORIENTATION::PIN_RIGHT: spin = SPIN_STYLE::LEFT; break;
|
2023-09-07 16:09:53 +00:00
|
|
|
case PIN_ORIENTATION::PIN_UP: spin = SPIN_STYLE::BOTTOM; break;
|
|
|
|
case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
|
|
|
|
case PIN_ORIENTATION::PIN_LEFT: spin = SPIN_STYLE::RIGHT; break;
|
2020-07-19 00:52:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
// Reorient based on the actual symbol orientation now
|
2020-07-19 00:52:34 +00:00
|
|
|
struct ORIENT
|
|
|
|
{
|
|
|
|
int flag;
|
|
|
|
int n_rots;
|
|
|
|
int mirror_x;
|
|
|
|
int mirror_y;
|
|
|
|
}
|
|
|
|
orientations[] =
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
{ SYM_ORIENT_0, 0, 0, 0 },
|
|
|
|
{ SYM_ORIENT_90, 1, 0, 0 },
|
|
|
|
{ SYM_ORIENT_180, 2, 0, 0 },
|
|
|
|
{ SYM_ORIENT_270, 3, 0, 0 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
|
|
|
|
{ SYM_MIRROR_Y, 0, 0, 1 },
|
|
|
|
{ SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
|
|
|
|
{ SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
|
2020-07-19 00:52:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ORIENT o = orientations[ 0 ];
|
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
const SCH_SYMBOL* parentSymbol = static_cast<const SCH_SYMBOL*>( aPin->GetParentSymbol() );
|
2020-07-19 00:52:34 +00:00
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
if( !parentSymbol )
|
2020-07-19 00:52:34 +00:00
|
|
|
return spin;
|
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
int symbolOrientation = parentSymbol->GetOrientation();
|
2020-07-19 00:52:34 +00:00
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
for( const ORIENT& i : orientations )
|
2020-07-19 00:52:34 +00:00
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
if( i.flag == symbolOrientation )
|
2020-07-19 00:52:34 +00:00
|
|
|
{
|
|
|
|
o = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int i = 0; i < o.n_rots; i++ )
|
|
|
|
spin = spin.RotateCCW();
|
|
|
|
|
|
|
|
if( o.mirror_x )
|
|
|
|
spin = spin.MirrorX();
|
|
|
|
|
|
|
|
if( o.mirror_y )
|
|
|
|
spin = spin.MirrorY();
|
|
|
|
|
|
|
|
return spin;
|
|
|
|
}
|
|
|
|
|
2020-11-09 12:06:03 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
void addConnections( SCH_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath,
|
|
|
|
std::set<SCH_ITEM*>& connectedItems )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2020-11-25 22:16:06 +00:00
|
|
|
if( connectedItems.insert( aItem ).second )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2020-11-25 22:16:06 +00:00
|
|
|
for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
|
|
|
|
addConnections( connectedItem, aSheetPath, connectedItems );
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& aRef, SCH_PIN* aPin,
|
|
|
|
const SCH_CONNECTION* aConnection,
|
2020-11-25 22:16:06 +00:00
|
|
|
const wxString& aOldName, const wxString& aNewName )
|
|
|
|
{
|
|
|
|
wxString msg;
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
// Find a physically-connected driver. We can't use the SCH_CONNECTION's m_driver because
|
|
|
|
// it has already been resolved by merging subgraphs with the same label, etc., and our
|
|
|
|
// name change may cause that resolution to change.
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
std::set<SCH_ITEM*> connectedItems;
|
|
|
|
SCH_ITEM* driver = nullptr;
|
|
|
|
CONNECTION_SUBGRAPH::PRIORITY driverPriority = CONNECTION_SUBGRAPH::PRIORITY::NONE;
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
addConnections( aPin, aConnection->Sheet(), connectedItems );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
for( SCH_ITEM* item : connectedItems )
|
|
|
|
{
|
|
|
|
CONNECTION_SUBGRAPH::PRIORITY priority = CONNECTION_SUBGRAPH::GetDriverPriority( item );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
if( priority > driverPriority )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2020-11-25 22:16:06 +00:00
|
|
|
driver = item;
|
|
|
|
driverPriority = priority;
|
2020-06-08 18:36:25 +00:00
|
|
|
}
|
2020-11-25 22:16:06 +00:00
|
|
|
}
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
switch( driver->Type() )
|
|
|
|
{
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
2020-06-08 18:36:25 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
|
|
|
++m_changesCount;
|
2020-11-25 22:16:06 +00:00
|
|
|
|
|
|
|
msg.Printf( _( "Change %s pin %s net label from '%s' to '%s'." ),
|
|
|
|
aRef,
|
2021-06-17 09:37:13 +00:00
|
|
|
aPin->GetShownNumber(),
|
2020-11-25 22:16:06 +00:00
|
|
|
aOldName,
|
|
|
|
aNewName );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
2023-06-09 16:24:49 +00:00
|
|
|
aCommit->Modify( driver, aConnection->Sheet().LastScreen() );
|
2022-01-25 22:33:37 +00:00
|
|
|
static_cast<SCH_LABEL_BASE*>( driver )->SetText( aNewName );
|
2020-06-08 18:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
break;
|
|
|
|
|
2020-07-19 00:52:34 +00:00
|
|
|
case SCH_PIN_T:
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2023-09-07 16:09:53 +00:00
|
|
|
SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
|
|
|
|
SPIN_STYLE spin = orientLabel( schPin );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2023-01-18 15:06:46 +00:00
|
|
|
if( schPin->IsGlobalPower() )
|
2020-06-08 18:36:25 +00:00
|
|
|
{
|
2021-06-17 09:37:13 +00:00
|
|
|
msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ),
|
|
|
|
aOldName,
|
|
|
|
aNewName );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ERROR );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++m_changesCount;
|
2021-06-17 09:37:13 +00:00
|
|
|
msg.Printf( _( "Add label '%s' to %s pin %s net." ),
|
|
|
|
aNewName,
|
|
|
|
aRef,
|
|
|
|
aPin->GetShownNumber() );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
|
|
|
if( !m_dryRun )
|
|
|
|
{
|
|
|
|
SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
|
|
|
|
SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
|
|
|
|
label->SetParent( &m_frame->Schematic() );
|
2023-02-19 03:40:07 +00:00
|
|
|
label->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
|
2023-09-07 16:09:53 +00:00
|
|
|
label->SetSpinStyle( spin );
|
2020-06-08 18:36:25 +00:00
|
|
|
label->SetFlags( IS_NEW );
|
|
|
|
|
2020-11-25 22:16:06 +00:00
|
|
|
SCH_SCREEN* screen = aConnection->Sheet().LastScreen();
|
2023-06-12 18:33:52 +00:00
|
|
|
aCommit->Add( label, screen );
|
2020-06-08 18:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-07-19 00:52:34 +00:00
|
|
|
}
|