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 );
|
m_SelectedNetName = FROM_UTF8( text );
|
||||||
|
|
||||||
SetStatusText( _( "Selected net: " ) + m_SelectedNetName );
|
SetStatusText( _( "Selected net: " ) + m_SelectedNetName );
|
||||||
SetCurrentSheetHighlightFlags();
|
std::vector<EDA_ITEM*> itemsToRedraw;
|
||||||
// Be sure hightlight change will be redrawn in any case
|
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
||||||
GetGalCanvas()->GetView()->RecacheAllItems();
|
|
||||||
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
// 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;
|
return;
|
||||||
|
|
|
@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
||||||
SetCurrentSheetHighlightFlags();
|
SetCurrentSheetHighlightFlags( nullptr );
|
||||||
|
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,11 @@
|
||||||
|
|
||||||
#include <netlist_object.h>
|
#include <netlist_object.h>
|
||||||
|
|
||||||
|
// List of items having the highlight option modified, therefore need to be redrawn
|
||||||
|
|
||||||
bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
||||||
{
|
{
|
||||||
|
std::vector<EDA_ITEM*> itemsToRedraw;
|
||||||
m_SelectedNetName = "";
|
m_SelectedNetName = "";
|
||||||
bool buildNetlistOk = false;
|
bool buildNetlistOk = false;
|
||||||
|
|
||||||
|
@ -69,30 +71,44 @@ bool SCH_EDIT_FRAME::HighlightConnectionAtPosition( wxPoint aPosition )
|
||||||
|
|
||||||
SendCrossProbeNetName( m_SelectedNetName );
|
SendCrossProbeNetName( m_SelectedNetName );
|
||||||
SetStatusText( "selected net: " + m_SelectedNetName );
|
SetStatusText( "selected net: " + m_SelectedNetName );
|
||||||
SetCurrentSheetHighlightFlags();
|
SetCurrentSheetHighlightFlags( &itemsToRedraw );
|
||||||
// Be sure hightlight change will be redrawn in any case
|
|
||||||
GetGalCanvas()->GetView()->RecacheAllItems();
|
|
||||||
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
||||||
|
|
||||||
|
// 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;
|
return buildNetlistOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList )
|
||||||
{
|
{
|
||||||
SCH_SCREEN* screen = m_CurrentSheet->LastScreen();
|
SCH_SCREEN* screen = m_CurrentSheet->LastScreen();
|
||||||
|
|
||||||
// Disable highlight flag on all items in the current screen
|
// Disable highlight flag on all items in the current screen
|
||||||
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
for( SCH_ITEM* ptr = screen->GetDrawItems(); ptr; ptr = ptr->Next() )
|
||||||
{
|
{
|
||||||
|
if( ptr->GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||||
|
aItemsToRedrawList->push_back( ptr );
|
||||||
|
|
||||||
ptr->SetState( BRIGHTENED, false );
|
ptr->SetState( BRIGHTENED, false );
|
||||||
|
|
||||||
|
|
||||||
if( ptr->Type() == SCH_SHEET_T )
|
if( ptr->Type() == SCH_SHEET_T )
|
||||||
{
|
{
|
||||||
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( ptr )->GetPins() )
|
||||||
|
{
|
||||||
|
if( ptr->GetState( BRIGHTENED ) && aItemsToRedrawList )
|
||||||
|
aItemsToRedrawList->push_back( &pin );
|
||||||
|
|
||||||
pin.SetState( BRIGHTENED, false );
|
pin.SetState( BRIGHTENED, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( m_SelectedNetName == "" )
|
if( m_SelectedNetName == "" )
|
||||||
return true;
|
return true;
|
||||||
|
@ -111,6 +127,9 @@ bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
||||||
{
|
{
|
||||||
obj1->m_Comp->SetState( BRIGHTENED, true );
|
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 a bus is associated with this net highlight it as well
|
||||||
if( obj1->m_BusNetCode )
|
if( obj1->m_BusNetCode )
|
||||||
{
|
{
|
||||||
|
@ -118,11 +137,16 @@ bool SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags()
|
||||||
{
|
{
|
||||||
if( obj2 && obj2->m_Comp && obj2->m_SheetPath == *m_CurrentSheet &&
|
if( obj2 && obj2->m_Comp && obj2->m_SheetPath == *m_CurrentSheet &&
|
||||||
obj1->m_BusNetCode == obj2->m_BusNetCode )
|
obj1->m_BusNetCode == obj2->m_BusNetCode )
|
||||||
|
{
|
||||||
|
if( aItemsToRedrawList )
|
||||||
|
aItemsToRedrawList->push_back( obj2->m_Comp );
|
||||||
|
|
||||||
obj2->m_Comp->SetState( BRIGHTENED, true );
|
obj2->m_Comp->SetState( BRIGHTENED, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -647,10 +647,13 @@ public:
|
||||||
* Set or reset the BRIGHTENED of connected objects inside the current sheet,
|
* Set or reset the BRIGHTENED of connected objects inside the current sheet,
|
||||||
* according to the highlighted net name.
|
* 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
|
* @return true if the flags are correctly set, and false if something goes wrong
|
||||||
* (duplicate sheet names)
|
* (duplicate sheet names)
|
||||||
*/
|
*/
|
||||||
bool SetCurrentSheetHighlightFlags();
|
bool SetCurrentSheetHighlightFlags( std::vector<EDA_ITEM*>* aItemsToRedrawList );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a filename that can be used in plot and print functions
|
* @return a filename that can be used in plot and print functions
|
||||||
|
|
Loading…
Reference in New Issue