From 97c83766db678f54e3c2fb75654dccd6f7f4bde2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 10 Sep 2018 11:58:50 +0100 Subject: [PATCH] Refresh issues around sheet pins. --- eeschema/bus-wire-junction.cpp | 6 +----- eeschema/busentry.cpp | 4 ++-- eeschema/getpart.cpp | 2 +- eeschema/onleftclick.cpp | 26 +++++++++++------------ eeschema/operations_on_items_lists.cpp | 2 +- eeschema/sch_base_frame.cpp | 29 ++++++++++++++++++++++++++ eeschema/sch_base_frame.h | 19 +++++++++++++++++ eeschema/sch_edit_frame.cpp | 16 ++------------ eeschema/sch_edit_frame.h | 7 +------ eeschema/sch_painter.cpp | 1 + eeschema/sch_view.cpp | 13 ++++++------ eeschema/schedit.cpp | 5 +++-- 12 files changed, 80 insertions(+), 50 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 8ebcab2027..67182879cc 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -614,7 +614,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend ) remove_item( item ); remove_item( secondItem ); itemList.PushItem( ITEM_PICKER( line, UR_NEW ) ); - AddToScreen( (SCH_ITEM*) line ); + AddToScreen( line ); break; } } @@ -845,8 +845,6 @@ void SCH_EDIT_FRAME::RepeatDrawItem() if( !repeater ) return; - //D( repeater>Show( 0, std::cout ); ) - // clone the repeater, move it, insert into display list, then save a copy // via SetRepeatItem(); @@ -872,9 +870,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem() AddToScreen( my_clone ); if( my_clone->IsConnectable() ) - { GetScreen()->TestDanglingEnds(); - } SaveCopyInUndoList( my_clone, UR_NEW ); my_clone->ClearFlags(); diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index 83941542ee..1f4f00c939 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -46,7 +46,7 @@ SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry() busEntry->SetFlags( IS_NEW ); GetScreen()->SetCurItem( busEntry ); - addCurrentItemToList(); + addCurrentItemToScreen(); return busEntry; } @@ -57,7 +57,7 @@ SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry() busEntry->SetFlags( IS_NEW ); GetScreen()->SetCurItem( busEntry ); - addCurrentItemToList(); + addCurrentItemToScreen(); return busEntry; } diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index d65d7da208..e93cd70ca0 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -313,7 +313,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) if( item->GetFlags() == 0 ) { - addCurrentItemToList(); + addCurrentItemToScreen(); SchematicCleanUp( true ); } diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index dc9267fd8a..a1a751dcbb 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -87,7 +87,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case SCH_FIELD_T: case SCH_BITMAP_T: case SCH_NO_CONNECT_T: - addCurrentItemToList(); + addCurrentItemToScreen(); GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearHiddenFlags(); return; @@ -133,7 +133,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -150,7 +150,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -162,7 +162,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -174,7 +174,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -205,7 +205,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -217,7 +217,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -229,7 +229,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -247,7 +247,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -264,7 +264,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -285,7 +285,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) ) { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; @@ -313,7 +313,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) } else { - addCurrentItemToList(); + addCurrentItemToScreen(); } break; diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index 124b822a85..7b97a405f9 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -195,7 +195,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend ) wxT( "Sheet label has invalid parent item." ) ); SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend ); sheet->RemovePin( (SCH_SHEET_PIN*) aItem ); - m_canvas->RefreshDrawingRect( sheet->GetBoundingBox() ); + RefreshItem( sheet ); } else if( aItem->Type() == SCH_JUNCTION_T ) { diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 99a1122440..df780456d6 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -567,17 +567,45 @@ void EDA_DRAW_FRAME::createCanvas() } +void SCH_BASE_FRAME::RefreshItem( SCH_ITEM* aItem, bool isAddOrDelete ) +{ + EDA_ITEM* parent = aItem->GetParent(); + + if( aItem->Type() == SCH_SHEET_PIN_T ) + { + // Sheet pins aren't in the view. Refresh their parent. + if( parent ) + GetCanvas()->GetView()->Update( parent ); + } + else + { + if( !isAddOrDelete ) + GetCanvas()->GetView()->Update( aItem ); + + // Component children are drawn from their parents. Mark them for re-paint. + if( parent && parent->Type() == SCH_COMPONENT_T ) + GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT ); + } + + GetCanvas()->Refresh(); +} + + void SCH_BASE_FRAME::AddToScreen( SCH_ITEM* aItem ) { GetScreen()->Append( aItem ); GetCanvas()->GetView()->Add( aItem ); + RefreshItem( aItem, true ); // handle any additional parent semantics } void SCH_BASE_FRAME::AddToScreen( DLIST& aItems ) { for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() ) + { GetCanvas()->GetView()->Add( item ); + RefreshItem( item, true ); // handle any additional parent semantics + } GetScreen()->Append( aItems ); } @@ -587,6 +615,7 @@ void SCH_BASE_FRAME::RemoveFromScreen( SCH_ITEM* aItem ) { GetCanvas()->GetView()->Remove( aItem ); GetScreen()->Remove( aItem ); + RefreshItem( aItem, true ); // handle any additional parent semantics } diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index 24b2ada6a7..fca8e70948 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -290,10 +290,29 @@ public: virtual void HardRedraw() override; + /** + * Add an item to the screen (and view) + */ void AddToScreen( SCH_ITEM* aItem ); + + /** + * Add a list of items to the screen (and view) + */ void AddToScreen( DLIST& aItems ); + + /** + * Remove an item from the screen (and view) + */ void RemoveFromScreen( SCH_ITEM* aItem ); + /** + * Mark an item for refresh. + */ + void RefreshItem( SCH_ITEM* aItem, bool isAddOrDelete = false ); + + /** + * Mark all items for refresh. + */ void SyncView(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index f5cdd27c1e..0fe499a618 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -752,18 +752,6 @@ void SCH_EDIT_FRAME::OnModify() } -void SCH_EDIT_FRAME::RefreshItem( SCH_ITEM* aItem ) -{ - GetCanvas()->GetView()->Update( aItem ); - - // Component children are drawn from their parents so we must also dirty the parent. - if( aItem->GetParent() && aItem->GetParent()->Type() == SCH_COMPONENT_T ) - GetCanvas()->GetView()->Update( aItem->GetParent(), KIGFX::REPAINT ); - - GetCanvas()->Refresh(); -} - - void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event ) { event.Enable( m_blockItems.GetCount() > 0 ); @@ -1339,7 +1327,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const } -void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw ) +void SCH_EDIT_FRAME::addCurrentItemToScreen( bool aRedraw ) { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); @@ -1416,7 +1404,7 @@ void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw ) if( item->Type() == SCH_SHEET_PIN_T ) ( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item ); else - wxLogMessage( wxT( "addCurrentItemToList: expected type = SCH_SHEET_PIN_T, actual type = %d" ), + wxLogMessage( wxT( "addCurrentItemToScreen: expected type = SCH_SHEET_PIN_T, actual type = %d" ), item->Type() ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 96922dabe3..f2439045cd 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -194,7 +194,7 @@ protected: * * @param aRedraw = true (default) to redrw -the screen after adding the item. */ - void addCurrentItemToList( bool aRedraw = true ); + void addCurrentItemToScreen( bool aRedraw = true ); void updateFindReplaceView( wxFindDialogEvent& aEvent ); @@ -347,11 +347,6 @@ public: */ void OnModify(); - /** - * Mark an item for refresh. - */ - void RefreshItem( SCH_ITEM* aItem ); - virtual wxString GetScreenDesc() const override; /** diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index b5aaf7c328..5dfd7e4c8d 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -166,6 +166,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) HANDLE_ITEM(SCH_HIERARCHICAL_LABEL_T, SCH_HIERLABEL); HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL); HANDLE_ITEM(SCH_SHEET_T, SCH_SHEET); + HANDLE_ITEM(SCH_SHEET_PIN_T, SCH_HIERLABEL); HANDLE_ITEM(SCH_NO_CONNECT_T, SCH_NO_CONNECT); HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE); HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE); diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 6bb5268af5..8576fb7060 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -151,13 +151,14 @@ void SCH_VIEW::ClearPreview() void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned ) { - m_preview->Add(aItem); - if(owned) - m_previewItems.push_back(aItem); + m_preview->Add( aItem ); - SetVisible(m_preview.get(), true); - Hide(m_preview.get(), false); - Update(m_preview.get()); + if( owned ) + m_previewItems.push_back( aItem ); + + SetVisible( m_preview.get(), true ); + Hide( m_preview.get(), false ); + Update( m_preview.get() ); } void SCH_VIEW::ShowSelectionArea( bool aShow ) diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 08d5364d42..7fa7dc1e05 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -229,7 +229,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_END_SHEET: m_canvas->MoveCursorToCrossHair(); - addCurrentItemToList(); + addCurrentItemToScreen(); break; case ID_POPUP_SCH_RESIZE_SHEET: @@ -360,7 +360,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) item = screen->GetCurItem(); if( item ) - addCurrentItemToList(); + addCurrentItemToScreen(); break; @@ -664,6 +664,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair() if( itemHasConnections ) screen->TestDanglingEnds(); + GetCanvas()->Refresh(); OnModify(); return true; }