Implement GAL refresh for a bunch of operations.

This commit is contained in:
Jeff Young 2018-09-04 17:12:15 +01:00
parent afeebc8944
commit d7178c7833
12 changed files with 51 additions and 69 deletions

View File

@ -35,6 +35,8 @@
#include <base_struct.h>
#include <base_screen.h>
#include <legacy_gal/class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <confirm.h>
#include <block_commande.h>
@ -152,6 +154,16 @@ void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos )
}
void BLOCK_SELECTOR::UpdateItems( EDA_DRAW_PANEL* aPanel )
{
// ugly, but temporary
auto canvas = dynamic_cast<EDA_DRAW_PANEL_GAL*>( aPanel );
for( size_t i = 0; i < m_items.GetCount(); i++ )
canvas->GetView()->Update( m_items.GetPickedItem( i ) );
}
void BLOCK_SELECTOR::ClearItemsList()
{
m_items.ClearItemsList();

View File

@ -244,15 +244,13 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
m_canvas->Refresh();
break;
case BLOCK_DRAG:
case BLOCK_DRAG_ITEM: // Drag from a drag command
case BLOCK_MOVE:
case BLOCK_DUPLICATE:
if( block->GetCommand() == BLOCK_DRAG_ITEM &&
GetScreen()->GetCurItem() != NULL )
if( block->GetCommand() == BLOCK_DRAG_ITEM && GetScreen()->GetCurItem() != NULL )
{
// This is a drag command, not a mouse block command
// Only this item is put in list
@ -313,7 +311,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
}
GetScreen()->TestDanglingEnds();
m_canvas->Refresh();
break;
case BLOCK_COPY: // Save a copy of items in paste buffer
@ -356,7 +353,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
m_canvas->Refresh();
break;
case BLOCK_MIRROR_Y:
@ -377,7 +373,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
m_canvas->Refresh();
break;
default:
@ -390,8 +385,10 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
GetScreen()->ClearDrawingState();
}
if( ! nextcmd )
if( !nextcmd )
{
block->UpdateItems( GetCanvas() );
block->SetState( STATE_NO_BLOCK );
block->SetCommand( BLOCK_IDLE );
GetScreen()->SetCurItem( NULL );
@ -406,7 +403,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
view->ShowSelectionArea( false );
view->ClearHiddenFlags();
return nextcmd;
}

View File

@ -382,7 +382,7 @@ void LIB_EDIT_FRAME::OnShowElectricalType( wxCommandEvent& event )
// Update canvas
GetRenderSettings()->m_ShowPinsElectricalType = m_showPinElectricalTypeName;
GetCanvas()->GetView()->MarkDirty();
GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
GetCanvas()->Refresh();
}
@ -574,11 +574,7 @@ void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event )
m_lastDrawItem = NULL;
m_unit = i + 1;
// Update canvas
GetRenderSettings()->m_ShowUnit = m_unit;
GetCanvas()->GetView()->MarkDirty();
GetCanvas()->Refresh();
RebuildView();
DisplayCmpDoc();
}
@ -632,10 +628,7 @@ void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
m_lastDrawItem = NULL;
// Update canvas
GetRenderSettings()->m_ShowConvert = m_convert;
GetCanvas()->GetView()->MarkDirty();
GetCanvas()->Refresh();
RebuildView();
}
@ -818,7 +811,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GlobalSetPins( (LIB_PIN*) item, id );
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
}
break;
@ -1073,7 +1065,6 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
updateTitle();
DisplayCmpDoc();
OnModify();
m_canvas->Refresh();
}
@ -1197,8 +1188,6 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
if( !item->InEditMode() )
item->ClearFlags();
m_canvas->Refresh();
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
}
@ -1371,26 +1360,18 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem )
part->RemoveDrawItem( pin );
}
}
m_canvas->Refresh();
}
else
{
if( m_canvas->IsMouseCaptured() )
{
m_canvas->CallEndMouseCapture( aDC );
}
else
{
part->RemoveDrawItem( aItem, m_canvas, aDC );
m_canvas->Refresh();
}
}
SetDrawItem( NULL );
m_lastDrawItem = NULL;
OnModify();
RebuildView();
m_canvas->CrossHairOn( aDC );
}
@ -1399,6 +1380,12 @@ void LIB_EDIT_FRAME::OnModify()
{
GetScreen()->SetModify();
storeCurrentPart();
// Parts have a small number of view items (compared to a full schematic), and changes
// in shared pins, graphic items, etc. can add/remove items from the view. All things
// considered, it's safer to just use a big hammer.
RebuildView();
m_treePane->GetLibTree()->Refresh();
}
@ -1429,8 +1416,6 @@ void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent )
return;
OnModify();
m_canvas->Refresh();
return;
}
@ -1716,6 +1701,8 @@ void LIB_EDIT_FRAME::RebuildView()
view->HideWorksheet();
view->ClearHiddenFlags();
GetCanvas()->Refresh();
}
const BOX2I LIB_EDIT_FRAME::GetDocumentExtents() const

View File

@ -95,8 +95,6 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
updateTitle();
DisplayCmpDoc();
OnModify();
m_canvas->Refresh();
RebuildView();
}
@ -143,6 +141,4 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
updateTitle();
DisplayCmpDoc();
OnModify();
m_canvas->Refresh();
RebuildView();
}

View File

@ -26,7 +26,7 @@
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_view.h>
#include <sch_component.h>
#include <lib_edit_frame.h>
#include <class_library.h>
@ -97,7 +97,6 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
SaveCopyInUndoList( parent );
dlg.UpdateField( aField );
m_canvas->Refresh();
OnModify();
}

View File

@ -121,7 +121,6 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
MSG_PANEL_ITEMS items;
pin->GetMsgPanelInfo( m_UserUnits, items );
SetMsgPanel( items );
m_canvas->Refresh();
}
pin->EnableEditMode( false );
@ -169,7 +168,6 @@ static void AbortPinMove( EDA_DRAW_PANEL* aPanel, wxDC* DC )
panel->GetView()->ClearPreview();
panel->GetView()->ClearHiddenFlags();
// clear edit flags
parent->SetDrawItem( NULL );
parent->SetLastDrawItem( NULL );
@ -271,11 +269,6 @@ void LIB_EDIT_FRAME::PlacePin()
SetDrawItem( NULL );
OnModify();
m_canvas->Refresh();
printf("Rebuild %d %d\n", cur_pin->GetPosition().x, cur_pin->GetPosition().y );
RebuildView();
}
@ -323,10 +316,6 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem )
cur_pin->GetMsgPanelInfo( m_UserUnits, items );
SetMsgPanel( items );
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
// Refresh the screen to avoid color artifacts when drawing
// the pin in Edit mode and moving it from its start position
m_canvas->Refresh();
}

View File

@ -102,8 +102,6 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
MSG_PANEL_ITEMS items;
DrawItem->GetMsgPanelInfo( m_UserUnits, items );
SetMsgPanel( items );
m_canvas->Refresh();
RebuildView();
}
@ -369,8 +367,6 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
SetDrawItem( NULL );
OnModify();
m_canvas->SetMouseCapture( NULL, NULL );
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
@ -379,7 +375,7 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
view->ClearHiddenFlags();
view->ClearPreview();
RebuildView();
OnModify();
}
}

View File

@ -146,7 +146,6 @@ void LIB_EDIT_FRAME::LoadOneSymbol()
part->RemoveDuplicateDrawItems();
OnModify();
m_canvas->Refresh();
}
@ -224,9 +223,5 @@ void LIB_EDIT_FRAME::PlaceAnchor()
wxPoint offset( -cross_hair.x, cross_hair.y );
part->SetOffset( offset );
OnModify();
// Redraw the symbol
RedrawScreen( wxPoint( 0, 0 ), true );
m_canvas->Refresh();
}
}

View File

@ -39,6 +39,7 @@
#include <sch_line.h>
#include <sch_edit_frame.h>
#include <netlist_object.h>
#include <sch_view.h>
#include <dialogs/dialog_edit_line_style.h>
@ -795,7 +796,10 @@ int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw )
return wxID_CANCEL;
if( aRedraw )
m_canvas->Refresh();
{
GetCanvas()->GetView()->Update( aLine );
GetCanvas()->Refresh();
}
return wxID_OK;
}

View File

@ -888,8 +888,6 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
if( m_autoplaceFields )
component->AutoAutoplaceFields( GetScreen() );
m_canvas->Refresh();
break;
}
@ -899,7 +897,6 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
case SCH_HIERARCHICAL_LABEL_T:
m_canvas->MoveCursorToCrossHair();
ChangeTextOrient( (SCH_TEXT*) item );
m_canvas->Refresh();
break;
case SCH_FIELD_T:
@ -911,7 +908,6 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( item->GetParent() );
parent->ClearFieldsAutoplaced();
}
m_canvas->Refresh();
break;
case SCH_BITMAP_T:
@ -942,6 +938,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
}
GetCanvas()->GetView()->Update( item );
GetCanvas()->Refresh();
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );
@ -1101,6 +1098,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
}
GetCanvas()->GetView()->Update( item );
GetCanvas()->Refresh();
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );
@ -1246,8 +1244,6 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
if( m_autoplaceFields )
component->AutoAutoplaceFields( GetScreen() );
m_canvas->Refresh();
break;
}
@ -1273,6 +1269,7 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
}
GetCanvas()->GetView()->Update( item );
GetCanvas()->Refresh();
if( item->GetFlags() == 0 )
screen->SetCurItem( NULL );

View File

@ -32,7 +32,8 @@
#include <sch_edit_frame.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <sch_view.h>
#include <sch_painter.h>
#include <general.h>
#include <hotkeys.h>
#include <eeschema_id.h>
@ -328,10 +329,15 @@ void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
switch( id )
{
case ID_TB_OPTIONS_HIDDEN_PINS:
{
m_showAllPins = !m_showAllPins;
if( m_canvas )
m_canvas->Refresh();
auto painter = static_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
painter->GetSettings()->m_ShowHiddenPins = m_showAllPins;
GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
GetCanvas()->Refresh();
}
break;
case ID_TB_OPTIONS_BUS_WIRES_ORIENT:

View File

@ -139,6 +139,11 @@ public:
*/
void PushItem( ITEM_PICKER& aItem );
/**
* Mark the list of items for update when the view is next refreshed.
*/
void UpdateItems( EDA_DRAW_PANEL* aPanel );
/**
* Function ClearListAndDeleteItems
* deletes only the list of EDA_ITEM * pointers, AND the data printed