Added net highlighting.
This commit is contained in:
parent
9a84944fba
commit
a6917280fe
|
@ -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,8 +139,6 @@ public:
|
|||
inline void SetHighlight( bool aEnabled, int aNetcode = -1 )
|
||||
{
|
||||
m_highlightEnabled = aEnabled;
|
||||
|
||||
if( aNetcode > 0 )
|
||||
m_highlightNetcode = aNetcode;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,12 +111,19 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
|
||||
// single click? Select single object
|
||||
else if( evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
if( evt->Modifier( MD_CTRL ) )
|
||||
{
|
||||
highlightNet( evt->Position() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !m_additive )
|
||||
clearSelection();
|
||||
|
||||
selectSingle( evt->Position() );
|
||||
}
|
||||
}
|
||||
|
||||
// right click? if there is any object - show the context menu
|
||||
else if( evt->IsClick( BUT_RIGHT ) )
|
||||
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue