Sometimes a DRAW_PANEL_GAL wants its immediate parent and sometimes not.

For instance, we get things like high-contrast-mode from the pad
dialog when rendering a pad preview, but we want the colours from the
parent PCB_BASE_FRAME.
This commit is contained in:
Jeff Young 2020-09-02 21:56:31 +01:00
parent 9a8dd6312b
commit 450519a4bd
4 changed files with 18 additions and 8 deletions

View File

@ -170,7 +170,7 @@ void EDA_DRAW_PANEL_GAL::DoRePaint()
// Update current zoom settings if the canvas is managed by a EDA frame // Update current zoom settings if the canvas is managed by a EDA frame
// (i.e. not by a preview panel in a dialog) // (i.e. not by a preview panel in a dialog)
if( GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() ) if( !IsDialogPreview() && GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter(); GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter();
m_viewControls->UpdateScrollbars(); m_viewControls->UpdateScrollbars();

View File

@ -177,6 +177,8 @@ public:
*/ */
EDA_DRAW_FRAME* GetParentEDAFrame() const { return m_edaFrame; } EDA_DRAW_FRAME* GetParentEDAFrame() const { return m_edaFrame; }
bool IsDialogPreview() const { return m_parent != (wxWindow*) m_edaFrame; }
/** /**
* Function OnShow() * Function OnShow()
* Called when the window is shown for the first time. * Called when the window is shown for the first time.

View File

@ -291,6 +291,7 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas()
settings->SetSketchModeGraphicItems( sketchMode ); settings->SetSketchModeGraphicItems( sketchMode );
settings->SetHighContrast( false ); settings->SetHighContrast( false );
settings->SetContrastModeDisplay( HIGH_CONTRAST_MODE::NORMAL );
// gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid: // gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid:
double gridsize = 0.001 * IU_PER_MM; double gridsize = 0.001 * IU_PER_MM;
@ -786,6 +787,7 @@ void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
settings->SetSketchModeGraphicItems( m_sketchPreview ); settings->SetSketchModeGraphicItems( m_sketchPreview );
settings->SetHighContrast( false ); settings->SetHighContrast( false );
settings->SetContrastModeDisplay( HIGH_CONTRAST_MODE::NORMAL );
m_previewNotebook->ChangeSelection( 0 ); m_previewNotebook->ChangeSelection( 0 );
redraw(); redraw();

View File

@ -130,11 +130,14 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
// Load display options (such as filled/outline display of items). // Load display options (such as filled/outline display of items).
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class) // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
// which is not always the case (namely when it is used from a wxDialog like the pad editor) // which is not always the case (namely when it is used from a wxDialog like the pad editor)
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() ); if( !IsDialogPreview() )
{
KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_view );
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
if( frame ) if( frame )
static_cast<KIGFX::PCB_VIEW*>( m_view )->UpdateDisplayOptions( view->UpdateDisplayOptions( frame->GetDisplayOptions() );
frame->GetDisplayOptions() ); }
} }
@ -210,7 +213,7 @@ void PCB_DRAW_PANEL_GAL::UpdateColors()
{ {
COLOR_SETTINGS* cs = nullptr; COLOR_SETTINGS* cs = nullptr;
auto frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() ); PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
if( frame ) if( frame )
{ {
@ -385,7 +388,7 @@ void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
int viasCount = 0; int viasCount = 0;
int trackSegmentsCount = 0; int trackSegmentsCount = 0;
for( auto item : board->Tracks() ) for( TRACK* item : board->Tracks() )
{ {
if( item->Type() == PCB_VIA_T ) if( item->Type() == PCB_VIA_T )
viasCount++; viasCount++;
@ -415,7 +418,10 @@ void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
void PCB_DRAW_PANEL_GAL::OnShow() void PCB_DRAW_PANEL_GAL::OnShow()
{ {
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() ); PCB_BASE_FRAME* frame = nullptr;
if( !IsDialogPreview() )
frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
try try
{ {