Infrastructure for net hiding
LoadProjectSettings changed to take place after the board has been loaded so that board-specific project settings can be applied (such as net visibility and color overrides)
This commit is contained in:
parent
282fcd5f3c
commit
afd432e687
|
@ -177,6 +177,8 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
|||
}
|
||||
},
|
||||
{} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( "hidden_nets", &m_HiddenNets, {} ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,12 @@ public:
|
|||
*/
|
||||
std::map<wxString, KIGFX::COLOR4D> m_PcbNetColors;
|
||||
|
||||
/**
|
||||
* A list of netnames that have been manually hidden in the board editor.
|
||||
* Currently, hiding nets means hiding the ratsnest for those nets.
|
||||
*/
|
||||
std::vector<wxString> m_HiddenNets;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Parses a bus vector (e.g. A[7..0]) into name, begin, and end.
|
||||
|
|
|
@ -528,9 +528,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
mgr->LoadProject( pro.GetFullPath() );
|
||||
}
|
||||
|
||||
// load project settings before BOARD
|
||||
LoadProjectSettings();
|
||||
}
|
||||
|
||||
if( is_new )
|
||||
|
@ -648,6 +645,9 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
GetBoard()->BuildConnectivity();
|
||||
Compile_Ratsnest( true );
|
||||
|
||||
// Load project settings after setting up board; some of them depend on the nets list
|
||||
LoadProjectSettings();
|
||||
|
||||
onBoardLoaded();
|
||||
|
||||
// Refresh the 3D view, if any
|
||||
|
|
|
@ -218,9 +218,16 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOption
|
|||
}
|
||||
|
||||
|
||||
void PCB_RENDER_SETTINGS::LoadNetSettings( const NET_SETTINGS& aSettings )
|
||||
void PCB_RENDER_SETTINGS::LoadNetSettings( const NET_SETTINGS& aSettings,
|
||||
const NETINFO_LIST& aList )
|
||||
{
|
||||
m_netColors = aSettings.m_PcbNetColors;
|
||||
m_netColors.clear();
|
||||
|
||||
for( const auto& pair : aSettings.m_PcbNetColors )
|
||||
{
|
||||
if( NETINFO_ITEM* net = aList.GetNetItem( pair.first ) )
|
||||
m_netColors[net->GetNet()] = pair.second;
|
||||
}
|
||||
|
||||
m_netclassColors.clear();
|
||||
|
||||
|
@ -229,6 +236,14 @@ void PCB_RENDER_SETTINGS::LoadNetSettings( const NET_SETTINGS& aSettings )
|
|||
if( pair.second->GetPcbColor() != COLOR4D::UNSPECIFIED )
|
||||
m_netclassColors[pair.first] = pair.second->GetPcbColor();
|
||||
}
|
||||
|
||||
m_hiddenNets.clear();
|
||||
|
||||
for( const wxString& hidden : aSettings.m_HiddenNets )
|
||||
{
|
||||
if( NETINFO_ITEM* net = aList.GetNetItem( hidden ) )
|
||||
m_hiddenNets.insert( net->GetNet() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,8 +315,8 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
|
|||
// Apply net color overrides
|
||||
if( conItem && m_netColorMode == NET_COLOR_MODE::ALL )
|
||||
{
|
||||
if( m_netColors.count( conItem->GetNetname() ) )
|
||||
return m_netColors.at( conItem->GetNetname() );
|
||||
if( m_netColors.count( conItem->GetNetCode() ) )
|
||||
return m_netColors.at( conItem->GetNetCode() );
|
||||
else if( m_netclassColors.count( conItem->GetNetClassName() ) )
|
||||
return m_netclassColors.at( conItem->GetNetClassName() );
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ class DIMENSION;
|
|||
class PCB_TARGET;
|
||||
class MARKER_PCB;
|
||||
class NET_SETTINGS;
|
||||
class NETINFO_LIST;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
|
@ -107,8 +108,9 @@ public:
|
|||
/**
|
||||
* Loads net-specific render settings
|
||||
* @param aSettings is the NET_SETTINGS for the current proejct
|
||||
* @param aList is the list of nets in the board
|
||||
*/
|
||||
void LoadNetSettings( const NET_SETTINGS& aSettings );
|
||||
void LoadNetSettings( const NET_SETTINGS& aSettings, const NETINFO_LIST& aList );
|
||||
|
||||
virtual void LoadColors( const COLOR_SETTINGS* aSettings ) override;
|
||||
|
||||
|
@ -185,7 +187,10 @@ public:
|
|||
|
||||
std::map<wxString, KIGFX::COLOR4D>& GetNetclassColorMap() { return m_netclassColors; }
|
||||
|
||||
std::map<wxString, KIGFX::COLOR4D>& GetNetColorMap() { return m_netColors; }
|
||||
std::map<int, KIGFX::COLOR4D>& GetNetColorMap() { return m_netColors; }
|
||||
|
||||
std::set<int>& GetHiddenNets() { return m_hiddenNets; }
|
||||
const std::set<int>& GetHiddenNets() const { return m_hiddenNets; }
|
||||
|
||||
protected:
|
||||
///> Flag determining if items on a given layer should be drawn as an outline or a filled item
|
||||
|
@ -238,8 +243,11 @@ protected:
|
|||
///> Overrides for specific netclass colors
|
||||
std::map<wxString, KIGFX::COLOR4D> m_netclassColors;
|
||||
|
||||
///> Overrides for specific net colors
|
||||
std::map<wxString, KIGFX::COLOR4D> m_netColors;
|
||||
///> Overrides for specific net colors, stored as netcodes for the ratsnest to access easily
|
||||
std::map<int, KIGFX::COLOR4D> m_netColors;
|
||||
|
||||
///> Set of net codes that should not have their ratsnest displayed
|
||||
std::set<int> m_hiddenNets;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ bool PCB_EDIT_FRAME::LoadProjectSettings()
|
|||
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
||||
GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
||||
|
||||
rs->LoadNetSettings( project.NetSettings() );
|
||||
rs->LoadNetSettings( project.NetSettings(), GetBoard()->GetNetInfo() );
|
||||
|
||||
PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
|
||||
|
||||
|
|
|
@ -81,15 +81,19 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
|||
|
||||
bool colorByNet = rs->GetNetColorMode() != PCB_RENDER_SETTINGS::NET_COLOR_MODE::OFF;
|
||||
|
||||
std::set<int> highlightedNets = rs->GetHighlightNetCodes();
|
||||
std::set<int> highlightedNets = rs->GetHighlightNetCodes();
|
||||
const std::set<int>& hiddenNets = rs->GetHiddenNets();
|
||||
|
||||
gal->SetStrokeColor( color.Brightened(0.5) );
|
||||
|
||||
const bool curved_ratsnest = rs->GetCurvedRatsnestLinesEnabled();
|
||||
|
||||
// Draw the "dynamic" ratsnest (i.e. for objects that may be currently being moved)
|
||||
for( const auto& l : m_data->GetDynamicRatsnest() )
|
||||
for( const RN_DYNAMIC_LINE& l : m_data->GetDynamicRatsnest() )
|
||||
{
|
||||
if( hiddenNets.count( l.netCode ) )
|
||||
continue;
|
||||
|
||||
if ( l.a == l.b )
|
||||
{
|
||||
gal->DrawLine( VECTOR2I( l.a.x - CROSS_SIZE, l.a.y - CROSS_SIZE ),
|
||||
|
@ -116,6 +120,9 @@ void RATSNEST_VIEWITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
|||
|
||||
for( int i = 1 /* skip "No Net" at [0] */; i < m_data->GetNetCount(); ++i )
|
||||
{
|
||||
if( hiddenNets.count( i ) )
|
||||
continue;
|
||||
|
||||
RN_NET* net = m_data->GetRatsnestForNet( i );
|
||||
|
||||
if( !net )
|
||||
|
|
Loading…
Reference in New Issue