Update dimension units when opening PCBs in CLI.
Fixes https://gitlab.com/kicad/code/kicad/issues/14170
This commit is contained in:
parent
72ebe5a429
commit
a0adb59437
|
@ -194,12 +194,6 @@ public:
|
||||||
return m_pcb;
|
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.
|
* @return the primary data model.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include <pcb_bitmap.h>
|
#include <pcb_bitmap.h>
|
||||||
#include <pcb_text.h>
|
#include <pcb_text.h>
|
||||||
#include <pcb_textbox.h>
|
#include <pcb_textbox.h>
|
||||||
|
#include <pcb_dimension.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <pcbnew_settings.h>
|
#include <pcbnew_settings.h>
|
||||||
#include <progress_reporter.h>
|
#include <progress_reporter.h>
|
||||||
|
@ -978,6 +979,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()
|
void BOARD::DeleteMARKERs()
|
||||||
{
|
{
|
||||||
// the vector does not know how to delete the PCB_MARKER, it holds pointers
|
// 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; }
|
EDA_UNITS GetUserUnits() { return m_userUnits; }
|
||||||
void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
|
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
|
* Extract the board outlines and build a closed polygon from lines, arcs and circle items
|
||||||
* on edge cut layer.
|
* on edge cut layer.
|
||||||
|
|
|
@ -231,12 +231,8 @@ void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
||||||
|
|
||||||
if( BOARD* board = GetBoard() )
|
if( BOARD* board = GetBoard() )
|
||||||
{
|
{
|
||||||
bool selectedItemsModified = false;
|
board->UpdateUserUnits( board, GetCanvas()->GetView() );
|
||||||
|
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
||||||
UpdateUserUnits( board, &selectedItemsModified );
|
|
||||||
|
|
||||||
if( selectedItemsModified )
|
|
||||||
m_toolManager->PostEvent( EVENTS::SelectedItemsModified );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReCreateAuxiliaryToolbar();
|
ReCreateAuxiliaryToolbar();
|
||||||
|
|
|
@ -285,45 +285,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)
|
// it might be stored in another orientation if the lib is an archive built from a board)
|
||||||
aFootprint->SetOrientation( ANGLE_0 );
|
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
|
EDA_ITEM* PCB_BASE_FRAME::GetItem( const KIID& aId ) const
|
||||||
{
|
{
|
||||||
return GetBoard()->GetItem( aId );
|
return GetBoard()->GetItem( aId );
|
||||||
|
|
|
@ -189,6 +189,7 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
|
||||||
brd->BuildConnectivity();
|
brd->BuildConnectivity();
|
||||||
brd->BuildListOfNets();
|
brd->BuildListOfNets();
|
||||||
brd->SynchronizeNetsAndNetClasses( false );
|
brd->SynchronizeNetsAndNetClasses( false );
|
||||||
|
brd->UpdateUserUnits( brd, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
return brd;
|
return brd;
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// Set parent so that clearance can be loaded
|
// Set parent so that clearance can be loaded
|
||||||
fp->SetParent( board );
|
fp->SetParent( board );
|
||||||
m_frame->UpdateUserUnits( fp );
|
board->UpdateUserUnits( fp, m_frame->GetCanvas()->GetView() );
|
||||||
|
|
||||||
for( PAD* pad : fp->Pads() )
|
for( PAD* pad : fp->Pads() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue