Move libedit message panel updating to the Inspection Tool.

This commit is contained in:
Jeff Young 2019-05-06 13:32:51 +01:00
parent a12d769074
commit 207900e4f9
9 changed files with 39 additions and 64 deletions

View File

@ -772,7 +772,7 @@ void EDA_DRAW_FRAME::SetMsgPanel( const MSG_PANEL_ITEMS& aList )
if( m_messagePanel == NULL ) if( m_messagePanel == NULL )
return; return;
ClearMsgPanel(); m_messagePanel->EraseMsgBox();
for( unsigned i = 0; i < aList.size(); i++ ) for( unsigned i = 0; i < aList.size(); i++ )
m_messagePanel->AppendMessage( aList[i] ); m_messagePanel->AppendMessage( aList[i] );

View File

@ -68,6 +68,7 @@
#include <tools/sch_actions.h> #include <tools/sch_actions.h>
#include <tools/sch_selection_tool.h> #include <tools/sch_selection_tool.h>
#include <tools/sch_picker_tool.h> #include <tools/sch_picker_tool.h>
#include <tools/sch_inspection_tool.h>
#include <sch_view.h> #include <sch_view.h>
#include <sch_painter.h> #include <sch_painter.h>
@ -253,7 +254,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
updateTitle(); updateTitle();
DisplayCmpDoc(); DisplayCmpDoc();
UpdatePartSelectList(); RebuildSymbolUnitsList();
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
m_auimgr.SetArtProvider( new EDA_DOCKART( 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 ZOOM_TOOL );
m_toolManager->RegisterTool( new SCH_SELECTION_TOOL ); m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
m_toolManager->RegisterTool( new SCH_PICKER_TOOL ); m_toolManager->RegisterTool( new SCH_PICKER_TOOL );
m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );
m_toolManager->InitTools(); m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active // 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 ) if( m_partSelectBox == NULL )
return; return;
@ -598,11 +600,14 @@ void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event )
if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) ) if( ( i == wxNOT_FOUND ) || ( ( i + 1 ) == m_unit ) )
return; return;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
m_unit = i + 1; m_unit = i + 1;
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
RebuildView(); RebuildView();
DisplayCmpDoc();
} }
@ -647,11 +652,11 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event )
{ {
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); 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_convert = event.GetId() == ID_DE_MORGAN_NORMAL_BUTT ? 1 : 2;
m_lastDrawItem = NULL; m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
RebuildView(); RebuildView();
} }
@ -945,6 +950,7 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
if( !aPart && !m_my_part ) if( !aPart && !m_my_part )
return; return;
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
GetScreen()->SetCurItem( nullptr ); GetScreen()->SetCurItem( nullptr );
if( m_my_part != aPart ) 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 // Ensure synchronized pin edit can be enabled only symbols with interchangeable units
m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked(); m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked();
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
RebuildView(); RebuildView();
} }
@ -1026,6 +1033,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
wxArrayString oldAliases = GetCurPart()->GetAliasNames( false ); wxArrayString oldAliases = GetCurPart()->GetAliasNames( false );
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() );
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
if( GetDrawItem() && GetDrawItem()->Type() == LIB_FIELD_T ) if( GetDrawItem() && GetDrawItem()->Type() == LIB_FIELD_T )
SetDrawItem( nullptr ); // selected LIB_FIELD might be deleted SetDrawItem( nullptr ); // selected LIB_FIELD might be deleted
@ -1061,7 +1069,7 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
SyncLibraries( false ); SyncLibraries( false );
} }
UpdatePartSelectList(); RebuildSymbolUnitsList();
updateTitle(); updateTitle();
DisplayCmpDoc(); DisplayCmpDoc();
@ -1321,18 +1329,6 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPos, const KICA
item = selTool->SelectPoint( gridPos, aFilter ); 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; return (LIB_ITEM*) item;
} }
@ -1342,10 +1338,11 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem )
if( !aItem ) if( !aItem )
return; return;
m_canvas->CrossHairOff( aDC );
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
m_canvas->CrossHairOff( aDC );
SaveCopyInUndoList( part ); SaveCopyInUndoList( part );
if( aItem->Type() == LIB_PIN_T ) if( aItem->Type() == LIB_PIN_T )
@ -1421,8 +1418,11 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent ) void LIB_EDIT_FRAME::OnOpenPinTable( wxCommandEvent& aEvent )
{ {
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
SaveCopyInUndoList( part );
SetDrawItem( nullptr ); SetDrawItem( nullptr );
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
SaveCopyInUndoList( part );
DIALOG_LIB_EDIT_PIN_TABLE dlg( this, part ); DIALOG_LIB_EDIT_PIN_TABLE dlg( this, part );

View File

@ -338,7 +338,7 @@ public:
void OnUpdateElectricalType( wxUpdateUIEvent& aEvent ); void OnUpdateElectricalType( wxUpdateUIEvent& aEvent );
void OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent ); void OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent );
void UpdatePartSelectList(); void RebuildSymbolUnitsList();
/** /**
* Redraw the current component loaded in library editor * Redraw the current component loaded in library editor
@ -397,10 +397,8 @@ public:
void OnModify(); void OnModify();
int GetUnit() { return m_unit; } int GetUnit() { return m_unit; }
void SetUnit( int unit ) { m_unit = unit; }
int GetConvert() { return m_convert; } int GetConvert() { return m_convert; }
void SetConvert( int convert ) { m_convert = convert; }
LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; } LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; }
void SetLastDrawItem( LIB_ITEM* drawItem ) { m_lastDrawItem = drawItem; } void SetLastDrawItem( LIB_ITEM* drawItem ) { m_lastDrawItem = drawItem; }
@ -441,6 +439,8 @@ public:
bool IsEditingDrawItem() { return GetDrawItem() && GetDrawItem()->InEditMode(); } bool IsEditingDrawItem() { return GetDrawItem() && GetDrawItem()->InEditMode(); }
void ClearMsgPanel() override { DisplayCmpDoc(); }
private: private:
// Sets up the tool framework // Sets up the tool framework
void setupTools(); void setupTools();

View File

@ -147,7 +147,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in
SetShowDeMorgan( GetCurPart()->HasConversion() ); SetShowDeMorgan( GetCurPart()->HasConversion() );
if( aUnit > 0 ) if( aUnit > 0 )
UpdatePartSelectList(); RebuildSymbolUnitsList();
return true; return true;
} }
@ -206,7 +206,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
Zoom_Automatique( false ); Zoom_Automatique( false );
updateTitle(); updateTitle();
UpdatePartSelectList(); RebuildSymbolUnitsList();
// Display the document information based on the entry selected just in // Display the document information based on the entry selected just in
// case the entry is an alias. // case the entry is an alias.
@ -791,7 +791,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
wxString msg1; wxString msg1;
msg1.Printf( _( "Symbol library documentation file \"%s\" saved" ), docFileName.GetFullPath() ); msg1.Printf( _( "Symbol library documentation file \"%s\" saved" ), docFileName.GetFullPath() );
AppendMsgPanel( msg, msg1, BLUE ); AppendMsgPanel( msg, msg1, BLUE );
UpdatePartSelectList(); RebuildSymbolUnitsList();
return true; return true;
} }
@ -845,7 +845,7 @@ void LIB_EDIT_FRAME::DisplayCmpDoc()
{ {
LIB_PART* part = GetCurPart(); LIB_PART* part = GetCurPart();
ClearMsgPanel(); EDA_DRAW_FRAME::ClearMsgPanel();
if( !part ) if( !part )
return; return;

View File

@ -50,25 +50,8 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
return; return;
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited ) if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited )
{
item = LocateItemUsingCursor( aPosition ); 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() ) switch( GetToolId() )
{ {
case ID_ZOOM_SELECTION: case ID_ZOOM_SELECTION:
@ -118,16 +101,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
item = LocateItemUsingCursor( aPosition ); item = LocateItemUsingCursor( aPosition );
if( item ) if( item )
{
deleteItem( DC, item ); deleteItem( DC, item );
}
else
{
DisplayCmpDoc();
if( m_canvas->GetAbortRequest() )
m_canvas->SetAbortRequest( false );
}
break; break;
case ID_LIBEDIT_ANCHOR_ITEM_BUTT: case ID_LIBEDIT_ANCHOR_ITEM_BUTT:

View File

@ -30,7 +30,8 @@
#include <lib_manager.h> #include <lib_manager.h>
#include <widgets/lib_tree.h> #include <widgets/lib_tree.h>
#include <symbol_tree_pane.h> #include <symbol_tree_pane.h>
#include <tool/tool_manager.h>
#include <tools/sch_actions.h>
void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, UNDO_REDO_T undoType ) 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 ) if( GetScreen()->GetRedoCommandCount() <= 0 )
return; return;
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
// Load the last redo entry // Load the last redo entry
PICKED_ITEMS_LIST* redoCommand = GetScreen()->PopCommandFromRedoList(); PICKED_ITEMS_LIST* redoCommand = GetScreen()->PopCommandFromRedoList();
ITEM_PICKER redoWrapper = redoCommand->PopItem(); ITEM_PICKER redoWrapper = redoCommand->PopItem();
@ -90,10 +93,9 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
} }
SetDrawItem( NULL ); SetDrawItem( NULL );
UpdatePartSelectList(); RebuildSymbolUnitsList();
SetShowDeMorgan( part->HasConversion() ); SetShowDeMorgan( part->HasConversion() );
updateTitle(); updateTitle();
DisplayCmpDoc();
RebuildView(); RebuildView();
GetCanvas()->Refresh(); GetCanvas()->Refresh();
@ -106,6 +108,8 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
// Load the last undo entry // Load the last undo entry
PICKED_ITEMS_LIST* undoCommand = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* undoCommand = GetScreen()->PopCommandFromUndoList();
ITEM_PICKER undoWrapper = undoCommand->PopItem(); ITEM_PICKER undoWrapper = undoCommand->PopItem();
@ -139,10 +143,9 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
} }
SetDrawItem( NULL ); SetDrawItem( NULL );
UpdatePartSelectList(); RebuildSymbolUnitsList();
SetShowDeMorgan( part->HasConversion() ); SetShowDeMorgan( part->HasConversion() );
updateTitle(); updateTitle();
DisplayCmpDoc();
RebuildView(); RebuildView();
GetCanvas()->Refresh(); GetCanvas()->Refresh();

View File

@ -128,7 +128,7 @@ int SCH_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
if( selection.GetSize() == 1 ) if( selection.GetSize() == 1 )
{ {
SCH_ITEM* item = (SCH_ITEM*) selection.Front(); EDA_ITEM* item = (EDA_ITEM*) selection.Front();
MSG_PANEL_ITEMS msgItems; MSG_PANEL_ITEMS msgItems;
item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems ); item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems );

View File

@ -461,8 +461,6 @@ EDA_ITEM* SCH_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T
if( !m_additive && anyCollected ) if( !m_additive && anyCollected )
clearSelection(); clearSelection();
m_frame->ClearMsgPanel();
return nullptr; return nullptr;
} }

View File

@ -855,7 +855,7 @@ public:
/** /**
* Clear all messages from the message panel. * 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. * Clear the message panel and populates it with the contents of \a aList.