From 67095af04393b0b69ff6a36a27615d45df198db8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 9 Nov 2020 20:32:08 +0000 Subject: [PATCH] Handle dimensions in Edit Text and Graphics Properties. Fixes https://gitlab.com/kicad/code/kicad/issues/6340 --- .../dialog_global_edit_text_and_graphics.cpp | 26 +++++++++++++++---- pcbnew/pcb_edit_frame.cpp | 24 +++++++++++------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index 61806aec1d..c87b9668bf 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -270,8 +271,12 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B aCommit.Modify( aItem ); EDA_TEXT* textItem = dynamic_cast( aItem ); - PCB_SHAPE* drawItem = dynamic_cast( aItem ); FP_TEXT* fpTextItem = dynamic_cast( aItem ); + PCB_SHAPE* drawItem = dynamic_cast( aItem ); + DIMENSION* dimension = dynamic_cast( aItem ); + + if( dimension ) + textItem = &dimension->Text(); if( m_setToSpecifiedValues->GetValue() ) { @@ -296,8 +301,14 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B if( m_keepUpright->Get3StateValue() != wxCHK_UNDETERMINED && fpTextItem ) fpTextItem->SetKeepUpright( m_keepUpright->GetValue() ); - if( !m_lineWidth.IsIndeterminate() && drawItem ) - drawItem->SetWidth( m_lineWidth.GetValue() ); + if( !m_lineWidth.IsIndeterminate() ) + { + if( drawItem ) + drawItem->SetWidth( m_lineWidth.GetValue() ); + + if( dimension ) + dimension->SetLineThickness( m_lineWidth.GetValue() ); + } } else { @@ -315,6 +326,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, B if( drawItem ) drawItem->SetWidth( m_brdSettings->GetLineThickness( layer ) ); + + if( dimension ) + dimension->SetLineThickness( m_brdSettings->GetLineThickness( layer ) ); } } @@ -399,12 +413,14 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() // Go through the PCB text & graphic items for( BOARD_ITEM* boardItem : m_parent->GetBoard()->Drawings() ) { - if( boardItem->Type() == PCB_TEXT_T ) + KICAD_T itemType = boardItem->Type(); + + if( itemType == PCB_TEXT_T ) { if( m_boardText->GetValue() ) visitItem( commit, boardItem ); } - else if( boardItem->Type() == PCB_SHAPE_T ) + else if( itemType == PCB_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T ) { if( m_boardGraphics->GetValue() ) visitItem( commit, boardItem ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 45cfd46e4a..3350e2ff9c 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1381,19 +1381,27 @@ void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimesta void PCB_EDIT_FRAME::RunEeschema() { wxString msg; - wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), - KiCadSchematicFileExtension ); + wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(), "kicad_sch" ); - if( !schfn.FileExists() ) + if( !schematic.FileExists() ) { - msg.Printf( _( "Schematic file \"%s\" not found." ), schfn.GetFullPath() ); - wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); - return; + wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(), "sch" ); + + if( legacySchematic.FileExists() ) + { + schematic = legacySchematic; + } + else + { + msg.Printf( _( "Schematic file \"%s\" not found." ), schematic.GetFullPath() ); + wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); + return; + } } if( Kiface().IsSingle() ) { - wxString filename = wxT( "\"" ) + schfn.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" ); + wxString filename = wxT( "\"" ) + schematic.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" ); ExecuteFile( this, EESCHEMA_EXE, filename ); } else @@ -1425,7 +1433,7 @@ void PCB_EDIT_FRAME::RunEeschema() if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor) // but no project loaded. { - frame->OpenProjectFiles( std::vector( 1, schfn.GetFullPath() ) ); + frame->OpenProjectFiles( std::vector( 1, schematic.GetFullPath() ) ); frame->Show( true ); }