diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 89c02ae182..a5422dde8b 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -274,6 +274,10 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) m_modified = false; + // clear highlight symbol in schematic: + SendMessageToEESCHEMA( true ); + + // Delete window Destroy(); } @@ -717,22 +721,35 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() } -void CVPCB_MAINFRAME::SendMessageToEESCHEMA() +void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly ) { if( m_netlist.IsEmpty() ) 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(); - if ( selection < 0 ) - selection = 0; + if ( selection < 0 ) // Nothing selected + return; if( m_netlist.GetComponent( selection ) == NULL ) return; + // Now highlight the selected component: 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() ) SendCommand( MSG_TO_SCH, packet.c_str() ); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index ab97978b75..8e2bc3e525 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -288,8 +288,10 @@ public: * Send a remote command to Eeschema via a socket, * Commands are * $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(); diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 40734eac47..d0da2c80f9 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -108,8 +108,9 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) /* look for a complement */ 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 ); return; } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index b7eb260a31..83f645b67b 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -235,12 +235,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, SetStatusText( msg ); - if( foundItem ) - { - // highlight selection - GetCanvas()->GetView()->HighlightItem( foundItem, pin ); - GetCanvas()->Refresh(); - } + // highlight selection if foundItem is not null, or clear any highlight selection + GetCanvas()->GetView()->HighlightItem( foundItem, pin ); + GetCanvas()->Refresh(); return item; } diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index b27db82bb4..9cbac64f10 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -62,10 +62,9 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) { SCH_ITEM* item = GetScreen()->GetCurItem(); 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 ) || ( item && item->GetFlags() ) ) + if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || + ( item && ( item->GetFlags() & ~HIGHLIGHTED ) ) ) { m_canvas->SetAutoPanRequest( false ); 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() ) { case ID_NO_TOOL_SELECTED: diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index b6efb49592..273547635a 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * 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 * modify it under the terms of the GNU General Public License @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -76,7 +77,9 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) bool blockActive = GetScreen()->IsBlockActive(); 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. m_canvas->SetCanStartBlock( -1 ); @@ -142,9 +145,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) bool actionCancelled = false; 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( item == NULL && actionCancelled ) return false; diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 2a79eb1f41..2e5da60a0c 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -190,7 +190,7 @@ void SCH_VIEW::HideWorksheet() void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin ) { - if(! aItem ) + if( !aItem ) { for( auto item : *m_allItems ) { diff --git a/eeschema/sch_view.h b/eeschema/sch_view.h index 6321476ba8..12695199c4 100644 --- a/eeschema/sch_view.h +++ b/eeschema/sch_view.h @@ -93,7 +93,11 @@ public: void ShowSelectionArea( bool aShow = true ); void ShowPreview( bool aShow = true ); + /** + * Clear the hide flag of all items in the view + */ void ClearHiddenFlags(); + void HideWorksheet(); void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr );