Lazy loading of Schematic Setup panels.
This commit is contained in:
parent
932f171e96
commit
ddc6ecf7be
|
@ -119,10 +119,8 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
|
|||
// as this initial width is sometimes strange depending on the language (wxGrid bug?)
|
||||
int const min_width = m_netclassGrid->GetVisibleWidth( i, true, true );
|
||||
|
||||
int const weighted_min_best_width =
|
||||
( i == GRID_LINESTYLE )
|
||||
? min_best_width * 3 / 2
|
||||
: min_best_width;
|
||||
int const weighted_min_best_width = ( i == GRID_LINESTYLE ) ? min_best_width * 3 / 2
|
||||
: min_best_width;
|
||||
|
||||
m_netclassGrid->SetColMinimalWidth( i, min_width );
|
||||
|
||||
|
@ -172,7 +170,6 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
|
|||
|
||||
m_netclassGrid->SetAutoEvalCols( { GRID_WIREWIDTH,
|
||||
GRID_BUSWIDTH,
|
||||
|
||||
GRID_CLEARANCE,
|
||||
GRID_TRACKSIZE,
|
||||
GRID_VIASIZE,
|
||||
|
@ -325,6 +322,8 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
|
|||
row++;
|
||||
}
|
||||
|
||||
AdjustAssignmentGridColumns( GetSize().x * 3 / 5 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -650,16 +649,15 @@ void PANEL_SETUP_NETCLASSES::AdjustAssignmentGridColumns( int aWidth )
|
|||
// Account for scroll bars
|
||||
aWidth -= ( m_assignmentGrid->GetSize().x - m_assignmentGrid->GetClientSize().x );
|
||||
|
||||
// Set className column width to original className width from netclasses grid
|
||||
int classNameWidth = m_originalColWidths[ 0 ];
|
||||
m_assignmentGrid->SetColSize( 1, m_originalColWidths[ 0 ] );
|
||||
int classNameWidth = 160;
|
||||
m_assignmentGrid->SetColSize( 1, classNameWidth );
|
||||
m_assignmentGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_NETCLASSES::OnSizeAssignmentGrid( wxSizeEvent& event )
|
||||
{
|
||||
AdjustAssignmentGridColumns( event.GetSize().GetX());
|
||||
AdjustAssignmentGridColumns( event.GetSize().GetX() );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
|||
m_assignmentGrid->SetMargins( 0, 0 );
|
||||
|
||||
// Columns
|
||||
m_assignmentGrid->SetColSize( 0, 400 );
|
||||
m_assignmentGrid->SetColSize( 0, 360 );
|
||||
m_assignmentGrid->SetColSize( 1, 160 );
|
||||
m_assignmentGrid->EnableDragColMove( false );
|
||||
m_assignmentGrid->EnableDragColSize( true );
|
||||
|
|
|
@ -766,7 +766,7 @@
|
|||
<property name="col_label_values">"Pattern" "Net Class"</property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTER</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes">400,160</property>
|
||||
<property name="column_sizes">360,160</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
|
|
|
@ -90,7 +90,7 @@ bool WX_TREEBOOK::AddLazySubPage( std::function<wxWindow*( wxWindow* aParent )>
|
|||
}
|
||||
|
||||
|
||||
wxWindow* WX_TREEBOOK::ResolvePage( int aPage )
|
||||
wxWindow* WX_TREEBOOK::ResolvePage( size_t aPage )
|
||||
{
|
||||
wxWindow* page = GetPage( aPage );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -34,60 +34,88 @@
|
|||
#include <settings/settings_manager.h>
|
||||
#include "dialog_schematic_setup.h"
|
||||
#include "panel_template_fieldnames.h"
|
||||
#include <wx/treebook.h>
|
||||
|
||||
|
||||
DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
||||
PAGED_DIALOG( aFrame, _( "Schematic Setup" ), true,
|
||||
_( "Import Settings from Another Project..." ) ),
|
||||
m_frame( aFrame ),
|
||||
m_severities( nullptr )
|
||||
m_frame( aFrame )
|
||||
{
|
||||
PROJECT_FILE& project = aFrame->Prj().GetProjectFile();
|
||||
SCHEMATIC& schematic = aFrame->Schematic();
|
||||
SCHEMATIC_SETTINGS& settings = schematic.Settings();
|
||||
|
||||
SetEvtHandlerEnabled( false );
|
||||
|
||||
m_formatting = new PANEL_SETUP_FORMATTING( m_treebook, aFrame );
|
||||
|
||||
m_fieldNameTemplates = new PANEL_TEMPLATE_FIELDNAMES( m_treebook,
|
||||
&settings.m_TemplateFieldNames );
|
||||
|
||||
m_pinMap = new PANEL_SETUP_PINMAP( m_treebook, aFrame );
|
||||
|
||||
m_pinToPinError = ERC_ITEM::Create( ERCE_PIN_TO_PIN_WARNING );
|
||||
m_severities = new PANEL_SETUP_SEVERITIES( this, ERC_ITEM::GetItemsWithSeverities(),
|
||||
schematic.ErcSettings().m_ERCSeverities,
|
||||
m_pinToPinError.get() );
|
||||
|
||||
m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() );
|
||||
|
||||
m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, project.NetSettings(),
|
||||
schematic.GetNetClassAssignmentCandidates(), true );
|
||||
|
||||
m_buses = new PANEL_SETUP_BUSES( m_treebook, aFrame );
|
||||
|
||||
/*
|
||||
* WARNING: If you change page names you MUST update calls to ShowSchematicSetupDialog().
|
||||
*/
|
||||
|
||||
m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "General" ) );
|
||||
m_treebook->AddSubPage( m_formatting, _( "Formatting" ) );
|
||||
m_treebook->AddSubPage( m_fieldNameTemplates, _( "Field Name Templates" ) );
|
||||
|
||||
m_formattingPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
return new PANEL_SETUP_FORMATTING( aParent, m_frame );
|
||||
}, _( "Formatting" ) );
|
||||
|
||||
m_fieldNameTemplatesPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
|
||||
return new PANEL_TEMPLATE_FIELDNAMES( aParent, &settings.m_TemplateFieldNames );
|
||||
}, _( "Field Name Templates" ) );
|
||||
|
||||
m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "Electrical Rules" ) );
|
||||
m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) );
|
||||
m_treebook->AddSubPage( m_pinMap, _( "Pin Conflicts Map" ) );
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
ERC_SETTINGS& ercSettings = m_frame->Schematic().ErcSettings();
|
||||
return new PANEL_SETUP_SEVERITIES( aParent, ERC_ITEM::GetItemsWithSeverities(),
|
||||
ercSettings.m_ERCSeverities,
|
||||
m_pinToPinError.get() );
|
||||
}, _( "Violation Severity" ) );
|
||||
|
||||
m_pinMapPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
return new PANEL_SETUP_PINMAP( aParent, m_frame );
|
||||
}, _( "Pin Conflicts Map" ) );
|
||||
|
||||
m_treebook->AddPage( new wxPanel( GetTreebook() ), _( "Project" ) );
|
||||
m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) );
|
||||
m_treebook->AddSubPage( m_buses, _( "Bus Alias Definitions" ) );
|
||||
m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) );
|
||||
|
||||
m_netclassesPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
SCHEMATIC& schematic = m_frame->Schematic();
|
||||
return new PANEL_SETUP_NETCLASSES( aParent, m_frame,
|
||||
m_frame->Prj().GetProjectFile().NetSettings(),
|
||||
schematic.GetNetClassAssignmentCandidates(),
|
||||
true );
|
||||
}, _( "Net Classes" ) );
|
||||
|
||||
m_busesPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
return new PANEL_SETUP_BUSES( aParent, m_frame );
|
||||
}, _( "Bus Alias Definitions" ) );
|
||||
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
return new PANEL_TEXT_VARIABLES( aParent, &Prj() );
|
||||
}, _( "Text Variables" ) );
|
||||
|
||||
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
||||
m_treebook->ExpandNode( i );
|
||||
|
||||
// This is unfortunate, but it's the cost of lazy-loading the panels
|
||||
m_treebook->SetMinSize( wxSize( 920, 460 ) );
|
||||
m_treebook->SetInitialSize( wxSize( 920, 460 ) );
|
||||
|
||||
SetEvtHandlerEnabled( true );
|
||||
|
||||
finishDialogSettings();
|
||||
|
@ -148,19 +176,34 @@ void DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction( wxCommandEvent& event )
|
|||
file.m_SchematicSettings->LoadFromFile();
|
||||
|
||||
if( importDlg.m_FormattingOpt->GetValue() )
|
||||
m_formatting->ImportSettingsFrom( *file.m_SchematicSettings );
|
||||
{
|
||||
static_cast<PANEL_SETUP_FORMATTING*>( m_treebook->ResolvePage( m_formattingPage ) )
|
||||
->ImportSettingsFrom( *file.m_SchematicSettings );
|
||||
}
|
||||
|
||||
if( importDlg.m_FieldNameTemplatesOpt->GetValue() )
|
||||
m_fieldNameTemplates->ImportSettingsFrom( &otherSch.Settings().m_TemplateFieldNames );
|
||||
{
|
||||
static_cast<PANEL_TEMPLATE_FIELDNAMES*>( m_treebook->ResolvePage( m_fieldNameTemplatesPage ) )
|
||||
->ImportSettingsFrom( &otherSch.Settings().m_TemplateFieldNames );
|
||||
}
|
||||
|
||||
if( importDlg.m_PinMapOpt->GetValue() )
|
||||
m_pinMap->ImportSettingsFrom( file.m_ErcSettings->m_PinMap );
|
||||
{
|
||||
static_cast<PANEL_SETUP_PINMAP*>( m_treebook->ResolvePage( m_pinMapPage ) )
|
||||
->ImportSettingsFrom( file.m_ErcSettings->m_PinMap );
|
||||
}
|
||||
|
||||
if( importDlg.m_SeveritiesOpt->GetValue() )
|
||||
m_severities->ImportSettingsFrom( file.m_ErcSettings->m_ERCSeverities );
|
||||
{
|
||||
static_cast<PANEL_SETUP_SEVERITIES*>( m_treebook->ResolvePage( m_severitiesPage ) )
|
||||
->ImportSettingsFrom( file.m_ErcSettings->m_ERCSeverities );
|
||||
}
|
||||
|
||||
if( importDlg.m_NetClassesOpt->GetValue() )
|
||||
m_netclasses->ImportSettingsFrom( file.m_NetSettings );
|
||||
{
|
||||
static_cast<PANEL_SETUP_NETCLASSES*>( m_treebook->ResolvePage( m_netclassesPage ) )
|
||||
->ImportSettingsFrom( file.m_NetSettings );
|
||||
}
|
||||
|
||||
m_frame->GetSettingsManager()->UnloadProject( otherPrj, false );
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -45,16 +45,16 @@ protected:
|
|||
void onPageChanged( wxBookCtrlEvent& aEvent ) override;
|
||||
void onAuxiliaryAction( wxCommandEvent& aEvent ) override;
|
||||
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
|
||||
PANEL_SETUP_FORMATTING* m_formatting;
|
||||
PANEL_TEMPLATE_FIELDNAMES* m_fieldNameTemplates;
|
||||
PANEL_SETUP_PINMAP* m_pinMap;
|
||||
PANEL_SETUP_SEVERITIES* m_severities;
|
||||
PANEL_SETUP_NETCLASSES* m_netclasses;
|
||||
PANEL_SETUP_BUSES* m_buses;
|
||||
PANEL_TEXT_VARIABLES* m_textVars;
|
||||
std::shared_ptr<ERC_ITEM> m_pinToPinError;
|
||||
std::shared_ptr<ERC_ITEM> m_pinToPinError;
|
||||
|
||||
size_t m_formattingPage;
|
||||
size_t m_fieldNameTemplatesPage;
|
||||
size_t m_pinMapPage;
|
||||
size_t m_busesPage;
|
||||
size_t m_severitiesPage;
|
||||
size_t m_netclassesPage;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
bool AddLazySubPage( std::function<wxWindow*( wxWindow* aParent )> aLazyCtor,
|
||||
const wxString& text, bool bSelect = false, int imageId = NO_IMAGE );
|
||||
|
||||
wxWindow* ResolvePage( int aPage );
|
||||
wxWindow* ResolvePage( size_t aPage );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <settings/settings_manager.h>
|
||||
#include <widgets/resettable_panel.h>
|
||||
#include <widgets/wx_progress_reporters.h>
|
||||
#include <widgets/wx_treebook.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include "dialog_board_setup.h"
|
||||
|
@ -102,7 +101,6 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
|||
return new PANEL_SETUP_FORMATTING( aParent, m_frame );
|
||||
}, _( "Formatting" ) );
|
||||
|
||||
m_textVarsPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
|
@ -129,13 +127,13 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
|||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
BOARD* board = m_frame->GetBoard();
|
||||
return new PANEL_SETUP_NETCLASSES( aParent, m_frame,
|
||||
m_frame->Prj().GetProjectFile().NetSettings(),
|
||||
m_frame->GetBoard()->GetNetClassAssignmentCandidates(),
|
||||
board->GetNetClassAssignmentCandidates(),
|
||||
false );
|
||||
}, _( "Net Classes" ) );
|
||||
|
||||
m_rulesPage = m_treebook->GetPageCount();
|
||||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
|
@ -146,15 +144,18 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
|||
m_treebook->AddLazySubPage(
|
||||
[this]( wxWindow* aParent ) -> wxWindow*
|
||||
{
|
||||
BOARD* board = m_frame->GetBoard();
|
||||
return new PANEL_SETUP_SEVERITIES( aParent, DRC_ITEM::GetItemsWithSeverities(),
|
||||
m_frame->GetBoard()->GetDesignSettings().m_DRCSeverities );
|
||||
board->GetDesignSettings().m_DRCSeverities );
|
||||
}, _( "Violation Severity" ) );
|
||||
|
||||
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
||||
m_treebook->ExpandNode( i );
|
||||
|
||||
m_treebook->SetMinSize( wxSize( -1, 580 ) );
|
||||
m_treebook->SetInitialSize( wxSize( -1, 700 ) );
|
||||
// This is unfortunate, but it's the cost of lazy-loading the panels
|
||||
m_treebook->SetMinSize( wxSize( 980, 600 ) );
|
||||
m_treebook->SetInitialSize( wxSize( 980, 600 ) );
|
||||
|
||||
SetEvtHandlerEnabled( true );
|
||||
|
||||
finishDialogSettings();
|
||||
|
@ -180,7 +181,7 @@ void DIALOG_BOARD_SETUP::onPageChanged( wxBookCtrlEvent& aEvent )
|
|||
{
|
||||
PAGED_DIALOG::onPageChanged( aEvent );
|
||||
|
||||
int page = aEvent.GetSelection();
|
||||
size_t page = aEvent.GetSelection();
|
||||
|
||||
// Ensure layer page always gets updated even if we aren't moving towards it
|
||||
if( m_currentPage == m_physicalStackupPage )
|
||||
|
|
|
@ -60,17 +60,15 @@ public:
|
|||
static std::mutex g_Mutex; // Mutex to prevent multiple windows opening
|
||||
|
||||
private:
|
||||
int m_currentPage; // the current page index
|
||||
int m_textAndGraphicsPage;
|
||||
int m_constraintsPage;
|
||||
int m_formattingPage;
|
||||
int m_physicalStackupPage;
|
||||
int m_tracksAndViasPage;
|
||||
int m_netclassesPage;
|
||||
int m_maskAndPagePage;
|
||||
int m_rulesPage;
|
||||
int m_severitiesPage;
|
||||
int m_textVarsPage;
|
||||
size_t m_currentPage; // the current page index
|
||||
size_t m_textAndGraphicsPage;
|
||||
size_t m_constraintsPage;
|
||||
size_t m_formattingPage;
|
||||
size_t m_physicalStackupPage;
|
||||
size_t m_tracksAndViasPage;
|
||||
size_t m_netclassesPage;
|
||||
size_t m_maskAndPagePage;
|
||||
size_t m_severitiesPage;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue