From aa3aafc4ff72f5cb2277a7b0f74ce11ed1bac1cc Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 17 Jun 2019 17:01:05 -0400 Subject: [PATCH] Eeschema: fix sheet plotting bug. Prefix the sheet name with "Sheet: " and the sheet file name with "File: " when plotting so that it matches the display sheet rendering. Improve the root sheet plot file name. Fixes lp:1832081 https://bugs.launchpad.net/kicad/+bug/1832081 (cherry picked from commit 7235da0979ea25abc6793c0238b3acbb11b66566) --- eeschema/sch_edit_frame.cpp | 24 +++++++++++++++++------- eeschema/sch_sheet.cpp | 6 +++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 497fe2185d..ae2562214c 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -742,15 +742,25 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet() wxString filename = fn.GetName(); wxString sheetFullName = m_CurrentSheet->PathHumanReadable(); - // Remove the last '/' of the path human readable - // (and for the root sheet, make sheetFullName empty): - sheetFullName.RemoveLast(); + if( sheetFullName == "" ) + { + // For the root sheet, use root schematic file name. + sheetFullName.clear(); + } + else + { + if( filename.Last() != '-' || filename.Last() != '_' ) + filename += '-'; - sheetFullName.Trim( true ); - sheetFullName.Trim( false ); + // Remove the first and last '/' of the path human readable + sheetFullName.RemoveLast(); + sheetFullName.Remove( 0, 1 ); + sheetFullName.Trim( true ); + sheetFullName.Trim( false ); - // Convert path human readable separator to '-' - sheetFullName.Replace( wxT( "/" ), wxT( "-" ) ); + // Convert path human readable separator to '-' + sheetFullName.Replace( "/", "-" ); + } if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX ) filename += sheetFullName; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 21e58e2afc..f23a5bb93d 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2017 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2019 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 @@ -984,7 +984,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) aPlotter->SetColor( GetLayerColor( LAYER_SHEETNAME ) ); bool italic = false; - aPlotter->Text( pos_sheetname, txtcolor, Text, name_orientation, size, + aPlotter->Text( pos_sheetname, txtcolor, wxT( "Sheet: " ) + Text, name_orientation, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, thickness, italic, false ); @@ -996,7 +996,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) aPlotter->SetColor( GetLayerColor( LAYER_SHEETFILENAME ) ); - aPlotter->Text( pos_filename, txtcolor, Text, name_orientation, size, + aPlotter->Text( pos_filename, txtcolor, wxT( "File: " ) + Text, name_orientation, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, thickness, italic, false );