eeschema: Fix slow redraw on net highlighting (by redrawing only modified items)
Fixes: lp:1806197 https://bugs.launchpad.net/kicad/+bug/1806197
This commit is contained in:
parent
4f4f03a98a
commit
58036382c1
|
@ -81,10 +81,17 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
m_SelectedNetName = FROM_UTF8( text );
|
||||
|
||||
SetStatusText( _( "Selected net: " ) + m_SelectedNetName );
|
||||
SetCurrentSheetHighlightFlags();
|
||||
// Be sure hightlight change will be redrawn in any case
|
||||
GetGalCanvas()->GetView()->RecacheAllItems();
|
||||
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
std::vector<EDA_ITEM*> itemsToRedraw;
|
||||
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
||||
|
||||
// Be sure hightlight change will be redrawn
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
|
||||
for( auto item : itemsToRedraw )
|
||||
view->Update( (KIGFX::VIEW_ITEM*)item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
||||
|
||||
//view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|||
}
|
||||
|
||||
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
||||
SetCurrentSheetHighlightFlags();
|
||||
SetCurrentSheetHighlightFlags( nullptr );
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
|
|
@ -36,9 +36,11 @@
|
|||
|
||||
#include <netlist_object.h>
|
||||
|
||||
// List of items having the highlight option modified, therefore need to be redrawn
|
||||
|
||||
bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
||||
{
|
||||
std::vector<EDA_ITEM*> itemsToRedraw;
|
||||
m_SelectedNetName = "";
|
||||
bool buildNetlistOk = false;
|
||||
|
||||
|
@ -69,28 +71,42 @@ bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
|||
|
||||
SendCrossProbeNetName( m_SelectedNetName );
|
||||
SetStatusText( "selected net: " + m_SelectedNetName );
|
||||
SetCurrentSheetHighlightFlags();
|
||||
// Be sure hightlight change will be redrawn in any case
|
||||
GetGalCanvas()->GetView()->RecacheAllItems();
|
||||
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
||||
|
||||
// Be sure hightlight change will be redrawn
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
|
||||
for( auto item : itemsToRedraw )
|
||||
view->Update( (KIGFX::VIEW_ITEM*)item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
|
||||
|
||||
//view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
GetGalCanvas()->Refresh();
|
||||
return buildNetlistOk;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
||||
bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList )
|
||||
{
|
||||
SCH_SCREEN* screen = m_CurrentSheet->LastScreen();
|
||||
|
||||
// Disable highlight flag on all items in the current screen
|
||||
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
||||
{
|
||||
if( ptr->GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( ptr );
|
||||
|
||||
ptr->SetState( BRIGHTENED, false );
|
||||
|
||||
|
||||
if( ptr->Type() == SCH_SHEET_T )
|
||||
{
|
||||
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
||||
{
|
||||
if( ptr->GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( &pin );
|
||||
|
||||
pin.SetState( BRIGHTENED, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +127,9 @@ bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
|||
{
|
||||
obj1->m_Comp->SetState( BRIGHTENED, true );
|
||||
|
||||
if( aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( obj1->m_Comp );
|
||||
|
||||
//if a bus is associated with this net highlight it as well
|
||||
if( obj1->m_BusNetCode )
|
||||
{
|
||||
|
@ -118,7 +137,12 @@ bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
|||
{
|
||||
if( obj2 && obj2->m_Comp && obj2->m_SheetPath == *m_CurrentSheet &&
|
||||
obj1->m_BusNetCode == obj2->m_BusNetCode )
|
||||
{
|
||||
if( aItemsToRedrawList )
|
||||
aItemsToRedrawList->push_back( obj2->m_Comp );
|
||||
|
||||
obj2->m_Comp->SetState( BRIGHTENED, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,10 +647,13 @@ public:
|
|||
* Set or reset the BRIGHTENED of connected objects inside the current sheet,
|
||||
* according to the highlighted net name.
|
||||
*
|
||||
* @param aItemsToRedrawList is the list of modified items (flag BRIGHTENED modified)
|
||||
* that must be redrawn.
|
||||
* Can be NULL
|
||||
* @return true if the flags are correctly set, and false if something goes wrong
|
||||
* (duplicate sheet names)
|
||||
*/
|
||||
bool SetCurrentSheetHighlightFlags();
|
||||
bool SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList );
|
||||
|
||||
/**
|
||||
* @return a filename that can be used in plot and print functions
|
||||
|
|
Loading…
Reference in New Issue