Correctly refresh the board after action plugin run and maintain
selection
This commit is contained in:
parent
933a5d45e1
commit
7dfa100ff0
|
@ -572,7 +572,8 @@ void TOOL_MANAGER::DeactivateTool()
|
|||
|
||||
void TOOL_MANAGER::ResetTools( TOOL_BASE::RESET_REASON aReason )
|
||||
{
|
||||
DeactivateTool();
|
||||
if( aReason != TOOL_BASE::REDRAW )
|
||||
DeactivateTool();
|
||||
|
||||
for( auto& state : m_toolState )
|
||||
{
|
||||
|
|
|
@ -78,7 +78,8 @@ public:
|
|||
{
|
||||
RUN, ///< Tool is invoked after being inactive
|
||||
MODEL_RELOAD, ///< Model changes (required full reload)
|
||||
GAL_SWITCH ///< Rendering engine changes
|
||||
GAL_SWITCH, ///< Rendering engine changes
|
||||
REDRAW ///< Full drawing refresh
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,6 +107,11 @@ public:
|
|||
|
||||
void HardRedraw() override;
|
||||
|
||||
/**
|
||||
* Rebuilds board connectivity, refreshes canvas.
|
||||
*/
|
||||
void RebuildAndRefresh();
|
||||
|
||||
/**
|
||||
* Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER
|
||||
* (currently 4242).
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <bitmaps.h>
|
||||
#include <board.h>
|
||||
#include <board_commit.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <footprint.h>
|
||||
#include <pcb_track.h>
|
||||
#include <zone.h>
|
||||
|
@ -35,6 +36,8 @@
|
|||
#include <pcbnew_settings.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <tool/action_toolbar.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <pcb_painter.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include "../../scripting/python_scripting.h"
|
||||
|
||||
|
@ -372,7 +375,32 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
|
|||
|
||||
// Apply changes, UndoList already handled
|
||||
commit.Push( _( "Apply action script" ), SKIP_UNDO | SKIP_SET_DIRTY );
|
||||
ActivateGalCanvas();
|
||||
|
||||
RebuildAndRefresh();
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::RebuildAndRefresh()
|
||||
{
|
||||
m_pcb->BuildConnectivity();
|
||||
|
||||
PCB_DRAW_PANEL_GAL* canvas = GetCanvas();
|
||||
|
||||
canvas->GetView()->Clear();
|
||||
canvas->GetView()->InitPreview();
|
||||
canvas->GetGAL()->SetGridOrigin( VECTOR2D( m_pcb->GetDesignSettings().GetGridOrigin() ) );
|
||||
canvas->DisplayBoard( m_pcb );
|
||||
|
||||
// allow tools to re-add their view items (selection previews, grids, etc.)
|
||||
if( m_toolManager )
|
||||
m_toolManager->ResetTools( TOOL_BASE::REDRAW );
|
||||
|
||||
// reload the drawing-sheet
|
||||
SetPageSettings( m_pcb->GetPageSettings() );
|
||||
|
||||
canvas->SyncLayersVisibility( m_pcb );
|
||||
|
||||
canvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "pcbnew_scripting_helpers.h"
|
||||
|
||||
#include <tool/tool_manager.h>
|
||||
#include <action_plugin.h>
|
||||
#include <board.h>
|
||||
#include <board_design_settings.h>
|
||||
|
@ -398,27 +397,7 @@ void Refresh()
|
|||
{
|
||||
if( s_PcbEditFrame )
|
||||
{
|
||||
TOOL_MANAGER* toolMgr = s_PcbEditFrame->GetToolManager();
|
||||
BOARD* board = s_PcbEditFrame->GetBoard();
|
||||
PCB_DRAW_PANEL_GAL* canvas = s_PcbEditFrame->GetCanvas();
|
||||
|
||||
canvas->SyncLayersVisibility( board );
|
||||
|
||||
canvas->GetView()->Clear();
|
||||
canvas->GetView()->InitPreview();
|
||||
canvas->GetGAL()->SetGridOrigin( VECTOR2D( board->GetDesignSettings().GetGridOrigin() ) );
|
||||
canvas->DisplayBoard( board );
|
||||
|
||||
// allow tools to re-add their view items (selection previews, grids, etc.)
|
||||
if( toolMgr )
|
||||
toolMgr->ResetTools( TOOL_BASE::GAL_SWITCH );
|
||||
|
||||
// reload the drawing-sheet
|
||||
s_PcbEditFrame->SetPageSettings( board->GetPageSettings() );
|
||||
|
||||
board->BuildConnectivity();
|
||||
|
||||
canvas->Refresh();
|
||||
s_PcbEditFrame->RebuildAndRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void BOARD_EDITOR_CONTROL::Reset( RESET_REASON aReason )
|
|||
{
|
||||
m_frame = getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
|
||||
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
|
||||
{
|
||||
m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
|
||||
getView()->Remove( m_placeOrigin.get() );
|
||||
|
|
|
@ -89,7 +89,7 @@ void PCB_CONTROL::Reset( RESET_REASON aReason )
|
|||
{
|
||||
m_frame = getEditFrame<PCB_BASE_FRAME>();
|
||||
|
||||
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
|
||||
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
|
||||
{
|
||||
m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
|
||||
m_gridOrigin->SetColor( m_frame->GetGridColor() );
|
||||
|
|
|
@ -224,7 +224,7 @@ void PCB_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
|||
|
||||
getView()->GetPainter()->GetSettings()->SetHighlight( false );
|
||||
}
|
||||
else
|
||||
else if ( aReason != TOOL_BASE::REDRAW )
|
||||
{
|
||||
// Restore previous properties of selected items and remove them from containers
|
||||
ClearSelection( true );
|
||||
|
|
Loading…
Reference in New Issue