Refresh issues around sheet pins.

This commit is contained in:
Jeff Young 2018-09-10 11:58:50 +01:00
parent 96724af2c4
commit 97c83766db
12 changed files with 80 additions and 50 deletions

View File

@ -614,7 +614,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend )
remove_item( item ); remove_item( item );
remove_item( secondItem ); remove_item( secondItem );
itemList.PushItem( ITEM_PICKER( line, UR_NEW ) ); itemList.PushItem( ITEM_PICKER( line, UR_NEW ) );
AddToScreen( (SCH_ITEM*) line ); AddToScreen( line );
break; break;
} }
} }
@ -845,8 +845,6 @@ void SCH_EDIT_FRAME::RepeatDrawItem()
if( !repeater ) if( !repeater )
return; return;
//D( repeater>Show( 0, std::cout ); )
// clone the repeater, move it, insert into display list, then save a copy // clone the repeater, move it, insert into display list, then save a copy
// via SetRepeatItem(); // via SetRepeatItem();
@ -872,9 +870,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem()
AddToScreen( my_clone ); AddToScreen( my_clone );
if( my_clone->IsConnectable() ) if( my_clone->IsConnectable() )
{
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
}
SaveCopyInUndoList( my_clone, UR_NEW ); SaveCopyInUndoList( my_clone, UR_NEW );
my_clone->ClearFlags(); my_clone->ClearFlags();

View File

@ -46,7 +46,7 @@ SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry()
busEntry->SetFlags( IS_NEW ); busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry ); GetScreen()->SetCurItem( busEntry );
addCurrentItemToList(); addCurrentItemToScreen();
return busEntry; return busEntry;
} }
@ -57,7 +57,7 @@ SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
busEntry->SetFlags( IS_NEW ); busEntry->SetFlags( IS_NEW );
GetScreen()->SetCurItem( busEntry ); GetScreen()->SetCurItem( busEntry );
addCurrentItemToList(); addCurrentItemToScreen();
return busEntry; return busEntry;
} }

View File

@ -313,7 +313,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
if( item->GetFlags() == 0 ) if( item->GetFlags() == 0 )
{ {
addCurrentItemToList(); addCurrentItemToScreen();
SchematicCleanUp( true ); SchematicCleanUp( true );
} }

View File

@ -87,7 +87,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case SCH_FIELD_T: case SCH_FIELD_T:
case SCH_BITMAP_T: case SCH_BITMAP_T:
case SCH_NO_CONNECT_T: case SCH_NO_CONNECT_T:
addCurrentItemToList(); addCurrentItemToScreen();
GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearPreview();
GetCanvas()->GetView()->ClearHiddenFlags(); GetCanvas()->GetView()->ClearHiddenFlags();
return; return;
@ -133,7 +133,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -150,7 +150,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -162,7 +162,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -174,7 +174,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -205,7 +205,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -217,7 +217,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -229,7 +229,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -247,7 +247,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -264,7 +264,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; 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) ) else if( (item->Type() == SCH_SHEET_PIN_T) && (item->GetFlags() != 0) )
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;
@ -313,7 +313,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
else else
{ {
addCurrentItemToList(); addCurrentItemToScreen();
} }
break; break;

View File

@ -195,7 +195,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
wxT( "Sheet label has invalid parent item." ) ); wxT( "Sheet label has invalid parent item." ) );
SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend ); SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED, aAppend );
sheet->RemovePin( (SCH_SHEET_PIN*) aItem ); sheet->RemovePin( (SCH_SHEET_PIN*) aItem );
m_canvas->RefreshDrawingRect( sheet->GetBoundingBox() ); RefreshItem( sheet );
} }
else if( aItem->Type() == SCH_JUNCTION_T ) else if( aItem->Type() == SCH_JUNCTION_T )
{ {

View File

@ -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 ) void SCH_BASE_FRAME::AddToScreen( SCH_ITEM* aItem )
{ {
GetScreen()->Append( aItem ); GetScreen()->Append( aItem );
GetCanvas()->GetView()->Add( aItem ); GetCanvas()->GetView()->Add( aItem );
RefreshItem( aItem, true ); // handle any additional parent semantics
} }
void SCH_BASE_FRAME::AddToScreen( DLIST<SCH_ITEM>& aItems ) void SCH_BASE_FRAME::AddToScreen( DLIST<SCH_ITEM>& aItems )
{ {
for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() ) for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() )
{
GetCanvas()->GetView()->Add( item ); GetCanvas()->GetView()->Add( item );
RefreshItem( item, true ); // handle any additional parent semantics
}
GetScreen()->Append( aItems ); GetScreen()->Append( aItems );
} }
@ -587,6 +615,7 @@ void SCH_BASE_FRAME::RemoveFromScreen( SCH_ITEM* aItem )
{ {
GetCanvas()->GetView()->Remove( aItem ); GetCanvas()->GetView()->Remove( aItem );
GetScreen()->Remove( aItem ); GetScreen()->Remove( aItem );
RefreshItem( aItem, true ); // handle any additional parent semantics
} }

View File

@ -290,10 +290,29 @@ public:
virtual void HardRedraw() override; virtual void HardRedraw() override;
/**
* Add an item to the screen (and view)
*/
void AddToScreen( SCH_ITEM* aItem ); void AddToScreen( SCH_ITEM* aItem );
/**
* Add a list of items to the screen (and view)
*/
void AddToScreen( DLIST<SCH_ITEM>& aItems ); void AddToScreen( DLIST<SCH_ITEM>& aItems );
/**
* Remove an item from the screen (and view)
*/
void RemoveFromScreen( SCH_ITEM* aItem ); 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(); void SyncView();

View File

@ -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 ) void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
{ {
event.Enable( m_blockItems.GetCount() > 0 ); 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_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
@ -1416,7 +1404,7 @@ void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw )
if( item->Type() == SCH_SHEET_PIN_T ) if( item->Type() == SCH_SHEET_PIN_T )
( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item ); ( (SCH_SHEET*)undoItem )->AddPin( (SCH_SHEET_PIN*) item );
else 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() ); item->Type() );
} }

View File

@ -194,7 +194,7 @@ protected:
* *
* @param aRedraw = true (default) to redrw -the screen after adding the item. * @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 ); void updateFindReplaceView( wxFindDialogEvent& aEvent );
@ -347,11 +347,6 @@ public:
*/ */
void OnModify(); void OnModify();
/**
* Mark an item for refresh.
*/
void RefreshItem( SCH_ITEM* aItem );
virtual wxString GetScreenDesc() const override; virtual wxString GetScreenDesc() const override;
/** /**

View File

@ -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_HIERARCHICAL_LABEL_T, SCH_HIERLABEL);
HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL); HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL);
HANDLE_ITEM(SCH_SHEET_T, SCH_SHEET); 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_NO_CONNECT_T, SCH_NO_CONNECT);
HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE); HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE);
HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE); HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE);

View File

@ -152,6 +152,7 @@ void SCH_VIEW::ClearPreview()
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned ) void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
{ {
m_preview->Add( aItem ); m_preview->Add( aItem );
if( owned ) if( owned )
m_previewItems.push_back( aItem ); m_previewItems.push_back( aItem );

View File

@ -229,7 +229,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_END_SHEET: case ID_POPUP_SCH_END_SHEET:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
addCurrentItemToList(); addCurrentItemToScreen();
break; break;
case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_SCH_RESIZE_SHEET:
@ -360,7 +360,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
item = screen->GetCurItem(); item = screen->GetCurItem();
if( item ) if( item )
addCurrentItemToList(); addCurrentItemToScreen();
break; break;
@ -664,6 +664,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair()
if( itemHasConnections ) if( itemHasConnections )
screen->TestDanglingEnds(); screen->TestDanglingEnds();
GetCanvas()->Refresh();
OnModify(); OnModify();
return true; return true;
} }