Fix incorrect refresh of User Interface after running an action plugin, and add comments
This commit is contained in:
parent
db3491f382
commit
a557838c61
|
@ -48,7 +48,7 @@ class text_by_date( pcbnew.ActionPlugin ):
|
|||
|
||||
def Run( self ):
|
||||
pcb = pcbnew.GetBoard()
|
||||
for draw in pcb.m_Drawings:
|
||||
for draw in pcb.GetDrawings():
|
||||
if draw.GetClass() == 'PTEXT':
|
||||
txt = re.sub( "\$date\$ [0-9]{4}-[0-9]{2}-[0-9]{2}",
|
||||
"$date$", draw.GetText() )
|
||||
|
|
|
@ -269,6 +269,12 @@ public:
|
|||
*/
|
||||
void PythonPluginsReload();
|
||||
|
||||
/**
|
||||
* Update the layer manager and other widgets from the board setup
|
||||
* (layer and items visibility, colors ...)
|
||||
*/
|
||||
void UpdateUserInterface();
|
||||
|
||||
/**
|
||||
* Function GetAutoSaveFilePrefix
|
||||
*
|
||||
|
|
|
@ -724,8 +724,7 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
|
|||
}
|
||||
|
||||
// Re-create the layer manager to allow arbitrary colors when GAL is enabled
|
||||
ReFillLayerWidget();
|
||||
m_Layers->ReFillRender();
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1048,6 +1047,32 @@ void PCB_EDIT_FRAME::UpdateTitle()
|
|||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::UpdateUserInterface()
|
||||
{
|
||||
// Update the layer manager and other widgets from the board setup
|
||||
// (layer and items visibility, colors ...)
|
||||
|
||||
// Rebuild list of nets (full ratsnest rebuild)
|
||||
Compile_Ratsnest( NULL, true );
|
||||
GetBoard()->BuildConnectivity();
|
||||
|
||||
// Update info shown by the horizontal toolbars
|
||||
ReCreateLayerBox();
|
||||
|
||||
// Update the layer manager
|
||||
m_Layers->Freeze();
|
||||
ReFillLayerWidget();
|
||||
m_Layers->ReFillRender();
|
||||
|
||||
// upate the layer widget to match board visibility states, both layers and render columns.
|
||||
syncLayerVisibilities();
|
||||
syncLayerWidgetLayer();
|
||||
syncRenderStates();
|
||||
|
||||
m_Layers->Thaw();
|
||||
}
|
||||
|
||||
|
||||
#if defined( KICAD_SCRIPTING_WXPYTHON )
|
||||
|
||||
void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent )
|
||||
|
|
|
@ -368,6 +368,7 @@ void PCB_EDIT_FRAME::OnActionPlugin( wxCommandEvent& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
UpdateUserInterface();
|
||||
GetScreen()->SetModify();
|
||||
Refresh();
|
||||
}
|
||||
|
|
|
@ -40,20 +40,20 @@
|
|||
#include <macros.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static PCB_EDIT_FRAME* PcbEditFrame = NULL;
|
||||
static PCB_EDIT_FRAME* s_PcbEditFrame = NULL;
|
||||
|
||||
BOARD* GetBoard()
|
||||
{
|
||||
if( PcbEditFrame )
|
||||
return PcbEditFrame->GetBoard();
|
||||
if( s_PcbEditFrame )
|
||||
return s_PcbEditFrame->GetBoard();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPCBEdaFrame )
|
||||
void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPcbEditFrame )
|
||||
{
|
||||
PcbEditFrame = aPCBEdaFrame;
|
||||
s_PcbEditFrame = aPcbEditFrame;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,13 +101,29 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard )
|
|||
|
||||
void Refresh()
|
||||
{
|
||||
// first argument is erase background, second is a wxRect
|
||||
PcbEditFrame->GetCanvas()->Refresh( true, NULL );
|
||||
if( s_PcbEditFrame )
|
||||
{
|
||||
if( s_PcbEditFrame->IsGalCanvasActive() )
|
||||
s_PcbEditFrame->GetGalCanvas()->Refresh();
|
||||
else
|
||||
// first argument is erase background, second is a wxRect that
|
||||
// defines a reftresh area (all canvas if null)
|
||||
s_PcbEditFrame->GetCanvas()->Refresh( true, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WindowZoom( int xl, int yl, int width, int height )
|
||||
{
|
||||
EDA_RECT Rect( wxPoint( xl, yl ), wxSize( width, height )) ;
|
||||
PcbEditFrame->Window_Zoom( Rect );
|
||||
|
||||
if( s_PcbEditFrame )
|
||||
s_PcbEditFrame->Window_Zoom( Rect );
|
||||
}
|
||||
|
||||
|
||||
void UpdateUserInterface()
|
||||
{
|
||||
if( s_PcbEditFrame )
|
||||
s_PcbEditFrame->UpdateUserInterface();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,24 @@ BOARD* LoadBoard( wxString& aFileName );
|
|||
// so no option to choose the file format.
|
||||
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
|
||||
|
||||
/**
|
||||
* Update the board display after modifying it bu a python script
|
||||
* (note: it is automatically called by action plugins, after running the plugin,
|
||||
* so call this function is usually not needed inside action plugins
|
||||
*
|
||||
* Could be deprecated because modifying a board (especially deleting items) outside
|
||||
* a action plugin can crash Pcbnew.
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
void WindowZoom( int xl, int yl, int width, int height );
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Update the layer manager and other widgets from the board setup
|
||||
* (layer and items visibility, colors ...)
|
||||
* (note: it is automatically called by action plugins, after running the plugin,
|
||||
* so call this function is usually not needed inside action plugins
|
||||
*/
|
||||
void UpdateUserInterface();
|
||||
|
||||
#endif // __PCBNEW_SCRIPTING_HELPERS_H
|
||||
|
|
Loading…
Reference in New Issue