Eeschema highlight symbols (cross probing) fix a few issues.

Fix highlight not cleared by Pcbnew.
Fix highlight not cleared by Cvpcb (missing code).
Add comments. Remove a few now useless printf used for debug
When clicking on a empty area, clear any highligthed symbols

Fixes: lp:1809977
https://bugs.launchpad.net/kicad/+bug/1809977
This commit is contained in:
jean-pierre charras 2018-12-29 09:39:08 +01:00
parent ad0d9f8df0
commit fb35a7c8b4
8 changed files with 44 additions and 21 deletions

View File

@ -274,6 +274,10 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
m_modified = false; m_modified = false;
// clear highlight symbol in schematic:
SendMessageToEESCHEMA( true );
// Delete window
Destroy(); Destroy();
} }
@ -717,22 +721,35 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles()
} }
void CVPCB_MAINFRAME::SendMessageToEESCHEMA() void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
{ {
if( m_netlist.IsEmpty() ) if( m_netlist.IsEmpty() )
return; return;
// clear highlight of previously selected components (if any):
// Selecting a non existing symbol clears any previously highlighted symbols
std::string packet = "$PART: \"$DUMMY$\"";
if( Kiface().IsSingle() )
SendCommand( MSG_TO_SCH, packet.c_str() );
else
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
if( aClearHighligntOnly )
return;
int selection = m_compListBox->GetSelection(); int selection = m_compListBox->GetSelection();
if ( selection < 0 ) if ( selection < 0 ) // Nothing selected
selection = 0; return;
if( m_netlist.GetComponent( selection ) == NULL ) if( m_netlist.GetComponent( selection ) == NULL )
return; return;
// Now highlight the selected component:
COMPONENT* component = m_netlist.GetComponent( selection ); COMPONENT* component = m_netlist.GetComponent( selection );
std::string packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) ); packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) );
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
SendCommand( MSG_TO_SCH, packet.c_str() ); SendCommand( MSG_TO_SCH, packet.c_str() );

View File

@ -288,8 +288,10 @@ public:
* Send a remote command to Eeschema via a socket, * Send a remote command to Eeschema via a socket,
* Commands are * Commands are
* $PART: "reference" put cursor on component anchor * $PART: "reference" put cursor on component anchor
* @param aClearHighligntOnly = true if the message to send is only "clear highlight"
* (used when exiting Cvpcb)
*/ */
void SendMessageToEESCHEMA(); void SendMessageToEESCHEMA( bool aClearHighligntOnly = false );
COMPONENT* GetSelectedComponent(); COMPONENT* GetSelectedComponent();

View File

@ -108,8 +108,9 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
/* look for a complement */ /* look for a complement */
idcmd = strtok( NULL, " \n\r" ); idcmd = strtok( NULL, " \n\r" );
if( idcmd == NULL ) // component only if( idcmd == NULL ) // Highlight component only (from Cvpcb or Pcbnew)
{ {
// Highlight component part_ref, or clear Highlight, if part_ref is not existing
FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString ); FindComponentAndItem( part_ref, true, FIND_COMPONENT_ONLY, wxEmptyString );
return; return;
} }

View File

@ -235,12 +235,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
SetStatusText( msg ); SetStatusText( msg );
if( foundItem ) // highlight selection if foundItem is not null, or clear any highlight selection
{
// highlight selection
GetCanvas()->GetView()->HighlightItem( foundItem, pin ); GetCanvas()->GetView()->HighlightItem( foundItem, pin );
GetCanvas()->Refresh(); GetCanvas()->Refresh();
}
return item; return item;
} }

View File

@ -62,10 +62,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{ {
SCH_ITEM* item = GetScreen()->GetCurItem(); SCH_ITEM* item = GetScreen()->GetCurItem();
wxPoint gridPosition = GetGridPosition( aPosition ); wxPoint gridPosition = GetGridPosition( aPosition );
DBG(printf("mousep %d %d gridp %d %d\n", aPosition.x, aPosition.y, gridPosition.x, gridPosition.y );)
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) ||
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->GetFlags() ) ) ( item && ( item->GetFlags() & ~HIGHLIGHTED ) ) )
{ {
m_canvas->SetAutoPanRequest( false ); m_canvas->SetAutoPanRequest( false );
SetRepeatItem( NULL ); SetRepeatItem( NULL );
@ -108,6 +107,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
} }
} }
if( !item ) // If clicked on a empty area, clear any highligthed symbol
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -48,6 +48,7 @@
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <sch_view.h>
#include <iostream> #include <iostream>
@ -76,7 +77,9 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
bool blockActive = GetScreen()->IsBlockActive(); bool blockActive = GetScreen()->IsBlockActive();
wxString msg; wxString msg;
DBG(printf("on-rclick cur %p blk %d\n", item, blockActive ? 1 : 0 );) // Ugly hack, clear any highligthed symbol, because the HIGHLIGHT flag create issues when creating menus
// Will be fixed later
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
// Do not start a block command on context menu. // Do not start a block command on context menu.
m_canvas->SetCanStartBlock( -1 ); m_canvas->SetCanStartBlock( -1 );
@ -142,9 +145,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
bool actionCancelled = false; bool actionCancelled = false;
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled ); item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
printf("Locateandshow %d %d item %p type %d\n", aPosition.x, aPosition.y,
item, item ? item->Type() : 0 ); fflush(0);
// If the clarify item selection context menu is aborted, don't show the context menu. // If the clarify item selection context menu is aborted, don't show the context menu.
if( item == NULL && actionCancelled ) if( item == NULL && actionCancelled )
return false; return false;

View File

@ -93,7 +93,11 @@ public:
void ShowSelectionArea( bool aShow = true ); void ShowSelectionArea( bool aShow = true );
void ShowPreview( bool aShow = true ); void ShowPreview( bool aShow = true );
/**
* Clear the hide flag of all items in the view
*/
void ClearHiddenFlags(); void ClearHiddenFlags();
void HideWorksheet(); void HideWorksheet();
void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr ); void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr );