Commit a6917280 authored by Maciej Suminski's avatar Maciej Suminski

Added net highlighting.

parent 9a84944f
......@@ -109,6 +109,26 @@ public:
return ( m_activeLayers.count( aLayerId ) > 0 );
}
/**
* Function GetHighlight
* Returns current highlight setting.
* @return True if highlight is enabled, false otherwise.
*/
bool GetHighlight() const
{
return m_highlightEnabled;
}
/**
* Function GetHighlightNetCode
* Returns netcode of currently highlighted net.
* @return Netcode of currently highlighted net.
*/
int GetHighlightNetCode() const
{
return m_highlightNetcode;
}
/**
* Function SetHighlight
* Turns on/off highlighting - it may be done for the active layer or the specified net.
......@@ -119,9 +139,7 @@ public:
inline void SetHighlight( bool aEnabled, int aNetcode = -1 )
{
m_highlightEnabled = aEnabled;
if( aNetcode > 0 )
m_highlightNetcode = aNetcode;
m_highlightNetcode = aNetcode;
}
/**
......
......@@ -112,10 +112,17 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
// single click? Select single object
else if( evt->IsClick( BUT_LEFT ) )
{
if( !m_additive )
clearSelection();
if( evt->Modifier( MD_CTRL ) )
{
highlightNet( evt->Position() );
}
else
{
if( !m_additive )
clearSelection();
selectSingle( evt->Position() );
selectSingle( evt->Position() );
}
}
// right click? if there is any object - show the context menu
......@@ -650,6 +657,30 @@ 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 = getEditFrame<PCB_EDIT_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>( PCB_T ), 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();
}
}
void SELECTION_TOOL::SELECTION::clear()
{
items.ClearItemsList();
......
......@@ -221,6 +221,14 @@ private:
*/
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 );
/// Visual representation of selection box
SELECTION_AREA* m_selArea;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment