From ed3dbe8b728949374efe6cf398177adcaee6e2e8 Mon Sep 17 00:00:00 2001 From: charras Date: Fri, 26 Mar 2010 17:18:59 +0000 Subject: [PATCH] make SVG print dialog consistent with print dialog and layers orders in layer manager --- pcbnew/dialog_SVG_print.cpp | 61 +++++++++++++++++++++++--------- pcbnew/dialog_SVG_print_base.cpp | 8 ++--- pcbnew/dialog_SVG_print_base.fbp | 8 ++--- pcbnew/dialog_SVG_print_base.h | 1 - 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/pcbnew/dialog_SVG_print.cpp b/pcbnew/dialog_SVG_print.cpp index c773e1be3d..35f1804d83 100644 --- a/pcbnew/dialog_SVG_print.cpp +++ b/pcbnew/dialog_SVG_print.cpp @@ -49,7 +49,7 @@ public: private: void OnCloseWindow( wxCloseEvent& event ); - void OnInitDialog( wxInitDialogEvent& event ); + void initDialog( ); void OnButtonPrintSelectedClick( wxCommandEvent& event ); void OnButtonPrintBoardClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event ); @@ -80,10 +80,13 @@ DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( WinEDA_DrawFrame* parent ) : { m_Parent = (WinEDA_BasePcbFrame*) parent; m_Config = wxGetApp().m_EDA_Config; + initDialog( ); + GetSizer()->SetSizeHints( this ); + Centre(); } -void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) +void DIALOG_SVG_PRINT::initDialog( ) { SetFocus(); // Make ESC key working @@ -103,12 +106,29 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) // Create layers list BOARD* board = m_Parent->GetBoard(); - int mask = 1; - for( int layer = 0; layerGetLayerName( layer ) ); + if( !board->IsLayerEnabled( layer ) ) + m_BoxSelectLayer[layer] = NULL; + else + m_BoxSelectLayer[layer] = + new wxCheckBox( this, -1, board->GetLayerName( layer ) ); + } + // Add wxCheckBoxes in layers lists dialog + // List layers in same order than in setup layers dialog + // (Front or Top to Back or Bottom) + DECLARE_LAYERS_ORDER_LIST(layersOrder); + for( int layer_idx = 0; layer_idx < NB_LAYERS; ++layer_idx ) + { + layer = layersOrder[layer_idx]; + wxASSERT(layer < NB_LAYERS); + + if( m_BoxSelectLayer[layer] == NULL ) + continue; + + long mask = 1 << layer; if( mask & s_SelectedLayers ) m_BoxSelectLayer[layer]->SetValue( true ); @@ -131,18 +151,14 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) for( int layer = 0; layerRead( layerKey, &option ) ) m_BoxSelectLayer[layer]->SetValue( option ); } } - - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } } @@ -179,9 +195,19 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) if( aPrintAll ) m_PrintMaskLayer = 0xFFFFFFFF; + else + m_PrintMaskLayer = 0; + + if( m_PrintBoardEdgesCtrl->IsChecked() ) + m_PrintMaskLayer |= EDGE_LAYER; + else + m_PrintMaskLayer &= ~EDGE_LAYER; for( int layer = 0; layerGetValue() ) continue; @@ -253,7 +279,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, GRResetPenAndBrush( &dc ); s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); - GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : true ); + GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true ); s_Parameters.m_DrillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE; @@ -263,14 +289,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, screen->m_IsPrinting = true; SetLocaleTo_C_standard(); // Switch the locale to standard C (needed - // to print floating point numbers like - // 1.3) + // to print floating point numbers like 1.3) m_Parent->PrintPage( &dc, aPrint_Frame_Ref, m_PrintMaskLayer, false, &s_Parameters); SetLocaleTo_Default(); // revert to the current locale screen->m_IsPrinting = false; panel->m_ClipBox = tmp; - GRForceBlackPen( FALSE ); + GRForceBlackPen( false ); screen->m_StartVisu = tmp_startvisu; screen->m_DrawOrg = old_org; @@ -308,8 +333,10 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) { m_Config->Write( PLOTSVGMODECOLOR_KEY, s_Parameters.m_Print_Black_and_White ); wxString layerKey; - for( int layer = 0; layerWrite( layerKey, m_BoxSelectLayer[layer]->IsChecked() ); } diff --git a/pcbnew/dialog_SVG_print_base.cpp b/pcbnew/dialog_SVG_print_base.cpp index 0738f73fb9..205c5f8329 100644 --- a/pcbnew/dialog_SVG_print_base.cpp +++ b/pcbnew/dialog_SVG_print_base.cpp @@ -72,13 +72,13 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c bButtonsSizer = new wxBoxSizer( wxVERTICAL ); m_buttonPrintSelected = new wxButton( this, wxID_PRINT_CURRENT, _("Print Selected"), wxDefaultPosition, wxDefaultSize, 0 ); - bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bButtonsSizer->Add( m_buttonPrintSelected, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_buttonBoard = new wxButton( this, wxID_PRINT_BOARD, _("Print Board"), wxDefaultPosition, wxDefaultSize, 0 ); - bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bButtonsSizer->Add( m_buttonBoard, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Quit"), wxDefaultPosition, wxDefaultSize, 0 ); - bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bButtonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); bUpperSizer->Add( bButtonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -108,7 +108,6 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SVG_PRINT_base::OnInitDialog ) ); m_ModeColorOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this ); m_buttonPrintSelected->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonBoard->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this ); @@ -119,7 +118,6 @@ DIALOG_SVG_PRINT_base::~DIALOG_SVG_PRINT_base() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_SVG_PRINT_base::OnCloseWindow ) ); - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SVG_PRINT_base::OnInitDialog ) ); m_ModeColorOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnSetColorModeSelected ), NULL, this ); m_buttonPrintSelected->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintSelectedClick ), NULL, this ); m_buttonBoard->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SVG_PRINT_base::OnButtonPrintBoardClick ), NULL, this ); diff --git a/pcbnew/dialog_SVG_print_base.fbp b/pcbnew/dialog_SVG_print_base.fbp index a4285efa44..58ebd6d721 100644 --- a/pcbnew/dialog_SVG_print_base.fbp +++ b/pcbnew/dialog_SVG_print_base.fbp @@ -49,7 +49,7 @@ - OnInitDialog + @@ -415,7 +415,7 @@ none 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 @@ -467,7 +467,7 @@ 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 @@ -519,7 +519,7 @@ 5 - wxALL|wxALIGN_CENTER_HORIZONTAL + wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND 0 diff --git a/pcbnew/dialog_SVG_print_base.h b/pcbnew/dialog_SVG_print_base.h index d5b1f419d3..27da774d36 100644 --- a/pcbnew/dialog_SVG_print_base.h +++ b/pcbnew/dialog_SVG_print_base.h @@ -57,7 +57,6 @@ class DIALOG_SVG_PRINT_base : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); } - virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } virtual void OnSetColorModeSelected( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonPrintSelectedClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonPrintBoardClick( wxCommandEvent& event ){ event.Skip(); }