diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 63cb9d9e95..43fc421d07 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -335,15 +335,6 @@ void WinEDA_DrawFrame::DisplayUnitsMsg() } -void WinEDA_DrawFrame::ReDrawPanel() -{ - if( DrawPanel == NULL ) - return; - - KicadGraphicContext dc( DrawPanel ); - DrawPanel->ReDraw( &dc ); -} - /* Recalculate the size of toolbars and display panel. */ diff --git a/common/zoom.cpp b/common/zoom.cpp index 5ddc8903ee..418e681c1b 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -27,7 +27,8 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse ) { PutOnGrid( &(GetBaseScreen()->m_Curseur) ); AdjustScrollBars(); - ReDrawPanel(); + KicadGraphicContext dc( DrawPanel ); + DrawPanel->ReDraw( &dc ); /* Move the mouse cursor to the on grid graphic cursor position */ if( ToMouse == TRUE ) @@ -55,12 +56,13 @@ void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord ) } -/** Redraw the screen with the zoom level which shows all the page or the board +/** Redraw the screen with best zoom level and the best centering + * that shows all the page or the board */ void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor ) { - if( GetBaseScreen()->SetZoom( BestZoom() ) ) - Recadre_Trace( move_mouse_cursor ); + GetBaseScreen()->SetZoom( BestZoom() ); // Set the best zoom + Recadre_Trace( move_mouse_cursor ); // Set the best centering and refresh the screen } @@ -93,11 +95,7 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect ) void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) { if( DrawPanel == NULL ) - { - wxLogDebug( wxT( "%s, %d: DrawPanel object is undefined ." ), - __TFILE__, __LINE__ ); - return; - } + return; int i; int id = event.GetId(); @@ -131,7 +129,10 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) case ID_ZOOM_REDRAW: // DrawPanel->Refresh(); usually good, // but does not work under linux, when called from here (wxGTK bug ?) - ReDrawPanel(); + { + KicadGraphicContext dc( DrawPanel ); + DrawPanel->ReDraw( &dc ); + } break; case ID_POPUP_ZOOM_CENTER: @@ -139,12 +140,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) break; case ID_ZOOM_PAGE: - // With Zoom_Automatique(), the "Zoom Auto" button (and hotkey) - // does nothing if the view is already at the correct - // zoom level, but needs to be shifted (centered). - //Zoom_Automatique( false ); - GetBaseScreen()->SetZoom( BestZoom() ); - Recadre_Trace( false ); + Zoom_Automatique( false ); break; case ID_POPUP_ZOOM_SELECT: diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 9fc05822f6..3fddd5af16 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -236,9 +236,7 @@ public: wxDC* DC ); TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC ); - void InstallPadOptionsFrame( D_PAD* pad, - wxDC* DC, - const wxPoint& pos ); + void InstallPadOptionsFrame( D_PAD* pad ); void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC ); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 3d8288ded5..2ddb8c1737 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -298,9 +298,7 @@ public: void SetToolbars(); void Process_Settings( wxCommandEvent& event ); - void InstallPcbOptionsFrame( const wxPoint& pos, - wxDC* DC, - int id ); + void InstallPcbOptionsFrame( int id ); void InstallDisplayOptionsDialog( wxCommandEvent& aEvent ); void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); diff --git a/include/wxstruct.h b/include/wxstruct.h index ce457c6c7e..d5036e9a8c 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -273,7 +273,6 @@ public: void SVG_Print( wxCommandEvent& event ); void OnActivate( wxActivateEvent& event ); - void ReDrawPanel(); void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ); void PlotWorkSheet( PLOTTER *plotter, BASE_SCREEN* screen ); diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index 49cf05115f..44896dab0b 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -19,12 +19,10 @@ #include "pcbnew_id.h" -Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent, - wxDC* DC ) : +Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent ) : DialogGeneralOptionsBoardEditor_base( parent ) { m_Parent = parent; - m_DC = DC; init(); } @@ -101,8 +99,8 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() ) { g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue(); - m_Parent->Ratsnest_On_Off( m_DC ); - m_Parent->RedrawActiveWindow( m_DC, true ); + m_Parent->Ratsnest_On_Off( NULL ); + m_Parent->DrawPanel->Refresh( ); } g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); @@ -121,8 +119,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) #include "dialog_graphic_items_options.cpp" -void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos, - wxDC* DC, int id ) +void WinEDA_PcbFrame::InstallPcbOptionsFrame( int id ) { switch( id ) { diff --git a/pcbnew/dialog_general_options.h b/pcbnew/dialog_general_options.h index fa65cf5837..691e601f46 100644 --- a/pcbnew/dialog_general_options.h +++ b/pcbnew/dialog_general_options.h @@ -9,12 +9,11 @@ class Dialog_GeneralOptions : public DialogGeneralOptionsBoardEditor_base { private: WinEDA_PcbFrame* m_Parent; - wxDC* m_DC; void init(); public: - Dialog_GeneralOptions( WinEDA_PcbFrame* parent, wxDC* DC ); + Dialog_GeneralOptions( WinEDA_PcbFrame* parent ); ~Dialog_GeneralOptions() {}; void OnOkClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); diff --git a/pcbnew/dialog_pad_properties.cpp b/pcbnew/dialog_pad_properties.cpp index 4e9d5b8db4..bbf3f9c50a 100644 --- a/pcbnew/dialog_pad_properties.cpp +++ b/pcbnew/dialog_pad_properties.cpp @@ -55,11 +55,10 @@ class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE { public: WinEDA_BasePcbFrame* m_Parent; - wxDC* m_DC; D_PAD* m_CurrentPad; public: - DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad, wxDC* DC ); + DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad ); void InitDialog( ); void OnPadShapeSelection( wxCommandEvent& event ); void OnDrillShapeSelected( wxCommandEvent& event ); @@ -72,12 +71,11 @@ public: /*******************************************************************************************/ -DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad, wxDC* DC ) : +DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad ) : DIALOG_PAD_PROPERTIES_BASE( parent ) /*******************************************************************************************/ { m_Parent = parent; - m_DC = DC; m_CurrentPad = Pad; if( m_CurrentPad ) @@ -95,10 +93,10 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD /*************************************************************/ -void WinEDA_BasePcbFrame::InstallPadOptionsFrame( D_PAD* Pad, wxDC* DC, const wxPoint& pos ) +void WinEDA_BasePcbFrame::InstallPadOptionsFrame( D_PAD* Pad ) /*************************************************************/ { - DIALOG_PAD_PROPERTIES dlg( this, Pad, DC ); + DIALOG_PAD_PROPERTIES dlg( this, Pad ); dlg.ShowModal(); } @@ -418,9 +416,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) int internalUnits = m_Parent->m_InternalUnits; wxString msg; - if( m_DC ) - m_Parent->DrawPanel->CursorOff( m_DC ); - g_Pad_Master.m_Attribut = CodeType[m_PadType->GetSelection()]; g_Pad_Master.m_PadShape = CodeShape[m_PadShape->GetSelection()]; @@ -489,11 +484,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) } if( error ) - { - if( m_DC ) - m_Parent->DrawPanel->CursorOn( m_DC ); - return; - } + return; PadLayerMask = 0; if( m_PadLayerCu->GetValue() ) @@ -533,12 +524,12 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) m_Parent->SaveCopyInUndoList( Module, UR_CHANGED ); Module->m_LastEdit_Time = time( NULL ); - if( m_DC ) // redraw the area where the pad was, without pad (delete pad on screen) - { - m_CurrentPad->m_Flags |= DO_NOT_DRAW; - m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); - m_CurrentPad->m_Flags &= ~DO_NOT_DRAW; - } + // redraw the area where the pad was, without pad (delete pad on screen) + m_CurrentPad->m_Flags |= DO_NOT_DRAW; + m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); + m_CurrentPad->m_Flags &= ~DO_NOT_DRAW; + + // Update values m_CurrentPad->m_PadShape = g_Pad_Master.m_PadShape; m_CurrentPad->m_Attribut = g_Pad_Master.m_Attribut; if( m_CurrentPad->m_Pos != g_Pad_Master.m_Pos ) @@ -634,15 +625,13 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) Module->Set_Rectangle_Encadrement(); m_CurrentPad->DisplayInfo( m_Parent ); - if( m_DC ) // redraw the area where the pad was - m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); + // redraw the area where the pad was + m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); m_Parent->GetScreen()->SetModify(); } EndModal(1); - if( m_DC ) - m_Parent->DrawPanel->CursorOn( m_DC ); if( RastnestIsChanged ) // The net ratsnest must be recalculated m_Parent->GetBoard()->m_Status_Pcb = 0; } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index a8f72141f5..d55d53d31f 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -689,7 +689,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_EDIT_PAD: - InstallPadOptionsFrame( (D_PAD*) GetCurItem(), &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) GetCurItem() ); DrawPanel->MouseToCursorSchema(); break; diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index cce8984e79..36331dbc94 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -270,7 +270,7 @@ this file again.")); AuxiliaryToolBar_Update_UI(); // Display the loaded board: - DrawPanel->Refresh( true); + Zoom_Automatique( false ); wxSafeYield(); // Needed if we want to see the board now. // Compile rastnest and displays net info diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 43293f4fc6..21f62e7f0d 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -80,11 +80,7 @@ void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event ) */ void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event ) { - KicadGraphicContext dc( m_Parent->DrawPanel ); - - m_Parent->DrawPanel->CursorOff( &dc ); - m_Parent->InstallPadOptionsFrame( m_CurrentPad, &dc, wxDefaultPosition ); - m_Parent->DrawPanel->CursorOn( &dc ); + m_Parent->InstallPadOptionsFrame( m_CurrentPad ); } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 7fdfe9114f..0e6a2bdcfc 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -401,7 +401,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_PAD_SETTINGS: - InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); + InstallPadOptionsFrame( NULL ); break; case ID_MODEDIT_CHECK: @@ -427,7 +427,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) else { SetToolID( id, wxCURSOR_ARROW, _( "Pad Settings" ) ); - InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); + InstallPadOptionsFrame( NULL ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); } break; @@ -491,8 +491,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_EDIT_PAD: { - InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem(), - &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() ); DrawPanel->MouseToCursorSchema(); } break; @@ -626,7 +625,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) if( item->Type() != TYPE_PAD ) item = NULL; } - InstallPadOptionsFrame( (D_PAD*) item, &dc, pos ); + InstallPadOptionsFrame( (D_PAD*) item ); } break; diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 0374ae11df..8d7a9d3073 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -400,7 +400,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) switch( DrawStruct->Type() ) { case TYPE_PAD: - InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); + InstallPadOptionsFrame( (D_PAD*) DrawStruct ); DrawPanel->MouseToCursorSchema(); break; @@ -409,7 +409,6 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) DrawStruct ); int ret = dialog.ShowModal(); GetScreen()->GetCurItem()->m_Flags = 0; - GetScreen()->GetCurItem()->m_Flags = 0; DrawPanel->MouseToCursorSchema(); if( ret > 0 ) DrawPanel->Refresh(); diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 23ab564e0a..445a2c79f1 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -426,7 +426,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) break; case TYPE_PAD: - InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); + InstallPadOptionsFrame( (D_PAD*) DrawStruct ); DrawPanel->MouseToCursorSchema(); break; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 9ea6625033..c787485470 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -215,6 +215,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, { m_FrameName = wxT( "PcbFrame" ); m_Draw_Sheet_Ref = true; // true to display sheet references + m_Draw_Axis = false; // true to display X and Y axis m_Draw_Auxiliary_Axis = true; m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 52ad64a0b9..f0386fa49a 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -30,8 +30,6 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) int id = event.GetId(); wxPoint pos; - KicadGraphicContext dc( DrawPanel ); - wxFileName fn; pos = GetPosition(); @@ -61,17 +59,17 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event ) case ID_OPTIONS_SETUP: { - Dialog_GeneralOptions dlg( this, &dc ); + Dialog_GeneralOptions dlg( this ); dlg.ShowModal(); } break; case ID_PCB_DRAWINGS_WIDTHS_SETUP: - InstallPcbOptionsFrame( pos, &dc, id ); + InstallPcbOptionsFrame( id ); break; case ID_PCB_PAD_SETUP: - InstallPadOptionsFrame( NULL, NULL, pos ); + InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: diff --git a/pcbnew/tool_onrightclick.cpp b/pcbnew/tool_onrightclick.cpp index 25811ec2d7..22990520f0 100644 --- a/pcbnew/tool_onrightclick.cpp +++ b/pcbnew/tool_onrightclick.cpp @@ -38,7 +38,7 @@ void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event ) case ID_PCB_ADD_LINE_BUTT: case ID_PCB_COTATION_BUTT: case ID_PCB_ADD_TEXT_BUTT: - InstallPcbOptionsFrame( pos, NULL, ID_PCB_DRAWINGS_WIDTHS_SETUP ); + InstallPcbOptionsFrame( ID_PCB_DRAWINGS_WIDTHS_SETUP ); break; default: @@ -59,7 +59,7 @@ void WinEDA_ModuleEditFrame::ToolOnRightClick( wxCommandEvent& event ) switch( id ) { case ID_MODEDIT_ADD_PAD: - InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); + InstallPadOptionsFrame( NULL ); break; case ID_PCB_CIRCLE_BUTT: