diff --git a/pcbnew/initpcb.cpp b/pcbnew/initpcb.cpp index 5470c453e8..7092822fb4 100644 --- a/pcbnew/initpcb.cpp +++ b/pcbnew/initpcb.cpp @@ -102,17 +102,18 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) return false; } - // Clear undo and redo lists + // Clear undo and redo lists because we want a full deletion GetScreen()->ClearUndoRedoList(); + GetScreen()->ClrModify(); - // Delete the current footprint - GetBoard()->m_Modules.DeleteAll(); - - // init pointeurs et variables - GetBoard()->SetFileName( wxEmptyString ); + BOARD* board = new BOARD; + SetBoard( board ); SetCurItem( NULL ); + // clear filename, to avoid overwriting an old file + GetBoard()->SetFileName( wxEmptyString ); + GetScreen()->InitDataPoints( GetPageSizeIU() ); Zoom_Automatique( false ); diff --git a/pcbnew/modeditoptions.cpp b/pcbnew/modeditoptions.cpp index 02f70e4748..ac06b7f6a6 100644 --- a/pcbnew/modeditoptions.cpp +++ b/pcbnew/modeditoptions.cpp @@ -83,68 +83,68 @@ void FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) PARAM_CFG_ARRAY& FOOTPRINT_EDIT_FRAME::GetConfigurationSettings() { - DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); + DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) GetDisplayOptions(); BOARD_DESIGN_SETTINGS& settings = GetDesignSettings(); - if( m_configSettings.empty() ) - { - // Display options: - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorUnits" ), - (int*)&g_UserUnit, MILLIMETRES ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorDisplayPolarCoords" ), - &displ_opts->m_DisplayPolarCood, false ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorPadDisplayMode" ), - &displ_opts->m_DisplayPadFill, true ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorGraphicLinesDisplayMode" ), - &displ_opts->m_DisplayModEdgeFill, FILLED ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), - &displ_opts->m_DisplayModTextFill, FILLED ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), - &displ_opts->m_DisplayModTextFill, FILLED ) ); - m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorTextsRefDefaultText" ), - &settings.m_RefDefaultText, wxT( "REF**" ) ) ); + // Update everything + m_configSettings.clear(); // boost::ptr_vector destroys the pointers inside - // design settings - m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorGrlineWidth" ), - &settings.m_ModuleSegmentWidth, - Millimeter2iu( DEFAULT_GR_MODULE_THICKNESS ), - Millimeter2iu( 0.01 ), Millimeter2iu( 100.0 ), - NULL, 1/IU_PER_MM ) ); - m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultSizeH" ), - &settings.m_ModuleTextSize.x, - Millimeter2iu( DEFAULT_TEXT_MODULE_SIZE ), - Millimeter2iu( 0.01 ), Millimeter2iu( 100.0 ), - NULL, 1/IU_PER_MM ) ); - m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultSizeV" ), - &settings.m_ModuleTextSize.y, - Millimeter2iu( DEFAULT_TEXT_MODULE_SIZE ), - Millimeter2iu(0.01), Millimeter2iu( 100.0 ), - NULL, 1/IU_PER_MM ) ); - m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultThickness" ), - &settings.m_ModuleTextWidth, - Millimeter2iu( DEFAULT_GR_MODULE_THICKNESS ), - Millimeter2iu( 0.01 ), Millimeter2iu( 20.0 ), - NULL, 1/IU_PER_MM ) ); + // Display options: + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorUnits" ), + (int*)&g_UserUnit, MILLIMETRES ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorDisplayPolarCoords" ), + &displ_opts->m_DisplayPolarCood, false ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorPadDisplayMode" ), + &displ_opts->m_DisplayPadFill, true ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorGraphicLinesDisplayMode" ), + &displ_opts->m_DisplayModEdgeFill, FILLED ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), + &displ_opts->m_DisplayModTextFill, FILLED ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "FpEditorTextsDisplayMode" ), + &displ_opts->m_DisplayModTextFill, FILLED ) ); + m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorTextsRefDefaultText" ), + &settings.m_RefDefaultText, wxT( "REF**" ) ) ); - m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, - wxT( "FpEditorRefDefaultText" ), - &settings.m_RefDefaultText, wxT( "REF**" ) ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, - wxT( "FpEditorRefDefaultVisibility" ), - &settings.m_RefDefaultVisibility, true ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorRefDefaultLayer" ), - &settings.m_RefDefaultlayer, - int( F_SilkS ), int( F_SilkS ), int( F_Fab ) ) ); + // design settings + m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorGrlineWidth" ), + &settings.m_ModuleSegmentWidth, + Millimeter2iu( DEFAULT_GR_MODULE_THICKNESS ), + Millimeter2iu( 0.01 ), Millimeter2iu( 100.0 ), + NULL, 1/IU_PER_MM ) ); + m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultSizeH" ), + &settings.m_ModuleTextSize.x, + Millimeter2iu( DEFAULT_TEXT_MODULE_SIZE ), + Millimeter2iu( 0.01 ), Millimeter2iu( 100.0 ), + NULL, 1/IU_PER_MM ) ); + m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultSizeV" ), + &settings.m_ModuleTextSize.y, + Millimeter2iu( DEFAULT_TEXT_MODULE_SIZE ), + Millimeter2iu(0.01), Millimeter2iu( 100.0 ), + NULL, 1/IU_PER_MM ) ); + m_configSettings.push_back( new PARAM_CFG_INT_WITH_SCALE( true, wxT( "FpEditorTextsDefaultThickness" ), + &settings.m_ModuleTextWidth, + Millimeter2iu( DEFAULT_GR_MODULE_THICKNESS ), + Millimeter2iu( 0.01 ), Millimeter2iu( 20.0 ), + NULL, 1/IU_PER_MM ) ); - m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorValueDefaultText" ), - &settings.m_ValueDefaultText, wxT( "" ) ) ); - m_configSettings.push_back( new PARAM_CFG_BOOL( true, - wxT( "FpEditorValueDefaultVisibility" ), - &settings.m_ValueDefaultVisibility, true ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorValueDefaultLayer" ), - &settings.m_ValueDefaultlayer, - int( F_Fab ), int( F_SilkS ), int( F_Fab ) ) ); - } + m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, + wxT( "FpEditorRefDefaultText" ), + &settings.m_RefDefaultText, wxT( "REF**" ) ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, + wxT( "FpEditorRefDefaultVisibility" ), + &settings.m_RefDefaultVisibility, true ) ); + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorRefDefaultLayer" ), + &settings.m_RefDefaultlayer, + int( F_SilkS ), int( F_SilkS ), int( F_Fab ) ) ); + + m_configSettings.push_back( new PARAM_CFG_WXSTRING( true, wxT( "FpEditorValueDefaultText" ), + &settings.m_ValueDefaultText, wxT( "" ) ) ); + m_configSettings.push_back( new PARAM_CFG_BOOL( true, + wxT( "FpEditorValueDefaultVisibility" ), + &settings.m_ValueDefaultVisibility, true ) ); + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "FpEditorValueDefaultLayer" ), + &settings.m_ValueDefaultlayer, + int( F_Fab ), int( F_SilkS ), int( F_Fab ) ) ); return m_configSettings; } diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index 6ab272ffdb..1987d6510e 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -23,6 +23,9 @@ */ #include +#include +#include +#include void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle ) { @@ -56,3 +59,29 @@ void PCB_BASE_EDIT_FRAME::UseGalCanvas( bool aEnable ) if( !aEnable ) UndoRedoBlock( false ); } + + +void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard ) +{ + bool new_board = ( aBoard != m_Pcb ); + + // It has to be done before the previous board is destroyed by SetBoard() + if( new_board ) + GetGalCanvas()->GetView()->Clear(); + + PCB_BASE_FRAME::SetBoard( aBoard ); + + // update the tool manager with the new board and its view. + if( m_toolManager ) + { + PCB_DRAW_PANEL_GAL* drawPanel = static_cast( GetGalCanvas() ); + + drawPanel->DisplayBoard( aBoard ); + m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(), + drawPanel->GetViewControls(), this ); + + if( new_board ) + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); + } +} + diff --git a/pcbnew/pcb_base_edit_frame.h b/pcbnew/pcb_base_edit_frame.h index bcc869fdcb..7a3574c4a5 100644 --- a/pcbnew/pcb_base_edit_frame.h +++ b/pcbnew/pcb_base_edit_frame.h @@ -92,6 +92,9 @@ public: ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() void UseGalCanvas( bool aEnable ); + ///> @copydoc PCB_BASE_FRAME::SetBoard() + virtual void SetBoard( BOARD* aBoard ); + protected: /// User defined rotation angle (in tenths of a degree). int m_rotationAngle; diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 9038bcf742..6323bb8e53 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -213,10 +213,16 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( const BOARD* aBoard ) m_view->Add( zone ); // Ratsnest - delete m_ratsnest; + if( m_ratsnest ) + { + m_view->Remove( m_ratsnest ); + delete m_ratsnest; + } + m_ratsnest = new KIGFX::RATSNEST_VIEWITEM( aBoard->GetRatsnest() ); m_view->Add( m_ratsnest ); + // Display settings UseColorScheme( aBoard->GetColorsSettings() ); PCB_BASE_FRAME* frame = dynamic_cast( GetParent() ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index ec593616ce..940a5192d7 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -476,29 +476,14 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME() void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard ) { - bool new_board = ( aBoard != m_Pcb ); - - PCB_BASE_FRAME::SetBoard( aBoard ); + PCB_BASE_EDIT_FRAME::SetBoard( aBoard ); if( IsGalCanvasActive() ) { - PCB_DRAW_PANEL_GAL* drawPanel = static_cast( GetGalCanvas() ); - - drawPanel->DisplayBoard( aBoard ); aBoard->GetRatsnest()->Recalculate(); // reload the worksheet SetPageSettings( aBoard->GetPageSettings() ); - - // update the tool manager with the new board and its view. - if( m_toolManager ) - { - m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(), - drawPanel->GetViewControls(), this ); - - if( new_board ) - m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - } } } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 8cbafd0f99..01bdcac71b 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1081,7 +1081,7 @@ void EDIT_TOOL::processPickedList( const PICKED_ITEMS_LIST* aList ) // fall through case UR_MODEDIT: - updItem->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + updItem->ViewUpdate( KIGFX::VIEW_ITEM::ALL ); break; case UR_DELETED: