diff --git a/eeschema/libedit/pinedit.cpp b/eeschema/libedit/pinedit.cpp index a56c054ecc..0d2c4ca5fd 100644 --- a/eeschema/libedit/pinedit.cpp +++ b/eeschema/libedit/pinedit.cpp @@ -336,8 +336,9 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi auto view = parent->GetCanvas()->GetView(); + view->Hide( cur_pin ); view->ClearPreview(); - view->AddToPreview( cur_pin, false ); + view->AddToPreview( cur_pin->Clone() ); } diff --git a/eeschema/libedit/symbdraw.cpp b/eeschema/libedit/symbdraw.cpp index b68f2e89ec..5e01032765 100644 --- a/eeschema/libedit/symbdraw.cpp +++ b/eeschema/libedit/symbdraw.cpp @@ -47,8 +47,6 @@ #include -static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ); static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -136,7 +134,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC ) LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC ) { LIB_ITEM* item = GetDrawItem(); - m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); + m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn ); wxPoint drawPos = GetCrossHairPosition( true ); // no temp copy -> the current version of symbol will be used for Undo @@ -262,8 +260,9 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx item->CalcEdit( p ); + view->Hide( item ); view->ClearPreview(); - view->AddToPreview( item, false ); + view->AddToPreview( item->Clone() ); } @@ -299,33 +298,11 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC, LIB_ITEM* aItem ) TempCopyComponent(); aItem->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) ); - m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); + m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); } -//! @brief Manage mouse events when creating new graphic object or modifying an graphic object. -static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) -{ - LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); - - if( item == NULL ) - return; - - auto view = static_cast(aPanel)->GetView(); - - auto cp = aPanel->GetParent()->GetCrossHairPosition( true ); - - DBG(printf("SymbolDisplayDraw\n");) - - item->CalcEdit( cp ); - - view->ClearPreview(); - view->AddToPreview( item, false ); -} - - void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC ) { LIB_ITEM* item = GetDrawItem(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index ce538a9f54..f199dc1a3f 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1058,9 +1058,6 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer ) for( auto& item : temp->GetDrawItems() ) { - if( aComp->IsMoving() ) - item.SetFlags( IS_MOVED ); - auto rp = aComp->GetPosition(); auto ip = item.GetPosition(); item.Move( wxPoint( rp.x + ip.x, ip.y - rp.y ) ); @@ -1076,7 +1073,7 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer ) for( SCH_FIELD* field : fields ) { - if( field->GetId() == REFERENCE || !field->IsMoving() ) + if( !field->IsMoving() ) draw( field, aLayer ); } } diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 5704f1927a..2a1a794d49 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -680,6 +680,7 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_ITEM* item = screen->GetCurItem(); auto panel = static_cast( aPanel ); + auto view = panel->GetView(); wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); @@ -688,12 +689,9 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, item->SetPosition( cpos ); - // Draw the item at it's new position. - item->SetWireImage(); // While moving, the item may choose to render differently - - auto view = panel->GetView(); + view->Hide( item ); view->ClearPreview(); - view->AddToPreview( item, false ); + view->AddToPreview( item->Clone() ); // Needed when moving a bitmap image to avoid ugly rendering and artifacts, // because a bitmap is drawn only as non cached @@ -745,7 +743,6 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) // Just restore its data currentItem->SwapData( oldItem ); - // Erase the wire representation before the 'normal' view is drawn. view->Hide( item, false ); item->ClearFlags(); @@ -769,15 +766,17 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem ) SetUndoItem( aItem ); } + aItem->SetFlags( IS_MOVED ); + if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T ) { + RefreshItem( aItem ); + // Now that we're moving a field, they're no longer autoplaced. SCH_COMPONENT *parent = static_cast( aItem->GetParent() ); parent->ClearFieldsAutoplaced(); } - aItem->SetFlags( IS_MOVED ); - // For some items, moving the cursor to anchor is not good // (for instance large hierarchical sheets od componants can have // the anchor position outside the canvas) diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 6dff7140ba..724ace610a 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -348,8 +348,10 @@ static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const auto panel = static_cast( aPanel ); auto view = panel->GetView(); + + view->Hide( sheet ); view->ClearPreview(); - view->AddToPreview( sheet, false ); + view->AddToPreview( sheet->Clone() ); }