code cleaning

This commit is contained in:
charras 2009-12-19 19:24:49 +00:00
parent 96849d5a11
commit c2ea4a0aff
17 changed files with 47 additions and 87 deletions

View File

@ -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. /* Recalculate the size of toolbars and display panel.
*/ */

View File

@ -27,7 +27,8 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
{ {
PutOnGrid( &(GetBaseScreen()->m_Curseur) ); PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars(); AdjustScrollBars();
ReDrawPanel(); KicadGraphicContext dc( DrawPanel );
DrawPanel->ReDraw( &dc );
/* Move the mouse cursor to the on grid graphic cursor position */ /* Move the mouse cursor to the on grid graphic cursor position */
if( ToMouse == TRUE ) 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 ) void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor )
{ {
if( GetBaseScreen()->SetZoom( BestZoom() ) ) GetBaseScreen()->SetZoom( BestZoom() ); // Set the best zoom
Recadre_Trace( move_mouse_cursor ); 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 ) void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
{ {
if( DrawPanel == NULL ) if( DrawPanel == NULL )
{ return;
wxLogDebug( wxT( "%s, %d: DrawPanel object is undefined ." ),
__TFILE__, __LINE__ );
return;
}
int i; int i;
int id = event.GetId(); int id = event.GetId();
@ -131,7 +129,10 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
case ID_ZOOM_REDRAW: case ID_ZOOM_REDRAW:
// DrawPanel->Refresh(); usually good, // DrawPanel->Refresh(); usually good,
// but does not work under linux, when called from here (wxGTK bug ?) // but does not work under linux, when called from here (wxGTK bug ?)
ReDrawPanel(); {
KicadGraphicContext dc( DrawPanel );
DrawPanel->ReDraw( &dc );
}
break; break;
case ID_POPUP_ZOOM_CENTER: case ID_POPUP_ZOOM_CENTER:
@ -139,12 +140,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
break; break;
case ID_ZOOM_PAGE: case ID_ZOOM_PAGE:
// With Zoom_Automatique(), the "Zoom Auto" button (and hotkey) Zoom_Automatique( false );
// 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 );
break; break;
case ID_POPUP_ZOOM_SELECT: case ID_POPUP_ZOOM_SELECT:

View File

@ -236,9 +236,7 @@ public:
wxDC* DC ); wxDC* DC );
TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC ); TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC );
void InstallPadOptionsFrame( D_PAD* pad, void InstallPadOptionsFrame( D_PAD* pad );
wxDC* DC,
const wxPoint& pos );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod,
wxDC* DC ); wxDC* DC );

View File

@ -298,9 +298,7 @@ public:
void SetToolbars(); void SetToolbars();
void Process_Settings( wxCommandEvent& event ); void Process_Settings( wxCommandEvent& event );
void InstallPcbOptionsFrame( const wxPoint& pos, void InstallPcbOptionsFrame( int id );
wxDC* DC,
int id );
void InstallDisplayOptionsDialog( wxCommandEvent& aEvent ); void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); void InstallPcbGlobalDeleteFrame( const wxPoint& pos );

View File

@ -273,7 +273,6 @@ public:
void SVG_Print( wxCommandEvent& event ); void SVG_Print( wxCommandEvent& event );
void OnActivate( wxActivateEvent& event ); void OnActivate( wxActivateEvent& event );
void ReDrawPanel();
void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ); void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width );
void PlotWorkSheet( PLOTTER *plotter, BASE_SCREEN* screen ); void PlotWorkSheet( PLOTTER *plotter, BASE_SCREEN* screen );

View File

@ -19,12 +19,10 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent, Dialog_GeneralOptions::Dialog_GeneralOptions( WinEDA_PcbFrame* parent ) :
wxDC* DC ) :
DialogGeneralOptionsBoardEditor_base( parent ) DialogGeneralOptionsBoardEditor_base( parent )
{ {
m_Parent = parent; m_Parent = parent;
m_DC = DC;
init(); init();
} }
@ -101,8 +99,8 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() ) if( g_Show_Ratsnest != m_ShowGlobalRatsnest->GetValue() )
{ {
g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue(); g_Show_Ratsnest = m_ShowGlobalRatsnest->GetValue();
m_Parent->Ratsnest_On_Off( m_DC ); m_Parent->Ratsnest_On_Off( NULL );
m_Parent->RedrawActiveWindow( m_DC, true ); m_Parent->DrawPanel->Refresh( );
} }
g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue();
g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue();
@ -121,8 +119,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
#include "dialog_graphic_items_options.cpp" #include "dialog_graphic_items_options.cpp"
void WinEDA_PcbFrame::InstallPcbOptionsFrame( const wxPoint& pos, void WinEDA_PcbFrame::InstallPcbOptionsFrame( int id )
wxDC* DC, int id )
{ {
switch( id ) switch( id )
{ {

View File

@ -9,12 +9,11 @@ class Dialog_GeneralOptions : public DialogGeneralOptionsBoardEditor_base
{ {
private: private:
WinEDA_PcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
wxDC* m_DC;
void init(); void init();
public: public:
Dialog_GeneralOptions( WinEDA_PcbFrame* parent, wxDC* DC ); Dialog_GeneralOptions( WinEDA_PcbFrame* parent );
~Dialog_GeneralOptions() {}; ~Dialog_GeneralOptions() {};
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );

View File

@ -55,11 +55,10 @@ class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
{ {
public: public:
WinEDA_BasePcbFrame* m_Parent; WinEDA_BasePcbFrame* m_Parent;
wxDC* m_DC;
D_PAD* m_CurrentPad; D_PAD* m_CurrentPad;
public: public:
DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad, wxDC* DC ); DIALOG_PAD_PROPERTIES( WinEDA_BasePcbFrame* parent, D_PAD* Pad );
void InitDialog( ); void InitDialog( );
void OnPadShapeSelection( wxCommandEvent& event ); void OnPadShapeSelection( wxCommandEvent& event );
void OnDrillShapeSelected( 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 ) DIALOG_PAD_PROPERTIES_BASE( parent )
/*******************************************************************************************/ /*******************************************************************************************/
{ {
m_Parent = parent; m_Parent = parent;
m_DC = DC;
m_CurrentPad = Pad; m_CurrentPad = Pad;
if( m_CurrentPad ) 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(); dlg.ShowModal();
} }
@ -418,9 +416,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
int internalUnits = m_Parent->m_InternalUnits; int internalUnits = m_Parent->m_InternalUnits;
wxString msg; wxString msg;
if( m_DC )
m_Parent->DrawPanel->CursorOff( m_DC );
g_Pad_Master.m_Attribut = CodeType[m_PadType->GetSelection()]; g_Pad_Master.m_Attribut = CodeType[m_PadType->GetSelection()];
g_Pad_Master.m_PadShape = CodeShape[m_PadShape->GetSelection()]; g_Pad_Master.m_PadShape = CodeShape[m_PadShape->GetSelection()];
@ -489,11 +484,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
} }
if( error ) if( error )
{ return;
if( m_DC )
m_Parent->DrawPanel->CursorOn( m_DC );
return;
}
PadLayerMask = 0; PadLayerMask = 0;
if( m_PadLayerCu->GetValue() ) if( m_PadLayerCu->GetValue() )
@ -533,12 +524,12 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_Parent->SaveCopyInUndoList( Module, UR_CHANGED ); m_Parent->SaveCopyInUndoList( Module, UR_CHANGED );
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
if( m_DC ) // redraw the area where the pad was, without pad (delete pad on screen) // redraw the area where the pad was, without pad (delete pad on screen)
{ m_CurrentPad->m_Flags |= DO_NOT_DRAW;
m_CurrentPad->m_Flags |= DO_NOT_DRAW; m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() );
m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); m_CurrentPad->m_Flags &= ~DO_NOT_DRAW;
m_CurrentPad->m_Flags &= ~DO_NOT_DRAW;
} // Update values
m_CurrentPad->m_PadShape = g_Pad_Master.m_PadShape; m_CurrentPad->m_PadShape = g_Pad_Master.m_PadShape;
m_CurrentPad->m_Attribut = g_Pad_Master.m_Attribut; m_CurrentPad->m_Attribut = g_Pad_Master.m_Attribut;
if( m_CurrentPad->m_Pos != g_Pad_Master.m_Pos ) 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(); Module->Set_Rectangle_Encadrement();
m_CurrentPad->DisplayInfo( m_Parent ); m_CurrentPad->DisplayInfo( m_Parent );
if( m_DC ) // redraw the area where the pad was // redraw the area where the pad was
m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() ); m_Parent->DrawPanel->PostDirtyRect( m_CurrentPad->GetBoundingBox() );
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
} }
EndModal(1); EndModal(1);
if( m_DC )
m_Parent->DrawPanel->CursorOn( m_DC );
if( RastnestIsChanged ) // The net ratsnest must be recalculated if( RastnestIsChanged ) // The net ratsnest must be recalculated
m_Parent->GetBoard()->m_Status_Pcb = 0; m_Parent->GetBoard()->m_Status_Pcb = 0;
} }

View File

@ -689,7 +689,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_PAD: case ID_POPUP_PCB_EDIT_PAD:
InstallPadOptionsFrame( (D_PAD*) GetCurItem(), &dc, pos ); InstallPadOptionsFrame( (D_PAD*) GetCurItem() );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;

View File

@ -270,7 +270,7 @@ this file again."));
AuxiliaryToolBar_Update_UI(); AuxiliaryToolBar_Update_UI();
// Display the loaded board: // Display the loaded board:
DrawPanel->Refresh( true); Zoom_Automatique( false );
wxSafeYield(); // Needed if we want to see the board now. wxSafeYield(); // Needed if we want to see the board now.
// Compile rastnest and displays net info // Compile rastnest and displays net info

View File

@ -80,11 +80,7 @@ void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event )
*/ */
void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event ) void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event )
{ {
KicadGraphicContext dc( m_Parent->DrawPanel ); m_Parent->InstallPadOptionsFrame( m_CurrentPad );
m_Parent->DrawPanel->CursorOff( &dc );
m_Parent->InstallPadOptionsFrame( m_CurrentPad, &dc, wxDefaultPosition );
m_Parent->DrawPanel->CursorOn( &dc );
} }

View File

@ -401,7 +401,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_PAD_SETTINGS: case ID_MODEDIT_PAD_SETTINGS:
InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); InstallPadOptionsFrame( NULL );
break; break;
case ID_MODEDIT_CHECK: case ID_MODEDIT_CHECK:
@ -427,7 +427,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
else else
{ {
SetToolID( id, wxCURSOR_ARROW, _( "Pad Settings" ) ); SetToolID( id, wxCURSOR_ARROW, _( "Pad Settings" ) );
InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); InstallPadOptionsFrame( NULL );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
} }
break; break;
@ -491,8 +491,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_PAD: case ID_POPUP_PCB_EDIT_PAD:
{ {
InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem(), InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() );
&dc, pos );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
break; break;
@ -626,7 +625,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( item->Type() != TYPE_PAD ) if( item->Type() != TYPE_PAD )
item = NULL; item = NULL;
} }
InstallPadOptionsFrame( (D_PAD*) item, &dc, pos ); InstallPadOptionsFrame( (D_PAD*) item );
} }
break; break;

View File

@ -400,7 +400,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPE_PAD: case TYPE_PAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); InstallPadOptionsFrame( (D_PAD*) DrawStruct );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
@ -409,7 +409,6 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) DrawStruct ); DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) DrawStruct );
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0; GetScreen()->GetCurItem()->m_Flags = 0;
GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( ret > 0 ) if( ret > 0 )
DrawPanel->Refresh(); DrawPanel->Refresh();

View File

@ -426,7 +426,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case TYPE_PAD: case TYPE_PAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct, DC, pos ); InstallPadOptionsFrame( (D_PAD*) DrawStruct );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;

View File

@ -215,6 +215,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
{ {
m_FrameName = wxT( "PcbFrame" ); m_FrameName = wxT( "PcbFrame" );
m_Draw_Sheet_Ref = true; // true to display sheet references 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_Draw_Auxiliary_Axis = true;
m_SelTrackWidthBox = NULL; m_SelTrackWidthBox = NULL;
m_SelViaSizeBox = NULL; m_SelViaSizeBox = NULL;

View File

@ -30,8 +30,6 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
KicadGraphicContext dc( DrawPanel );
wxFileName fn; wxFileName fn;
pos = GetPosition(); pos = GetPosition();
@ -61,17 +59,17 @@ void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
case ID_OPTIONS_SETUP: case ID_OPTIONS_SETUP:
{ {
Dialog_GeneralOptions dlg( this, &dc ); Dialog_GeneralOptions dlg( this );
dlg.ShowModal(); dlg.ShowModal();
} }
break; break;
case ID_PCB_DRAWINGS_WIDTHS_SETUP: case ID_PCB_DRAWINGS_WIDTHS_SETUP:
InstallPcbOptionsFrame( pos, &dc, id ); InstallPcbOptionsFrame( id );
break; break;
case ID_PCB_PAD_SETUP: case ID_PCB_PAD_SETUP:
InstallPadOptionsFrame( NULL, NULL, pos ); InstallPadOptionsFrame( NULL );
break; break;
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:

View File

@ -38,7 +38,7 @@ void WinEDA_PcbFrame::ToolOnRightClick( wxCommandEvent& event )
case ID_PCB_ADD_LINE_BUTT: case ID_PCB_ADD_LINE_BUTT:
case ID_PCB_COTATION_BUTT: case ID_PCB_COTATION_BUTT:
case ID_PCB_ADD_TEXT_BUTT: case ID_PCB_ADD_TEXT_BUTT:
InstallPcbOptionsFrame( pos, NULL, ID_PCB_DRAWINGS_WIDTHS_SETUP ); InstallPcbOptionsFrame( ID_PCB_DRAWINGS_WIDTHS_SETUP );
break; break;
default: default:
@ -59,7 +59,7 @@ void WinEDA_ModuleEditFrame::ToolOnRightClick( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_MODEDIT_ADD_PAD: case ID_MODEDIT_ADD_PAD:
InstallPadOptionsFrame( NULL, NULL, wxPoint( -1, -1 ) ); InstallPadOptionsFrame( NULL );
break; break;
case ID_PCB_CIRCLE_BUTT: case ID_PCB_CIRCLE_BUTT: