diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index dd0add61b3..20fe6fd302 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -772,7 +772,7 @@ void EDA_DRAW_FRAME::SetMsgPanel( const MSG_PANEL_ITEMS& aList ) if( m_messagePanel == NULL ) return; - ClearMsgPanel(); + m_messagePanel->EraseMsgBox(); for( unsigned i = 0; i < aList.size(); i++ ) m_messagePanel->AppendMessage( aList[i] ); diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index d70c17b810..e3a07b0721 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -253,7 +254,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : updateTitle(); DisplayCmpDoc(); - UpdatePartSelectList(); + RebuildSymbolUnitsList(); m_auimgr.SetManagedWindow( this ); m_auimgr.SetArtProvider( new EDA_DOCKART( this ) ); @@ -335,6 +336,7 @@ void LIB_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new ZOOM_TOOL ); m_toolManager->RegisterTool( new SCH_SELECTION_TOOL ); m_toolManager->RegisterTool( new SCH_PICKER_TOOL ); + m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL ); m_toolManager->InitTools(); // Run the selection tool, it is supposed to be always active @@ -380,7 +382,7 @@ double LIB_EDIT_FRAME::BestZoom() } -void LIB_EDIT_FRAME::UpdatePartSelectList() +void LIB_EDIT_FRAME::RebuildSymbolUnitsList() { if( m_partSelectBox == NULL ) return; @@ -598,11 +600,14 @@ void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event ) if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) ) return; + m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); + m_lastDrawItem = NULL; m_unit = i + 1; + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); RebuildView(); - DisplayCmpDoc(); } @@ -647,11 +652,11 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) { m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); m_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2; - m_lastDrawItem = NULL; - + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); RebuildView(); } @@ -945,6 +950,7 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) if( !aPart && !m_my_part ) return; + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); GetScreen()->SetCurItem( nullptr ); if( m_my_part != aPart ) @@ -968,6 +974,7 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) // Ensure synchronized pin edit can be enabled only symbols with interchangeable units m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked(); + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); RebuildView(); } @@ -1026,6 +1033,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) wxArrayString oldAliases = GetCurPart()->GetAliasNames( false ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); if( GetDrawItem() && GetDrawItem()->Type() == LIB_FIELD_T ) SetDrawItem( nullptr ); // selected LIB_FIELD might be deleted @@ -1061,7 +1069,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event ) SyncLibraries( false ); } - UpdatePartSelectList(); + RebuildSymbolUnitsList(); updateTitle(); DisplayCmpDoc(); @@ -1321,18 +1329,6 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPos, const KICA item = selTool->SelectPoint( gridPos, aFilter ); } - // JEY TODO: move to a selection event... - if( item ) - { - MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( m_UserUnits, items ); - SetMsgPanel( items ); - } - else - { - ClearMsgPanel(); - } - return (LIB_ITEM*) item; } @@ -1342,10 +1338,11 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem ) if( !aItem ) return; - m_canvas->CrossHairOff( aDC ); - LIB_PART* part = GetCurPart(); + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); + m_canvas->CrossHairOff( aDC ); + SaveCopyInUndoList( part ); if( aItem->Type() == LIB_PIN_T ) @@ -1421,8 +1418,11 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent ) void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent ) { LIB_PART* part = GetCurPart(); - SaveCopyInUndoList( part ); + SetDrawItem( nullptr ); + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); + + SaveCopyInUndoList( part ); DIALOG_LIB_EDIT_PIN_TABLE dlg( this, part ); diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 479bfbd2bb..d1ee6100ce 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -338,7 +338,7 @@ public: void OnUpdateElectricalType( wxUpdateUIEvent& aEvent ); void OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent ); - void UpdatePartSelectList(); + void RebuildSymbolUnitsList(); /** * Redraw the current component loaded in library editor @@ -397,10 +397,8 @@ public: void OnModify(); int GetUnit() { return m_unit; } - void SetUnit( int unit ) { m_unit = unit; } int GetConvert() { return m_convert; } - void SetConvert( int convert ) { m_convert = convert; } LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; } void SetLastDrawItem( LIB_ITEM* drawItem ) { m_lastDrawItem = drawItem; } @@ -441,6 +439,8 @@ public: bool IsEditingDrawItem() { return GetDrawItem() && GetDrawItem()->InEditMode(); } + void ClearMsgPanel() override { DisplayCmpDoc(); } + private: // Sets up the tool framework void setupTools(); diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 1bb4d19a4e..f0eb75d7ad 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -147,7 +147,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in SetShowDeMorgan( GetCurPart()->HasConversion() ); if( aUnit > 0 ) - UpdatePartSelectList(); + RebuildSymbolUnitsList(); return true; } @@ -206,7 +206,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a Zoom_Automatique( false ); updateTitle(); - UpdatePartSelectList(); + RebuildSymbolUnitsList(); // Display the document information based on the entry selected just in // case the entry is an alias. @@ -791,7 +791,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile ) wxString msg1; msg1.Printf( _( "Symbol library documentation file \"%s\" saved" ), docFileName.GetFullPath() ); AppendMsgPanel( msg, msg1, BLUE ); - UpdatePartSelectList(); + RebuildSymbolUnitsList(); return true; } @@ -845,7 +845,7 @@ void LIB_EDIT_FRAME::DisplayCmpDoc() { LIB_PART* part = GetCurPart(); - ClearMsgPanel(); + EDA_DRAW_FRAME::ClearMsgPanel(); if( !part ) return; diff --git a/eeschema/libedit/libedit_onleftclick.cpp b/eeschema/libedit/libedit_onleftclick.cpp index 4d31fdb875..3f57b11e66 100644 --- a/eeschema/libedit/libedit_onleftclick.cpp +++ b/eeschema/libedit/libedit_onleftclick.cpp @@ -50,25 +50,8 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) return; if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited ) - { item = LocateItemUsingCursor( aPosition ); - if( item ) - { - MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( m_UserUnits, items ); - - SetMsgPanel( items ); - } - else - { - DisplayCmpDoc(); - - if( m_canvas->GetAbortRequest() ) - m_canvas->SetAbortRequest( false ); - } - } - switch( GetToolId() ) { case ID_ZOOM_SELECTION: @@ -118,16 +101,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) item = LocateItemUsingCursor( aPosition ); if( item ) - { deleteItem( DC, item ); - } - else - { - DisplayCmpDoc(); - - if( m_canvas->GetAbortRequest() ) - m_canvas->SetAbortRequest( false ); - } break; case ID_LIBEDIT_ANCHOR_ITEM_BUTT: diff --git a/eeschema/libedit/libedit_undo_redo.cpp b/eeschema/libedit/libedit_undo_redo.cpp index 88a8657d37..bdbfdaeaa0 100644 --- a/eeschema/libedit/libedit_undo_redo.cpp +++ b/eeschema/libedit/libedit_undo_redo.cpp @@ -30,7 +30,8 @@ #include #include #include - +#include +#include void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, UNDO_REDO_T undoType ) { @@ -57,6 +58,8 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) if( GetScreen()->GetRedoCommandCount() <= 0 ) return; + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); + // Load the last redo entry PICKED_ITEMS_LIST* redoCommand = GetScreen()->PopCommandFromRedoList(); ITEM_PICKER redoWrapper = redoCommand->PopItem(); @@ -90,10 +93,9 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) } SetDrawItem( NULL ); - UpdatePartSelectList(); + RebuildSymbolUnitsList(); SetShowDeMorgan( part->HasConversion() ); updateTitle(); - DisplayCmpDoc(); RebuildView(); GetCanvas()->Refresh(); @@ -106,6 +108,8 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) if( GetScreen()->GetUndoCommandCount() <= 0 ) return; + m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true ); + // Load the last undo entry PICKED_ITEMS_LIST* undoCommand = GetScreen()->PopCommandFromUndoList(); ITEM_PICKER undoWrapper = undoCommand->PopItem(); @@ -139,10 +143,9 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) } SetDrawItem( NULL ); - UpdatePartSelectList(); + RebuildSymbolUnitsList(); SetShowDeMorgan( part->HasConversion() ); updateTitle(); - DisplayCmpDoc(); RebuildView(); GetCanvas()->Refresh(); diff --git a/eeschema/tools/sch_inspection_tool.cpp b/eeschema/tools/sch_inspection_tool.cpp index 568160cc5c..05c5e35a5a 100644 --- a/eeschema/tools/sch_inspection_tool.cpp +++ b/eeschema/tools/sch_inspection_tool.cpp @@ -128,7 +128,7 @@ int SCH_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) if( selection.GetSize() == 1 ) { - SCH_ITEM* item = (SCH_ITEM*) selection.Front(); + EDA_ITEM* item = (EDA_ITEM*) selection.Front(); MSG_PANEL_ITEMS msgItems; item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index 6d2d1344d0..cdc0a91dac 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -461,8 +461,6 @@ EDA_ITEM* SCH_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T if( !m_additive && anyCollected ) clearSelection(); - m_frame->ClearMsgPanel(); - return nullptr; } diff --git a/include/draw_frame.h b/include/draw_frame.h index e1a659ddcf..624d6ca900 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -855,7 +855,7 @@ public: /** * Clear all messages from the message panel. */ - void ClearMsgPanel( void ); + virtual void ClearMsgPanel(); /** * Clear the message panel and populates it with the contents of \a aList.