67#define RESOLVE_PAGE( T, pageIndex ) static_cast<T*>( m_treebook->ResolvePage( pageIndex ) )
70 PAGED_DIALOG( aParentWindow ? aParentWindow : aFrame,
_(
"Board Setup" ), false, false,
71 _(
"Import Settings from Another Board..." ), wxSize( 980, 600 ) ),
100 SetEvtHandlerEnabled(
false );
116 [
this]( wxWindow* aParent ) -> wxWindow*
119 },
_(
"Board Editor Layers" ) );
123 [
this]( wxWindow* aParent ) -> wxWindow*
128 },
_(
"Physical Stackup" ) );
132 [
this]( wxWindow* aParent ) -> wxWindow*
135 },
_(
"Board Finish" ) );
139 [
this]( wxWindow* aParent ) -> wxWindow*
142 },
_(
"Drill Chart" ) );
148 [
this]( wxWindow* aParent ) -> wxWindow*
151 },
_(
"Defaults" ) );
155 [
this]( wxWindow* aParent ) -> wxWindow*
158 },
_(
"Formatting" ) );
161 [
this]( wxWindow* aParent ) -> wxWindow*
164 },
_(
"Text Variables" ) );
169 [
this]( wxWindow* aParent ) -> wxWindow*
173 _(
"Constraints" ) );
175 const std::vector<std::pair<PANEL_SETUP_CONSTRAINT_RULES::FAMILY, wxString>> ruleFamilies = {
185 for(
const auto& [family, familyTitle] : ruleFamilies )
187 size_t familyPage =
m_treebook->GetPageCount();
198 [
this]( wxWindow* aParent ) -> wxWindow*
202 _(
"Solder Mask/Paste" ) );
209 [
this, section]( wxWindow* aParent ) -> wxWindow*
220 [
this]( wxWindow* aParent ) -> wxWindow*
223 },
_(
"Pre-defined Sizes" ) );
227 [
this]( wxWindow* aParent ) -> wxWindow*
231 _(
"Microvia Stacks" ) );
235 [
this]( wxWindow* aParent ) -> wxWindow*
243 [
this]( wxWindow* aParent ) -> wxWindow*
246 },
_(
"Teardrops" ) );
250 [
this]( wxWindow* aParent ) -> wxWindow*
258 },
_(
"Length-tuning Patterns" ) );
262 [
this]( wxWindow* aParent ) -> wxWindow*
266 m_frame->Prj().GetProjectFile().TuningProfileParameters() );
268 _(
"Tuning Profiles" ) );
272 [
this]( wxWindow* aParent ) -> wxWindow*
276 m_frame->Prj().GetProjectFile().NetSettings(),
279 },
_(
"Net Classes" ) );
283 [
this]( wxWindow* aParent ) -> wxWindow*
287 aParent,
m_frame,
m_frame->Prj().GetProjectFile().ComponentClassSettings(),
290 _(
"Component Classes" ) );
294 [
this]( wxWindow* aParent ) -> wxWindow*
298 _(
"Custom Rules" ) );
302 [
this]( wxWindow* aParent ) -> wxWindow*
308 _(
"Violation Severity" ) );
313 [
this]( wxWindow* aParent ) -> wxWindow*
317 std::vector<EMBEDDED_FILES*> inheritedFiles;
320 inheritedFiles.push_back( fp->GetEmbeddedFiles() );
324 _(
"Embedded Files" ) );
328 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
331 SetEvtHandlerEnabled(
true );
339 if(
Prj().IsReadOnly() )
341 m_infoBar->ShowMessage(
_(
"Project is missing or read-only. Some settings will not be editable." ),
345 wxBookCtrlEvent evt( wxEVT_TREEBOOK_PAGE_CHANGED, wxID_ANY, 0 );
358 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
360 wxWindow* page =
m_treebook->GetResolvedPage( i );
377 if( !
m_ruleDocument->IsModified() && ( !rules || !rules->IsModified() ) )
380 return OKOrCancelDialog(
this,
_(
"Confirmation" ),
_(
"Discard changes to custom rules?" ), wxEmptyString,
381 _(
"Discard Changes" ) ) == wxID_OK;
409 bool saveRules =
m_ruleDocument->IsModified() && !
m_frame->GetBoard()->GetDesignRulesPath().IsEmpty();
417 SetError( wxString::Format(
_(
"Cannot save design rules: %s" ), error ),
nullptr,
nullptr );
441 auto* tuningProfiles =
446 const std::map<wxString, wxString> renames = tuningProfiles->TakeProfileRenames();
448 if( !renames.empty() )
450 std::shared_ptr<NET_SETTINGS>& netSettings =
m_frame->Prj().GetProjectFile().NetSettings();
452 auto remapProfile = [&renames](
const std::shared_ptr<NETCLASS>& aNetclass )
454 auto it = renames.find( aNetclass->GetTuningProfile() );
456 if( it != renames.end() )
457 aNetclass->SetTuningProfile( it->second );
460 remapProfile( netSettings->GetDefaultNetclass() );
462 for(
const auto& [
name, netclass] : netSettings->GetNetclasses() )
463 remapProfile( netclass );
465 netSettings->ClearAllCaches();
479 if(
int selected =
m_treebook->GetSelection(); selected != wxNOT_FOUND )
484 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
486 wxWindow* resolved =
m_treebook->GetResolvedPage( i );
489 rulesPage->RefreshDefaults();
491 constraintsPage->RefreshDefaults();
493 maskPage->RefreshDefaults();
541 if(
Prj().IsReadOnly() )
553 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
564 for(
size_t i = 0; i <
m_treebook->GetPageCount(); ++i )
566 wxWindow* resolved =
m_treebook->GetResolvedPage( i );
570 if( rulesPage->ImportGroup() == aGroup )
571 rulesPage->RefreshDefaults();
575 if( aGroup ==
_(
"Constraints" ) )
576 resolved->TransferDataToWindow();
580 if( aGroup ==
_(
"Solder Mask/Paste" ) )
581 resolved->TransferDataToWindow();
589 wxWindow* resolved =
m_treebook->GetResolvedPage( aPage );
592 rulesPage->RefreshFromDocument();
594 textPage->RefreshFromDocument();
596 constraintsPage->RefreshDefaults();
598 maskPage->RefreshDefaults();
606 if( importDlg.
ShowModal() == wxID_CANCEL )
616 wxFileName projectFn( boardFn );
619 wxString msg = wxString::Format(
_(
"Error importing settings from board:\n"
620 "Associated project file %s could not be loaded" ),
621 projectFn.GetFullPath() );
635 bool okToProceed =
true;
638 std::unique_ptr<BOARD> otherBoard;
644 pi->SetProgressReporter( &progressReporter );
646 otherBoard = pi->LoadBoard( boardFn.GetFullPath() );
653 okToProceed =
m_layers->CheckCopperLayerCount( loadedBoard, otherBoard.get() );
668 wxString msg = wxString::Format(
_(
"Error loading board file:\n%s" ), boardFn.GetFullPath() );
681 BOARD* other = otherBoard.get();
688 const bool activeProject = ( otherPrj == &
m_frame->Prj() );
690 struct BOARD_DETACH_GUARD
694 ~BOARD_DETACH_GUARD() {
if( board && !skip ) board->
ClearProject(); }
695 } detachGuard{ other, activeProject };
703 m_layers->ImportSettingsFrom( other );
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
PNS::MEANDER_SETTINGS m_DiffPairMeanderSettings
PNS::MEANDER_SETTINGS m_SingleTrackMeanderSettings
PNS::MEANDER_SETTINGS m_SkewMeanderSettings
Information pertinent to a Pcbnew printed circuit board.
EMBEDDED_FILES * GetEmbeddedFiles() override
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
const FOOTPRINTS & Footprints() const
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
wxString GetDesignRulesPath() const
Return the absolute path to the design rules file for this board.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
size_t m_embeddedFilesPage
DIALOG_BOARD_SETUP(PCB_EDIT_FRAME *aFrame, wxWindow *aWindow=nullptr)
size_t m_tracksAndViasPage
void forEachOpenRulePage(const std::function< void(PANEL_SETUP_CONSTRAINT_RULES *)> &aAction)
std::unique_ptr< DRC_RULE_DOCUMENT > m_ruleDocument
void onCancelButton(wxCommandEvent &aEvent)
size_t m_physicalStackupPage
PANEL_SETUP_TUNING_PROFILES * m_tuningProfiles
std::unique_ptr< BOARD_DESIGN_SETTINGS > m_stagedSettings
The constraint, mask and rule pages edit one value from several pages, so they share this copy,...
void onAuxiliaryAction(wxCommandEvent &aEvent) override
size_t m_tuningPatternsPage
PANEL_SETUP_BOARD_STACKUP * m_physicalStackup
PANEL_SETUP_ZONES * m_zones
void refreshStagedPages(const wxString &aGroup)
Reads the staged settings back into the open pages of one Import Settings group.
PANEL_SETUP_BOARD_FINISH * m_boardFinish
PANEL_SETUP_LAYERS * m_layers
size_t m_tuningProfilesPage
bool TransferDataFromWindow() override
size_t m_componentClassesPage
void onPageChanged(wxBookCtrlEvent &aEvent) override
PANEL_SETUP_NETCLASSES * m_netClasses
void onCloseWindow(wxCloseEvent &aEvent)
void refreshRulePage(size_t aPage)
wxCheckBox * m_CustomRulesOpt
wxCheckBox * m_ZoneHatchingOffsetsOpt
wxCheckBox * m_MaskAndPasteOpt
wxCheckBox * m_ConstraintsOpt
wxCheckBox * m_ComponentClassesOpt
wxCheckBox * m_TuningPatternsOpt
wxCheckBox * m_SeveritiesOpt
wxCheckBox * m_TextAndGraphicsOpt
wxCheckBox * m_TuningProfilesOpt
wxCheckBox * m_FormattingOpt
wxCheckBox * m_TeardropsOpt
wxCheckBox * m_TracksAndViasOpt
wxCheckBox * m_NetclassesOpt
wxString GetFilePath() const
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
An exception saying that the user cancelled an interactive part of a load, import,...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
WX_TREEBOOK * GetTreebook()
PAGED_DIALOG(wxWindow *aParent, const wxString &aTitle, bool aShowReset, bool aShowOpenFolder, const wxString &aAuxiliaryAction=wxEmptyString, const wxSize &aInitialSize=wxDefaultSize)
bool TransferDataFromWindow() override
virtual void onPageChanged(wxBookCtrlEvent &aEvent)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
static void CopySettings(const BOARD_DESIGN_SETTINGS &aFrom, BOARD_DESIGN_SETTINGS &aTo)
Copies every value this page edits, which is what the Constraints import group carries.
void RefreshFromDocument()
static std::vector< CONSTRAINT_SECTION > SectionsFor(FAMILY aFamily)
The sections of one family, in the order they are shown in the tree.
Board-wide drill chart and map setup.
static void CopySettings(const BOARD_DESIGN_SETTINGS &aFrom, BOARD_DESIGN_SETTINGS &aTo)
Copies every value this page edits, which is what the Solder Mask/Paste import group carries.
The main frame for Pcbnew.
@ KICAD_SEXP
S-expression Pcbnew file format.
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a PCB_IO which the caller can use to import, export, save, or load design documents.
The backing store for a PROJECT, in JSON format.
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
std::shared_ptr< TUNING_PROFILES > & TuningProfileParameters()
std::shared_ptr< COMPONENT_CLASS_SETTINGS > m_ComponentClassSettings
Component class settings for the project (owned here)
Container for project specific data.
virtual PROJECT_FILE & GetProjectFile() const
Move-only RAII wrapper for "load a foreign PROJECT non-active and unload it on scope exit.
bool IsValid() const
True iff the project loaded (or was already loaded).
PROJECT * GetProject() const
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define RESOLVE_PAGE(T, pageIndex)
static const std::string ProjectFileExtension
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
KICOMMON_API void Disable(wxWindow *aWindow)
Makes a window read-only.
One constraint on a Design Rules page: its board default, the net class values that apply to it,...
A filename or source description, a problem input line, a line number, a byte offset,...
Definition of file extensions used in Kicad.