diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 5112c0ed4f..233900475a 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -107,6 +107,8 @@ EDA_ITEM* SCH_BITMAP::Clone() const void SCH_BITMAP::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( aItem->Type() == SCH_BITMAP_T, wxString::Format( wxT( "SCH_BITMAP object cannot swap data with %s object." ), aItem->GetClass() ) ); diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 32b7f9eabe..142e1e02a2 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -138,6 +138,8 @@ VECTOR2I SCH_BUS_ENTRY_BASE::GetEnd() const void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + SCH_BUS_ENTRY_BASE* item = dynamic_cast( aItem ); wxCHECK_RET( item, wxT( "Cannot swap bus entry data with invalid item." ) ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index e40de04836..e5e1f19c22 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -407,6 +407,8 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) void SCH_FIELD::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( ( aItem != nullptr ) && ( aItem->Type() == SCH_FIELD_T ), wxT( "Cannot swap field data with invalid item." ) ); diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index 0afdf62cec..97a8b406f4 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -259,6 +259,27 @@ void SCH_ITEM::SwapData( SCH_ITEM* aItem ) } +void SCH_ITEM::SwapFlags( SCH_ITEM* aItem ) +{ + EDA_ITEM_FLAGS editFlags = GetEditFlags(); + EDA_ITEM_FLAGS tempFlags = GetTempFlags(); + EDA_ITEM_FLAGS aItem_editFlags = aItem->GetEditFlags(); + EDA_ITEM_FLAGS aItem_tempFlags = aItem->GetTempFlags(); + + std::swap( m_flags, aItem->m_flags ); + + ClearEditFlags(); + SetFlags( editFlags ); + ClearTempFlags(); + SetFlags( tempFlags ); + + aItem->ClearEditFlags(); + aItem->SetFlags( aItem_editFlags ); + aItem->ClearTempFlags(); + aItem->SetFlags( aItem_tempFlags ); +} + + void SCH_ITEM::ClearCaches() { auto clearTextCaches = diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index e9962b72b3..9cee36c092 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -189,6 +189,11 @@ public: */ virtual void SwapData( SCH_ITEM* aItem ); + /** + * Swap the non-temp and non-edit flags. + */ + void SwapFlags( SCH_ITEM* aItem ); + /** * Routine to create a new copy of given item. * The new object is not put in draw list (not linked). diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index db61749da2..8fe4a37959 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -60,6 +60,8 @@ EDA_ITEM* SCH_JUNCTION::Clone() const void SCH_JUNCTION::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( ( aItem != nullptr ) && ( aItem->Type() == SCH_JUNCTION_T ), wxT( "Cannot swap junction data with invalid item." ) ); diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 798d36242f..0a984d378d 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -1212,6 +1212,7 @@ SCH_DIRECTIVE_LABEL::SCH_DIRECTIVE_LABEL( const VECTOR2I& pos ) : void SCH_DIRECTIVE_LABEL::SwapData( SCH_ITEM* aItem ) { SCH_LABEL_BASE::SwapData( aItem ); + SCH_DIRECTIVE_LABEL* label = static_cast( aItem ); std::swap( m_pinLength, label->m_pinLength ); diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 8bd739714f..23789d56e0 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -837,6 +837,8 @@ bool SCH_LINE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) con void SCH_LINE::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + SCH_LINE* item = (SCH_LINE*) aItem; std::swap( m_layer, item->m_layer ); diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 511f805e82..d92f2a0c84 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -56,6 +56,8 @@ EDA_ITEM* SCH_NO_CONNECT::Clone() const void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( ( aItem != nullptr ) && ( aItem->Type() == SCH_NO_CONNECT_T ), wxT( "Cannot swap no connect data with invalid item." ) ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 56b66a46a5..a96ef05654 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2783,7 +2783,7 @@ void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer ) m_gal->SetIsFill( true ); m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) ); m_gal->SetIsStroke( true ); - m_gal->SetLineWidth( getTextThickness( aLabel ) ); + m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) ); m_gal->SetStrokeColor( color ); m_gal->DrawPolyline( pts2 ); diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index fa24cb91db..3bad221255 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -51,6 +51,8 @@ EDA_ITEM* SCH_SHAPE::Clone() const void SCH_SHAPE::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + SCH_SHAPE* shape = static_cast( aItem ); EDA_SHAPE::SwapShape( shape ); diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index fb748fe686..fef836399a 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -311,6 +311,8 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in void SCH_SHEET::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( aItem->Type() == SCH_SHEET_T, wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ), aItem->GetClass() ) ); diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 3e6c167b79..9fc9ef4d61 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -74,13 +74,14 @@ void SCH_SHEET_PIN::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOf void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem ) { + SCH_HIERLABEL::SwapData( aItem ); + wxCHECK_RET( aItem->Type() == SCH_SHEET_PIN_T, wxString::Format( "SCH_SHEET_PIN object cannot swap data with %s object.", aItem->GetClass() ) ); SCH_SHEET_PIN* pin = static_cast( aItem ); - SCH_HIERLABEL::SwapData( pin ); std::swap( m_number, pin->m_number ); std::swap( m_edge, pin->m_edge ); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 1831791c4e..24eb033e6a 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1119,6 +1119,8 @@ std::vector SCH_SYMBOL::GetPins( const SCH_SHEET_PATH* aSheet ) const void SCH_SYMBOL::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + wxCHECK_RET( aItem != nullptr && aItem->Type() == SCH_SYMBOL_T, wxT( "Cannot swap data with invalid symbol." ) ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index c9e36902ec..7d004baf5b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -230,6 +230,8 @@ void SCH_TEXT::SetTextSpinStyle( TEXT_SPIN_STYLE aSpinStyle ) void SCH_TEXT::SwapData( SCH_ITEM* aItem ) { + SCH_ITEM::SwapFlags( aItem ); + SCH_TEXT* item = static_cast( aItem ); std::swap( m_layer, item->m_layer ); diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 118bc389ad..0b403432df 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -186,14 +186,14 @@ VECTOR2I SCH_TEXTBOX::GetDrawPos() const void SCH_TEXTBOX::SwapData( SCH_ITEM* aItem ) { + SCH_SHAPE::SwapData( aItem ); + SCH_TEXTBOX* item = static_cast( aItem ); std::swap( m_layer, item->m_layer ); SwapText( *item ); SwapAttributes( *item ); - - SCH_SHAPE::SwapData( aItem ); } diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index ead20a5914..f3e8ea5673 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1224,7 +1224,7 @@ int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent ) m_toolMgr->GetTool()->RebuildSelection(); - m_frame->SyncView(); + m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); return 0; @@ -1255,7 +1255,6 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent ) m_toolMgr->GetTool()->RebuildSelection(); - m_frame->SyncView(); m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); diff --git a/include/eda_item.h b/include/eda_item.h index 59f65688e7..4c14582f5b 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -134,14 +134,21 @@ public: return m_flags & mask; } - void ClearTempFlags() + void ClearEditFlags() { - ClearFlags( CANDIDATE | SELECTED_BY_DRAG | IS_LINKED | SKIP_STRUCT ); + ClearFlags( GetEditFlags() ); } - void ClearEditFlags() + EDA_ITEM_FLAGS GetTempFlags() const { - ClearFlags( GetEditFlags() ); + constexpr int mask = ( CANDIDATE | SELECTED_BY_DRAG | IS_LINKED | SKIP_STRUCT ); + + return m_flags & mask; + } + + void ClearTempFlags() + { + ClearFlags( GetTempFlags() ); } virtual bool RenderAsBitmap( double aWorldScale ) const { return false; }