Update dimension units when opening PCBs in CLI.
Fixes https://gitlab.com/kicad/code/kicad/issues/14170
(cherry picked from commit a0adb59437
)
This commit is contained in:
parent
b2679b7648
commit
249bcd9e1a
|
@ -194,12 +194,6 @@ public:
|
|||
return m_pcb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update any references within aItem (or its descendants) to the user units. Primarily
|
||||
* for automatic-unit dimensions.
|
||||
*/
|
||||
void UpdateUserUnits( BOARD_ITEM* aItem, bool* aSelectedItemsModified = nullptr );
|
||||
|
||||
/**
|
||||
* @return the primary data model.
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <pcb_bitmap.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <pgm_base.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <progress_reporter.h>
|
||||
|
@ -977,6 +978,37 @@ wxString BOARD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
|||
}
|
||||
|
||||
|
||||
void BOARD::UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView )
|
||||
{
|
||||
INSPECTOR_FUNC inspector =
|
||||
[&]( EDA_ITEM* descendant, void* aTestData )
|
||||
{
|
||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( descendant );
|
||||
|
||||
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
|
||||
{
|
||||
dimension->UpdateUnits();
|
||||
|
||||
if( aView )
|
||||
aView->Update( dimension );
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
aItem->Visit( inspector, nullptr, { PCB_DIM_ALIGNED_T,
|
||||
PCB_DIM_LEADER_T,
|
||||
PCB_DIM_ORTHOGONAL_T,
|
||||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T,
|
||||
PCB_FP_DIM_ALIGNED_T,
|
||||
PCB_FP_DIM_LEADER_T,
|
||||
PCB_FP_DIM_ORTHOGONAL_T,
|
||||
PCB_FP_DIM_CENTER_T,
|
||||
PCB_FP_DIM_RADIAL_T } );
|
||||
}
|
||||
|
||||
|
||||
void BOARD::DeleteMARKERs()
|
||||
{
|
||||
// the vector does not know how to delete the PCB_MARKER, it holds pointers
|
||||
|
|
|
@ -644,6 +644,12 @@ public:
|
|||
EDA_UNITS GetUserUnits() { return m_userUnits; }
|
||||
void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
|
||||
|
||||
/**
|
||||
* Update any references within aItem (or its descendants) to the user units. Primarily
|
||||
* for automatic-unit dimensions.
|
||||
*/
|
||||
void UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView );
|
||||
|
||||
/**
|
||||
* Extract the board outlines and build a closed polygon from lines, arcs and circle items
|
||||
* on edge cut layer.
|
||||
|
|
|
@ -229,12 +229,8 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
|||
|
||||
if( BOARD* board = GetBoard() )
|
||||
{
|
||||
bool selectedItemsModified = false;
|
||||
|
||||
UpdateUserUnits( board, &selectedItemsModified );
|
||||
|
||||
if( selectedItemsModified )
|
||||
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
||||
board->UpdateUserUnits( board, GetCanvas()->GetView() );
|
||||
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
||||
}
|
||||
|
||||
ReCreateAuxiliaryToolbar();
|
||||
|
|
|
@ -249,45 +249,11 @@ void PCB_BASE_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
|
|||
// it might be stored in another orientation if the lib is an archive built from a board)
|
||||
aFootprint->SetOrientation( ANGLE_0 );
|
||||
|
||||
UpdateUserUnits( aFootprint );
|
||||
GetBoard()->UpdateUserUnits( aFootprint, GetCanvas()->GetView() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_BASE_FRAME::UpdateUserUnits( BOARD_ITEM* aItem, bool* aSelectedItemsModified )
|
||||
{
|
||||
KIGFX::VIEW* view = GetCanvas()->GetView();
|
||||
|
||||
INSPECTOR_FUNC inspector =
|
||||
[&]( EDA_ITEM* descendant, void* aTestData )
|
||||
{
|
||||
PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( descendant );
|
||||
|
||||
if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
|
||||
{
|
||||
dimension->UpdateUnits();
|
||||
|
||||
if( aSelectedItemsModified && dimension->IsSelected() )
|
||||
*aSelectedItemsModified = true;
|
||||
|
||||
view->Update( dimension );
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
aItem->Visit( inspector, nullptr, { PCB_DIM_ALIGNED_T,
|
||||
PCB_DIM_LEADER_T,
|
||||
PCB_DIM_ORTHOGONAL_T,
|
||||
PCB_DIM_CENTER_T,
|
||||
PCB_DIM_RADIAL_T,PCB_FP_DIM_ALIGNED_T,
|
||||
PCB_FP_DIM_LEADER_T,
|
||||
PCB_FP_DIM_ORTHOGONAL_T,
|
||||
PCB_FP_DIM_CENTER_T,
|
||||
PCB_FP_DIM_RADIAL_T } );
|
||||
}
|
||||
|
||||
|
||||
EDA_ITEM* PCB_BASE_FRAME::GetItem( const KIID& aId ) const
|
||||
{
|
||||
return GetBoard()->GetItem( aId );
|
||||
|
|
|
@ -189,6 +189,7 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
|
|||
brd->BuildConnectivity();
|
||||
brd->BuildListOfNets();
|
||||
brd->SynchronizeNetsAndNetClasses( false );
|
||||
brd->UpdateUserUnits( brd, nullptr );
|
||||
}
|
||||
|
||||
return brd;
|
||||
|
|
|
@ -1106,7 +1106,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Set parent so that clearance can be loaded
|
||||
fp->SetParent( board );
|
||||
m_frame->UpdateUserUnits( fp );
|
||||
board->UpdateUserUnits( fp, m_frame->GetCanvas()->GetView() );
|
||||
|
||||
for( PAD* pad : fp->Pads() )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue