Net highlighting is moved to a separate TOOL_ACTION.
This commit is contained in:
parent
c636c4e735
commit
ac10ca40f8
|
@ -383,6 +383,10 @@ TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_MODULE ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_MODULE ),
|
||||||
_( "Add modules" ), _( "Add modules" ), NULL, AF_ACTIVATE );
|
_( "Add modules" ), _( "Add modules" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
|
TOOL_ACTION COMMON_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
"", "" );
|
||||||
|
|
||||||
|
|
||||||
// Module editor tools
|
// Module editor tools
|
||||||
TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
|
TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
|
||||||
|
|
|
@ -270,6 +270,7 @@ public:
|
||||||
static TOOL_ACTION resetCoords;
|
static TOOL_ACTION resetCoords;
|
||||||
static TOOL_ACTION switchCursor;
|
static TOOL_ACTION switchCursor;
|
||||||
static TOOL_ACTION switchUnits;
|
static TOOL_ACTION switchUnits;
|
||||||
|
static TOOL_ACTION highlightNet;
|
||||||
static TOOL_ACTION showHelp;
|
static TOOL_ACTION showHelp;
|
||||||
static TOOL_ACTION toBeDone;
|
static TOOL_ACTION toBeDone;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "selection_tool.h"
|
#include "selection_tool.h"
|
||||||
|
|
||||||
|
#include <painter.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <class_mire.h>
|
#include <class_mire.h>
|
||||||
#include <ratsnest_data.h>
|
#include <ratsnest_data.h>
|
||||||
|
#include <collectors.h>
|
||||||
|
|
||||||
#include <view/view_group.h>
|
#include <view/view_group.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
|
@ -466,6 +468,47 @@ int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function highlightNet()
|
||||||
|
* Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it enables
|
||||||
|
* highlight for its net.
|
||||||
|
* @param aPoint is the point where an item is expected (world coordinates).
|
||||||
|
*/
|
||||||
|
static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
|
||||||
|
{
|
||||||
|
KIGFX::RENDER_SETTINGS* render = aToolMgr->GetView()->GetPainter()->GetSettings();
|
||||||
|
GENERAL_COLLECTORS_GUIDE guide = static_cast<PCB_BASE_FRAME*>( aToolMgr->GetEditFrame() )->GetCollectorsGuide();
|
||||||
|
BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
|
||||||
|
GENERAL_COLLECTOR collector;
|
||||||
|
int net = -1;
|
||||||
|
|
||||||
|
// Find a connected item for which we are going to highlight a net
|
||||||
|
collector.Collect( board, GENERAL_COLLECTOR::PadsTracksOrZones,
|
||||||
|
wxPoint( aPosition.x, aPosition.y ), guide );
|
||||||
|
bool enableHighlight = ( collector.GetCount() > 0 );
|
||||||
|
|
||||||
|
// Obtain net code for the clicked item
|
||||||
|
if( enableHighlight )
|
||||||
|
net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
|
||||||
|
|
||||||
|
if( enableHighlight != render->GetHighlight() || net != render->GetHighlightNetCode() )
|
||||||
|
{
|
||||||
|
render->SetHighlight( enableHighlight, net );
|
||||||
|
aToolMgr->GetView()->UpdateAllLayersColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDITOR_CONTROL::SetTransitions()
|
void PCB_EDITOR_CONTROL::SetTransitions()
|
||||||
{
|
{
|
||||||
// Track & via size control
|
// Track & via size control
|
||||||
|
@ -484,7 +527,9 @@ void PCB_EDITOR_CONTROL::SetTransitions()
|
||||||
Go( &PCB_EDITOR_CONTROL::PlaceTarget, COMMON_ACTIONS::placeTarget.MakeEvent() );
|
Go( &PCB_EDITOR_CONTROL::PlaceTarget, COMMON_ACTIONS::placeTarget.MakeEvent() );
|
||||||
Go( &PCB_EDITOR_CONTROL::PlaceModule, COMMON_ACTIONS::placeModule.MakeEvent() );
|
Go( &PCB_EDITOR_CONTROL::PlaceModule, COMMON_ACTIONS::placeModule.MakeEvent() );
|
||||||
|
|
||||||
|
// Other
|
||||||
Go( &PCB_EDITOR_CONTROL::SelectionCrossProbe, SELECTION_TOOL::SelectedEvent );
|
Go( &PCB_EDITOR_CONTROL::SelectionCrossProbe, SELECTION_TOOL::SelectedEvent );
|
||||||
|
Go( &PCB_EDITOR_CONTROL::HighlightNet, COMMON_ACTIONS::highlightNet.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,9 @@ public:
|
||||||
///> Notifies eeschema about the selected item.
|
///> Notifies eeschema about the selected item.
|
||||||
int SelectionCrossProbe( const TOOL_EVENT& aEvent );
|
int SelectionCrossProbe( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
///> Highlights net belonging to the item under the cursor.
|
||||||
|
int HighlightNet( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
///> Sets up handlers for various events.
|
///> Sets up handlers for various events.
|
||||||
void SetTransitions();
|
void SetTransitions();
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( evt->Modifier( MD_CTRL ) && !m_editModules )
|
if( evt->Modifier( MD_CTRL ) && !m_editModules )
|
||||||
{
|
{
|
||||||
highlightNet( evt->Position() );
|
m_toolMgr->RunAction( COMMON_ACTIONS::highlightNet, true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1004,30 +1004,6 @@ bool SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SELECTION_TOOL::highlightNet( const VECTOR2I& aPoint )
|
|
||||||
{
|
|
||||||
KIGFX::RENDER_SETTINGS* render = getView()->GetPainter()->GetSettings();
|
|
||||||
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
|
|
||||||
GENERAL_COLLECTOR collector;
|
|
||||||
int net = -1;
|
|
||||||
|
|
||||||
// Find a connected item for which we are going to highlight a net
|
|
||||||
collector.Collect( getModel<BOARD>(), GENERAL_COLLECTOR::PadsTracksOrZones,
|
|
||||||
wxPoint( aPoint.x, aPoint.y ), guide );
|
|
||||||
bool enableHighlight = ( collector.GetCount() > 0 );
|
|
||||||
|
|
||||||
// Obtain net code for the clicked item
|
|
||||||
if( enableHighlight )
|
|
||||||
net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
|
|
||||||
|
|
||||||
if( enableHighlight != render->GetHighlight() || net != render->GetHighlightNetCode() )
|
|
||||||
{
|
|
||||||
render->SetHighlight( enableHighlight, net );
|
|
||||||
getView()->UpdateAllLayersColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static double calcArea( BOARD_ITEM* aItem )
|
static double calcArea( BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
switch( aItem -> Type() )
|
switch( aItem -> Type() )
|
||||||
|
|
|
@ -294,14 +294,6 @@ private:
|
||||||
*/
|
*/
|
||||||
bool selectionContains( const VECTOR2I& aPoint ) const;
|
bool selectionContains( const VECTOR2I& aPoint ) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Function highlightNet()
|
|
||||||
* Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it enables
|
|
||||||
* highlight for its net.
|
|
||||||
* @param aPoint is the point where an item is expected (world coordinates).
|
|
||||||
*/
|
|
||||||
void highlightNet( const VECTOR2I& aPoint );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function guessSelectionCandidates()
|
* Function guessSelectionCandidates()
|
||||||
* Tries to guess best selection candidates in case multiple items are clicked, by
|
* Tries to guess best selection candidates in case multiple items are clicked, by
|
||||||
|
|
Loading…
Reference in New Issue