From 53b8a8ca962cda2db5c2152b23e40b0daf8f2ca4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 20 Apr 2015 18:48:31 +0200 Subject: [PATCH] Pcbnew: add the board thickness setup in dialog_layers_setup.cpp (mainly for the 3D viewer) --- pcbnew/dialogs/dialog_layers_setup.cpp | 10 + pcbnew/dialogs/dialog_layers_setup_base.cpp | 30 +- pcbnew/dialogs/dialog_layers_setup_base.fbp | 290 +++++++++++++++++++- pcbnew/dialogs/dialog_layers_setup_base.h | 5 +- 4 files changed, 330 insertions(+), 5 deletions(-) diff --git a/pcbnew/dialogs/dialog_layers_setup.cpp b/pcbnew/dialogs/dialog_layers_setup.cpp index 79e5a24cd5..da06a759b9 100644 --- a/pcbnew/dialogs/dialog_layers_setup.cpp +++ b/pcbnew/dialogs/dialog_layers_setup.cpp @@ -322,6 +322,9 @@ DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoa m_copperLayerCount = m_pcb->GetCopperLayerCount(); showCopperChoice( m_copperLayerCount ); setCopperLayerCheckBoxes( m_copperLayerCount ); + m_staticTextBrdThicknessUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); + PutValueInLocalUnits( *m_textCtrlBrdThickness, + m_pcb->GetDesignSettings().GetBoardThickness() ); showBoardLayerNames(); @@ -620,6 +623,13 @@ void DIALOG_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event ) } } + int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness ); + + // Clamp the value between reasonable values + + thickness = Clamp( Millimeter2iu( 0.1 ), thickness, Millimeter2iu( 3.0 ) ); + m_pcb->GetDesignSettings().SetBoardThickness( thickness ); + EndModal( wxID_OK ); } } diff --git a/pcbnew/dialogs/dialog_layers_setup_base.cpp b/pcbnew/dialogs/dialog_layers_setup_base.cpp index b6b523b0a3..67847f260f 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.cpp +++ b/pcbnew/dialogs/dialog_layers_setup_base.cpp @@ -33,7 +33,7 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID bPresetsSizer->Add( m_PresetsChoice, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bChoicesSizer->Add( bPresetsSizer, 1, wxEXPAND, 5 ); + bChoicesSizer->Add( bPresetsSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bCopperLayersSizer; bCopperLayersSizer = new wxBoxSizer( wxVERTICAL ); @@ -49,7 +49,33 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID bCopperLayersSizer->Add( m_CopperLayersChoice, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bChoicesSizer->Add( bCopperLayersSizer, 1, wxEXPAND, 5 ); + bChoicesSizer->Add( bCopperLayersSizer, 0, wxEXPAND, 5 ); + + wxBoxSizer* bBrdThicknessSizer; + bBrdThicknessSizer = new wxBoxSizer( wxVERTICAL ); + + m_staticTextBrdThickness = new wxStaticText( this, wxID_ANY, _("Board Thickness"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextBrdThickness->Wrap( -1 ); + bBrdThicknessSizer->Add( m_staticTextBrdThickness, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxFlexGridSizer* fgSizerBrdThickness; + fgSizerBrdThickness = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizerBrdThickness->AddGrowableCol( 0 ); + fgSizerBrdThickness->SetFlexibleDirection( wxBOTH ); + fgSizerBrdThickness->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_textCtrlBrdThickness = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizerBrdThickness->Add( m_textCtrlBrdThickness, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_staticTextBrdThicknessUnit = new wxStaticText( this, wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextBrdThicknessUnit->Wrap( -1 ); + fgSizerBrdThickness->Add( m_staticTextBrdThicknessUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + + bBrdThicknessSizer->Add( fgSizerBrdThickness, 1, wxEXPAND, 5 ); + + + bChoicesSizer->Add( bBrdThicknessSizer, 1, wxEXPAND, 5 ); bMainSizer->Add( bChoicesSizer, 0, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_layers_setup_base.fbp b/pcbnew/dialogs/dialog_layers_setup_base.fbp index 4b255d0c04..dcba49444d 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.fbp +++ b/pcbnew/dialogs/dialog_layers_setup_base.fbp @@ -105,7 +105,7 @@ 5 wxEXPAND - 1 + 0 bPresetsSizer @@ -287,7 +287,7 @@ 5 wxEXPAND - 1 + 0 bCopperLayersSizer @@ -466,6 +466,292 @@ + + 5 + wxEXPAND + 1 + + + bBrdThicknessSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Board Thickness + + 0 + + + 0 + + 1 + m_staticTextBrdThickness + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 2 + wxBOTH + 0 + + 0 + + fgSizerBrdThickness + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 0 + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlBrdThickness + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unit + + 0 + + + 0 + + 1 + m_staticTextBrdThicknessUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_layers_setup_base.h b/pcbnew/dialogs/dialog_layers_setup_base.h index 8961d32ac2..539e9c3ea4 100644 --- a/pcbnew/dialogs/dialog_layers_setup_base.h +++ b/pcbnew/dialogs/dialog_layers_setup_base.h @@ -22,9 +22,9 @@ class DIALOG_SHIM; #include #include #include +#include #include #include -#include #include #include #include @@ -192,6 +192,9 @@ class DIALOG_LAYERS_SETUP_BASE : public DIALOG_SHIM wxChoice* m_PresetsChoice; wxStaticText* m_staticTextCopperLayers; wxChoice* m_CopperLayersChoice; + wxStaticText* m_staticTextBrdThickness; + wxTextCtrl* m_textCtrlBrdThickness; + wxStaticText* m_staticTextBrdThicknessUnit; wxStaticText* m_staticTextLayers; wxPanel* m_TitlePanel; wxScrolledWindow* m_LayersListPanel;