63 std::unique_lock<KISPINLOCK> lock(
m_data->GetLock(), std::try_to_lock );
68 constexpr int CROSS_SIZE = 200000;
70 auto gal = aView->
GetGAL();
72 gal->SetIsFill(
false );
73 gal->SetLineWidth( 1.0 );
82 const std::set<int>& hiddenNets = rs->GetHiddenNets();
87 const bool dimStatic =
m_data->GetLocalRatsnest().size() > 0 || highlightedNets.size() > 0;
89 std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
90 std::map<wxString, KIGFX::COLOR4D>& ncColors = rs->GetNetclassColorMap();
91 const std::map<int, wxString>& ncMap =
m_data->GetNetclassMap();
99 visibleLayers.set( rs->GetPrimaryHighContrastLayer() );
106 visibleLayers.set( layer );
110 const bool curved_ratsnest = cfg->m_Display.m_DisplayRatsnestLinesCurved;
115 if( hiddenNets.count( l.netCode ) )
118 if( colorByNet && netColors.count( l.netCode ) )
119 color = netColors.at( l.netCode );
120 else if( colorByNet && ncMap.count( l.netCode ) && ncColors.count( ncMap.at( l.netCode ) ) )
121 color = ncColors.at( ncMap.at( l.netCode ) );
123 color = defaultColor;
125 if(
color == COLOR4D::UNSPECIFIED )
126 color = defaultColor;
128 gal->SetStrokeColor(
color.Brightened( 0.5 ).WithAlpha( std::min( 1.0,
color.a + 0.3 ) ) );
132 gal->DrawLine(
VECTOR2I( l.a.x - CROSS_SIZE, l.a.y - CROSS_SIZE ),
133 VECTOR2I( l.b.x + CROSS_SIZE, l.b.y + CROSS_SIZE ) );
134 gal->DrawLine(
VECTOR2I( l.a.x - CROSS_SIZE, l.a.y + CROSS_SIZE ),
135 VECTOR2I( l.b.x + CROSS_SIZE, l.b.y - CROSS_SIZE ) );
141 int dx = l.
b.x - l.a.x;
142 int dy = l.b.y - l.a.y;
144 l.a.y + 0.5 * dy + 0.1 * dx );
145 gal->DrawCurve( l.a, center, center, l.b );
149 gal->DrawLine( l.a, l.b );
154 for(
int i = 1 ; i <
m_data->GetNetCount(); ++i )
156 if( hiddenNets.count( i ) )
164 if( colorByNet && netColors.count( i ) )
165 color = netColors.at( i );
166 else if( colorByNet && ncMap.count( i ) && ncColors.count( ncMap.at( i ) ) )
167 color = ncColors.at( ncMap.at( i ) );
169 color = defaultColor;
171 if(
color == COLOR4D::UNSPECIFIED )
172 color = defaultColor;
178 if( highlightedNets.count( i ) )
180 color.Brightened( 0.8 ).WithAlpha( std::min( 1.0,
color.a + 0.4 ) ) );
182 gal->SetStrokeColor(
color );
186 if( !edge.IsVisible() )
189 const std::shared_ptr<const CN_ANCHOR>& sourceNode = edge.GetSourceNode();
190 const std::shared_ptr<const CN_ANCHOR>& targetNode = edge.GetTargetNode();
191 const VECTOR2I source( sourceNode->Pos() );
192 const VECTOR2I target( targetNode->Pos() );
194 if( !sourceNode->Valid() || !targetNode->Valid() )
197 bool enable = !sourceNode->GetNoLine() && !targetNode->GetNoLine();
204 if( cfg->m_Display.m_ShowGlobalRatsnest )
206 show = sourceNode->Parent()->GetLocalRatsnestVisible() &&
207 targetNode->Parent()->GetLocalRatsnestVisible();
211 show = sourceNode->Parent()->GetLocalRatsnestVisible() ||
212 targetNode->Parent()->GetLocalRatsnestVisible();
215 if( onlyVisibleLayers && show )
217 LSET sourceLayers = sourceNode->Parent()->GetLayerSet();
218 LSET targetLayers = targetNode->Parent()->GetLayerSet();
220 if( !( sourceLayers & visibleLayers ).any() ||
221 !( targetLayers & visibleLayers ).any() )
227 if ( enable && show )
229 if ( source == target )
231 gal->DrawLine(
VECTOR2I( source.
x - CROSS_SIZE, source.
y - CROSS_SIZE ),
232 VECTOR2I( source.
x + CROSS_SIZE, source.
y + CROSS_SIZE ) );
233 gal->DrawLine(
VECTOR2I( source.
x - CROSS_SIZE, source.
y + CROSS_SIZE ),
234 VECTOR2I( source.
x + CROSS_SIZE, source.
y - CROSS_SIZE ) );
240 int dx = target.
x - source.
x;
241 int dy = target.
y - source.
y;
243 source.
y + 0.5 * dy + 0.1 * dx );
244 gal->DrawCurve( source, center, center, target );
248 gal->DrawLine( source, target );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ HIDDEN
Inactive layers are hidden.
@ OFF
Net (and netclass) colors are not shown.
@ VISIBLE
Ratsnest lines are drawn to items on visible layers only.
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
A base class for most all the KiCad significant classes used in schematics and boards.
APP_SETTINGS_BASE * KifaceSettings() const
A color representation with 4 components: red, green, blue, alpha.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
LSET is a set of PCB_LAYER_IDs.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
const BOX2I ViewBBox() const override
RATSNEST_VIEW_ITEM(std::shared_ptr< CONNECTIVITY_DATA > aData)
Class that draws missing connections on a PCB.
std::shared_ptr< CONNECTIVITY_DATA > m_data
Object containing ratsnest data.
void ViewGetLayers(int aLayers[], int &aCount) const override
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Describe ratsnest for a single net.
const std::vector< CN_EDGE > & GetEdges() const
PCB_LAYER_ID
A quick note on layer IDs:
Class that computes missing connections on a PCB.
@ NOT_USED
the 3d code uses this value