diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 6deec2d169..40edd16173 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -52,6 +52,14 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : m_plotOpts = aParent->GetPlotSettings(); init_Dialog(); + // We use a sdbSizer here to get the order right, which is platform-dependent + m_sdbSizer1OK->SetLabel( _( "Plot" ) ); + m_sdbSizer1Apply->SetLabel( _( "Draft Plot" ) ); + m_sdbSizer1Apply->SetToolTip( _( "Plot without running zone fill checks." ) ); + m_sdbSizer1Cancel->SetLabel( _( "Close" ) ); + + m_sdbSizer1OK->SetDefault(); + GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); } @@ -753,7 +761,19 @@ void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event ) } -void DIALOG_PLOT::Plot( wxCommandEvent& event ) +void DIALOG_PLOT::Plot( wxCommandEvent& ) +{ + doPlot( true ); +} + + +void DIALOG_PLOT::DraftPlot( wxCommandEvent& ) +{ + doPlot( false ); +} + + +void DIALOG_PLOT::doPlot( bool aCheckZones ) { BOARD* board = m_parent->GetBoard(); @@ -782,6 +802,9 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) return; } + if( aCheckZones ) + m_parent->Check_All_Zones( this ); + m_plotOpts.SetAutoScale( false ); m_plotOpts.SetScale( 1 ); diff --git a/pcbnew/dialogs/dialog_plot.h b/pcbnew/dialogs/dialog_plot.h index 1dc9e2a5c1..30f3712b15 100644 --- a/pcbnew/dialogs/dialog_plot.h +++ b/pcbnew/dialogs/dialog_plot.h @@ -58,6 +58,7 @@ private: // Event called functions void Plot( wxCommandEvent& event ) override; + void DraftPlot( wxCommandEvent& event ) override; void OnQuit( wxCommandEvent& event ) override; void OnClose( wxCloseEvent& event ) override; void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override; @@ -74,6 +75,7 @@ private: void init_Dialog(); // main initialization void reInitDialog(); // initialization after calling drill dialog void applyPlotSettings(); + void doPlot( bool aCheckZones ); PlotFormat getPlotFormat(); void setPlotModeChoiceSelection( EDA_DRAW_MODE_T aPlotMode ) diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 667808c74d..86595d2391 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -378,23 +378,27 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); m_buttonDRC = new wxButton( this, wxID_ANY, _("Run DRC..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_buttonDRC, 0, wxALL, 5 ); + bSizerButtons->Add( m_buttonDRC, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_buttonDrill = new wxButton( this, ID_CREATE_DRILL_FILE, _("Generate Drill File..."), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButtons->Add( m_buttonDrill, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); bSizerButtons->Add( 10, 0, 1, wxEXPAND, 5 ); - m_plotButton = new wxButton( this, wxID_ANY, _("Plot"), wxDefaultPosition, wxDefaultSize, 0 ); - m_plotButton->SetDefault(); - bSizerButtons->Add( m_plotButton, 0, wxALL, 5 ); + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Apply = new wxButton( this, wxID_APPLY ); + m_sdbSizer1->AddButton( m_sdbSizer1Apply ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); - m_buttonDrill = new wxButton( this, ID_CREATE_DRILL_FILE, _("Generate Drill File..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_buttonDrill, 0, wxALL, 5 ); - - m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerButtons->Add( m_buttonQuit, 0, wxALL, 5 ); + bSizerButtons->Add( m_sdbSizer1, 0, wxEXPAND, 5 ); - m_MainSizer->Add( bSizerButtons, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 5 ); + m_MainSizer->Add( bSizerButtons, 0, wxALIGN_RIGHT|wxEXPAND|wxLEFT, 5 ); this->SetSizer( m_MainSizer ); @@ -437,9 +441,10 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_useGerberX2Attributes->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnGerberX2Checked ), NULL, this ); m_DXF_plotModeOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnChangeDXFPlotMode ), NULL, this ); m_buttonDRC->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onRunDRC ), NULL, this ); - m_plotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); m_buttonDrill->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::CreateDrillFile ), NULL, this ); - m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); + m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::DraftPlot ), NULL, this ); + m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); + m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); this->Connect( m_menuItem1->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); this->Connect( m_menuItem2->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); this->Connect( m_menuItem3->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); @@ -460,9 +465,10 @@ DIALOG_PLOT_BASE::~DIALOG_PLOT_BASE() m_useGerberX2Attributes->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnGerberX2Checked ), NULL, this ); m_DXF_plotModeOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnChangeDXFPlotMode ), NULL, this ); m_buttonDRC->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::onRunDRC ), NULL, this ); - m_plotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); m_buttonDrill->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::CreateDrillFile ), NULL, this ); - m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); + m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::DraftPlot ), NULL, this ); + m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnQuit ), NULL, this ); + m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_BASE::Plot ), NULL, this ); this->Disconnect( ID_LAYER_FAB, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); this->Disconnect( ID_SELECT_COPPER_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); this->Disconnect( ID_DESELECT_COPPER_LAYERS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PLOT_BASE::OnPopUpLayers ) ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 17375c9fe8..a11f35d742 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -14,7 +14,6 @@ dialog_plot_base 1000 none - 1 Dialog_Plot_base @@ -4391,7 +4390,7 @@ 5 - wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND + wxALIGN_RIGHT|wxEXPAND|wxLEFT 0 @@ -4400,7 +4399,7 @@ none 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -4488,105 +4487,7 @@ 5 - wxEXPAND - 1 - - 0 - protected - 10 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Plot - - 0 - - - 0 - - 1 - m_plotButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - Plot - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -4674,90 +4575,38 @@ 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Close - - 0 - - - 0 - - 1 - m_buttonQuit - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnQuit - - - - - - - - - - - - - - - - - - - - - - - + 10 + + + + 5 + wxEXPAND + 0 + + 1 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + DraftPlot + OnQuit + + + + Plot + + diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 1b2478396c..f45e9ed0d7 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -113,9 +113,11 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxCheckBox* m_DXF_plotTextStrokeFontOpt; WX_HTML_REPORT_PANEL* m_messagesPanel; wxButton* m_buttonDRC; - wxButton* m_plotButton; wxButton* m_buttonDrill; - wxButton* m_buttonQuit; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Apply; + wxButton* m_sdbSizer1Cancel; wxMenu* m_popMenu; // Virtual event handlers, overide them in your derived class @@ -128,9 +130,10 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM virtual void OnGerberX2Checked( wxCommandEvent& event ) { event.Skip(); } virtual void OnChangeDXFPlotMode( wxCommandEvent& event ) { event.Skip(); } virtual void onRunDRC( wxCommandEvent& event ) { event.Skip(); } - virtual void Plot( wxCommandEvent& event ) { event.Skip(); } virtual void CreateDrillFile( wxCommandEvent& event ) { event.Skip(); } + virtual void DraftPlot( wxCommandEvent& event ) { event.Skip(); } virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } + virtual void Plot( wxCommandEvent& event ) { event.Skip(); } virtual void OnPopUpLayers( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 2c6bd4a4ae..a393975626 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -334,6 +334,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_microWaveToolBar = NULL; m_Layers = nullptr; + // We don't know what state board was in when it was lasat saved, so we have to + // assume dirty + m_ZoneFillsDirty = true; + m_rotationAngle = 900; // Create GAL canvas @@ -1087,6 +1091,8 @@ void PCB_EDIT_FRAME::OnModify( ) if( draw3DFrame ) draw3DFrame->ReloadRequest(); + + m_ZoneFillsDirty = true; } diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index cdcb98a367..678912e19a 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -256,6 +256,8 @@ public: bool m_show_microwave_tools; bool m_show_layer_manager_tools; + bool m_ZoneFillsDirty; // Board has been modified since last zone fill. + virtual ~PCB_EDIT_FRAME(); /** diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index 2ec3cf76a8..4da12d4924 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -118,7 +118,9 @@ int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent ) ZONE_FILLER filler( board(), &commit ); filler.SetProgressReporter( progressReporter.get() ); - filler.Fill( toFill ); + + if( filler.Fill( toFill ) ) + frame()->m_ZoneFillsDirty = false; return 0; } diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index e5e39857b2..d4aaaf64cb 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -82,7 +82,7 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ) m_progressReporter = aReporter; } -void ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) +bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) { int parallelThreadCount = std::max( ( int )std::thread::hardware_concurrency(), 2 ); @@ -90,7 +90,7 @@ void ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) auto connectivity = m_board->GetConnectivity(); if( !connectivity->TryLock() ) - return; + return false; for( auto zone : aZones ) { @@ -202,7 +202,7 @@ void ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) connectivity->SetProgressReporter( nullptr ); connectivity->Unlock(); - return; + return false; } } @@ -311,6 +311,7 @@ void ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) } connectivity->Unlock(); + return true; } diff --git a/pcbnew/zone_filler.h b/pcbnew/zone_filler.h index b505f6ea24..27f50a1a51 100644 --- a/pcbnew/zone_filler.h +++ b/pcbnew/zone_filler.h @@ -41,8 +41,8 @@ public: ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit = nullptr ); ~ZONE_FILLER(); - void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ); - void Fill( std::vector aZones, bool aCheck = false ); + void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ); + bool Fill( std::vector aZones, bool aCheck = false ); private: diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index e8ae03ec82..1c1a12322a 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -105,6 +105,9 @@ int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow* aActiveWindow ) void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow ) { + if( !m_ZoneFillsDirty ) + return; + std::vector toFill; for( auto zone : GetBoard()->Zones() ) @@ -117,5 +120,7 @@ void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow ) ZONE_FILLER filler( GetBoard(), &commit ); filler.SetProgressReporter( progressReporter.get() ); - filler.Fill( toFill, true ); + + if( filler.Fill( toFill, true ) ) + m_ZoneFillsDirty = false; }