diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 7f37add336..af92eabf3f 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -72,6 +72,8 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly ) // Update the references for the sheet that is currently being displayed. m_CurrentSheet->UpdateAllScreenReferences(); + + SyncView(); GetCanvas()->Refresh(); OnModify(); } @@ -230,13 +232,13 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, if( !CheckAnnotate( aReporter, !aAnnotateSchematic ) ) aReporter.ReportTail( _( "Annotation complete." ), REPORTER::RPT_ACTION ); - OnModify(); - // Update on screen references, that can be modified by previous calculations: m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); SyncView(); + GetCanvas()->Refresh(); + OnModify(); } diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index fefbfb423a..ffed3ca7d1 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -709,8 +709,7 @@ void SCH_EDIT_FRAME::OnAutoplaceFields( wxCommandEvent& aEvent ) component->AutoplaceFields( screen, /* aManual */ true ); - SyncView(); - GetCanvas()->Refresh(); + RefreshItem( component ); OnModify(); } diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index 3e370324e5..b060f0386e 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -121,7 +121,11 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef } if( isChanged ) + { + SyncView(); + GetCanvas()->Refresh(); OnModify(); + } } @@ -252,6 +256,8 @@ bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() return false; } + SyncView(); + GetCanvas()->Refresh(); OnModify(); return true; } diff --git a/eeschema/block.cpp b/eeschema/block.cpp index cde33e2bcb..0be01f4bec 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -176,12 +176,6 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetScreen()->ClearBlockCommand(); GetScreen()->SetCurItem( NULL ); - if( block->GetCount() ) - { - DisplayError( this, wxT( "HandleBlockPLace() error: some items left in buffer" ) ); - block->ClearItemsList(); - } - m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false ); GetCanvas()->GetView()->ClearPreview(); diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index a5d82742a9..bb7910d12e 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -76,6 +76,7 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, c BusEntry->SetBusEntryShape( s_LastShape ); TestDanglingEnds(); - + + RefreshItem( BusEntry ); OnModify( ); } diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index ed70a4c398..3b3b81af35 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -336,6 +336,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataFromWindow() m_libEntry->GetFootprints().Clear(); m_libEntry->GetFootprints() = m_FootprintFilterListBox->GetStrings(); + m_Parent->RebuildView(); m_Parent->OnModify(); return true; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index bba0577446..c135c07127 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -533,8 +533,9 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() m_cmp->UpdatePinCache(); - GetParent()->OnModify(); GetParent()->TestDanglingEnds(); + GetParent()->RefreshItem( m_cmp ); + GetParent()->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 9b75a620bb..db3c893211 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -334,13 +334,14 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() m_CurrentText->SetThickness( 0 ); } + m_Parent->RefreshItem( m_CurrentText ); + m_Parent->GetCanvas()->Refresh(); m_Parent->OnModify(); // Make the text size the new default size ( if it is a new text ): if( m_CurrentText->IsNew() ) SetDefaultTextSize( m_CurrentText->GetTextWidth() ); - m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); return true; diff --git a/eeschema/dialogs/dialog_edit_line_style.cpp b/eeschema/dialogs/dialog_edit_line_style.cpp index e9756fd30b..1f5e81ede4 100644 --- a/eeschema/dialogs/dialog_edit_line_style.cpp +++ b/eeschema/dialogs/dialog_edit_line_style.cpp @@ -123,6 +123,8 @@ bool DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow() m_line->SetLineStyle( m_lineStyle->GetSelection() ); m_line->SetLineColor( m_selectedColor ); + m_frame->RefreshItem( m_line ); + m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); return true; diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index e3b4518401..3f0a2d9a9d 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -784,6 +784,7 @@ bool DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataFromWindow() SCH_SHEET_PATH currentSheet = m_parent->GetCurrentSheet(); m_dataModel->ApplyData(); + m_parent->SyncView(); m_parent->OnModify(); // Reset the view to where we left the user diff --git a/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp b/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp index c9f1bbdd87..986c373b47 100644 --- a/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp +++ b/eeschema/dialogs/dialog_sch_edit_sheet_pin.cpp @@ -98,6 +98,8 @@ bool DIALOG_SCH_EDIT_SHEET_PIN::TransferDataFromWindow() auto shape = static_cast( m_choiceConnectionType->GetCurrentSelection() ); m_sheetPin->SetShape( shape ); + m_frame->RefreshItem( m_sheetPin ); + m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); return true; diff --git a/eeschema/dialogs/dialog_update_fields.cpp b/eeschema/dialogs/dialog_update_fields.cpp index 983607e024..9b79abfa6d 100644 --- a/eeschema/dialogs/dialog_update_fields.cpp +++ b/eeschema/dialogs/dialog_update_fields.cpp @@ -82,6 +82,8 @@ bool DIALOG_UPDATE_FIELDS::TransferDataFromWindow() for( auto component : m_components ) updateFields( component ); + m_frame->SyncView(); + m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); return true; diff --git a/eeschema/edit_bitmap.cpp b/eeschema/edit_bitmap.cpp index 3fc3a5c44b..95c548af09 100644 --- a/eeschema/edit_bitmap.cpp +++ b/eeschema/edit_bitmap.cpp @@ -140,47 +140,15 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC ) } -void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC ) -{ - // 5.1 TODO: MoveImage(), moveBitmap() and abortMoveBitmap() are obsolete.... - - aImageItem->SetFlags( IS_MOVED ); - - m_canvas->SetMouseCapture( moveBitmap, abortMoveBitmap ); - GetScreen()->SetCurItem( aImageItem ); - SetRepeatItem( NULL ); - - SetUndoItem( aImageItem ); - - if( aImageItem->IsMovableFromAnchorPoint() ) - { - SetCrossHairPosition( aImageItem->GetPosition() ); - m_canvas->MoveCursorToCrossHair(); - aImageItem->SetStoredPos( wxPoint( 0,0 ) ); - } - else - { - // Round the point under the cursor to a multiple of the grid - wxPoint cursorpos = GetCrossHairPosition() - aImageItem->GetPosition(); - wxPoint gridsize = GetScreen()->GetGridSize(); - cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x; - cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y; - - aImageItem->SetStoredPos( cursorpos ); - } - - OnModify(); -} - - void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem ) { if( aItem->GetFlags( ) == 0 ) SaveCopyInUndoList( aItem, UR_ROTATED, false, aItem->GetPosition() ); aItem->Rotate( aItem->GetPosition() ); + + RefreshItem( aItem ); OnModify(); - m_canvas->Refresh(); } @@ -194,8 +162,8 @@ void SCH_EDIT_FRAME::MirrorImage( SCH_BITMAP* aItem, bool Is_X_axis ) else aItem->MirrorY( aItem->GetPosition().x ); + RefreshItem( aItem ); OnModify(); - m_canvas->Refresh(); } @@ -217,6 +185,7 @@ void SCH_EDIT_FRAME::EditImage( SCH_BITMAP* aItem ) } dlg.TransfertToImage( aItem->GetImage() ); + + RefreshItem( aItem ); OnModify(); - m_canvas->Refresh(); } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 94f6625f17..29f409977e 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -79,12 +79,12 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField ) dlg.UpdateField( aField, m_CurrentSheet ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetIgnoreMouseEvents( false ); - OnModify(); if( m_autoplaceFields ) component->AutoAutoplaceFields( GetScreen() ); - m_canvas->Refresh(); + RefreshItem( aField ); + OnModify(); MSG_PANEL_ITEMS items; component->SetCurrentSheetPath( &GetCurrentSheet() ); @@ -110,5 +110,6 @@ void SCH_EDIT_FRAME::RotateField( SCH_FIELD* aField ) else aField->SetTextAngle( TEXT_ANGLE_HORIZ ); + RefreshItem( aField ); OnModify(); } diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 74610fbde7..01e875d4ab 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -59,6 +59,8 @@ void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem ) SaveCopyInUndoList( aTextItem, UR_CHANGED ); aTextItem->SetLabelSpinStyle( orient ); + + RefreshItem( aTextItem ); OnModify(); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 863428456a..7bda43c3f1 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -619,8 +619,6 @@ bool SCH_EDIT_FRAME::AppendSchematic() SCH_SCREENS allScreens; allScreens.ReplaceDuplicateTimeStamps(); - OnModify(); - SCH_SCREENS screens( GetCurrentSheet().Last() ); screens.UpdateSymbolLinks( true ); @@ -631,7 +629,10 @@ bool SCH_EDIT_FRAME::AppendSchematic() GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); + SyncView(); + GetCanvas()->Refresh(); + OnModify(); return true; } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index e3420655b4..6c89cee649 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -42,7 +42,7 @@ #include #include #include - +#include #include #include #include @@ -333,6 +333,7 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( m_foundItems.ReplaceItem( sheet ) ) { + GetCanvas()->GetView()->Update( undoItem, KIGFX::ALL ); OnModify(); SaveUndoItemInUndoList( undoItem ); updateFindReplaceView( aEvent ); @@ -363,6 +364,7 @@ void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) if( m_foundItems.ReplaceItem( sheet ) ) { + GetCanvas()->GetView()->Update( undoItem, KIGFX::ALL ); OnModify(); SaveUndoItemInUndoList( undoItem ); updateFindReplaceView( aEvent ); diff --git a/eeschema/libedit/block_libedit.cpp b/eeschema/libedit/block_libedit.cpp index e3987411a6..686541058c 100644 --- a/eeschema/libedit/block_libedit.cpp +++ b/eeschema/libedit/block_libedit.cpp @@ -346,6 +346,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) } BlockDeleteSelectedItems( GetCurPart(), block ); + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } } @@ -366,6 +368,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) if( GetCurPart() ) { BlockDeleteSelectedItems( GetCurPart(), block ); + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } break; @@ -449,7 +453,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) BlockMoveSelectedItems( pt, GetCurPart(), block ); block->ClearItemsList(); - m_canvas->Refresh( true ); break; case BLOCK_PASTE: // Paste (recopy the last block saved) @@ -461,7 +464,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) pasteClipboard( pt ); block->ClearItemsList(); - m_canvas->Refresh( true ); break; case BLOCK_ZOOM: // Handled by HandleBlockEnd @@ -472,6 +474,8 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) break; } + RebuildView(); + GetCanvas()->Refresh(); OnModify(); block->SetState( STATE_NO_BLOCK ); @@ -481,8 +485,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetCanvas()->GetView()->ClearPreview(); GetCanvas()->GetView()->ClearHiddenFlags(); - - m_canvas->Refresh( true ); } @@ -547,6 +549,8 @@ void LIB_EDIT_FRAME::pasteClipboard( const wxPoint& aOffset ) } BlockMoveSelectedItems( aOffset, GetCurPart(), &GetScreen()->m_BlockLocate ); + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index ba92fe99f5..9e42882f15 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -1003,6 +1003,8 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ) if( dlg.ShowModal() != wxID_OK ) return; + GetCanvas()->GetView()->Update( DrawItem ); + GetCanvas()->Refresh(); OnModify(); // Display new text @@ -1051,6 +1053,9 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) UpdatePartSelectList(); updateTitle(); DisplayCmpDoc(); + + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } @@ -1186,7 +1191,7 @@ void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) } GetCanvas()->CallMouseCapture( nullptr, wxDefaultPosition, false ); - GetGalCanvas()->Refresh(); + GetCanvas()->Refresh(); } else if( item ) { @@ -1196,6 +1201,12 @@ void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) SaveCopyInUndoList( part, UR_LIBEDIT ); item->Rotate( rotationPoint ); + + if( item->InEditMode() ) + GetCanvas()->CallMouseCapture( nullptr, wxDefaultPosition, false ); + else + GetCanvas()->GetView()->Update( item ); + GetCanvas()->Refresh(); OnModify(); if( !item->InEditMode() ) @@ -1243,7 +1254,7 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent ) } m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); - GetGalCanvas()->Refresh(); + GetCanvas()->Refresh(); } else if( item ) { @@ -1258,6 +1269,11 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent ) else item->MirrorVertical( mirrorPoint ); + if( item->InEditMode() ) + m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); + else + GetCanvas()->GetView()->Update( item ); + GetCanvas()->Refresh(); OnModify(); if( !item->InEditMode() ) @@ -1418,11 +1434,6 @@ 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(); } @@ -1452,6 +1463,8 @@ void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent ) if( dlg.ShowModal() == wxID_CANCEL ) return; + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } diff --git a/eeschema/libedit/libedit_undo_redo.cpp b/eeschema/libedit/libedit_undo_redo.cpp index 64c7659e34..1add393d6a 100644 --- a/eeschema/libedit/libedit_undo_redo.cpp +++ b/eeschema/libedit/libedit_undo_redo.cpp @@ -94,6 +94,9 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) SetShowDeMorgan( part->HasConversion() ); updateTitle(); DisplayCmpDoc(); + + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } @@ -140,5 +143,8 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) SetShowDeMorgan( part->HasConversion() ); updateTitle(); DisplayCmpDoc(); + + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } diff --git a/eeschema/libedit/libfield.cpp b/eeschema/libedit/libfield.cpp index f18fbadaee..2429c13a9f 100644 --- a/eeschema/libedit/libfield.cpp +++ b/eeschema/libedit/libfield.cpp @@ -98,5 +98,7 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField ) dlg.UpdateField( aField ); + GetCanvas()->GetView()->Update( aField ); + GetCanvas()->Refresh(); OnModify(); } diff --git a/eeschema/libedit/pinedit.cpp b/eeschema/libedit/pinedit.cpp index 2ac375793e..a56c054ecc 100644 --- a/eeschema/libedit/pinedit.cpp +++ b/eeschema/libedit/pinedit.cpp @@ -115,6 +115,8 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) if( pin->IsModified() || pin->IsNew() ) { + GetCanvas()->GetView()->Update( pin ); + GetCanvas()->Refresh(); OnModify( ); MSG_PANEL_ITEMS items; @@ -267,6 +269,8 @@ void LIB_EDIT_FRAME::PlacePin() SetDrawItem( NULL ); + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } @@ -274,7 +278,6 @@ void LIB_EDIT_FRAME::PlacePin() void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) { LIB_PIN* cur_pin = (LIB_PIN*) aItem; - wxPoint startPos; TempCopyComponent(); @@ -294,8 +297,7 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) if( pin->GetPosition() == cur_pin->GetPosition() && pin->GetOrientation() == cur_pin->GetOrientation() && - pin->GetConvert() == cur_pin->GetConvert() - ) + pin->GetConvert() == cur_pin->GetConvert() ) { pin->SetFlags( IS_LINKED | IS_MOVED ); } @@ -303,13 +305,11 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) cur_pin->SetFlags( IS_LINKED | IS_MOVED ); - startPos.x = OldPos.x; - startPos.y = -OldPos.y; - MSG_PANEL_ITEMS items; cur_pin->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); + m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove ); } @@ -329,9 +329,6 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T ) return; - - DBG(printf("DrawMovePin\n");) - auto p = aPanel->GetParent()->GetCrossHairPosition( true ); // Redraw pin in new position @@ -339,11 +336,8 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi auto view = parent->GetCanvas()->GetView(); - auto copy_pin = static_cast( cur_pin->Clone() ); - - view->Hide( cur_pin ); view->ClearPreview(); - view->AddToPreview( copy_pin ); + view->AddToPreview( cur_pin, false ); } @@ -494,6 +488,8 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId ) // Now changes are made, call OnModify() to validate thes changes and set // the global change for UI + RebuildView(); + GetCanvas()->Refresh(); OnModify(); } @@ -564,7 +560,10 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) MSG_PANEL_ITEMS items; pin->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); - OnModify( ); + + RebuildView(); + GetCanvas()->Refresh(); + OnModify(); } diff --git a/eeschema/libedit/symbdraw.cpp b/eeschema/libedit/symbdraw.cpp index 90b67d8fcb..08908c03a2 100644 --- a/eeschema/libedit/symbdraw.cpp +++ b/eeschema/libedit/symbdraw.cpp @@ -97,6 +97,8 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) DrawItem->SetWidth( m_drawLineWidth ); + GetCanvas()->GetView()->Update( DrawItem ); + GetCanvas()->Refresh(); OnModify( ); MSG_PANEL_ITEMS items; @@ -117,9 +119,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC ) item->EndEdit( parent->GetCrossHairPosition( true ), true ); if( newItem ) - { delete item; - } else parent->RestoreComponent(); @@ -129,7 +129,6 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC ) view->ClearPreview(); view->ShowPreview( false ); view->ClearHiddenFlags(); - DBG(printf("abort\n");) parent->RebuildView(); } @@ -253,28 +252,18 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC ) static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { - LIB_ITEM* item; - - item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); + LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); if( item == NULL ) return; - DBG(printf("CalcDraw!\n");) - auto view = static_cast(aPanel)->GetView(); - auto p = aPanel->GetParent()->GetCrossHairPosition( true ); item->CalcEdit( p ); - DBG(printf("cp: %d %d %d %d\n", item->GetPosition().x, item->GetPosition().y, p.x, p.y );) - view->ClearPreview(); - - auto copy = static_cast( item->Clone() ); - DBG(printf("cp: %d %d\n", copy->GetPosition().x, copy->GetPosition().y );) - view->AddToPreview( copy ); + view->AddToPreview( item, false ); } diff --git a/eeschema/libedit/symbedit.cpp b/eeschema/libedit/symbedit.cpp index d0e77f7d6c..cd7bc694c7 100644 --- a/eeschema/libedit/symbedit.cpp +++ b/eeschema/libedit/symbedit.cpp @@ -185,30 +185,26 @@ void LIB_EDIT_FRAME::SaveOneSymbol() prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() ); if( fn.FileExists() ) - { wxRemove( fn.GetFullPath() ); - } - wxString msg; - msg.Printf( _( "Saving symbol in \"%s\"" ), fn.GetPath() ); - SetStatusText( msg ); + SetStatusText( wxString::Format( _( "Saving symbol in \"%s\"" ), fn.GetPath() ) ); - SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); + SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) ); try { PROPERTIES nodoc_props; // Doc file is useless for a .sym file nodoc_props[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = ""; - pi->CreateSymbolLib( fn.GetFullPath(), &nodoc_props ); + plugin->CreateSymbolLib( fn.GetFullPath(), &nodoc_props ); LIB_PART* saved_part = new LIB_PART( *part ); saved_part->RemoveAllAliases(); // useless in a .sym file - pi->SaveSymbol( fn.GetFullPath(), saved_part, &nodoc_props ); + plugin->SaveSymbol( fn.GetFullPath(), saved_part, &nodoc_props ); } catch( const IO_ERROR& ioe ) { - msg.Printf( _( "An error occurred attempting to save symbol file \"%s\"" ), - fn.GetFullPath() ); + wxString msg = wxString::Format( _( "An error occurred saving symbol file \"%s\"" ), + fn.GetFullPath() ); DisplayErrorMessage( this, msg, ioe.What() ); } } diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 32fb10e859..12c981a39f 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -574,7 +574,8 @@ bool SCH_EDIT_FRAME::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand ) viewer->ReCreateListLib(); GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); - m_canvas->Refresh( true ); + SyncView(); + GetCanvas()->Refresh(); OnModify(); return true; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 08a8be1756..d58bf992eb 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1438,13 +1438,13 @@ void SCH_EDIT_FRAME::addCurrentItemToScreen() item->ClearFlags(); - GetCanvas()->GetView()->Update( item ); - screen->SetModify(); screen->SetCurItem( NULL ); m_canvas->SetMouseCapture( NULL, NULL ); m_canvas->EndMouseCapture(); + RefreshItem( item ); + if( item->IsConnectable() ) { std::vector< wxPoint > pts; diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 49ecc7d1cc..3670ef599d 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -1000,7 +1000,6 @@ private: // Images: SCH_BITMAP* CreateNewImage( wxDC* aDC ); - void MoveImage( SCH_BITMAP* aItem, wxDC* aDC ); void RotateImage( SCH_BITMAP* aItem ); /** diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index da4c7004cf..fe598b1ab3 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -131,20 +131,21 @@ void SCH_VIEW::ClearPreview() { m_preview->Clear(); - for( auto item : m_previewItems ) + for( auto item : m_ownedItems ) delete item; - m_previewItems.clear(); - Update(m_preview.get()); + m_ownedItems.clear(); + Update( m_preview.get() ); } -void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned ) +void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool takeOwnership ) { + Hide( aItem, false ); m_preview->Add( aItem ); - if( owned ) - m_previewItems.push_back( aItem ); + if( takeOwnership ) + m_ownedItems.push_back( aItem ); SetVisible( m_preview.get(), true ); Hide( m_preview.get(), false ); diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index c6bdbadba1..7da1a60631 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -41,7 +41,7 @@ public: KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); } void ClearPreview(); - void AddToPreview( EDA_ITEM *aItem, bool makeCopy = true ); + void AddToPreview( EDA_ITEM *aItem, bool takeOwnership = true ); void ShowSelectionArea( bool aShow = true ); void ShowPreview( bool aShow = true ); @@ -55,7 +55,7 @@ private: std::unique_ptr m_worksheet; std::unique_ptr m_selectionArea; std::unique_ptr m_preview; - std::vector m_previewItems; + std::vector m_ownedItems; std::unordered_map m_cachedBBoxes; }; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 7ee27d687f..907daa9686 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -223,7 +223,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SetRepeatItem( NULL ); TestDanglingEnds(); SetSheetNumberAndCount(); - m_canvas->Refresh(); + GetCanvas()->Refresh(); OnModify(); break; @@ -262,8 +262,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) /* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */ SaveCopyInUndoList( sheet, UR_CHANGED ); sheet->CleanupSheet(); + SyncView(); + GetCanvas()->Refresh(); OnModify(); - m_canvas->RefreshDrawingRect( sheet->GetBoundingBox() ); } break; @@ -691,7 +692,6 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, // Draw the item item at it's new position. item->SetWireImage(); // While moving, the item may choose to render differently - view->Hide( item ); view->ClearPreview(); view->AddToPreview( item, false ); } diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index a0fda29ad6..37fbf991f1 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -404,11 +404,13 @@ void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event ) List->ReversePickersListOrder(); GetScreen()->PushCommandToRedoList( List ); - OnModify(); SetSheetNumberAndCount(); TestDanglingEnds(); - m_canvas->Refresh(); + + SyncView(); + GetCanvas()->Refresh(); + OnModify(); } @@ -427,9 +429,11 @@ void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event ) List->ReversePickersListOrder(); GetScreen()->PushCommandToUndoList( List ); - OnModify(); SetSheetNumberAndCount(); TestDanglingEnds(); - m_canvas->Refresh(); + + SyncView(); + GetCanvas()->Refresh(); + OnModify(); }