Fixed footprint editor crash on ref/val text layer change (GAL).

This commit is contained in:
Maciej Suminski 2015-08-15 16:00:34 +02:00
parent a09d6431e4
commit 0cad702fc7
7 changed files with 105 additions and 81 deletions

View File

@ -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 );

View File

@ -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;
}

View File

@ -23,6 +23,9 @@
*/
#include <pcb_base_edit_frame.h>
#include <tool/tool_manager.h>
#include <pcb_draw_panel_gal.h>
#include <class_board.h>
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<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
drawPanel->DisplayBoard( aBoard );
m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(),
drawPanel->GetViewControls(), this );
if( new_board )
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
}
}

View File

@ -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;

View File

@ -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<PCB_BASE_FRAME*>( GetParent() );

View File

@ -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<PCB_DRAW_PANEL_GAL*>( 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 );
}
}
}

View File

@ -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: