Units for footprint preview widgets.
This commit is contained in:
parent
67e6603699
commit
056349e5ea
|
@ -86,6 +86,12 @@ void FOOTPRINT_PREVIEW_WIDGET::ClearStatus()
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::SetUserUnits( EDA_UNITS aUnits )
|
||||
{
|
||||
m_prev_panel->SetUserUnits( aUnits );
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_PREVIEW_WIDGET::DisplayFootprint( const LIB_ID& aFPID )
|
||||
{
|
||||
if( !m_prev_panel || m_libid == aFPID )
|
||||
|
|
|
@ -305,6 +305,7 @@ wxPanel* DIALOG_CHOOSE_SYMBOL::ConstructRightPanel( wxWindow* aParent )
|
|||
m_fp_sel_ctrl = new FOOTPRINT_SELECT_WIDGET( m_parent, panel, fp_list, true );
|
||||
|
||||
m_fp_preview = new FOOTPRINT_PREVIEW_WIDGET( panel, Kiway() );
|
||||
m_fp_preview->SetUserUnits( GetUserUnits() );
|
||||
}
|
||||
|
||||
if( m_fp_sel_ctrl )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
|
@ -25,10 +25,9 @@
|
|||
#include <functional>
|
||||
#include <import_export.h>
|
||||
#include <lib_id.h>
|
||||
|
||||
#include <eda_units.h>
|
||||
#include <gal/color4d.h>
|
||||
|
||||
class FOOTPRINT_LOAD_EVENT;
|
||||
class FOOTPRINT_PREVIEW_PANEL_BASE;
|
||||
class KIWAY;
|
||||
class wxStaticText;
|
||||
|
@ -64,6 +63,11 @@ public:
|
|||
*/
|
||||
void ClearStatus();
|
||||
|
||||
/**
|
||||
* Set the units for the preview.
|
||||
*/
|
||||
void SetUserUnits( EDA_UNITS aUnits );
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here
|
||||
* must have been passed to CacheFootprint before.
|
||||
|
@ -73,12 +77,11 @@ public:
|
|||
private:
|
||||
FOOTPRINT_PREVIEW_PANEL_BASE* m_prev_panel;
|
||||
|
||||
wxStaticText* m_status;
|
||||
wxPanel* m_statusPanel;
|
||||
wxSizer* m_statusSizer;
|
||||
wxSizer* m_outerSizer;
|
||||
LIB_ID m_libid;
|
||||
|
||||
wxStaticText* m_status;
|
||||
wxPanel* m_statusPanel;
|
||||
wxSizer* m_statusSizer;
|
||||
wxSizer* m_outerSizer;
|
||||
LIB_ID m_libid;
|
||||
};
|
||||
|
||||
|
||||
|
@ -91,6 +94,8 @@ class APIEXPORT FOOTPRINT_PREVIEW_PANEL_BASE
|
|||
public:
|
||||
virtual ~FOOTPRINT_PREVIEW_PANEL_BASE() {}
|
||||
|
||||
virtual void SetUserUnits( EDA_UNITS aUnits ) = 0;
|
||||
|
||||
/**
|
||||
* Set the currently displayed footprint. Any footprint passed in here
|
||||
* must have been passed to CacheFootprint before.
|
||||
|
|
|
@ -174,6 +174,7 @@ wxPanel* DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel( wxWindow* aParent )
|
|||
auto sizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_preview_ctrl = new FOOTPRINT_PREVIEW_WIDGET( panel, Kiway() );
|
||||
m_preview_ctrl->SetUserUnits( GetUserUnits() );
|
||||
sizer->Add( m_preview_ctrl, 1, wxEXPAND | wxTOP | wxRIGHT, 5 );
|
||||
|
||||
panel->SetSizer( sizer );
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <base_units.h>
|
||||
#include <board.h>
|
||||
#include <footprint.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <footprint_preview_panel.h>
|
||||
#include <fp_lib_table.h>
|
||||
|
@ -107,6 +108,25 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr<FOOTPRINT> aFootp
|
|||
|
||||
m_currentFootprint->SetParent( m_dummyBoard.get() );
|
||||
|
||||
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->SetUnits( m_userUnits );
|
||||
dimension->Update();
|
||||
}
|
||||
|
||||
return INSPECT_RESULT::CONTINUE;
|
||||
};
|
||||
|
||||
m_currentFootprint->Visit( inspector, nullptr, { PCB_FP_DIM_LEADER_T,
|
||||
PCB_FP_DIM_ORTHOGONAL_T,
|
||||
PCB_FP_DIM_CENTER_T,
|
||||
PCB_FP_DIM_RADIAL_T } );
|
||||
|
||||
// Ensure we are not using the high contrast mode to display the selected footprint
|
||||
KIGFX::PAINTER* painter = GetView()->GetPainter();
|
||||
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||
|
@ -139,7 +159,8 @@ bool FOOTPRINT_PREVIEW_PANEL::DisplayFootprint( const LIB_ID& aFPID )
|
|||
|
||||
try
|
||||
{
|
||||
const FOOTPRINT* fp = fptbl->GetEnumeratedFootprint( aFPID.GetLibNickname(), aFPID.GetLibItemName() );
|
||||
const FOOTPRINT* fp = fptbl->GetEnumeratedFootprint( aFPID.GetLibNickname(),
|
||||
aFPID.GetLibItemName() );
|
||||
|
||||
if( fp )
|
||||
m_currentFootprint.reset( static_cast<FOOTPRINT*>( fp->Duplicate() ) );
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
|
||||
virtual ~FOOTPRINT_PREVIEW_PANEL( );
|
||||
|
||||
virtual void SetUserUnits( EDA_UNITS aUnits ) override { m_userUnits = aUnits; }
|
||||
virtual bool DisplayFootprint( const LIB_ID& aFPID ) override;
|
||||
|
||||
virtual const KIGFX::COLOR4D& GetBackgroundColor() const override;
|
||||
|
@ -81,6 +82,7 @@ private:
|
|||
private:
|
||||
std::unique_ptr<BOARD> m_dummyBoard;
|
||||
std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> m_displayOptions;
|
||||
EDA_UNITS m_userUnits;
|
||||
std::shared_ptr<FOOTPRINT> m_currentFootprint;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue